akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    int ans = (2 * l + n - 1) * n / 2;

    if (l >= 0) {
        cout << ans - l;
    } else if (n + l - 1 <= 0) {
        cout << ans - (n + l - 1);
    } else {
        cout << ans;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int dp[110000];


int main() {
	int N; cin >> N;
	for (int i = 0; i < 110000; i++)dp[i] = N;

	dp[0] = 0;

	for (int n = 0; n < N; n++) {
		for (int i = 1; n + i <= N; i*=6) {
			dp[n + i] = min(dp[n + i], dp[n] + 1);
		}
		for (int j = 1; n + j <= N; j *= 9) {
			dp[n + j] = min(dp[n + j], dp[n] + 1);
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

long long n, k, x;

int main(){

    cin >> n >> k;

    while(n){
        n = n/k;
        x++;
    }

    cout << x;
    
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N,X=map(int, input().split())
M=[int(input()) for i in range(N)]
Y = X - sum(M)

cnt = N
cnt += (Y // min(M))
print(cnt)

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001





int main(){
    int n,m;
    cin>>n>>m;
    
    int ans = (n*(n-1)+m*(m-1))/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m, x;
cin >> n >> m >> x;
vector<ll> a(m);

rep(i, m) cin >> a[i];

sort(a.begin(), a.end());
ll l_cost=0, r_cost = 0;
rep(i,m){
    if(a[i]<x){
        l_cost++;
    }
    else{
        r_cost++;
    }
}
cout << min(l_cost, r_cost) << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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)*}
    };
}

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<_>>()
    };

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        v: [i32; n],
    }

    let mut map1 = HashMap::new();
    let mut map2 = HashMap::new();
    // Review some books.
    for i in 0..(n / 2) {
        let num1 = v[i * 2];
        let num2 = v[i * 2 + 1] ;

        // 뮤터블을 만들면 , 다른 참조(임뮤터블 포함해서)를 만들수없음
        if map1.contains_key(&num1) {
            // 인덱스 참조서 임뮤터블 참조를 만든다.
            let t = map1[&num1];
            // 여기서 map1.insert를 통해ㅓ map1를 바꿈. 뮤터블 참조가 내부에서 생김(함수 정의 확인해보면 암.) 그래서 다른 참조를 만들지 못함.
            map1.insert(num1, t + 1);
        } else {
            map1.insert(num1, 1);
        }
        if map2.contains_key(&num2) {
            let t = map2[&num2];
            map2.insert(num2, t + 1);
        } else {
            map2.insert(num2, 1);
        }
    }

    let mut max1 = 0;
    let mut maxk1 = 0;
    let mut max2 = 0;
    let mut maxk2 = 0;
    // Iterate over everything.
    for (k, v) in &map1 {
        if *v > max1 {
            max1 = *v;
            maxk1 = *k;
        }
    }
    for (k, v) in &map2 {
        if *v > max2 {
            max2 = *v;
            maxk2 = *k;
        }
    }
    use std::iter::FromIterator;

    let mut v1 = Vec::from_iter(map1);
    v1.sort_by(|&(_, a), &(_, b)| b.cmp(&a));
    let mut v2 = Vec::from_iter(map2);
    v2.sort_by(|&(_, a), &(_, b)| b.cmp(&a));

    let ans;

    if maxk2 == maxk1 {
        let (_, m1) = 
            if v1.len() < 2 {
                (0, 0)
            } else{
                v1[1]
            };

        let (_, m2) = 
            if v2.len() < 2 {
                (0, 0)
            } else{
                v2[1]
            };

        ans = std::cmp::max(max1 + m2, max2 + m1);
    } else{
        ans = max1 + max2
    }


    println!("{}", n - ans);
}


Measured memory_bytes: 12540
#include<stdio.h>
int main()
{
    int w,h,i=0,j=0;

    while(1){ scanf("%d%d",&h,&w);
    if (w==0&&h==0) break;
            for(i=0;i<1;i++)
            {
            for (j=0;j<w;j++)
                {
                    printf("#");
                }    printf("\n");
            }

          for(i=1;i<h-1;i++)
            {
            for (j=0;j<1;j++)
                {
                    printf("#");
                }
                for (j=1;j<w-1;j++)
                {
                    printf(".");
                }
                for (j=w-1;j<w;j++)
                {
                    printf("#");
                }
                 printf("\n");
            }

            for(i=h-1;i<h;i++)
            {
            for (j=0;j<w;j++)
                {
                    printf("#");
                }    printf("\n");
            }


        printf("\n");
    }
}



