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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,q;
vi cnt1[525];
int tmp[525];
int cnt2[525][525];

int main(){
  scanf("%d%d%d",&n,&m,&q);
  REP(i,m){
    int l,r;
    scanf("%d%d",&l,&r);
    --l;--r;
    cnt1[l].push_back(r);
  }
  FORR(l,0,n){
    for(int x : cnt1[l]){
      tmp[x]++;
    }
    REP(r,n){
      cnt2[l][r+1] = cnt2[l][r] + tmp[r];
    }
  }
  while(q--){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;
    printf("%d\n",cnt2[a][b]);
  }
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,k,s=1,num=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int m;
    k=0;
    cin>>m;
    if(m==2){
      num++;
    }else if(m%2==0){
      continue;
    }else{
      for(int j=3;j<=sqrt(m);j+=2){
	if(m%j==0){
	  k=1;
	  break;
	}
      }
      if(k==0)
	num++;
    }
  }
  cout<<num<<endl;
  return 0;
}

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

int N;
int a[200007];

int main(){
    cin >> N;
    for(int i =0; i<N-1; i++) cin >> a[i];

    int ans[N];
    for(int i; i<N; i++) ans[i] =0;
    for(int i=0; i<N-1; i++){
        ans[a[i]-1] += 1;
    }

    for(int i=0; i<N; i++) cout << ans[i] << " ";
    cout << endl;
}

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

