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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> S;
    cin >>N;

    vector<int> T(N);
    vector<int> F(N);
    vector<char> C(N);

    REP(i,N){
        T.at(i) = 0;
        F.at(i) = 0;
    }

    REP(i,N){
        cin >> T.at(i);
        if(T.at(i)==2){
            cin >> F.at(i) >> C.at(i);
        }
    }
    //cout << "test" << endl;

    /*REP(i,N){
        cout << F.at(i) << C.at(i) << endl;
    }*/

    bool jyunretsu = true;
    
    
    string S_for, S_rev;
    //cout << "test" << endl;

    REP(i,N){
        if(T.at(i)==1){
            if(jyunretsu==true){
                jyunretsu = false;
            }
            else{
                jyunretsu = true;
            }
        }
        else{
            if(F.at(i)==1){
                if(jyunretsu==true){
                    S_for.push_back(C.at(i));
                }
                else{
                    S_rev.push_back(C.at(i));
                }
            }
            else{
                if (jyunretsu == true)
                {
                    S_rev.push_back(C.at(i));
                }
                else
                {
                    S_for.push_back(C.at(i));
                }
            }
        }
    }

    //cout << "test" << endl;
    //cout << S_for.size() << endl;
    ll tmp = S_for.size();
    //cout << S_for << endl;
    //cout << S_rev << endl;
    string S_tmp1=S_for;

    REP(k,tmp){
        //cout << "test1" << endl;
        //cout << k << " " << tmp - k - 1 << endl;
        //cout << S_tmp1.at(0) << endl;
        S_tmp1.at(k) = S_for.at(tmp - k - 1);
    }
    S_for = S_tmp1;
    //cout << "test" << endl;
    //cout << S << endl;

    S = S_for + S;
    S = S+S_rev;

    //cout << "test" << endl;
    //cout << S << endl;
    string S_tmp=S;

    if (jyunretsu == false)
    {
        REP(j, S.size())
        {
            S_tmp.at(j) = S.at(S.size() - j - 1);
        }
        S = S_tmp;
    }
    //cout << "test" << endl;

    cout << S << endl;
}


Measured memory_bytes: 3308
x = gets.to_i
a = x / 100 # 100円のおにぎりを買えるだけ買う
b = x % 100 # b円余る
puts b <= a * 5 ? 1 : 0 # 余ったお金は最大でおにぎりを全てパソコンに変えるだけ消費できる


Measured memory_bytes: 1788
#include<cstdio>
long long n,a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for(int i=0;i<n;i++){
		if(c*(n-1-i)-d*i<=b-a&&d*(n-1-i)-c*i>=b-a){
			puts("YES");return 0;
		}
	}
	return 0*puts("NO");
}

Measured memory_bytes: 128
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
#define ll long long
const int N = (ll)(2e5) + 100;
 
int div_cel(int n, int k) {
    return (n + k - 1) / k;
}

void solve() {
    int a,b,c;cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c;
}
 
 
int main() {
    solve();
    return 0;
}

// 41 59 31
// 59 41 31
// 31 41 59


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  rep(i, b) cout << a;
  cout << endl;
}


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

