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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

vi arr;
void in(){
    rep(i,0,5) arr.push_back(input());
    sort(all(arr));
}

void solve(){

    int ans = 0;
    int hoge = 0;
    rep(i,0,5){
        int t = ceil(arr[i], 10) * 10;
        ans += t;
        if(arr[i] % 10 != 0) chmax(hoge, 10 - (arr[i] % 10));
    }
    print(ans -= hoge);
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s, t;
	cin >> s;
	REP(i, s.size()){
		if(s[i] == '0') t.pb('0');
		elif(s[i] == '1') t.pb('1');
		else{
			if(!t.empty()) t.pop_back();
		}
	}
	cout << t << endl;

	rtn 0;
}

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

#define MAX 100

int main() {

  while(1) {
    int a=-1, b;
    int V = 0;
    int edge[MAX]={};
    while(cin>>a>>b&&(a+b)) {
      V = max(V, max(a, b));
      a--, b--;
      edge[a]++, edge[b]++;
    }
    
    if(a==-1) break;
    
    if( edge[0]&1 || edge[1]&1 ) {
      for( int i=2; i<V; i++ ) if( edge[i] % 2 == 1 ) goto NG;
      cout << "OK" << endl;
      goto Fin;
    }
  NG:
    cout << "NG" << endl;
  Fin:;
  }
  
  return 0;
}

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

int main() {
  char b;
  cin >> b;
  vector<char> x = {'A', 'C', 'G', 'T'};
  vector<char> y = {'T', 'G', 'C', 'A'};
  for(int i = 0; i < 4; i++){
    if(b == x.at(i)){
      cout << y.at(i) << endl;
      break;
    }
  }
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N;
    std::cin >> N;

    string ans = "YES";
    int A_cnt = 1, un_cnt = 1;
    REP(i, N) {
        string S;
        std::cin >> S;
        A_cnt  += S == "A" ? 1: -1;
        un_cnt += S == "Un" ? 1: -1;
        if(A_cnt < un_cnt) {
            ans = "NO";
            break;
        }
    }

    std::cout << ((A_cnt == un_cnt) ? ans : "NO") << std::endl;

    return 0;
}



Measured memory_bytes: 3220
#define _USE_MATH_DEFINES
     
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

void solution() {
    int n, x;
    cin >> x >> n;
    map <int, int> M;
    while (n--) {
        int r;
        cin >> r;
        M[r]++;
    }

    int ans = -1000;
    for (int j = -1000; j <= 1000; j++) {
        if (M[j]) {
            continue;
        }
        int dif = abs(j - x);
        if (dif < abs(ans - x)) {
            ans = j;
        }
    }
    cout << ans << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);
           
    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

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

typedef pair<double,string> pa;
vector<pa> vec;
bool my (pa i,pa j) { return (i.first==j.first?i.second>j.second:i.first<j.first); }
int main(){
    int n;
    while(cin >>  n && n){
        while(n--){
            string na;
            double p,a,b,c,d,e,f,s,m;
            cin>>na>>p>>a>>b>>c>>d>>e>>f>>s>>m;
            vec.push_back(pa((f*s*m-p)/(a+b+c+(d+e)*m),na));
        }
        sort(vec.begin(),vec.end(),my);
        for(long long i=vec.size()-1;i>=0;i--){
            cout<<vec[i].second<<endl;
        }
        cout<<"#"<<endl;
        vec.clear();
    }
}

Measured memory_bytes: 1256
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)

Measured memory_bytes: 25716
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    n = 1
    for a in A:
        if a == n:
            n += 1
    if n == 1:
        return -1
    return N - n + 1


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  int N;
  ll A[MAX_N];

  int cnt_nega = 0;
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> A[i];
    if(A[i] < 0) ++cnt_nega;
    A[i] = std::abs(A[i]);
  }

  if(cnt_nega % 2 != 0) {
    std::sort(A, A + N);
    A[0] = - A[0];
  }

  ll ans = 0;
  for(int i = 0; i < N; ++i) {
    ans += A[i];
  }

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

