akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    string S;
    cin >> S;
    if (S.back() == 's') S += "es";
    else S += "s";
    cout << S << endl;
}

















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

int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;
  --X, --Y;
  vector<vector<int>> dist(N, vector<int>(N, -1));
  for (int s = 0; s < N; ++s)
  {
    queue<int> que;
    que.push(s);
    dist[s][s] = 0;
    while (!que.empty())
    {
      auto v = que.front();
      que.pop();
      vector<int> nvs;
      //cout << nvs.size() << endl;
      if (v > 0)
        nvs.push_back(v - 1);
      if (v < N - 1)
        nvs.push_back(v + 1);
      if (v == X)
        nvs.push_back(Y);
      if (v == Y)
        nvs.push_back(X);
      //cout << nvs.size() << endl;
      for (auto nv : nvs)
      {
        if (dist[s][nv] == -1)
        {
          dist[s][nv] = dist[s][v] + 1;
          que.push(nv);
        }
      }
      //cout << nvs.size() << endl;
    }
  }
  vector<int> res(N, 0);
  for (int i = 0; i < N; ++i)
  {
    for (int j = i + 1; j < N; ++j)
      res[dist[i][j]]++;
  }
  for (int d = 1; d < N; ++d)
    cout << res[d] << endl;
}

Measured memory_bytes: 16000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func solve(N int) int {
	n := 1
	tbl := []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
	for i := 0; i < N; i++ {
		n *= tbl[i]
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for i := 0; i < n; i++ {
		x := i
		s := make([]int, N)
		skip := false
		for j := 0; j < N; j++ {
			b := x % tbl[j]
			x /= tbl[j]
			s[N-1-j] = b
			if b > N-j {
				skip = true
				break
			}
		}
		if skip {
			continue
		}

		flag := true
		max := 0
		for j := 0; j < N; j++ {
			if s[j] > j {
				flag = false
				break
			}
			if max+1 < s[j] {
				flag = false
				break
			}
			if max < s[j] {
				max = s[j]
			}
		}
		if flag == true {
			for _, v := range s {
				fmt.Fprintf(w, "%c", v+'a')
			}
			fmt.Fprintln(w)
		}
	}
	return 0
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()

	solve(N)
}


Measured memory_bytes: 9984
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskA {    
    String s;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      s = in.next();
      long ans = go(0, 0, 0);
      out.println(ans);
    }
    
    long go(int l, int r, long sum) {
      if (r >= s.length())
        return sum; 
        long ans = go(r + 1, r + 1, sum + Long.parseLong(s.substring(l, r + 1)));
        if (r + 1 < s.length())
          ans += go(l, r + 1, sum);
        return ans;
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


Measured memory_bytes: 8532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H * W) - (h * W) - (w * H) + h * w << endl;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
//In the name of Allah
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long  int
int i,j;

main()
{
   int n,i,j;
   cin>>n;
  // vector<int> v; int j=0; int a[130]={0};
   for(i=-1000;i<=1000;i++)
   {
      for(j=-1000;j<=1000;j++)
      {
          if(((i*i*i*i*i)-(j*j*j*j*j))==n)
          {
              cout<<i<<' '<<j<<endl;
             return 0;
          }
      }
   }


}


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

int main() {
  string s;
  cin >> s;
  if (s.size() < 4) {
    cout << "No" << endl;
    return 0;
  }
  string t = "YAKI";
  bool flag = true;
  for (int i = 0; i < 4; i++) {
    if (s[i] != t[i]) {
      flag = false;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    for (int i = 0; i < s.size(); i++)
    {
        s[i] = 'x';
    }

    cout << s << endl;
    
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<int> hist(N,0);
  
  for(int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
    hist.at(a.at(i) - 1)++;
    hist.at(b.at(i) - 1)++;
  }
  for(int i=0; i<N; i++)
    cout << hist.at(i) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 100100
struct BIT{
	ll bit[MAX_N+1];
	void add(int i,ll x){
		i++;
		while(i<=MAX_N){
			bit[i]+=x;
			i+=i&-i;
		}
		return;
	}
	ll sum(int i){
		i++;
		ll res=0;
		while(i>0){
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
	ll sum(int l,int r){// [l,r]
		if(l==0)return sum(r);
		else return sum(r)-sum(l-1);
	}
}bit;
int N;
P a[100100];
ll ans[100100];
vector<P> vec;
int main(){
	cin >> N;
	ll pre = 0ll;
	for(int i=0;i<N;i++){
		cin >> a[i].fi;
		a[i].sec = i;
		if(pre<a[i].fi){
			vec.pb(a[i]);
			pre = a[i].fi;
		}
	}
	sort(a,a+N);
	int k=0;
	int M = vec.size();
	for(int i=0;i<vec.size();i++){
		while(k<N&&a[k].fi<vec[i].fi){
			bit.add(a[k].sec,a[k].fi);
			k++;
		}
		ans[vec[i].sec] = bit.sum(N-1)+(ll)(N-k)*vec[i].fi;
	}
	for(int i=M-2;i>=0;i--){
		ans[vec[i+1].sec]-=ans[vec[i].sec];
	}
	for(int i=0;i<N;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 5872
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
typedef long long ll;
using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    int eat;
    if(n+l-1 <= 0) eat = n+l-1;
    else if(l >= 0) eat = l;
    else eat = 0;
    cout << (2*l+n-1)*n/2-eat << endl;
}


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

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

#define fi first
#define se second

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

    int n,x;cin>>n>>x;

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

    sort(ix.begin(),ix.end());

    map<int,int> m;

    if(ix[0]>x)m[ix[0]-x]++;

    vector<int> xx;

    for(int i=1;i<n;i++)
    {
        if(ix[i-1]<x&&x<ix[i])
        {
            xx.push_back(ix[i]-x);
            xx.push_back(x-ix[i-1]);
        }
        m[ix[i]-ix[i-1]]++;
    }
    if(ix[n-1]<x)m[x-ix[n-1]]++;

    int ans=(*m.begin()).fi;

    for(auto mm:m)
    {
        ans=gcd(ans,mm.fi);
    }

    if(xx.size()>0)ans=max(gcd(ans,xx[0]),gcd(ans,xx[1]));

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  if(str=="hi"||str=="hihi"||str=="hihihi"||str=="hihihihi"||str=="hihihihihi"){
cout<<"Yes"<<endl;
  }
else{
cout<<"No"<<endl;
}
  return 0;
}

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


int main(void)
{
	int n;
	int i, j;
	int depature;
	int arrival;
	int time[24 * 3600];
	int hour, min, sec;
	int max;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		memset(time, 0, sizeof(time));
		
		for (i = 0; i < n; i++){
			scanf("%d:%d:%d", &hour, &min, &sec);
			depature = hour * 3600 + min * 60 + sec;
			
			scanf("%d:%d:%d", &hour, &min, &sec);
			arrival = hour * 3600 + min * 60 + sec;

			for (j = depature; j < arrival; j++){
				time[j]++;
			}

		}
		
		max = 0;
		for (i = 0; i < 24 * 3600; i++){
			if (max < time[i]){
				max = time[i];
			}
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}
	

Measured memory_bytes: 944
# -*- coding: utf-8 -*-
from operator import itemgetter
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

res = 0
ab.sort(key=itemgetter(1))

i = 0
while i<m:
    a,b = ab[i]
    for j in range(i+1,m):
        if ab[j][0]<b<=ab[j][1]:
            i += 1
        else:
            break
    i += 1
    res += 1

print(res)


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

int main(){
 
 int n;cin>>n;
 if(n%10==2 ||n%10==4 ||n%10==5 ||n%10==7 ||n%10==9){
     cout<<"hon"<<endl;
 }
 else if(n%10==0 ||n%10==1 ||n%10==6 ||n%10==8 ){
     cout<<"pon"<<endl;
 }
 else if(n%10==3){
     cout<<"bon"<<endl;
 }
    
    
    return 0;
}

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


int main() {
	int n, x;
	cin>>n;
	int maxTillNow = INT_MIN;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		cin>>x;
		if (x < maxTillNow) {
			ans += (maxTillNow - x);
		}
		maxTillNow = max(maxTillNow, x);
	}

	cout<<ans<<endl;

}


Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
d_sum = sum(A)

for i in range(N):
    if A[i] >= B[i]:
        A[i] = A[i] - B[i]
    else:
        B[i] -= A[i]
        A[i] = 0
        if A[i+1] >= B[i]:
            A[i+1] -= B[i]
            B[i] = 0
        else:
            A[i+1] = 0

print(d_sum - sum(A))

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

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

    vector<vector<long>> dp(N, vector<long>(4));

    long modulo = 1e+9 + 7;

    dp.at(0).at(0) = 1;
    dp.at(0).at(1) = 1;
    dp.at(0).at(2) = 0;
    dp.at(0).at(3) = 8;
    for (int i = 1; i < N; i++)
    {
        dp.at(i).at(0) = (dp.at(i - 1).at(0) * 9 + dp.at(i - 1).at(3)) % modulo;
        dp.at(i).at(1) = (dp.at(i - 1).at(1) * 9 + dp.at(i - 1).at(3)) % modulo;
        dp.at(i).at(2) = (dp.at(i - 1).at(2) * 10 + dp.at(i - 1).at(0) + dp.at(i - 1).at(1)) % modulo;
        dp.at(i).at(3) = (dp.at(i - 1).at(3) * 8) % modulo;
    }
    
    cout << dp.at(N-1).at(2) << endl;
    return 0;
}


Measured memory_bytes: 73476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

vector<int> loopdetect(vector<vector<ll>> &e, int s)
{
  queue<int> q;
  vector<int> ans(0), bac(siz(e), -1);
  q.push(s);
  while (!q.empty())
  {
    int now = q.front();
    q.pop();

    if (now == s && bac[now] >= 0)
    {
      break;
    }

    rep(i, siz(e[now]))
    {
      if (bac[e[now][i]] < 0)
      {
        bac[e[now][i]] = now;
        q.push(e[now][i]);
      }
    }
  }

  int now = s;
  ans.pb(s);
  while (bac[now] != s)
  {
    ans.pb(bac[now]);
    now = bac[now];
  }
  return ans;
}

signed main()
{
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> v(n, vector<ll>(0));

  rep(i, m)
  {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].pb(b);
  }

  queue<ll> q;

  ll ansind = -1, anspath = INF;
  vector<bool> used(n, false);
  rep(i, n)
  {
    q.push(i);
    q.push(0);

    while (!q.empty())
    {
      ll now = q.front();
      q.pop();
      ll l = q.front();
      q.pop();
      used[now] = true;

      if (now == i && l > 2)
      {
        if (anspath > l)
        {
          anspath = l;
          ansind = i;
        }
        break;
      }
      l++;

      rep(j, siz(v[now]))
      {
        if (v[now][j]==i || !used[v[now][j]])
        {
          q.push(v[now][j]);
          q.push(l);
        }
      }
    }

    while (!q.empty())
    {
      q.pop();
    }
    used.assign(n, false);
  }

  if (ansind == -1)
  {
    cout << -1 << endl;
    return 0;
  }

  //cout<<ansind<<endl;

  vector<int> ans = loopdetect(v, ansind);

  cout << siz(ans) << endl;

  rep(i, siz(ans))
  {
    cout << ans[i] + 1 << endl;
  }
}

Measured memory_bytes: 384
N = int(input())
L = [list(input()) for _ in range(N)]

dic = {}

for l in L[0]:
    if l in dic:
        dic[l] += 1
    else:
        dic[l] = 1
        
for i in range(N):
    tmp = {}
    for j in range(len(L[i])):
        if L[i][j] in tmp:
            tmp[L[i][j]] += 1
        else:
            tmp[L[i][j]] = 1
            
    for t in dic:
        if t in tmp:
            dic[t] = min(dic[t], tmp[t])
        else:
            dic[t] = 0
     
res_list = []
for d in dic:
    for i in range(dic[d]):
        res_list.append(d)
  
res_list.sort()
result = ''
for res in res_list:
    result += res

print(result)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define LL long long 
char d[105][105];

int main(){
    int a,b,c;
    LL H, W;
    LL ans = 1e18;
    cin >> a >> b >> c;
    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}

long long gcd(long long a, long long b)
{
	while (b != 0) {
		long long t = b;
		b = a % b;
		a = t;
	}
	return a;
}


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

	long long n, m, a, b, c, MOD = 1000003, r, ans, nn, i, j, k, p, q, pp, qq, x, d, xx, dd, xd;
	vector<long long> fact(MOD);
	fact[0] = 1;
	for (i = 1; i < MOD; i++) fact[i] = (fact[i - 1] * i) % MOD;

	cin >> qq;
	while (qq--) {
		cin >> x >> d >> n;

		if (d == 0) {
			// calculate x ^ n
			ans = 1;
			xx = x;
			for (i = 0; i < 50; i++) {
				if ((1LL << i) & n) ans = (ans * xx) % MOD;
				xx = (xx * xx) % MOD;
			}
		}
		else {
			xd = division(x, d, MOD);
			if (xd + n - 1 >= MOD)
				ans = 0;
			else {
				if (xd == 0) ans = division(fact[xd + n - 1], 1, MOD);
				else ans = division(fact[xd + n - 1], fact[xd - 1], MOD);

				// calculate d ^ n
				q = 1;
				dd = d;
				for (i = 0; i < 50; i++) {
					if ((1LL << i) & n) q = (q * dd) % MOD;
					dd = (dd * dd) % MOD;
				}
				ans = (ans * q) % MOD;
			}
		}

		cout << ans << "\n";
	}
	

	return 0;
}




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

int main()
{
	int k, n;
	cin >> n >> k;
	auto p = vector<int>(n);
	for(auto&& pp : p) cin >> pp;
	sort(p.begin(), p.end());
	int ans = 0;
	for(int i = 0; i < k; ++i){
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
  int n;
  long long int ans = 1;
  cin >> n;
  for(int i = 1;i <= n;i++){
    ans *= i;   
  }
  if(n == 0)cout << 0 << endl;
  else cout << ans << endl;
}
  

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

#define NOT_CHECK 0
#define CHECK 1

typedef struct element_ {
	int idx, val;
} element;

int element_sort(void *a, void *b) {
	return (*(element*)a).val - (*(element*)b).val;
}

int main(void) {
	int i, n, costs, m;
	int A[1005];
	int W[10005];
	int chk[1005];
	element sortedA[1005];

	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d\n", &A[i]);
		sortedA[i].idx = i;
		sortedA[i].val = A[i];
		W[A[i]] = i;
		chk[i] = NOT_CHECK;
	}

	qsort((void*)sortedA, n, sizeof(element), element_sort);

	m = sortedA[0].val;
	costs = 0;
	for(i=0;i<n;i++) {
		int p, cost, lt, cnt, t;
		p = i;

		t = 0;
		cnt = 0;
		lt = 10005;
		while(chk[p]==NOT_CHECK) {
			chk[p] = CHECK;
			t += A[p];
			cnt++;
			if(lt > A[p]) lt = A[p];
			p = W[sortedA[p].val];
		}
		if(cnt<2) continue;	// 入れ替えが発生し始めるのはcntが2以上になってから
		
		// 入れ替え中に見つかった最小値を入れ替えに使った方がコストが低いか
		// 回り道して最小の値を使って入れ替えに使った方がコストが低いか
		cost = t+m*(cnt+1)+lt;	// lt -> m ・・ m -> A[k] ・・ m -> lt
		if(cost>t+lt*(cnt-2)) cost = t+lt*(cnt-2);
		costs += cost;
	}

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

Measured memory_bytes: 676
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t R, G, B, N;
    cin >> R >> G >> B >> N;

    int64_t res = 0;
    for (size_t r = 0; r <= 3000; ++r) {
        for (size_t g = 0; g <= 3000; ++g) {
            int64_t red_num = R * r;
            int64_t green_num = G * g;
            if (red_num + green_num <= N && (N - (red_num + green_num)) % B == 0) {
                res++;
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 384
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
p = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():

    def combination(n, r, p):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n-r] % p

    N = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    x, y = nm()

    if (x + y) % 3 != 0:
        print(0)
        exit()
    
    n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
    m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

    if n < 0 or m < 0:
        print(0)
        exit()

    print(combination(n+m, n, p))

if __name__ == '__main__':
    main()

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

#define FILE                          \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

int main()
{
    //FILE;
    FIO;
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
        cout << s;
    else
    {
        string str = s.substr(0, k);
        cout << str + "...";
    }

    //system("pause");
    return 0;
}

Measured memory_bytes: 3652
def d_maximum_sum_of_minimum(N, Nodes, C):
    # 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
    import sys
    sys.setrecursionlimit(10**6)

    int_list = list(sorted(C))
    graph = [[] for _ in range(N)]
    for u, v in Nodes:  # 0-basedとする
        graph[u - 1].append(v - 1)
        graph[v - 1].append(u - 1)

    def traverse_tree(parent, current, ret=[0] * N):
        """各頂点にCの値が大きなもの順に書き込んでいく"""
        def dfs(p, c):
            ret[c] = int_list.pop()
            for next_edge in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge)
        dfs(parent, current)
        return ret
    tmp = traverse_tree(-1, 0)
    return str(sum(tmp[1:])) + '\n' + ' '.join(map(str, tmp))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
print(d_maximum_sum_of_minimum(N, Nodes, C))


Measured memory_bytes: 17816
#include <iostream>

using namespace std;

int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    if(x==y &&x !=z)
        cout << z;
    else if(x==z && y!=z)
        cout << y;
    else{
        cout << x;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    bool ok = t * (v - w) >= abs(b - a);
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}
///////////////////////////////////////////////////////////////

ll dfs(string S) {
  int N = S.size();
  if (S[1] != '[') {
    ll k = stoll(S.substr(1,N-2));
    return k / 2 + 1;
  }
  int count = 0;
  vector<ll> A;
  string t = "";
  for (int i = 1; i < N-1; i++) {
    if (S[i] == '[') count++;
    if (S[i] == ']') count--;
    t.push_back(S[i]);
    if (count == 0) {
      A.emplace_back(dfs(t));
      t = "";
    }
  }
  sort(all(A));
  ll y = 0;
  rep(i,A.size() / 2 + 1) y += A[i];
  return y;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int Q; cin >> Q;
  rep(q,Q) {
    string S; cin >> S;
    cout << dfs(S) << endl;
  }
}


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

int main(){

    int n;
    string s;
    map<string, ll> dict;

    cin >> n;
    for (int i=0; i<n; i++){
        cin >> s;
        sort(s.begin(), s.end());
        dict[s]++;        
    }

    ll cnum = 0;
    for (auto p: dict){
        auto key = p.first;
        auto value = p.second;
        cnum += (p.second*(p.second - 1))/2;
    }

    cout << cnum << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    char c; cin >> c;
    cout << ((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "vowel" : "consonant") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	long long int d;
	cin >> n >> d;
	d = d * d;
	int res = 0;
	for (int i = 0; i < n; i++) {
		long long int x, y;
		cin >> x >> y;
		if (x * x + y * y <= d) {
			res++;
		}
	}
	cout << res << endl;
}


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

int main(){
  int h,n;
  cin>>h>>n;
  long long wa=0;
  for(int i=0;i<n;i++){
    long long x;
    cin>>x;
    wa+=x;
  }
  if(h<=wa)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 前からと後ろから
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> former;
  vector<int> latter;
  auto work = [&](string S, vector<int> v, bool rev){
    int cur = 0, cnt = 0;
    while (cur < N && cnt < K) {
      if (S[cur] == 'o') {
        if (rev) {
          v.push_back(N-1-cur);
        } else {
          v.push_back(cur);
        }
        cur += C+1;
        cnt++;
        continue;
      }
      cur++;
    }
    return v;
  };
  former = work(S, former, false);
  reverse(S.begin(), S.end());
  latter = work(S, latter, true);
  sort(latter.begin(), latter.end());
  rep(i, K) {
    if (former[i] == latter[i]) {
      cout << former[i]+1 << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 5912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputs = Console.ReadLine();
            string inputt = Console.ReadLine();
            Console.WriteLine(hantei(inputs, inputt));
            Console.Read();

        }

        public static string hantei(string x, string y)
        {
            string print = "";
            string new_y = "";
            for(int i = 0; i < y.Length - 1; i++)
            {
                new_y = new_y + y[i];
            }
            if(x == new_y)
            {
                print = "Yes";
            }
            else
            {
                print = "No";
            }
            return print;
        }
    }
}


Measured memory_bytes: 25792
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int x[4] = { -1,0,1,0 };
int y[4] = { 0,1,0,-1 };
int g[4][4];
int m = 0;
bool solve(int depth, int t, int zx, int zy) {
	int c = 0;
	for (int i=0;i<4;i++) {
		for (int j=0;j<4;j++) {
			if (g[i][j] != 0) {
				int t = g[i][j]-1;
				c += abs(t / 4 - i) + abs(t % 4 - j);
			}
		}
	}
	if (c+depth>m) return false;
	if (c==0) return true;
	int dx,dy;
	for(int i=0;i<4;i++) {
		if (abs(i-t)!=2) {
			dx = zx+x[i];
			dy = zy+y[i];
			if (dx < 0 || dx == 4 || dy < 0 || dy == 4) continue;
            swap(g[dx][dy], g[zx][zy]);
            if (solve(depth + 1, i, dx, dy)) return true;
            swap(g[dx][dy], g[zx][zy]);
		}
	}
	return false;
}
int main() {
	int zx,zy;
	for (int i=0;i<4;i++) {
		for (int j=0;j<4;j++) {
			cin>>g[i][j];
			if (g[i][j]==0) {
				zx=i;zy=j;
			}
		}
	}
	for (m=0;m>=0;m++) {
		if (solve(0,9,zx,zy)) {
			cout<<m<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
import numpy as np

# 解説みた
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K, N):
    if A[i] / A[i - K] > 1:
        print("Yes")
    else:
        print("No")

"""
・書き始める前に式変形等考える
・判定分を吟味する。（実際の数、今回でいうと積、で比較しない）
"""


Measured memory_bytes: 49828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  ll n, w;
  cin >> n >> w;
  ll weight[110], value[110];
  rep(i,n) cin >> weight[i] >> value[i];
  ll dp[110][100100];
  rep(i,w+1) dp[0][i] = 0;

  rep(i,n) rep(j,w+1) {
    if (j >= weight[i]) dp[i+1][j] = max(dp[i][j-weight[i]] + value[i], dp[i][j]);
    else dp[i+1][j] = dp[i][j];
  }

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


Measured memory_bytes: 80768
#include<stdio.h>
int main( void )
{
	int n ;
	int m ;
	int sports[ 1000 ] = { 0 } ;
	int yen[ 1000 ] ,maxyen[ 1000 ] ;
	int max = 0 ,lank ;
	int i ,j ;
	scanf( "%d %d", &n , &m ) ;
	for( i = 0 ; i < n ; i++ )
	{
		scanf( "%d", &yen[ i ] ) ;
	}
	for( i = 0 ; i < m ; i++ )
	{
		scanf( "%d", &maxyen[ i ] ) ;
		for( j = 0 ; j < n ; j++ )
		{
			if( yen[ j ] <= maxyen[ i ] )
			{
				sports[ j ]++ ;
				maxyen[ i ] = -1 ;
			}
		}
	}
	for( i = 0 ; i < m ; i++ )
	{
		if( sports[ i ] > max )
		{
			max = sports[ i ] ;
			lank = i + 1 ;
		}
	}
	printf( "%d\n", lank ) ;
	return 0 ;
}

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    int a[n]; 
    long long sum = 0;
    long long min = 100000000;

    for (int  i = 0; i < n; i++){ 
        cin >> a[i];
    }
    if (n == 1){
        cout << 0 << endl;
        return 0;
    }
    sort(a, a+n);
    // cout<< a[n-1] << endl;
    for (int i = a[0]; i <= a[n-1]; i++){
        sum = 0;
        for (int j = 0; j < n; j++){
            sum += (i - a[j]) * (i - a[j]);
        }
        if (sum < min){
            min = sum;
        }

    }
    cout << min << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;
 
int n;
ll m;
int cd[5010];
ll p[2][5010][5010];
 
ll f(int b, int d) {
  if (d == 0)
    return 1;
  if (b == 0)
    return d + 1;
  while (cd[b] <= min(b, d)) {
    int c = cd[b];
    ll r = f(b - c, c);
    p[0][b][c] = r + (c > 0 ? p[0][b][c - 1] : 0);
    if (p[0][b][c] >= m)
      p[0][b][c] -= m;
    p[1][b][c] = (c * r + (c > 0 ? p[1][b][c - 1] : 0)) % m;
    cd[b]++;
  }
  ll r = (d + 1) * p[0][b][min(b, d)] - p[1][b][min(b, d)];
  return (r % m + m) % m;
}
 
ll g(int b, int d) {
  if (d == 0)
    return b * 2 + (n % 2 == 1);
  if (b == 0)
    return (d + 1) * (n % 2 == 1);
  while (cd[b] <= min(b, d)) {
    int c = cd[b];
    ll r = g(b - c, c);
    p[0][b][c] = r + (c > 0 ? p[0][b][c - 1] : 0);
    if (p[0][b][c] >= m)
      p[0][b][c] -= m;
    p[1][b][c] = (c * r + (c > 0 ? p[1][b][c - 1] : 0)) % m;
    cd[b]++;
  }
  ll r = (d + 1) * p[0][b][min(b, d)] - p[1][b][min(b, d)];
  return (r % m + m) % m;
}
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m;
  ll r = 0;
  for (int s = 1; s <= n; s++)
    r += f(s - 1, n - s);
  for (int i = 0; i < 5010; i++)
    cd[i] = 0;
  for (int s = (n - 1) / 2 + 1; s < n; s++)
    r -= g(s - 1 - (n - 1) / 2, n - s - 1);
  r = (r % m + m) % m;
  cout << r << "\n";
}

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



int main(){
  int N;
  cin>>N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=1;i<N;i++){
    if(vec.at(i-1)==vec.at(i)) sum+=1;
  }
  cout<<N-sum<<endl;
}

Measured memory_bytes: 9544
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int len = line[0];
		int k = line[1];
		long[] score = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();

		for (int i = k; i < len; i++) {
			if (score[i] > score[i - k]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 85764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    map<int,int> mp;
    int ans = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if(!mp[a]){
            ans++;
            mp[a]++;
        }else{
            ans--;
            mp[a]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import cmp_to_key
import itertools

N, T = map(int, readline().split())
m = map(int, read().split())
AB0 = []
AB1 = []
for a,b in zip(m,m):
    if a == 0:
        AB0.append(b)
    else:
        AB1.append((a,b))

def sort_func(ab0, ab1):
    a0, b0 = ab0
    a1, b1 = ab1
    return a1*(1+b0) - a0*(1+b1)

AB0.sort()
AB1.sort(key=cmp_to_key(sort_func))
AB0, AB1

def compute_0():
    INF = T + 1
    dp = [INF] * 40
    dp[0] = 0
    for a,b in AB1:
        for n in range(39, -1, -1):
            if dp[n] > T:
                continue
            x = (dp[n] + 1) * (a + 1) + b
            if x < dp[n+1]:
                dp[n+1] = x
    return dp

def compute_1():
    return [0] + list(itertools.accumulate(x + 1 for x in AB0))

dp0 = compute_0()
dp1 = compute_1()

R = len(dp1) - 1
answer = 0
for i,x in enumerate(dp0):
    if x > T:
        break
    while x + dp1[R] > T:
        R -= 1
    value = i + R
    if answer < value:
        answer = value

print(answer)

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

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

  int A[3][3];
  for(int i=0; i<3; i++)
    for(int j=0; j<3; j++)
      cin>>A[i][j];

  int n;
  cin>>n;
  int B[11];
  for(int i=0; i<n; i++)cin>>B[i];

  bool C[3][3];
  memset(C, false, sizeof(C));

  for(int i=0; i<3; i++)
    for(int j=0; j<3; j++)
      for(int k=0; k<n; k++){
        if(B[k]==A[i][j])C[i][j] = true;
      }

    bool ans = false;
    for(int i=0; i<3; i++){
      bool temp = true;
      for(int j=0; j<3; j++)
        if(!C[i][j])temp = false;
      if(temp)ans = temp;
    }

    if(!ans){
      for(int j=0; j<3; j++){
        bool temp = true;
        for(int i=0; i<3; i++)
          if(!C[i][j])temp=false;
        if(temp)ans = temp;
      }
    }

    if(!ans){
      bool temp  = true;
      for(int i=0; i<3; i++)
        if(!C[i][2-i])temp = false;
      if(temp)ans = temp;
    }
    if(!ans){
      bool temp = true;
      for(int i=0; i<3; i++)
        if(!C[i][i])temp = false;
      if(temp)ans = temp;
    }

    if(ans)cout<<"Yes\n";
    else cout<<"No\n";

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;

bool oddDigits(int num) {
  if(num / 10 == 0) return true;
  elif(num / 100 == 0) return false;
  elif(num / 1000 == 0) return true;
  elif(num / 10000 == 0) return false;
  elif(num / 100000 == 0) return true;
  else return false;
}

int main() {
  io();
  
  cin >> N;
  
  int ret = 0;
  
  foris(i, 1, N+1) {
    if(oddDigits(i)) ++ret;
  }
  
  cout << ret;
  
  return 0;
}

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


int main()
{
    /*
    string s;
    cin>>s;
    bool flag = 0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==s[i+1])
        {
            flag = 1;
        }
    }
    if(flag)
    {
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
    */
    int n,l;
    cin>>n>>l;
    vector <int> a(n);
    int sum=0;
    int minv=1000;
    int key=0;
    for(int i=0;i<n;i++)
    {
        a[i]=l+i;
        if(minv>abs(a[i]))
        {
            minv = abs(a[i]);
            key = a[i];
        }
        sum+=l+i;
    }

    
    
    cout<<sum-key<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n, s = map(int, input().split())
aaa = list(map(int, input().split()))

fwd_acc = np.zeros((n + 1, s + 1), dtype=np.int64)
fwd_acc[0][0] = 1

ans = 0
MOD = 998244353
for i, a in enumerate(aaa, start=1):
    fwd_acc[i] = fwd_acc[i - 1]
    fwd_acc[i][0] = i
    if a <= s:
        fwd_acc[i][a:] = fwd_acc[i][a:] + fwd_acc[i][:-a]
    fwd_acc[i] %= MOD
    ans = (ans + fwd_acc[i][s]) % MOD
    # print(fwd_acc)
    # print(ans)
print(ans)


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int a[n+1];
    f1(i,0,n+1)
    cin>>a[i];
    int b[n];
    f1(i,0,n)
    cin>>b[i];
    int ans=0;
    f1(i,0,n)
    {
    	ans+=min(b[i],a[i]);
    	b[i]-=a[i];
    	if(b[i]>0)
    	{
    		ans+=(min(b[i],a[i+1]));
    		a[i+1]-=b[i];
    		if(a[i+1]<0)
    			a[i+1]=0;
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e3;
int N,K;
ll a[MAX_N];
ll psm[MAX_N+1];
int main(){
	cin>>N>>K;
	REP(i,N)cin>>a[i];
	REP(i,N){
		psm[i+1]=psm[i]+a[i];
	}
	multiset<ll> ms;
	REP(i,N){
		FOR(j,i,N){
			ms.insert(psm[j+1]-psm[i]);
		}
	}
	ll ans=0;
	for(int k=39;k>=0;k--){
		int cnt=0;
		for(auto i:ms){
			if ((i>>k)&1){
				cnt++;
			}
		}
		if (cnt>=K){
			for(auto ite=ms.begin();ite!=ms.end();){
				if ((((*ite)>>k)&1)==0){
					ite=ms.erase(ite);
				}else{
					ite++;
				}
			}
			ans+=(1ll<<k);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 23680
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int top, S[1000];
void push(int);
int pop();
 
int main(){
  int x, y;
  char s[100];
 
  top = 0;
 
  while(scanf("%s", s) != EOF){
    if(s[0] ==  '+'){
      x = pop();
      y = pop();
      push(x + y);
    }else if(s[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
   
  return 0;
}
 
void push(int x){
  top++;
  S[top] = x;
}
 
int pop()
{
  return S[top--];
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll x;
  ll res=0;
  cin >> x;

  res  = x/11 * 2;
  if(x%11>6) res+=2;
  else if(x%11) res++;

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	map<char,int> ct;
	for (const char ch : s)
		ct[ch]++;
	cout<<ct['1']<<endl;
 	return 0;
}


Measured memory_bytes: 256