akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
 
const int MOD = 1e9 + 7;
const int N = 300001;
 
typedef long long ll;
 
 
int n;

ll a[N];
ll dfs(int idx , ll sum , bool sign){
	if(idx == n+1)
		return 0;
	sum = sum + a[idx];
	ll toAdd = 0;
	if(sign == 1 && sum <= 0){
		toAdd = abs(sum) + 1;
		sum = 1;
	}
	if(sign == 0 && sum >= 0){
		toAdd = abs(sum)+1;
		sum = -1;
	}
	return toAdd + dfs(idx+1,sum,!sign);
}
int main() {
	//freopen("input.txt","r",stdin);
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	cout << min(dfs(1,0,1),dfs(1,0,0)) << endl;
	return 0;
}

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

int main(){
string S, T, U;
cin >> S >> T;
for(int i=0;i<T.size()-1;i++){
	if(S.at(i) != T.at(i)){
		cout << "No" << endl;
		return 0;
	}
}
cout << "Yes" << endl;

}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second

#define scn(a) scanf("%d",&a)
#define sccn(a,b) scanf("%d%d",&a,&b)
#define scccn(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scnl(a) scanf("%lld",&a)
#define sccnl(a,b) scanf("%lld%lld",&a,&b)
#define scccnl(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scnc(c) scanf(" %c",&c)

#define rep(i,n) for(int i = 0; i<n; ++i)
#define repab(i,a,b) for(int i = a; i<=b; ++i)
#define repba(i,b,a) for(int i = b-1; i>=a; --i)

#define printar(i,ar,n) for(int i = 1; i<=n; ++i) printf("%d ",ar[i]); puts("")

#define ms(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define pb(a) push_back(a)
#define pbp(a,b) push_back({a,b});

#define test(x) cout<<#x<<" "<<x<<endl

#define PI acos(-1)
#define MOD 1000000007
#define eps 0.00000001
#define inf 1<<30
#define MX 100005

int main(){
    // int h,w,m;
    // scccn(h,w,m);
    // int a[3*MX],b[3*MX];
    // memset(a,0,sizeof(a));
    // memset(b,0,sizeof(b));
    // int mxa=0,mxb=0,sa=0,sb=0,ra,rb;
    // for(int i = 0; i<m; ++i){
    //     int f = 1;
    //     int x,y;
    //     scanf("%d%d",&x,&y);
    //     ++a[x];
    //     ++b[y];
    //     if(mxa<a[x]){
    //         mxa = a[x];
    //         ra = x;
    //     }
    //     else f=0;
    //     if(mxb<b[y]){
    //         mxb = b[y];
    //         rb = y;
    //     }
    //     else f= 0;
    //     if(f){
    //         sa = x;
    //         sb = y;
    //     }
    // }
    // test(ra);
    // test(rb);
    // int ans = mxa+mxb;
    // if(sa==ra && sb == rb)
    //     --ans;
    // cout<<ans<<endl;

    string a;
    cin>>a;
    int len= a.size();
    int ans = 0;
    for(int i = 0; i<len; ++i){
        ans +=a[i]-'0';
    }
    if(ans%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int K,T;
    cin>>K>>T;

    int a[T];
    int am=0;
    rep(i,T) {
        cin>>a[i];
        am=max(am,a[i]);
    }
    cout << max(0LL,2*am-K-1) << endl;





}


Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b)
{
  if (a < b) return a;
  else return b;
}

int getMinSet(int amount, int set)
{
  int ans;

  ans = amount / set;

  if (ans * set < amount) ans++;

  return ans;
}

int main() {
  int n, a, b, c, d;
  int setX, setY;
  int price;

  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

  setX = getMinSet(n, a);
  setY = getMinSet(n, c);

  price = min(setX * b, setY * d);

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

  return 0;
}


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

using namespace std;

