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

int main() {
  int A, B, p = 0;
  cin >> A >> B;
  
  for (; A - 1 < B;) {
    p += (
      (A%10 == A/10000) 
      && ((A%100-A%10) / 10 == (A/1000-A/10000*10))
      );
    A ++;
  }
  
  cout << p << endl;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> b(n - 1);
	for (int i = 0; i < n - 1; ++i) cin >> b[i];
	int ans = b[0] + b[n - 2];
	for (int i = 1; i < n - 1; ++i)
		ans += min(b[i - 1], b[i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
int main(){
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll> > v[n];
	for(ll i = 0; i < m; ++i){
		ll a, b, c; cin >> a >> b >> c;
		v[--a].push_back(pair<ll, ll>(--b, -c));
	}
	ll d[n] = {0};
	ll po = INF;
	bool flag = 0;
	for(ll i = 1; i < n; ++i) d[i] = INF;
	for(ll count = 0;;++count){
		bool update = 0;
		for(ll i = 0; i < n; ++i){
			if(d[i] == INF) continue;
			for(auto next : v[i]){
				if(d[next.first] > d[i] + next.second){
					update = 1;
					d[next.first] = d[i] + next.second;
				}
			}
		}
		if(!update)break;
		if(count >= n - 1 && !flag){
			po = d[n - 1];
			flag = 1;
		}
		if(count >= 2 * (n - 1)){
			if(po == d[n - 1]) break;
			cout << "inf\n";
			return 0;
		}
	}
	cout << -d[n - 1] << endl;
	return 0;
}

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

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

    string s;
    cin >> s;

    bool c = false, f = false;
    rep(i, s.size()) {
        if (s[i] == 'C') {
            c = true;
        }
        else if (s[i] == 'F') {
            if (c) { cout << "Yes" << endl; return 0; }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
from bisect import bisect_right, bisect_left
from itertools import accumulate
n = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
li_a.sort()
li_b.sort()
li_c.sort()
relation_bc = [] #relation_bc[i] : 大きい方からi番目のbより大きいcがいくつあるか
for i in range(n):
    i += 1
    j = li_b[(-1)*i]
    k = bisect_right(li_c, j)
    relation_bc.append(len(li_c)-k)
ans = 0
li = list(accumulate(relation_bc))
for i in li_a:
    p = bisect_right(li_b, i) # i より大きいbがいくつあるか調べる
    p = n - p
    if p >= 1:
        ans += li[p-1]
    else:
        continue
print(ans)

Measured memory_bytes: 112356
#include <stdio.h>

int main(){
	int K;
	int A, B;
	scanf("%d", &K);
	scanf("%d %d", &A, &B);
	int flag = 0;
	for(int i = A; i<=B; i++){
		if(i%K ==0){
			flag = 1;
			break;
		}
	}
	
	flag ? printf("OK\n") : printf("NG\n");
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;

int main()
{
    ll n;
    cin>>n;
    vector<ll> h(n);
    rep(i,n)cin>>h[i];
    reverse(h.begin(),h.end());
    bool flag=true;
    for(ll i=1;i<n-1;i++)
    {
        if(h[i]-h[i-1]==1)
        {
            h[i]--;
        }
        else if(h[i]-h[i-1]>1)
        {
            flag=false;
        }

    }
    if(flag)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 50
#define M 17
#define mod 1000000007
using namespace std;
int n,x,y,z,pw[N],f[2][(1<<M)+10];
void upd(int &x,int y){ x+=y; if (x>=mod) x-=mod; }
int main(){
	scanf("%d%d%d%d",&n,&x,&y,&z);
	pw[0]=1; rep (i,1,n) pw[i]=(ll)pw[i-1]*10%mod;
	int m=x+y+z,k=1,nk=0,ret=0;
	f[0][0]=1;//定义一个0/1状态，1=(1),2=(01),3=(001)...(2,3,1,4,1)=(10001100101)（倒过来），长度表示加起来的和。
	//f[i][j]表示处理到第i为状态为j的方案数
	rep (i,0,n-1){
		k^=1; nk^=1; memset(f[nk],0,sizeof(f[nk]));
		rep (sta,0,(1<<m)-1) if (f[k][sta]){
			rep (d,1,10){//枚举要插入的数字
				int nw=sta>>d;
				if (d<=m) nw|=1<<m-d;
				if ((nw&1) && (nw>>x&1) && (nw>>x+y&1)) upd(ret,(ll)f[k][sta]*pw[n-i-1]%mod);
				else upd(f[nk][nw],f[k][sta]);
			}
		}
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N;
double T,A;
int main(int argc, char const *argv[])
{
    cin>>N>>T>>A;
    std::vector<double> H(N);
    std::vector<double> temparature(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
        temparature[i]=abs(T-H[i]*0.006-A);
    }

    double min = *std::min_element(temparature.begin(), temparature.end());
    auto itr = std::find(temparature.begin(), temparature.end(), min);  
    size_t index=std::distance(temparature.begin(),itr);
    cout<<index+1<<endl;
    return 0;
}


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

using namespace std;

const int COUNT = 6;


class Dice
{
public:
	int num[6];

public:
	Dice();
	void play_dice(string);
	void play(int, int, int, int);
	void print_(int x) {printf("%d\n", num[x]);}
	void to_top_and_front(int, int);
};

Dice::Dice()
{
	for (int i = 0; i < COUNT; ++i)
	{
		cin >> num[i];
		
	}
}


void Dice::play_dice(string s)
{
	if(s == "E") {play(0, 2, 5, 3); }
		
	if(s == "N") {play(0, 4, 5, 1); }
		
	if(s == "S") {play(0, 1, 5, 4); }
	
	if(s == "W") {play(0, 3, 5, 2); }
}

void Dice::play(int a, int b, int c, int d)
{
	int temp;
	temp = num[d]; num[d] = num[c]; num[c] = num[b]; num[b] = num[a]; num[a] = temp;
}


void Dice::to_top_and_front(int top, int front)
{
	string str[7] = {"N", "N", "N", "W", "N", "N", "N"};
	for (int i = 0; i < 7; ++i)
	{
		if(front == num[1]) break;
		play_dice(str[i]);
	}
	while(top != num[0])
	{
		play_dice("W");
	}
}


int main(int argc, char const *argv[])
{
	Dice a, b;
	a.to_top_and_front(b.num[0], b.num[1]);
	
	for (int i = 0; i < COUNT; ++i)
	{
		if (a.num[i] == b.num[i])
		{
			/* code */
		}
		else
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 1168
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
  int n,a,b;
  scanf("%d",&n);
  a=0;
  while(n--)
  {
    scanf("%d",&b);
    if(b<a)
    {
      printf("No");
      return 0;
    }
    a=(b-1>=a)?b-1:b;
  }
  printf("Yes");
  return 0;
}

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

struct Edge {
	int to, rev_i, dir; // 1 -> 0
};

using EdgeVec = std::vector<Edge>;
using EdgeLists = std::vector<EdgeVec>;

int N, M;
EdgeLists edges;
std::vector<bool> visited;

void dfs(int);
bool solve();

int main()
{
	if (!solve())
	{
		puts("-1");
		return 0;
	}
	for (int i{}; i < N; i++)
		for (auto& f: edges[i])
		{
			if (f.to < i) continue;
			if (f.dir == 1) printf("%d %d\n", i + 1, f.to + 1);
			else printf("%d %d\n", f.to + 1, i + 1);
		}

	return 0;
}

bool solve()
{
	scanf("%d%d", &N, &M);
	edges.resize(N);
	for (int i{}; i < M; i++)
	{
		int A, B;
		scanf("%d%d", &A, &B);
		A--; B--;
		edges[A].push_back({B, (int)edges[B].size(), -1});
		edges[B].push_back({A, (int)edges[A].size() - 1, -1});
	}
	if (M % 2 == 1) return false;
	visited.resize(N);
	dfs(0);
	return true;
}

void dfs(int index)
{
	if (visited[index]) return;
	visited[index] = true;
	for (int i{}; i < (int)edges[index].size(); i++)
		dfs(edges[index][i].to);

	int in_count{};
	for (auto& e: edges[index])
		if (e.dir == 0)
			in_count++;
	// outの数が偶数になるように調整したい
	for (auto& e: edges[index])
	{
		if (e.dir != -1) continue;
		if ((edges[index].size() - in_count) % 2)
		{
			in_count++;
			e.dir = 0;
			edges[e.to][e.rev_i].dir = 1;
		}
		else
		{
			e.dir = 1;
			edges[e.to][e.rev_i].dir = 0;
		}
	}
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll checkstring(string s,ll i){
    ll ans=-2;
    if(i<4)
        return -2;
    string p="";
    for(int j=i-4;j<=i;j++){
        p+=s[j];
    }
    if(p=="dream" || p=="erase"){
        ans=1;
        return i-5;
    }
    if(i<5)
        return -2;
    string q="";
    for(ll j=i-5;j<=i;j++){
        q+=s[j];
    }
    if(q=="eraser"){
        ans=1;
        return i-6;
    }
    if(i<6)
        return -2;
    string r="";
    for(ll j=i-6;j<=i;j++){
        r+=s[j];
    }
    if(r=="dreamer"){
        ans=1;
        return i-7;
    }
    if(ans==-2)
        return -2;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    ll i=s.length()-1;
    while(1){
        i=checkstring(s,i);
        if(i==-2){
            cout<<"NO"<<endl;
            break;
        }
        else if(i==-1){
            cout<<"YES"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll calc(vector<ll> &A, ll a) {
    ll ret = 0;
    rep(i, A.size()) {
        ret += abs(A[i] - a);
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] -= i + 1;
    ll l = -inf, r = inf;
    while(r - l > 2) {
        ll ml = (2 * l + r) / 3;
        ll mr = (l + 2 * r) / 3;
        if(calc(A, ml) < calc(A, mr)) {
            r = mr;
        }
        else {
            l = ml;
        }
    }
    ll ans = 1LL << 60;
    for(ll i = l; i <= r; i++) {
        ans = min(ans, calc(A, i));
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 1792
s=input()

while True:
    
    if len(s)<5:
        break
        
    else:
      
        if s[:5]=='dream':
            
            if len(s)<7:                
                  s=s[5:]
            elif 7<=len(s) and len(s)<10:
                if s[5:7]=='er':
                  s=s[7:]
            else:
                
                if s[5:7]=='er':
                    if s[7:10]=='ase':
                        s=s[5:]
                    else:
                        s=s[7:]
                else:
                    s=s[5:]
                
        elif s[:5]=='erase':
          
            if len(s)>5:
                if s[5]=='r':
                    s=s[6:]
                else:
                    s=s[5:]
                    
            else:
                s=s[5:]
                
        else:
            break
            
if s=='':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n,k;
	cin >> n >> k;
	vector<lli> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	lli ans = 0;
	for(int i=0; i<n-k; i++){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

using pll = pair<long long, long long>;
int main() {
    int N; cin >> N;
    vector<pll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i].first, A[i].second = i;
    sort(A.begin(), A.end(), greater<pll>());

    vector<vector<long long>> dp(N+1, vector<long long>(N+1, 0));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; i + j < N; ++j) {
            // left
            chmax(dp[i+1][j], dp[i][j] + A[i+j].first * (A[i+j].second - i));

            // right
            chmax(dp[i][j+1], dp[i][j] + A[i+j].first * ((N-1-j) - A[i+j].second));
        }
    }
    long long res = 0;
    for (int i = 0; i <= N; ++i) chmax(res, dp[i][N-i]);
    cout << res << endl;
}



Measured memory_bytes: 34676
s = input()
k = int(input())

a = list(s)
a = [ord(i) for i in a]
b = sorted(set(a))
c = []
INF = 97+26
for m in b:
    a1 = [i for i in range(len(s)) if a[i] == m]

    for i in a1:
        j = 0
        for j in range(k):
            if s[i:i+j+1] not in c:
                c.append(s[i:i+j+1])
                c.sort()
            if len(c) > 5:
                del c[-1]
            j += 1
            if i + j >= len(s):
                break
    if len(c) >= k:
        break

print(c[k-1])


Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long s = scn.nextLong();
		ArrayList<Long> al = new ArrayList<Long>();
		al.add(s);
		boolean cont = true;
		while(cont) {
			long a_last = al.get(al.size()-1);
			al.add(a_last%2 == 0?a_last/2:a_last*3 + 1);
			a_last = al.get(al.size()-1);
			for(int i = 0;i < al.size()-2;i++) {
				if(a_last == al.get(i)) {
					cont = false;
					break;
				}
			}
		}
		System.out.println(al.size());
	}

}


Measured memory_bytes: 21844
import numpy as np
from numba import njit

R, C, K = map(int, input().split())
item = np.zeros((R, C), np.int_)
for _ in range(K):
    r, c, v = map(int, input().split())
    item[r-1,c-1] = v

@njit
def solve(R, C, K, item):
    DP = np.zeros((R, C, 4), np.int_)

    DP[0][0][1] = item[0][0]

    for i in range(R):
        for j in range(C):
            for k in range(4):
                if i > 0:  # 前の行から
                    DP[i,j,0] = max(DP[i,j,0], max(DP[i-1,j]))  # 取らない
                    DP[i,j,1] = max(DP[i,j,1], max(DP[i-1,j])+item[i,j])  # 取る

                if j > 0:  # 前の列から
                    DP[i,j,k] = max(DP[i,j,k], DP[i,j-1,k])  # 取らない
                    if k >= 1:
                        DP[i,j,k] = max(DP[i,j,k], DP[i,j-1,k-1]+item[i,j])  # 取る

    print(max(DP[R-1,C-1]))

solve(R, C, K, item)

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin>>N;
  vector<ll> v(N+1);
  v[0]=2;
  v[1]=1;

  FOR(i,2,N+1){
    v[i]=v[i-1]+v[i-2];
  }
  cout<<v[N]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int n,m=1e16,tmp;
	cin>>n;
	for(int i=1;i<=5;i++){
		cin>>tmp;
		m=min(m,tmp);
	}
	cout<<(n-1)/m+5;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int k;
	cin >> k;
	vector<int> a(k);

	ll ama = 0,t=1;
	rep(i, 100000000){
		ama += 7 * t;
		ama %= k;
		if (ama == 0) {
			cout << i + 1 << endl;
			return 0;
		}
		a[ama]++;
		if (a[ama] == 2) {
			cout << -1 << endl;
			return 0;
		}
		t *= 10;
		t %= k;
	}
}


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

#define int long long

signed main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    int t = z;
    while(true) {
        if(t+y+z>x) break;
        ans++;
        t += (y+z);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    string display = "";
    rep(i, s.length()) {
        if (s[i] == 'B') {
            if (display != "") display = display.substr(0, display.length() - 1);
        } else {
            display += s[i];
        }
    }
    cout << display << endl;

    return 0;
}

Measured memory_bytes: 256
io = STDIN
N=io.gets.to_i
ar=io.gets.split.map(&:to_i)
ar.unshift(nil)
s=Array.new(N+1)
N.downto(1) do |i|
  cnt=0
  i.step(N,i) do |j|
    if i==j
      cnt+=ar[j]
    else
      cnt+=s[j]
    end
  end
  s[i]=cnt % 2
end
puts s.count(1)
if s.count(1)>0
  ans=[]
  (1..N).each do |i|
    ans << i if s[i]==1
  end
  puts ans.join(" ")
end


Measured memory_bytes: 22924
export class Main {
  static main(input): string {
    const b: string = input.split("\n")[0].split(" ")[0];
    return `${(() => {
      switch(b) {
        case "A":
          return "T"
        case "T":
          return "A"
        case "C":
          return "G";
        case "G":
          return "C"
      }
    })()}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	vint v(3);
	rep(i,3) cin>>v[i];
	sort(ALL(v));
	if(v[0]+v[1]==v[2]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;		
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

MOD = 10**9+7

l = -((-N)//2)
c = [0] *l
flg = True
for a in A:
    if (N-a)%2 == 1:
        b = (N-a)//2
        if b < l+1:
            c[b] += 1
        else:
            flg = False
    else:
        flg = False

if N % 2 == 1:
    for i in range(l):
        if i == l-1:
            flg &= (c[i] == 1)
        else:
            flg &= (c[i]==2)
else:
    for i in range(l):
        flg &= (c[i] ==2)
if flg:
    print(pow(2,N//2,MOD))
else:
    print(0)



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

int main() {
	int n, m, k;
	int count = 0;
	cin >> n >> m;
	int* b = new int[m];

	for (int h = 0; h < m; h++) {
		b[h] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> k;
		int* a;
		a = new int[k];
		for (int j = 0; j < k; j++) {
			cin >> a[j];
			b[a[j] - 1]++;
		}
	}
	for (int o = 0; o < m; o++) {
		if (b[o] == n) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

int main(){

	int n;

	long long int tbl[5][4001] = { 0 };
	//0  <= a <= 1000
	tbl[0][0] = 1;

	for (int i = 1; i < 5; i++){
		for (int j = 0; j < 4001; j++){
			for (int k = 0 ; k < 1001; k++){
				if (j - k < 0) break;
				tbl[i][j] += tbl[i - 1][j-k];
			}
		}
	}

	while (cin >> n){
		cout << tbl[4][n] << endl;
	}

	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;
const int N = 500001;
const long long mod1 = 1000000009ll, mod2 = 1000000007ll;
const long long R = N + 5;
int n, k, perm[N], sz[N << 2];
long long pw1[N], pw2[N], suf1[N], suf2[N], sgt1[N << 2], sgt2[N << 2], val1 = 0ll, val2 = 0ll;
set<pair<long long, long long> > s;
void build (int l, int r, int now) {
	int mid = l + r >> 1;
	sz[now] = 0, sgt1[now] = sgt2[now] = 0ll;
	if (l < r) build(l, mid, now << 1), build(mid + 1, r, now << 1 | 1);
}
void change (int pos, int l, int r, int now) {
	int mid = l + r >> 1;
	if (l == r) sz[now] ^= 1, sgt1[now] ^= pos, sgt2[now] ^= pos;
	else {
		if (pos <= mid) change(pos, l, mid, now << 1);
		else if (pos > mid) change(pos, mid + 1, r, now << 1 | 1);
		sz[now] = sz[now << 1] + sz[now << 1 | 1];
		sgt1[now] = (sgt1[now << 1] * pw1[sz[now << 1 | 1]] + sgt1[now << 1 | 1]) % mod1;
		sgt2[now] = (sgt2[now << 1] * pw2[sz[now << 1 | 1]] + sgt2[now << 1 | 1]) % mod2;
	}
}
int main () {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &perm[i]), perm[i]++;
	suf1[n + 1] = suf2[n + 1] = 0, pw1[0] = pw2[0] = 1ll;
	for (int i = 1; i <= n; i++) pw1[i] = pw1[i - 1] * R % mod1;
	for (int i = 1; i <= n; i++) pw2[i] = pw2[i - 1] * R % mod2;
	for (int i = n; i; i--) {
		suf1[i] = (suf1[i + 1] + pw1[n - i] * perm[i]) % mod1;
		suf2[i] = (suf2[i + 1] + pw2[n - i] * perm[i]) % mod2;
	}
	build(1, n, 1);
	for (int i = 1; i <= k; i++) change(perm[i], 1, n, 1);
	for (int i = 1; i <= n - k + 1; i++) {
		if (i > 1) {
			val1 = (val1 * R + perm[i - 1]) % mod1;
			val2 = (val2 * R + perm[i - 1]) % mod2;
			change(perm[i + k - 1], 1, n, 1), change(perm[i - 1], 1, n, 1);
		}
		long long h1 = ((val1 * pw1[k] + sgt1[1]) % mod1 * pw1[n + 1 - k - i] + suf1[i + k]) % mod1;
		long long h2 = ((val2 * pw2[k] + sgt2[1]) % mod2 * pw2[n + 1 - k - i] + suf2[i + k]) % mod2;
		s.insert(make_pair(h1, h2));
	}
	printf("%d\n", s.size());
	return 0;
}

Measured memory_bytes: 43648
while true do
  person_count = gets.to_i
  break if person_count == 0

  scores = Array.new(person_count, 0)
  total_score = 0

  person_count.times do |i|
    scores[i] = gets.to_i
    total_score += scores[i]
  end

  total_score -= scores.min
  total_score -= scores.max

  p total_score / (person_count-2)
end

Measured memory_bytes: 8652
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

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

     int pre = 1, ans = 0;

     for (i = 0; i < n; i++)
     {
          if (a[i] == pre)
          {
               ans++;
               pre++;
          }
     }
     if (!ans)
          cout << -1;
     else
          cout << n - ans;

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    string s;
    cin >> s;
    li sum = 0;
    for (int i = 0; i < s.size(); ++i) {
        sum += s[i] - '0';
        sum %= 9;
    }
    
    cout << (sum == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1e6+10;
int a[maxn]= {0},n;
int main()
{
	int x;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&x);
		a[x+1]++;
	}
	int ans=0;
	for(int i=1; i<=1e6+3; i++)
	{
		ans=max(ans,a[i]+a[i+1]+a[i+2]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = sorted(list(map(int, input().split())), reverse=True)
print(sum(sorted(p + q + r, reverse=True)[:x+y]))

Measured memory_bytes: 22504
#include <bits/stdc++.h>
using namespace std;
const int N=3500;
typedef long long LL;
LL n;
int main()
{
    cin>>n;
    for(LL x=1;x<=N;x++){
        for(LL y=1;y<=N;y++){
            LL d=4*x*y-n*(x+y);
            if(d>0 && (n*x*y)%d==0){
                printf("%I64d %I64d %I64d",x,y,(n*x*y)/d);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int N;

int main() {
	scanf("%d", &N);
	if (N == (N & -N)) return puts("No"), 0;
	puts("Yes");
	int M = 1 << (31 - __builtin_clz(N));
	printf("%d 1\n", M);
	printf("1 %d\n", M + 1);
	printf("%d %d\n", M + 1, M + N);
	printf("%d %d\n", M + N, 1 + N);
	printf("%d %d\n", 1 + N, M + 1 + N);
	for (int i = 2; i < N; i += 2) if (i != M)
		printf("%d %d\n", i + 1 + N, i),
		printf("%d 1\n", i),
		printf("1 %d\n", i + 1),
		printf("%d %d\n", i + 1, i + N);
	if (~N & 1)
		printf("%d %d\n", N, M + 1),
		printf("%d %d\n", N - M, N + N);
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

# 順列の作成
import itertools
l = [i for i in range(1,n+1)]
ll = itertools.permutations(l)
for i,v in enumerate(ll):
    if list(v) == p:
        pi = i + 1
    if list(v) == q:
        qi = i + 1

ans = abs(pi - qi)
print(ans)

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	string s;
	cin >> s;
	int red = 0, blue = 0;
	for (char c : s) {
		if (c == '0') ++red;
		else ++blue;
	}
	cout << (min(red, blue) * 2) << endl;
}


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

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<int> a(N);
  for(int i; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> ord(N + 1, -1);//街を何番目に通ったかの配列
  vector<int> s;//通った町の番号の配列
  int v = 1;//現在の町番号
  while(ord.at(v) == -1) {
    ord.at(v) = s.size();
    s.push_back(v);
    v = a.at(v - 1);
  }
  int l = ord.at(v);//周期に入るまでの回数
  int c = s.size() - l;//周期の回数
  if (K < l) {
    cout << s.at(K) << endl;
  } else {
    K = (K - l) % c;
    cout << s.at(K + l) << endl;
  }
}

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

int main() {
    ll h;
    int n;
    cin >> h >> n;
    ll sum = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= h){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = []
for i in range(h):#h:高さ
    c.append([str(m) for m in list(input())])
for i in range(2 * h):
    if i != 0:
        print()
    for j in range(w):
        print(c[i // 2][j], sep = "", end = "")

Measured memory_bytes: 4472
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//型宣言
typedef long long ll;
typedef unsigned long long ull;
typedef std::string string;
typedef string answerType;

//変数宣言
ll N;
ll M;
std::vector<string> Ai;
std::vector<string> Bi;
answerType answer;

//関数のプロトタイプ宣言
//入力の取得
void getInput();
//答えを求める
answerType calcAnswer();

//メイン関数
int main() {
	//入力の取得
	getInput();

	//答え
	answerType answer = calcAnswer();

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}

//入力の取得
void getInput() {
	std::cin >> N >> M;

	string temp;
	std::getline(std::cin, temp);

	for(ll i=0; i<N; ++i) {
		string A;
		std::getline(std::cin, A);
		Ai.push_back(A);
	}

	for(ll i=0; i<M; ++i) {
		string B;
		std::getline(std::cin, B);
		Bi.push_back(B);
	}
}

//答えを求める
answerType calcAnswer() {
	for(int i=0; i<=N-M; ++i) {
		size_t temp = string::npos;
		for(int j=0; j<M; ++j) {
			string A = Ai[i+j];
			string B = Bi[j];
			size_t temp2;
			if(temp == string::npos) {
				temp2 = A.find(B);
				temp = temp2;
			} else {
				temp2 = A.find(B, temp);
			}
			if(temp2 == string::npos || temp != temp2) {
				temp = string::npos;
				break;
			}
		}
		if(temp != string::npos) {
			return "Yes";
		}
	}
	return "No";
}


Measured memory_bytes: 256
/*
AizuOnline A0124
Title Baseball Championship
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;

struct BTEAM
{
  char nam[21];
  int  order;  //input order
  int  win;
  int  draw;
  int  lose;
  int  katit;  //katiten
} team_info[10];
//
int team_compare (struct BTEAM * a,struct BTEAM * b)
{

  if(a->katit < b->katit)return(1);
  if(a->katit > b->katit)return(-1);
  if(a->order > b->order)return(1);
  if(a->order < b->order)return(-1);
  return(0);
}
main()
{
  int i,j,ss,flag;
  flag=0;
  while(1)
    {
      EOF!=scanf("%d",&n);
      if(n==0)break;
      if(flag)
	printf("\n");
      flag=1;
      for(i=0;i<n;i++)
	{
	  scanf("%s %d %d %d",
		team_info[i].nam,&team_info[i].win,
		&team_info[i].lose,&team_info[i].draw);
	  
	  team_info[i].katit =  team_info[i].win*3+team_info[i].draw;
	}
      qsort(team_info,n,sizeof(struct BTEAM ),(__compar_fn_t)team_compare);
      for(i=0;i<n;i++)
	{
          printf("%s,%d\n",team_info[i].nam,team_info[i].katit);
	}
    }
      return(0);
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define INF 100000
using namespace std;
main(){
  int n;
  while(cin>>n,n){
    int d[n],t[n];

    for(int i=0;i<n;i++)
       cin>>d[i]>>t[i];

    for(int i=n-1;i>=1;i--)t[i]-=t[i-1];

    int dp[n][4];

    for(int i=0;i<n;i++)
      for(int j=0;j<4;j++)
        dp[i][j]=INF;

    if(t[0]<d[0]){
      cout<<"NG "<<1<<endl;
    }
    else{
      dp[0][0]=d[0];
    for(int i=1;i<n;i++){
      if(dp[i-1][1]!=INF){
        int dt=abs(d[i]-d[i-1]);
        if(dt*3<=t[i])dp[i][2]=min(dp[i][2],dp[i-1][1]+dt);
        int de=d[i-1]*3+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][1]+d[i]+d[i-1]);
      }
      if(dp[i-1][2]!=INF){
        int de=d[i-1]*4+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][2]+d[i]+d[i-1]);
      }
      if(dp[i-1][0]!=INF){
        int dt=abs(d[i]-d[i-1]);
        if(dt*2<=t[i])dp[i][1]=min(dp[i][1],dp[i-1][0]+dt);
        int de=d[i-1]*2+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][0]+d[i]+d[i-1]);
      }
      int cc=0;
      for(int j=0;j<4;j++)
        if(dp[i][j]!=INF)cc++;
      if(!cc){
        cout<<"NG "<<i+1<<endl;
        goto L;
      }
    }
    int sum=INF;
    for(int i=0;i<4;i++)
      sum=min(sum,dp[n-1][i]+d[n-1]);
    cout<<"OK "<<sum<<endl;
    }L:;
  }
}

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

signed main(void)
{
	string a, b, c;
	int i, j, k;
	char turn;
	bool ok_a, ok_b, ok_c;
	cin >> a >> b >> c;
	turn = 'a';
	i = j = k = 0;
	ok_a = ok_b = ok_c = false;
	while (true)
	{
		if (turn == 'a')
		{
			if (i >= a.size()) {ok_a = true; break;}
			turn = a[i];
			i++;
		}
		else if (turn == 'b')
		{
			if (j >= b.size()) {ok_b = true; break;}
			turn = b[j];
			j++;
		}
		else if (turn == 'c')
		{
			if (k >= c.size()) {ok_c = true; break;}
			turn = c[k];
			k++;
		}
	}
	if (ok_a)
		cout << 'A' << endl;
	else if (ok_b)
		cout << 'B' << endl;
	else if (ok_c)
		cout << 'C' << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
      	int r = 0;
      	int g = 0;
      	int b = 0;
      	for(int i=0; i<n; i++){
			if(s.charAt(i)=='R'){
				r++;
			}else if(s.charAt(i)=='G'){
				g++;
			}else{
				b++;
			}
		}
      	long ans = (long)r*g*b;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				int k = 2*j - i;
				if(k>=n){
					continue;
				}
				char ci = s.charAt(i);
              	char cj = s.charAt(j);
              	char ck = s.charAt(k);
				if(ci != cj && cj != ck && ck != ci){
					ans--;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 36384
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long int lli;
using namespace std;

int main() {
	string s;
	cin >> s;

	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else if (s == "Rainy")cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

void aaa(int a);
int main()
{
    int a;
    scanf("%d",&a);
    aaa(a);
    printf("\n");
    return 0;
}

void aaa(int a)
{
    int i,k;
    for(i=1;i<=a;i++)
    {
        k = i;
        if(i%3==0)
        {
            printf(" %d",i);
        }else
        {
            while(k!=0)
            {
                if(k%10 == 3)
                {
                    printf(" %d",i);
                    k=0;
                }else
                {
                    k /= 10;
                }
            }
        }
    }
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int result = 0;
		int max = 0, min = 1000000;
		int arc = 0;
		int abc = 0;

		String str[] = br.readLine().split(" ");
		int list[] = new int[n];

		for (int i = 0; i < n; i++) {
			list[i] = Integer.parseInt(str[i]);
			max = Math.max(list[i], max);
			min = Math.min(list[i], min);
		}

		Arrays.sort(list);
		int ave = list[list.length / 2 - 1];

		for (int i = ave; i < list[list.length / 2]; i++) {
			/*
			 * for (int j = 0; j < n; j++) { if (i >= list[j]) { arc++; } else
			 * if (i < list[j]) { abc++; } } if (abc == arc) result++; abc = 0;
			 * arc = 0;
			 */
			result++;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 37024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    cout << a[N-1] - a[0] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define INF 4e18

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

lint N,Source,Sink,X;
lint Cost[105],Par[105];
lint Cap[105][105],Adj[105][105];
bool Vis[105];

bool BFS(){
    lint U,V;
    memset(Vis,0,sizeof(Vis));
    queue<int> Q;
    Q.push(Source);
    Vis[Source]=1;
    Par[Source]=-1;
    while(!Q.empty()){
        U=Q.front();
        Q.pop();
        for(V=0;V<=N+1;++V){
            if(Vis[V]==0&&Cap[U][V]>0){
                Q.push(V);
                Par[V]=U;
                Vis[V]=1;
            }
        }
    }
    return Vis[Sink];
}

lint Maxflow(){
    lint U,V;
    for(int i=0;i<=N+1;++i)
        for(int j=0;j<=N+1;++j)
            Cap[i][j]=Adj[i][j];
    lint Max_Flow=0;
    while(BFS()){
        lint Path_Flow=INF;
        V=Sink;
        while(V!=Source){
            U=Par[V];
            Path_Flow=min(Path_Flow,Cap[U][V]);
            V=Par[V];
        }
        V=Sink;
        while(V!=Source){
            U=Par[V];
            Cap[U][V]-=Path_Flow;
            Cap[V][U]+=Path_Flow;
            V=Par[V];
        }
        Max_Flow+=Path_Flow;
    }
    return Max_Flow;
}

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
    cin>>N;
    for(int i=1;i<=N;++i){
        cin>>Cost[i];
        if(Cost[i]>0){
            X+=Cost[i];
            Adj[i][N+1]=Cost[i];
        } else {
            Adj[0][i]=-Cost[i];
        }
        for(int j=2*i;j<=N;j+=i){
            Adj[i][j]=INF;
        }
    }
    Source=0;
    Sink=N+1;
    cout<<X-Maxflow()<<endl;
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t*)calloc(N, sizeof(t))

void hoge(int A, int B, int C, int K, int * is_fullfilled) {
  if (K == 0) {
    if (C > B) {
      if (B > A) {
        *is_fullfilled = 1;
        return;
      }
    }
    return;
  }

  hoge(A * 2, B, C, K - 1, is_fullfilled);
  hoge(A, B * 2, C, K - 1, is_fullfilled);
  hoge(A, B, C * 2, K - 1, is_fullfilled);
}

/**
 * Operation
 *   rep(i, K) {
 *     A *= 2 or B *= 2 or C *= 2
 *   }
 * Condition
 *   C > B > A
 * Question
 *   if the Operation fullfil the Condition
 */
int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  int K;
  scanf("%d", &K);

  int is_fullfilled = 0;

  hoge(A * 2, B, C, K - 1, &is_fullfilled);
  hoge(A, B * 2, C, K - 1, &is_fullfilled);
  hoge(A, B, C * 2, K - 1, &is_fullfilled);

  if (is_fullfilled == 1) {
    printf("%s\n", "Yes");
  } else {
    printf("%s\n", "No");
  }

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

string s,ss,x;
 ll a,b,i,j,l=0,k=0,d,c;
map<ll,ll>m;
cin>>a>>b>>c;
for(i=1;i<=c;i++)
{
cin>>d;m[d]++;
}
for(i=1;i<=a;i++)
{
if((b-c+m[i])>0)
{
cout<<"Yes\n";
}
else
{cout<<"No\n";}
}

}

Measured memory_bytes: 6912
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

ll N, X;
vector<ll> x;

ll simulate(ll n) {
    //n回かけて運ぶとどうなるかのシミュレーションをする
    ll ret = X * n + X * N;

    for (ll i = 0; i < N; ++i) {
        ll mul = max(5ll, 2 * (i / n) + 3);
        ll index = N - i - 1;
        ret += x[index] * mul;
    }

    return ret;
}

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

    cin >> N >> X;
    x.resize(N);
    rep(i, 0, N) cin >> x[i];

//    cout << simulate(1) << endl;

    ll lb = 1;
    ll ub = N + 1;
    ll ans;

//    if (true) {
//        for (int i = 1; i <= N; ++i) {
//            cout << simulate(i) << endl;
//        }
//    }

    while (true) {
        ll sec1 = lb + (ub - lb) / 3;
        ll sec2 = lb + 2 * (ub - lb) / 3;

        ll val1 = simulate(sec1);
        ll val2 = simulate(sec2);
        if (ub - lb <= 3) {
//            ans = min(val1, val2);
//            ans = min(all(vector<ll>({val1, val2})));
            ans = val1;
            for (ll t = lb; t <= ub; ++t) {
                if (t == 0) continue;
                chmin(ans, simulate(t));
            }
            break;
        }
        if (val1 < val2) {
            ub = sec2;
        } else {
            lb = sec1;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc157/abc157_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<int> S(N, -1);
  rep(i, M) {
    int s, c;
    cin >> s >> c;
    s--;
    if (S[s] == -1) {
      S[s] = c;
    } else if (S[s] != c) {
      // 同じ桁で違う数字
      cout << -1 << endl;
      return 0;
    }
  }

  // 先頭が0指定
  if (N > 1 && S[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  // 2桁以上で先頭が指定されない場合、先頭は１
  if (N > 1 && S[0] == -1) {
    S[0] = 1;
  }

  string ans = "";
  rep(i, N) {
    if (S[i] == -1) {
      ans += "0";
    } else {
      ans += to_string(S[i]);
    }
  }

  cout << ans << endl;
}

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

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

    const ll MOD = 2019;

    string S;
    cin >> S;
    ll N = S.size();

    vector<ll> sum(N + 1, 0);
    map<ll, ll> mp;
    mp[0]++;
    ll res = 1;
    for (int i = N - 1; i >= 0; --i) {
        sum.at(i) = (sum.at(i + 1) + res * (S.at(i) - '0')) % MOD;
        mp[sum.at(i)]++;
        res = res * 10 % MOD;
    }
    ll ans = 0;
    for (int i = 0; i < MOD; ++i) {
        ll m = mp[i];
        ans += m * (m - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5188
N,K=map(int,input().split())

mod=10**9+7
mod
ferumaC=3000
fac=[0 for i in range(ferumaC)]
fac[0]=1
ifac=[0 for i in range(ferumaC)]
ifac[0]=1
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)

for i in range(0,ferumaC-1):
    fac[i+1]=(fac[i]*(i+1))%mod
    ifac[i+1]=ifac[i]*mpow(i+1,mod-2)%mod
def comb(a,b):
    if a==0 and b==0:return(1)
    if a<b or a<0:return(0)
    tmp=ifac[a-b]*ifac[b]%mod
    return(tmp*fac[a]%mod)

for i in range(1,K+1):
    print((comb(N-K+1,i)%mod)*comb(K-1,i-1)%mod)


Measured memory_bytes: 43632