akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    
    vector<pii> p;
    irep(i, n) {
        int a, b;
        cin >> a >> b;
        p.push_back({b, a});
    }

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

    bool ok = true;
    ll now = 0;
    irep(i, n) {
        if(now + p[i].se > p[i].fi) { 
            ok = false;
            break;
        } else {
            now += p[i].se;
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 5328
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll n,Y;
    cin>>n>>Y;
    ll ans[3];
    ans[0]=-1;
    ans[1]=-1;
    ans[2]=-1;
    for(ll x=0;x<=n;++x){
        for(ll y=0;y<=n;++y){
            ll z=(Y-(10000*x)-(5000*y))/1000;
            if(z==n-x-y and 0<=z){
                ans[0]=x;
                ans[1]=y;
                ans[2]=z;
            }
        }
    }
    cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<endl;
}

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

using namespace std;

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

  long long n, d, x, y;
  int cnt = 0;
  cin >> n >> d;
  while (n--) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) ++cnt;
  }
  cout << cnt;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n,a,b;
	cin >> n >> a >> b;
	
	cout << min(b, n*a) << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
/*
  B - Contest with Drinks Easy
  Contest 050
  Rakesh Kumar --> 04/08/2020
 */

#include <bits/stdc++.h>

using ull = unsigned long long int;

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

    int n = 0;
    std::cin >> n;

    std::vector<int> v;
    ull total = 0;
    while (n--) {
        int t = 0;
        std::cin >> t;
        total += t;
        v.emplace_back(t);
    }

    int m = 0;
    std::cin >> m;
    while (m--) {
        int p = 0, x = 0;
        std::cin >> p >> x;
        std::cout << total + - v[p - 1] + x << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  int n;
  cin >> n;
  cin >> s;
  int ans = 0;
  REP(i, n - 2) {
    if (s[i] == 'A') {
      if (s[i + 1] == 'B' && s[i + 2] == 'C')
        ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

def to_bits(n):
    if n == 0:
        return [0]
    else:
        bits = []
        while (n != 0):
            bit = n % 2
            bits.append(bit)
            n = (n - bit) // (-2)
        return list(reversed(bits))

print(''.join([str(bit) for bit in to_bits(N)]))


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<int> h(H,0), w(W,0);
  vector<vector<char>> table(H, vector<char>(W));
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> table.at(i).at(j);
    }
  }
  for(int i = 0; i < H; i++ ){
    int flag = 0;
    for(int j = 0; j < W; j++ ){
      if(table.at(i).at(j) == '#'){
        flag = 1;
        break;
      }
    }
    if(flag == 1){
      h.at(i) = 1;
    }
  }
  for(int i = 0; i < W; i++ ){
    int flag = 0;
    for(int j = 0; j < H; j++ ){
      if(table.at(j).at(i) == '#'){
        flag = 1;
        break;
      }
    }
    if(flag == 1){
      w.at(i) = 1;
    }
  }
  
  for(int i = 0; i < H; i++){
    if(h.at(i) == 0){
      continue;
    }
    for(int j = 0; j < W ; j++){
      if(w.at(j) == 0){
        if(j == W-1){
          cout << endl;
        }
        continue;
      }else{
        cout << table.at(i).at(j);
        if(j == W-1){
          cout << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int Lucky = 0;
  scanf("%d", &n);
  for(int i=0;i<3;i++){
    if(n%10==7)
      Lucky = 1;
    n= n/10;
  }
   if(Lucky==1){
     printf("Yes");
   }else{
    printf("No");
   }
  
  return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }


signed main()
{
  string s; ll k; cin>>s>>k;
  ll n=s.size();
  ll ans=0;
  
  if(n==1){
    ans=k/2;
    cout<<ans<<endl;
    return 0;
  }
  
  ll top=0;
  ll back=0;
  ll cnt=0;
  for(ll i=0;i<n;i+=cnt){
    cnt=1;
    for(ll j=i+1;j<n;j++){
      if(s[i]==s[j]) cnt++;
      else break;
    }
    if(i==0){
        top=cnt;
        continue;
    }
    if(i+cnt>=n){
        back=cnt;
        continue;
    }
    ans+=cnt/2;
  }
  
  ans*=k;
  
  if(top==n){
    ans=(n*k)/2;
  }else{
    if(s[0]==s[n-1]) ans+=(top+back)/2*(k-1)+top/2+back/2;
    else ans+=k*(top/2+back/2);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

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

    bool rev = false;
    list<int> a;
    for(int i=0;i<N;i++){
        int v;
        cin >> v;
        if(rev) a.push_front(v);
        else a.push_back(v);
        rev = !rev;
    }

    vector<int> b(a.begin(), a.end());
    if(rev){
        for(int i=N-1;i>0;i--){
            cout << b[i] << " ";
        }
        cout << b[0] << endl;
    }else{
        for(int i=0;i<N-1;i++){
            cout << b[i] << " ";
        }
        cout << b[N-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 9216
n = int(input())
height_list = [int(i) for i in input().split(" ")]
is_see_count = 0
for i in range(n):
    if n == 0:
        is_see_count += 1
    else:
        height = height_list[i]
        for j in range(i):
            if not height >= height_list[j]:
                break
        else:
            is_see_count += 1
print(is_see_count)


Measured memory_bytes: 3060
package main
import "fmt"
func main() {
  var n,t,w int
  var c,s,f []int
  fmt.Scan(&n)
  c = make([]int,n)
  s = make([]int,n)
  f = make([]int,n)
  for i:=0;i<n-1;i++ {
    fmt.Scan(&c[i],&s[i],&f[i])
  }
  c[n-1] = 0
  s[n-1] = 0
  f[n-1] = 1
  for i:=0;i<n;i++ {
    t = s[i] + c[i]
    for j:=i+1;j<n;j++ {
      if t <= s[j] {
        t = s[j] + c[j]
      } else {
        w = (t+f[j]-1)/f[j]
        t = w*f[j] + c[j]
      }
    }
    fmt.Println(t)
  }
}

Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;

class Program{
    static void Main(string[] args){
        var arr = Console.ReadLine().Split();
        var N = int.Parse(arr[0]);
        var C = int.Parse(arr[2]);
        var B = Console.ReadLine().Split().Select(int.Parse);
        var answer = 0;
        for (int i = 1; i <= N; i++){
            var A = Console.ReadLine().Split().Select(int.Parse);
            var sum = 0;
            foreach (var (a,b) in A.Zip(B)){
                sum += a * b;}
            if (sum + C > 0) answer++;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 28392
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll s,t,x;
};

bool asc(s_t left,s_t right) {
  return left.x < right.x;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n,q;
  cin>>n>>q;
  vector<s_t>v;
  s_t z;
  for(ll i=0;i<n;i++){
    cin>>z.s>>z.t>>z.x;
    v.push_back(z);
  }
  sort(v.begin(),v.end(),asc);
  set<ll>st;
  vector<ll>vv(q,0);
  for(ll i=0;i<q;i++){
    cin>>vv[i];
    st.insert(vv[i]);
  }
  map<ll,ll>mp;
  for(ll i=0;i<n;i++){
    ll a=v[i].s-v[i].x;
    ll b=v[i].t-v[i].x;
    // auto it1=lower_bound(st.begin(),st.end(),a);
    // auto it2=lower_bound(st.begin(),st.end(),b);
    auto it1=st.lower_bound(a);
    auto it2=st.lower_bound(b);
    for(auto itr=it1;itr!=it2;) {
      mp[*itr]=v[i].x+1;
      itr=st.erase(itr);
    }
  }
  for(ll i=0;i<q;i++){
    ll ans=mp[vv[i]]-1;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 29420
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;

int N,F,ans=0;
map< P , int > mp;

int main(){
  cin>>N>>F;
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    vector<string> v(K);
    for(int j=0;j<K;j++){
      cin>>v[j];
      for(int k=0;k<j;k++){
        string a=v[j];
        string b=v[k];
        if(a>b)swap(a,b);
        mp[ P(a,b) ]++;
        if(mp[ P(a,b) ]==F)ans++;
      }
    }
  }

  cout<<ans<<endl;
  map< P , int > :: iterator it;
  for(it=mp.begin();it!=mp.end();it++){
    if( it->second >= F ){
      cout<< it->first.first <<' '<< it->first.second <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3408
c = list( map(int, input().split()) )

n = c[0]
all = c[1]

okflag = False

for x in range(0, n+1):
  for y in range(0, n+1-x):
    z = n - x - y
    if (((10000*x) + (5000*y) + (1000*z) ) == all):
      print(str(x) + " " + str(y) + " " + str(z))
      exit()

print("-1 -1 -1")

Measured memory_bytes: 3064
n, x, y = map(int, input().split())


d = [0]*(n-1)
for i in range(1, n):
    for j in range(i+1,n+1):
        c = min(j-i, abs(i-x)+1+abs(j-y))
        d[c-1] = d[c-1] + 1

for i in d:
    print(i)

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

int main() {
	vector<string> e;
	string s;
	while (getline(cin, s), s != "END_OF_TEXT") {
		e.push_back(s);
	}
	int y = 0, x = 0;
	string buffer = "";
	char c;
	while (cin >> c, c != '-') {
		switch (c) {
			case 'a':
				x = 0;
				break;
			case 'e':
				x = e[y].size();
				break;
			case 'p':
				x = 0;
				y = max(0, y-1);
				break;
			case 'n':
				x = 0;
				y = min((int)e.size()-1, y+1);
				break;
			case 'f':
				if (x < e[y].size()) {
					++x;
				} else if (y+1 < e.size()) {
					x = 0;
					++y;
				}
				break;
			case 'b':
				if (0 < x) {
					--x;
				} else if (0 <= y-1) {
					x = e[y-1].size();
					--y;
				}
				break;
			case 'd':
				if (x < e[y].size()) {
					e[y] = e[y].substr(0,x) + e[y].substr(x+1);
				} else if (y+1 < e.size()) {
					e[y] += e[y+1];
					e.erase(e.begin()+y+1);
				}
				break;
			case 'k':
				if (x < e[y].size()) {
					buffer = e[y].substr(x);
					e[y] = e[y].substr(0,x);
					x = e[y].size();
				} else if (y+1 < e.size()) {
					buffer = "\n";
					e[y] += e[y+1];
					e.erase(e.begin()+y+1);
				}
				break;
			case 'y':
				if (buffer != "") {
					if (buffer == "\n") {
						e.insert(e.begin()+y+1, e[y].substr(x));
						e[y] = e[y].substr(0,x);
						x = 0;
						++y;
					} else {
						e[y] = e[y].substr(0,x) + buffer + e[y].substr(x);
						x += buffer.size();
					}
				}
				break;
		}
	}
	for (int i=0; i<e.size(); ++i) {
		cout << e[i] << endl;
	}
	return 0;
}

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

int main(){
  int a[100], p;
  char s[199];
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      a[p-1] = a[p-1] + a[p];
      p--;
    }else if(s[0] == '-'){
      a[p-1] = a[p-1] - a[p];
      p--;
    }else if(s[0] == '*'){
      a[p-1] = a[p-1] * a[p];
      p--;
    }else{
      p++;
      a[p] = atoi(s);
    }
  }
  printf("%d\n", a[p]);
  return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007

int main(){
    int n;
    cin>>n;
    int a[n];
  	ll cnt[200010]={};
    rep(i,0,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll ttl=0;
    rep(i,0,200010){
        if(cnt[i]>0){
            ttl+=cnt[i]*(cnt[i]-1)/2;
        }
    }
    rep(i,0,n){
        cout<<ttl-cnt[a[i]]+1<<endl;
    }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define maxn 300005
#define eps 1e-5
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,p,k;
char ch[1005];
bool solve(int l,int r){
	int i;
	for(i=l;i<=r;i++) if(ch[i]!=ch[r-(i-l)]) return 0;
	for(i=1;i<=(r-1)/2;i++) if(ch[i]!=ch[(r-1/2)-(i-1)]) return 0;
	for(i=(r+3)/2;i<=r;i++) if(ch[i]!=ch[r-(i-(r+3)/2)])return 0;
	return 1;
}
int L;
int main()
{
	int i,j,l,op,x,y;
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    L=read();
    printf("%.8f",1.0*L*L*L/27);
    return 0;
} 

Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

good = Hash.new(true)

$graph = Hash.new{ |h, k| h[k] = []}

m.times do |i|
  a, b =gets.chomp.split.map(&:to_i)

  if h[a-1] >= h[b-1]
    good[b-1] = false
  end

  if h[b-1] >= h[a-1]
    good[a-1] = false
  end
end


# p good

ans = 0

n.times do |i|
  if good[i]
    ans += 1
    # puts i
  end
end

puts ans



Measured memory_bytes: 23896
#include<iostream>
using namespace std;
int main()
{
	//// 整数の入力
	//int a;
	//cin >> a;
	//// スペース区切りの整数の入力
	//int b, c;
	//cin >> b >> c;
	//// 文字列の入力
	//string s;
	//cin >> s;
	//// 出力
	//cout << (a + b + c) << " " << s << endl;


	// 1
	//int N;
	//cin >> N;
	//cout << (800 * N) - N / 15 * 200;

	int N;
	cin >> N;
	long long int p = 1;
	for (int i = 1; i <= N; i++)
	{
		p *= i;
		p %= 1000000007;
	}
	cout << p;

	return 0;
}

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

from collections import defaultdict

def main():
  n = int(input())
  la = list(map(int, input().split()))
  cum = defaultdict(int)
  for i, a in enumerate(la, 1):
    cum[i - a] += 1
    
  cnt = 0
  for i, a in enumerate(la, 1):
    cnt += cum[a + i]
  print(cnt)

if __name__=='__main__':
  main()


Measured memory_bytes: 61648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000001;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int a[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	
	int ret = 0;
	rep(i,n)ret += a[i]%2;
	if(ret%2 == 0)puts("YES");
	else puts("NO");
}
	



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
    int n,q,t;
    string name;
    queue<pair<string,int> > Q;
    cin>>n>>q;
    for (int i = 0; i < n; ++i) {
        cin>>name>>t;
        Q.push(make_pair(name,t));
    }
    pair<string,int> u;
    int elaps=0,a;
    while(!Q.empty()){
        u=Q.front();Q.pop();
        a=min(u.second,q);
        u.second -= a;
        elaps +=a;
        if(u.second>0) Q.push(u);
        else cout<<u.first<<" "<<elaps<<endl;
    }
    return 0;
}



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

int main(){
	int n;
	int sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		sum += x;
	}
	cout << sum-n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N, K;
    cin >> N >> K;
    
    vector<ll> pos(N);
    REP(i, N) {
        cin >> pos[i];
    }

    ll ans = INF;
    for(int l = 0; l < N-K+1; l++) {
        int r = l+K-1;
        ans = min(ans, abs(pos[l]-pos[r]) + abs(pos[l]));
        ans = min(ans, abs(pos[l]-pos[r]) + abs(pos[r]));
    }

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

Measured memory_bytes: 1024
#include<stdio.h>

int MOD = 1000000007;

int H, W, i, j;
char M[1001][1001];
long long int ans[1001][1001];

int main(){
	scanf("%d%d", &H, &W);
	for(i=0; i<H; i++){
		scanf("%s", M+i);
	}
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(i==0 && j==0){
				ans[0][0] = 1;
			}else if(i==0){
				if(M[0][j]=='#'){
					ans[0][j] = 0;
				}else{
					ans[0][j] = ans[0][j-1];
				}
			}else if(j==0){
				if(M[i][0]=='#'){
					ans[i][0] = 0;
				}else{
					ans[i][0] = ans[i-1][0];
				}
			}else{
				if(M[i][j]=='#'){
					ans[i][j] = 0;
				}else{
					ans[i][j] = (ans[i-1][j] + ans[i][j-1]) %MOD;
				}
			}
		}
	}
	printf("%lld\n", ans[H-1][W-1]);
}


Measured memory_bytes: 8960
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
	int f = 0, ch = 0; x = 0;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
	for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
int a[100005], n;
int main(){
	read(n); int ans = 0;
	for(int i = 1; i <= n; i++) read(a[i]);
	for(int i = 2; i <= n; i++)
		if(a[i] == a[i-1]) a[i] = -1, ans++; 
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
A,B,K = map(int,input().split())
if (2*K)<(B-A+2):
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
else:
  for i in range(A,B+1):
    print(i)

Measured memory_bytes: 3060
from collections import defaultdict
import queue

N,M=map(int,input().split())
ab=[]
d=defaultdict(list)
for i in range(M):
    a,b=map(int,input().split())
    ab.append((a,b))
    d[a].append(b)
    d[b].append(a)


ans=0
for i in range(M):
    Remove=ab[i]
    d[Remove[0]].remove(Remove[1])
    d[Remove[1]].remove(Remove[0])
    
    dist=[False]*N
    q=queue.Queue()
    q.put(list(d.keys())[0])

    while not q.empty():
        From=q.get()
        dist[From-1]=True
        for g in d[From]:
            if dist[g-1]==False:
                q.put(g)
    
    if False in dist:
        ans+=1

    d[Remove[0]].append(Remove[1])
    d[Remove[1]].append(Remove[0])

print(ans)

Measured memory_bytes: 4208
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#define N 100005
#define db double
#define ll long long
int n,t[N],x[N],y[N]; 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++)
	{
		int tmp=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(tmp>t[i]-t[i-1]) {puts("No");return 0;}
		if((t[i]-t[i-1]-tmp)&1) {puts("No");return 0;}
	}
	puts("Yes");
	
	return 0;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	e := make([]int, n)
	w := make([]int, n)
	for i, v := range s {
		if v == 'E' {
			e[i] = 1
		} else {
			w[i] = 1
		}
	}
	// e, wがそれぞれその場所で何個変わるか
	for i := 1; i < n; i++ {
		w[i] += w[i-1]
		e[n-i-1] += e[n-i]

	}
	m := 9999999999
	m = min(m, e[0])
	for i := 1; i < n-1; i++ {
		//fmt.Println(e[i+1] + w[i-1])
		m = min(m, e[i+1]+w[i-1])
	}
	m = min(m, w[n-1-1])
	fmt.Println(m)
}

func min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

Measured memory_bytes: 7296
#include<stdio.h>

int main()
{
    char S[3], T[3];

    scanf("%s",S);
    scanf("%s",T);

    int count=0;
    for ( int i=0 ; i<3 ; i++)
    {
        if ( S[i]==T[i] )
        count++;
    }
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int w, h; cin>>w>>h;
        if(w == 0) return 0;
        vector<string> a(h);
        for(int i=0; i<h; i++) cin>>a[i];

        int BS = 0, WS = 0;
        vector<vector<bool>> visited(h, vector<bool>(w, false));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(a[i][j] == '.' && !visited[i][j]){
                    visited[i][j] = true;
                    queue<P> que;
                    que.push(P(i, j));
                    int S = 1;
                    bool isW = false, isB = false;
                    while(que.size()){
                        int cy, cx;
                        tie(cy, cx) = que.front();
                        que.pop();

                        for(int k=0; k<4; k++){
                            int ny = cy + dy[k];
                            int nx = cx + dx[k];

                            if(0 <= ny && ny < h && 0 <= nx && nx < w){
                                if(!visited[ny][nx] && a[ny][nx] == '.'){
                                    S++;
                                    visited[ny][nx] = true;
                                    que.push(P(ny, nx));
                                }
                                if(a[ny][nx] == 'W') isW = true;
                                if(a[ny][nx] == 'B') isB = true;
                            }
                        }
                    }

                    if(!isW && isB) BS += S;
                    if(isW && !isB) WS += S;
                }
            }
        }

        cout << BS << " " << WS << endl;
    }
}


Measured memory_bytes: 3200
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
#define L 501

struct Move {
	int x,y,tx,ty;
};
int n,m,r;
int num[L][L];
bool even[L];
vector<Move>ans;

int main() {
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<m;j++) {
			scanf("%d",&r);
			num[i][j]+=r;
			if(num[i][j]%2==1) {
				num[i][j]--,num[i][j+1]++;
				ans.push_back((Move){i,j,i,j+1});
			}
		}
		scanf("%d",&r);
		num[i][m]+=r;
		if(num[i][m]%2==1) {
			if(i==n) continue;
			num[i][m]--,num[i+1][m]++;
			ans.push_back((Move){i,m,i+1,m});
		}
	}
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++)
		printf("%d %d %d %d\n",ans[i].x,ans[i].y,ans[i].tx,ans[i].ty);
	return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#define inf 1000000007
using namespace std;
 
int main(void){
    int a[4], b[4], c[4];
    for(int i = 0; i < 3; i++)
        cin >> a[i] >> b[i] >> c[i];
    a[3]=a[0]; b[3]=b[0]; c[3]=c[0];
    for(int i = 0; i < 3; i++){
        if(a[i]+b[i+1]-a[i+1]!=b[i]){
            cout << "No" << endl; break;}
        if(b[i]+c[i+1]-b[i+1]!=c[i]){
            cout << "No" << endl; break;}
        if(c[i]+a[i+1]-c[i+1]!=a[i]){
            cout << "No" << endl; break;}
        if(i==2)
            cout << "Yes" << endl;                        
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int K,A,B;
    cin>>K>>A>>B;

    if(B-A<=2 or K<A-1){
        cout<<K+1<<endl;
    }
    else{
        int ans=A;
        ans+=(B-A)*((K-A+1)/2)+(K-A+1)%2;
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int array[4][3][10];
  int n,i,j,k,sharp;
  int b,f,r,v;
   
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++)  array[i][j][k]=0;
    }
  }
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&b,&f,&r,&v);
    array[b-1][f-1][r-1]+=v;
  }
   
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++)  printf(" %d",array[i][j][k]);
      printf("\n");
    }
    for(sharp=0;sharp<20;sharp++)  printf("#");
    printf("\n");
  }
   
  for(j=0;j<3;j++){
    for(k=0;k<10;k++)  printf(" %d",array[3][j][k]);
    printf("\n");
  }
   
  return 0;
}