int main() {
	vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int K;
	cin >>K;

	cout <<a.at(K-1)<<endl;

}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  long long money = 1000;
  rep(i, N - 1)
  {
    if (A[i] < A[i + 1])
    {
      long long num = money / A[i];
      money -= A[i] * num;
      money += A[i + 1] * num;
    }
  }

  cout << money << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#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 rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
        a[i]-=i+1;
    }
    sortup(a,n);
    ll b=a[n/2];
    rep(i,0,n){
        ans+=ABS(a[i]-b);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3324
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <vector>

#define fprintf(...) (void)0

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

  std::vector<intmax_t> a(n);
  for (size_t i=0; i<n; ++i)
    scanf("%jd", &a[i]);

  auto sgn=[](intmax_t x)->intmax_t {
    return x>0? 1:-1;
  };

  intmax_t res=1e17;
  {
    // positive, negative, positive, ...
    intmax_t sum=0, cur=0;
    if (a[0] <= 0) {
      sum = 1;
      cur = -a[0] + 1;
    } else {
      sum = a[0];
    }

    fprintf(stderr, "%jd", sum);
    for (size_t i=1; i<n; ++i) {
      if (sum + a[i] == 0) {
        sum = -sgn(sum);
        ++cur;
      } else if ((sum < 0) ^ (sum + a[i] < 0)) {
        sum += a[i];
      } else {
        cur += std::abs(sum+a[i]-sgn(-sum));
        sum = sgn(-sum);
      }
      fprintf(stderr, " %jd(%jd)", sum, cur);
    }
    res = std::min(res, cur);
    fprintf(stderr, "\n");
  }

  {
    // negative, positive, negative, ...
    intmax_t sum=0, cur=0;
    if (a[0] >= 0) {
      sum = -1;
      cur = a[0] + 1;
    } else {
      sum = a[0];
    }

    fprintf(stderr, "%jd", sum);
    for (size_t i=1; i<n; ++i) {
      if (sum + a[i] == 0) {
        sum = -sgn(sum);
        ++cur;
      } else if ((sum < 0) ^ (sum + a[i] < 0)) {
        sum += a[i];
      } else {
        cur += std::abs(sum+a[i]-sgn(-sum));
        sum = sgn(-sum);
      }
      fprintf(stderr, " %jd(%jd)", sum, cur);
    }
    res = std::min(res, cur);
    fprintf(stderr, "\n");
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int i,a,b,c,count=0;
      cin>>a>>b>>c;
      if(a!=b)
      	count++;
      if(b!=c)
      	count++;
      if(c!=a)
      	count++;
      if(a==b && b==c)
      	count=1;
      cout<<count<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int max(int p0,int p1){
  return((p0>p1)?p0:p1);
}

int main(){
  int n,x,y,k,m,mid,l,p;
  scanf("%d",&n);
  scanf("%d",&x);
  scanf("%d",&y);
  for(k=1;k<n;k++){
    mid=(x+y)/2;
    l=y-x+1;
    m=max(mid-k,0)-max(mid-x-k,0); //AA,AB
    m+=max(n-mid-k,0)-max(y-mid-1-k,0); //CD,DD
    m+=max(x+y-mid-k,0)-max(x+1-k,0)-max(y-mid-k,0); //AC
    m+=max(n+x-y+1-k,0)-max(x-k,0)-max(n-y+1-k,0); //AD
    m+=max(mid-x+n-y+2-k,0)-max(n-y+2-k,0)-max(mid-x+1-k,0)-(((x+y)%2==0)&(mid-x+1<=k)&(mid-x+1+n-y>=k)); //BD
    p=1+(l>k*2)-(l<k*2);
    m+=p*l/2-p*2+(k==1); //BB,BC,CC
    m+=((x+y)%2==0)&(y-mid<=k)&(mid+k<=n); //MD
    printf("%d\n",m);
  }
  return(0);
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;

        for (int i = 0; i <= n; i++) {
                if (i * (i + 1) / 2 >= n) {
                        cout << i;
                        return;
                }
        }
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3604
# key not available ""
import sys
n, k = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print(dp[-1])


Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000
#define limit 200001
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
    int n, k;
    cin >> n >> k;

    vector<ld> a(n);


    ld l0 = 1.0, h0 = 0;
    rep(i,n)
    {
        cin >> a[i];
        h0 = max(h0, a[i]);
    }

    rep(i,100)
    {
        ld m0 = (l0 + h0)/2.0;

        lli opr = 0;
        rep(j,n)
            opr += (int)floor(a[j]/m0);
        
        if(opr <= k)
            h0 = m0;
        else 
            l0 = m0;
    }
    cout << (int)ceil(l0) << '\n';
}
 
int main()
{
    

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

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

int main() {
 	string n; 
	cin >> n;
	int ans;
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  
  
    for( int i=0; i<n.size(); i++)
    {
     if(n.at(i) == '1')
      {a ++;}
     else if(n.at(i) == '2')
      {a += 2;}
     else if(n.at(i) == '3')
      {a += 3;}
     else if(n.at(i) == '4')
      {a += 4;}
      
     else if(n.at(i) == '5')
      {a += 5;}
     else if(n.at(i) == '6')
      {a += 6;}
     else if(n.at(i) == '7')
      {a += 7;}
     else if(n.at(i) == '8')
      {a += 8;}
      
      if(a>=9)
      {a -= 9;}
      
    }
  

  
  
if(a == 0 )
{	cout << "Yes" << endl;}
  else
  {cout << "No" << endl;}
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iterator>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const int MAX_N = 100000;

struct edge{int to; ll cap; int rev;};

int n, m;
vector<int> degrees(MAX_N, 0);

vector<edge> G[MAX_N];
vector<int> level(MAX_N, -1);
vector<int> iter(MAX_N, 0);
int H, W, s, t;

void add_edge(int from, int to, ll cap){
    /*
        ある点vに対する辺の集合はvectorで管理されているので，
        そのvectorの中の何番目の辺に対応しているかを記憶する→rev
    */
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size()-1});
}

void bfs(int s){
    level = vector<int>(MAX_N, -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(edge e : G[v]){
            if(e.cap > 0 && level[e.to] == -1){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll dfs(int v, int t, ll f){
    if(v == t) return f;
    for(int i=0;i<G[v].size();++i){
        edge &e = G[v][i]; //eの中身を書き換えたいのでポインタを使用
        if(level[v] < level[e.to] && e.cap > 0){
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll dinic(int s, int t){
    ll max_flow = 0;
    while(true){
        bfs(s);
        if(level[t] < 0) return max_flow;
        ll f;
        while((f = dfs(s, t, LLONG_MAX)) > 0){
            max_flow += f;
        }
    }

    return max_flow;
}


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;

    int a,b;
    for(int i=0;i<m;++i) {
        cin >> a >> b;
        --a; --b;
        add_edge(a, b, 1);
        add_edge(b, a, 1);
        ++degrees[a];
        ++degrees[b];
    }

    bool ok = false;
    vector<int> four;
    for(int i=0;i<n;++i) {
        if(degrees[i] % 2) {
            cout << "No\n";
            return 0; 
        } else if(degrees[i] >= 6) {
            ok = true;
        } else if(degrees[i] == 4) {
            four.push_back(i);
            if(four.size() == 3) ok = true;
        }
    }

    if(ok) {
        cout << "Yes\n";
    } else if(four.size() == 2) {
        cout << ((dinic(four[0], four[1]) == 2)?"Yes\n":"No\n");
    } else {
        cout << "No\n";
    }
    return 0;
}

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

int main() {
    string S; cin >> S;
    int a = S[0] - '0';
    int b = S[1] - '0';
    int c = S[2] - '0';
    int d = S[3] - '0';
    if (a+b+c+d == 7) {
        cout << S[0] << '+' << S[1] << '+' << S[2] << '+' << S[3] << "=7" << endl;
    }
    else if (a+b+c-d == 7) {
        cout << S[0] << '+' << S[1] << '+' << S[2] << '-' << S[3] << "=7" << endl;
    }
    else if (a+b-c+d == 7) {
        cout << S[0] << '+' << S[1] << '-' << S[2] << '+' << S[3] << "=7" << endl;
    }
    else if (a-b+c+d == 7) {
        cout << S[0] << '-' << S[1] << '+' << S[2] << '+' << S[3] << "=7" << endl;
    }
    else if (a+b-c-d == 7) {
        cout << S[0] << '+' << S[1] << '-' << S[2] << '-' << S[3] << "=7" << endl;
    }
    else if (a-b+c-d == 7) {
        cout << S[0] << '-' << S[1] << '+' << S[2] << '-' << S[3] << "=7" << endl;
    }
    else if (a-b-c+d == 7) {
        cout << S[0] << '-' << S[1] << '-' << S[2] << '+' << S[3] << "=7" << endl;
    }
    else {
        cout << S[0] << '-' << S[1] << '-' << S[2] << '-' << S[3] << "=7" << endl;
    }
}


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

int main() {
  long long  a, b;
  cin >> a >> b;
  if (a*b <= 0) cout << "Zero" << '\n';
  else if (0 < a || (b-a)%2 == 1) cout << "Positive" << '\n';
  else cout << "Negative" << '\n';
}






Measured memory_bytes: 256
n = (gets.to_i) - 1
line = gets.split(' ').map(&:to_i)
total_trade = 0

n.times do |i|
  trade = 0
  (n-i).times do |j|
    if line[j] > line[j+1]
      tmp = line[j]
      line[j] = line[j+1]
      line[j+1] = tmp
      trade += 1
    else
      next
    end
  end
  break if trade == 0
  total_trade += trade
end
puts line.join(' ')
puts total_trade


Measured memory_bytes: 6868
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	String a =	sc.next();
	for(int i = 0; i<a.length();i++) {
            if(i%2==0)System.out.print(a.charAt(i));
	}
        System.out.println();
    }
}

Measured memory_bytes: 30624
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int n, m;

	cin >> n;
	map<string,int> red;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		red[s]++;
	}

	cin >> m;
	map<string,int> blue;
	for (int i = 0; i < m; i++) {
		cin >> s;
		blue[s]++;
	}

	int ret = 0;
	int max = 0;
	for (auto itr = red.begin(); itr != red.end(); itr++) {
		ret = (itr->second) - blue[itr->first];
		if (ret > max) {
			max = ret;
		}
	}
	cout << max << endl;
	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)
#define x first
#define y second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
llint ti[200001] = {};

int main()
{
  llint n, t;
  I >> n >> t;


  for(int i = 0; i < n; i++) I >> ti[i];

  for(int i = 1; i < n; i++) {
    if(ti[i] - ti[i - 1] < t) cnt += ti[i] - ti[i - 1];
    else cnt += t;
  }

  O << cnt + t << EN; 
  
  return 0;
}


Measured memory_bytes: 1792
import copy

line = [[int(i) for i in input().split()] for _ in range(3)]
ansB = copy.copy(line[0])
ansA = [0, line[1][0]-ansB[0], line[2][0]-ansB[0]]
# print(line, ansA, ansB)
for i in range(1, 3):
    for j in range(1, 3):
        if ansA[i] + ansB[j] != line[i][j]:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 3444
a = []
b = []
for i in range(3):
  x,y = map(int, input().split())
  a += [x-1]
  b += [y-1]

haji = [0,0,0,0]
for i in range(3):
  haji[a[i]] += 1
  haji[b[i]] += 1
  
cont = 0
for p in haji:
  if p == 1:cont+=1
if cont ==2:
  print("YES")
else:
  print("NO")

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int h1, h2, m1, m2;
  int k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1 * 60 + m1;
  int t2 = h2 * 60 + m2;
  int len = t2 - t1 - k;
  cout << len << "\n";
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    cin >> n;

    vector<int64_t> L;
    L.push_back(2);
    L.push_back(1);

    for (int i = 2; i <= n; i++) {
        L.push_back(L.at(i - 2) + L.at(i - 1));
    }
    cout << L.at(n) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N, count = 0;
    cin >> N;
    int  a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i] % 2 != 0 && (i+1) % 2 != 0){
            count++;
        }
        else{
            continue;
        }
    }
    cout << count;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main(void)
{
	int n;
	int c_a, c_b;
	int sum_a, sum_b;
	int i;
	
	while (scanf("%d", &n), n != 0){
		sum_a = sum_b = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &c_a, &c_b);
			
			if(c_a > c_b){
				sum_a += c_a + c_b;
			}
			else if(c_a < c_b){
				sum_b += c_a + c_b;
			}
			else {
				sum_a += c_a;
				sum_b += c_b;
			}
		}
		printf("%d %d\n", sum_a, sum_b);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int h, w, n;
    cin >> h >> w >> n;
    cout << n / (max(h, w)) + (n % max(h,w) != 0) << endl;

    return 0;
}

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