Measured memory_bytes: 2576
#include <cstdio>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a + b < 10)
    {
        printf("%d", a + b);
    }
     else 
     {
         printf("error");
     }
   
    
        
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
  int n;
  long mod = 1000000007;
  scanf("%d\n",&n);
  char a[n];
  int b[26];
  for(int i = 0; i < 26; ++i) b[i] = 0;
  for(int i = 0; i < n; ++i) scanf("%c",&a[i]);
  for(int i = 0; i < n; ++i){
    b[a[i] - 'a']++;
  }
  long answer = 1;
  for(int i = 0; i < 26; ++i){
    answer *= (1 + (long)b[i]);
    answer = answer % mod;
  }
  answer--;
  answer = answer % mod;
  printf("%ld\n",answer);
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli a,b,c,x,y;

	cin>>a>>b>>c>>x>>y;

	lli ans = INF;

	for(lli ab=0;ab<=2*max(x,y);ab++){
		lli abCost = c*ab;
		lli leftA = x-ab/2;
		lli leftB = y-ab/2;

		lli aCost = max(leftA*a,0LL);
		lli bCost = max(leftB*b,0LL);
		//if(DEBUG)cout<<"ab="<<ab<<"A="<<leftA<<"B="<<leftB<<"aCost="<<aCost<<" bCost="<<bCost<<endl;

		ans = min(abCost+aCost+bCost,ans);
	}
	cout<<ans<<endl;

	return 0;
}

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

int main() {
 int input,n,i,max, a;
 cin >> n;
 i=1000000000;
 max = -1000000000;
cin >> i;
 for(int r = 2; r<=n;r++){
   cin >> input;
   a = (input - i);
    if(max < a){
      max = a;
    }
    if(input < i){
      i = input;
    }
 }


 cout <<max<<endl;


}


