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


const int Max = 5e5+10;
int num[Max << 2], mark[Max << 2];
int n;
string s;


void push_up(int node)
{
    num[node] = num[node << 1] | num[node << 1 | 1];
}


void push_down(int node, int l, int r)
{
    if (mark[node]) {
        mark[node << 1] = mark[node];
        mark[node << 1 | 1] = mark[node];
        num[node << 1] = mark[node];
        num[node << 1 | 1] = mark[node];
        mark[node] = 0;
    }
}


void build(int node, int l, int r)
{
    if (l == r) {
        int c = s[l-1] - 'a';
        num[node] = 1 << c;
        mark[node] = 0;
    } else {
        int mid = (l + r) >> 1;
        build(node << 1, l, mid);
        build(node << 1 | 1, mid + 1, r);
        push_up(node);
    }
}


void update(int node, int l, int r, int cl, int cr, int x)
{
    if (cl > r || cr < l) return;
    if (cl <= l && cr >= r) {
        mark[node] = x;
        num[node] = x;
        return;
    }
    push_down(node, l, r);
    int mid = (r + l) >> 1;
    update(node << 1, l, mid, cl, cr, x);
    update(node << 1 | 1, mid + 1, r, cl, cr, x);
    push_up(node);
}


int query(int node, int l, int r, int cl, int cr)
{
    if (cl > r || cr < l) return 0;
    if (cl <= l && cr >= r) return num[node];
    push_down(node, l, r);
    int mid = (r + l) >> 1;
    int ret = 0;
    ret |= query(node << 1, l, mid, cl, cr);
    ret |= query(node << 1 | 1, mid + 1, r, cl, cr);
    return ret;
}


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

    cin >> n >> s;
    build(1, 1, n);
    int q, idx, iq, lq, rq;
    char cq;
    cin >> q;
    while (q--) {
        cin >> idx;
        if (idx == 1) {    // 1 iq cq
            cin >> iq >> cq;
            int c = cq - 'a';
            update(1, 1, n, iq, iq, 1 << c);
        } else {    // 2 lq rq
            cin >> lq >> rq;
            int res = query(1, 1, n, lq, rq);
            cout << __builtin_popcount(res) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, b;
    std::cin >> a >> b;
    if (a < 10 && b < 10) std::cout << a * b << std::endl;
    else std::cout << -1 << std::endl;
    return 0;
}

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

int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> H[i];
    }

    std::sort(H.begin(), H.end());
    for (int i = 0; i < K; i++)
    {
        if (i >= N)
            break;
        H[N - 1 - i] = 0;
    }

    long long attack = std::accumulate(H.begin(), H.end(), 0LL);
    std::cout << attack << std::endl;

    return 0;
}