#define REP(i, n) for(int i=0; i<n; i++)
#define REPA(i, a, n) for(int i=a; i<n; i++)
#define REPE(i, a, n) for(int i=a; i<=n; i++)
#define SetArray(a, n) for(int array_i=0; array_i<n; array_i++) cin >> a[array_i]
#define print(x) cout << x
#define printw(x) cout << x << " "
#define println(x) cout << x << endl
#define printl() cout << endl
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vi;

int main(){
    int n, m;
    cin >> n >> m;

    int a;
    ll total = 0;
    REP(i, m){
        cin >> a;
        total += a;
    }

    if(total > n)
        println(-1);
    else
        println(n-total);

    return 0;
}




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

int n,s,m=1e9;

int main()
{
    scanf("%d",&n);
    for(int i=1,a;i<=n;++i)
    {
	scanf("%d",&a),s+=a;
	if(a%10!=0)m=std::min(m,a);
    }

    if(m==1e9)puts("0");
    else printf("%d\n",s%10==0?s-m:s);
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {

    String Name;
    int SV;
    int EV;
    boolean T;

    Main(String Name, int SV, int EV, boolean T) {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    }

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    }
}


Measured memory_bytes: 21716
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [m, f, r] <- getInts
  ; if m == -1 && f == -1 && r == -1 then done
    else printGrade m f r    
  }

