akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = 0
b = 0
for i in range(n):
    l = input().split()
    ls = sorted(l)
    if l[0] == l[1]:
        a += 1
        b += 1
    elif l[1] == ls[1]:
        b += 3
    else:
        a += 3
print(a, b)



Measured memory_bytes: 5600
n,*as=$<.read.split.map &:to_i
f=->i{
  t=0
  ans=0
  as.each{|e|
    t+=e
    if t*i<=0
      ans+=1+t.abs
      t=i
    end
    i=-i
  }
  ans
}
puts [f[1],f[-1]].min

Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
int main(void){
  char a[10];
  scanf("%s",a);
  int sum=0;
  for(int i=0;i<strlen(a);i++){
    char b[2];
    b[0]=a[i];
    sum+=atoi(b);
  }
  if((atoi(a)%sum)==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    while(1){
        vector<int> point;
        int n,x;
        long long sum=0;
        cin >> n;
        if(n==0)    break;
        while(n--){
            cin >> x;
            point.push_back(x);
        }
        sort(point.begin(),point.end());
        for(int i=1;i<point.size()-1;i++){
            sum+=point[i];
        }
        cout << sum/(point.size()-2) << "\n";
        point.clear();
    }
}

Measured memory_bytes: 3120
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

ll generator(
    const ll M,
    const ll N,
    const vector<vector<ll>>& row,
    vector<ll> A
) {
    ll res = 0;
    if (A.size() == N) {
        for (auto query : row) {
            ll a = query[0];
            ll b = query[1];
            ll c = query[2];
            ll d = query[3];
            if (A[b] - A[a] == c)res += d;
        }
        return res;
    }
    if (A.empty()) {
        REP(i, 1, M + 1) {
            A.push_back(i);
            res = max(res, generator(M, N, row, A));
            A.pop_back();
        }
    }
    else {
        REP(i, A.back(), M + 1) {
            A.push_back(i);
            res = max(res, generator(M, N, row, A));
            A.pop_back();
        }
    }
    return res;
}

int main()
{
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> row(Q, vector<ll>(4));
    rep(i, Q)rep(j, 4) {
        ll tmp;
        cin >> tmp;
        row[i][j] = tmp - (j < 2 ? 1 : 0);
    }

    vector<ll> A;
    cout << generator(M, N, row, A) << endl;
    return 0;
}


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

int main(){
    int N;
    string S;
    long long r=0;

    cin >> N;
    vector<long long> v(5,0);

    for(int i=0;i<N;++i){
        cin >> S;
        if (S[0] == 'M') v[0]+=1;
        else if (S[0] == 'A') v[1]+=1;
        else if (S[0] == 'R') v[2]+=1;
        else if (S[0] == 'C') v[3]+=1;
        else if (S[0] == 'H') v[4]+=1;}

    for (int i=0;i<3;++i){
        for (int j=i+1;j<4;++j){
            if (j==4) break;
            for (int k=j+1;k<5;++k){
                if (k==5) break;
                r += v[i]*v[j]*v[k];
            }
        }
    }
    cout << r << endl;}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int n = sc.nextInt();

		int[] a = new int[n];
		int md = 0;
		for ( int i=0; i<n; i++ ) {
			a[i] = sc.nextInt();
			if ( i!=0 ) {
				md = Math.max(md, a[i]-a[i-1]);
			}
		}
		md = Math.max(md, a[0]+k-a[n-1]);

		System.out.println(k-md);
	}
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(!(c < a)&& !(c > b))
		cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

count = 0

mod = 10**9+7

k.upto(n+1) do |i|
  min = i * (i-1) / 2
  max = i * (2*(n+1-i) + (i-1)) / 2
  count += (max - (min-1))
end

puts count % mod


Measured memory_bytes: 14296
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    var res = 0.0
    for (i in 1..n) {
        var den = n
        var num = i
        while (num < k) {
            den *= 2
            num *= 2
        }
        res += 1.0/den
    }

    println(res)
}

Measured memory_bytes: 36028
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    string s;
    cin>>a>>b;
    cin>>s;
    bool flag = true;
    if(s.size()!=(a+b+1)) flag = false;
    else{
        rep(i,0,s.size()-1){
            if(s[a]!='-'){
                flag = false;
                break;
            }
            if(i!=a){
                if(s[i]=='-'){
                    flag = false;
                    break;
                }
            }
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

// Segment-Tree
struct SegmentTree {
  int n;
  vector<int> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.assign(2 * n - 1, 0);
  }
  
  // i番目の値をxに更新
  void update(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] = max(dat[i], x);
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = max(dat[2 * i + 1], dat[2 * i + 2]);
    }
  }
  
  // [a, b)の最大値
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  int query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return 0;
    // eval(k); // RUQ
    if (a <= l && r <= b) return dat[k];
    else {
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return max(vl, vr);
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  SegmentTree st(310000);
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    int keep = st.query(max(0, a.at(i) - k), min(300005, a.at(i) + k + 1));
    dp[i] = keep + 1;
    st.update(a.at(i), dp[i]);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  
  cout << ans << '\n';
}