Measured memory_bytes: 1024
"use strict";
const main = arg => {
  let ans = -1;
  let info = arg.split(" ");
  if(info[0] < 10 && info[1] < 10){
  	ans = info[0] * info[1];
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
n,m=map(int,input().split())
l=[]
count=0
for i in range(n):
    k=[]
    k+=(map(int,input().split()))
    del k[0]
    l.extend(k)
for j in range(1,m+1):
    if l.count(j)==n:
        count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const long double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
vector<ll> v,v1;
vector< pair<ll,ll> > v2;
ll n,k;
bool check(ll mid){
   ll rem=k;
   for(int i=0;i<sz(v2);i++){
    ll se=v2[i].second;
    ll fr=v2[i].first;
    if(fr*se<=mid) continue;

    rem-= (se-mid/fr);
    if(rem<0) return 0;
   }
  return 1;
}
ll BS(ll l,ll r){
   ll ans;
   while(l<=r){
    ll mid=(l+r)/2;
    if(check(mid)){
        r=mid-1;
        ans=mid;
    }
    else{
        l=mid+1;
    }
   }
   return ans;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int no;
        cin>>no;
        v.pb(no);
    }
    sort(allr(v));

    for(int i=0;i<n;i++){
        int no;
        cin>>no;
        v1.pb(no);
    }
    sort(all(v1));
    ll ans=0;
    for(int i=0;i<n;i++){
       v2.pb(mp(v1[i],v[i]));
    }
    cout<<BS(0,1e12+9)<<endl;
}








Measured memory_bytes: 9456
#include <stdio.h>
#include <math.h>

double x,y;
void clc(double a,double b,double c,
	 double d,double e,double f){
  double z;
  if( a<0 ){
    a=-a; b=-b; c=-c;
  }
  if( d<0 ){
    d=-d; e=-e; f=-f;
  }

  z = b*d-a*e;
  x = (b*f-c*e)/z;
  y = (c*d-a*f)/z;
}

int main(void){
  int n,loop;
  double x1,y1,x2,y2,x3,y3;
  double a,b,c,d,e,f,g;
  double r;

  scanf("%d ",&n);
  for( loop=0;loop<n;loop++ ){
    scanf("%lf %lf %lf %lf %lf %lf ",&x1,&y1,
	  &x2,&y2,&x3,&y3 );
    a=2*(x2-x1); b=2*(y2-y1);
    c=(x2+x1)*(x2-x1) + (y2+y1)*(y2-y1);
    d=2*(x3-x2); e=2*(y3-y2);
    f=(x3+x2)*(x3-x2) + (y3+y2)*(y3-y2);
    clc(a,b,c,d,e,f);

    a=x; b=y;
    x=x-x1; y=y-y1;
    r=sqrt(x*x+y*y);
    printf("%.3lf %.3lf %.3lf\n",a,b,r);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(int argc, char *argv[]){
	int a;
	int b;
	char buf[128];

	if(argc == 1){
		//printf("N: ");
		fgets(buf, 127, stdin);
		sscanf(buf, "%d", &a);
	}
	if(a%2==0){
		printf("%d\n",a);
	} else if(a%2==1){
		b = a*2;
		printf("%d\n", b);
	}


}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
 
typedef long long LL;
 
template<typename T>void chmin(T &a,T b){a=min(a,b);}
template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
string t="CODEFESTIVAL2016";
int main(){
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0;i<t.size();i++)if(s[i]!=t[i])cnt++;
    cout<<cnt<<endl;
    return(0);
}


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

int main() {
	// your code goes here
	long long int n;
	cin>>n;
	string s="";
	while(n>0)
	{
	    int rem=n%26;
	    if(rem==0)
	    {
	        s=s+'z';
	        n=(n/26)-1;
	    }
	    else
	    {
	        //cout<<(rem-1)+'a'<<endl;
	        char h=(rem-1)+'a';
	        s=s+h;
	        n=(n/26);
	    }
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> v(n);
  ll sum = 0;
  rep(i, n) {
    cin >> v[i];
    sum += v[i];
  }
  ll tmp1 = 0;
  ll res = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    tmp1 += v[i];
    res = min(res, abs(tmp1 - (sum - tmp1)));
  }

  cout << res << endl;


}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,cc,t[2];
bool visited[1005];
char a[1005][1005];
void dfs(int pos){
  if(visited[pos])return;
  visited[pos]=true;
  cc++;
  for(int i=0;i<N;i++)
    if(a[pos][i]=='Y')
      dfs(i);
}
int main(){ 
  scanf("%d",&N);
  int total=N*(N-1)/2;
  for(int i=0;i<N;i++){
    scanf("%s",a[i]);
    for(int j=0;j<i;j++)
      if(a[i][j]=='Y')total--;
  }
  for(int i=0;i<N;i++){
    if(visited[i])continue;
    cc=0;
    dfs(i);
    t[cc%2]++;    
  }
  int f=(t[0]==0&&t[1]==2?0:1);
  if( (t[0]==1&&t[1]==2) || total%2==f )cout<<"Taro"<<endl;
  else cout<<"Hanako"<<endl;
  return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[1005][1005];

int main() {
    string S, T;
    cin >> S >> T;
    ll N = S.length(), M = T.length();
    REP(i, N + 1) {
        REP(j, M + 1) {
            dp[i][j] = INF;
        }
    }
    REP(i, N + 1) {
        dp[i][0] = i;
    }
    REP(j, M + 1) {
        dp[0][j] = j;
    }

    REP(i, N) {
        REP(j, M) {
            dp[i + 1][j + 1] = std::min(dp[i][j], std::min(dp[i + 1][j], dp[i][j + 1])) + 1;
            if (S[i] == T[j])
                dp[i + 1][j + 1] = std::min(dp[i + 1][j + 1], dp[i][j]);
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}


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

namespace abc099_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sa = x[1] - x[0];
            Console.WriteLine(sa * (sa + 1) / 2 - x[1]);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define sc(v) v.size()
#define eb push_back
#define pb pop_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define TC() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define fi first
#define se second
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

const int N = 200005;
int ar[N], le[N], ri[N];
int main()
{
	int n, d;
	cin>>n;
	memset(le, 0, sizeof le);
	memset(ri, 0, sizeof ri);
	for (int i = 0;i < n;i++) {
		cin>>ar[i];
	}
	for (int i = 1;i < n;i++) {
		le[i] = max(le[i - 1], ar[i - 1]);
	}
	for (int i = n - 2;i >= 0;i--) {
		ri[i] = max(ri[i + 1], ar[i + 1]);
	}
	for (int i = 0;i < n;i++) {
		int ans = max(le[i], ri[i]);
		printf("%d\n", ans);
	}
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<28
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

bool cmp_n(const P &pp,const P &qq){
  if(pp.S != qq.S)return pp.S < qq.S;
  return pp.F < qq.F;
}

int main(){
  int N,M;
  while(true){
    cin >> N >> M;
    if(N+M == 0)break;
    vector<P> vec;
    vec.clear();
    ll total = 0;
    rep(i,N)
      {
	int a,b;
	cin >> a >> b;
	total += a;
	vec.push_back(P(a,b));
      }
    sort(vec.begin(),vec.end(),cmp_n);
    if(0 >= total-M){
      cout << 0 << endl;
      continue;
    }

   

    
    
    ll sam = 0;
    ll dif = total - M;

    int index = 0;
    while(true){
      if(dif <= 0)break;
      sam += vec[index].S;
      //cout << "sum! " << vec[index].S << endl;
      dif--,vec[index].F--; 
      if(vec[index].F == 0)index++;
    }
   
    cout << sam << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
INF = 10000
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

dp = [[INF for i in range(N)] for j in range(1 << N)]

for i in range(N):
    dp[1 << i][i] = i

for i in range(1 << N):
    for j in range(N):
        if i >> j & 1:
            if (popcount(i) - j) % 2 != 0:
                num = A[j]
            else:
                num = B[j]
            cnt = 0
            for k in range(N):
                if not (i >> k & 1):
                    if (popcount(i) - k) % 2 == 0:
                        num2 = A[k]
                    else:
                        num2 = B[k]
                    if num <= num2:
                        dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + cnt)
                    cnt += 1

ans = INF
for i in range(N):
    ans = min(ans, dp[(1 << N) - 1][i])

if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 157548
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] num = new int[6];
        for (int i = 0; i < 6; i++){
            num[i] = input.nextInt();
        }
        Dice dice = new Dice(num);
        int q,top,front;
        int a = 0;
        int b = 0;
        q = input.nextInt();
        for (int i = 0; i < q; i++){
            top = input.nextInt();
            front = input.nextInt();
            for (int j = 0; j < 6; j++){
                if (num[j] == top){
                    a = j;
                } else if (num[j] == front){
                    b = j;
                }
            }
            if ((a == 3 && b == 1) || (a == 1 && b == 2) || (a == 2 && b == 4) || (a == 4 && b == 3)){
                dice.disp_num(0);
            } else if ((a == 2 && b == 0) || (a == 5 && b == 2) || (a == 3 && b == 5) || (a == 0 && b == 3)){
                dice.disp_num(1);
            } else if ((a == 0 && b == 1) || (a == 1 && b == 5) || (a == 5 && b == 4) || (a == 4 && b == 0)){
                dice.disp_num(2);
            } else if ((a == 1 && b == 0) || (a == 5 && b == 1) || (a == 4 && b == 5) || (a == 0 && b == 4)){
                dice.disp_num(3);
            } else if ((a == 0 && b == 2) || (a == 2 && b == 5) || (a == 5 && b == 3) || (a == 3 && b == 0)){
                dice.disp_num(4);
            } else{
                dice.disp_num(5);
            }
        }
    }
}

class Dice {
    private int N,E,W,S,T,B;
    private int[] dice_num;
    Dice(int[] num_array){
        dice_num = num_array;
        T = dice_num[0];
        S = dice_num[1];
        E = dice_num[2];
        W = dice_num[3];
        N = dice_num[4];
        B = dice_num[5];
    }
    public void roll(char direction){
        int tmp;
        if (direction == 'N'){
            tmp = T;
            T = S;
            S = B;
            B = N;
            N = tmp;
        } else if (direction == 'E'){
            tmp = T;
            T = W;
            W = B;
            B = E;
            E = tmp;
        } else if (direction == 'W'){
            tmp = T;
            T = E;
            E = B;
            B = W;
            W = tmp;
        } else {
            tmp = T;
            T = N;
            N = B;
            B = S;
            S = tmp;
        }
    }
    public void disp_top(){
        System.out.println(T);
    }
    public void disp_num(int n){
        System.out.println(dice_num[n]);
    }
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

//ａをbで割る
long long mod_div(long long a,long long b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

void mod_add(long long &a,long long &b){
	a += b;
	if(a >= MOD)a -= MOD;
}
 
ll mp[111111];
ll kaijo,n;

int main(){

	int n;cin >> n;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	ll ans = 0;
	
	for(int i = 1;i < 111111;i++){
		mp[i] = mod_div(1, 1+i);
	}
	REP(i,111110){
		mod_add(mp[i+1],mp[i]);
	}
	kaijo = 1;
	REP(i,n){
		kaijo *= (i+1);
		kaijo %= MOD;
	}

	REP(i,n){
		ll tmp = (((1 + mp[i] + mp[n-1-i]) % MOD) * kaijo) % MOD;
		ans += (tmp * v[i]) % MOD;
		ans %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,q,i,j;
    cin>>n>>k>>q;
    long long int a[n];
    for(i=0;i<n;i++)
    {
        a[i]=k-q;
    }
    long long int b[q];
    for(i=0;i<q;i++)
    {
        cin>>b[i];
        a[b[i]-1]+=1;
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<=0)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }

}


Measured memory_bytes: 5152
#include <iostream>
#include <algorithm>
using namespace std;
 
string ticket;
 
string find_7(int roop_count, int ticket_result){
    if(roop_count == 3){
        if(ticket_result == 7){
            return "=7";
        }else{
            return "";
        }
    }else{
        if(find_7(roop_count + 1, ticket_result + ticket[roop_count + 1] - '0') != ""){
            return "+" + to_string(ticket[roop_count + 1] - '0') + find_7(roop_count + 1, ticket_result + ticket[roop_count + 1] - '0');
        }else if(find_7(roop_count + 1, ticket_result - ticket[roop_count + 1] + '0') != ""){
            return "-" + to_string(ticket[roop_count + 1] - '0') + find_7(roop_count + 1, ticket_result - ticket[roop_count + 1] + '0');
        }else{
            return "";
        }
    }
}
 
int main(){
    cin >> ticket;
    cout << ticket[0] << find_7(0, ticket[0] - '0') << endl;
}

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


  
int main() {
  string N;
  cin >> N;
  int sum = 0;
 for(int i =0;i<N.size();i++){
 sum += N.at(i)-'0';
 }
if(sum % 9 == 0){
  cout<< "Yes" <<endl;
}
    else{
      cout <<"No"<< endl;
    }
}

Measured memory_bytes: 3704
#include<iostream>
#include<cstring>
#define ll long long
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 2e5+5;
ll dp[405][405], a[405], pre[405];
int n;

ll dfs(int l, int r){
	if(l >= r) return a[l];
	if(dp[l][r]) return dp[l][r];
	ll res = 1e17;
	for(int i = l; i < r; i++){
		res = min(res, dfs(l, i) + dfs(i+1, r));
	}
	return dp[l][r] = res + pre[r] - pre[l-1];
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}

	cout << dfs(1, n) - pre[n] << endl;
	return 0;
}

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

ans = 0
if K >= A:
    K -= A
    ans += A
else:
    ans += K
    K = 0

if K >= B:
    K -= B
else:
    K = 0

if K >= C:
    K -= C
    ans -= C
else:
    ans -= K
    K = 0

print(ans)


Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int t,d,l;
  while(cin>>t>>d>>l,t){
	int sum=0;
	int stk=0;
	for(int i=0;i<t;i++){
	  int x;
	  cin>>x;
	  if(x>=l)stk=d;
	  if(stk>0&&i<t-1){
		stk--;
		sum++;
	  }
	}
	cout<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] x = new int[N];
    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      ans += 2 * Math.min(x[i], K - x[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e7+5+5e6;
using namespace std;
const ll INF=1e15+7;
const ll mod=998244353;
ll n,m,p;
ll dp[305][305];
ll num[maxn];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
    for(int i=0;i<=n;i++)
        for(int k=0;k<=n;k++) dp[i][k]=INF;
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=n-m;k++)
        {
            for(int j=0;j<i;j++)
            {
                dp[i][k]=min(dp[i][k],dp[j][k-1]+max(0ll,num[i]-num[j]));
            }
        }
    }
    //
    ll res=INF;
    for(int i=1;i<=n;i++)
        res=min(res,dp[i][n-m]);
    if(m==n) printf("0\n");
    else
        printf("%lld\n",res);
    return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, k;
  cin >> n >> k;
  ll cur = 1;
  for (int i = 0; i < n; i++) {
    if (cur * 2 < cur + k) {
      cur *= 2;
    } else {
      cur += k;
    }
  }

  cout << cur << '\n';
}

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

using lint = long long;
const lint MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<lint> x(n), y(m);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i];
    }

    lint xsum = 0, xprev = 0;
    for (int i = 1; i < n; i++) {
        lint dx = x[i] - x[i - 1];
        xprev = (xprev + i*dx)%MOD;
        xsum = (xsum + xprev)%MOD;
    }
    lint ysum = 0, yprev = 0;
    for (int i = 1; i < m; i++) {
        lint dy = y[i] - y[i - 1];
        yprev = (yprev + i*dy)%MOD;
        ysum = (ysum + yprev)%MOD;
    }

    cout << (xsum*ysum)%MOD << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll a, b, x; cin >> a >> b >> x;
    ll m = a/x, n = b/x;
    if(a%x==0){m--;}
    cout << n - m;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
  ll K;
  cin >> K;
  vector<bool> A(K);
  ll namari = 7;
  ll amari = 7;
  ll cnt = 1;
  if(K == 7||K==1){
      cout << 1 << endl;
  }
  else{
    while(true){
      namari *= 10;
      namari %= K;
      amari += namari;
      amari %= K;
      cnt++;
      if(amari == 0){
          cout << cnt << endl;
          break;
      }
      else{
          if(A.at(amari-1)){
              cout << -1 << endl;
              break;
          }
          else{
              A.at(amari-1) = true;
          }
      }
    }
  }
}

Measured memory_bytes: 3764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll n;
    cin >> n;
    for(ll i=0;i*7<=n;i++){
        if((n-i*7)%4==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,h;
    cin>>n;
    int count=0;
    int top=0;
    for (int i=0;i<n;i++) {
        cin>>h;
        if (h>=top) {
            count++;
            top=h;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline

a,b = map(int, input().split())
s = input().strip()

for c in s[0:a]:
    if "0" <= c and c <= "9":
        pass
    else:
        print("No")
        exit()

for c in s[a+1:]:
    if "0" <= c and c <= "9":
        pass
    else:
        print("No")
        exit()

if s[a] != "-":
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int N = scanner.nextInt();
        if (N / 100 == N % 10) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main() {
  int64_t N, M, A, B, count=0;
  cin >> N >> M;
  vector<vector<int>> high(2, vector<int>(N+1, 1));
  
  for (int i=0; i<N; i++) cin >> high.at(0).at(i+1);
  
  for (int i=0; i<M; i++) {
    cin >> A >> B;
    if (high.at(0).at(A) >= high.at(0).at(B)) {
      high.at(1).at(B)=0;
    }
    if (high.at(0).at(A) <= high.at(0).at(B)) {
      high.at(1).at(A)=0;
    }
  }
  
  for (int i=1; i<N+1; i++) {
    //cout << high.at(1).at(i);
    if (high.at(1).at(i)==1) count++;
  }
  
  cout << count << endl;
}

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

int main() {
	int n, m, c, ans = 0; cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>>a(n,vector<int>(m));

	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	int check = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			check += b[j] * a[i][j];
		}
		check += c;
		if (check > 0)ans++;
		check = 0;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 1100000000000000000LL
//#define MOD 1000000007
#define MOD 123456789012345671
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main() {
	int N;
	cin>>N;
	int f;
	cin>>f;
	ll DP[SIZE][3]={};
	for(int i=0;i<SIZE;i++)
		for(int j=0;j<3;j++)
			DP[i][j]=-INFLL;
	DP[0][0]=f;
	for(int i=0;i<N-1;i++){
		int a;
		char o;
		cin>>o>>a;
		if(o=='+'){
			DP[i+1][0]=max(DP[i+1][0],DP[i][0]+a);
			DP[i+1][1]=max(DP[i+1][1],DP[i][1]-a);
			DP[i+1][2]=max(DP[i+1][2],DP[i][2]+a);
			DP[i+1][0]=max(DP[i+1][0],DP[i][2]+a);
			DP[i+1][0]=max(DP[i+1][0],DP[i][1]-a);
			DP[i+1][1]=max(DP[i+1][1],DP[i][2]+a);
		}
		else{
			DP[i+1][0]=max(DP[i+1][0],DP[i][0]-a);
			DP[i+1][1]=max(DP[i+1][1],DP[i][1]+a);
			DP[i+1][2]=max(DP[i+1][2],DP[i][2]-a);
			DP[i+1][1]=max(DP[i+1][1],DP[i][0]-a);
			DP[i+1][2]=max(DP[i+1][2],DP[i][1]+a);
			//DP[i+1][2]=max(DP[i+1][2],DP[i][0]-a);
		}
	}
	cout<<max({DP[N-1][0],DP[N-1][1],DP[N-1][2]})<<endl;
	/*
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++)
			printf("DP[%d][%d]=%d ",i,j,DP[i][j]);
		cout<<endl;
	}
	*/
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B;
    cin >> A >> B;

    if ((A < 0) || (A > 9) || (B < 0) || (B > 9)) {
        print("-1");
    } else {
        print(A * B);
    }
}

int main()
{
    solve();

    return 0;
}


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

int main(){
  ull n,k;
  cin>>n>>k;
  vector<unsigned long long> a(n);

  for(ull i=0;i<n;i++){
    cin>>a[i];
  }

  for(ull i=k;i<n;i++){
    if(a[i] > a[i-k]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4836
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    long long n,i,j,k=0,l,x;
    cin>>n;
    x=n+1;
    for(i=0; i<n; i++)
    {
        cin>>j;
        if(j<x)
        {
            k++;
            x=j;
        }
    }
    cout<<k<<endl;
    return 0;
}



Measured memory_bytes: 3640
#include <stdio.h>

int main() {
	int a[5];
	for(int i=0;i<5;i++){
	    scanf("%d\n",&a[i]);
	}
	int k;
	scanf("%d",&k);
	if (a[4]-a[0]<=k){
	    printf("Yay!");
	}else{
	    printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		int ans = 0;
		
		ans = (T/A)*B;

		System.out.println(ans);
		

	}
}


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

int main() {
  int a;
  int b;
  
  cin >> a >> b;
  
  if (a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9+7;

long long factorial(long long n, long long mod) {
    long long ret = 1;
    for (long long i = 1; i <= n; i++) {
        ret = (ret * i) % mod;
    }
    return ret;
}

long long inv_mod(long long n, long long mod) {
    long long a = n % mod, b = mod - 2, ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

long long nPr(long long n, long long r, long long mod) {
    long long ret = 1;
    for (long long i = n; i >= n - r + 1; i--) {
        ret = ret * (i % mod) % mod;
    }
    return ret;
}

long long nCr(long long n, long long r, long long mod) {
    return nPr(n,r,mod) * inv_mod(factorial(r,mod),mod) % mod;
}

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    ll r = n-k;
    for (int i = 1; i <= k; ++i) {
        cout << nCr(r+1, i, MOD) * nCr(k-1,i-1, MOD)%MOD << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int ansCount = 0;
	int A = 0;
	int coin500, coin100, coin50;

	cin >> coin500 >> coin100 >> coin50;

	cin >> A;

	for (int i = 0; i <= coin500; ++i)
	{
		for (int j = 0; j <= coin100; ++j)
		{
			for (int k = 0; k <= coin50; ++k)
			{
				if (500 * i + 100 * j + 50 * k == A)
					++ansCount;
			}
		}
	}

	cout << ansCount << endl;


	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <functional>
template<typename T>
class SegmentTreeAllOne {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    SegmentTreeAllOne(int _n, T _init, Func up) {
        init = _init;
        update_func = up;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int l, int r, T val) {
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                data[l] = update_func(data[l], val);
            }
            if (!(r & 1)) {
                data[r - 1] = update_func(data[r - 1], val);
            }
        }
    }
    T query(int pos) {
        pos += n - 1;
        T res = data[pos];
        while (pos > 0) {
            pos = (pos - 1) / 2;
            res = update_func(res, data[pos]);
        }
        return res;
    }
};

#include <utility>
using P = pair<ll, ll>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }
    auto MAX = [](P t, P s) {
        vector<ll> tmp = {t.first, t.second, s.first, s.second};
        sort(tmp.rbegin(), tmp.rend());
        return make_pair(tmp[0], tmp[1]);
    };
    auto MIN = [](P t, P s) {
        vector<ll> tmp = {t.first, t.second, s.first, s.second};
        sort(tmp.begin(), tmp.end());
        return make_pair(tmp[0], tmp[1]);
    };

    SegmentTreeAllOne<P> seg1(n + 1, P(-1, -1), MAX), seg2(n + 1, P(n, n), MIN);
    vector<P> m1(n), m2(n);
    REP(i, 0, n) {
        seg1.update(1, a[i], P(i, -1));
        m1[i] = seg1.query(a[i]);
    }
    REP(i, 0, n) {
        int j = n - i - 1;
        seg2.update(1, a[j], P(j, n));
        m2[j] = seg2.query(a[j]);
    }
    ll ans = 0;
    REP(i, 0, n) {
        ll t = 0;
        if (m1[i].first != -1) {
            t += (m1[i].first - m1[i].second) * (m2[i].first - i);
        }
        if (m2[i].first != n) {
            t += (m2[i].second - m2[i].first) * (i - m1[i].first);
        }
        dump(t);
        ans += t * a[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13952
from itertools import product
N = int(input())
MOD = 10**9+7
D = [[[[0]*4 for _ in range(4)] for _ in range(4)] for _ in range(N+3)]
D[0][3][3][3] = 1
for n in range(1,N+1):
    for i, j, k, l in product(range(4), repeat=4):
        if (i,j,l)==(2,1,0) or (i,k,l) == (2,1,0) or (i,j,k) == (1,2,0) or (i,j,k) == (2,0,1) or (i,j,k) == (2,1,0): continue
        D[n][i][j][k] += D[n-1][j][k][l]%MOD
res = 0
for i, j, k in product(range(4),repeat=3):
    res += D[N][i][j][k]
    res %= MOD
print(res)

Measured memory_bytes: 74412
// 2013/11/05 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		int f1 = x*b+y*p;

		if(b<5){
			b = 5;
		}
		if(p<2){
			p = 2;
		}
		int f2 = (x*b+y*p)*4/5;

		if(f1<f2){
			cout << f1 << endl;
		}
		else{
			cout << f2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main() {
    int N;
    long long sum = 0;
    scanf("%d", &N);
    for (int i=1; i<=N; i++) {
        if (i%3 != 0 & i%5 != 0) {
            sum += i;
        }
    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
 
using namespace std;
 
int main(int argc, char* argv[])
{
unsigned long long x; cin >> x; unsigned long long a = (x%11 > 6 ? 2 : 1);
if (x%11 == 0) { --a; }
cout << ((x/11)*2 + a) << endl;
return 0;
}

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

using namespace std;

int main(){
  int i, j, n, count, outcount, data[3];
  string event;

  cin >> n;

  for(i=0; i<n; ++i){
    count = 0;
    outcount = 0;
    for(j=0; j<3; ++j)
      data[j] = 0;

    while(1){
      cin >> event;

      if(event == "HOMERUN"){
        ++count;
        for(j=0; j<3; ++j){
          if(data[j] == 1){
            ++count;
            data[j] = 0;
          }
        }
      }else if(event == "HIT"){
        if(data[2] == 1) ++count;
        data[2] = data[1];
        data[1] = data[0];
        data[0] = 1;
      }else if(event == "OUT"){
        ++outcount;
      }

      if(outcount == 3) break;
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 0
N,X,Y =map(int,input().split())

count = [0] * (N-1)


for i in range(1,N):
    for j in range(i+1,N+1):
        dist = min(j-i, abs(X-i)+1+abs(Y-j))
        count[dist-1] +=1


for i in range(N-1):
    print(count[i])

Measured memory_bytes: 9176
S = int(input())
MOD = 10**9+7
fact = [1]
for i in range(1, S+1):
    fact.append(fact[-1]*i % MOD)
ifact = [None]*(S+1)
ifact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(S, 0, -1):
    ifact[i-1] = ifact[i]*i % MOD
def comb(n, k):
    if n < 0:
        return 0
    return (fact[n]*ifact[n-k]*ifact[k]) % MOD
ans = 0
for i in range(1, S+1):
    if S<3*i:
        break
    ans = (ans+comb(S-2*i-1, i-1)) % MOD
print(ans)

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

int main() {
  int N, ans = 0;
  ll x;
  cin >> N >> x;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];
  sort(ALL(a));
  rep(i, N){
    x -= a[i];
    if(x < 0) break;
    if(i == N - 1 && x != 0) break;
    ++ans;
  }
  cout << ans << endl;
}


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

const ll mod = 1e9 + 7;
int main(){
    string l;
    cin >> l;
    int n = l.size();

    vector<ll> dp1(n, 0);
    vector<ll> dp2(n, 0);
    
    dp1[0] = 1;
    dp2[0] = 2;
    for(int i=1;i<n;i++){
        if(l[i] == '1'){
            dp1[i] = (dp1[i-1] * 3 + dp2[i-1])%mod;
            dp2[i] = (dp2[i-1] * 2)%mod;
        }else{
            dp1[i] = (dp1[i-1] * 3)%mod;
            dp2[i] = (dp2[i-1])%mod;
        }
    }
    

    cout << (dp1[n-1] + dp2[n-1])%mod << endl;

}

Measured memory_bytes: 2048
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
         
        int r = sc.nextInt();
        int D = sc.nextInt();
        long n = sc.nextInt();
        
        for(int i=0;i<10;i++){
        	n = r*n-D;
        	System.out.println(n);
        }
        
    }
	
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  multimap<string, int> m;
  int q; cin >> q;
  int command;
  string key;
  int x;
  string L, R;
  rep_i(i, q){
    cin >> command;
    if(command == 0){
      cin >> key >> x;
      m.insert(make_pair(key, x));
    }else if(command == 1){
      cin >> key;
      auto it = m.equal_range(key);
      for (auto i = it.first; i != it.second; i++){
        cout << i->second << endl;
      }
    }else if(command == 2){
      cin >> key;
      // auto it = m.find(key);
      // if(it != m.end()){
        m.erase(key);
      // }
    }else if(command == 3){
      cin >> L >> R;
      auto start = m.lower_bound(L);
      auto end = m.upper_bound(R);
      while (start != end){
        cout << start->first << " " << start->second << endl;
        ++start;
      }
    }
  }
}
  


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n, w;
	cin >> n >> w;

	vector < pair < int, int > > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;

	vector < ll > DP(w + 5);
	for (int i = 0; i < n; ++i) {
		for (int j = w; j >= v[i].first; --j) {
			DP[j] = max(DP[j], DP[j - v[i].first] + v[i].second);
		}
	}

	cout << DP[w];
	return 0;
}

Measured memory_bytes: 1024
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

    def LII_split(): return list(map(int, input().split()))

    # 2次元リスト化
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    from collections import deque
    N = input_int()
    friendlinesses = LII_split()

    s_fris = sorted(friendlinesses, reverse=True)

    ans = s_fris[0]
    for i in range(N - 2):
        ans += s_fris[i // 2 + 1]
    print(ans)
resolve()

Measured memory_bytes: 32484
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int k, s; cin >> k >> s;
	int cnt = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (0 <= s - i - j&&s - i - j <= k)cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256