done :: IO ()
done = return ()

printGrade :: Int -> Int-> Int-> IO ()
printGrade m f r = putStrLn (grade m f r) >> loop

grade :: Int -> Int -> Int -> String
grade m f r = if m  == -1 || f == -1 then "F"
              else if mpf >= 80 then "A"
              else if mpf >= 65 then "B"
              else if mpf >= 50 then "C"
              else if mpf >= 30 then (if r >= 50 then "C" else "D")
              else "F"
  where
    mpf = m + f
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn  .  unwords .  map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4236
import math
n, k = map(int, input().split())
p = 0
if n >= k:
  p += (n-k+1)
for i in range(int(math.log2(k)), -1, -1):
  if n >= math.ceil(k/2**(i)):
    p += (math.ceil(k/2**(i))-math.ceil(k/2**(i+1)))/2**(i+1)
  else:
    p += (n-math.ceil(k/2**(i+1))+1)/2**(i+1)
    break
print(p/n)

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

using namespace std;

namespace {
    string s;
    bool input() {
        cin >> s;
        return s != "#";
    }

    struct A {
        int a, b;
        A(int a, int b) {
            int g = __gcd(a, b);
            this->a = a / g;
            this->b = b / g;
        }
    };
    int lcm(int a, int b) {
        return a / __gcd(a, b) * b;
    }
    A operator+(const A& x, const A& y) {
        int l = lcm(x.b, y.b);
        return A(x.a * (l / x.b) + y.a * (l / y.b), l);
    }
    A operator*(int k, const A& x) {
        return A(k * x.a, x.b);
    }
    ostream& operator<<(ostream& os, const A& a) {
        if (a.b == 1) {
            return os << a.a;
        }
        return os << a.a << "/" << a.b;
    }

