akhauriyash/Code-Regression huggingface dataset:
#include "stdio.h"
#define TEAM_MAX 300

int main(int argc, char const *argv[])
{
    int ti,team,probrem,record;
    int ti_keika,team_num,pro_num,gouhi;
    int i,j,k;
    int score[TEAM_MAX][50];
    int score_sin[TEAM_MAX];
    int min;
    int min_num;
    int syuturyoku_count = 0;
    int dataset = 0;

    while(1){
        dataset++;
        //?????????
        for(i = 0;i < TEAM_MAX;i++){
            for(j = 0;j < 50;j++){
                score[i][j] = 0;                    
            }
            score_sin[i] = 0;
        }

    
    // ???????????????????????¢?????????????????\??????0 0 ???????????????
    scanf("%d %d %d %d",&ti,&team,&probrem,&record);//???????????????????????°???????????°???????????°
    if(probrem == 0 && record == 0 && team == 0 && ti == 0){
        break;
    }
    for(i = 0; i < record;i++){
        // ???????????\???
        scanf("%d %d %d %d",&ti_keika,&team_num,&pro_num,&gouhi);
        // ??????????????£???????????????????????£???????????????
        // ??£?§£????????????????????¢????????????
        if(gouhi != 0){
            score[team_num][pro_num] += 20;
        } else {
            score_sin[team_num] += score[team_num][pro_num]+ti_keika;
            score_sin[team_num] -= 1000000;
        }
    }
    syuturyoku_count = 0;
    // ????????¢?????????????????????????????????
    while(syuturyoku_count != team) {
        min = 100000001;
        //?????§???????????¢???????????????
        for(j = team;j >= 1;j--){
            if(min > score_sin[j]){
                min_num=1;
                min = score_sin[j];
            } else if(min == score_sin[j]) {
                min_num++;
            }
        }
        // ????????¨???
        for(j = team;j >= 1;j--){
            //?????????????????° 
            if(min == score_sin[j]){
                printf("%d", j);
                syuturyoku_count++;
                if(syuturyoku_count == team){
                    printf("\n");
                    break;
                } else {
                    if(min_num >= 2){
                        printf("=");
                    }
                    else {
                        printf(",");
                    }
                }
                score_sin[j] = 100000000;
                break;
            }
        }
    }
}
return 0;
}

Measured memory_bytes: 660
#include<iostream>

using namespace std;
typedef long Type;
typedef struct CardValSuite{char suit,val;}Card;


template <class T1>
inline void swap0(T1& a,T1& b){
	T1 t;t=a;a=b;b=t;
}



Card* insertionSort(Card A[], int N){

	int i,j;
	Card buf;
	for(i=1;i<N;i++){
		j=i-1;
		buf=A[i];
		while(buf.val<A[j].val&&j>=0){
			A[j+1]=A[j];
			j--;
		}A[j+1]=buf;
		
		/*for(j=0;j<N-1;j++){
			cout<<A[j]<<" ";
		}cout<<A[N-1]<<endl;
		*/
	}
	return A;
}


Card* selectionSort(Card A[], int N){

	int i,j,cnt=0,cnt2=0;
	char Min;
	
	for(int i=0;i<N;i++){
		Min=A[i].val;
		for(int j=i;j<N;j++){
			if(Min>A[j].val)Min=A[j].val,cnt=j;
		}
		if(cnt)swap0(A[i],A[cnt]),cnt2++;
		cnt=0;
	}
	
	//cout<<cnt2<<endl;
	return A;
}



Card* bubbleSort(Card A[], int N){

	for(int j=0;j<N-1;j++)
	for(int i=N-1;i>j;i--){
		if(A[i].val<A[i-1].val)swap0(A[i],A[i-1]);
	}
	return A;
}



bool isStable(Card A[],Card B[],int N){

	for(int i=0;i<N;i++){
		if(A[i].val!=B[i].val||A[i].suit!=B[i].suit)
		return 0;
	}
	return 1;
}