Measured memory_bytes: 9808
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a >= 9 || b >= 9)
	  	  System.out.println(":(");
                else 
	  	  System.out.println("Yay!");
	}
}

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

bool isOK(int index, int key, const vector<int> &v) {
    return v.at(index) < key;
}

int binary_search(int key, const vector<int> &v) {
    int ng = -1;
    int ok = v.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, v)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n * 3);
    for (int i = 0; i < n * 3; i++) {
        cin >> a.at(i);
    }

    map<int, int> left_map;
    long long left_sum = 0;
    for (int i = 0; i < n; i++) {
        left_sum += a.at(i);
        left_map[a.at(i)]++;
    }

    vector<pair<int, int>> sorted_right(n * 2);
    for (int i = 0; i < n * 2; i++) {
        sorted_right.at(i) = make_pair(a.at(n + i), n + i);
    }
    sort(sorted_right.begin(), sorted_right.end());

    vector<bool> used(n * 3, false);
    long long right_sum = 0;
    for (int i = 0; i < n; i++) {
        right_sum += sorted_right.at(i).first;
        used.at(sorted_right.at(i).second) = true;
    }
    int right_max_index = n;
    
    vector<bool> done(n * 3);
    long long ans = left_sum - right_sum;
    for (int i = n; i < n * 2; i++) {
        done.at(i) = true;
        if (used.at(i)) {
            right_sum -= a.at(i);
            
            while (done.at(sorted_right.at(right_max_index).second)) right_max_index++;
            
            right_sum += sorted_right.at(right_max_index).first;
            done.at(sorted_right.at(right_max_index).second) = true; 
            used.at(sorted_right.at(right_max_index).second) = true;
            right_max_index++;
        }

        auto ite = left_map.begin();
        if (ite -> first < a.at(i)) {
            left_sum -= ite -> first;
            left_sum += a.at(i);

            left_map[ite -> first]--;
            if (ite -> second == 0) left_map.erase(ite -> first); 
            left_map[a.at(i)]++;
        }

        ans = max(ans, left_sum - right_sum);
    }
    
    cout << ans << endl;
}   

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

typedef pair<int, int> P;

static const int MAX_H = 1000;
static const int MAX_W = 1000;

int H, W;
char grid[MAX_H][MAX_W + 1];
int count[MAX_H][MAX_W];

//#define OCTAS
#ifdef OCTAS
static const int dh[] = {-1, -1, -1, 0, 0, +1, +1, +1};
static const int dw[] = {-1, 0, +1, -1, +1, -1, 0, +1};
#else
static const int dh[] = {-1, 0, 0, +1};
static const int dw[] = {0, -1, +1, 0};
#endif

// CAUTION!!!
// Call init_count() first!!!
//
void init_count() {
  // memset(::count, -1, sizeof(::count));
  fill_n(::count[0], MAX_H * MAX_W, -1);
}

void bfs() {
  queue<P> que;
  for (int h{}; h < H; ++h) {
    for (int w{}; w < W; ++w) {
      if (grid[h][w] == '#') {
        ::count[h][w] = 0;
        que.push(P(h, w));
      }
    }
  }

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int cnt = ::count[p.first][p.second];
    ++cnt;
    for (int i = 0; i < sizeof(dh) / sizeof(int); ++i) {
      int nh = p.first + dh[i];
      int nw = p.second + dw[i];
      if (nh < 0 || nh >= H ||
          nw < 0 || nw >= W ||
          ::count[nh][nw] >= 0 ||
          grid[nh][nw] == '#')
        continue;
      ::count[nh][nw] = cnt;
      que.push(P(nh, nw));
    }
  }
}

int main() {
  init_count();
  scanf("%d%d", &H, &W);
  for (int h = 0; h < H; ++h) {
    scanf("%s", &grid[h][0]);
  }

  bfs();
  int ans{};
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if (ans < ::count[h][w])
        ans = ::count[h][w];
    }
  }

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


Measured memory_bytes: 13328
#include<iostream>

using namespace std;

int main(void)

