akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
 
int main(){
    int i,j;
    int n;
    int num[1000000];
    
    for(i=0;i<1000000;i++){
        num[i]=1;
    }
    num[0]=num[1]=0;
     
    for(i=2;i<sqrt(1000000);i++){
        if(num[i]==1){
            for(j=i*i;j<1000000;j+=i) num[j]=0;
        }
    }
    for(i=1;i<1000000-1;i++){
        num[i+1]+=num[i];
    }
    for(;scanf("%d",&n)!=EOF;){
        printf("%d\n",num[n]);
    }
     
    return 0;
}

Measured memory_bytes: 4504
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
using namespace std;
int n,k,x[105],y[105],i,j,ans;
struct str{
	int x,y;
}a[100005];
bool cmp(str a,str b)
{
	if(a.x==b.x)
		return a.y<b.y;
	return a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d %d",&x[i],&y[i]);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(i!=j)
				a[++k]=(str){x[i]-x[j],y[i]-y[j]};
	sort(a+1,a+1+k,cmp);
	for(i=1;i<=k;)
	{
		for(j=i;j<=k&&a[i].x==a[j].x&&a[i].y==a[j].y;j++);
		ans=max(ans,j-i);
		i=j;
	}
	cout<<n-ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define PB push_back
#define GCD __gcd
#define COUNT1 __builtin_popcount
#define FORJ(i,j,k) for(int i=j; i<k; ++i)
#define FOR(i,k) FORJ(i,0,k)
#define FORR(i,k) for(int i=k; i>=0; --i)
#define FORE(x,v) for(auto &x : v)
#define FORG(y,x,g) FOR(y, sz(g)) FOR(x, sz2(g))
#define CIN(a) int a; cin>>a;
#define CINC(a) char a; cin>>a;
#define CINS(a) string a; cin>>a;
#define CIND(a) double a; cin>>a;
#define CINL(a) ll a; cin>>a;
#define CINP(a) PII a; cin>>a.F>>a.S;
#define CINLINE(a) string a; getline(cin, a);
#define CIN2(a,b) int a,b; cin>>a>>b;
#define CIN3(a,b,c) int a,b,c; cin>>a>>b>>c;
#define CIN4(a,b,c,d) int a,b,c,d; cin>>a>>b>>c>>d;
#define CINV(n,a) VI a; FOR(i,n) { CIN(x); a.PB(x); }
#define CINV2(n,a,b) VI a,b; FOR(i,n) { CIN2(x,y); a.PB(x); b.PB(y);}
#define CINVP(n,a) VP a; FOR(i,n) { CINP(p); a.PB(p);}
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define D(x) cout<<#x<<": "<<(x)<<endl
#define H cout<<"H"<<hcnt++<<endl;

using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<bool> VB;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef vector<VI> GI;
typedef vector<VB> GB;
typedef vector<vector<char> > GC;
typedef map<char,int> MC;
typedef map<int,int> MI;
typedef map<string,int> MS;

void OUT(auto x) { cout<<x<<endl; }
void OUTP(const PII &p) { cout<<p.F<<" "<<p.S<<endl; }
void OUTB(int x) { cout<<bitset<32>(x)<<endl; }
void OUTN(const auto &x) { cout<<x->d<<endl; }
void OUTV(const auto &x) { FORE(d,x) cout<<d<<" "; cout<<endl; }
void OUTVP(const VP &x) { FORE(d,x) cout<<d.F<<" "<<d.S<<endl; }
void OUTVN(const auto &x) { FORE(d,x) cout<<d->d<<" "; cout<<endl; }
void OUTG(const auto &x) { FORE(v,x) { FORE(u,v) cout<<u; cout<<endl; } }
void OUTM(const auto &x) {FORE(p,x) cout<<p.F<<":"<<p.S<<" "; cout<<endl;}
PII operator+(const PII &l, const PII &r) { return {l.F+r.F, l.S+r.S}; }
void amin(auto &x, auto y) { if(y < x) x = y; }
void amax(auto &x, auto y) { if(x < y) x = y; }
bool bet(auto x, auto l, auto r) { return x>=l && x<r; }
auto mod(auto x, auto m) { return ((x % m) + m) % m; }
bool IsSameSign(auto a, auto b) { return ((a>=0) ^ (b<0)); }
int sz(const auto &x) { return (int)x.size(); }
int sz2(const auto &x) { return (int)x[0].size(); }
bool IsSafe(const auto &x, int i) { return bet(i,0,sz(x)); }
auto Safe(const auto &x, int i) { return IsSafe(x,i) ? x[i] : 0; }
bool Find(const auto &x, auto y) { return x.find(y) != x.end(); }
void Tally(const auto &v, auto &m) { FORE(x,v) m[x]++; }

int hcnt=1;
VP nb4 = {{0,1}, {1,0}, {0,-1}, {-1,0}};
VP nb8 = {{0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1}};

int main() {
  CIN(n);
  OUT(n/3);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 110
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ll n;
    cin >> n;
    ll x[n];
    for (ll i=0;i<n;i++){
        cin >> x[i];
    }
    sort(x,x+n);
    cout << x[n-1]-x[0] << endl;
    return 0;
}



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

int main() {
	string s;
	cin>>s;
	if(s=="RRS"|| s=="SRR") cout<<"2"<<"\n";
	if(s=="RSR"|| s=="SRS" || s=="SSR" || s=="RSS") cout<<"1"<<"\n";
	if(s=="RRR") cout<<"3"<<"\n";
	if(s=="SSS") cout<<"0"<<"\n";
	return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;


namespace ConsoleApplication28
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');              
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            int[,] a = new int[n, m];

            for(int i = 0; i < n; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');

                for(int j = 0; j < m; j++)
                {
                    a[i,j] = int.Parse(str2[j]);
                }
            }

            int[] b = new int[m];

            for(int i = 0; i < m; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }

            int[] c = new int[n];

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    c[i] += a[i, j] * b[j];
                }
                
            }
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(c[i]);
            }
        }
    }
}

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    
    int N;
    cin >> N;
    int A[2][N];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++){
            cin >> A[i][j];
        }
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = A[0][0] + A[1][N-1];
        bool flag = false;
        for (int j = 1; j < N; j++) {
            if (j == N-i || flag) {
                sum += A[1][j-1];
                flag = true;
            }else{
                sum += A[0][j];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
using std::priority_queue;
using std::vector;
typedef long long ll;

priority_queue<int, vector<int> > q;
int n, m;
ll ans;
 
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1,a; i <= n; i++) {
      	scanf("%d",&a);
		ans += a;
		q.push(a);
	}
 
	for (int i = 1; i <= m; i++) {
      	int now = q.top();
		q.pop();
		ans -= now - (now >> 1);
		q.push(now >> 1);
	}
 
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;


const int MAX = 1e6;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll modcomb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n,m;
    cin >> n >> m;
    vector<ll> factors;
    ll mcopy=m;
    for(ll i=2;mcopy>1;i++){
        while(mcopy%i==0){
            factors.push_back(i);
            mcopy/=i;
        }
    }
    ll ans=1;

    for(ll i=0;i<factors.size();i++){
        ll tmp=factors[i],cnt=1;
        while(i<factors.size()-1&&factors[i]==factors[i+1]){
            cnt++;
            i++;
        }
        ans=(ans*modcomb(n+cnt-1,cnt))%MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int l, r, d, ld = 0, rd = 0;
    cin >> l >> r >> d;
    ld = l/d;
    rd = r/d;
    int ans = rd - ld;
    if(l == d||l == r) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
ALPHABET = %w(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)

def get_index_number(char)
  ALPHABET.each.with_index do |al, idx|
    return idx - 1 if char == al
  end
  raise 'No index'
end

while str = gets
  break if str.nil? || str.empty?
  0.upto(25) do |i|
    text = ''
    str.split('').each do |c|
      if c =~ /[a-z]/
        text << ALPHABET[(get_index_number(c) + i) % 26]
      else
        text << c
      end
    end

    if text.split(' ').any? { |w| %w(the this that).include?(w) }
      puts text
      break
    end
  end
end

Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
const int maxn = 200009;
int64 a[maxn<<2],b[maxn<<2];
void build(int rt,int l,int r,int64 op[]){
  if(l==r){
    op[rt]=-2e18;return;
  }
  int mid=(l+r)>>1;
  build(rt<<1,l,mid,op);
  build(rt<<1|1,mid+1,r,op);
  op[rt]=-2e18;
}
void upd(int rt,int l,int r,int p,int64 v,int64 op[]){
  if(l==r){
    op[rt]=max(op[rt],v);
    return;
  }
  int mid=(l+r)>>1;
  if(p<=mid)upd(rt<<1,l,mid,p,v,op);
  else upd(rt<<1|1,mid+1,r,p,v,op);
  op[rt]=max(op[rt<<1],op[rt<<1|1]);
}
void upd2(int rt,int l,int r,int p,int v,int64 op[]){
  if(l==r){
    if(op[rt]==v)op[rt]=-2e18;
    return;
  }
  int mid=(l+r)>>1;
  if(p<=mid)upd2(rt<<1,l,mid,p,v,op);
  else upd2(rt<<1|1,mid+1,r,p,v,op);
  op[rt]=max(op[rt<<1],op[rt<<1|1]);
}
int64 query(int rt,int l,int r,int ll,int rr,int64 op[]){
  if(ll<=l&&rr>=r)return op[rt];
  int mid=(l+r)>>1;
  int64 res=-2e18;
  if(ll<=mid)res=max(res,query(rt<<1,l,mid,ll,rr,op));
  if(rr>mid)res=max(res,query(rt<<1|1,mid+1,r,ll,rr,op));
  return res;
}
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<pair<int64,int64>> A(n);
  vector<int64>  Y;
  for(int i=0;i<n;++i){
    cin>>A[i].first>>A[i].second;
    Y.push_back(A[i].second);
  }
  sort(A.begin(),A.end());
  sort(Y.begin(),Y.end());
  A.erase(unique(A.begin(),A.end()),A.end());
  Y.erase(unique(Y.begin(),Y.end()),Y.end());
  int m=SZ(Y)-1;
  build(1,0,m,a);
  build(1,0,m,b);
  for(int i=0;i<n;++i){
    int y=lower_bound(Y.begin(),Y.end(),A[i].second)-Y.begin();
    upd(1,0,m,y,A[i].first+A[i].second,a);
    upd(1,0,m,y,A[i].first-A[i].second,b);
  }
  int64 res=0;
  for(int i=0;i<n;++i){
    int y=lower_bound(Y.begin(),Y.end(),A[i].second)-Y.begin();
    res=max(query(1,0,m,0,y,b)-A[i].first+A[i].second,res);
    res=max(res,query(1,0,m,y,m,a)-A[i].first-A[i].second);
    upd2(1,0,m,y,A[i].first+A[i].second,a);
    upd2(1,0,m,y,A[i].first-A[i].second,b);
  }
  cout<<res;
  
  
  return 0;
}
//2020.09.13 20:30:51


Measured memory_bytes: 16352
import sys
def main():
  n, *lst = map(int, sys.stdin.read().split())
  a = lst[n::-1]
  b = lst[-1:n:-1]
  res = 0
  for i in range(n):
    if i == 0:
      tmp = min(b[i], a[i])
      res += tmp
      a[i] -= tmp
      b[i] -= tmp
    else:
      tmp = min(b[i] + b[i - 1], a[i])
      res += tmp
      a[i] -= tmp
      b[i] -= min(b[i], max(tmp - b[i-1], 0))
  res += min(b[n - 1], a[n - 1] + a[n])
  print(res)


if __name__ == '__main__':
  main()

Measured memory_bytes: 25564
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]%2==1:
        pass
    else:
        if a[i]%3==0 or a[i]%5==0:
            pass
        else:
            print("DENIED")
            exit()