int main(){
	
	int N;
	cin>>N;
	//Type A[N];
	Card* ans;
	Card* ans2;
	
	Card A[N],B[N];
	
	for(int i=0;i<N;i++)cin>>A[i].suit>>A[i].val;
	for(int i=0;i<N;i++)B[i]=A[i];
	
	ans=bubbleSort(A,N);
	
	for(int j=0;j<N-1;j++){
		cout<<ans[j].suit<<ans[j].val<<" ";
	}cout<<ans[N-1].suit<<ans[N-1].val<<endl;
	cout<<"Stable"<<endl;
	
	ans2=selectionSort(B,N);
	
	for(int j=0;j<N-1;j++){
		cout<<ans2[j].suit<<ans2[j].val<<" ";
	}cout<<ans2[N-1].suit<<ans2[N-1].val<<endl;
	
	if(isStable(ans,ans2,N)){
		cout<<"Stable"<<endl;
	}else{cout<<"Not stable"<<endl;}
	
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
using namespace std;
//*********************************
//******problem D DP contest***
int main(){
    ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
    cout.tie(NULL);
    ll int n,w;
    cin>>n>>w;
    ll int a[n+2],b[n+2];
    for(ll int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }

    ll int dp[n+2][w+2];
    memset(dp,0,sizeof(dp));
    for(ll int j = 1;j<=n;j++){
        for(ll int wt=1;wt<=w;wt++){
            //if(j==0||wt==0) dp[j][wt] = 0;
             if(wt<a[j])
                   dp[j][wt] = dp[j-1][wt];

            else{
                dp[j][wt] = max(dp[j-1][wt] , b[j] + dp[j-1][wt-a[j]]);
            }
        }

    }
    //cout<<dp[2][2];
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 80000
#include<stdio.h>
#include<string.h>
int main(void){
    int A,B,C,D,E,x,y,cou=0,v[3];
    char S[3],s[3],X,Y;
    scanf("%s%s",&S,&s);
   if((S[0]==s[2])&&(S[1]==s[1])&&(S[2]==s[0])){
            printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
while True:
	n = int(raw_input())
	if n == 0: break
	s = 32
	a = map(int, raw_input().split())
	i = 0
	while s > 0:
		s -= (s-1)%5
		print s
		s -= a[i%n] if s > a[i%n] else s
		print s
		i += 1

Measured memory_bytes: 4204
import java.util.Scanner

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val A = Array.fill(N)(sc.nextInt)

    // Ai までの累積の余りを出す
    val s = ArrayBuffer.fill(N + 1)(0)
    s(0) = 0
    var sum = 0
    for (i <- 0 until N) {
      sum += A(i)
      sum %= M
      s(i + 1) = sum
    }

    var ans = 0L
    val r = mutable.Map[Int, Int]()
    for (i <- 0 to N) {
      val n = r.getOrElse(s(i), 0)
      ans += n
      r(s(i)) = n + 1
    }
    ans.toString
  }
}


Measured memory_bytes: 58188
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GreatOceanView | diff GreatOceanView.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GreatOceanView.cpp && ./a.out

/*
 
 4/17/2019
 
 15:37-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  int res=0;
  REP(i,N) {
    bool ok=true;
    REP(j,i) ok&=A[j]<=A[i];
    res+=ok;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

int main(){
    int c;
    int n,m;
    int b;
    cin>>n>>m;
    int cnt[n]={0};
    while(cin>>b){
        for(int i=0;i<b;i++){
            cin>>c;
            for(int i=0;i<n;i++){
                if(c==i+1)cnt[i]++;
            }
        }
    }
    int cnt1=0;
    for(int i=0;i<n;i++){
        if(cnt[i]==0)cnt1++;
    }
    cout<<cnt1;
    return 0;
}

Measured memory_bytes: 3572
import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(N+1)
    ans=[0]*(N+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(N+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)


for i in range(2,N+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

print('Yes')
for i in range(2,N+1):
    print(ans[i])




Measured memory_bytes: 38700
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second


void solve() {
	string s; cin >> s;
	int cnt = 0;
	int n = s.length();
	rep(i, n) {
		Rep(j, i, n) {
			bool f = true;
			Rep1(k, i, j) {
				if (s[k] != 'A' && s[k] != 'T' && s[k] != 'G' && s[k] != 'C')f = false;
			}
			if (f)cnt = max(cnt, j - i + 1);
		}
	}
	cout << cnt << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


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

using namespace std;

typedef pair<int, int> pii;

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

    pii cb[n+m];
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cb[i] = pii(a, 1);
    }
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        cb[n+i] = pii(c, b);
    }
    sort(cb, cb+n+m);

    long long ans = 0;
    int cnt = 0;
    for (int i = n + m - 1; i >= 0; i--) {
        if (cb[i].second + cnt >= n) {
            ans += 1ll * (n - cnt) * cb[i].first;
            break;
        } else {
            ans += 1ll * cb[i].second * cb[i].first;
            cnt += cb[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int MOD = 1'000'000'007;

struct mint {
  long long x;

  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

  mint operator-() const { return mint(-x); }

  mint &operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }

  mint &operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }

  mint &operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }

  mint operator+(const mint a) const { return mint(*this) += a; }

  mint operator-(const mint a) const { return mint(*this) -= a; }

  mint operator*(const mint a) const { return mint(*this) *= a; }

  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(MOD - 2); }

  mint &operator/=(const mint a) { return *this *= a.inv(); }

  mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

// a が小さいときの combination
mint combination2(int n, int k) {
  mint x = 1; // 分子
  mint y = 1; // 分母
  rep(i, k) {
    x *= (n - i);
    y *= (k - i);
  }
  return x / y;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  mint res = mint(2).pow(n);
  mint acomb = combination2(n, a);
  mint bcomb = combination2(n, b);
  res -= mint(1);
  res -= acomb;
  res -= bcomb;
  cout << res.x << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> h(n);
  rep(i,n) cin>>h[i];

  int ans=0;
  int mh=-1;
  for(int i=0;i<n;i++){
    if(mh<=h[i])
    ans++;
    mh=max(mh,h[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void) {
	float a,b,c,d,e,f;
	
	while(scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f) != EOF){
		float by = d/a,x,y;
		y = (c*by-f)/(b*by-e);
		x = (c - b*y)/a;
		printf("%.3f %.3f\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 1076
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    string s;
    cin >> s;
    reverse(all(s)); 
    
    vl ans;
    ll now = 0;
    while(now != n) {
        bool ok = false;
        for(ll x = m; x >= 1; x--) {
            if(now + x > n) {
                continue;
            }
            if(s[now + x] == '1') {
                continue;
            }
            ok = true;
            ans.pb(x);
            now += x;
            break;
        }
        if(ok == false) {
            out(-1);
            re0;
        }
    }

    reverse(all(ans));

    for(auto p : ans) {
        cout << p << " ";
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 1528
pypy -ca,b,c,d=`tr \  ,`"
m=10**9+7
def f(r,c):
 s=t=1
 for i in range(c):s=s*(r+c-i)%m;t=t*-~i%m
 return s*pow(t,m-2,m)%m
print(f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m"

Measured memory_bytes: 88508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d || (abs(a-b) <=d && abs(b-c) <= d)) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

bool isSquare(int num) {
  int ans = 1;
  while (num > 0) {
    num -= ans;
    ans += 2;
  }
  return ans == 0;
}

int main() {
  string a, b;
  cin >> a >> b;
  string s = a + b;
  int x = 0;
  rep(i, s.size()) {
    x = x * 10 + (s[i] - '0');
  }
  rep(i, 1000) {
    if (x == i * i) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    vector<int> dp_a(n, -INF);
    vector<int> dp_b(n, -INF);
    vector<int> dp_c(n, -INF);
    dp_a[0] = a[0];
    dp_b[0] = b[0];
    dp_c[0] = c[0];
    repk(i, 1, n) {
        chmax(dp_a[i], dp_b[i - 1] + a[i]);
        chmax(dp_a[i], dp_c[i - 1] + a[i]);
        chmax(dp_b[i], dp_c[i - 1] + b[i]);
        chmax(dp_b[i], dp_a[i - 1] + b[i]);
        chmax(dp_c[i], dp_a[i - 1] + c[i]);
        chmax(dp_c[i], dp_b[i - 1] + c[i]);
    }
    cout << max(dp_a[n - 1], max(dp_b[n - 1], dp_c[n - 1])) << endl;
}

Measured memory_bytes: 5592
#include <stdio.h>

int main(void){
  int sum = 0;
  char c;
  
  while(c = getchar(), c != EOF && c != '\n'){
    if((sum += (c-'0')) >= 9)
      sum %= 9;
 	 fprintf(stderr, "%d ", sum);
  }
  
  if(sum % 9)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 1596
#include<iostream>
#include<vector>
#include<queue>
#include<functional>
 
constexpr int MAX_N = 100, INF = (int)1e8;
 
using P = std::pair<int, int>;
 
struct edge {
    int to, cost;
    edge() = default;
    edge(int _t, int _c) : to(_t), cost(_c) {}
};
 
int n;
std::vector<edge> G[2][MAX_N];//0:??????,1:??????
 
int d[MAX_N];
 
int dijkstra(int s, int g, int index) {
    std::fill(d, d + n, INF);
    d[s] = 0;
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    que.emplace(d[s], s);
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        if (p.second == g)
            return d[g];
        if (d[p.second] > p.first)
            continue;
        for (int i = 0; i < G[index][p.second].size(); ++i) {
            edge e = G[index][p.second][i];
            if (d[e.to] > d[p.second] + e.cost) {
                d[e.to] = d[p.second] + e.cost;
                que.emplace(d[e.to], e.to);
            }
        }
    }
    return -1;
}
 
int main() {
    while (1) {
        int m;
        std::cin >> m >> n;
        if (m + n == 0)
            break;
        int a, b, c, t;
        for (int i = 0; i < m; ++i) {
            std::cin >> a >> b >> c >> t;
            --a;
            --b;
            G[0][a].emplace_back(b, c);
            G[0][b].emplace_back(a, c);
            G[1][a].emplace_back(b, t);
            G[1][b].emplace_back(a, t);
        }
        int q, r;
        std::cin >> q;
        int p[2];
        for (int i = 0; i < q; ++i) {
            std::cin >> p[0] >> p[1] >> r;
            --p[0];
            --p[1];
            std::cout << dijkstra(p[0], p[1], r) << std::endl;
        }
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < n; ++j)
                G[i][j].clear();
        }
    }
    return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
void solve(vector<int64> &A){
    int n = A.size();
    int64 dp[n + 1][2];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            dp[i][j] = 0;
        }
    }
    dp[2][1] = A[2];
    dp[2][0] = A[1];
    for(int i = 3; i < n; i++){
        if(i % 2 == 1){ // odd.
            dp[i][0] = max(A[i - 1] + dp[i - 2][0],
                       max(A[i - 1] + dp[i - 3][0],
                       max(A[i - 1] + dp[i - 3][1],
                           A[i - 2] + dp[i - 3][0])));
            dp[i][1] = A[i] + max(dp[i - 2][0],
                              max(dp[i - 2][1],
                              max(dp[i - 3][1],
                                  dp[i - 3][1])));
        }
        else{
            dp[i][0] = A[i - 1] + dp[i - 2][0];
            dp[i][1] = A[i] + max({dp[i - 1][0],
                                   dp[i - 2][0],
                                   dp[i - 2][1]});
        }
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
    return;
}
int main(){
    int n; cin >> n;
    vector<int64> A(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    solve(A);
    return 0;
}


Measured memory_bytes: 7968
c = [[i for i in map(int,input().split())] for j in range(3)]

b = [c[0][0],c[0][1],c[0][2]]
a = [0,c[1][0]-c[0][0],c[2][0]-c[0][0]]

flag = True

for i in range(3):
    for j in range(3):
        if c[i][j] == a[i]+ b[j]:
            continue
        else:
            flag = False
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int k;
    cin >> k;
    int x = 7 % k;
    set <int> s;
    for (int i = 1; i <= k; ++i) {
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	set<ll> ans;
	ll n;
	ll k;
	cin >> n;
	ll cur = 0;
	for(ll i=0; i<n;i++){
		cin >> k;
		if(k >= 1 and k<=399)
			ans.insert(1);
		else if(k>=400 and k<=799)
			ans.insert(2);
		else if(k>799 and k<=1199)
			ans.insert(3);
		else if(k>1199 and k<=1599)
			ans.insert(4);
		else if(k>1599 and k<=1999)
			ans.insert(5);
		else if(k>1999 and k<=2399)
			ans.insert(6);
		else if(k>1999 and k<=2799)
			ans.insert(7);
		else if(k>=2800 and k<=3199)
			ans.insert(8);
		else
			cur++;
	}
	cout << (ans.size() == 0 ? 1 : ans.size()) << " " << ans.size()+cur;
	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll x[200010],s[200010];
ll ss[200010];

int main(){
	cin>>n;
  rep(i,n)cin>>x[i]>>s[i];
  set<P> st;
  rep(i,n){
    ss[i+1]=ss[i]+s[i];
    st.insert(P(-(ss[i+1]-x[i]),i));
  }
  ll nx=x[0];
  ll ns=0;
  ll res=0;
  rep(i,n){
    P t=*st.begin();
    maxch(res,-t.fi+nx-ns);
    if(i+1<n)nx=x[i+1];
    ns+=s[i];
    st.erase(P(-(ss[i+1]-x[i]),i));
  }
  cout<<res<<endl;

	return 0;
}


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

int main(){
    int N,sum=0;
    cin >> N;
    vector<int> a(N+2,0);
    for(int i=1;i<=N;i++){
        cin >> a[i];
        sum += abs(a[i]-a[i-1]);
    }
    sum += abs(a[N+1] - a[N]);
    for(int i=1;i<=N;i++){
        int tmp = sum + (abs(a[i-1]-a[i+1]))-(abs(a[i-1]-a[i])+abs(a[i+1]-a[i]));
        cout << tmp << endl;
    }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>

using namespace std;

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

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using std::min;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if (a&1 && b&1 && c&1){
		printf("%lld",min(1ll*a*b,min(1ll*b*c,1ll*a*c)));
	}else puts("0");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n, a[1005], b = 0, al = 0;
    cin >> n ;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    for(ll i = 0; i < n; i ++)
    {
        if((i + 1) % 2 == 0)
        {
            b += a[i];
        }
        else
        {
            al += a[i];
        }
    }
    cout << abs(al - b);
}


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

typedef long long ll;
#define debug(x) cout << #x << ": " << (x) << endl
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define all(x) x.begin(), x.end()
#define INF (1ll << 40)
#define MOD (1000000007)
#define print(arr, n) REP(i, n) cout << arr[i] << " ";

struct PreMain {PreMain(){std::cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

vector<ll> s, t;

int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int A, B, Q;
    cin >> A >> B >> Q;
    ll tmp;
    s.emplace_back(-INF);
    t.emplace_back(-INF);
    REP(i, A) {cin >> tmp; s.emplace_back(tmp);}
    REP(i, B) {cin >> tmp; t.emplace_back(tmp);}
    s.emplace_back(INF);
    t.emplace_back(INF);
    sort(all(s)); sort(all(t));

    ll x;
    ll ans;

    REP(i, Q) {
        cin >> x;

        auto s_it = upper_bound(all(s), x);
        auto t_it = upper_bound(all(t), x);

        ll inf1 = *prev(s_it);
        ll sup1 = *s_it;
        ll inf2 = *prev(t_it);
        ll sup2 = *t_it;

        ans = INF;
        ans = min(ans, x - min(inf1, inf2));
        ans = min(ans, max(sup1, sup2) - x);

        ans = min(ans, 2 * (x - inf1) + 1 * (sup2 - x));
        ans = min(ans, 1 * (x - inf1) + 2 * (sup2 - x));

        ans = min(ans, 2 * (x - inf2) + 1 * (sup1 - x));
        ans = min(ans, 1 * (x - inf2) + 2 * (sup1 - x));

        ans = min(ans, 2 * (x - inf1) + 1 * (sup2 - x));
        ans = min(ans, 1 * (x - inf1) + 2 * (sup2 - x));

        cout << ans << endl;
    }

//    //ソートする必要があるのじゃ…
//    vector<int> a = {1, 4, 4, 7, 7, 8, 8, 11, 13, 19};
//    vector<int> b = {0, 1, 2, 3, 4, 5, 19, 20};
//
//    for (auto x: b){
//        auto it = lower_bound(all(a), x);
//        auto it2 = upper_bound(all(a), x);
//        cout << x << " Iter1 = " << *it << " " << it - a.begin(); //Iter1 = 4
//        cout << " Iter2 = " << *it2 << " " << it2 - a.begin() << endl; //Iter1 = 4
//        if (it == a.begin()){
//            cout << "1 same as begin" << endl;
//        }
//
//        if (it == a.end()){
//            cout << "1 same as end" << endl;
//        }
//
//        if (it2 == a.begin()){
//            cout << "2 same as begin" << endl;
//        }
//
//        if (it2 == a.end()){
//            cout << "2 same as end" << endl;
//        }
//
//    }

    return 0;
}




Measured memory_bytes: 3060
#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 a,b;
    cin>>a>>b;
    
    cout1(1.*a/b)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline ll read(){
  ll x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
ll q[N], ans[N], t[N], top;
inline void add(ll l, ll r, ll v) {
  ans[l] += v;
  ans[r + 1] -= v;
}
int main(int argc, char const *argv[]) {
  ll n = read(), m = read();
  q[++ top] = n;
  for (int i = 1; i <= m; ++ i) {
    ll x = read();
    while (top && q[top] >= x) {
      -- top;
    }
    q[++ top] = x;
  }
  t[top] = 1;
  for (int i = top; i; -- i) {
    ll x = q[i];
    ll p = upper_bound(q + 1, q + i, x) - q - 1;
    while (p) {
      t[p] += (x / q[p]) * t[i];
      x %= q[p];
      p = upper_bound(q + 1, q + p, x) - q - 1;
    }
    add(1, x, t[i]);
  }
  for (int i = 1; i <= n; ++ i) {
    ans[i] += ans[i - 1];
    printf("%lld\n", ans[i]);
  }
  return 0;
}
/*

先把 qi>qj && i<j 的 qi 全部删去，这显然没有贡献

结果你能得到一个递增的数组 q

设 t[i] 表示第 i 次操作完后的序列在最终序列中出现了多少次

显然 t[m] = 1

对于每个 q[i]，每次我们需要二分找到一个最大的 k 使得 q[k] <= q[i]

t[k] += (q[i] / q[k]) * t[i]
q[i] %= q[k]

如果 k <= q[1]，说明只能是 [1..k]，直接差分计算即可。

=====================================

样例 2

12345678                    ( 8  )
123456781                   ( 9  )
1234567811234567811         ( 19 )
1234567811234567811123      ( 22 )
123456781123456781112312345 ( 27 )


*/

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   vector<int> a(n);
   rep(i,n)cin >> a[i];
   int l = 0, r = 0;
   int xsum = 0;
   ll ans = 0;
   for(;r<n;r++){
      if (xsum & a[r]){
         while(l < r && (xsum&a[r])){
            xsum ^= a[l];
            l++;
         }
         xsum ^= a[r];
      }
      else{
         xsum ^= a[r];
      }
      ans += r-l+1;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3988
#include<stdio.h>
int main(void)
{
		int n,t,i,k,j,g,s,r,a;
	while(1)	{
		scanf("%d",&t);
		if(t==0)	break;
		scanf("%d",&n);
		g=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&s);
			k=s-a;
			g+=k;
		}
		if(g>=t){
			printf("OK\n");
		}
		if(g<t){
			r=t-g;
			printf("%d\n",r);
		}
		k=0;	
	}	
	return 0;
}	

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#define mod 1000000007
using ll = long long;
using namespace std; 
const double pi = acos(-1);

int main() {
    string a; cin >> a;
    for (int i=0;i<(1<<3);i++){
        char q=a[0];
        int ans=int(q-'0');
        string s;
        for (int j=0;j<3;j++){
            if (i&(1<<j)){
                char q=a[j+1];
                ans+=int(q-'0');
                s+="+";
            }
            else {
                char q=a[j+1];
                ans-=int(q-'0');
                s+="-";
            }
        }
        if (ans==7){
            cout << a[0] << s[0] << a[1] << s[1] << a[2] << s[2] << a[3] << "=7" << "\n";
            return 0;
        }
    }
    cout << "no" << "\n";
}



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

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

  int n;
  cin >> n;

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

  int mx = *max_element(a.begin(), a.end());
  int mn = *min_element(a.begin(), a.end());

  cout << mx - mn << endl;

  return 0;
}

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