int main(void)
{
    int n;
    vector<int> a;

    cin>>n;

    for(int i = 0;i < n;i++)
    {
	int temp;
	cin>>temp;
	a.push_back(temp);
    }

    sort(a.begin(),a.end(),greater<int>());

    bool flag = false;
    vector<long long int> seki;
    for(int i = 0;i < n-1;)
    {
	if(a[i] == a[i+1]) {
	    seki.push_back(a[i]);
	    i += 2;
	    if(flag == true)
		break;
	    flag = true;
	}
	else
	    i++;

    }
    seki.push_back(0);
    seki.push_back(0);

    cout<<seki[0]*seki[1]<<endl;

    return 0;
}


Measured memory_bytes: 892
import sys

H, W, m = map(int, input().split())

H_bomb = [0]*H
W_bomb = [0]*W
S = set()

for _ in range(m):
    h, w = map(int, sys.stdin.readline().split())
    h, w = h-1, w-1
    S.add(tuple([h, w]))
    H_bomb[h] += 1
    W_bomb[w] += 1

H_max = max(H_bomb)
W_max = max(W_bomb)

H_memo = []
W_memo = []

for i in range(H):
    if H_bomb[i] == H_max:
        H_memo.append(i)

for j in range(W):
    if W_bomb[j] == W_max:
        W_memo.append(j)

ans = H_max + W_max

for i in H_memo:
    for j in W_memo:
        if tuple([i, j]) not in S:
            print(ans)
            exit()
print(ans-1)

Measured memory_bytes: 181320
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<pint> out;
int main()
{
	int n;cin>>n;
	int t;
	if(n%2==0) t=n+1;else t=n;
	REP(i,1,n+1) REP(j,i+1,n+1){
		if(i+j==t) continue;
		out.pb(mp(i,j));
	}
	cout<<out.size()<<endl;
	rep(i,out.size()){
		cout<<out[i].fi<<' '<<out[i].se<<endl;
	}
}


Measured memory_bytes: 384
s = input()
t = input()

def getCommonCharNum(x, y):
    commonCharNum = 0
    for i in range(len(x)):
        if x[i] == y[i]:
            commonCharNum += 1
    return commonCharNum
maxCommonNum = 0
for i in range(len(s) - len(t) + 1):
    tmpCommonCharNum = getCommonCharNum(s[i: len(t) + i], t)  #s[0, len(s)] → s[0 + last_i, len(s) + last_i]
    if maxCommonNum < tmpCommonCharNum:
        maxCommonNum = tmpCommonCharNum
print(len(t) - maxCommonNum)