Measured memory_bytes: 600
def main():
    _ = int(input())
    A = [int(i) for i in input().split() if int(i) % 2 == 0]
    ans = 0
    while A and any(a % 2 == 0 for a in A):
        A = [a//2 for a in A if a % 2 == 0]
        ans += len(A)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41708
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        ArrayList<Integer> val_1 = new ArrayList<Integer>();
        ArrayList<Integer> val_2 = new ArrayList<Integer>();
        ArrayList<Integer> val_3 = new ArrayList<Integer>();
        ArrayList<Integer> val_4 = new ArrayList<Integer>();
        int w1 = Integer.parseInt(sc.next());
        int v1 = Integer.parseInt(sc.next());
        val_1.add(v1);
        for (int i=0;i<N-1;i++) {
            int w = Integer.parseInt(sc.next());
            int v = Integer.parseInt(sc.next());
            if (w==w1) {
                val_1.add(v);
            } else if (w==w1+1) {
                val_2.add(v);
            } else if (w==w1+2) {
                val_3.add(v);
            } else { // w==w1+3
                val_4.add(v);
            }
        }
        Collections.sort(val_1, (o1, o2) -> Integer.compare(o2, o1));
        Collections.sort(val_2, (o1, o2) -> Integer.compare(o2, o1));
        Collections.sort(val_3, (o1, o2) -> Integer.compare(o2, o1));
        Collections.sort(val_4, (o1, o2) -> Integer.compare(o2, o1));
        // System.out.println(val_1);
        // System.out.println(val_2);
        // System.out.println(val_3);
        // System.out.println(val_4);
        long[] dp_1 = new long[val_1.size()+1];
        long[] dp_2 = new long[val_2.size()+1];
        long[] dp_3 = new long[val_3.size()+1];
        long[] dp_4 = new long[val_4.size()+1];
        for (int i=0;i<val_1.size();i++) {
            dp_1[i+1] = dp_1[i]+(long)val_1.get(i);
        }
        for (int i=0;i<val_2.size();i++) {
            dp_2[i+1] = dp_2[i]+(long)val_2.get(i);
        }
        for (int i=0;i<val_3.size();i++) {
            dp_3[i+1] = dp_3[i]+(long)val_3.get(i);
        }
        for (int i=0;i<val_4.size();i++) {
            dp_4[i+1] = dp_4[i]+(long)val_4.get(i);
        }
        long ans = 0L;
        for (int i=0;i<=N;i++) {
            for (int j=0;j<=N;j++) {
                for (int k=0;k<=N;k++) {
                    for (int l=0;l<=N;l++) {
                    // int l = Math.min(val_4.size(), N-i-j-k);
                    if (l<0) {
                        continue;
                    }
                    if (i>val_1.size() || j>val_2.size() || k>val_3.size() || l>val_4.size()) {
                        continue;
                    }
                    // System.out.println("a: " + ((long)w1*i+(long)(w1+1)*j+(long)(w1+2)*k+(long)(w1+3)*l));
                    if (((long)w1*i+(long)(w1+1L)*j+(long)(w1+2L)*k+(long)(w1+3L)*l)>(long)W) {
                        // System.out.println("aa");
                        continue;
                    }
                    ans = Math.max(ans, dp_1[i]+dp_2[j]+dp_3[k]+dp_4[l]);
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28372
#include <iostream>

using namespace std;

int ans=0;
int N;
int a[200010];
bool continueflag=true;

void solve(int target, int start){
  for(int i=start; i<N; i++){
    if(a[i]==target){
      ans+=i-start;
      start=i+1;
      break;
    }
    if(i==N-1&&target==1){
      ans=-1;
      continueflag=false;
    }
    if(i==N-1&&target!=1){
      ans+=N-start;
      continueflag=false;
    }
  }
  if(target<N-1&&continueflag==true) solve(target+1, start);
}

int main(){
  cin >> N;
  for(int i=0; i<N; i++) cin >> a[i];
  solve(1, 0);
  cout << ans << endl;
  
  return 0;
}

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

using ll = long long;

const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N];
std::vector<ll> v[N];
bool dfs(ll node) {
    for (auto i : v[node]) {
        if (a[node] <= a[i]) return false;
    }
    return true;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i + 1];
    }

    for (int i = 0; i < m; ++i) {
        ll xx, yy;
        cin >> xx >> yy;
        v[xx].push_back(yy);
        v[yy].push_back(xx);
    }

    for (int i = 1; i <= n; ++i) {
        res += dfs(i);
    }
    cout << res;
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}// smf

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a + b > 9) cout << "error" << endl;
    else cout << a + b << endl;
    return 0;
}

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

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int r = st[0];
            int g = st[1];
            int b = st[2];

            if ((10 * g + b) % 4 == 0) {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 11348
;;;; heap

(defstruct (binary-heap (:conc-name bh-))
  (predicate #'>=)
  (nodes (make-array (list 1024) :adjustable t :fill-pointer 0)))

(defun bh-empty (binary-heap)
  (= (length (bh-nodes binary-heap)) 0))

(defun bh-tail (binary-heap)
  (1- (length (bh-nodes binary-heap))))

(defun bh-invalid-index (binary-heap index)
  (> index (bh-tail binary-heap)))
  
(defun bh-parent (index)
  (when (> index 0)
    (1- (ceiling index 2))))

(defun bh-left (index)
  (+ (* index 2) 1))

(defun bh-right (index)
  (+ (* index 2) 2))

(defun bh-ref (binary-heap index)
  (if (bh-invalid-index binary-heap index)
      nil
      (aref (bh-nodes binary-heap) index)))

(defun bh-ref (binary-heap index)
  (when (<= index (bh-tail binary-heap))
    (aref (bh-nodes binary-heap) index)))

(defsetf bh-ref (binary-heap index) (value)
  `(setf (aref (bh-nodes ,binary-heap) ,index) ,value))

(defun bh-compare (binary-heap p c)
  (cond ((bh-invalid-index binary-heap p)
         nil)
        ((bh-invalid-index binary-heap c)
         t)
        (t
         (funcall (bh-predicate binary-heap) (bh-ref binary-heap p) (bh-ref binary-heap c)))))

(defun bh-rotate (binary-heap a b)
  (rotatef (bh-ref binary-heap a) (bh-ref binary-heap b)))


(defun up-heap (value binary-heap)
  (vector-push-extend value (bh-nodes binary-heap))
  (let* ((c (bh-tail binary-heap))
         (p (bh-parent c)))
    (loop :while p
          :until (bh-compare binary-heap p c)
          :finally (return binary-heap)
          :do (bh-rotate binary-heap p c)
          :do (setf c p)
          :do (setf p (bh-parent c))))
    binary-heap)

(defun down-heap (binary-heap)
  (when (not (bh-empty binary-heap))
    (prog1 (bh-ref binary-heap 0)
      (bh-rotate binary-heap 0 (bh-tail binary-heap))
      (vector-pop (bh-nodes binary-heap))
      (when (not (bh-empty binary-heap))
        (let* ((c 0))
          (loop :for l := (bh-left c)
                :for r := (bh-right c)
                :until (and (bh-compare binary-heap c l) (bh-compare binary-heap c r))
                :do (cond ((bh-compare binary-heap l r)
                           (bh-rotate binary-heap c l)
                           (setf c l))
                          (t
                           (bh-rotate binary-heap c r)
                           (setf c r)))))))))

;; main
(let* ((n (read))
       (m (read))
       (h (make-binary-heap))
       (ans 0))
  (loop :for i :from 1 :to n
        :for a := (read)
        :do (up-heap a h))
  (loop :for i :from 1 :to m
        :for x := (down-heap h)
        :do (up-heap (floor (/ x 2)) h))
  (loop :for i :from 1 :to n
        :for x := (down-heap h)
        :do (incf ans x))
  (format t "~A~%" ans))


Measured memory_bytes: 77692
def nck(n, k, mod):
    result = 1
    for i in range(n - k + 1, n + 1):
        result = result * i % mod
    tmp = 1
    for i in range(1, k + 1):
        tmp = tmp * i % mod
    return result * pow(tmp, mod - 2, mod) % mod


def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    print((pow(2, n, mod) - nck(n, a, mod) - nck(n, b, mod) - 1) % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

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

	int H, N;
	H = sc.nextInt();
	N = sc.nextInt();
	
	int A[] = new int[N];
	int sum = 0;
	for (int i = 0; i < N; i++) {
	    A[i] = sc.nextInt();
	    sum += A[i];
	}

	if (H > sum)
	    System.out.println("No");
	else
	    System.out.println("Yes");
    }
}

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

using namespace std;

#define mod 1000000007


int main()
{
	int n, k;
	cin >> n >> k;
	long long int a[20];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<pair<long long int, long long int> > result((1 << n), make_pair(-1, -1));
	result[1] = make_pair((long long int)0, a[0]);
	long long int ans = -1;
	for(int i = 1; i < (1 << n); i++){
		if(result[i].first == -1) continue;
		long long int nowcost = result[i].first;
		long long int nowmaxheight = result[i].second;
		for(int j = n - 1; j >= 0; j--){
			if((i & (1 << j)) != 0) break;
			bool flag = true;
			for(int k = j - 1; k >= 0; k--){
				if((i & (1 << k)) != 0) break;
				if(a[k] > nowmaxheight) flag = false;
			}
			if(!flag) continue;
			long long int nextcost = nowcost + max((long long int)0, nowmaxheight + 1 - a[j]);
			long long int nextmaxheight = max(a[j], nowmaxheight + 1);
			if(result[i | (1 << j)].second == -1 || result[i | (1 << j)].second > nextmaxheight){
				result[i | (1 << j)] = make_pair(nextcost, nextmaxheight);
			}
		}
		int cnt = 0;
		for(int j = 0; j < n; j++){
			if((i & (1 << j)) != 0) cnt++;
		}
		if(cnt >= k){
			if(ans == -1 || ans > result[i].first) ans = result[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define ALL(v) (v).begin(), (v).end()
typedef pair<ll, ll> P;

int main(){
    string st;
    int k;
    cin >> st >> k;

    set<string> ans;
    string s;

    REP(i, st.length()) {
        s = st.substr(i, 1);
        ans.insert(s);
    }

    if(1 < st.length()) {
        REP(i, st.length()-1) {
            s = st.substr(i, 2);
            ans.insert(s);
        }
    }

    if(2 < st.length()) {
        REP(i, st.length()-2) {
            s = st.substr(i, 3);
            ans.insert(s);
        }
    }


    if(3 < st.length()) {
        REP(i, st.length()-3) {
            s = st.substr(i, 4);
            ans.insert(s);
        }
    }

    if(4 < st.length()) {
        REP(i, st.length()-4) {
            s = st.substr(i, 5);
            ans.insert(s);
        }
    }

    auto itr = ans.begin();
    REP(i, k) {

    }
    REP(i, k-1) {
        itr++;
    }
    cout << *itr << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 3005;
const int MAXH = 100005;
const LL MOD = 1000000007;

#define x first
#define y second

int N, H, W;
PII ps[MAXN];
LL dp[MAXN], fac[2*MAXH], inv[2*MAXH], ans;

LL possible_path(int r1, int c1, int r2, int c2) {
	int dr = r2 - r1, dc = c2 - c1;
	if (dr < 0 || dc < 0) return 0;
	return fac[dr + dc] * inv[dr] % MOD * inv[dc] % MOD;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> H >> W >> N;
	
	fac[0] = inv[0] = inv[1] =1;
	for (int i = 1; i <= H + W; i++) fac[i] = fac[i - 1] * i % MOD;
	for (int i = 2; i <= H + W; i++) inv[i] = -MOD / i * inv[MOD % i] % MOD;
	for (int i = 1; i <= H + W; i++) inv[i] = inv[i - 1] * inv[i] % MOD;
	
	for (int i = 1; i <= N; i++) {
		cin >> ps[i].x >> ps[i].y;
	}
	
	sort(ps + 1, ps + 1 + N);
	ans = possible_path(1, 1, H, W);
	for (int i = N; i >= 1; i--) {
		int r = ps[i].x, c = ps[i].y;
		dp[i] = possible_path(r, c, H, W);
		
		for (int j = i + 1; j <= N; j++) {
			int r2 = ps[j].x, c2 = ps[j].y;
			dp[i] = (dp[i] - possible_path(r, c, r2, c2) * dp[j]) % MOD;
		}
		
		ans = (ans - possible_path(1, 1, r, c) * dp[i]) % MOD;
	}
	
	cout << (ans + MOD) % MOD << "\n";
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    int n, k, ct0 = 0, ct1 = 0;
    string s;

    vector<int> v;

    cin >> n >> k;
    cin >> s;

    s += '2';

    bool flag = true;
    int now = 0;

    if (s[0] == '0')
    {
        flag = false;
        v.push_back(0);
    }

    for (int i = 0; i <= n; i++)
    {
        //1
        if (flag)
        {
            if (s[i] == '1')
            {
                now++;
            }
            else
            {
                v.push_back(now);
                now = 1;
                flag = false;
            }
        }
        //0
        else
        {
            if (s[i] == '0')
            {
                now++;
            }
            else
            {
                v.push_back(now);
                ct0++;
                now = 1;
                flag = true;
            }
        }
    }

    // cout << ct0 << endl;

    v.push_back(0);

    if (ct0 <= k)
    {
        cout << n;
    }
    else
    {
        int res = 0;
        int tmp = 0;
        int first = 1, last = 2 * (k - 1) + 1;
        for (int i = 0; i < k; i++)
        {
            tmp += v[2 * i + 1] + v[2 * i];
        }

        tmp += (v[last + 1]);

        res = tmp;

        //cout << res << endl;

        for (int i = 1; i <= ct0 - k; i++)
        {
            tmp -= (v[first] + v[first - 1]);
            last += 2;
            first += 2;
            tmp += (v[last] + v[last + 1]);
            res = max(res, tmp);
        }
        cout << res;
    }
}


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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<string,int>> S(N);
    ll ac = 0; 
   repo(i,M){
        ll index = 0;
        string s;
        cin >> index >> s;
        index--;
//         cout << "firstは : "<< S[index].first << "secondは : " <<S[index].second << endl;
//         if(s == "AC") ac++; 
        if(S[index].first == ""){
            
            S[index].first = s;
            S[index].second++;
        }else if(S[index].first == "WA"){
//             S[index].first = s;
           if(S[index].first != s)
                S[index].first = s; 
           S[index].second++; 
        }
//         cout << S[index].first << S[index].second << endl;
   } 
   int sum = 0;
//    ll ac = 0;
   repo(i,N){
//        cout << i << "版目のsecondの値は" << S[i].second << endl;
       if(S[i].first == "" || S[i].first == "WA") continue;
       sum += S[i].second;
       if(S[i].first == "AC")
            ac++;
   }
//    sum = max(0,sum-ac)

//    repo(i,N){
//        cout << i << "版目のSのfirstは : " << S[i].first << "second : " << S[i].second << endl;
//    }
   cout << ac << " " <<sum-ac << endl;

    return 0;
}



Measured memory_bytes: 6528
#include <stdio.h>

long long int sum(long long int number) {
  if(number < 10) {
    return number;
  } else {
    return number % 10 + sum(number / 10);
  }
}

int main() {
  long long int number, sum_number;
  scanf("%lld", &number);
  sum_number = sum(number);
  if(number % sum_number == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


int c[15];
int a[15][15];

void solve()
{
   int n,m,x;
    cin >> n >> m >> x;
    
    f(i,n)
    {
        cin >> c[i];
        f(j,m) cin >> a[i][j];
    }
    
    int res = -1;
    
    for(int i=1;i<(1LL<<n);i++)
    {
        vi under(m,0);
        
            int cost = 0;
        for(int j=0;j<n;j++)
        {
            if((i&(1LL<<j)))
            {
                cost+=c[j];
                f(k,m) under[k]+=a[j][k];
            }
        }
        
        int flag = 1;
        
        f(j,m) if(under[j] < x) flag = 0;
            
        if(flag == 1)
        {
            if(res == -1) res=  cost;
            else res = min(res,cost);
        }
    }
    
    cout << res;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3652
import numpy as np
n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros((n,3),int)
for i in range(n):
  for j in range(3):
    dp[i][j]=ABC[0][j] if i==0 else max(dp[i-1][(j+1)%3]+ABC[i][j], dp[i-1][(j+2)%3]+ABC[i][j])
  
print(max(dp[-1]))


Measured memory_bytes: 41792