    string dfs(const string& t) {
        if (t == "north") return "n";
        if (t == "west") return "w";
        if (t.substr(0, 4) == "west") {
            string nt = t.substr(4, t.size() - 4);
            return "w" + dfs(nt);
        } else {
            string nt = t.substr(5, t.size() - 5);
            return "n" + dfs(nt);
        }
    }

    int sign(char c) {
        return (c == 'n' ? -1: +1);
    }

    void solve() {
        string t = dfs(s);
        A a( (t[t.size() - 1] == 'n' ? 0 : 90), 1 );
        for (int i = t.size() - 2; i >= 0; i--) {
            int n = t.size() - i - 1;
            a = a + sign(t[i]) * A(90, 1 << n);
        }
        cout << a << endl;
    }
}

int main() {
    while (input()) solve();
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N, M; cin >> N >> M;
	int ans = N*(N-1)/2 + M*(M-1)/2;
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  x = (n/500) * 1000;
  n%=500;
  c(x + (n/5)*5);
 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#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 max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll h,w,k;
char s[310][310];
int a[310][310];
int main(){
	scanf("%lld%lld%lld",&h,&w,&k);
	rep(i,0,h)scanf(" %s",s[i]);
	
	ll l=0,cnt=0;
	rep(i,0,h){
		int flag=-1;
		rep(j,0,w)if(s[i][j]=='#')flag=j;
		if(flag==-1)continue;
		rep(j,0,w){
			rep(k,l,i+1)a[k][j]=cnt;
			if(s[i][j]=='#')cnt++;
		}
		rep(j,flag+1,w)rep(k,l,i+1)a[k][j]=cnt-1;
		l=i+1;
	}
	rep(i,l,h)rep(j,0,w)a[i][j]=a[l-1][j];
	
	rep(i,0,h){
		rep(j,0,w)printf("%d ",a[i][j]+1);
		puts("");
	}
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<vector>
#include<algorithm>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int n,A[200010],c[200010],C[200010],D[200010],iD[200010],d[200010],id[200010];
std::vector<int>vec[200010];
int t[200010],T[200010],from[200010];
void add(int&x,int y){x=x+y>=mod?x+y-mod:x+y;}
void update(int*t,int x,int y){while(x<=n)add(t[x],y),x+=x&-x;}
int query(int*t,int x){int r=0;while(x)add(r,t[x]),x-=x&-x;return r;}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi();
	for(int i=1;i<=n;++i)++c[A[i]=gi()];
	for(int i=n;i;--i)C[i]=c[i]+C[i+1];
	int S=1;
	for(int i=1;i<=n;++i)S=1ll*S*std::max(0,C[i]-n+i)%mod;
	if(!S)return puts("0"),0;
	for(int i=1;i<=n;++i)d[i]=1ll*(C[i]-n+i-1)*pow(C[i]-n+i,mod-2)%mod,id[i]=pow(d[i],mod-2);
	for(int i=1;i<=n;++i){
		from[i]=d[i]?from[i-1]:i;
		if(d[i-1])d[i]=1ll*d[i]*d[i-1]%mod,id[i]=1ll*id[i]*id[i-1]%mod;
	}
	for(int i=1;i<=n;++i)D[i]=d[A[i]],iD[i]=id[A[i]];
	int ans=0;
	for(int i=1;i<=n;++i)ans=(ans+1ll*c[i]*(c[i]-1)/2)%mod;
	ans=1ll*ans*S%mod*(mod+1>>1)%mod;
	for(int i=1;i<=n;++i)vec[from[A[i]]].push_back(i);
	for(int i=0;i<=n;++i){
		if(vec[i].empty())continue;
		for(int i:vec[i]){
			add(ans,1ll*D[i]*query(t,A[i]-1)%mod*S%mod*(mod+1>>1)%mod);
			update(t,A[i],iD[i]);
		}
		for(int i:vec[i])update(t,A[i],mod-iD[i]);
		std::reverse(vec[i].begin(),vec[i].end());
		for(int i:vec[i]){
			add(ans,(1ll*S*query(T,A[i]-1)%mod-1ll*S*D[i]%mod*query(t,A[i]-1)%mod*(mod+1>>1)%mod+mod)%mod);
			update(t,A[i],iD[i]);update(T,A[i],1);
		}
		for(int i:vec[i])update(t,A[i],mod-iD[i]),update(T,A[i],mod-1);
	}
	memset(t,0,sizeof t);
	for(int i=n;i;--i)add(ans,1ll*S*query(t,from[A[i]]-1)%mod),update(t,A[i],1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    ll a[n+1][m+1];
    ll c[n+1];
    ll ans = 10000000000;
    for(int i=1;i<=n;i++){
        cin >> c[i];
    for(int j=1;j<=m;j++){
        cin >> a[i][j];
    }
    }
    int k[n+1];
    for(int i=1;i<=n;i++){
        k[i]=0;
    }
    for(int i=1;i<=pow(2,n);i++){
        k[1]++;
        for(int j=1;j<=n;j++){
            if(k[j]==2){
                k[j+1]++;
                k[j]=0;
            }
        }
        int cnt1 = 0;
        for(int r=1;r<=m;r++){
        int cnt = 0;
        for(int j=1;j<=n;j++){
            cnt += k[j]*a[j][r];
        }
        if(cnt >= x)cnt1++;
        }
        if(cnt1==m){
        ll ans1=0;
        for(int j=1;j<=n;j++){
            ans1 += k[j]*c[j];
        }
        ans = min(ans1,ans);
        }
    }
    if(ans == 10000000000)ans = -1;
    cout << ans << endl;
}

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

int main() {
  ll M;
  cin >> M;
  ll sum_d = 0;
  ll k = 0;
  REP(i,M) {
    ll c,d;
    cin >> d >> c;
    sum_d += (d*c);
    k += c;
  }
  cout << ((k-1)+(sum_d-1)/9) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    map<char,int> mm;
    char arr[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    for(int i=0;i<n;i++)
    {
        string a;
        cin>>a;
        if(i==0)
        {
            for(int j=0;j<26;j++)
                mm[arr[j]]=0;
            for(int j=0;j<a.length();j++)
            {
                mm[a[j]]++;
            }
        }
        else
        {
            map<char,int> mmt;
            for(int j=0;j<26;j++)
                mmt[arr[j]]=0;
            for(int j=0;j<a.length();j++)
            {
                mmt[a[j]]++;
            }
            map<char,int>::iterator itt = mmt.begin();
            for(map<char,int>::iterator it = mm.begin();it!=mm.end();it++)
            {
                it->second = min(it->second,itt->second);
                // cout<<itt->second<<"        "<<it->second<<"    "<<it->first<<endl;
                itt++;
            }
        }
    }
    int c = 0;
    for(map<char,int>::iterator it = mm.begin();it!=mm.end();it++)
    {
        int temp = it->second;
        for(int i=0;i<temp;i++)
        {
            cout<<arr[c];
        }
        c++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int table[7][6] = { {0},
					{1, 2, 3, 5, 4, 6},// 1
					{2, 6, 3, 1, 4, 5},// 2
					{3, 6, 5, 1, 2, 4},// 3
					{4, 6, 2, 1, 5, 3},// 4
					{5, 6, 4, 1, 3, 2},// 5
					{6, 5, 3, 2, 4, 1} // 6
};

int match(int *face1, int *face2);

int main(void)
{
	int dice1[7], dice2[7];
	int face1[5], face2[5];
	int i, j;
	int flag;
	
	for (i = 1; i <= 6; i++){
		scanf("%d", &dice1[i]);
	}
	for (i = 1; i <= 6; i++){
		scanf("%d", &dice2[i]);
	}

	for (i = 0; i < 5; i++){
		face1[i] = dice1[table[1][i + 1]];
	}

	flag = 0;
	for (i = 1; i <= 6; i++){
		if (dice1[1] == dice2[i]){
			for (j = 0; j < 5; j++){
				face2[j] = dice2[table[i][j + 1]];
			}
			flag = match(face1, face2);
			if (flag == 1){
				break;
			}
		}
	}
	
	if (flag == 1){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

int match(int *face1, int *face2)
{
	int i, j, k;
	
	if (face1[4] != face2[4]){
		return (0);
	}
		
	for (i = 0; i < 4; i++){
		if (face1[0] == face2[i]){
			for (j = 0; j < 4; j++){
				if (face1[j] != face2[(i + j) % 4]){
					break;
				}
			}
			if (j == 4){
				return (1);
			}
		}
	}
	
	return (0);
}



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

int main(void){
  
  int n,i,f=0;
  string s;
  cin >> s;
  for(i=0;i<3;i++){
    if(s[i] == '7') f = 1;
  }

  cout << (f ==1  ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = 1e5 + 5, MAXM = 2e5 + 5, BOUND = 2e5, MOD = 45989, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-3;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define lc(x) c[x][0]
#define rc(x) c[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
char gdffsaw;
#define G gdffsaw=getchar()
#define GO G;while(gdffsaw<'-')G
#define in(z) GO;z=gdffsaw&15;G;while(gdffsaw>'-')z*=10,z+=gdffsaw&15,G
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int n, m, fa[MAXN], sum[MAXN];
struct Q {
	int a, b;
}q[MAXN];

int find(int x) {
	if (x == fa[x]) {
		return x;
	}
	int y = find(fa[x]);
	return fa[x] = y;
}
int main() {
	ios::sync_with_stdio(false);
	in(n); in(m);
	vector<ll> ans;
	rep(i, 1, m) {
		in(q[i].a); in(q[i].b);
	}
	ll res = 1LL * n * (n - 1) / 2;
	ans.push_back(res);
	for (int i = 1; i <= n; i++)fa[i] = i, sum[i] = 1;
	for (int i = m; i >= 2; i--) {
		int x = find(fa[q[i].a]), y = find(fa[q[i].b]);
		if (x != y) {
			fa[x] = y;
			res -= 1LL * sum[y] * sum[x];
			sum[y] += sum[x];
		}
		ans.push_back(res);
	}
	for (int i = ans.size() - 1; i >= 0; i--)cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
  
#define mod 1000000007
  
/*long rec(int a[], int n, long **mem, int id, int k)
{
  if(k==0)
  	return 1;
  if(id==n&&k>0)
    return -1;
  if(id==n&&k==0)
    return 1;
  if(mem[id][k]!=-1)
    return mem[id][k];
  long ans=0;
  for(int i=0;i<=min(k,a[id]);i++)
  {
    long ans1=rec(a,n,mem,id+1,k-i);
    if(ans1==-1)
      continue;
    ans1%=mod;
    ans=(ans%mod+ans1%mod)%mod;
    
  }
  mem[id][k]=ans;
  return ans;
}*/
  
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  /*long **mem=new long*[n+1];
  for(int i=0;i<=n;i++)
  {
    mem[i]=new long[k+1];
    for(int j=0;j<=k;j++)
      mem[i][j]=-1;
  }
  
  cout<<rec(a,n,mem,0,k);*/
  
  long dp[n+1][k+1];
  for(int j=0;j<=k;j++)
    dp[0][j]=0;
  for(int i=0;i<=n;i++)
    dp[i][0]=1;
  for(int i=1;i<=n;i++)
  {
    int sum[k+1];
    sum[0]=dp[i-1][0];
    for(int j=1;j<=k;j++)
      sum[j]=(sum[j-1]+dp[i-1][j])%mod;
    for(int j=0;j<=k;j++)
    {
      int tr=sum[j];
      if(j-a[i-1]-1>=0)
        tr=(tr-sum[j-a[i-1]-1]+mod)%mod;
      dp[i][j]=tr;
    }
  }
  
  cout<<dp[n][k];
  

}

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

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.size()) mp[s[i]]++;
    bool ok = true;
    for (auto p : mp)
    {
        if (p.second != 2)
            ok = false;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
    int L1,L2,L3;
    char s1[10],s2[10],s3[10];
    cin>>s1>>s2>>s3;
    
    L1=s1[0]; L2=s2[0]; L3=s3[0];
    s1[0]=L1-32; s2[0]=L2-32; s3[0]=L3-32;
    cout<<s1[0]<<s2[0]<<s3[0]<<endl;

    return 0;

}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b, k;cin >> a >> b >> k;
    for(int i=a;i<=min(a+k-1, b);i++){
        cout << i << endl;
    }
    for(int i=max(b-k+1, min(a+k-1, b)+1);i<=b;i++){
        cout << i << endl;
    }
    return 0;
}


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

int main(){
	char str1[21] = "", str2[21] = "";
	cin >> str1;
	int a = 0;
	for(int i = 0;i < 21;i++){
		if(str1[20 - i] != '\0'){
			str2[a] = str1[20 - i];
			a++;
		}
	}
	cout << str2 << "\n";
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll N;
  cin >> N;

  ll LIM = 3500;
  ll H, M, W;

  REP1(h, LIM){
    REP1(m, LIM){
      ll numerator = N*h*m;
      ll denominator = 4*h*m - N*h - N*m;
      if(denominator <= 0)
        continue;
      if(numerator % denominator == 0){
        H = h;
        M = m;
        W = numerator / denominator;
      }
    }
  }

  cout << H << " " << M << " " << W << endl;

}


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

int main() {
  int N,K;
  cin >> N>>K;
  vector <int> p(N);
  for (int i=0; i<N ; i++ ){
    cin >> p.at(i);
  }

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

  int sum=0;

  for (int i=0; i<K; i++){
    sum+=p.at(i);
  }


  cout << sum << endl;

}


Measured memory_bytes: 3624
n,m=map(int,input().split())

markarr=[-1]*n
flag=0
for i in range(m):
    a,b=map(int,input().split())
    if(markarr[a-1]!=-1 and markarr[a-1]!=b):
        flag=1
    markarr[a-1]=b

if(flag==1 or (markarr[0]==0 and n>1)):
    print(-1)
else:
    ans=''
    if(n==1):
        print(max(markarr[0],0))
        exit(0)

    elif(markarr[0]==-1):
        ans='1'
    else:
        ans=str(markarr[0])

    for i in range(1,n):
        ans+=str(max(markarr[i],0))
    print(ans)


Measured memory_bytes: 3064