using namespace std;

class MinkowskiDistance
{
public:
	MinkowskiDistance()
	: size(0)
	, dim1(0.0)
	, dim2(0.0)
	, dim3(0.0)
	, dimInf(0.0) {}

	void setSize() {
		cin >> size;
	}

	void input_x() {
		for(int i = 0; i < size; ++i) {
			int inputData;
			cin >> inputData;
			x.push_back(inputData);
		}
	}

	void input_y() {
		for(int i = 0; i < size; ++i) {
			int inputData;
			cin >> inputData;
			y.push_back(inputData);
		}
	}

	void printDistances() {
		calculateDim1Distance();
		calculateDim2Distance();
		calculateDim3Distance();
		calculateDimInfDistance();

		cout << fixed << setprecision(8) << dim1 << endl
		     << dim2 << endl
		     << dim3 << endl
		     << dimInf << endl;
	}

private:
	int size;
	vector<int> x, y;
	double dim1;
	double dim2;
	double dim3;
	double dimInf;

	void calculateDim1Distance() {
		dim1 = 0.0;
		for(int i = 0; i < size; ++i) {
			dim1 += fabs(x.at(i) - y.at(i));
		}
	}

	void calculateDim2Distance() {
		dim2 = 0.0;
		for(int i = 0; i < size; ++i) {
			dim2 += pow(x.at(i) - y.at(i), 2);
		}
		dim2 = sqrt(dim2);
	}