Measured memory_bytes: 1024
n = input()
hlist = list(map(int, input().split(' ')))
for i in range(len(hlist)-1):
    if hlist[i] >= hlist[i + 1]:
        hlist[i] = 1
    else:
        hlist[i] = 0
hlist[len(hlist)-1] = 0
hlist.reverse()
for i in range(len(hlist)-1):
    if hlist[i + 1] == 1:
        hlist[i + 1] += hlist[i]

print(max(hlist))


Measured memory_bytes: 14224
#include <stdio.h>
#include <stdbool.h>

int main()
{
    bool found;
    int row, col, i, j, k;
    scanf("%d %d", &row, &col);
    char grid[row][col+1];
    for(i=0; i<row; i++)
    {
        scanf("%s", grid[i]);
        found = true;
        for(j=0; j<col; j++)
        {
            if(grid[i][j]!='.')
            {
                found = false;
                break;
            }
        }
        if(found)
        {
            for(j=0; j<col; j++)
            {
                grid[i][j] = '-';
            }
        }
    }
    for(j=0; j<col+1; j++)
    {
        found = true;
        for(i=0; i<row; i++)
        {
            if(grid[i][j]=='.'||grid[i][j]=='-')
            {
                continue;
            }
            else
            {
                found = false;
                break;
            }
        }
        if(found)
        {
            for(i=0; i<row; i++)
            {
                grid[i][j] = '-';
            }
        }
    }
    for(i=0; i<row; i++)
    {
        found = false;
        for(j=0; j<col+1; j++)
        {
            if(grid[i][j]!='-'&&grid[i][j] != '\0')
            {
                printf("%c", grid[i][j]);
                if(grid[i][j]=='.'||grid[i][j]=='#')
                {
                    found = true;
                }
            }
        }
        if(found)
        {
            printf("\n");
        }
    }
    return 0;
}


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

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


  if(n == 1){
    cout << m << endl;
    return 0;
  }

  int ans = 1;
  for(int i = 2;i <= m-i*(n-1);i++){
    int tmp = m - i*(n-1);
    if(tmp % i == 0){
      ans = i;
    }
  }

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


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int s;
    double w, h;
    char dot;
    while (cin >> s >> dot >> w >> dot >> h)
    {
        double bmi = w / (h * h);
        if (bmi >= 25)
            OP(s);
    }
    return 0;
}


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

int main(){
    string S, T;

    cin >> S >> T;
    int a= S.size();
    int b= T.size();
    int tmp=b;
    for(int i=0; i<=a-b; i++){
        int sum=0;
        for(int j=0; j<b; j++){
            if(S[i+j]!=T[j]){
                sum++;
            }
        }
        tmp= min(tmp, sum);
    }
    cout<< tmp << endl;
    return 0;
}

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

int main(){
  int n, m, kk;
  const int INF = 1 << 28;

  while(cin >> n >> m){
    if((n|m) == 0) break;

    vector<vector<vector<int> > > score(2, vector<vector<int> >(m, vector<int>(m, INF)));
    int a, b, cost, time;

    for(int i=0; i<n; i++){
      cin >> a >> b >> cost >> time;
      a--;
      b--;
      score[0][a][b] = score[0][b][a] = cost;
      score[1][a][b] = score[1][b][a] = time;
    }

    for (int k = 0; k < m; ++k) {
      for (int i = 0; i < m; ++i) {
	for (int j = 0; j < m; ++j) {
	  score[0][i][j] = min(score[0][i][j], score[0][i][k]+score[0][k][j]);
	  score[1][i][j] = min(score[1][i][j], score[1][i][k]+score[1][k][j]);
	}
      }
    }

    int p, q, r;

    cin >> kk;
    while(kk--){
      cin >> p >> q >> r; 
      --q;
      --p;
      cout << score[r][p][q] << endl;
    }
  }
    return 0;
}

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

