akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????
typedef Segment Line;                               //??´???
typedef struct Circle{Point c; double r;}Circle;    //???

//????????????a????????????
double norm(Vector a){
    return a.x * a.x + a.y * a.y;
}

//????????????a?????§??????
double absolute(Vector a){
    return sqrt(norm(a));
}

//????????????a,b?????????
double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

//??????s(p1p2)???????????????p????°???±
Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

//?????¨??????l?????????????±???????
pair<Point, Point> getCrossPoints(Circle c, Line l){
    Vector pr = project(l, c.c);
    Vector e = (l.p2 - l.p1) / absolute(l.p2 - l.p1);
    double base = sqrt(c.r * c.r - norm(pr - c.c));
    return make_pair(pr + e * base, pr - e * base);
}

int main(){
    
    int cx, cy;
    double r;
    int q;
    int x1, y1, x2, y2;
    
    cin >> cx >> cy >> r >> q;
    
    Circle c = {Point(cx, cy), r};
    
    for (int i = 0; i < q; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        
        Line l = {Point(x1, y1), Point(x2, y2)};
        
        pair<Point, Point> ans = getCrossPoints(c, l);
        bool swap_flag = (ans.first.x == ans.second.x) ? ans.first.y > ans.second.y : (ans.first.x > ans.second.x);
        if(swap_flag) swap(ans.first, ans.second);
        
        printf("%.8lf %.8lf %.8lf %.8lf\n", ans.first.x, ans.first.y, ans.second.x, ans.second.y);
    }

    return 0;
}

Measured memory_bytes: 1248
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    s = S()
    if s=='ARC':    ans = 'ABC'
    else:   ans = 'ARC'
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9288
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.nextLine();
        long[] count = new long[26];
        for (char ch : a.toCharArray()) {
            count[ch - 'a']++;
        }
        long ans = (a.length() * (a.length() - 1L)) / 2L + 1L;
        ans -= LongStream.of(count).map(v -> (v * (v - 1L)) / 2L).sum();
        System.out.println(ans);
    }
}

Measured memory_bytes: 28888
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=1e18,MOD=1e9+7,MAX=1e6+2;



int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    string s,t;
    cin>>s>>t;
    int res=1e9;
    lp(i,0,sz(s)){
        if(i+sz(t)<=sz(s)){
            int cnt=0;
            lp(j,i,i+sz(t)){
                cnt+=t[j-i]!=s[j];
            }
            res=min(res,cnt);
        }
    }
    cout<<res;
}

Measured memory_bytes: 3656
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N,Q=rl()
S=input()
L,R=[0]*Q,[0]*Q
for i in range(Q):
    L[i],R[i] = rl()
s = [0]*(N+2)
ss = [0]*(N+2)
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        s[i] = 1
        s[i+1] = 1

ss[0] = s[0]
for i in range(1,N):
    ss[i] = ss[i-1] + s[i]

for i in range(Q):
    l,r = L[i],R[i]
    l -= 1
    r -= 1
    res = (ss[r] - ss[l-1])//2
    if s[r]==1 and s[l]==1 and S[r]=='A' and S[l]=='C':
        res -= 1
    print(res)

Measured memory_bytes: 16644
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> h(n),dp(n+1);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  dp[0]=INT_MIN;
  dp[1]=0;
  for (int i = 2; i <= n; i++){
    if (i != 2){
      dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
    }else{
      dp[i] = abs(h[i-1]-h[i-2]);
    }
  }
  cout << dp[n]<< '\n';
  return 0;
}

Measured memory_bytes: 4000
n = input()
p = input().split()

i_cnt = 1
current_max = {'idx': 0, 'value': 0}

for j in range(len(p)):
  for i in range(current_max['idx'], j):
    current_max['idx'] = i
    if current_max['value'] <= int(p[i]): 
      current_max['value'] = int(p[i])
    if int(p[i]) < int(p[j]):
      break
    if j-1 == i:
      i_cnt += 1

