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

int N,M,Q;
vector<int> A,B,C,D;
vector<long long int> Ans;

void create(vector<int> v,int n,int max,int min){
    if(n>0){    
        if(min<max){
        create(v,n,max,min+1);
        v.push_back(min);
        create(v,n-1,max,min);
        }
        else if(min=max){
        v.push_back(min);
        create(v,n-1,max,min);
        }
    }
    else{
        long  long int sum=0;
        for(int i=0;i<Q;i++){
            if(v[B[i]-1]-v[A[i]-1]==C[i]){
                sum  += D[i];
            }
        }
        Ans.push_back(sum);

    }
        
    
}

int main(){
    
    cin >> N >> M >> Q;
    for(int i=0;i<Q;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
        D.push_back(d);
        

    }
    vector<int> v;
    create(v,N,M,1);

    int mx = 0;
    for(int i=0;i<Ans.size();i++){
        if(Ans[i]>mx){mx=Ans[i];}

    }
    cout << mx << endl;

    return 0;


}

Measured memory_bytes: 4328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n, m; cin >> n >> m;
	vi ng(n + 1), dp(n + 1);
	rep(i, m){
		int a; cin >> a;
		ng[a] = 1;
	}
	dp[0] = 1;
	rep(i, n) for(int j = 1; j <= 2; j++){
		if(i + j <= n && !ng[i + j]) (dp[i + j] += dp[i]) %= mod;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
class abc167_c{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int m = int.Parse(str[1]);
    int x = int.Parse(str[2]);
    int[] cost = new int[n];
    int[,] val = new int[n,m];
    for(int i=0; i<n; i++){
      int[] temp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
      cost[i] = temp[0];
      for(int j=0; j<m; j++){
        val[i,j] = temp[j+1];
      }
    }
    List<Cl> list = new List<Cl>();
    Cl c = new Cl(m);
    list.Add(c);
    for(int i=0; i<n; i++){
      int num = list.Count;
      for(int j=0; j<num; j++){
        Cl nc = new Cl(m);
        nc.sum = list[j].sum+cost[i];
        for(int k=0; k<m; k++){
          nc.sut[k] = val[i,k]+list[j].sut[k];
        }
        list.Add(nc);
      }
      Cl nc2 = new Cl(m);
      nc2.sum = cost[i];
      for(int j=0; j<m; j++){
        nc2.sut[j] = val[i,j];
      }
    }
    int min = Int32.MaxValue;
    bool flag = true;
    /*for(int i=0; i<list.Count; i++){
      Console.Write("sum: {0} // ",list[i].sum);
      for(int j=0; j<m; j++){
        Console.Write("{0} ",list[i].sut[j]);
      }
      Console.WriteLine("");
    }*/
    for(int i=0; i<list.Count; i++){
      Cl c2 = list[i];
      flag = true;
      for(int j=0; j<m && flag; j++){
        if(c2.sut[j] < x){
          flag = false;
        }
      }
      if(flag){
        if(min > c2.sum){
          min = c2.sum;
        }
      }
    }
    if(min == Int32.MaxValue){
      Console.WriteLine("-1");
    }
    else
      Console.WriteLine(min);
  }
}

class Cl{
  public int sum;
  public int[] sut;
  public Cl(int m){
    sum = 0;
    sut = new int[m];
  }
}


Measured memory_bytes: 19368
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	lli n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	lli kaisu = n/min({a, b, c, d, e}) +1;
	if(n%min({a, b, c, d, e}) == 0) kaisu--;
	cout << kaisu+4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
//#include<vector>
using namespace std;

int main(){
  int n, m, pos, jdg=0;
  cin >> n >> m;
  string a[n], b[m];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<m;j++){
      for(int k=0;k<n-m+1;k++){
        if(a[i+j].substr(k,m)==b[j]){
          jdg += 1;
          int o=j;
          for(int l=i+j+1;l<m+i+j;l++){
            o++;
            if(a[l].substr(k,m)!=b[o]){
              jdg = 0;
              break;
            }
            else{
              jdg += 1;
            }
          }
        }
        if(jdg==m)break;
      }
      if(j==0 && jdg==0)break;
      else if(jdg==m)break;
    }
    if(jdg==m)break;
  }
  if(jdg==m)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

int accumulate(int* a,int n){
    return accumulate(a,a+n,0LL);
}