int dp[223456][3];
bool used[223445][3];
int n, a[312312], b[312312], c[312312];
int mx;
vector <int> v[5];
int mn = 50102031;

string s;
int main() {
   cin >> n;
   cin >> s;
   if(n >= 3200) cout << s;
   else cout << "red";
}



Measured memory_bytes: 2304
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

i64 a[100010];

signed main()
{
  int N, K;
  cin >> N >> K;

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

  int l = 0;
  int r = K-1;

  i64 ans = LINF;
  for (; r < N; ++l, ++r) {
    i64 lx = a[l];
    i64 rx = a[r];

    if (rx <= 0) {
      chmin(ans, abs(lx));
    }
    else if (0 <= lx) {
      chmin(ans, abs(rx));
    }
    else {
      if (abs(lx) < abs(rx))
        chmin(ans, 2 * abs(lx) + abs(rx));
      else
        chmin(ans, abs(lx) + 2 * abs(rx));
    }
  }

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



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

vector<pair<int, int>> v[100001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int p, y;
        cin >> p >> y;
        v[p].emplace_back(y, i);
    }
    vector<pair<int, ll>> sol;
    for (int i = 1; i <= n; ++i)
    {
        sort(all(v[i]));
        for (int j = 0; j < v[i].size(); ++j)
        {
            int a, b;
            tie(a, b) = v[i][j];
            sol.emplace_back(b, i * 1000000ll + j + 1);
        }
    }
    sort(all(sol));
    for (auto p : sol)
        cout << setw(12) << setfill('0') << p.second << '\n';
}


Measured memory_bytes: 8688
use std::io;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    buf.trim().to_string()
}

fn read_i32() -> i32 {
    read_line().parse().expect("")
}

fn read_vi32() -> Vec<i32> {
    read_line().split(' ').into_iter()
        .map(|w| w.parse().expect(""))
        .collect()
}

fn main() {
    let tmp = read_vi32();
    let n = tmp[0];
    let m = tmp[1];
    let q = tmp[2];

    let mut arr = vec![0; n as usize];

    let mut va = vec![];
    let mut vb = vec![];
    let mut vc = vec![];
    let mut vd = vec![];
    for i in 0..q {
        if let &[a, b, c, d] = &read_vi32()[..] {
            va.push(a-1);
            vb.push(b-1);
            vc.push(c);
            vd.push(d);
        }
    }

    let mut i = 0;
    let mut ans = 0;
    loop {
        if i == -1 {
            break;
        } else if i == n {
            let mut tmp = 0;
            for j in 0..va.len() {
                if arr[vb[j] as usize] - arr[va[j] as usize] == vc[j] {
                    tmp += vd[j];
                }
            }

            if ans < tmp {
                ans = tmp;
            }
            
            i -= 1;
        } else if arr[i as usize] == m {
            arr[i as usize] = 0;
            i -= 1;
        } else if i >= 1 && arr[i as usize] < arr[i as usize - 1] {
            arr[i as usize] = arr[i as usize - 1];
            i += 1;
        } else {
            arr[i as usize] += 1;
            i += 1;
        }
    }

    println!("{}", ans);
}


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

int z , p , q , w ;

deque<int>vc,cv;

int main( ) {

    int n ;
    cin >> n ;
    int a[n] ;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a[i] ;
    }
    sort(a,a+n);
    for(int i = 1 ; i < n ; i ++ ){
        if(a[i]==a[i-1]){
            cout<<"NO"<<endl;
            return 0 ;
        }
    }
    cout<<"YES"<<endl;
    return 0;

}



Measured memory_bytes: 1152
#include "stdio.h"

int main(void)
{
    int x[5];

    int i;
    for(i=0;i<=4;i++)
    {
        scanf("%d",&x[i]);
    }

    for(i=0;i<=4;i++)
    {
        if(x[i]==0)
        {
            printf("%d",i+1);
        }
    }
    return 0;
}