print(i_cnt)

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> p(n);
    for (auto &&x : p) cin >> x;
    sort(p.begin(), p.end());
    cout << accumulate(p.begin(), p.end(), 0) - 0.5 * p.back() << endl;

    return 0;
}


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

void die(int x, int y) {
  cout << x << " " << y;
  exit(0);
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 1; i < n; ++i)
    if (s[i] == s[i - 1])
      die(i, i + 1);
    else if (i - 2 >= 0 && s[i - 2] == s[i])
      die(i - 1, i + 1);
  cout << "-1 -1";
}

Measured memory_bytes: 512
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

V,E=get_i
ind=array(V,0)
g=array(V)
E.times do|i|
  s,t=get_i
  g[s]=[] if g[s].nil?
  g[s].push(t)
  ind[t]+=1
end

def tps(g,ind)
  ans=[]
  queue=[]
  V.times do|i|
    queue.push(i) if ind[i].zero?
  end
  until queue==[]
      curr=queue.shift
      ans.push(curr)
      next if g[curr].nil?
      g[curr].each do|v|
          ind[v]-=1
          queue.push(v) if ind[v].zero?
      end
  end
  return ans
end
puts tps(g,ind).join("\n")


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

int main() {
ll num[3];
REP(i,3){
  cin>>num[i];
}
int k;
cin>>k;
sort(num,num+3);
for (int i = 0; i < k; i++)
{
  /* code */
  num[2]=num[2]*2;
}
cout<<num[0]+num[1]+num[2]<<endl;

}

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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    LL X;
    cin >> X;

    LL cur = 100;
    int res = 0;

    while (cur < X) {
        cur = (LL)(cur * 1.01);
        res++;
    }

    cout << res << endl;

}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
int a,b,f[maxn],k,s[maxn],dp2[maxn];
map<int,int,greater<int>> dp;
unordered_map<int,int> fre;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int mul(int a,int b){
    return (int)(((long long)a*b)%mod);
}

int main(){
    int n;
    scanf("%d%d",&n,&k);
    int cc=n,pt=1;
    while(cc){
        int x=n/cc;
        dp[x]=(n/x-n/(x+1));
        fre[x]=dp[x];
        cc=(n/(x+1));
    }
    int sum=0;
    int last=-1;
    pt=0;
    for(auto it:dp){
        s[pt]=it.second;
        f[pt]=fre[it.first];
        pt++;
    }

    while(k--){
        last=-1;
    for(int i=0;i<pt;i++){
        dp2[i]=(last==-1)?s[i]:add(last,s[i]);
        last=dp2[i];
    }
    for(int i=0;i<pt;i++){
        s[i]=mul(f[i],dp2[pt-i-1]);
    }
    /**
    for(auto it:dp){
        dp2[it.first]=(last==-1)?it.second:add(last,it.second);
        last=dp2[it.first];
    }
    for(auto it:dp){
        dp[it.first]=mul(fre[it.first],dp2[n/(it.first)]);
    }
    **/
    }
    printf("%d\n",s[0]);
}


Measured memory_bytes: 6948
#include <cstdio>
using namespace std;