Measured memory_bytes: 9052
#include <iostream>
using namespace std;
int main(){
	int n , i = 0;
  cin>>n;
  int j;
  int k = 1,sum = 0;
  while( i < n){
  	cin>>j;
    if( j == k){
    	k++;
      sum++;
    }
    i++;
  }
  if( k == 1){
  	cout<<-1<<endl;
  }
  else{
  	cout<<n-sum<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

ll x;
cin>>x;
for(int i=0;i<=120;i++)
{
    for(int j=-64;j<=119;j++)
    {
        if(po(i,5)-po(j,5)==x)
        {
            cout<<i<<" "<<j<<endl;
            return 0;
        }
    }
}

return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define ll long long
using namespace std;
const int N=1e6+6;
int main(){
	int n,q; static char s[N];
	scanf("%d%s%d",&n,s,&q);
	while (q--){
        int k,c1=0,c2=0; scanf("%d",&k);
        ll sm=0,ans=0;
        rep(i,1,n){
            if (i-k>=1){
                if (s[i-k-1]=='D') --c1,sm-=c2;
                if (s[i-k-1]=='M') --c2;
            }
            if (s[i-1]=='D') ++c1;
            if (s[i-1]=='M') ++c2,sm+=c1;
            if (s[i-1]=='C') ans+=sm;
        }
        printf("%lld\n",ans);
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, a;
  cin >> n >> a;
  cout << n * n - a << endl;
}


Measured memory_bytes: 256
S1=input()
S1=S1.split()
S2=input()
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
    div=int(S2[i+1])-int(S2[i])
    if (div)*A>=B:
        move+=B
    else:
        move+=A*(div)
print(move)

Measured memory_bytes: 11100
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, R;
  scanln(N, R);
  writeln(R + max(0, 10-N)*100);
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int A[100];
  int N;
  int key;
  int i, j, k;

  //Read N and keys
  scanf("%d", &N);
  for(i=0; i<N; i++)scanf("%d", &A[i]);

  //Sort
  for(i=0; i<N; i++)
    {
      key=A[i];
      j=i-1;

      //if A[j]>key, change A[j] to A[j+1]
      while(j>=0 && A[j]>key)
	{
	  A[j+1]=A[j];
	  j=j-1;
	}
      A[j+1]=key;

      //print
      for(k=0; k<N; k++)
	{
	  printf("%d", A[k]);
	  if(k!=N-1)printf(" ");
	}
      printf("\n");
    }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,i,j,t,w,aa,bb,ac,m;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    int a[100001]={0};
    int b[100001]={0};
    aa=0;
    bb=0;
    ac=0;
    w=0;  
    for(i=0;i<n;i++){
      scanf("%d",&m);
      a[m]++;
      if(aa<m)aa=m;
    }
    for(i=0;i<n;i++){
      scanf("%d",&m);
      b[m]++;
      if(bb<m)bb=m;
    }
    if(aa>bb){
      if(n==1)printf("NA\n");
      else    printf("1\n");
    }
    else{
      for(i=bb;i>0;i--){
	w-=b[i];
	for(j=0;j<a[i];j++){
	  w++;
	  ac++;
	  if(w*2>ac)break;
	}
	if(w*2>ac)break;
      }
      if(ac==n)printf("NA\n");
      else     printf("%d\n",ac);
    }
  }
  return 0;
}

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

struct team{
	char t;
	int w, l;
};

bool large(team t1, team t2){
	return ((t1.w > t2.w) || (t1.w == t2.w && t1.l < t2.l));
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		team teams[10] = {0};
		for(int i = 0;i < n;i++){
			cin >> teams[i].t;
			for(int j = 0;j < n - 1;j++){
				int r;
				cin >> r;
				if(r == 0) teams[i].w++;
				if(r == 1) teams[i].l++;
			}
		}
		stable_sort(teams, teams + n, large);
		for(int i = 0;i < n;i++){
			cout << teams[i].t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
x = int(input())
num = list(map(int, input().split()))
test = []
count = 0

for i in num:
  if(i % 2 == 0):
    test.append(i)

for i in test:
  if(i % 3 != 0 and i % 5 != 0):
    print('DENIED')
    count += 1
    sys.exit()

if(count == 0):
  print('APPROVED')


Measured memory_bytes: 3060
import math
x1, y1, x2, y2 = [int(x) for x in input().split()]
x12 = (x2-x1)
y12 = (y2-y1)
L = math.sqrt((x12)**2+(y12)**2)
x3 = (x12-y12)+x1
y3 = (x12+y12)+y1
x4 = -y12+x1
y4 = x12+y1
print('{} {} {} {}'.format(x3, y3, x4, y4))

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

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

int main()
{
    ll i,j;
    ll n,u,v;
    cin >> n >> u >> v;
    --u;    --v;
    vector<vector<ll>> graph(n);
    for(i = 0;i < n-1;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }
    vector<ll> takahasi(n,-1);
    vector<ll> aoki(n,-1);
    takahasi.at(u) = 0;
    aoki.at(v) = 0;
    queue<ll> que;
    que.emplace(u);
    while(!que.empty()){
        ll now = que.front();
        ll dist = takahasi.at(now);
        que.pop();
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i);
            if(takahasi.at(next) == -1){
                takahasi.at(next) = dist+1;
                que.emplace(next);
            }
        }
    }
    que.emplace(v);
    while(!que.empty()){
        ll now = que.front();
        ll dist = aoki.at(now);
        que.pop();
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i);
            if(aoki.at(next) == -1){
                aoki.at(next) = dist+1;
                que.emplace(next);
            }
        }
    }
    ll ans = 0;
    for(i = 0;i < n;++i){
        if(aoki.at(i) > takahasi.at(i)) ans = max(ans, aoki.at(i)-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
      char s;
      cin >> s;
      if(s == 'a'){
           cout << "vowel" << endl;
       }else if(s == 'i'){
              cout << "vowel" << endl;
        }else if(s == 'u'){
               cout << "vowel" << endl;
        }else if(s=='e'){
               cout << "vowel" << endl;
        }else if(s == 'o'){
                 cout << "vowel" << endl;
        }else{
                 cout  << "consonant" << endl;
         }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define vi vector<int>
#define srt(a) sort(a.begin(), a.end());
#define se second
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

LL n;
LL tree[200005];
void update(LL idx, LL val){
    while (idx <= n){
        tree[idx] += val;
        idx += (idx & -idx);
    }
}

LL read(LL idx){
    LL sum = 0;
    while (idx > 0){
        sum += tree[idx];
        idx -= (idx & -idx);
    }
    return sum;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    LL d,aa; cin>>n>>d>>aa;
    vector <pair<LL,LL> > a(n);
    forn(i,n) cin>>a[i].fi>>a[i].se;
    srt(a);
    vector <LL> h(n);
    forn(i,n) h[i] = a[i].fi;
    LL an = 0;
    for(LL i =0;i<n;i++){
      LL va = read(i+1) + a[i].se;
      LL nx = upper_bound(all(h),h[i]+2*d) - h.begin();
//      cout<<nx<<endl;
      if(va>0){
       LL up = ((va/aa)*aa + (va%aa==0?0LL:aa));
       update(i+1,-up);
       update(nx+1,up);
       an+= up/aa;

      }
    }
    cout<<an<<endl;

    return 0;
}



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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 100003

int main(void)
{
  int n,c,k;
  cin>>n>>c>>k;

  int a[n];
  for(int i=0;i<n;i++)
  	scan(a[i]);
  sort(a,a+n);

  queue<int> line;
  for(int i=0;i<n;i++)
  	line.push(a[i]);

  int res = 0;

  while(!line.empty())
  {
  	res++;
  	int top = line.front();
  	line.pop();
  	//cerr<<top<<" ";
  	int total = c-1;
  	int end_time = top + k;

  	while(!line.empty() && total)
  	{
  		int curr = line.front();
  		if(curr>end_time) break;
  		line.pop();
  		total--;
  		//cerr<<curr<<" ";
  	}
  //	cerr<<endl;
  }

  cout<<res;
  return 0;
}


void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

// Z-algorithm
// Zalgoでは、Sの部分文字列の被りを調べる。
// 上のコードを解説すると、
//  1,頭から順に調べ
//  2,連続部分がでてきたら、その連続部分の個数を検出して再利用する。
// 例えば、abcdabcd があったとしたら、　abcd    abcd   とi=4の時二つになる。
// この時、i=5 は　S[5]='b'　と S[0]='a' を比べ始めるわけだが、前のabcd と 後ろのabcd は一致しているので、S[5]以降とS[4]以降を比べても問題ないはず。
// また、この考え方で行くと、S[5]以降とS[4]以降の一致個数は、S[1]以降とS[0]以降の一致個数に等しくなるはず。
// ということは、a->b ^ b->c なら a->c 的な考え方で、S[5]以降のS[0]以降との一致個数は、S[1]以降のS[0]以降との一致個数に等しくなる。
// これは、res[5] = res[1] に他ならない。
// 一般化すると、res[i+k] = res[k] になるということ。
// j回までなのは、そもそも初めの一致個数をオーバーしてしまったら、前のabcd と 後ろのabcd が一致するという前提がなくなるからダメということ。
// 終わりの+=と-=はiを進めるのと、jを0に戻すため。
// 以上の動きによってどのルートを進んでも一回ごとにi++されるのでO(N)でlcp[]が求まる。

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

    int res = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);     //この問題では部分文字列の重複（重なり）を許していないので、各先頭文字列のindexより大きい長さはありえないので、カットしている。
            res = max(res, l);
        }
    }
        
    cout << res << endl;
}