Measured memory_bytes: 3084
#include<cstdio>
const int MaxN=200010;
int N,K,P[MaxN],pre[MaxN][2],pos[MaxN][2];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int main(){
	scanf("%d%d",&N,&K);++K;
	for(int i=0;i<N;i++){
		scanf("%d",P+i);
		pre[i+1][0]=min(i%K==0?N:pre[i][0],P[i]);
		pre[i+1][1]=max(i%K==0?0:pre[i][1],P[i]);
	}
	for(int i=N;i--;){
		pos[i][0]=i%K==0?N:min(pos[i+1][0],P[i]);
		pos[i][1]=i%K==0?0:max(pos[i+1][1],P[i]);
	}
	K--;
	int s=0,t=0,fl=0;
	for(int j=1;j<K;j++)if(P[j]<P[j-1])t++;
	for(int i=0,j=K;j<=N;i++,j++){
		if(t){
			s++;
			if(j<N&&(t+=(P[j]<P[j-1])-(P[i+1]<P[i]))&&min(pos[i][0],pre[j+1][0])==P[i]&&max(pos[i][1],pre[j+1][1])==P[j])s--;
		}
		else t+=(P[j]<P[j-1])-(P[i+1]<P[i]),fl=1;
	}
	printf("%d\n",s+fl);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 998244353
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;}
ll gcd(ll a,ll b){
    if(b==0){return a;}
    else{return gcd(b,a%b);}
}
int main(){
    ll n,x;cin>>n>>x;
    vector<ll> xvec(n);
    vector<ll> minus(n);
    rep(i,n) cin>>xvec[i];
    xvec.push_back(x);
    sort(xvec.begin(),xvec.end());

    rep(i,n) minus[i]=xvec[i+1]-xvec[i];

    if(n==1){
        cout<<abs(minus[0])<<endl;
        return 0;
    }
    ll ans=gcd(minus[0],minus[1]);
    rep(i,n-1){
        ans=gcd(ans,minus[i]);
    }

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

Measured memory_bytes: 5544
n=int(input())
l=list(map(int,input().split()))
x=0
y=0
c=0
for i in range(n):
    if(l[i]%4==0):
        x+=1
    elif(l[i]%2==0):
        y+=1
    else:
        c+=1
if(n%2==0):
    if(x>=c):
        print("Yes")
    else:
        print('No')
else:
    if(x>=(c-1)):
        print("Yes")
    else:
        print("No")


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

void solve() {
	int n; cin >> n;
	deque<int> a;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		if (i & 1)a.push_back(x);
		else a.push_front(x);
	}
	if (!(n & 1)) reverse(a.begin(), a.end());
	for (auto& x : a) {
		cout << x << ' ';
	}
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	cout << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define INFd 1010001000.0
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define double long double
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define vd vector<double>
#define vvd vector< vd >
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
//
void akari(int akane)
{
    string akaza;
    if (akane) {
        while (akane) {
            akaza.pb((akane&1)+'0');
            akane >>= 1;
        }
        reverse(all(akaza));
        cout << akaza;
    } else {
        cout << 0;
    }
}

 
signed main()
{
    Int(n);
    vi dist(n), weight(n), state(n), cost(1 << n);
    vvi line(1 << n, vi(n));
    vvd dp(1 << n, vd(n, INFd));

    rep(i, n) {
        cin >> state[i];
        cin >> dist[i] >> weight[i];
    }
    cost[0] = 0;
    Rep(i, 1 << n) {
        rep(j, n) {
            if (i & (1 << j)) {
                cost[i] += weight[j];
            }
        }
    }
    /*
    cout << "==cost=====" << endl;
    rep(i, 1 << n) {
        akari(i);
        cout << " : " << cost[i] << endl;
    }
    cout << endl;
    */
    rep(i, n) {
        dp[1 << i][i] = 0;
    }
    
    Rep(i, 1 << n) {
        rep(j, n) {
            if (i & (1 << j)) {
                rep(k, n) {
                    if (!(i & (1 << k))) {
                        double tmp = dp[i][j] + 
                            (double)(abs(dist[j]-dist[k])*(70+cost[i]*20))
                            /2000.0;
                        if (dp[i|(1 << k)][k] > tmp) {
                            dp[i|(1 << k)][k] = tmp;
                            line[i|(1 << k)][k] = j;
                        }
                    }
                }
            }
        }
    }

    /*
    cout << "===table======" << endl;
    rep(i, 1 << n) {
        akari(i);
        cout << " : ";
        rep(j, n) {
            cout << "(" << dp[i][j] << ", " << line[i][j] << ") ";
        }
        cout << endl;
    }
    cout << endl;
    */
    int ptr = 0;
    Rep(i, n) {
        if (dp[(1 << n)-1][i] < dp[(1 << n)-1][ptr]) {
            ptr = i;
        }
    }
    vi ans;
    int pos = (1 << n) - 1;
    ans.pb(ptr);
    Rep(i, n) {
        int tmp = ptr;
        ptr = line[pos][ptr];
        pos -= (1 << tmp);
        ans.pb(ptr);
    }
    reverse(all(ans));
    cout << state[ans[0]];
    Rep(i, n) {
        cout << " " << state[ans[i]];
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 16852
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin >> s;
	int c0 = 0, c1 = 0;
	int n = s.size();
	for(int i = 0;i < n;i++){
		if(i % 2 && s[i] == '1'){
			c1++;
		}else if(s[i] == '1'){
			c0++;
		}
	}
	cout << min(c0 + (n / 2) - c1, c1 + ((n + 1) / 2) - c0) << endl;
}


Measured memory_bytes: 512
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
memo = []
memo_cir = []
visited = [False] * n
index = 0
flag = True
while flag:
    if visited[index]:
        flag = False
    else:
        memo.append(index)
        visited[index] = True
        index = a[index] - 1
flag = False
for i_ in memo:
    if i_ == index:
        flag = True
    if flag:
        memo_cir.append(i_)
if k + 1 >= (len(memo) - len(memo_cir)):
    k -= (len(memo) - len(memo_cir) - 1)
    print(memo_cir[(k % len(memo_cir)) - 1] + 1)
else:
    print(memo[k] + 1)


Measured memory_bytes: 105560
#include <bits/stdc++.h>
using namespace std;
int n,XoR=0;
int arr[200002];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		XoR^=arr[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<(XoR^arr[i])<<' ';
	}
}

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

int main(){
	int N;
	long x;
	cin>>N>>x;
	long a[N];
	long ans=0;
	for(int i=0;i<N;++i)cin>>a[i];
	if(a[0]>x){
		ans+=a[0]-x;
		a[0]=x;
	}
	for(int i=1;i<N;++i){
		if(a[i-1]+a[i]>x){
			ans+=a[i]+a[i-1]-x;
			a[i]=x-a[i-1];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e3 + 10;

bool seen1[N], seen2[N];
ll dp1[N], dp2[N], a[N];
int n; ll z, w;

ll f1(int i);
ll f2(int i);

int main() {
	cin >> n >> z >> w;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	cout << f1(0);
}

ll f1(int i) {
	if (seen1[i]) {
		return dp1[i];
	}

	ll card = (i ? a[i] : w);
	seen1[i] = true;
	dp1[i] = abs(a[n] - card);
	for (int j = i + 1; j < n; ++j) {
		dp1[i] = max(dp1[i], f2(j));
	}

	return dp1[i];
}

ll f2(int i) {
	if (seen2[i]) {
		return dp2[i];
	}

	ll card = (i ? a[i] : z);
	seen2[i] = true;
	dp2[i] = abs(a[n] - card);
	for (int j = i + 1; j < n; ++j) {
		dp2[i] = min(dp2[i], f1(j));
	}

	return dp2[i];
}

Measured memory_bytes: 384
n = gets.to_i
r = 0
if n >= 10
  r += 9
else
  r = n
end

if 100 <= n && n < 1000
  r += n - 99
elsif n >= 1000
  r += 900
end

if 10000 <= n && n < 100000
  r += n - 9999
elsif n == 100000
  r += 90000
end
print r

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    int tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot += a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int best = 0;
    int j = -1;
    for (int i = n - 1; i >= -1; i--) {
        while (j + 1 < m && tot + b[j + 1] <= k) {
            j++;
            tot += b[j];
        }
        if (tot <= k) {
            best = max(best, i + j + 2);
        }
        if (i >= 0) tot -= a[i];
    }
    cout << best << '\n';

    fflush(stdout);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
// #define MOD 998244353
#define VL vector<ll>

vector<ll> dx = {-1, 1, 0,  0, -1, -1,  1, 1};
vector<ll> dy = { 0, 0, 1, -1, -1,  1, -1, 1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

	vector<P> A(N);
	vector<ll> V(N);
	REP(i, N) {
		ll T;
		cin >> T;
		A[i] = P(T, i);
		V[i] = T;
	}
	sort(ALL(A));
	ll cnt = 0;
	REP(i, N) {
		ll t = abs(i - A[i].second);
		if (t % 2 != 0) cnt++;
	}
	PRINT(cnt / 2);
	return 0;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(200002)

N,M=map(int,input().split())
mp=[[] for i in range(N+1)]
for i in range(M):
  L,R,D=map(int,input().split())
  mp[L].append([R,D])
  mp[R].append([L,-D])

dist=[None]*(N+1)

def dfs(n):
  for np,nd in mp[n]:
    if dist[np] is None:
      dist[np]=dist[n]+nd
      if not dfs(np):
        return False
    else:
      if dist[np]!=dist[n]+nd:
        return False
  return True
ans=True
for i in range(1,N+1):
  if dist[i] is None:
    dist[i]=0
    if not dfs(i):
      ans=False
      break
if ans:
  print("Yes")
else:
  print("No")


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

int main(){
  string s;
  cin>>s;
  int i=0;
  int j=s.size()-1;
  int ix=0,jx=0;
  int ans=0;
  while(i<=j){
    //cout<<"i="<<i<<" j="<<j<<" ans="<<ans<<endl;
    if(s[i]=='x'){
      ix+=1;
      i+=1;
      continue;
    }
    if(s[j]=='x'){
      jx+=1;
      j-=1;
      continue;
    }
    if(i==j){
      ans+=abs(ix-jx);
      break;
    }else if(s[i]==s[j]){
      ans+=abs(ix-jx);
      ix=0;
      jx=0;
      i+=1;
      j-=1;
      continue;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T>
T gcd(T a, T b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cd = c / gcd(c, d) * d;
    ll allc = b / c;
    ll alld = b / d;
    ll allcd = b / cd;
    ll conc = (a - 1) / c;
    ll cond = (a - 1) / d;
    ll concd = (a - 1) / cd;
    cout << (b - allc - alld + allcd) - (a - 1 - conc - cond + concd) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

//素数の真偽
vector<bool> IsPrime;

void sieve(int max)
{
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (int i = 2; i * i <= max; i++)         // 0からsqrt(max)まで調べる
        if (IsPrime[i])                        // iが素数ならば
            for (int j = 2; i * j <= max; j++) // (max以下の)iの倍数は
                IsPrime[i * j] = false;        // 素数ではない
}

int main()
{
    int q;
    int n = 100001;
    sieve(n);

    //res[i] = 0~iのうち2017に似た数の個数
    vector<int> res;
    res.push_back(0);

    cin >> q;

    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 0)
        {
            res.push_back(res[i - 1]);
        }
        else
        {
            if (IsPrime[i] && IsPrime[(i + 1) / 2])
            {
                res.push_back(res[i - 1] + 1);
            }
            else
            {
                res.push_back(res[i - 1]);
            }
        }
    }

    for (int i = 1; i <= q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << res[r] - res[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define max1 1005
#define siz 100000
#define mod 1000000007
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
vector<vector<ll> > dp(max1,vector<ll>(max1,0));
vector<vector<char> > a(max1,vector<char>(max1) );
ll h,w;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  cin>>h>>w;
  for(ll i=0;i<h;i++)
  {
    for(ll j=0;j<w;j++)
    {
      cin>>a[i][j];
    }
  }
  dp[0][0]=1;
  for(ll i=0;i<h;i++)
  {
    for(ll j=0;j<w;j++)
    {
      if(j<(w-1)&&a[i][j+1]=='.')
      {
        dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
      }
      if(i<(h-1)&&a[i+1][j]=='.')
      {
        dp[i+1][j]=(dp[i][j]+dp[i+1][j])%mod;
      }
    }
  }
  cout<<dp[h-1][w-1]<<endl;
}

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

using namespace std;


int minjumpcost(vector<int> &arr,int i,int &k,vector<int> &dp){
    int n=arr.size();
    if(i==(n-1)){
        return 0;
    }

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

    int mincost;

    mincost = abs(arr[i]-arr[i+1]) + minjumpcost(arr,i+1,k,dp);

    for(int j=2;j<=k;j++){
            if((i+j) < n){
        mincost=min(mincost,(abs(arr[i]-arr[i+j])+minjumpcost(arr,i+j,k,dp)));
            }
            else{
                break;
            }
    }

    dp[i] =  mincost;

    return dp[i];
}


int main(){

int n,k;
cin>>n>>k;
vector<int> arr(n,0);
vector<int> dp(n,-1);

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

cout<<minjumpcost(arr,0,k,dp);

return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
typedef long long ll;

int n, k;
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    ll x;
    cin >> x;
    for(ll i = -1000; i <= 1000; ++i){
        for(ll j = -1000; j <= 1000; ++j){
            if(i * i * i * i * i - j * j * j * j * j == x){
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }   

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,D,A;
    cin >> N >> D >> A;
    D *= 2;
    vector<P> mon(N);
    for(int i=0; i<N; i++){
        cin >> mon[i].first >> mon[i].second;
    }
    sort(mon.begin(),mon.end());
    queue<pair<int,ll>> que;
    ll now = 0;
    ll ans = 0;
    for(int i=0; i<N; i++){
        while(que.size() and que.front().first < mon[i].first){
            now -= que.front().second;
            que.pop();
        }
        if(now < mon[i].second){
            ll dam = ((mon[i].second - now)+A-1)/A;
            que.emplace(mon[i].first+D,dam*A);
            ans += dam;
            now += dam*A;
        }
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) { LLI res = 1; while (b > 0) { if (b & 1)res = res * a % MOD; a = a * a % MOD; b >>= 1; }return res; }

const int COMMAX = 410000;
long long fac[COMMAX], finv[COMMAX], inv[COMMAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < COMMAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();
	cout << fixed << setprecision(10);
	LLI n, k;
	cin >> n >> k;
	LLI cnt = 0;
	if (n - 1 <= k) {
		cout << COM(2 * n - 1, n - 1);
		return 0;
	}
	REP(i, k + 1) {
		cnt += (COM(n, i) * COM(n - 1, i)) % MOD;
		cnt %= MOD;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define INF 1 << 30
using namespace std;

int n, m, c[1001], d[1001], dp[1001][1001];
int main()
{
  cin >> n >> m;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= m; j++) dp[i][j] = INF;
  }
  for(int i = 1; i <= n; i++) cin >> d[i];
  for(int i = 1; i <= m; i++) cin >> c[i];

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++) dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + c[j] * d[i]);
  }

  cout << dp[n][m] << endl;
  return 0;
}

Measured memory_bytes: 4352
#B - すぬけ君の塗り絵 2 イージー

W,H,N = list(map(int,input().split()))

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

up = H
down = 0
left = 0
right = W

for l in xya:
  if l[2] == 1 and l[0] > left:
    left = l[0]
  elif l[2] == 2 and l[0] < right:
    right = l[0]
  elif l[2] == 3 and l[1] > down:
    down = l[1]
  elif l[2] == 4 and l[1] < up:
    up = l[1]
    
if left >= right or down >= up:
  area = 0
else:
  area = (up-down)*(right-left)
  
print(area)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n;
    cin >> n;
    int x[300005], y[300005];
    for(int i = 0; i < n * n; i++){
        int p;
        cin >> p;
        p--;
        x[i] = p / n;
        y[i] = p % n;
    }
    int d[503][503];
    bool b[503][503];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            b[i][j] = false;
            d[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
        }
    }
    int ans = 0;
    for(int i = 0; i < n * n; i++){
        ans += d[x[i]][y[i]];
        b[x[i]][y[i]] = true;
        queue<P> que;
        que.push(P(x[i], y[i]));
        while(que.size()){
            P p = que.front();
            que.pop();
            int u = p.first, v = p.second;
            for(int j = 0; j < 4; j++){
                int nu = u + dx[j], nv = v + dy[j];
                if(b[u][v]){
                    if(nu >= 0 && nu < n && nv >= 0 && nv < n && d[nu][nv] > d[u][v]){
                        d[nu][nv] = d[u][v];
                        que.push(P(nu, nv));
                    }
                }
                else{
                    if(nu >= 0 && nu < n && nv >= 0 && nv < n && d[nu][nv] > d[u][v] + 1){
                        d[nu][nv] = d[u][v] + 1;
                        que.push(P(nu, nv));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6824
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int64_t value[200001];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int64_t sum = 0;
	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> value[i];
		sum+= value[i];
		if (i != 0) { value[i] += value[i - 1]; }
	}
	int64_t min = 20000110000000000;
	for (int32_t i = 0; i < N-1; ++i)
	{
		min = std::min(min, std::abs(sum - value[i] - value[i]));
	}
	out << min << endl;

	return 0;
}
#endif


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

using namespace std;

typedef struct
{
	int D, P;
} Road;

class GreaterP
{
public:
	bool operator() (const Road& lhs, const Road& rhs)
	{
		return lhs.P > rhs.P;
	}
};

int main()
{
	int N, M;
	while (scanf("%d %d", &N, &M) != EOF) {
		if (N == 0 && M == 0)
			break;

		vector<Road> R(N);
		for (int i = 0; i < N; ++i)
			scanf("%d %d", &R[i].D, &R[i].P);

		sort(R.begin(), R.end(), GreaterP());

		int ans = 0;
		for (unsigned int i = 0; i < R.size(); ++i) {
			if (M < R[i].D) {
				int diff = R[i].D - M;
				ans += (diff * R[i].P);
				M = 0;
			} else {
				M -= R[i].D;
			}
		}

		printf("%d\n", ans);
	}
	return 0;
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

long long gcd(long long m, long long n) {
    
    if (m < n) std::swap(m, n);

    long long tmp;
    while (m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }

    return n;
}

long long lcm(long long m, long long n) {
    return m * n / gcd(m, n);
}


int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];

    vector<map<int, int>> vm(n);
    vector<int> vp = {2};
    for (int i = 3; i <= ceil(sqrt(1e9)); i+=2) {
        bool ok = true;
        for(auto x : vp) if (i % x == 0) {
            ok = false;break;
        }
        if (ok) vp.push_back(i);
    }

    vector<ll> lgcd(n, 0), rgcd(n, 0);
    lgcd[0] = a[0];
    rgcd[n - 1] = a[n - 1];
    for (int i = 1; i < n; i++) lgcd[i] = gcd(lgcd[i - 1], a[i]);
    for (int i = n - 2; i >= 0; i--) rgcd[i] = gcd(rgcd[i + 1], a[i]);
    
    ll ans = max(lgcd[n - 2], rgcd[1]);
    for (int i = 1; i < n - 1; i++) {
//        cout << lgcd[i - 1] << " " << rgcd[i + 1] << endl;
        ans = max(ans, gcd(lgcd[i - 1], rgcd[i + 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>

ll inv(ll a, ll b) {
	return 1 < a ? b - inv(b % a, a) * b / a : 1;
}


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;
    ll fact[max(a, b) +1];
    fact[0] = fact[1] = 1;
    for (int i = 2 ; i <= max(a, b) ; ++i)
        fact[i] = (fact[i-1]*i)%MOD;
    ll ans = (binpow(2, n, MOD)-1)%MOD, tmp1 = 1, tmp2 = 1;
    for (int i = 0 ; i < a ; ++i){
        tmp1 *= (n-i);
        tmp1 %= MOD;
    }
    for (int i = 0 ; i < b ; ++i){
        tmp2 *= (n-i);
        tmp2 %= MOD;
    }
    tmp1 = (tmp1*inv(fact[a], MOD))%MOD;
    tmp2 = (tmp2*inv(fact[b], MOD))%MOD;
    ans = (ans-tmp1-tmp2)%MOD;
    while(ans < 0)
        ans += MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
Nset = list(input())
N = Nset
N = [int(i) for i in Nset]

for i in range(2 ** 3):
    ans = N[0]
    ans_final = list(Nset[0])
    for j in range(3):
        if (i >> j) & 1:
            ans += N[j + 1]
            ans_final.append('+')
            ans_final.append(Nset[j+1])
        else:
            ans -= N[j + 1]
            ans_final.append('-')
            ans_final.append(Nset[j+1])
    if ans == 7:
        ans_final.append('=7')
        print(''.join(ans_final))
        break


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,l;
    cin>>n>>l;
    string s[n];
    rep(i,n){
        cin>>s[i];
    }
    sort(s,s+n);
    rep(i,n){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

n = list(map(int, input().split()))
n = n[0]
a = list(map(int, input().split()))

count = 0
flag = 0
for i in range(n):
    if(a[i] == 0):
        flag = 1
        break
    if(a[i]<0):
        count = 1 - count

if(count == 0 and flag==0):
    flag = 1

abss = [abs(a[i]) for i in range(n)]

if(flag==1):
    print(sum(abss))
else:
    print(sum(abss) - 2*min(abss))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[300100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    int left = 0;
    int right = 0;
    ll ans = 0;
    ll tmp = 0;
    while(right < N){
        ll a = A[right];
        bool ok = true;
        for(int k = 0; k < 20; k++){
            int tbit = (tmp >> k) & 1;
            int abit = (a >> k) & 1;
            if(tbit & abit) {
                ok = false;
                break;
            }
        }

        if(ok){
            tmp += A[right];
            right++;
            ans += right - left;
        }
        else{
            tmp -= A[left];
            left++;
        }
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
int k=0;
getline(cin,s);
cin>>k;
int r=0;
string a[250005];
for(int i=0;i<s.length();++i)
{
    
        for(int j=0;j<=k;++j)
        {
            if(i+j+1<=s.length())
            {
               a[r]=s.substr(i,j+1);
                ++r;
            }
        }
    
}
sort(a,a+r);
if(k==1)
{
    cout<<a[0];
}
else
{
int ri=1;
while(k-1)
{
    if(a[ri]!=a[ri-1])
        --k;
    ++ri;
}
cout<<a[ri-1];
}
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,a,pos;
    double ans = 99999999999.0;
    cin>>n>>t>>a;
    a+=100;
    vector<double> v;
    vector<double>::iterator it;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        double y = t - (x * 0.006);
        y+=100;
        if(abs(a-y)<=ans)
        {
            ans = abs(a-y);
            pos = i+1;
        }
    }
    cout<<pos<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	c=c-a-b;
	if(c<0) cout<<"No";
	else{
		if((long long)c*c>(long long)4*a*b) cout<<"Yes";
		else cout<<"No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  string str; cin >> str;
  int size;
  size = str.size();
  vector<int> a(26) ;
  for(int i = 0;i < size; i++) cin >> a[i];
 
  // compute 

  for(int i = 0; i < size; i++){
    if(str.at(i) == 'a') a[0] += 1;
    if(str.at(i) == 'b') a[1] += 1;
    if(str.at(i) == 'c') a[2] += 1;
    if(str.at(i) == 'd') a[3] += 1;
    if(str.at(i) == 'e') a[4] += 1;
    if(str.at(i) == 'f') a[5] += 1;
    if(str.at(i) == 'g') a[6] += 1;
    if(str.at(i) == 'h') a[7] += 1;
    if(str.at(i) == 'i') a[8] += 1;
    if(str.at(i) == 'j') a[9] += 1;
    if(str.at(i) == 'k') a[10] += 1;
    if(str.at(i) == 'l') a[11] += 1;
    if(str.at(i) == 'm') a[12] += 1;
    if(str.at(i) == 'n') a[13] += 1;
    if(str.at(i) == 'o') a[14] += 1;
    if(str.at(i) == 'p') a[15] += 1;
    if(str.at(i) == 'q') a[16] += 1;
    if(str.at(i) == 'r') a[17] += 1;
    if(str.at(i) == 's') a[18] += 1;
    if(str.at(i) == 't') a[19] += 1;
    if(str.at(i) == 'u') a[20] += 1;
    if(str.at(i) == 'v') a[21] += 1;
    if(str.at(i) == 'w') a[22] += 1;
    if(str.at(i) == 'x') a[23] += 1;
    if(str.at(i) == 'y') a[24] += 1;
    if(str.at(i) == 'z') a[25] += 1;
  }

  for(int i = 0; i < 26; i++){
      if(a[i] >= 2){
          cout << "no" << endl;
          return 0;
      }
  }
  
  // output  
  cout << "yes" << endl;
  
}

Measured memory_bytes: 3568
'use strict'

function main(s) {
  const num = s.split('\n')[0];
  const digit_sum = num.split('').map(n => Number(n)).reduce((a, b) => a + b);
  const ans = (Number(s) % digit_sum === 0) ? 'Yes' : 'No';
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> S(N);
  for (int i=0; i<N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());

  // 出力
  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string s;
  cin >> n;
  int c[26];
  fill(c, c + 26, 1e9);
  for (int i = 0; i < n; i++) {
	cin >> s;
	int b[26];
	fill(b, b + 26, 0);
	for (int j = 0; j < s.size(); j++) {
	  b[s[j] - 'a']++;
	}
	for (int j = 0; j < 26; j++) {
	  c[j] = min(c[j], b[j]);
	}
  }
  string ans;
  for (int i = 0; i < 26; i++) {
	for (int j = 0; j < c[i]; j++) {
	  ans += i + 'a';
	}
  }
  sort(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    long long A[N];
    long long B[N];
    for(int i = 0; i <N;i++)cin >> A[i] >> B[i];
    
    long long max = 0;
    int num;
    for(int i = 0; i < N;i++){
        if(max < A[i]){
            max = A[i];
            num = i;
            //cout << max <<" "<< num << endl;
        }
    }
    //cout << max <<endl;
    //cout << num <<endl;
    cout << max + B[num] <<endl;
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int maxn=222222;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,k,a[55];
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n,cmp);
    ll ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	vector<int> A(N);
	int64_t sum_a = 0;
	for(int i=0; i<N; ++i){
		cin>>A[i];
		sum_a += A[i];
	}
	int MOD = (1e9) + 7;
	int64_t ans = 0;
	for(int a:A){
		sum_a -= a;
		sum_a %= MOD;
		ans += sum_a * a % MOD;
		ans %= MOD;
	}
	cout<< (ans + MOD) % MOD <<endl;
}


Measured memory_bytes: 3976
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 200005;

int n, A[MAXN];
multiset<int, greater<int>> S;

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
        S.insert(A[i]);
    }

    for (int i = 0; i < n; i++) {
        S.erase(S.find(A[i]));
        printf("%d\n", *S.begin());
        S.insert(A[i]);
    }

    return 0;
}

Measured memory_bytes: 11776
import Data.Maybe
import qualified Data.ByteString.Char8 as B

getInts = map f . B.words <$> B.getLine
    where f = fst . fromJust . B.readInteger

solve h w d = [[f x y | x <- [1..w]] | y <- [1..h]]
    where
    f x y = c u v
        where
        g z = (z `mod` (2*d)) `div` d
        u = g (x+y)
        v = g (x-y)
        c 0 0 = 'R'
        c 0 1 = 'G'
        c 1 0 = 'B'
        c 1 1 = 'Y'
        c _ _ = 'X'

main = do
    [h, w, d] <- getInts
    mapM_ putStrLn $ solve h w d


Measured memory_bytes: 1276
#include <bits/stdc++.h>
 
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define MOD 1000000007
#define ull unsigned long long
#define foi(j, n) for(int i = j;i<n;i++)
#define foj(z, n) for(int j = z;j<n;j++)
#define FO(j, n) for(int i = j;i<=n;i++)

int main()
{
	fastio;
	int k;
	cin>>k;
	ull sum = 0;
	for(int i = 1;i<=k;i++) {
		for(int j = 1;j<=k;j++) {
			for(int l = 1;l<=k;l++) {
				sum += __gcd(i, __gcd(j, l));
			}
		}
	}
	
	cout<<sum<<"\n";
	
return 0; 
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (A, B, C) = readInputLine().split(" ").map { it.toCharArray() }
    
    if (A[A.size - 1] == B[0] && B[B.size - 1] == C[0]) {
        println("YES")
    } else {
        println("NO")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38064
n, h = map(int, input().split())
ab = [ [ int(x) for x in input().split() ] for _ in range(n) ]

ab.sort(key=lambda x: x[1], reverse=True)
max_attack = max(ab)[0]

ans = 0
for _, b in ab:
    if h <= 0:
        break
    if b > max_attack:
        h -= b
        ans += 1
    else:
        break

print( ans+max(0, (h+max_attack-1)//max_attack) )

Measured memory_bytes: 22644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, A, B; cin >> N >> A >> B;
	cout << min(N * A, B) << "\n";

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = [i-1 for i in a]
ans = b[a[0]]
for i in range(1, n):
    ans += b[a[i]]
    if a[i-1] == a[i]-1:
        ans += c[a[i-1]]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

#define MAX_N 2000
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}

int main() {
  int N, K;
  cin >> N >> K;
  make();
  REP(i, 1, K+1) {
    cout << (comb(K-1, i-1) * comb(N-K+1, i)) % mod << endl;
  }
  return 0;
}


Measured memory_bytes: 256