	void calculateDim3Distance() {
		dim3 = 0.0;
		for(int i = 0; i < size; ++i) {
			dim3 += fabs(pow(x.at(i) - y.at(i), 3));
		}
		dim3 = pow(dim3, 1.0 / 3);
	}

	void calculateDimInfDistance() {
		dimInf = 0.0;
		for(int i = 0; i < size; ++i) {
			dimInf = max(dimInf, fabs(x.at(i) - y.at(i)));
		}
	}
};

int main() {
	MinkowskiDistance distance;
	distance.setSize();
	distance.input_x();
	distance.input_y();
	distance.printDistances();
	return 0;
}


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

int main() {

	int N;
	int K;
	cin >> N >> K;

	vector<int> h(N);
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int ans = 0;
	for (int i = N-1; i >= 0; i--)
	{
		if (h[i] >= K) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;





	return 0;
}

Measured memory_bytes: 640
a,b,c = map(int, input().split())
k = int(input())

for i in range(k):
    if a >= c:
        c = 2*c
        continue
    if b >= c:
        c = 2*c
        continue
    if a >= b:
        b = 2*b
        continue

if a < b < c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define MN 100005
typedef long long ll;
int T,n,cnt;char ch[MN];
int main(){
//	freopen("test.in","r",stdin);
//	freopen("mysol.out","w",stdout);
	scanf("%s",ch+1);n=strlen(ch+1);bool pd=(ch[1]=='1')&(ch[n]=='0');
	for(int i=1;i<n;i++)pd&=(ch[i]==ch[n-i]);
	if(!pd)puts("-1");
	else {
		int lst=0,lstx=0;
		for(int i=1;i<=n/2;i++)if(ch[i]=='1'){
			int tmp=++cnt;if(lstx)printf("%d %d\n",tmp,lstx);
			for(int j=1;j<i-lst;j++)printf("%d %d\n",(++cnt),tmp);
			lst=i,lstx=tmp;
		}
		int tmp=++cnt;if(lstx)printf("%d %d\n",tmp,lstx);
		for(int j=1;j<n-lst;j++)printf("%d %d\n",(++cnt),tmp);
	}
}



Measured memory_bytes: 3892
# N = gets.to_i
# A = gets.split(" ").map(&:to_i)
# S = gets.chomp

a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

def up(x)
  (x + 9) / 10 * 10
end

n = 0
arr = [a, b, c, d, e]
# arr = [1,2,3,4,5,6,7,8,9,0]
arr = arr.sort_by { |x| - ((x -1) % 10) }
# p arr

n += up(arr[0])
n += up(arr[1])
n += up(arr[2])
n += up(arr[3])
n += arr[4]

puts n


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long // LEMBRAR DE TROCAR CASO PROBLEMA DE MEMORIA
#define pii pair<int,int>
#define ieps (int) 1e6
#define eps (int) 1e9
#define mp make_pair
#define pb push_back



int32_t main(){
	/*ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	*/
	set<char> s;
	for(char i = 'a' ; i<='z' ; i++) s.insert(i);
	string t;
	cin>>t;
	int n = t.size();
	for(int i = 0 ; i <t.size() ; i++){
		s.erase(t[i]);
	}
	if(s.size()){
		char w = *s.begin();
		t+=w;
		cout<<t<<endl;
		return 0;
	}
	else{
		string a = t;
		next_permutation(a.begin() , a.end());
		string lul;
		for(int i = 0 ; i < t.size() ; i++){
			if(a[i] == t[i]){
				lul += a[i];
			}
			else{
				lul += a[i];
				break;
			}
		}
		if(lul > t){
			cout<<lul<<endl;
			return 0;
		}
	}
	puts("-1");
}

// qyxwvutsrzponmlkjihgfedcba

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		ArrayDeque<String> deque = new ArrayDeque<String>();
		StringBuilder sb = new StringBuilder();
		String s = in.next();
		deque.add(s);
		int n=in.nextInt();
		int rev=0;
		for(int i=0;i<n;i++)
		{
			int t=in.nextInt();
			if(t==1)
			{
				rev=(rev+1)%2;
			}
			else
			{
				int f=in.nextInt();
				String c=in.next();
				if((f==1&&rev==0)||(f==2&&rev==1))
				{
					deque.addFirst(c);
				}
				else
				{
					deque.addLast(c);
				}
			}
		}
		int m = deque.size();
			for(int i = 0 ;i < m ; i++) {
				sb.append(deque.pollFirst());
			}
		if(rev==1) { 
			sb.reverse();
			}
		
		System.out.println(sb.toString());
	}
}
	