{
    int x, y;
    cin>>x>>y;
    if(x == 1 ||x == 3 ||x == 5 ||x == 7 ||x == 8 ||x == 10 ||x == 12 ){
        if(y == 1 ||y == 3 ||y == 5 ||y == 7 ||y == 8 ||y == 10 ||y == 12 )
            cout<<"Yes\n";
        else cout<<"No\n";
    }
    else if(x == 4 ||x == 6 ||x == 9 ||x == 11){
        if((y == 4 ||y == 6 ||y == 9 ||y == 11))
            cout<<"Yes\n";
        else cout<<"No\n";

    }
    else if(x == 2 && y ==2){
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    for(int i = 0; i < 1000000; i++){

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int x,y;
int a[]={100,0,1,0,2,0,2,0,0,2,0,2,0};
signed main(){
	cin>>x>>y;
	if(a[x]==a[y])puts("Yes");
	else puts("No");
	return 0;
}

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

signed main(void){
    int a ,b, k; cin >> a >>b >>k;
    if(a < k){
        k -= a;
        a = 0;
    }else{
        a -= k;
        k = 0;
    }

    cout << a << ' ' << max((int)0,b-k) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100010][4],x[100010],f[2],g[2];
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=3;i++)
	  for(j=1;j<=n;j++)
	    scanf("%d",&a[j][i]);
      for(i=1;i<=n;i++)
      {
       x[i]=(a[i][1]-1)/3;
       if(a[i][1]==3*x[i]+1 && a[i][2]==3*x[i]+2 && a[i][3]==3*x[i]+3)x[i]++;
       else if(a[i][1]==3*x[i]+3 && a[i][2]==3*x[i]+2 && a[i][3]==3*x[i]+1)
         x[i]=-x[i]-1;
       else
         {
          printf("No\n");
          return 0;
         }
      }
      for(int i=1;i<=n;i++)
      {
          if((x[i]^i)&1)return puts("No"),0;
      }
      for(int i=1;i<=n;i++)
      {
          if(x[i]<0)f[i&1]^=1;
      }
      for(int i=1;i<=n;i++)
      {
          while(abs(x[i])!=i)
          {
              swap(x[i],x[abs(x[i])]);
              g[i&1]^=1;
          }
      }if((f[0]^g[1]) || (f[1]^g[0])) puts("No"); else puts("Yes");
	return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  cout << (n>k?k*x+(n-k)*y:n*x)<< endl;
	return 0;
}


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

void CountingSort(int *,int *,int,int);

int main(){
  int n,i,k;
  int *A;
  int *B;
  k=0;
  scanf("%d",&n);
  A = (int *)malloc(n*sizeof(int)+2);
  B = (int *)malloc(n*sizeof(int)+2);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
    if(k < A[i]) k = A[i];
  }

  CountingSort(A,B,n,k);

  for(i=1; i<=n; i++){
    if(i != 1 )printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

void CountingSort(int A[],int B[],int n,int k){
  int i,j;
  int *C;
  C =(int *)malloc(k*sizeof(int)+1);

  for(i=0; i<=k; i++) C[i]=0;

  for(j=0; j<n; j++) C[A[j]]++;

  for(i=0; i<k; i++) C[i+1] += C[i];

  for(j=n-1; j>=0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
}



Measured memory_bytes: 17404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int test=1;
	//cin>>test;
	rep(tt,test) {
		int n;
		cin>>n;
		int a[n];
		rep(i,n) cin>>a[i];
		int maxl=0;
		int len=0;
		rep(i,n-1){
			if(a[i]>=a[i+1]) {
				len++;
				if(len>maxl) maxl=len;
			}
			else len=0;
		}
		cout<<maxl<<endl;
	}
	return 0;
}


Measured memory_bytes: 4332
#define _GLIBCXX_DEBUG
#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 rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp;
  rep(i,n) mp[a[i]]=i;
  set<int> st={-1,n};
  ll ans=0;
  for(ll i=1;i<=n;i++){
    auto itr=st.upper_bound(mp[i]);
    int r=*(itr);
    int l=*(prev(itr));
    ans+=i*(r-mp[i])*(mp[i]-l);
    st.insert(mp[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 19840
def c_prison(N, M, Gate_info):
    can_pass_through = [0] * (N + 2)  # [i]: i番目のIDカードで通過できるゲートの数
    for l, r in Gate_info:
        can_pass_through[l] += 1
        can_pass_through[r + 1] -= 1
    for i in range(1, N + 1):
        can_pass_through[i + 1] += can_pass_through[i]
    return sum([1 for p in can_pass_through if p == M])

N, M = [int(i) for i in input().split()]
Gate_info = [[int(i) for i in input().split()] for j in range(M)]
print(c_prison(N, M, Gate_info))

Measured memory_bytes: 25484
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;

int main() {
	int a;
	char s[20];
	scanf("%d", &a);
	scanf("%s", s);
	if (a >= 3200) {
		printf("%s", s);
	}
	else {
		printf("red");
	}
	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    vvl dp(n+1, vl(n+1));  // dp[L][R] : a[L],…,a[R-1]の状態からはじめて2人が最適に行動したときのX-Yの値
    exrep(len, 1, n) {  // 区間の長さ
        for(ll L = 0; L + len <= n; L++) {  // 区間[L,R)の左
            ll R = L + len;  // 区間[L,R)の右
            if(len%2 == n%2) {  // 区間の長さともとの数列の長さの偶奇が等しいなら先手のターン
                dp[L][R] = max(dp[L+1][R] + a[L], dp[L][R-1] + a[R-1]);  // 先頭要素を取るか末尾要素を取るか
            }
            else {  // そうでなければ後手のターン
                dp[L][R] = min(dp[L+1][R] - a[L], dp[L][R-1] - a[R-1]);  // 先頭要素を取るか末尾要素を取るか
            }
        }
    }
    
    out(dp[0][n]);
    re0;
}

Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main()
{
	int f = 1, l = 4, r = 3, t = 5, b = 2, n;
	int ans;
	string com;

	while (cin >> n){
		if (n == 0) break;
		ans = 1;
	  f = 1;
	 	l = 4;
	 	r = 3;
	 	t = 5;
	 	b = 2;
		for (int i = 0; i < n; i++){
			cin >> com;
			if (com == "North"){
				t = f;
				f = b;
				b = 7 - t;
			}
			else if (com == "East"){
				r = f;
				f = l;
				l = 7 - r;
			}
			else if (com == "West"){
				l = f;
				f = r;
				r = 7 - l;
			}
			else if (com == "South"){
				b = f;
				f = t;
				t = 7 - b;
			}
			else if (com == "Right"){
				r = t;
				t = l;
				l = b;
				b = 7 - t;
			}
			else if (com == "Left"){
				r = b;
				b = l;
				l = t;
				t = 7 - b;
			}
			//cout << ans << endl;

			ans += f;
		}
		cout << ans << endl;
	}
	return (0);
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO  ios::sync_with_stdio(false); cin.tie(0);   cout.tie(0);
#define all(in) in.begin(), in.end()
typedef pair<ll, ll> pll;

ll mod = 1e9 + 7;
void solve(){
    ll n;   cin >> n;
    if(n < 3){
        cout << 0 << endl;
        return;
    }
    vector<ll> v(n+1);
    v[0] = 1, v[1] = 0, v[2] = 0;
    for(ll i = 3 ; i <= n ; i++){
        for(ll j = 3 ; j <= i ; j++){
            v[i] += v[i-j];
            v[i] %= mod;
        }
    }
    cout << v[n] << endl;

}

int main(){
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	while(true){
		int W, H;
		cin >> H >> W;
		if(H == 0 || W == 0){ break; }
		vector<string> field(H);
		for(int i = 0; i < H; ++i){ cin >> field[i]; }
		int x = 0, y = 0;
		while(field[y][x] != '.' && field[y][x] != ' '){
			int px = x, py = y;
			switch(field[y][x]){
				case '>': ++x; break;
				case '<': --x; break;
				case 'v': ++y; break;
				case '^': --y; break;
			}
			field[py][px] = ' ';
		}
		if(field[y][x] == ' '){
			cout << "LOOP" << endl;
		}else{
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

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

int main(void){
  char S[100];
  char T[100];
  scanf("%s",S);
  scanf("%s",T);
  
   int a = strlen(S);
   int b = strlen(T);
  
  int count=0;
  for(int i=0;i<a;i++){
  if (S[i]==T[i]) count++;
  }
  
  if(count==a) printf("Yes");
  else printf("No");
  
  return 0;
  
}

Measured memory_bytes: 1708
class Heap
    attr_reader :size
    def initialize
        @heap = []
        @size = 0
    end

    def length
        @size
    end

    def push(x)
        i = @size
        @size += 1
        while i > 0
            p = (i-1)/2
            break if @heap[p] <= x
            @heap[i] = @heap[p]
            i = p
        end
        @heap[i] = x
    end

    def pop
        return nil if @size == 0
        ret = @heap[0]
        @size -= 1
        x = @heap[@size]
        i = 0
        while i*2+1 < @size
            a = i*2+1
            b = a+1
            if b < @size && @heap[b] < @heap[a]
                a = b
            end
            break if @heap[a] >= x
            @heap[i] = @heap[a]
            i = a
        end
        @heap[i] = x
        @heap.pop
        return ret
    end
end

class Array
    include Comparable
end

X, Y, Z, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort.reverse + [-10**18]
bs = gets.split.map(&:to_i).sort.reverse + [-10**18]
cs = gets.split.map(&:to_i).sort.reverse + [-10**18]

heap = Heap.new
heap.push([-(as[0]+bs[0]+cs[0]), 0, 0, 0])
used = {[0, 0, 0] => true}
K.times do
    ans, i, j, k = heap.pop
    puts -ans
    [[i+1, j, k], [i, j+1, k], [i, j, k+1]].each do |ijk|
        unless used[ijk]
            used[ijk] = true
            val = as[ijk[0]] + bs[ijk[1]] + cs[ijk[2]]
            heap.push([-val] + ijk)
        end
    end
end

Measured memory_bytes: 3192
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 998244353
using namespace std;

int main(){
	FASTIO
  string s;
  cin >> s;
  int n = s.size();
  string t;
  for (int i = 0; i < n; ++i) {
    if (i < (n - 1) && s[i] == 'B' && s[i + 1] == 'C') {
      t += 'D';
      ++i;
    } else {
      t += s[i];
    }
  }
  // cout << t << endl;

  n = t.size();
  ll answer = 0;
  ll count = 0;
  for (int i = 0; i < n; ++i) {
    if (t[i] == 'A') {
      count++;
    } else if (t[i] == 'D') {
      answer += count;
    } else {
      count = 0;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 916
def resolve():
    h, w = map(int, input().split())
    l = []
    for i in range(h):
        s = list(input())
        l.append(s)

    d = [[-1, 0], [0, -1], [0, 1], [1, 0]]

    for i in range(h):
        for j in range(w):
            for dx, dy in d:
                m = i + dx
                n = j + dy
                if m < 0 or m > h - 1:
                    pass
                elif n < 0 or n > w - 1:
                    pass
                elif l[i][j] == '#' and l[m][n] == '#':
                    l[i][j] = 'z'
                    l[m][n] = 'z'
                elif l[i][j] == 'z' and l[m][n] == '#':
                    l[m][n] = 'z'
                elif l[i][j] == '#' and l[m][n] == 'z':
                    l[i][j] = 'z'

    count = 0
    for i in l:
        count += i.count('#')

    if count == 0:
        return print('Yes')
    else:
        return print('No')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3064
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;
 
//#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 3000 + 10 ; 

int n , a [ N ] ;
bool dp [ N ] ;
vector < int > adj [ N ] , op ; 

void dfs ( int v , int p = -1 ) {
	for ( int u : adj [ v ] ) {
		if ( u ^ p ) {
			dfs ( u , v ) ;
			if ( a [ u ] < a [ v ] && !dp [ u ] )
				dp [ v ] = true ; 
		}
	}
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n ;
	for ( int j = 0 ; j < n ; ++j )
		cin >> a [ j ] ;
	for ( int j = 0 ; j < n - 1 ; ++j ) {
		int u , v;
		cin >> u >> v;
		--u , --v ;
		adj [ u ].push_back ( v ) ;
		adj [ v ].push_back ( u ) ; 
	}
	for ( int root = 0 ; root < n ; ++root ) {
		memset ( dp , 0 , sizeof dp ) ;
		dfs ( root ) ;
		if ( dp [ root ] )
			op.push_back ( root ) ; 
	}
	for ( int x : op )
		cout << ++x << ' ' ;
	cout << '\n' ; 
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct edge {
    int to,w,nxt;
} e[N<<1];
int tot=1,h[N];
void adde(int u,int v,int w) {
    e[++tot]=(edge){v,w,h[u]};h[u]=tot;
    e[++tot]=(edge){u,w,h[v]};h[v]=tot;
}
ll ans=0;
int n,fl=0,sz[N],f[N],mn=1e9;
void dfs(int u,int fa,int w) {
    sz[u]=1;
    for(int i=h[u];i;i=e[i].nxt) {
        int v=e[i].to; if(v==fa) continue;
        dfs(v,u,e[i].w),sz[u]+=sz[v],f[u]=max(f[u],sz[v]);
    }
    f[u]=max(f[u],n-sz[u]);
    ans+=2ll*w*min(sz[u],n-sz[u]);
    if(sz[u]*2==n) ans-=w,fl=1;
    if(f[u]<=n/2) for(int i=h[u];i;i=e[i].nxt) mn=min(mn,e[i].w);
}
int main() {
    cin>>n;
    for(int i=1,u,v,w;i<n;i++) u=gi(),v=gi(),w=gi(),adde(u,v,w);
    dfs(1,0,0);
    if(!fl) ans-=mn;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		for(int i = 1; i <= 1009; i++) {
			int a = (int)(i * 0.08);
			int b = (int)(i * 0.10);
			if(a == A && b == B) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
using namespace std;
static const int MAX = 500;

class E{
public:
  int t, c;
  E(){}
  E(int t, int c):t(t), c(c){}
};

int N;
vector<E> G[MAX];
int dp[MAX];

int dfs(int u){
  if ( dp[u] != -1 ) return dp[u];
  int maxv = 0;
  for ( int i = 0; i < G[u].size(); i++ ){
    maxv = max(maxv, dfs(G[u][i].t) + G[u][i].c);
  }
  return dp[u] = maxv;
}

main(){
  int m, s, t, c;
  cin >> N >> m;
  for ( int i = 0; i < N; i++ ) dp[i] = -1;
  for ( int i = 0; i < m; i++ ){
    cin >> s >> t >> c;
    G[t].push_back(E(s, c));
  }
  cout << dfs(N-1) << endl;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>

using namespace std;

void solve(int N) {
  if (N > 999) {
    printf("ABD\n");
  } else {
    printf("ABC\n");
  }
}

int main() {
  int N;
  cin >> N;
  solve(N);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int a[100005],b[100005];

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,1,n)cin>>a[i],b[i]=a[i];
sort(b+1,b+n+1);
rep(i,1,n)
a[i]=lower_bound(b+1,b+n+1,a[i])-b;
int ans=0;
rep(i,1,n)
{
	if(abs(a[i]-i)%2)
	ans++;
}

ol(ans/2+2*ans%2);

return 0;
}


Measured memory_bytes: 1152
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		200005									// 最大文字数
#define D_CHAR_CNT		26										// 文字種類数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1StrFrom[D_CHAR_MAX];								// 文字列 - 元
static char sc1StrTo[D_CHAR_MAX];								// 文字列 - 先
static int siSCnt;												// 文字列数
static char sc1ChgFrom[D_CHAR_CNT];								// 変換内容 - 元
static char sc1ChgTo[D_CHAR_CNT];								// 変換内容 - 先

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 判定
int
fJudge(
)
{
	int i;

	// 各文字チェック
	for (i = 0; i < siSCnt; i++) {
		int liFNo = sc1StrFrom[i] - 'a';
		int liTNo = sc1StrTo[i] - 'a';

		// 変換内容 - 元
		if (sc1ChgFrom[liFNo] == 0) {				// 初回
			sc1ChgFrom[liFNo] = liTNo;
		}
		else if (sc1ChgFrom[liFNo] != liTNo) {		// 不一致
			return -1;
		}

		// 変換内容 - 先
		if (sc1ChgTo[liTNo] == 0) {					// 初回
			sc1ChgTo[liTNo] = liFNo;
		}
		else if (sc1ChgTo[liTNo] != liFNo) {		// 不一致
			return -1;
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int liRet;
	char lc1Buf[1024], lc1Out[1024];

	// データ - 初期化
	memset(sc1ChgFrom, 0, sizeof(sc1ChgFrom));					// 変換内容 - 元
	memset(sc1ChgTo, 0, sizeof(sc1ChgTo));						// 変換内容 - 先

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 文字列 - 取得
	fgets(sc1StrFrom, sizeof(sc1StrFrom), szpFpI);
	fgets(sc1StrTo, sizeof(sc1StrTo), szpFpI);

	// 改行カット
	siSCnt = fCutCrLf(sc1StrFrom);

	// 判定
	liRet = fJudge();

	// 結果 - セット
	if (liRet == 0) {
		sprintf(lc1Out, "Yes\n");
	}
	else {
		sprintf(lc1Out, "No\n");
	}

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int sz[10000];

void change(vector<P> &nums, int x, int y){
	vector<P> res;
	int n = nums.size();
	int indx, indy;
	int ub = n + 1, lb = 0;
	sz[0] = 0;
	rep(i, n){
		sz[i+1] = sz[i] + nums[i].second - nums[i].first + 1;
	}

	while(ub - lb > 1){
		int mb = (ub + lb) / 2;
		if(sz[mb] < x) lb = mb;
		else ub = mb;
	}
	indx = lb;
	ub = n + 1, lb = 0;

	while(ub - lb > 1){
		int mb = (ub + lb ) / 2;
		if(sz[mb] <= y) lb = mb;
		else ub = mb;
	}
	indy = lb;

	int dy = indy == n ? 0 : y - sz[indy], dx = indx == n ? 0 : x - sz[indx];

	res.push_back(P(nums[indy].first + dy ,nums[indy].second));
	rep2(i, indy + 1, n){
		res.push_back(nums[i]);
	}
	if(indx != indy) res.push_back(P(nums[indx].first + dx, nums[indx].second));
	else res.push_back(P(nums[indx].first + dx, nums[indx].first + dy-1));
	rep2(i, indx + 1, indy){
		res.push_back(nums[i]);
	}
	if(indx != indy && dy != 0) res.push_back(P(nums[indy].first, nums[indy].first + dy - 1));
	rep(i, indx ){
		res.push_back(nums[i]);
	}
	if(dx != 0)res.push_back(P(nums[indx].first, nums[indx].first + dx - 1));
	nums = res;
}

int get_num(P p, int r){
	//cout << "***" << p.first << " " << p.second << endl;;
	if(p.second < p.first) return 0;
	if(r < p.first) return 0;
	else if(p.second <= r) return p.second - p.first + 1;
	else return r - p.first + 1;
}

int counter(const vector<P> &nums, int p, int q, int r){
	int cnt = 1;
	int res = 0;
	int n = nums.size();
	rep(i, n){
	//	cout << "+ " <<  nums[i].first << " " << nums[i].second << endl;
		int sz = nums[i].second - nums[i].first + 1;
		int pn = nums[i].first + p - cnt;
		int qn = nums[i].first + q - cnt;
		
		res += get_num(P(max(nums[i].first, pn), min(nums[i].second, qn)), r);
		cnt += sz;
	}
	return res;
}

int main(){
	int n, m;
	int p, q, r;
	int x, y;
	while(cin >> n && n){
		vector<P> nums;
		nums.push_back(P(1, n));
		cin >> m;
		cin >> p >> q >> r;
		rep(i, m){
			cin >> x >> y;
		    change(nums, x, y);
		}
		cout << counter(nums, p, q, r) << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import math
import fractions
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def main():
  mod = 10**9 +7
  n = int(input())
  ls = list(map(int,input().split()))
  
  t = ls[0]
  for a in ls:
    t = lcm(t,a)
  
  ans = 0
  for a in ls:
    ans += t//a
  print(ans%mod)
  
if __name__ == '__main__':
  main()


Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//a^n mod p
//n > 0
//#include <cmath>
long long modpow(long long a, long long n, long long p) {
	a %= p;
	if (a == 0) return 0;
	if (a == 1) return 1;
	long long b = 1, cnt = 0;
	while (b < p && cnt < n) {
		b *= a;
		cnt++;
	}
	if (b < p) return b;
	b %= p;
	return modpow(b, n / cnt, p) * (long long)pow(a, n % cnt) % p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll a(n), b(n);
	ll cnt_zero = 0;
	map<vll, ll> mp;
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0) cnt_zero++;
		else if (a[i] == 0) b[i] = 1;
		else if (b[i] == 0) a[i] = 1;
		else {
			bool x = (a[i] > 0), y = (b[i] > 0);
			a[i] = abs(a[i]);
			b[i] = abs(b[i]);
			ll z = __gcd(a[i], b[i]);
			a[i] /= z;
			b[i] /= z;
			if (x ^ y) a[i] *= -1;
		}
		mp[{a[i], b[i]}]++;
	}

	//for (ll i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl;

	vector<vll> v(0);
	ll cnt_ban = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		vll x = (i -> first);
		ll y = (i -> second);
		if (x[0] <= 0) continue;
		ll z = mp[{- x[1], x[0]}];
		if (z) {
			v.push_back({y, z});
			cnt_ban += y + z;
		}
	}

	ll ans = modpow(2, n - cnt_ban - cnt_zero, p);
	for (ll i = 0; i < v.size(); i++) {
		ans *= (modpow(2, v[i][0], p) + modpow(2, v[i][1], p) - 1) % p;
		ans %= p;
	}
	ans--;
	if (ans < 0) ans += p;
	ans += cnt_zero;
	ans %= p;
	cout << ans << endl;
}

Measured memory_bytes: 39496
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
import random
import time
start_time = time.time()
D = int(input())
c = [int(x) for x in input().split()]
s = []
for _ in range(D):
    s.append([int(x) for x in input().split()])
t = [random.randint(1, 26) for x in range(D)]
last = [0]*26
def solve(t):
    ans = 0
    for i in range(1, D + 1):
        ans += s[i - 1][t[i - 1] - 1]
        last[t[i - 1] - 1] = i
        for j in range(26):
            ans -= c[j]*(i - last[j])
    return ans
ans = solve(t)
while True:
    now_time = time.time()
    if now_time - start_time > 1.85:
        print(*t, sep='\n')
        break
    d, q = [random.randint(1, D), random.randint(1, 26)]
    temp = t[d - 1]
    t[d - 1] = q
    ans_2 = solve(t)
    if ans_2 > ans:
        ans = ans_2
    else:
        t[d - 1] = temp



Measured memory_bytes: 81048
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp
end

sample = attrs[0]
test = attrs[1]
yes = nil
tmp = sample

for i in 0..sample.length do
    if tmp == test then
        yes = "Yes"
    end
    tmp = tmp[1..(-1)] + tmp[0]
end

if yes then
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
using ll = long long;

int main(){
    int n,x,temp=0,l,ans=1;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> l;
        temp+=l;
        if(temp<=x) ans++;
    }
    cout << ans << endl;
    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 RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  vecll Rs(A), Gs(B), Ts(C), Zs(X+Y+C);
  REP(i, A) cin >> Rs[i];
  REP(i, B) cin >> Gs[i];
  sort(Rs.begin(), Rs.end(), std::greater<ll>());
  sort(Gs.begin(), Gs.end(), std::greater<ll>());
  REP(i, X) Zs[i] = Rs[i];
  REP(i, Y) Zs[i+X] = Gs[i];
  REP(i, C) cin >> Zs[i+X+Y];
  sort(Zs.begin(), Zs.end(), std::greater<ll>());
  ll res = 0;
  REP(i, X+Y) res += Zs[i];

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4736
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    vvi v(n,vi(26));
    rep(i, n) {
        string s;cin >> s;
        rep(j, s.size()) {
            v[i][s[j]-'a']++;
        }
    }
    /*rep(i, n) {
        rep(j, 26)cout << v[i][j] << (j==25?"\n":" ");
    }*/
    vi ans(26);
    rep(j, 26) {
        int mi = inf;
        rep(i, n) {
            chmin(mi,v[i][j]);
        }
        ans[j]=mi;
    }
    rep(i, 26) {
        rep(j,ans[i])cout << char(i+'a');
    }
    cout << endl;
    // for(auto p:ans)cout << p << ' ';
    return 0;
}

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

void solve(int N, vector<int> L)
{
    sort(L.begin(), L.end());
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if (L.at(i) == L.at(j) || L.at(i) == L.at(k) || L.at(j) == L.at(k))
                    continue;
                if (L.at(i) + L.at(j) > L.at(k))
                    res++;
            }
        }
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }
    solve(N, move(L));
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
     int n,k;
     cin>>n>>k;
     int a[n];
     for(int i=0;i<n;i++)
        cin>>a[i];
     sort(a,a+n);
     ll sum=0;
     for(int i=0;i<k;i++)
        sum+=a[i];
     cout<<sum;
}


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

int main() {
  long long N;
  cin >> N;
  vector<long long>A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<long long>Sum(N);
  Sum.at(0) = A.at(0);
  for (long long i = 1; i < N; i++) {
    Sum.at(i) = Sum.at(i - 1) + A.at(i);
  }
  long long ans = 3000000007;
  for (long long i = 0; i < N - 1; i++) {
    long long ABS = abs(Sum.at(N - 1) - Sum.at(i) - Sum.at(i));
    if (ans > ABS) ans = ABS;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fr(i, n) FOR(i, 0, n, 1)
#define rfr(i, n) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define gcd(a,b)  __gcd(a,b)
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz size
#define clr clear
#define len length
#define inf (int)1e9
#define eps 1e-9
#define pi 3.1415926535897932384626433832795
#define h 1000000007
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const double PI=acos(-1.0);
#define printlist(a, n) for (ll i = 0; i < n; i++) cout << a[i] << ' ' ; br
#define printvec(v) for (auto itv = v.begin(); itv != v.end(); itv++) cout << *itv << ' ' ; br
#define printset(s) for (auto its = s.begin(); its != s.end(); its++) cout << *its << ' '; br
#define printmap(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define printmm(m) for (auto itm = m.begin(); itm != m.end(); itm++) cout << (*itm).ff << ' ' << (*itm).ss << endl;
#define print2(a, b) cout << a << ' ' << b; br
#define print3(a, b, c) cout << a << ' ' << b << ' ' << c; br
#define print4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d; br
#define sum(a,n,s) ll s = 0; for (ll i = 0; i < n; i++) s += a[i];
#define br cout << endl
#define inputlist(arr,n) vi arr(n,0); fr(i,n) {cin>>arr[i];}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> seti;
typedef multiset<int> mulset;
typedef long long int ll;




signed main()
{
  fast();
  {
  inp(n); inputlist(v,n);
  inputlist(c,n);
  int ans=0;
  fr(i,n){
    if(v[i]-c[i]>0) 
      ans=ans+v[i]-c[i];
  }
  print(ans);
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int x = int.Parse(Console.ReadLine());
        bool flag;
        while (true)
        {
            flag = true;
            for (int i = 2; i * i <= x; i++)
            {
                if (x % i == 0)
                {
                    flag = false;
                }
            }
            if (flag)
                break;
            else
                x++;
        }
        Console.WriteLine(x);
    }
}

Measured memory_bytes: 13140