// Z-algorithmはSの0文字目からとi文字目からしか比較できないので、Tをi文字目から始まる部分文字列としてj文字目と比較していく。
// あとは各番号から始まる文字列ごとにZ-algorithmを適用していき、重なりを排除して最大値を更新していく。この動作でO(N^2)となる。

// けんちょんさんのコードまんま

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

int main(){
  int N, D, X; cin>>N>>D>>X;
  int cnt=0;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    for(int j=0; j*vec.at(i)+1<=D; j++){
      cnt++;
    }
  }
  cout<<cnt+X<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for(int i = 0; i < k; i++){
    if(a >= b) b *= 2;
    else if(b >= c) c *= 2;
  }
  if(a < b && b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  char s[2];
  cin >> s;
  int a=0;
  int i;
  for ( i=0; i<3; i++ )
  {
     if ( s[i] == '1' )
	{
          a++;
         }
  }
  cout << a << endl;
}


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

long mod = pow(10, 9) + 7;

int main(){
    long N;
    cin >> N;
    long res = 1;
    for(long i = 1; i <= N; i++){
        res *= i;
        res %= mod; 
    }
    cout << res << endl;
}

Measured memory_bytes: 256
# ARC058D - いろはちゃんとマス目 / Iroha and a Grid (ABC042D)
def get_fact(lim):
    # compute a toble of factorials (1-idx)
    fact = [1] * (lim + 1)
    x = 1
    for i in range(1, lim + 1):
        x = (x * i) % MOD
        fact[i] = x
    return fact