int accumulate(vector<int> a){
    return accumulate(a.begin(),a.end(),0LL);
}

signed main(){ 
    int n; cin>>n;
    int a[n],s[n];
    for(int i=0;i<n;i++){
        int ai; cin>>ai;
        if(i==0) {
            s[i]=ai;
            a[i]=ai;
        }
        else{
            s[i]=ai+s[i-1];
            a[i]=ai;
        }
    }

    int sum=accumulate(a,a+n,0LL);
    int mergin=sum+1;
    int pred=0;

    for(int i=0;i<n;i++){
        pred+=a[i];
        if(abs(pred-(sum-pred))<mergin){
            mergin=abs(pred-(sum-pred));
        }else{
            break;
        }
    }

    cout<<mergin<<endl;

}  

Measured memory_bytes: 6716
# K : 湖の円周 n : 家の軒数　
k, n = map(int, input().split())
# 家の位置をリストで取得
house_point = list(map(int,input().split()))

# それぞれの家の位置を差分を取得
house_point_diff = [house_point[i+1] - house_point[i] for i in range(n-1)]
# 最初の家と最後の家に位置の差分を、Kを考慮し取得
house_point_diff.append(k + house_point[0] - house_point[n-1])

# 最も離れた家の間を通らないようにすれば最短距離を得られる。
# そのため、湖の円周(K)から、最も離れた家の間の距離(max(house_point_diff))を引く
print(k-max(house_point_diff))

Measured memory_bytes: 25840
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#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;


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

  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  vector<ll> S(N + 1, 0);
  rep(i, N) S[i + 1] = S[i] + A[i];
  
  auto calc = [&](int x) {
    // tot:合計、num:何個数字を取れるか
    ll tot = 0, num = 0;
    rep (i, N) {
      int j = lower_bound(A.begin(), A.end(), x - A[i]) - A.begin();
      num += N - j;
      tot += S[N] - S[j];
      tot += A[i] * ll(N - j);
    }
    return make_pair(tot, num);
  };

  int l = 0, r = 200001;
  while (l + 1 < r) {
    int c = (l + r) / 2;
    // c以上を全部取った時、M個以上取れるような最大のcを求めたい。
    if (calc(c).second >= M) {
      l = c;
    } else {
      r = c;
    }
  }
  auto p = calc(l);
  ll ans = p.first;
  ans -= (p.second - M) * l; // 同率を削る
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <random>

using namespace std;

long long A[100005];
long long N;

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

    long long sum = 0;

    sort(A, A + N);

    long long l, r, lc, rc;

    l = A[0];
    r = A[0];

    lc = 1;
    rc = N - 1;

    long long t[4];

    for (int i = 1; i < N;i++)
    {
        t[0] = abs(A[lc] - l);
        t[1] = abs(A[lc] - r);
        t[2] = abs(A[rc] - l);
        t[3] = abs(A[rc] - r);

        int d = std::max_element(t, t + 4) - t;

        //cout << i << ':' << d << ' ' << t[d] << endl;

        if(d == 0)
        {
            sum += t[0];
            l = A[lc];
            lc++;
        }
        if (d == 1)
        {
            sum += t[1];
            r = A[lc];
            lc++;
        }
        if (d == 2)
        {
            sum += t[2];
            l = A[rc];
            rc--;
        }
        if (d == 3)
        {
            sum += t[3];
            r = A[rc];
            rc--;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

vector<ll> v; 

int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    ll a; cin >> a;
    v.push_back(a);
  }
  
  std::sort(v.begin(), v.end());
  
  ll sum = 0;
  for(int i = 0; i < n - k; ++i){
    sum += v[i];
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 2420
n, m = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(y) for y in input().split()]
p = 10 ** 9 + 7
print(sum([(X[i + 1] - X[i]) * (i + 1) * (n - i - 1) % p for i in range(n - 1)]) * sum([(Y[i + 1] - Y[i]) * (i + 1) * (m - i - 1) % p for i in range(m - 1)]) % p)

Measured memory_bytes: 19472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n)cin >> h[i];
  ll res = 0;
  ll mx = 0;
  rep(i,n){
    if(mx > h[i])res += abs(h[i]-mx);
    else mx = h[i];
  }
  cout << res << "\n";


  return 0;
}

Measured memory_bytes: 4840
require 'matrix'
N, M, X = gets.split.map &:to_i
books = []
N.times do
    cost, *a = gets.split.map &:to_i
    books << {cost: cost, und: Vector.elements(a)}