Measured memory_bytes: 1724
def piyo():
    hoge = list(int(i) for i in input().split())  
    n = int(input())
    m = hoge.index(max(hoge))
    for _ in range(n):
        hoge[m] = hoge[m]*2
    print(sum(hoge))
        
if __name__ == '__main__':
    piyo()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int n;
    char buf[30];

    fgets(buf, sizeof(buf),stdin);
    n = atoi(buf);
    if (n>= 1 && n <= 10){
        int result = n + (n*n) + (n * n * n);
        printf("%d\n",result);
    }
    else
    {
        printf("正しい値を入力してください:1以上10以下");
    }
   }

Measured memory_bytes: 1680
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n; cin>>n;
  ll ans=MMM;
  for(ll i=1;i*i<=n;i++){
  if(n%i!=0)continue;
    ll a=n/i;
    ans=min(ans,(a-1)+(i-1));
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
array = list(map(int,input().split()))
if len(set(array)) == 1:
    print(n//2)
    exit()
gu = []
ki = []
for i in range(n):
    if i % 2 == 0:
        gu.append(array[i])
    else:
        ki.append(array[i])
gu_c = Counter(gu)
ki_c = Counter(ki)
if gu_c.most_common()[0][0] != ki_c.most_common()[0][0]:
    print(n-(gu_c.most_common()[0][1]+ki_c.most_common()[0][1]))
elif gu_c.most_common()[0][1] < ki_c.most_common()[0][1]:
    print(n-(gu_c.most_common()[1][1]+ki_c.most_common()[0][1]))
elif gu_c.most_common()[0][1] > ki_c.most_common()[0][1]:
    print(n-(gu_c.most_common()[0][1]+ki_c.most_common()[1][1]))
else:
    print(n-(gu_c.most_common()[0][1]+max(gu_c.most_common()[1][1],ki_c.most_common()[1][1])))

Measured memory_bytes: 20572
N, M = map(int, input().split())

e_IN = [[] for _ in range(N+1)]
e_OUT = [[] for _ in range(N+1)]

for _ in range(M):
    l, r, d = map(int, input().split())
    e_OUT[l].append((r, d))
    e_IN[r].append((l, d))

posx = [-1] * (N + 1)


def dfs(v):
    #　0<=x<=10**9に注意
    node = [v]
    posx[v] = 0
    diameter = 0
    while node:
        s = node.pop()
        ds = posx[s]
        for t, dt in e_OUT[s]:
            dist = ds + dt
            if posx[t] != -1:
                if posx[t] != dist:
                    return False
                else:
                    continue
            posx[t] = dist
            node.append(t)
            diameter = max(diameter, dist)
    if diameter <= 10 ** 9:
        return True
    else:
        return False


ans = "Yes"
for i in range(N + 1):
    if len(e_IN[i]) == 0:
        posx[i] = 0
        bl = dfs(i)
        if not bl:
            ans = "No"
            break

if - 1 in posx:
    ans = "No"

print(ans)


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

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

// code starts
int main()
{
  int a,b;
  cin>>a>>b;
  int i;
  int ans=-1;
  for(i=10000;i>0;i--)
  {
    if(i*8/100==a&&i*10/100==b)ans=i;
  }
  cout<<ans<<endl;
}


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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s,t;

	cin >> s >> t;

	int res = 0;

	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
		{
			res++;
		}
	}

	cout << res << '\n';
	
	return 0;
}

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

sum=0
count=0

for i in range(n):
    sum=sum+a[i]

for i in range(n):
    if a[i]>=(sum/(4*m)):
        count=count+1

if count>=m:
    print("Yes")
else :
    print("No")

Measured memory_bytes: 38256
# O(1) solution
import math

A, B = map(int, input().split())

min_A = int(math.ceil(A * 12.5))
max_A = int(math.ceil((A + 1) * 12.5) - 1)

grp_A = {i for i in range(min_A, max_A + 1)}

min_B = int(math.ceil(B * 10))
max_B = int(math.ceil((B + 1) * 10) - 1)