Measured memory_bytes: 167368
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int Mod=1e9+7;
const int Maxn=1.5*1e5;

int N,M;

ll PowMod(ll a,int b) {
    ll ret=1;
    while(b) {
        if(b&1)ret=ret*a%Mod;
        a=a*a%Mod;
        b>>=1;
    }
    return ret;
}

ll f[Maxn+5];
ll inv[Maxn+5];

void Prepare() {
	f[0]=1;
	for(int i=1;i<=Maxn;i++)
	    f[i]=f[i-1]*i%Mod;
	inv[0]=1;
	inv[Maxn]=PowMod(f[Maxn],Mod-2);
	for(int i=Maxn-1;i>0;i--)
	    inv[i]=inv[i+1]*(i+1)%Mod;
}

ll F(int a,int b) {
    return f[a+b-1]*inv[a-1]%Mod*inv[b]%Mod;
}//C(a+b-1,a-1)

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&M);
	Prepare();
	int lim=sqrt(M);
	ll ans=1;
	for(int i=2;i<=lim;i++)
		if(M%i==0) {
			int cnt=0;
			while(M%i==0)
				M/=i,cnt++;
			ans=ans*F(N,cnt)%Mod;
		}
	if(M!=1)ans=ans*N%Mod;
	printf("%lld",ans);
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int x[n], y[n];
    rep(i,n) cin >> x[i] >> y[i];

    vector<ll> v1;
    vector<ll> v2;
    rep(i,n){
        v1.push_back(x[i]+y[i]);
        v2.push_back(x[i]-y[i]);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    cout << max(v1[n-1]-v1[0], v2[n-1]-v2[0]) << endl;
}