print("APPROVED")

Measured memory_bytes: 9132
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
t = list(li())
total = sum(t)

m = ni()
px = []
for _ in range(m):
    p,x = li()
    p -= 1
    print(total - t[p] + x)

Measured memory_bytes: 3064
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        js: [String; n],
    }
    let mut counter = HashMap::new();
    for j in js { *counter.entry(j).or_insert(0) += 1; }
    for r in ["AC", "WA", "TLE", "RE"].iter() { println!("{} x {}", r, counter.get(&r.to_string()).unwrap_or(&0)); }
}


Measured memory_bytes: 7804
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;

const int mod = 1000000007;
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; }

mint comb(ll N, ll a) {
  mint mnum(1);
  mint mden(1);
  for (ll n = N; n > N - a; n--) {
    mnum *= n;
    mden *= (N + 1 - n);
  }
  mnum /= mden;
  return mnum;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  int bend = (2 * X - Y) * 2;
  if (bend < 0 || bend % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  bend /= 6;
  int high = X - bend * 2;
  cout << comb(bend + high, bend) << endl;
  return 0;
}


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

#define  vt            vector
#define  db            long double
#define  int           long long
#define  pb            push_back
#define  inf           (int)1e18
#define  mxn           (int)2e5+5
#define  pii           pair<int,int>

#define  si(x)         (int)x.size()
#define  all(x)        x.begin(),x.end()
#define  mem(a,x)      memset(a,x,sizeof(a))
#define  forr(i,n)     for(int i=0;i<n;i++)

#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}

int mainx()
{
    int n , x , t;
    cin >> n >> x >> t;
    if (n % x)
    {
        cout << t*(n / x + 1) << endl;
    }
    else
    {
        cout << t*(n / x) << endl;
    }
    return 0;
}


inline void include() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
}
int32_t main() {
    //include();
    ios::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    //cout << fixed << setprecision(20);

    int tt = 1;
    //cin>>tt;
    for (int t = 1 ; t <= tt ; t++ )
    {
        mainx();
    }
    return 0 ;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    a[x] += 1;
    a[y] += 1;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=105;
int dp[N][N];
char ch[N][N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),m=read();
	For(i,1,n)dp[i][0]=1e9;
	For(i,1,m)dp[0][i]=1e9;
	dp[1][0]=0;
	For(i,1,n){
		scanf("%s",ch[i]+1);
		For(j,1,m){
			ch[i][j]=ch[i][j]=='#';
			dp[i][j]=min(dp[i-1][j]+(ch[i-1][j]^ch[i][j]),dp[i][j-1]+(ch[i][j-1]^ch[i][j]));
		}
	}
	cout<<(dp[n][m]+1)/2<<endl;
}


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