def get_inv(lim):
    # compute a toble of inverse factorials (1-idx)
    inv = [1] * (lim + 1)
    inv[lim] = pow(fact[lim], MOD - 2, MOD)
    x = inv[lim]
    for i in range(lim - 1, 0, -1):
        x = (x * (i + 1)) % MOD
        inv[i] = x
    return inv


def comb(n: int, r: int) -> int:
    # compute nCr (n! / r!(n - r)!)
    return fact[n] * inv[n - r] * inv[r]


def main():
    global MOD, fact, inv
    H, W, A, B = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7
    fact = get_fact(H + W)
    inv = get_inv(H + W)
    x, y, a = H - A - 1, W + A - 2, A - 1  # fixed variables
    ans = sum(comb(x + i, i) * comb(y - i, a) for i in range(B, W)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
    int n,ans;
    cin >> n;
    if(n < 10){
        ans = n;
    }
    else if(n < 100){
        ans = 9;
    }
    else if(n < 1000){
        ans = 9 + (n - 99);
    }
    else if(n < 10000){
        ans = 9 + 900;
    }
    else if(n < 100000){
        ans = 9 + 900 + (n - 9999);
    }
    else{
        ans = 9 + 900 + 90000;
    }

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;

int n;
ll preh, h;

int main(){
  cin >> n;
  for(int i=0; i<n; i++){
    if(i==0){
      cin >> preh;
    } else {
      cin >> h;
      if(preh < h){
        preh=h-1;
      } else if(preh > h){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int N;
vector<int>G[100010];
map<pii, int>ma;
int a[100100], b[100100];
int id;
int cnt;
bool used[100100];
int res = 0;
void dfs(int v,int col) {
	used[v] = true;
	for(int x:G[v]) {
		if (!used[x]) {
			col++;
			col %= cnt;
			if (v > x)ma[{x, v}] = col;
			else ma[{v, x}] = col;
			dfs(x,col);
		}
	}
}
int main() {
	REP(i, 100100)used[i] = false;
	cin >> N;
	REP(i, N-1) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	cnt = 0;
	REP(i, N) {
		if ((int)G[i].size() > cnt) {
			cnt = (int)G[i].size();
			id = i;
		}
	}
	dfs(id,0);
	cout << cnt << endl;
	REP(i, N-1) {
		cout << ma[{a[i], b[i]}]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL S;cin>>S;
    int n=to_string(S).length();
    LL ans=0;

    LL ten[10];
    ten[0]=1;
    REP(i,9)ten[i+1]=ten[i]*10;

    REP(i,1<<(n-1)){
        LL res=0;
        LL s=S;
        REP(j,n-1){
            if(i>>(n-2-j)&1){
                res+=s/ten[n-1-j];
                s%=ten[n-1-j];

            }
        }
        res+=s;
        ans+=res;
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<LL>v;
int main()
{
   LL n,k;
   cin>>n>>k;
   for(LL i=0;i<n;i++)
   {
       LL a;
       cin>>a;
       v.pb(a);
   }
   sort(all(v));
   reverse(all(v));
   LL s=0;
   for(LL i=k;i<n;i++)
    s+=v[i];
   cout<<s;

}



Measured memory_bytes: 2420
import java.util.Scanner;

import java.util.*;
import static java.util.Comparator.*;

public class Main{
	static public void  main(String[] args){
		Scanner scan = new Scanner(System.in);

		String s  = scan.next();

		int ret = 0;
		char c = s.charAt(0);
		for (int i = 1; i < s.length() ; i++){
			if(c == s.charAt(i)){
				ret++;
				c=(s.charAt(i) == '0')? '1':'0';
			}else{
				c = s.charAt(i);
			}
		}

		System.out.println(ret);

	}

}


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

H, W = map(int, input().split())
MOD = 10 ** 9 + 7
A = [input() for _ in range(H)]

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
 
for y in range(H):
  for x in range(W):
    if y+1 < H and A[y+1][x] == '.':
      dp[y+1][x] += dp[y][x]
      dp[y+1][x] = dp[y+1][x] % MOD

    if x+1 < W and A[y][x+1] == '.':
      dp[y][x+1] += dp[y][x]
      dp[y][x+1] = dp[y][x+1] % MOD

print(dp[H-1][W-1])

Measured memory_bytes: 43628
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=3005;
int n,i,j,k,a[N],head[N],adj[N*2],nxt[N*2];
bool f[N][2],v[N];
void dfs(int x)
{
	v[x]=true;
	int z=0;
	for(int y=head[x];y;y=nxt[y])
		if(a[x]>a[adj[y]])
		{
			++z;
			if(!v[adj[y]])
				dfs(adj[y]);
			f[x][0]=f[x][0]||!f[adj[y]][0];
			f[x][1]=f[x][1]||!f[adj[y]][1];
		}
	if(z==0)
		f[x][0]=true;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",a+i);
	for(i=1;i<n;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	for(i=1;i<=n;++i)
		if(!v[i])
			dfs(i);
	for(i=1;i<=n;++i)
		if(f[i][1])
			printf("%d ",i);
	puts("");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)}
for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk)

Measured memory_bytes: 9128
#include"bits/stdc++.h"
using namespace std;

int main(){
	double N, odd = 0,ans;
	cin >> N;

	for (int i = 1; i <= N; i++){
		if (0 != i % 2)odd++;
	}

	ans = odd / N;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
if n < 3:
    print(n)
    exit()

primes = [2]

import math
for i in range(3, n+1):
    k = int(math.sqrt(i))
    flag = True
    for p in primes:
        if p > k:
            break
        if  i%p == 0:
            flag = False
            break
    if flag:
        primes.append(i)

ans = 1
for p in primes:
    k = n
    cnt = 0
    while k:
        k = k//p
        cnt += k
    # print(p, cnt)
    ans *= cnt + 1
ans = ans % (10**9 + 7)
print(ans)

Measured memory_bytes: 3064
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

string s, t;
int n;
bool flag ;


bool match(int i , int j){

    rep(i, 0, n){
    if(j>n)j=0;

        if(s[i]==t[j]){j++;continue;}
        else return false;

    }
return true;

}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);



cin >>  s>> t;

n = s.size()-1;

rep(i, 0, n){

    rep(j, 0, n){

    if(match(i, j)){
        cout << "Yes";
        return 0;
    }

    }

}

cout << "No" ;





return 0;}
///.... Maria Otonashi


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++)    cin>>a[i];
    char x[h][w];
    int dx[8] = {-1,-1,-1,0,1,1,1,0};
    int dy[8] = {-1,0,1,1,1,0,-1,-1};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j] == '.'){
                int cnt=0;
                for(int k=0;k<8;k++){
                    int x = i+dx[k], y=j+dy[k];
                    if((x>=0 && y>=0) && (x<h && y<w)){
                        if(a[x][y] == '#')  cnt++;
                    }
                }
            x[i][j] = cnt+'0';
            }
            else{
                x[i][j] = a[i][j];
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<x[i][j];
        }
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

int main(){
    ll n,d;
    cin>>n>>d;
    ll w = 2*d+1;
    
    cout << n/w + bool(n%w != 0) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int N,Max,P[maxm];

int main(){
	register int i,Ans=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%d",P+i),Ans+=P[i],Max=max(Max,P[i]);
	Ans=Ans-Max+Max/2;
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=100005;

int ar[4][mxN];
int dp[4][mxN];
int n;


int main(){
    fast;
    int n;
    cin>>n;
    int a,b,c;
    fo(i, n){
        cin>>a>>b>>c;
        ar[0][i]=a;ar[1][i]=b;ar[2][i]=c;
    }
    fo(i,3)dp[i][0]=ar[i][0];
    fok(j, 1,n){
        dp[0][j]=ar[0][j]+ max(dp[1][j-1], dp[2][j-1]);
        dp[1][j]=ar[1][j]+ max(dp[2][j-1], dp[0][j-1]);
        dp[2][j]=ar[2][j]+ max(dp[0][j-1], dp[1][j-1]);
    }/*
    fo(i, 3){
        fo(j, n)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    int ans=max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
    cout<<ans;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int mx=max(a,b),mn=min(a,b);
	c=(c-1)/mx+1;
	c=min(c,mn);
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i

an = gets.chomp.split(" ").map(&:to_i);

sum =0
sum += an[0]
sum += an[-1]
an.each_with_index do |a, i|
  break if an.size - 1 == i
  sum += [an[i], an[i+1]].min
end

puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
const int mod = 1e9+7;


int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int arr[4];
arr[0] = a+ b;
arr[1] = a+ c;
arr[2] = b+ c;
arr[3] = 1e9;
	int min_n = 1e9;
	rep(i,3){
		min_n = min(min_n,arr[i]);
	}

	cout << min_n << endl;

	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
r = [[0 for _ in range(W)] for _ in range(H)]
l = [[0 for _ in range(W)] for _ in range(H)]
d = [[0 for _ in range(W)] for _ in range(H)]
u = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    c = 0
    for j in range(W):
        if S[i][j] == ".":
            r[i][j] = c
            c += 1
        else:
            c = 0
for i in range(H):
    c = 0
    for j in range(W)[::-1]:
        if S[i][j] == ".":
            c += 1
            l[i][j] = c
        else:
            c = 0
for i in range(W):
    c = 0
    for j in range(H):
        if S[j][i] == ".":
            d[j][i] = c
            c += 1
        else:
            c = 0
for i in range(W):
    c = 0
    for j in range(H)[::-1]:
        if S[j][i] == ".":
            c += 1
            u[j][i] = c
        else:
            c = 0
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, r[i][j] + l[i][j] + d[i][j] + u[i][j] - 1)
print(ans)

Measured memory_bytes: 313224
#!/usr/bin/perl

# 引数取り込み
my $a = <>;
my $b = substr( $a, 0, 1 );
my $c = substr( $a, 1, 1 );
my $d = substr( $a, 2, 1 );

# 処理開始
my $ans = "No";
$ans = "Yes" if ( $b ne $c );
$ans = "Yes" if ( $c ne $d );
$ans = "Yes" if ( $d ne $b );

print $ans;

1;

Measured memory_bytes: 4680
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    
    
}


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

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

    const int N = 4e2 + 4;
    const ll inf = 1e13;
    ll f[N][N],sum[N];
    int a[N];
    int n;
    ll ans = 0;

    void solve(){
        cin>>n;
        for(int i = 1;i <= n;++i){
            cin>>a[i];
            sum[i] = sum[i - 1] + 1LL*a[i];
        }
        for(int i = 1;i <= n;++i){
            f[i][i] = 0;
        }
        for(int gap = 2;gap <= n;++gap){
            for(int l = 1,r = gap;r <= n;++r,++l){
                f[l][r] = inf;
                for(int j = l;j < r;++j){
                  minimize(f[l][r],f[l][j] + f[j + 1][r] + sum[r] - sum[l - 1]);
                }
            }
        }
        cout<<f[1][n];
}}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int ta[300]={0};
	int n;
	while(cin>>n)ta[n]++;
	int ma=0;
	for(int i=1;i<=100;i++)if(ma<ta[i])ma=ta[i];
	for(int i=1;i<=100;i++)if(ma==ta[i])cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 1164
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)

N = int(input())
a = [0] + list(map(int, input().split())) + [0]
INF = float("inf")

sum_a = list(itertools.accumulate(a))

dp = [[INF]*(N+5) for i in range(N+5)]
for i in range(1,N+1):
    dp[i][i+1] = 0

for k in range(2,N+1):
    for l in range(1,N-k+2):
        r = l + k
        for i in range(r-l-1):
            w1 = sum_a[l+i] - sum_a[l-1]
            w2 = sum_a[r-1] - sum_a[l+i]
            dp[l][r] = min(dp[l][r], dp[l][l+i+1] + dp[l+i+1][r] + w1 + w2)

print(dp[1][N+1])




Measured memory_bytes: 75236
#include <stdio.h>

int main(void)
{
	int n;
	float hight[40];
	int i, j;
	int count[6] = {0};
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%f", &hight[i]);
		if (hight[i] < 165.0){
			count[0]++;
		}
		else if (hight[i] < 170.0){
			count[1]++;
		}
		else if (hight[i] < 175.0){
			count[2]++;
		}
		else if (hight[i] < 180.0){
			count[3]++;
		}
		else if (hight[i] < 185.0){
			count[4]++;
		}
		else if (hight[i] >= 185.0){
			count[5]++;
		}
	}
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		if (count[i] != 0){
			for (j = 0; j < count[i]; j++){
				printf("*");
			}
			printf("\n");
		}
		else {
			printf("\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;


int main() {
    int n,x,y; cin >> n >> x >> y;
    x --; y --;
    vector<int> dist(n,0);
    rep(i,n) {
        for (int j = i + 1; j < n ; j ++) {
            int d = min(j - i,abs(i - x) + 1 + abs(j - y));
            dist[d] ++;
        }
    }
    for (int i = 1; i < n;i ++) cout << dist[i] << endl;
}



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

vector<int> euler_phi_table(int n) {
	vector<int> res;
	for(int i = 0; i < n; ++i)
		res.push_back(i);

	for(int i = 2; i < n; ++i)
		if(res[i] == i)
			for(int j = i; j < n; j += i)
				res[j] = res[j] / i * (i - 1);

	return res;
}

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

	vector<int> euler = euler_phi_table(1000001);

	int t;
	cin >> t;

	for(int i = 0; i < t; ++i) {
		int n;
		cin >> n;

		long long ans = 1;
		for(int i = 0; i <= n; ++i)
			ans += euler[i];

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 6420