int main ()
{
  int N;
  int A;
  int B;
  int C;
  scanf("%d", &N);
  scanf("%d", &A);
  scanf("%d", &B);
  C = N * A;
  if (C > B) {
    printf("%d\n", B);
  } else {
    printf("%d\n", C);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int d,e,f;
  d = a.size();
  e = b.size();
  f = c.size();
  int g = 0,h = 0,j = 0;
  char top = 'a';
  char ans;
  for(int i = 0;i<400;i++){
    if(top=='a'){
      if(g==d){
        ans = 'A';
        break;
      }
      top = a.at(g);
      g++;
    }
    else if(top=='b'){
      if(h==e){
        ans = 'B';
        break;
      }
      top = b.at(h);
      h++;
    }
    else{
      if(j==f){
        ans = 'C';
        break;
      }
      top = c.at(j);
      j++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

vvll g(1e5+100);
vll vis(1e5+100,0),dis(1e5+100,1e6),par(1e5+100,1);

void dfs(ll n, ll p=-1){
    // trace(n,g[n]);
    vis[n]=1;
    for(ll x:g[n]){
        if(x!=p){
            if(!vis[x]) dfs(x,n);
        }
    }
}

void solve(){
    ll n,m;cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    // dfs(1);
    
    dis[1]=0;
    queue<ll> qu;
    qu.push(1);
    vis[1]=1;
    while(qu.size()>0){
        ll nd=qu.front();qu.pop();
        for(ll x:g[nd]){
            if(!vis[x]){
                qu.push(x);
                par[x]=nd;
                vis[x]=1;
            }
        }
    }

    ll cnt=0;
    for(ll i=1;i<=n;i++){
        if(vis[i]){
            cnt++;
        }
    }
    if(cnt!=n){
        cout<<"No\n";
        return;
    }

    cout<<"Yes\n";
    for(ll i=2;i<=n;i++) cout<<par[i]<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 14588
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int N,A,B;
  cin>>N;
  if (N==1){
    cout<<"Hello World"<<endl;
  }
  else{
    cin>>A>>B;
    cout<<A+B<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
result_L = []
yoryoku_L = [0]

for val in range(n+1):
    yoryoku = yoryoku_L[val] + b[val] - a[val]

    if yoryoku >= 0:
        result = a[val]

        if a[val] - yoryoku_L[val] >= 0:
            yoryoku_L.append(yoryoku)
        else:
            yoryoku_L.append(b[val])

        result_L.append(result)
    else:
        result = b[val] + yoryoku_L[val]
        yoryoku_L.append(0)
        result_L.append(result)


print(sum(result_L))


Measured memory_bytes: 18624
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
    {
        puts("GREATER");
        return 0;
    }
    if (a.size() < b.size())
    {
        puts("LESS");
        return 0;
    }

    for (int i = 0; i < a.size(); ++i)
    {
        if (a[i] > b[i])
        {
            puts("GREATER");
            return 0;
        }
        if (a[i] < b[i])
        {
            puts("LESS");
            return 0;
        }
    }
    puts("EQUAL");
}

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

int main() {
  int n,cnt=0,ans=0,current=0;
  cin >> n;
  vector<long> a(n);
  for(int i=0 ;i<n ;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0 ;i<n ;i++){
    if(a[i] != current){
      if(cnt < current){
        ans += cnt;
      }else{
        ans += cnt - current;
      }
      cnt = 1;
      current = a[i];
    }else{
      cnt++;
    }
  }
  if(cnt < current){
    ans += cnt;
  }else{
    ans += cnt - current;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
// 解き直し.
// ABC 143解説.
// https://img.atcoder.jp/abc143/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int MAX = 321123;
LL A[MAX], C[MAX], D[MAX], DCUM[MAX], KDCUM[MAX], f[MAX];

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%lld", &A[i]), C[A[i]]++;
    for(int i = 1; i <= N; i++) D[C[i]]++;
    
    // 2. 解説通り(累積和).
    for(int i = 1; i <= N; i++) DCUM[i] = DCUM[i - 1] + D[i];
    for(int i = 1; i <= N; i++) KDCUM[i] = KDCUM[i - 1] + (LL)i * D[i];
    
    // 3. f(X) の 計算.
    // -> lower_bound を 使用する都合上, index を ずらした.
    for(int x = 0; x < N; x++){
        f[x] = KDCUM[x];
        f[x] += (LL)(x + 1) * (DCUM[N] - DCUM[x]);
        f[x] /= (x + 1);
    }
    // for(int i = 0; i <= N; i++) printf("%lld ", DCUM[i]);
    // printf("\n");
    // for(int i = 0; i <= N; i++) printf("%lld ", KDCUM[i]);
    // printf("\n");
    
    // 4. f(X) の sort.
    // -> lower_bound を 使用する都合上, 昇順sort した.
    sort(f, f + N);
    // for(int i = 0; i < N; i++) printf("%lld ", f[i]);
    // printf("\n");
    
    // 5. N個の整数を出力.
    for(int t = 1; t <= N; t++){
        int at = lower_bound(f, f + N, t) - f;
        printf("%d\n", N - at);
    }
    return 0;
    
}

Measured memory_bytes: 15744
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    let s: String = read();
    let vec: Vec<char> = s.chars().collect();
    for i in 0..(s.len() - 8) {
        print!("{}", vec[i])
    }
}


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

int main(){
  int n,b[6]={};
  cin >> n;
  for(int i = 0; i < n; i++){
    double h;
    cin >> h;
    if( h < 165 ) b[0]++;
    if( 165 <= h && h < 170 ) b[1]++;
    if( 170 <= h && h < 175 ) b[2]++;
    if( 175 <= h && h < 180 ) b[3]++;
    if( 180 <= h && h < 185 ) b[4]++;
    if( h >= 185 ) b[5]++;
  }
  for(int i = 0; i < 6; i++){
    cout << i+1 << ":";
    for(int j = 0; j < b[i]; j++){
      cout << "*";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
//use readint!
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
#define ll long long
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline int readint(){
    int x=0;
    int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
long long a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	long long t=max(a,max(b,c));
	long long s=a+b+c;
	s-=t;
	for(int i=0;i<k;i++) t*=2;
	cout<<s+t<<endl;
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

ll ma[101010];

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

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    ll ans = 0;
    rep(i, N) {
        if (h[i] > ma[i]) {
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 4880
import sys
def input():
    return sys.stdin.readline()[:-1]
from heapq import *
from collections import defaultdict
N, K = map(int, input().split())
d_t = [list(map(int, input().split()))[::-1] for i in range(N)]
d_t.sort(reverse = 1)
f, c = 0, 0
dic = defaultdict(lambda : 0)
take = []
for d, t in d_t[:K]:
    f += d
    if dic[t] == 0:
        c += 1
    dic[t] += 1
    heappush(take, [d, t])
ans = f + c * c
rest = [[-d, t] for d, t in d_t[K:]]
heapify(rest)
while take:
    d, t = heappop(take)
    if dic[t] == 1: continue
    dic[t] -= 1
    f -= d
    while rest:
        rd, rt = heappop(rest)
        if dic[rt] == 0:
            dic[rt] = 1
            c += 1
            f -= rd
            ans = max(ans, f + c * c)
            break
print(ans)


Measured memory_bytes: 35844
n,k=map(int,input().split())
binlist=[]
for j in range(2**n):
    binlist.append(format(j,"0%ib"%n))
lista=[]
for i in range(k):
    a=list(map(int,input().split()))
    lista.append(a)
modlist=list(map(int,input().split()))
ans=0
for some in binlist:
    flag=True
    for j in range(k):
        checker=lista[j][1:]
        p=modlist[j]
        count=0
        for nums in checker:
            if some[nums-1]=="1":
                count+=1

        if count%2!=p:
            flag=False
            break
    if flag:
        ans+=1     
print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		char cur = S.charAt(0);
		int len = 1;
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 1 ; i < S.length() ; ++i) {
			char ci = S.charAt(i);
			if(cur != ci) {
				list.add(len);
				len = 0;
			}
			++len;
			cur = ci;
		}
		list.add(len);
		int H = 0;
		for(int i : list) {
			H += i - 1;
		}
//		System.out.println(list);
		int ret = Math.min(N - 1, H + 2 * K);
		System.out.println(ret);
		// R L R L R L
		// LLLRRL
	}
}


Measured memory_bytes: 26068
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
        int i;
        char c[3];
        string blood[4] = {"A", "B", "AB", "O"};
        int cnt[4] = {0};

        while (scanf("%d%*[,]%s%*[\n]", &i, c) != EOF) {
                int n;
                for (n = 0; strcmp(c, blood[n].c_str()); n++)
                        ;
                cnt[n]++;
        }

        for (int n = 0; n < 4; n++) {
                cout << cnt[n] << endl;
        }

        return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int d[10000];
int l[10000];
int n,x;
int main()
{
	cin>>n>>x;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
		d[i]=d[i-1]+l[i-1];
		if(d[i]<=x)
		{
			sum++;
		}
	}
	if(d[n-1]+l[n-1]<=x)
	{
		sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
X,Y,A,B,C=map(int,input().split())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
R=list(map(int, input().split()))
P=sorted(P)[::-1]
Q=sorted(Q)[::-1]
R=sorted(R)

if A+B+C==X+Y:
  print(sum(P)+sum(Q)+sum(R))
  exit()
if X<A:
  P=P[:X]
if Y<B:
  Q=Q[:Y]
l=0
if X>A:
  l+=(X-A)
if Y>B:
  l+=(Y-B)
h=C-l
S=sorted(P+Q+R[:h])[::-1]
ans=sum(S[:X+Y])+sum(R[h:])
print(ans)

Measured memory_bytes: 119208
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int n;
  string s;
  while (cin >> n >> s ){
    bool cnt[26];
    int ans = 0;
    REP(i,26){
      cnt[i] = false;
    }
    REP(i,n){
      int c = 0;
      int idx = s[i] - 'a';
      cnt[idx] = true;
      bool cnt2[26];
      REP(j,26){
	cnt2[j] = cnt[j];
      }
      FOR(j,i+1,n){
	int idx2 = s[j] - 'a';
	if(cnt2[idx2]){
	  c++;
	  cnt2[idx2] = false;
	}
      }
      ans = max(ans,c);
    }
    
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N 100
using namespace std;

void bubbleSort(int n, int A[]) {
	bool flag = 1;
	int count = 0;
	while (flag) {
		flag = 0;
		for (int i = n - 1; i > 0; i--) {
			int j = i - 1;
			if (A[i] < A[j]) {
				int t = A[i];
				A[i] = A[j];
				A[j] = t;
				flag = 1;
				count++;
			}
			/*cout << "[" << i << "]" << " ";
			for (int k = 0; k < n; k++) {
				cout << A[k] << " ";
			}
			cout << endl;*/
		}
	}
	for (int i = 0; i < n; i++) {
	    if(i != n-1) cout << A[i] << " ";
	    else cout << A[i];
	}
	cout << endl << count << endl;
}

int main() {
	int n;
	int A[N];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	bubbleSort(n, A);

}


Measured memory_bytes: 3088
import heapq
def dijkstra_heap():
    used = [-1] * (2451*n)
    edgelist=[]
    heapq.heappush(edgelist,[0,ss])
    while len(edgelist):
        #print(len(edgelist))
        minedge = heapq.heappop(edgelist)
        if used[minedge[1]]!=-1:
            continue
        v = minedge[1]
        kai=minedge[0]
        mai=v%2451
        used[v] = kai
        for e in edge[v//2451]:
            if mai-e[1]>=0:
                sss=mai-e[1]
                if used[e[2]*2451+sss]==-1:
                    heapq.heappush(edgelist,[e[0]+kai,e[2]*2451+sss])
        if mai+cd[v//2451][0]<=2450:
            if used[v+cd[v//2451][0]]==-1:
                heapq.heappush(edgelist,[kai+cd[v//2451][1],v+cd[v//2451][0]])
    return used

################################
n,m,ss = map(int,input().split())
ss=min(2450,ss)
edge = [[] for i in range(n)]

for i in range(m):
    x,y,a,b = map(int,input().split())
    edge[x-1].append([b,a,y-1])
    edge[y-1].append([b,a,x-1])
cd=[]
for i in range(n):
    cd.append(list(map(int,input().split())))
pp=dijkstra_heap()
for i in range(1,n):
    ans=10**20
    for j in range(2451):
        if pp[i*2451+j]!=-1:
            ans=min(ans,pp[i*2451+j])
    print(ans)

Measured memory_bytes: 107736
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami() - 1;
		int m = saori.saori_hayami() - 1;
		System.out.println(n*m);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int s = h1*60+m1, t = h2*60+m2;
  int ans = t-s-k;
  cout << ans << endl;
}


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

int main() {
 string N;
 cin >> N;
 string ans;
 if(N.at(0)==N.at(1) || N.at(1)==N.at(2) || N.at(2)==N.at(3)){
   ans = "Bad";
 } else{
   ans = "Good";
 }
 cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// ??°?????????????¢??????????????????°??????
int main()
{
  ll N, Q, S, T; cin >> N >> Q >> S >> T;
  ll A[N+1]; FOR(i,0,N+1) cin >> A[i];
  ll temp = A[0];
  FOR(i,1,N+1) temp += ((A[i] - A[i-1]) >= 0 ? -S : T) * abs(A[i] - A[i-1]);
  ll d[N]; CLR(d); // ???????????????????????????(i??¨i+1???)i????????????????????????
  FOR(i,0,Q) {
    int l, r, x; cin >> l >> r >> x;
    ll prel = ((A[l] + d[l-1] - A[l-1]) >= 0 ? -S : T) * abs(A[l] + d[l-1] - A[l-1]);
    d[l-1] += x;
    ll aftl = ((A[l] + d[l-1] - A[l-1]) >= 0 ? -S : T) * abs(A[l] + d[l-1] - A[l-1]);
    temp += aftl - prel;
    if(r < N) {
      ll prer = ((A[r+1] + d[r] - A[r]) >= 0 ? -S : T) * abs(A[r+1] + d[r] - A[r]);
      d[r] -= x;
      ll aftr = ((A[r+1] + d[r] - A[r]) >= 0 ? -S : T) * abs(A[r+1] + d[r] - A[r]);
      temp += aftr - prer;
    }
    cout << temp << endl;
  }
  return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

template<class T>
vector<pair<T,int>> run_length_encoding(const vector<T>& a){
	vector<pair<T,int>> res;
	int n=a.size(),pre=0;
	rep(i,n) if(i==n-1 || a[i]!=a[i+1]) res.emplace_back(a[i],i-pre+1), pre=i+1;
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	auto r=run_length_encoding(a);
	int m=r.size();

	vector<mint> dp(m+1);
	vector<int> pre(200000,-1);
	dp[0]=1;
	rep(i,m){
		int x=r[i].first;
		dp[i+1]=dp[i];
		if(pre[x]!=-1) dp[i+1]+=dp[pre[x]+1];
		pre[x]=i;
	}
	cout<<dp[m]<<'\n';

	return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

vector<int> comdiv(int x){
    vector<int> res;
    stack<int> big;
    for(int i = 1; i*i <= x; i++){
        if(x%i == 0){
            res.push_back(i);
            big.push(x/i);
        } 
    }
    while(!big.empty()){
        res.push_back(big.top());
        big.pop();
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> can = comdiv(m);
    int ans = 0;
    for(int i = 0; i < can.size(); i++){
        if(can[i] <= m/n) ans = can[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 5e5+5;

int mod = 1e9+7;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}


signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        int arr[n];
        rep(i,0,n)
        cin>>arr[i];
        int pre[n];
        pre[0] = arr[0];
        rep(i,1,n)
        pre[i] = min(pre[i-1],arr[i]);
        int ct = 0;
        rep(i,0,n)
        {
            if(arr[i]<=pre[i])
                ct++;
        }
        cout<<ct<<el;

    }


        return 0;
    }


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NX = ReadLineParseIntArray();
        int[] L = ReadLineParseIntArray();
        int pos = 0;
        int count = 1;
        for(int i = 0; i < NX[0]; i++)
        {
            pos += L[i];
            if (pos > NX[1]) break;
            count++;
        }
        WriteLine(count);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13396
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;

int main(){ 
	speedhack()
	int n,d;
	cin >> n >> d;
	int num = 0;
	int cnt = 0;
	while(n > num){
		num += 2*d+1;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
nums = list(map(int, input().split()))
counts = [0 for _ in range(N+1)]
for num in nums:
  counts[num] += 1
combination = 0
for count in counts:
  if count >= 2:
    combination += (count*(count-1))//2
for num in nums:
  print(combination-counts[num]+1)


Measured memory_bytes: 104768
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    int t[n + 1][n + 1];
    rep(i, n) rep(j, n) cin >> t[i][j];
    rep(i, n) {
      int c = 0, d = 0;
      rep(j, n) c += t[i][j], d += t[j][i];
      t[i][n] = c;
      t[n][i] = d;
    }
    int e = 0;
    rep(i, n) e += t[n][i];
    t[n][n] = e;
    rep(i, n + 1) {
      rep(j, n + 1) cout << setw(5) << t[i][j];
      cout << endl;
    }
  }
}

Measured memory_bytes: 2996
import numpy as np
n,t = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l.sort()
dp = np.array([0]*t)
ans = 0
for a,b in l:
    ans = max(ans,dp[-1]+b)
    dp[a:] = np.maximum(dp[a:],dp[:-a]+b)
    
    
print(max(ans,dp[-1]))

Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int MOD=1000000007;
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  int a=0,b=0,c=0;
  long ans=1;
  for(int i=0;i<N;i++){
    int m=0;
    if(A[i]==a)m++;
    if(A[i]==b)m++;
    if(A[i]==c)m++;
    ans=(ans*m)%MOD;
    if(A[i]==a)a++;
    else if(A[i]==b)b++;
    else if(A[i]==c)c++;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3788
//abc105_c.cpp
//Sat Aug 18 12:15:36 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
	string ans;

	if (n==0){
		ans = "0";
	}

	while (n!=0){
		if (n%2!=0){
			ans = "1"+ans;
			n = n-1;
		}else {
			ans = "0"+ans;
		}
		n = n/(-2);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace _153232
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string s = Console.ReadLine();
            int b = int.Parse(a);
            string A;
            if (b >= 3200) { A = s; }
            else { A = "red"; }
            Console.WriteLine(A);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 1000 - (n % 1000);
    ans = ans == 1000 ? 0 : ans;
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 35624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

const int mod = (int) 1e9 + 7;

int main() {
	int n, k, a, b;
	cin >> n >> k;

	vector<vector<int>> graph(n, vector<int>());
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--;
		b--;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
	}

	vector<int> num_known_connect(n, 0);

	queue<int> que;
	que.push(0);
	long long ans = k;


	while(!que.empty()) {
		auto x = que.front();
		que.pop();

		for (auto y: graph[x]) {

			// printf("xy %d %d\n", x, y);
			if (num_known_connect[y] > 0) {
				continue;
			}

			int tmp = num_known_connect[x] + 1;
			if (tmp >= k) {
				cout << 0 << endl;
				return 0;
			}

			ans = ans * (k - tmp) % mod;

			num_known_connect[x]++;
			num_known_connect[y]++;
			que.push(y);
		}
	}

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


Measured memory_bytes: 6904
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
 
using ld = double;
using P = complex<ld>;
 
const ld eps = 1e-11;
 
ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }
 
 
template <class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;
 
    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }
 
    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated
 
    iter ps = left;
    using circle = std::pair<P, ld>;
 
    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };
 
    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld)2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };
 
    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };
 
    circle c = make_circle_2(ps[0], ps[1]);
 
    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; ++i) {
        double x, y;
        cin >> x >> y;
        v[i] = { x, y };
    }
    cout << setprecision(14) << sqrt(min_ball(v.begin(), v.end()).second) << '\n';
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, m, x) = io.StdIn.readLine().split(" ").map(_.toInt)
  val costPos = io.StdIn.readLine().split(" ").map(_.toInt)
  val costL = costPos.count(p => p < x)
  println(math.min(costL,m-costL))
}

Measured memory_bytes: 25416
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define endl "\n"
#define BRISK ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
signed main()
{
    BRISK;
    int n,a,b;
    cin>>n>>a>>b;
    int x=n/(a+b);
    int rem=n%(a+b);
    int red=a*x;
    if(rem<a)red+=rem;
    else red+=a;
    cout<<red;
}

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

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

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

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

    int count = 0;
    for(int i=0; i<n; i++){
        int sum = c;
        for(int j=0; j<m; j++){
            sum += a[i][j] * b[j];
        }
        if(sum > 0) count += 1;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384