int main() {
	long long N, M;
	cin >> N >> M;
	if(N > 1 && M >1)
	cout << (N - 2) * (M - 2) << endl;
	else
	{
		if (N == 1 && M== 1)
		{
			cout << 1 << endl;
		}
		else if (N == 1)
		{
			cout << M - 2 << endl;
		}
		else
		{
			cout << N - 2 << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int64_t> x(n);
  vector<int64_t> y(m);
  for(int i=0;i<n;i++)
    cin>>x.at(i);
  for(int i=0;i<m;i++)
    cin>>y.at(i);
  int p=1000000007;
  int64_t sx=0;
  for(int i=0,j=n-1;i<j;i++,j--)
    sx=(sx+(x.at(j)-x.at(i))*(j-i))%p;
  int64_t sy=0;
  for(int i=0,j=m-1;i<j;i++,j--)
    sy=(sy+(y.at(j)-y.at(i))*(j-i))%p;
  cout<<sx*sy%p<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;


#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define ms(dp, x) memset(dp, x, sf(dp))

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve()
{
	ll n;
	cin>>n;
	cinal(a, n-1);
	ll arr[n+1]={0};
	rep(i, n-1)
		arr[a[i]]++;
	rep2(i, 1, n+1)
		cout<<arr[i]<<" "<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


Measured memory_bytes: 6368
#include <stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d",&a,&b);
    c=a+b;
    d=a-b;
    e=a*b;
    if((c>d ||c==d) && (c>e ||c==e)){
        printf("%d\n",c);
    }
    else if((d>e ||d==e) && (d>c ||d==c)){
        printf("%d\n",d);
    }
    else if((e>c || e==c) && (e>d ||e==d)){
        printf("%d\n",e);
    }


    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
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 T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k;cin>>k;
  k--;
  ll sz=99;
  auto dp=vec(100,10,0LL);
  dp[0][0]=0;
  rep(i,0,10)dp[1][i]=1;
  rep(i,0,sz){
    rep(j,0,10){
      dp[i+1][j]+=dp[i][j];
      if(j<9)dp[i+1][j+1]+=dp[i][j];
      if(j>0)dp[i+1][j-1]+=dp[i][j];
    }
    //cout<<i spa k<<endl;
    rep(j,1,10){
      if(dp[i+1][j]>k){
        string ret;
        ll now=i+1,pos=j;
        //cout<<i spa j spa k<<endl;
        //debug(dp,i+2,10);
        while(now){
          //cout<<now spa pos spa k<<endl;
          ret+=pos+'0';
          rep(o,0,10){
            if(abs(o-pos)>1)continue;
            if(dp[now-1][o]<=k)k-=dp[now-1][o];
            else{
              pos=o;
              break;
            }
          }
          now--;
        }
        cout<<ret<<endl;
        judge=false;
        break;
      }
      else k-=dp[i+1][j];
    }
    //cout<<k<<endl;
    if(!judge)break;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define per(i, a, b) for(int i = a; i >= b; --i)
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;
            
int n, k, a[N], ans, pref[N];
vector <int> t[N];

void build (int v, int l, int r) {
	if (l == r) {
		t[v].pb(pref[l]);
	} else {
		int mid = (l + r) / 2;
		build (v * 2, l, mid);
		build (v * 2 + 1, mid + 1, r);
		merge (all(t[v * 2]), all(t[v * 2 + 1]), back_inserter(t[v]));
	}
}
int get (int v, int l, int r, int L, int R, int val) {
	if (l > R || L > r)  return 0;
	if (L <= l && r <= R) {
		int left = lower_bound (all(t[v]), val) - t[v].begin();
		int right = upper_bound (all(t[v]), val) - t[v].begin();
		return right - left; 
	}
	int mid = (l + r) / 2;                                                     
	return get(v * 2, l, mid, L, R, val) + get(v * 2 + 1, mid + 1, r, L, R, val);
}

void solve () {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];		
 		a[i] --;	
 	} 
 	for (int i = 1; i <= n; ++i) {
 		pref[i] = pref[i - 1] + a[i];
 		pref[i] %= k;
 	}
 	build (1, 0,n - 1);
 	for (int i = 1; i <= n; ++i) {
 		int x = get(1, 0, n - 1, i - k + 1, i - 1, pref[i]);
 		ans += x;
 	}
 
	cout << ans;
}

signed main () {
    #ifdef Maga                                                                                                            	
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;                                                 
}

Measured memory_bytes: 97396
#include <stdio.h>
  
int main()
{
    int i,j,n,m,x;
    int a[100][100],b[100];
      
    scanf("%d %d",&n,&m);
      
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
      
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
      
    for(i=0;i<n;i++){
        x = 0;
        for(j=0;j<m;j++){
            x += a[i][j] * b[j];
        }
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    long long x;
    cin>>x;
    long long money=100,year=0;
    while(money<x){
        money*=1.01;
        year++;
        //cout<<year<<" "<<money<<endl;
    }
    cout<<year<<endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple {
		int p;
		int c;
		int baseScore;

		Tuple(int p, int c, int baseScore) {
			this.p = p;
			this.c = c;
			this.baseScore = baseScore;
		}
	}

	Tuple[] problems;
	int D, G;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		D = Integer.parseInt(tokens[0]);
		G = Integer.parseInt(tokens[1]);
		this.problems = new Tuple[D];
		for (int i = 0; i < D; ++i) {
			tokens = in.readLine().split(" ");
			int p = Integer.parseInt(tokens[0]);
			int c = Integer.parseInt(tokens[1]);
			problems[i] = new Tuple(p, c, (i + 1) * 100);
		}
	}

	int getSolveProblems(int pattern) {
		// まず解く問題セットを求める
		List<Tuple> list = new ArrayList<>();
		for (int i = 0; i < D; ++i) {
			if ((pattern & 1) > 0) {
				list.add(problems[i]);
			}
			pattern >>= 1;
		}
		// まずscoreと解く問題数を求める
		int solveNum = 0;
		int score = 0;
		for (Tuple tuple : list) {
			solveNum += tuple.p;
			score += tuple.p * tuple.baseScore + tuple.c;
		}
		// 足りない場合は-1を返す
		if (score < G) {
			return -1;
		}
		// 足りている場合，ギリギリまで解く問題数を削減する
		Collections.sort(list, new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return Integer.compare(o1.baseScore, o2.baseScore);
			}
		});
		Tuple t = list.get(0);
		score -= t.c;
		if (score < G) {
			// 全問解かないといけない
			return solveNum;
		}
		for (int i = 0; i < t.p; ++i) {
			score -= t.baseScore;
			solveNum--;
			if (score < G) {
				break;
			}
		}
		score += t.baseScore;
		if (score >= G) {
			return solveNum + 1;
		} else {
			return -1;
		}

	}

	void calc() {
		int solveNum = Integer.MAX_VALUE;
		for (int i = 1; i < Math.pow(2, D); ++i) {
			int num = getSolveProblems(i);
			if (num >= 0) {
				solveNum = Math.min(solveNum, num);
			}
		}
		System.out.println(solveNum);
	}

	void showResult() {
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli a, b, x, y;
	cin >> a >> b;

	lli d = extgcd(a,b,x,y);

	cout << (a / d) * b << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if(b>=0) cout<<"Zero"<<endl;
	else if((b-a)&1) cout<<"Positive"<<endl;
	else cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#define ll long long
 
using namespace std;
 
int main()
{
	double a,b,x;
	double const pi = 180/3.14159265359;
	cin >> a >> b >> x;
	cout << fixed;
    cout << setprecision(10);
	double otpt = atan((2*b-(2*x/(a*a)))/a)*pi;
	if (otpt < atan(b/a)*pi)
	{
		cout << otpt;
	}
	else
	{
		cout << atan(a*b*b/(2*x))*pi;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
#include <bitset>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int n;
    int ans = 0;
    cin >> n;
    while (ans < n) {
        ans += 1000;
    }
    cout << ans - n << endl;
}

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

int32_t main() {
  int n, k;
  scanf("%d%d", &n, &k);

  std::vector<int> p(n);
  for (int &pi : p) {
    scanf("%d", &pi);
  }

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

  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007




int main(){
	int n;
	while(cin >> n && n > 0){
		vi v (2 * n + 1, 0);
		int t;
		for(int i = 0; i < n; i++){
			cin>>t;
			v[t] = 1;
		}
		vi u[2];
		for(int i = 1; i < 2 * n + 1; i++){
			if(v[i]) u[0].pb(i);
			else u[1].pb(i);
		}
		int c = 0;
		t = 0;
		vi::iterator it;
		while(1){
			if(u[0].size() == 0 || u[1].size() == 0) break;
			it = upper_bound(all(u[t]), c);
			if(it == u[t].end()) c = 0;
			else{
				c = *it;
				u[t].erase(it);
			}
			t = (t + 1) % 2;
		}
		cout<<u[1].size()<<endl;
		cout<<u[0].size()<<endl;
	}
}

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

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<string.h>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ans=(int)s.size();
    for(int i=0;i<s.size()-1;i++)
        if(s[i]!=s[i+1])
            ans=min(ans,max(i+1,(int)s.size()-i-1));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int K;

int main(){
	while(cin>>K){
		if(!K)return 0;
		int s=0,n;
		for(int i=0;i<K*(K-1)/2;i++){
			cin>>n;
			s+=n;
		}
		cout<<s/(K-1)<<endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include<string>
#include<string.h>
using namespace std;

int main() {
  long int a, b = 0, d;
  cin >> a;
  string c = "abcdefghijklmnopqrstuvwxyz";
  string str;
  d = a;

for (int i = 1; a > pow(26, i); i++) {
    a -= pow(26, i);
    b = i;

    }
b += 1;
    a -= 1;

    //int d, e, f, g, h;

    for (int i = 0; i < b; i++) {
      d = a % 26;
      a /= 26;
      str = str + c.at(d);
    }
    reverse(str.begin(), str.end());
    cout << str <<  endl;
  }



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

int main() {
	// your code goes here
	long N, K;
	cin >> N >> K;
	
	long x[100000]={0};
	
	long a=0, b=0;
	for(int i=0; i<N; i++){
		cin >> a >>b;
		x[a-1] += b;
	}
	

	long ans=0;
	long j=0;
	while(j<=100000){
		K=K-x[j];
		ans=j+1;
		if(K<=0){break;}
		j++;
	};
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

#define EPS (1e-7)

double get_ex()
{
    int n, m;
    cin >> n >> m;
    double v, r, p = 1, e = 0;
    for (int i = 0; i < m; i++) {
        cin >> v >> r;
        e += v * r;
        p -= r;        
    }
    return e / (1 - p);
}

int main()
{
    int t;
    double max_ex = 0;
    cin >> t;
    while (t--) {
        max_ex = max(max_ex, get_ex());        
    }
    cout << (max_ex - get_ex() > EPS ? "YES" : "NO") << endl;    
    return 0;
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
const int mod = 1000000007;

int dw(int x) {
  if (x < mod) return x;
  return x - mod;
}

int main() {
  vl pw10(1000, 1);
  for (int i = 1; i < pw10.size(); ++i) pw10[i] = pw10[i-1] * 10 % mod;
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  int M = max(x, max(y, z));
  vi d(1 << (x + y + z + 1), 0);
  d[1] = 1;
  ll res = 0;
  for (int t = 0; t < n; ++t) {
    vi nd(d.size());
    for (int mask = 0; mask < d.size(); ++mask) if (d[mask]) {
      for (int a = 1; a <= M; ++a) {
        int nmask = 1;
        for (int i = 0; i + a <= x+y+z; ++i) if (mask & (1 << i)) {
          nmask |= (1 << (i + a));
        }
        nd[nmask] = dw(nd[nmask] + d[mask]);
      }
      nd[1] = (nd[1] + d[mask] * (ll)(10 - M)) % mod;
    }
    int all = (1 << (x + y + z));
    for (int mask = all; mask < nd.size(); ++mask) {
      if ((mask & (1 << z)) && (mask & (1 << (y + z)))) {
        res = (res + nd[mask] * pw10[n-t-1]) % mod;
        nd[mask] = 0;
      } else {
        nd[mask ^ all] = dw(nd[mask ^ all] + nd[mask]);
        nd[mask] = 0;
      }
    }
    d.swap(nd);
  }
  cout << res % mod << endl;
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cstdio>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(vec) vec.begin(), vec.end()

int main() {
    int n, w;
    cin >> n >> w;
    vector<pair<int, int> > treasure(n);
    rep(i,n) cin >> treasure.at(i).first >> treasure.at(i).second;
    vector<vector<int64_t> > dp(n+1, vector<int64_t>(w+1, 0));
    int64_t ans = 0;
    rep(i,n) {
        rep(j,w+1) {
            if (treasure.at(i).first > j) {dp.at(i+1).at(j) = dp.at(i).at(j); continue;}
            dp.at(i+1).at(j) = max(dp.at(i).at(j-treasure.at(i).first)+treasure.at(i).second, dp.at(i).at(j));
            ans = max(ans, dp.at(i+1).at(j));
        }
    }
    ct(ans);
}

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

int main(){
    string L[] = {"SUN", "MON", "TUE","WED","THU","FRI","SAT","SUN"};
    string S;
    cin >> S;

    rep(i,7){
        if(S == L[i]){
            cout<<(7-i)<<endl;
        }
    }
    return 0;
}

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

#define _LL long long

int main()
{
    int n;
    int c[4];
    for(int j = 0; j < 4; j++ ) c[j] = 0;
    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        string s;
        cin >> s;
        if( s == "AC" ) c[0]++;
        if( s == "WA" ) c[1]++;
        if( s == "TLE" ) c[2]++;
        if( s == "RE" ) c[3]++;
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
int a,b,c;
char op;
while(1){
scanf("%d %c %d\n",&a,&op,&b);
if(op=='?') break;
if(op=='+') c=a+b;
if(op=='-') c=a-b;
if(op=='*') c=a*b;
if(op=='/') c=a/b;
printf("%d\n",c);
}
return 0;
}

Measured memory_bytes: 604
from collections import Counter

M = 2019

Ss = input().rstrip()

As = [0]
A = 0
d = 1
for S in reversed(Ss):
    A += int(S) * d
    A %= M
    As.append(A)
    d = (d*10) % M

As.reverse()
#print('As:', As)

cnt = Counter(As)

ans = 0
for A, num in cnt.items():
    ans += num*(num-1)//2

print(ans)


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



int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N){
      cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  bool judge=true;
  rep(i,N-1){
      if(A.at(i)==A.at(i+1)){judge=false;}
  }
  if(judge){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int a[100010],b[100010];
int main()
{
	int n,h;
	int ans=0;
	cin>>n>>h;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	
	int po=lower_bound(b,b+n,a[n-1]+1)-b;
	int i=n-1;
	while(h>0 && i>=po)
	{
		h-=b[i];
		ans++;
		i--;
	}
	
	if(h>0)ans+=(h-1)/a[n-1]+1;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

const int limit=50;
bool egde[limit][limit];
bool visited[limit];
int a[limit],b[limit];
int n,m;

void dfs(int v){
    visited[v]=true;
    REP(v2,n){
        if(egde[v][v2]==false)continue;
        if(visited[v2]==true)continue;
        dfs(v2);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    REP(i,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        egde[a[i]][b[i]]=egde[b[i]][a[i]]=true;
    }
    int ans=0;
    REP(i,m){
        egde[a[i]][b[i]]=egde[b[i]][a[i]]=false;
        REP(j,n) visited[j]=false;
        dfs(0);

        bool ok=false;
        REP(j,n) if(visited[j]==false) ok=true;
        if(ok)ans++;
        egde[a[i]][b[i]]=egde[b[i]][a[i]]=true;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
s = input()

ans = 0
n = len(s) - 1
for i in range(2 ** n):
    op = [''] * n
    for j in range(n):
        if ((i >> j) & 1):
            op[n - j - 1] = '+'
    formula = ''
    for p_n, p_o in zip(s,op+['']):
        formula += (p_n+p_o)
    ans += eval(formula)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==0){
    cout<<a-b<<endl;
  }else{
    cout<<b-a<<endl;
  }
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static BigInteger limit = new BigInteger("1000000000000000000");

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int num = sc.nextInt();
			List<BigInteger> values = new ArrayList<BigInteger>();
			for (int i = 0; i < num; i++) {
				values.add(sc.nextBigInteger());
			}
			Collections.sort(values);

			BigInteger result = BigInteger.ONE;
			for (BigInteger value : values) {
				result = result.multiply(value);

				if (result.equals(BigInteger.ZERO)) {
					System.out.println(0);
					return;
				} else if (limit.compareTo(result) < 0) {
					System.out.println(-1);
					return;
				}
			}

			System.out.println(result.toString());

		} catch (Exception e) {
			System.out.println(-1);
			e.printStackTrace();
		}

	}
}


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

int main(){
  int N;
  cin >> N;
  int ans=1;
  for(int i=1;;i++){
    if(pow(2,i)<=N){
      ans=pow(2,i);
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256