end
# pp books
ans = nil
for i in 0..(2**12)
    sum_cost = 0
    sum_a = Vector.zero(books[0][:und].size)
    books.each_with_index do |book, idx|
        if i[idx] == 1
            sum_cost += book[:cost]
            sum_a += book[:und]
        end
    end
    if sum_a.all?{|item| item >= X}
        ans = [ans, sum_cost].compact.min
    end
end
p ans ? ans : -1

Measured memory_bytes: 15160
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

int n,xx;
cin>>xx>>n;
set<int>s;

    for(int i=0;i<n;i++)
    {
      int x;
      cin>>x;
      s.insert(x);
    }
    int dif=INT_MAX,mn=INT_MAX;
    for(int i=-200;i<=200;i++)
    {
      if(s.find(i)==s.end())
      {

        if(dif==abs(xx-i))
        {
          mn=min(mn,i);
        }
        if(dif>abs(xx-i))
        {
          dif=abs(xx-i);
          mn=i;

        }


      }

    }


cout<<mn;


    return 0;
  }


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
    long long int a,b,c,d,tmp,r,mina,minb;
    long long int x,y,z,C,D;
    

    scanf("%lld %lld %lld %lld",&a,&b,&C,&D);

    mina = (a-1)/C;
    minb = b/C;
    y = minb-mina;
    mina = (a-1)/D;
    minb = b/D;
    z = minb-mina;

    
  /* ユークリッドの互除法 */
     c = C;
     d = D;
     x = c*d;
    
     if(c < d){
    	tmp = c;
    	c = d;
    	d = tmp;
	}
    r = c%d;
    while(r!=0){
    	c = d;
    	d = r;
    	r = c % d;
  	}
    x = x/d;
    mina = (a-1)/x;     
    minb = b/x;
    x = minb-mina;

   

    printf("%lld\n",b-a+1-(y+z-x));
    return 0;

}

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

void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs << endl; 
} 

int main(){

	char s[3005], t[3005];
	cin >> s >> t;

	lcs(s, t, strlen(s), strlen(t));
	
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,h[100002],count=0,ans=0;
    cin >> n;
    rep(i,n) cin >> h[i];
    rep(i,n-1){
        if(h[i] >= h[i+1]){
            count ++;
            if(n-1 == i+1) ans = max(ans,count);
        }else{
            ans = max(ans,count);
            count = 0;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int n;
  	cin>>n;
  	vector<int> a(n);
  	for(int i=0;i<n;i++)cin>>a[i];
  	int L = a[0],R = a[0];
  	for(int i=0;i<n;i++){
    	L = min(L,a[i]);
    	R = max(R,a[i]);
    }
  
  	int ans = 1e9;
  	
  	for(int i = L;i<=R;i++){
      int tmp = 0;
      for(int j = 0;j<n;j++){
      	tmp += (a[j]-i)*(a[j]-i);
      }
      ans = min(ans,tmp);
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
 {
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int a,i,j;
   cin>>a;
   for(i=1;i<10;i++)
      {
          for(j=1;j<10;j++)
            {
                if(j*i==a)
                 {
                     cout<<"Yes"<<endl;
                     return 0;
                 }
            }

         
      }
      cout<<"No"<<endl;
    
 }

Measured memory_bytes: 256
use std::io::Read;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let total: usize = a.iter().sum();
    let count: usize = a.iter().filter(|it| 4 * m * **it >= total).count();

    return if count >= m {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

struct Rectangle {
  int H;
  int W;
};

int main()
{
  vector<Rectangle> data_set;

  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }

    data_set.push_back({H, W});
  }

  for (auto &&i : data_set) {
    for (int h = 0; h < i.H; h++) {
      for (int w = 0; w < i.W; w++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



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

using namespace std;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tii;

int main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x;
	cin >> x;
	cout << M_PI*2*x << endl;
}


Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);

        
        while (true) {
            int x = num.nextInt();
            int y = num.nextInt();
            if (x != 0 || y != 0) {
                if (x < y) {
                    System.out.println(x + " " + y);
                } else {
                    System.out.println(y + " " + x);
                }

            } else {
                break;
            }
        }
    }
}

Measured memory_bytes: 35964
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int price = 700;
		
		int count = 0;
		for(int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'o') {
				count++;
			}
		}
		System.out.println(price + count*100);

	}

}


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