grp_B = {i for i in range(min_B, max_B + 1)}

ans = grp_A & grp_B

if (len(ans) == 0):
    ans = -1
else:
    ans = min(ans)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define vl vector
#define ll long long
#define fast std::ios::sync_with_stdio(false)
using namespace std;

int main()
{
    fast;
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    ll d=abs(a-b);
    if(v<w) cout<<"NO";
    else if(d<=(v-w)*t) cout<<"YES";
    else cout<<"NO";
}


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

int a[100010];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        l--,r--;
        a[l]++;
        a[r+1]--;
    }
    
    vector<int> s(n+1,0);
    int ans=0;
    for(int i=0;i<n;i++) s[i+1]=s[i]+a[i];
    for(int i=1;i<=n;i++){
        if(s[i]==m){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

template<typename T> struct Combination
{
    vector<T> fact, rfact, inv;
    Combination(int n) : fact(n + 1), rfact(n + 1), inv(n + 1)
    {
        fact[0] = fact[1] = 1;
        rfact[0] = rfact[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            rfact[i] = rfact[i - 1] * inv[i] % MOD;
        }
    }
    T run(int n, int k)
    {
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n] * (rfact[k] * rfact[n - k] % MOD) % MOD;
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    map<char, int> mp;
    for(int i = 0; i < s.size(); i++) mp[s[i]]++;
    Combination<ll> comb(s.size());
    if((int)s.size() % 2 == 0)
    {
        bool ok = true;
        for(auto &&x : mp)
        {
            if(x.second % 2 != 0) ok = false;
            x.second /= 2;
        }
        if(ok)
        {
            int n = s.size() / 2;
            ll ans = 1;
            for(auto &&x : mp)
            {
                ans *= comb.run(n, x.second);
                n -= x.second;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
    else
    {
        int even = 0; char key;
        for(auto &&x : mp)
        {
            if(x.second % 2 != 0) even++, key = x.first;
            else x.second /= 2;
        }
        if(even == 1)
        {
            mp.erase(key);
            int n = s.size() / 2;
            ll ans = 1;
            for(auto &&x : mp)
            {
                ans *= comb.run(n, x.second);
                n -= x.second;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int ans,n,k;
int main(){
	n=read(),k=read(),ans=0;
	for(int i=1;i<=n;i++){
		int x=read();
		if(x>=k)ans++;
	} 
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-27 10:28:38
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
#define i64 long long
i64 read()
{
	i64 r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=100010,M=10000010;
namespace run
{
	const i64 inf=1ll<<60;
	i64 n,px[N],sx[N],py[N],sy[N],begin[N],next[N],to[N],w[N],c[N],e,S,T,m,x[N],y[N],v[N],ans,l,sw,sc;
	i64 d[N],q[M],_l,_r,pre[N],vis[N];
	void add(i64 u,i64 v,i64 W,i64 C){ e++; next[e]=begin[u]; begin[u]=e; to[e]=v; w[e]=W; c[e]=C; }
	void Add(i64 u,i64 v,i64 w,i64 c){ /*printf("%I64d %I64d %I64d\n",u,v,c);*/ add(u,v,w,c); add(v,u,0,-c); }
#define fo(i,a) for(int i=begin[a];i;i=next[i])
	int bfs()
	{
		fr(i,1,m){ d[i]=inf; pre[i]=0; vis[i]=0; }
		q[_l=_r=1]=S; d[S]=0;
		while(_l<=_r)
		{
			int u=q[_l++]; vis[u]=0;
//			printf("%d\n",u);
			fo(i,u) if(w[i]&&d[u]+c[i]<d[to[i]])
			{
				d[to[i]]=d[u]+c[i]; pre[to[i]]=i;
				if(!vis[to[i]]){ q[++_r]=to[i]; vis[to[i]]=1; }
			}
		}
		return d[T]!=inf;
	}
	i64 solve(int c)
	{
		memset(begin,0,sizeof(begin)); e=1; S=n+n+c+c+1; T=n+n+c+c+2; m=T;
//		printf("%d %I64d %I64d\n",c,S,T);
		fr(i,1,n) Add(i,i+n,1,-v[i]);
		fr(j,1,c){ Add(S,j+n+n,1,0); Add(j+n+n+c,T,1,0); }
		fr(i,1,n) fr(j,1,c) if(px[x[i]]>=j&&sx[x[i]]>=c-j+1) Add(j+n+n,i,1,0);
		fr(i,1,n) fr(j,1,c) if(py[y[i]]>=j&&sy[y[i]]>=c-j+1) Add(i+n,j+n+n+c,1,0);
		sw=sc=0;
		fr(i,1,c) if(bfs())
		{
//			printf("%I64d\n",d[T]);
			int u=T; sw++;
			while(u!=S){ w[pre[u]]--; w[pre[u]^1]++; sc-=::run::c[pre[u]]; u=to[pre[u]^1]; }
		}
		else return 0;
//		printf("%d %I64d\n",c,sw==c?sc:0);
		return sc;
	}
	int main()
	{
		n=read(); l=100;
		fr(i,1,n){ x[i]=read(); y[i]=read(); v[i]=read(); }
		fr(i,0,l+1) px[i]=sx[i]=py[i]=sy[i]=n;
		fr(i,1,read())
		{
			char opt[N]; i64 a,b;
			scanf("%s",opt); a=read(); b=read();
			if(*opt=='L') px[a]=std::min(px[a],b);
			if(*opt=='R') sx[a]=std::min(sx[a],b);
			if(*opt=='D') py[a]=std::min(py[a],b);
			if(*opt=='U') sy[a]=std::min(sy[a],b);
		}
		fr(i,1,l){ sx[i]=std::min(sx[i],sx[i-1]); sy[i]=std::min(sy[i],sy[i-1]); }
		fd(i,l,1){ px[i]=std::min(px[i],px[i+1]); py[i]=std::min(py[i],py[i+1]); }
//		fr(i,1,n) printf("%I64d %I64d %I64d %I64d\n", );
		fr(i,1,n){ i64 k=solve(i); ans=std::max(ans,k); if(!k) break; }
		printf("%lld\n",ans);
		return 0;
	}
}
int main(){ return run::main(); }

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 998244353

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

class Comb{
    // テーブルを作るのに O(NlogN)
    // 計算は O(1)
    int N;
    vector<long long> fact_num, fact_den;
    long long bipow(long long n, long long m) {
        if (m == 0) return 1;
        if (m % 2 == 0) {
            n = (n * n) % MOD;
            return bipow(n, m / 2) % MOD;
        } else
            return (n * bipow(n, m - 1)) % MOD;
    }
    void set_table(){
        fact_num.resize(N+1, 0);
        fact_den.resize(N+1, 0);
        vector<long long> fact_denpow(N+1, 0);

        fact_num[0] = 1;
        for(int i=1; i<=N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;
        for(int i=0; i<=N; i++) fact_denpow[i] = bipow(i, MOD-2);
        fact_den[0] = 1;
        for(int i=1; i<=N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
    }
public:
    Comb(int N): N(N) { set_table(); }
    // nCk
    long long calc(long long n, long long k){
        if(k > n) return 0;
        return ((fact_num[n] * fact_den[k]) % MOD * fact_den[n-k]) % MOD;
    }
};

long long bipow(long long n, long long m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

int main(){
    long long N, M, K;
    cin >> N >> M >> K;
    Comb comb(N+10);
    long long ans = 0;
    for(int k=0; k<=K; k++){
        long long tmp = (comb.calc(N-1, k) * bipow(M-1, N-1-k)) % MOD;
        ans += tmp;
        ans %= MOD;
    }
    ans *= M;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7880
import java.util.Scanner;

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

		do {
			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			int[] grade = new int[n];

			for (int i = 0; i < n; i++) {
				grade[i] = sc.nextInt();
			}

			dev = deviation(grade);

			System.out.println(dev);


		}while(true);

		sc.close();
	}

	private static double deviation(int[] grade) {
		double deviation = 0;

		for (int i = 0; i < grade.length; i++) {
			deviation += Math.pow( grade[i] - average(grade) , 2);
		}

		deviation /= grade.length;
		deviation = Math.sqrt(deviation);
		return deviation;
	}

	public static double average(int[] grade) {
		double average = 0;

		for (int i = 0; i < grade.length; i++) {
			average += grade[i];
		}

		average /= grade.length;

		return average;
	}


}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int L,R; cin >> L >> R;
    VI v;
    FOR(i,L,min(R+1,L+4038)) v.push_back(i%2019);

    int ans = INF;
    int K = v.size();
    REP(i,K-1)FOR(j,i+1,K) chmin(ans, v[i]*v[j]%2019);
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, sum = 0, a[100005], x[100005];

    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i != n-1) {
            if (i&1) sum += a[i];
            else sum -= a[i];
        }
    }

    x[0] = (a[n-1] - sum) / 2;

    for (int i = 1; i < n; i++)
        x[i] = a[i-1] - x[i-1];

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << x[i]*2;
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 2176
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin>>s;
    int a=0;
    int b=1;
    int cnta=0;
    int cntb=0;
    rep(i, s.size()){
        
        if (s[i]-'0'==a) cntb++;
        else cnta++;
        a=(a+1)%2;
        b=(b+1)%2;
        
    }
    int ans=min(cnta, cntb);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, A[100000]; cin >> N;
  int sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
    A[i] *= 2;
  }
  for(int i = 1; i < N; i+=2){
    sum -= A[i];
  }
  cout << sum << ' ';
  int tmp = sum;
  REP(i, N-1){
    cout << A[i]-tmp << ' ';
    tmp = A[i]-tmp;
  }
  cout << endl;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <algorithm>
#define oo 987654321
#define INT long long
using namespace std;

INT n, k, x = 1, t[100010], mx;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>t[i];
        if( i == 0 ) x = t[i];
        x = __gcd(x, t[i]);
        mx = max(mx, t[i]);
    }
    if( mx < k ) return cout<<"IMPOSSIBLE"<<endl, 0;
    else
    {
        for(int i = 0 ; i < n ; i++ )
            if( (t[i]-k)%x == 0 ) return cout<<"POSSIBLE"<<endl, 0;
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


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

int main(void)
{
	int q1, b, c1, c2, q2;
	
	while(1){
		scanf("%d", &q1);
		if (q1 == 0) break;
		scanf("%d %d %d %d", &b, &c1, &c2, &q2);
		
		if (c1 <= c2){
			int x = min(b/c1, q2);
			int y = (b - (x * c1)) / c2;
			if ((x + y) < q1){
				printf("NA\n");
			}
			else {
				printf("%d %d\n", x, y);
			}
		}
		else {
			int x = min(min((b - (c2 * q1)) / (c1 - c2), q2), (b / c1));
			int y = (b - (x * c1)) / c2;
			if(x <= 0){
				printf("NA\n");
			}
			else {
				printf("%d %d\n", x, y);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

#define N 10
int main(){
    int L[N],v1,v2,i;
    double n;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&L[0],&L[1],&L[2],&L[3],&L[4],&L[5],&L[6\
],&L[7],&L[8],&L[9],&v1,&v2)!=EOF){
    int sum=0;
    for (i=0;i<N;i++){
      sum+=L[i];
    }

    n=(double)sum*v1/(v1+v2);
    for (i=0;i<N;i++){
      n-=L[i];
      if (n<=0){
        printf("%d\n",i+1);
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 596
y=[]
z=[]
for i in range(1,5):
    x=int(input())
    y.append(x)
y.remove(min(y))

for i in range(1,3):
    x=int(input())
    z.append(x)
z.remove(min(z))

print(int(y[0]+y[1]+y[2]+z[0]))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<char,int>m;
    for(int i =0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M' ||s[0]=='A'|| s[0]=='R'|| s[0]=='C'||s[0]=='H'){
                m[s[0]]++;
        }


    }
    int ans=0,i=1;
    vi v;
    if(m.size() <3){
        cout<<0<<endl;
        return 0;
    }
    tr(it,m){
        v.pb(it->second);
    }


    for(int i =0;i < v.size()-2;i++){
        if(v[i]==0) continue;
        for(int j =i+1;j<v.size()-1;j++){
            if(v[j]==0) continue;
            for(int k =j+1;k<v.size();k++){
                if (v[k]==0) continue;
                ans = ans + v[i]*v[j]*v[k];
            }
        }
    }
    cout<<ans<<endl;





}








Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var input = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long N = input[0];
            long K = input[1];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var dict = new Dictionary<long,long>();
            for(var i=0;i<N;i++){
                if(!dict.ContainsKey(A[i]))dict[A[i]]=1;
                else dict[A[i]]++;
            }
            var num = new List<long>();
            foreach(var key in dict.Keys){
                num.Add(dict[key]);
            }
            num.Sort((a,b)=>(int)(b-a));
            long count = 0;
            long result = 0;
            foreach(var i in num){
                count++;
                if(count>K){
                    result +=i;
                }
            }
            Console.WriteLine(result);
        }
    } 
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n,m,q;cin>>n>>m>>q;
  string s[n];
  for(int i=0;i<n;i++)cin>>s[i];
  int cho[n+10][m+10]={};
  int henh[n+10][m+10]={};
  int henw[n+10][m+10]={};

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i][j]=='1'){
	cho[i+1][j+1]++;
      }
    }
  }

  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      if(cho[i][j]){
	henh[i][j] = cho[i-1][j];
	henw[i][j] = cho[i][j-1];
      }
    }
  }

  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      henh[i][j+1]+=henh[i][j];
      henw[i][j+1]+=henw[i][j];
      cho[i][j+1]+=cho[i][j];
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      henh[i+1][j]+=henh[i][j];
      henw[i+1][j]+=henw[i][j];
      cho[i+1][j]+=cho[i][j];
    }
  }

  for(int i=0;i<q;i++){
    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    cout<<(cho[x2][y2]+cho[x1-1][y1-1]-cho[x2][y1-1]-cho[x1-1][y2])-
      (henh[x2][y2]+henh[x1][y1-1]-henh[x2][y1-1]-henh[x1][y2])-
      (henw[x2][y2]+henw[x1-1][y1]-henw[x2][y1]-henw[x1-1][y2])
	<<endl;
  }
  return 0;
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;


int main(void){
    int n,m;
    cin>>n>>m;
    map<int,int> mp;
    int r = m;
    for(int i = 2; i <= sqrt(m); i++){
        while(r % i == 0){
            mp[i]++;
            r /= i;
        }
    }
    if(r > 1) mp[r]++;
    modint res = 1;
    for(auto itr : mp){
        int k = itr.second;
        res *= modint::com(n-1+k,k);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;

namespace Many_Sushiki
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            int n = S.Length-1;
            long answer=0;
            List<List<int>> insert = new List<List<int>>();
            for(int i = 0; i < (1 << n); i++)
            {
                List<int> plan = new List<int>();
                for(int j = 0; j < n; j++)
                {
                    if (((i >> j) & 1) == 1)
                    {
                        plan.Add(j);
                    }
                }
                insert.Add(plan);
            }
            for(int i = 0; i < insert.Count; i++)
            {
                if (insert[i].Count == 0)
                {
                    answer += long.Parse(S);
                }
                else
                {
                    int start = 0;
                    int end=0;
                    for(int j = 0; j < insert[i].Count; j++)
                    {
                        end = insert[i][j]+1;
                        answer += long.Parse(S.Substring(start, end - start));
                        start = end;
                    }
                    answer += long.Parse(S.Substring(end, S.Length - end));
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11220