int main(){
  string in;
  string ans = "";
  cin >> in;

  for(auto i = in.begin(), end = in.end();i != end;i++){
    switch(*i){
      case '0':
        ans.push_back('0');
        break;
      case '1':
        ans.push_back('1');
        break;
      case 'B':
        if(ans != ""){
          ans.pop_back();
        }
        break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> k(M), p(M);
    vector<vector<ll>> s(M);
    for (ll i = 0; i < M; i++) {
        cin >> k[i];
        for (ll j = 0; j < k[i]; j++) {
            ll t;
            cin >> t;
            s[i].push_back(t - 1);
        }
    }
    for (ll i = 0; i < M; i++) {
        cin >> p[i];
    }

    ll ans = 0;
    for (ll i = 0; i < (1 << N); i++) {
        bool ok = true;
        for (ll j = 0; j < M; j++) {
            ll num = 0;
            for (ll k : s[j]) {
                if (i & (1 << k)) {
                    num++;
                }
            }
            if (num % 2 != p[j]) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MAX int(2 * 1e5 +5)


int main(){
    int n;
    cin >> n;
    int dp[MAX];
    REP(i,MAX) dp[i] = 0;
    REP(i,n){
        int tmp;
        scanf("%d",&tmp);
        dp[tmp] = dp[tmp -1] +1;
    }
    int ma = 0;
    FOR(i,1,n+1) ma = max(ma,dp[i]);
    cout << n - ma << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int h[100005];

int main()
{
	int n;
	cin>>n;
	for(int i = 1;i <= n ;i += 1)cin >> h[i];
	long long int dp[n+1];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;


}

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

int main(){
  int n,sum=0;
  cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  sort(num.begin(),num.end());
  for(int i=0;i<n-1;i++){
    sum+=num[i];
  }
  if(num[n-1]<sum){
    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
A.sort(reverse=True)
cout = 0
for i in range(1, len(A)):
    if A[i] == A[i - 1]:
        cout = i
        break
for i in range(cout + 2, len(A)):
    if A[i] == A[i - 1]:
        print(A[cout] * A[i])
        break
if cout == 0:
    print(0)

Measured memory_bytes: 62832
from itertools import combinations
n=int(input())
a=list(map(int,input().split()))
c=0
for x in combinations(a,3):
    if x[0]!=x[1] and x[1]!=x[2] and x[2]!=x[0]:
        if x[0]<x[1]+x[2] and x[1]<x[0]+x[2] and x[2]<x[0]+x[1]:
            c+=1
print(c)

Measured memory_bytes: 9184
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。


ll f(ll n){
	ll ret=0;
	if((n&3)==0) ret=n;
	if((n&3)==1) ret=1;
	if((n&3)==2) ret=n+1;
	if((n&3)==3) ret=0;

	return ret;
}

int main(){
	ll a,b;
	cin>>a>>b;
	cout<<(f(b)^f(a)^a)<<endl;
    return 0;
}

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

int main() 
{
  int N;
  cin >> N;
  
  vector<int> tr(N);
  for(int i = 0; i < N; i++){
    cin >> tr.at(i);
  }
  
  sort(tr.begin(),tr.end());
  
  int num = 0;
  vector<int> sam(3);
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      for(int k = j+1; k < N; k++){
        if( (tr.at(i) != tr.at(j)) && (tr.at(j) != tr.at(k)) ){
          if( (tr.at(i) + tr.at(j)) > tr.at(k) ){
            num++;
          }//if
        }else if(tr.at(i) == tr.at(j)){
          break;
        }//else
      }//for
    }//for
  }//for
  
  cout << num << endl;
}

Measured memory_bytes: 3572
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.componentCount = size

    def root(self, index):
        if self.parent[index] == index:  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2):  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2:  # 連結されている場合
            return

        self.componentCount -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2]:
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else:
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2]:
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2):
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index):
        return self.size[self.root(index)]

N, M = map(int, input().split())
tree = UnionFind(N)

for _ in range(M):
    a, b, c = map(int, input().split())
    tree.union(a - 1, b - 1)

print(tree.componentCount)


Measured memory_bytes: 8564
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define mod 1000000007
#define inf 11451419198
using namespace std;

int main(){
	string s; cin >> s;
	s = '0' + s;
	reverse(s.begin(), s.end());
	vvl dp(s.size() + 1, vl(2, 0));
	for (ll i = 0; i < s.size(); ++i){
		dp[i + 1][0] = min(dp[i][0]+s[i]-'0',dp[i][1]+s[i]-'0'+1);
		if (!i) dp[i + 1][1] = 10 - (s[i] - '0');
		else dp[i + 1][1] = min(dp[i][0] + 10 - (s[i] - '0'), dp[i][1] + 9 - (s[i] - '0'));
	}cout << min(dp[s.size()][0],dp[s.size()][1]) << endl;
	return 0;
}

Measured memory_bytes: 55856
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll A[101010];
map<ll, ll> mp;

long long modpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  cin >> N;
  rep(i, 0, N) {
    cin >> A[i];
    ++mp[A[i]];
  }

  if (N % 2 == 1) {
    for (ll i = N - 1; i >= 2; i -= 2) {
      if (mp[i] != 2) {
        cout << 0;
        return 0;
      }
    }
    if (mp[0] != 1) {
      cout << 0;
      return 0;
    }
    cout << modpow(2, N / 2);
  } else {
    for (ll i = N - 1; i >= 1; i -= 2) {
      if (mp[i] != 2) {
        cout << 0;
        return 0;
      }
    }
    cout << modpow(2, N / 2);
  }
}


Measured memory_bytes: 8272
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,M,K,X,Y,W,H;
    ll ans=0;
    string S;
    ll A[100010];
    int temp[100]={0};
    bool f=false;
    bool fir=true;
    ll sum=0;