Measured memory_bytes: 8184
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int a[110];
signed main() {	
	int n,s=0,d=0,ans=inf;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		s += a[i];
	}
	rep(i, n) {
		s -= a[i];
		d += a[i];
		if (abs(s - d) < ans) {
			ans = abs(s - d);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            x1 = xy[i][0]
            y1 = xy[i][1]
            x2 = xy[j][0]
            y2 = xy[j][1]
            pq.append((x2 - x1, y2 - y1))

ans = N
for p,q in pq:
    tmp = 0
    for i in range(N):
        for j in range(N):
            if i != j:
                x1 = xy[i][0]
                y1 = xy[i][1]
                x2 = xy[j][0]
                y2 = xy[j][1]
                if x2 - x1 == p and y2 - y1 == q:
                    tmp += 1
    ans = min(ans, N - tmp)

print(ans)


Measured memory_bytes: 68568
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int ans = 0;
		for(int i=0; i<n.length(); i++){
			if(n.charAt(i)=='1') ans++;
		}
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
	int A,B,C;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	if(C-B<=0)
	{
		printf("%d",B+C);
	}
	else
	{
		if(C-B-A<=0)
		{
			printf("%d",B+C);

		}
		else
		{
			if(C-B-A<=1)
			{
				printf("%d",B+C);

			}
			else
			{
				printf("%d",2*B+A+1);

			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'



void solve(){
  vector<int> a(5);

  int ans = 0;
  forn(i, 5) {
    cin >> a[i];
    ans += ((a[i]+9)/10)*10;
  }
  
  int cur = ans;
  forn(i,5){
    if (a[i] % 10)
      setmin(ans, cur - (10 - (a[i] % 10)));
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false); 
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 




*/

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

#define int long long

signed main() {
    int n, m;
    cin >> n >> m;

    int st = (n - m) * 100;
    int y = 1;
    for(int i=0; i<m; ++i) y *= 2;

    int ans = (st + 1900 * m) * y;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256