int main() {
    int N;
    cin >> N;
    long long T = 0, c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        for (int j = 0; j + 1 < S.size(); ++j) {
            if (S[j] == 'A' && S[j + 1] == 'B') ++T;
        }
        if (S[0] == 'B' && S.back() == 'A') ++c1;
        else if (S.back() == 'A') ++c2;
        else if (S[0] == 'B') ++c3;
    }
    if (c2 == 0 && c3 == 0) cout << T + max(c1 - 1, 0LL) << endl;
    else cout << T + c1 + min(c2, c3) << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 26+5;
int n, vis[N]; char s[N];
int main()
{
    scanf("%s", s+1), n = strlen(s+1);
    if(n < 26)
    {
        int c = 0;
        for(int i = 1; i <= n; ++i) 
        {
            vis[s[i]-'a'] = 1;
            while(vis[c]) ++c;
        }
        s[n+1] = c+'a';
        return puts(s+1), 0;
    }
    else
    {
        for(int i = n-1; i; --i)
        {
            int k = i;
            for(int j = i+1; j <= n; ++j) if(s[j]>s[i]&&(s[k]>s[j]||k == i)) k = j;
            if(k == i) continue; s[i] = s[k], s[i+1] = 0; 
            return puts(s+1), 0;
        }
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 128
def chmin(a,b):
    if a>b: return b
    else: return a

def chmax(a,b):
    if a>b: return a
    else: return b

def main():
    N = int(input())
    h = list(map(int, input().split()))
    # 初期化
    # 初期条件
    # ループ
    # テーブルから解を得る
    INF = float('inf')
    dp = [INF] * N
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(N-2):
        dp[i+2] = chmin(dp[i]+abs(h[i+2]-h[i]), dp[i+1]+abs(h[i+2]-h[i+1]))
    print(dp[-1])

main()


Measured memory_bytes: 13908
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (int)(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long
namespace mf {
    static const int N = 23333;
    static const int M = 2e6 + 233;
    static const int inf = 1e16;
    struct E {
		int nxt, to, fl;
    }e[M << 1];
    int d[N], head[N], cur[N], e_cnt = 1;
    int n, s, t;
    inline void init(int _n, int _s, int _t) {
		n = _n * 2; s = _s; t = _t;
		fill(head, head + n + 1, 0);
		e_cnt = 1;
    }
    inline void add(int u, int v, int fl) {
		e[++ e_cnt] = (E) {head[u], v, fl}; head[u] = e_cnt;
    }
    inline void link(int u, int v, int fl) {
		// cout << u << " " << v << " " << fl << "\n";
		add(u, v, fl); add(v, u, 0);
    }
    inline bool bfs(void) {
		queue<int> q;
		fill(d, d + n + 1, -1);
		d[s] = 0; q.push(s);
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for(int i = head[u]; i; i = e[i].nxt) if(e[i].fl) {
					int v = e[i].to;
					if(!~ d[v]) d[v] = d[u] + 1, q.push(v);
				}
		}
		return d[t] != -1;
    }
    inline int dfs(int u, int f) {
		if(u == t || !f) return f;
		int used = 0, t;
		for(int &i = cur[u]; i; i = e[i].nxt) if(e[i].fl) {
				int v = e[i].to;
				if(d[v] != d[u] + 1) continue;
				t = dfs(v, min(f - used, e[i].fl));
				used += t; e[i].fl -= t; e[i ^ 1].fl += t;
				if(used == f) break;
			}
		if(!used) d[u] = -1;
		return used;
    }
    inline int doit(void) {
		int fl = 0;
		while(bfs()) {
			memcpy(cur, head, sizeof (int) * (n + 2));
			fl += dfs(s, inf);
		}
		return fl;
    }
}

const int N = 111;
int n, m, a[N][N], x[N][N], cnt[N][N], b[N][N], c[N][N], used[N][N], ee[N][N];

inline void print(int dd[N][N]) {
	rep (i, n) rep (j, m) cout << dd[i][j] << " \n"[j == m];
}

using mf::link;

signed main(void) {
	read(n); read(m);
	rep (i, n) rep (j, m) read(a[i][j]), x[i][j] = (a[i][j] - 1) / m + 1;
	rep (k, m) {
		int S = n + n + 1, T = S + 1;
		mf::init(T, S, T);
		rep (i, n) link(S, i, 1);
		rep (i, n) link(i + n, T, 1);
		rep (i, n) rep (j, m) if (a[i][j])
			link(i, x[i][j] + n, 1), ee[i][j] = mf::e_cnt;
		int c = mf::doit();
		assert(c == n);
		rep (i, n) rep (j, m) if (mf::e[ee[i][j]].fl) {
			b[i][k] = a[i][j]; a[i][j] = 0; ee[i][j] = 0;
			// cout << i << " " << j << " " << k << "\n";
		}
	}
	print(b);
	rep (j, m) {
		vector <int> cur;
		rep (i, n) cur.push_back(b[i][j]);
		sort(cur.begin(), cur.end(), [](int x, int y) {
				return (x - 1) / m < (y - 1) / m;
			});
		rep (i, n) c[i][j] = cur[i - 1];
	}
	print(c);
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int main() {
    map<string, int> day_to_sun;
    string S;

    day_to_sun["SUN"] = 7;
    day_to_sun["MON"] = 6;
    day_to_sun["TUE"] = 5;
    day_to_sun["WED"] = 4;
    day_to_sun["THU"] = 3;
    day_to_sun["FRI"] = 2;
    day_to_sun["SAT"] = 1;

    cin >> S;
    cout << day_to_sun[S] << endl;
}

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

int main(){
  double n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0;i<n;i++)
    cin >> x.at(i) >> y.at(i);
  
  double k=0;
  int m=0;
  
  for(int i=0;i<n-1;i++){
    for(int j=1;j<n;j++){
      if(i<j){
        int a=x.at(i)-x.at(j);
        int b=y.at(i)-y.at(j);
        k+=sqrt(a*a+b*b);
        m++;
      }
    }
  }
  
  printf("%.10f",k/m*(n-1));
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int N; cin >> N;
	int K; cin >> K;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	ll ok = 1e9, ng = 0;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		int cnt = 0;
		REP(i, N) {
			cnt += (A[i] + mid - 1) / mid-1;
		}
		if (cnt <= K)ok = mid;
		else ng = mid;
	}
	print(ok);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 4744
K, A, B = map(int, input().split())

if A + 2 > B:
    print(K + 1)

elif K <= A:
    print(K + 1)

else:
    bis = B
    times = K - (A + 1)
    bis += (B - A) * (times // 2)
    if times % 2 == 1:
        bis += 1

    print(bis)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int run_test(){
	int n, m;
	cin >> n >> m;
	priority_queue<ll> pq;
	for(int i=0; i<n; i++){
		ll a;
		cin >> a;
		pq.push(a);
	}
	while(m > 0){
		ll f = pq.top();
		pq.pop();
		if( f == 0){
			cout << 0;
			return 0;
		}
		f /= 2;
		pq.push(f);
		m--;
	}
	ll sum = 0;
	while(!pq.empty()){
		ll t = pq.top();
		sum += t;
		pq.pop();
	}
	cout << sum;
	return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
#define Max 200000

long long int parent[Max],cnt[Max],set_size[Max];


void makeSet(long long int n)
{
    parent[n]=n;
     set_size[n]=1;
}

long long int Find(long long int reprasentative)
{
    if (parent[reprasentative] == reprasentative)
    {
        return reprasentative;
    }
    return parent[reprasentative] = Find(parent[reprasentative]);
}

void Union(long long int a,long long int b)
{
    long long int u = Find(a);
    long long int v = Find(b);
    if(u == v)
    {
        //printf("Frnds");
    }
    else{
        if(set_size[u]>set_size[v])
           swap(u,v);
        parent[u]=v;
        set_size[v]+=set_size[u];
    }
}

long long int paircnt(long long int n)
{
    return (n-1)*n/2;
}

int main()
{
    long long int a,b,c,d,e,f,n,m,i,j,k;
    cin>>n>>m;
    for (int i=0; i <=n; i++)
    {
        makeSet(i);
    }
    c=paircnt(n);
    vector < pair <long long int , long long int > > v1;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        v1.push_back({a,b});
    }

    vector <long long int> ans;
    ans.push_back(c);
    for(i=m-1;i>0;i--)
    {
        a=v1[i].first;
        b=v1[i].second;
        if(Find(a)==Find(b))
            ans.push_back(c);
        else
        {
            d=set_size[Find(a)];
            e=set_size[Find(b)];
            Union(a,b);
            d=paircnt(d);
            e=paircnt(e);
            c-=(paircnt(set_size[Find(a)])-d-e);
            ans.push_back(c);
        }
    }
    k=ans.size();
    for(i=k-1;i>=0;i--)
    {
        cout<<ans[i];
         cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 7536
mod = 10**9+7
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

aa = [0 for _ in range(n*m)]
bb = [0 for _ in range(n*m)]

for i in range(n):
    if aa[n*m-a[i]] == 0:
        aa[n*m-a[i]] = 1
    else:
        print(0)
        exit()

for j in range(m):
    if bb[n*m-b[j]] == 0:
        bb[n*m-b[j]] = 1
    else:
        print(0)
        exit()

for i in range(n*m):
    if i == 0:
        continue
    aa[i] += aa[i-1]
    bb[i] += bb[i-1]

aa = aa[::-1]
bb = bb[::-1]

seta = set(a)
setb = set(b)

ans = 1

for x in range(1, n*m+1)[::-1]:
    if x in seta and x in setb:
        continue
    elif x in seta and x not in setb:
        ans *= bb[x-1]
        ans %= mod
    elif x not in seta and x in setb:
        ans *= aa[x-1]
        ans %= mod
    elif aa[x-1]*bb[x-1] - (n*m-x) > 0:
        ans *= aa[x-1]*bb[x-1] - (n*m-x)
        ans %= mod
    else:
        print(0)
        exit()

print(ans)


Measured memory_bytes: 115532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
void solve(char*a,int i, char c)
{
	if(i==n)
	{
		a[i]='\0';
		cout<<a<<endl;
		return;
	}
	for(char x='a';x<=c;x++)
	{
		a[i]=x;
		if(x==c)
			solve(a,i+1,c+1);
        else
        	solve(a,i+1,c);
	}
}
int main()
{
    cin>>n;
    char a[100];
    solve(a,0,'a');
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/// 1,3,6,10,...,(1+m)*m/2

int main(){
    int a,b,m,x;
    scanf("%d %d",&a,&b);
    m = b-a-1;
    x = (1+m)*m/2 - a;
    printf("%d",x);
    return 0;
}


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

using namespace std;

#define ll long long
int dp[100001][2];
int n, k;
int *a;

bool func(int stones, bool player){
	//base case
	if(stones == 0){
		return !player;
	}
	//recursive case
	if(dp[stones][player]!=-1){return dp[stones][player];}

	for(int i=0; i<n; i++){
		if(a[i] <= stones && player == func(stones - a[i], !player)){
			return dp[stones][player] = player;
		}
	}

	return dp[stones][player] = (!player);
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	memset(dp, -1, sizeof(dp));
	cin>>n>>k;
	a = new int[n];
	for(int i=0; i<n;i++){
		cin>>a[i];
	}
	sort(a, a+n);
	if(func(k, 1)){
		cout<<"First";
	}
	else{
		cout<<"Second";
	}
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int n;
    cin >> n;
    vector<string> S(n);
    rep(i,n) cin >> S[i];

    multiset<char> ans;
    rep(i, S[0].size()) ans.insert(S[0][i]);

    REP(i, 1, n)
    {
        multiset<char> tmp;
        set<char> roop;
        multiset<char> next;
        rep(j,S[i].size())
        {
            tmp.insert(S[i][j]);
            roop.insert(S[i][j]);
        }
        for(set<char>::iterator itr = roop.begin(); itr != roop.end(); itr++)
        {
            if( tmp.find(*itr) != tmp.end() && ans.find(*itr) != ans.end() )
            {
                rep(j, min(tmp.count(*itr), ans.count(*itr)) )
                {
                    next.insert(*itr);
                }
            }
        }
        ans = next;
    }
    for(multiset<char>::iterator itr = ans.begin(); itr != ans.end(); itr++) cout << *itr;
    cout << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N, n; cin >> N;
  int a[100]={0};
  for(int i = 1; i <= N; ++i) {
    n = i;
    for(int j = 2; j * j <= n; ++j) {
      while(n%j == 0) {
        a[j]++;
        n=n/j;
      }
    }
    a[n]++;
  }

  vector<int> v;
  for(int i = 2; i < 100; ++i) {
    if(a[i] > 0) v.push_back(a[i]);
  }
  int l = v.size();
  ll ans=0, a2=0, a4=0, a14=0, a24=0;
  for(int i = 0; i < l; ++i) {
    if(v[i] >= 74) ans++;
    if(v[i] >= 2) a2++;
    if(v[i] >= 4) a4++;
    if(v[i] >= 14) a14++;
    if(v[i] >= 24) a24++;
  }
  ans+=a24*(a2-1);
  ans+=a14*(a4-1);
  ans+=a4*(a4-1)*(a2-2)/2;
  cout << ans << endl;

  return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    int sum = 0;
    int count = 1;
    REP(i, N) {
        cin >> L[i];
        sum += L[i];
        if (sum <= X) {
            count++;
        } else {
            break;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string a, b, c; cin >> a >> b >> c;
  a[0] -= 32; b[0] -= 32; c[0] -= 32;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;




int main(){
	llint n;
	cin>>n;
	llint sum = n/500 * 1000;
	n %= 500;
	sum += n/5 * 5;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(N + 1, 0);
  dp[0] = 1000;
  //dp[i]: i日終了後で株を持っていないとき、所持金の最大値
  for (int i = 1; i <= N; i++){
    for (int j = 0; j < i; j++){
      dp[i] = max(dp[i], dp[j] / A[j] * A[i - 1] + dp[j] % A[j]);
    }
  }
  cout << dp[N] << endl;
}

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

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

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

	int a,b,c,d; cin >> a >> b >> c >> d;

	if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int N,s,sum,min_s=INF;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>s;
        if(s%10&&min_s>s)min_s=s;
        sum+=s;
    }
    
    if(!(sum%10)&&min_s!=INF)sum-=min_s;
    else if(!(sum%10)&&(min_s==INF))sum=0;
    
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int cnt = 0;
   char name[6];
   scanf("%s",name);

   if(name[2] == name[3] && name[4] == name[5]) {
      cnt++;
   }
   if(cnt == 1) {
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}


Measured memory_bytes: 1728
/* vo00_07.cpp */
#include <iostream>
using namespace std;

int main()
{
	double debt = 100000;

	int n;
	cin >> n;
	
	while (n--) {
		debt *= 1.05;
		debt /= 1000;
		debt += 0.999;
		debt = (int)debt;
		debt *= 1000;
	}

	cout << (int)debt << '\n';

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;

ll dp[110][100110]={};//n番目に入れた入れてないwの重さのナップサック、中身はそれの最大の価値

int main(){
  ll n,w;
  cin >> n >>w;
  ll wl[110],v[110];
  rep(i,n)cin >> wl[i] >> v[i];
  rep(i,n){
    rep(r,w+1){
      if(wl[i]<=r){chmax(dp[i+1][r],dp[i][r-wl[i]]+v[i]);}
      chmax(dp[i+1][r],dp[i][r]);
    }
  }
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<int> L(N);
    rep(i, N) cin >> L[i];

    if(N<=2){
        cout << 0 << '\n';
        return 0;
    }

    ll ans= 0;
    rep(i,N)rep(j,i)rep(k,j){
        if(L[i]==L[j]||L[i]==L[k]||L[j]==L[k]){
            continue;
        }
        if(i==j||j==k||k==i) continue;
        vec<int> a = {L[i],L[j],L[k]};
        sort(all(a));
        if(a[2]-a[1]-a[0]>=0){
            continue;
        }
        // cout << i << j << k << endl;
        ++ans;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll X;
  cin >> X;

  ll a,b;
  int f=0;
  for(a=-1000;a<1000;a++){
    for(b=-1000;b<1000;b++){
      if(a*a*a*a*a-b*b*b*b*b==X){
        f=1;break;
      }
    }
    if(f==1) break;
  }

  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int L, R;
    cin >> L >> R;
    vector<int> v;
    for (int i = 0; i <= min(2019 * 2, R - L); i++) { v.push_back((L + i) % 2019); }
    int ans = INF;
    for (int i = 0; i < v.size() - 1; i++) {
        for (int j = i + 1; j < v.size(); j++) {
            ans = min(ans, (v[i] * v[j]) % 2019);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
int M = 1e9+7;
 
int main() {
   
    //Fast IO crap
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++) {
    	if(s[i] != t[i]) ans++;
    }
   	
   	cout << ans;
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)

int main(){
	
	int a,b,c;cin>>a>>b>>c;
	if(a+b>=c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

//cout << ans << endl;

Measured memory_bytes: 256