int main(){
    cin>>N;
    cout<<"ABC"<<N;
    return 0;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
num_list = [0]*N

flag=True

for _ in range(M):
  s, c = map(int, input().split())

  if (s == 1 and c == 0 and N != 1):
    print(-1)
    flag=False
    break

  if (num_list[s-1] == 0):
    num_list[s-1] = c
  else:
    if num_list[s-1] != c:
      print(-1)
      flag=False
      break

if flag:
  if num_list[0] == 0 and N != 1:
    num_list[0] = 1

  ans = ""
  for i in num_list:
    ans += str(i)

  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <cstdint>

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

	std::priority_queue<std::int64_t> pque;
	for (int i = 0; i < n; ++i) {
		std::int64_t a;
		std::cin >> a;

		pque.push(a);
	}

	for (int i = 0; i < m; ++i) {
		auto x = pque.top();
		pque.pop();
		pque.push(x / 2);
	}

	std::int64_t ans = 0;
	while (!pque.empty()) {
		ans += pque.top();
		pque.pop();
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const int INF = 1LL << 29;

struct edge {
    int to, cap, rev, cost;
    edge(int a, int b, int c, int d): to(a), cap(b), rev(c), cost(d) {}
};

int V, E, F;
vector<edge> graph[100];

int min_cost_flow(int s, int g, int f) {
    vector<int> min_dist(V, INF);
    vector<int> prev_v(V, -1), prev_e(V, -1);
    int ans = 0;
    while (f > 0) {
        fill(begin(min_dist), end(min_dist), INF);
        min_dist[s] = 0;

        bool updated = true;
        while (updated) {
            updated = false;
            for (int v = 0; v < V; ++v) {
                if (min_dist[v] == INF) continue;
                for (int j = 0; j < graph[v].size(); ++j) {
                    edge& e = graph[v][j];
                    if (e.cap > 0 && min_dist[v] + e.cost < min_dist[e.to]) {
                        updated = true;
                        min_dist[e.to] = min_dist[v] + e.cost;
                        prev_v[e.to] = v;
                        prev_e[e.to] = j;
                    }
                }
            }
        }

        if (min_dist[g] == INF) {
            return -1;
        }

        int ff = f;
        for (int t = g; t != s; t = prev_v[t]) {
            ff = min(ff, graph[prev_v[t]][prev_e[t]].cap);
        }

        ans += ff * min_dist[g];
        for (int t = g; t != s; t = prev_v[t]) {
            edge& e = graph[prev_v[t]][prev_e[t]];
            e.cap -= ff;
            graph[t][e.rev].cap += ff;
        }

        f -= ff;
    }
    return ans;
}

int main() {
    cin >> V >> E >> F;
    for (int j = 0; j < E; ++j) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        graph[u].emplace_back(v, c, (int)graph[v].size(), d);
        graph[v].emplace_back(u, 0, (int)graph[u].size()-1, -d);
    }

    cout << min_cost_flow(0, V-1, F) << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
\

int main(){
    int a, b;
    scanf("%d %d", &a, &b); 
    int d = a / b; 
    int r = a % b;
    double f = 1.00 * a / b; 
    printf("%d\n", d);
    printf("%d\n", r);
    printf("%.6lf\n", f);

    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
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;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  cout<<max(zero,(a+(n-1)*b)-(a*(n-1)+b)+1)<<endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import product

h, w ,k =map(int, input().split())
C = [list(input()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if C[i][j] == "#":
            C[i][j] = 1
        else:
            C[i][j] = 0

H_total = [sum(x) for x in C]
W_total = []
for i in range(w):
    total = 0
    for j in range(h):
        total += C[j][i]
    W_total.append(total)

all_black = sum(H_total)

ans = 0

for a in product([0,1], repeat=h):
    for b in product([0,1], repeat=w):
        neg = 0
        for i in range(h):
            if a[i] == 1:
                neg += H_total[i]

        for j in range(w):
            if b[j] == 1:
                neg += W_total[j]

        for i in range(h):
            for j in range(w):
                if a[i]==1 and b[j]==1 and C[i][j]==1:
                    neg -= 1

        if all_black - neg == k:
            ans += 1

print(ans)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  unordered_map<string, int> dp;
  vector<string> cand;
  cand.push_back("");
  for (int i = 0; i < (int)(10); ++i) {
    cand.push_back(string(1, i + '0'));
    for (int j = 0; j < (int)(10); ++j) {
      cand.push_back(string(1, i + '0'));
      cand.back() += string(1, j + '0');
    }
  }
  dp[""] = -1;
  for (int i = 0; i < (int)(N); ++i) {
    vector<pair<string, int>> res;
    for (string& s : cand) {
      if (dp.find(s) != dp.end()) res.emplace_back(s + S[i], i);
    }
    for (auto& p : res) dp[p.first] = p.second;
  }
  int ans = 0;
  for (auto& p : dp) ans += (p.first.size() == 3);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
i=list(map(int, input().split()))
n=i[0]
x=i[1]-1
y=i[2]-1
l=[0]*n
for j in range (0,n-1):
    for k in range (j+1,n):
        s=abs(k-y)+abs(x-j)+1
        if s>k-j:
            s=k-j
        l[s]=l[s]+1

for z in range (1,n):
    print(l[z])

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3) {
    cout << 0 << endl;
    return 0;
  }
  int n = (X + Y) / 3;
  X -= n; Y -= n;
  if (X < 0 || Y < 0) {
    cout << 0 << endl;
    return 0;
  }
  combination c(X + Y);
  mint ans = c(X + Y, X);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 10624
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    int x=0,tmp=n;
    while(tmp>0){
        x+=tmp%10;
        tmp/=10;
    }
    
    if(n%x==0){
        cout1("Yes")
    }else{
        cout1("No")
    }
    
}

Measured memory_bytes: 256
N = int(input())
ylst = []
for i in range(1, int(N ** 0.5) + 1):
    if N % i == 0:
        ylst.append(i)
        if i != N // i:
            ylst.append(N // i)

ans = 10 ** 11

for i in range(len(ylst)):
    for j in range(i, len(ylst)):
        if ylst[i] * ylst[j] == N:
            tmp = max(len(str(ylst[i])), len(str(ylst[j])))
            ans = min(ans, tmp)

print(ans)

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	if((n & (n - 1)) == 0)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	bool was = false;
	for(int i = 3; i <= n; i += 2)
	{
		int u = i - 1, v = i;
		if(u == (n ^ (n - 1) ^ 1) || u == n - 1)
			swap(u, v);
		if(!was)
		{
			cout << "1 " << u << "\n";
			was = true;
		}
		cout << u << " " << v << "\n";
		cout << v << " " << n + 1 << "\n";
		cout << n + 1 << " " << n + u << "\n";
		cout << n + u << " " << n + v << "\n";
	}
	if(n % 2 == 0)
	{
		cout << n << " " << n - 1 << "\n";
		cout << (n ^ (n - 1) ^ 1) << " " << n + n << "\n";
	}
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, q, b[20], h[20], w[20];
double l[20], ans[20];

void merge(int i){
	w[i - 1] += w[i];
	for(; i <= n; i++){
		h[i] = h[i + 1];
		w[i] = w[i + 1];
		b[i] = b[i + 1];
		l[i] = l[i + 1];
	}
	n--;
}

int main(){
	int cs;
	cin >> cs;
	while(cs--){
		memset(w, 0, sizeof(w));
		memset(l, 0, sizeof(l));
		
		cin >> n;
		rep(i, n) cin >> b[i + 1] >> h[i + 1];
		h[0] = h[n + 1] = 50;
		b[n + 1] = 100;
		
		cin >> m;
		rep(i, m){
			int pos, flow;
			cin >> pos >> flow;
			pos = lower_bound(b, b + n + 1, pos) - b - 1;
			w[pos] += flow;
		}
		
		vector<pair<double, pi> > qs;
		cin >> q;
		rep(i, q){
			int pos, t;
			cin >> pos >> t;
			qs.pb(mp(t, mp(pos, i)));
			ans[i] = 50;
		}
		sort(all(qs));
		reverse(all(qs));
		
		double t = 0;
		while(qs.size()){
			double nxt = qs.back().first;
			rep(i, n + 1) if(w[i]){
				int ht = min(h[i], h[i + 1]), wd = b[i + 1] - b[i];
				double tmp = (ht - l[i]) / w[i] * 30 * wd;
				nxt = min(nxt, t + tmp);
			}
			
			rep(i, n + 1) if(w[i]){
				int wd = b[i + 1] - b[i];
				l[i] += (nxt - t) * w[i] / 30 / wd;
				
				if(l[i] > 50 - EPS) goto END;
			}
			
			t = nxt;
			if(abs(qs.back().first - t) < EPS){
				int pos = lower_bound(b, b + n + 1, qs.back().second.first) - b - 1;
				ans[qs.back().second.second] = l[pos];
				qs.pop_back();
			}
			
			while(1){
				bool ok = 1;
				rep(i, n + 1){
					if(abs(l[i] - h[i + 1]) < EPS){
						if(abs(l[i] - l[i + 1]) < EPS) ok = 0, merge(i + 1);
						else if(w[i]){
							ok = 0;
							w[i + 1] += w[i];
							w[i] = 0;
						}
					}
					if(abs(l[i] - h[i]) < EPS){
						if(abs(l[i] - l[i - 1]) < EPS) ok = 0, merge(i);
						else if(w[i]){
							ok = 0;
							w[i - 1] += w[i];
							w[i] = 0;
						}
					}
				}
				if(ok) break;
			}
		}
		END:
		rep(i, q) printf("%.9f\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
// #define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc()
{
    static const int BS = 1 << 22;
    static unsigned char buf[BS], *st, *ed;
    if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
    return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x)
{
    x = 0;
    bool f = 0;
    char c = gc();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = 1;
        c = gc();
    }
    while ('0' <= c && c <= '9')
    {
        x = (x << 3) + (x << 1) + (c ^ 48);
        c = gc();
    }
    if (f) x = -x;
}
#undef gc
#define pb push_back
int al[4] = {'R', 'G', 'Y', 'B'};
signed main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
#endif
    int n, m, d;
    in(n), in(m), in(d);
    for (ri i = 1; i <= n; ++i)
    {
        for (ri j = 1; j <= m; ++j)
            printf("%c", al[(i + j + 500) / d % 2 * 2 + (i - j + 500) / d % 2]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 512
n=int(input())
i= list(map(int, input().split()))
j= list(map(int, input().split()))
j.append(0)
amari=0
ans=0
for k in range(n+1):
    s=i[k]
    i[k]-=amari
    if i[k]<0:
        i[k]=0
        ans+=s
    else:
        ans+=amari
    amari=0
    if i[k]<j[k]:
        amari+=(j[k]-i[k])
        ans+=i[k]
    else:
        ans+=j[k]
print(ans)
        

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend()); //大きい順
    priority_queue<int, vector<int>, greater<int>> p_que, q_que;
    rep(i, x) p_que.push(p[i]);
    rep(i, y) q_que.push(q[i]);
    
    rep(i, c) {
        int p_min = p_que.top(), q_min = q_que.top(), r_max = r[i];
        if (r_max <= p_min && r_max <= q_min) {
            break;
        } else {
            int p_diff = r_max - p_min, q_diff = r_max - q_min;
            if (p_diff >= q_diff) {
                p_que.pop();
                p_que.push(r_max);
            } else {
                q_que.pop();
                q_que.push(r_max);
            }
        }
    }
    ll ans = 0;
    while (!p_que.empty()) {
        ans += p_que.top();
        p_que.pop();
    }
    while (!q_que.empty()) {
        ans += q_que.top();
        q_que.pop();
    }
    cout << ans << endl;

}


Measured memory_bytes: 2552
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner inp = new Scanner(System.in);
int a = inp.nextInt();
int b = inp.nextInt();
if (a>b) 
System.out.println("a > b");
else if (a<b)
System.out.println("a < b");
else if (a==b)
System.out.println("a == b");
}
}


Measured memory_bytes: 26288
#include<iostream>
#include<string>
#include<cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
 
using namespace std;
 
class Stack{
private:
  int inf[1000];
  int tp;
 
public:
 
  Stack(){
    tp=0;
  }
 
 
  void push(int x){
    tp++;
    inf[tp] = x;
  }
 
  void pop(){
    tp--; 
  }
 
  int top(){
    int x = inf[tp];
    return x;
  }
 
  bool isempty(){
    if(tp == 0)return true;
    return false;
  }
 
  int size(){
    return tp;
  }
 
};
 
  
 
int main(){
  Stack stack;
  string str,s[10000];
  int ind=0,th=0;
   
  getline(cin,str);
  for(int i=0;i<str.length();i++){
     
    if(str[i] == ' ')
      {
    th=0;
    ind++;
      }    else
      {
     
    s[ind].insert(th,str.substr(i,1));
    th++;
      }
  }
  ind++;
 
  for(int i=0;i<ind;i++){
        
    if(s[i] == "+" || s[i] == "*" || s[i] == "-")
      {
     
    int x2 = stack.top();
    stack.pop();
    int x1 = stack.top();
    stack.pop();
    if(s[i] == "+")
      {
        stack.push(x1+x2);
      }       
    else if(s[i] == "-")
      {
        stack.push(x1-x2);
      }
    else if(s[i] == "*")
      {
        stack.push(x1*x2);
      }
      }
    else
      {
    if(s[i] == " ")continue;
    int n = atoi(s[i].c_str());
    stack.push(n);
      }
  }
  cout << stack.top() << endl;
 
 
}


Measured memory_bytes: 3260
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func judge(t int, x int, y int) bool {

	if (x + y) > t {
		return false
	}

	if t%2 == 0 && (x+y)%2 == 0 {
		return true
	} else if t%2 != 0 && (x+y)%2 != 0 {
		return true
	}

	return false

}

func main() {
	var n int
	fmt.Scan(&n)

	ls := make([][3]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&ls[i][0], &ls[i][1], &ls[i][2])
	}

	for _, tri := range ls {
		t := tri[0]
		x := tri[1]
		y := tri[2]

		if !judge(t, x, y) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")

}


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

using namespace std;
using int64 = long long;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (a>0 && c>0) {
        c -= b;
        a -= d;
    }

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


Measured memory_bytes: 3108
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N, K; cin >> N >> K;
	V<ll> h(N); REP(i, N) cin >> h[i];
	sort(ALL(h));
	ll ans = LINF;
	for(int i = 0; i + K - 1 < N; ++i){
		ans = min(ans, abs(h[i + K - 1] - h[i]));
	}
	cout << ans << endl;


	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;	cin>>a>>b;
	if(a-b*2<0)	cout<<"0"<<endl;
	else cout<<a-b*2<<endl;


    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define NUM 100

int main()
{
   static long i,j,k,l;
   int mid;
   int end;
   int re;
   char grade[NUM];
   for(i=0;;i++) {
      cin >> mid >> end >> re;
      if(mid == -1 && end == -1 && re == -1)
         break;
      int sum = mid + end;
      if(mid == -1 || end == -1)
         grade[i] = 'F';
      else if(sum >= 80)
         grade[i] = 'A';
      else if(sum >= 65)
         grade[i] = 'B';
      else if(sum >= 50)
         grade[i] = 'C';
      else if(sum >= 30 && re >= 50)
         grade[i] = 'C';
      else if(sum >= 30)
         grade[i] = 'D';
      else
         grade[i] = 'F';
   }
   for(j=0;j<i;j++)
      cout << grade[j] << endl;

   return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r,d,a[1000];
	cin>>r>>d>>a[0];
	for(int i=1;i<11;i++)
	{
		a[i]=a[i-1]*r-d;
	}
	for(int i=1;i<11;i++)
	cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    n, Y = map(int, input().split())

    for x in reversed(range(n+1)):
        for y in reversed(range(n-x+1)):
            z = n - x - y
            if x*10000+y*5000+z*1000 == Y:
                print('{} {} {}'.format(x, y, z))
                exit()
    print('-1 -1 -1')

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

int main()
{
    long int x=0,en=100;
    int i=0;
    scanf("%ld",&x);

    for(i=1.0;;i++){
	en=en*1.01;
	if(en>=x)
	    break;
    }

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

    return 0;
}




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

int main(void){
    int H,W;cin>>H>>W;
    char C[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>C[i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<C[i][j];
        }
        cout<<endl;
        for(int j=0;j<W;j++){
            cout<<C[i][j];
        }
        cout<<endl;
    }    
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>

int gcd(int a, int b);
int lcm(int a, int b);

int main(){
	int a, b;
	while(std::cin >> a >> b){
		std::cout << gcd(a, b) << " " << lcm(a, b) << std::endl;
	}
    return 0;
}

//Greatest Common Divisor
int gcd(int a, int b){
	while(a != b){
		if(a > b) a = a - b;
		else b = b - a;
	}
	return a;
}

//Least Common Multiple
int lcm(int a, int b){
	return((a / gcd(a, b)) * b);
}

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

const int N = 1e5+2323;

int ans[N];

void show(int ara[],int n){
	#ifdef LOCAL
	for(int i = 1; i <= n;i++)cout << ara[i] << " ";cout << endl;
	#endif
}


int main()
{
   // ios_base::sync_with_stdio(false);
    
  	int n,q,l,r;
  	string s;
  	scanf("%d%d",&n,&q);
  	cin >> s;
  	string t = "x"+s;
  	for(int i = 1; i <= n;i++){
  		if(t[i] == 'C' and t[i-1] == 'A'){
  			//cout << " " << i << endl;
  			ans[i] = ans[i-1]+1;
  		}
  		else ans[i] = ans[i-1];
  	}
  	show(ans,n);
  	while(q--){
  		scanf("%d %d",&l,&r);
  		int k = 0;
  		if(t[l] == 'C' and t[l-1] == 'A')k++;
  		printf("%d\n",ans[r]-ans[l-1]-k);
  	}






    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n,l;
   cin>>n>>l;
   vector<int> r(n);
   int sum=0;
   for(int i=0;i<n;i++){
       r[i]=l+i+1-1;
       sum+=r[i];
   }

   
   int tmp=100000000;
   int p;
   for(int i=0;i<n;i++){
       if(abs(r[i])<tmp){
           tmp=abs(r[i]);
           p=r[i];
       }
   }

   

   cout<<sum-p<<endl;
}

   


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
ll ans=0;
int need=-1;
int pat=0;

void dfs(int len,int ndig,ll knum, int need)
{
  string s=to_string(knum);
  if(s.size()==len)
  {
    pat++;
    if(pat==need)
    {
      ans=knum;
    }
    return;
  }
  ll i;
  for(i=knum%10-1;i<=knum%10+1;i++)
  {
    if(i<0||i>9)continue;
    dfs(len,ndig+1,knum*10+i,need);
  }
}

int main()
{
  int k;cin>>k;
  int i,j,l;
  need=k;
  int ldig;
  for(ldig=1;ldig<=10;ldig++)
  {
    for(i=1;i<=9;i++)
    {
      pat=0;
      dfs(ldig,1,i,need);
      need-=pat;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3664
#include<stdio.h>
main(){
  double a,b;
  int cnt1[4]={0},cnt2[4]={0},i;
  while(scanf("%lf %lf",&a,&b)!=EOF){
    if(a>=1.1)cnt1[0]++;
    else if(a>=0.6)cnt1[1]++;
    else if(a>=0.2)cnt1[2]++;
    else cnt1[3]++;
    if(b>=1.1)cnt2[0]++;
    else if(b>=0.6)cnt2[1]++;
    else if(b>=0.2)cnt2[2]++;
    else cnt2[3]++;
  }
  for(i=0;i<=3;i++){
    printf("%d %d\n",cnt1[i],cnt2[i]);
  }
  return 0;
}

Measured memory_bytes: 628
function cmp(a, b){
    return (b-a);
}

function main(input) {
    const args = input.split('\n');
    const N_M = args[0].split(' ');
    const N = parseInt(N_M[0]);
    const M = parseInt(N_M[1]);
    var cakes = [];
    for(var i = 1; i <=N; i++){
        var cake = [];
        cake.push(parseInt(args[i].split(' ')[0]));
        cake.push(parseInt(args[i].split(' ')[1]));
        cake.push(parseInt(args[i].split(' ')[2]));
        cakes.push(cake);
    }
    var ans = 0;
    
    for(var b = 0; b < 8; b++){
        var arr = [];
        for(var i = 0; i < N; i++){
            var sum = 0;
            for(var j = 0, k = 1; j < 3; j++, k*=2){
                sum += cakes[i][j] * (b&k?1:-1);
            }
            arr.push(sum);
        }
        arr.sort(cmp);
        var tmp = 0;
        for(var i = 0; i < M; i++)tmp = tmp + arr[i];
        //console.log(arr);
        if(tmp>ans)ans=tmp;
    }
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11292
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> grades;
    int T; cin >> T;
    int sum = 0;    
    while(T--)
    {
        int num; cin >> num;
        sum += num;
        if(num%10 != 0)
            grades.push_back(num);
    }
    sort(grades.begin(), grades.end());
    int counter = 0;
    if(sum%10 != 0)
        cout << sum << endl;
    else
    {
        if(grades.size() == 0)
            cout << 0 << endl;
        else
        {
            sum -= grades[0];
            cout << sum << endl;
        }
    }
    
    

    return 0;
}


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

int main(){
    stack<int> S1;
    stack<pair<int,int> > S2;
    char ch;
    int sum=0;
    for (int i = 0; cin >> ch ; ++i) {
    	if (ch=='0') break;
        if ( ch == '\\') S1.push(i);
        else if (ch == '/'  && S1.size() > 0 ){
            int j =S1.top(); S1.pop();
            sum += i-j;
            int a = i-j;
            while ( S2.size() > 0 && S2.top().first > j ){
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    int t=0;
    while(S2.size()>0){ans.push_back(S2.top().second); S2.pop();}
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0 ; i < ans.size(); i++){
        cout << " ";
        t += ans[i];
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0){cout << "Yes" << endl;return 0;}
        a-=d;
        if(a<=0){cout << "No" << endl;return 0;}
    }
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
	int flag=0;
	long long ans=0;
	long long x,y;
	cin>>x>>y;
	if(x==1&&y==1){ans=1;flag=1;}
	if(x==1&&y!=1){ans=y-2;flag=1;}
	if(flag!=1&&y==1){ans=x-2;flag=1;}
	if(flag!=1&&(x==2||y==2)){ans=0;flag=1;}
	if(flag!=1)ans=x*y-y-y-x-x+4;
	printf("%lld\n",ans);
}



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


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

    ll n;

    cin >> n;

    ll arr[n];

    ll arr1[n];

    ll mod = 1e9+7;

    for(ll i=0; i<n; i++)
    {
        cin >> arr[i];
        arr1[i] = arr[i];
    }

    for(ll i=1; i<n; i++)
    {
        arr1[i] = (arr1[i] + arr1[i-1]);
    }

    ll z = arr1[n-1];

    ll sum = 0;



    for(ll i=0; i<n-1; i++)
    {
        ll temp = (z - arr1[i]) % mod;

        temp = (temp * arr[i]) % mod;

        sum = (sum + temp) % mod;
    }

    cout << sum % mod;



}



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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    int ans = 0;
    for (int i=0; i<n; i++) ans += a[i] - 1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define ll long long

int const N = 101, W = 1e5 + 1;

int n, w;

int arr[N][2];

bool vis[N][W];

ll dp[N][W];

ll pound(int index, int weight)

{

		if (index > n)				return 0;

				

		if (weight > w)

				return -1e9;

				

		if (vis[index][weight])

				return dp[index][weight];

				

		vis[index][weight] = true;

		

		return dp[index][weight] = max(arr[index][1] + pound(index + 1, weight + arr[index][0]), pound(index + 1, weight));

}

int main()

{

		

		ios_base::sync_with_stdio(false);

		cin.tie(nullptr);

    cin >> n >> w;

    

    for (int i = 0; i < n; ++i)

        cin >> arr[i][0] >> arr[i][1];

        

    cout << pound(0, 0);

    

    return 0;

}

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

int main()
{
    vector<int>task(3);
    for(int i = 0; i < 3; i++ ){
        cin >> task[i];
    }
    sort(task.begin(),task.end());
    int ans = task[1]-task[0] + task[2]-task[1];
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a.insert(0, 0)
a.append(0)

#print(a)

sub_a = []
for i in range(n+1):
    if i == n:
        sub_a.append(abs(a[i]))
    else:
        sub_a.append(abs(a[i]-a[i+1]))

#print(sub_a)
total = sum(sub_a)

for k in range(n):
    # もともとの差の総和から該当部分を引いて、iを飛ばした場合のに転換の距離を足す
    print(total - sub_a[k]-sub_a[k+1] + abs(a[k]-a[k+2]))



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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, W, N;
	cin >> H >> W >> N;

	int L = max(H, W);

	int ans = (N + L - 1) / L;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[4];
   cin>>a[0]>>a[1]>>a[2];
   swap(a[0],a[1]);
   swap(a[0],a[2]);
   cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;

}


Measured memory_bytes: 256