akhauriyash/Code-Regression huggingface dataset:
IDENTIFICATION DIVISION.
PROGRAM-ID. 124C.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP   PIC X(200000).
*>
WORKING-STORAGE SECTION.
01 S     PIC X(100001).
01 CNT.
   03 C  PIC 9(5) OCCURS 2.
01 F     PIC 9(1).
01 A     PIC 9(1).
01 H     PIC 9(5).
01 K1    PIC 9(5).
01 K2    PIC 9(5).
01 I     PIC 9(6).
01 OUT   PIC ZZZZ9.
*>
PROCEDURE DIVISION.
*>ACCEPT S FROM SYSIN.
  OPEN INPUT STDIO.
  READ STDIO INTO S.
  CLOSE STDIO.
*>
  MOVE 0 TO C(1) C(2).
  MOVE 1 TO F.
  PERFORM VARYING I FROM 1 BY 1 UNTIL S(I:1) = ' '
    IF (S(I:1) = '1') 
      COMPUTE C(F) = C(F) + 1
    END-IF     
    COMPUTE F = 3 - F
  END-PERFORM.
*>
  SUBTRACT 1 FROM I
  DIVIDE I BY 2 GIVING H REMAINDER A.
  COMPUTE K1 = H + A - C(1) + C(2)
  COMPUTE K2 = H     - C(2) + C(1)    
*>
  IF (K1 < K2)
    MOVE K1 TO OUT
  ELSE
    MOVE K2 TO OUT
  END-IF.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 1144
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

    String[] strs = sc.nextLine().split(" ");

    Deque<String> stack = new ArrayDeque<>();

    long a = 0;
    long b = 0;
  
    for (String s : strs) {
      if (Arrays.asList("+", "-", "*").contains(s)) {
        a = Long.valueOf(stack.pop());
        b = Long.valueOf(stack.pop());
      }

      String r = s;
      if ("+".equals(s)) r = String.valueOf(b + a);
      if ("-".equals(s)) r = String.valueOf(b - a);
      if ("*".equals(s)) r = String.valueOf(b * a);

      stack.push(r);
    }

    System.out.println(stack.pop());
  }
}


Measured memory_bytes: 26208
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

k=int(input())
a=0
for i in range(1,k+1):
    for j in range(1,k+1):
        b= gcd(i,j)
        for m in range(1,k+1):
            a+=gcd(b,m)
print(a)

Measured memory_bytes: 68252
#include <iostream>
#include <map>

using namespace std;

int main() {
  map<string, int> m = {{"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4},
                        {"THU", 3}, {"FRI", 2}, {"SAT", 1}};
  string str;
  cin >> str;
  cout << m[str] << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from heapq import*


n, m = map(int, input().split())

JOBS = {i:[] for i in range(1, m + 1)}
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        JOBS[a].append(b)

answer = 0
REWARDS = []
heapify(REWARDS)
for i in range(1, m + 1):
    for reward in JOBS[i]:
        heappush(REWARDS, -reward)
    if len(REWARDS) > 0:
        reward = -heappop(REWARDS)
        answer += reward

print(answer)


Measured memory_bytes: 26980
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;
import core.checkedint;
import core.bitop;
import std.digest.sha;

void main()
{
	int n = readln.chomp.to!int;
	bool[] done = new bool[](n + 1);
	done[0] = true;
	foreach (d; [4, 7]) {
		foreach (i; 0..n - d + 1) {
			done[i + d] |= done[i];
		}
	}
	writeln = done[n] ? "Yes" : "No";
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,n,total=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        int k=0,j;
        scanf("%d",&j);
        while((j%2) != 1){
            j /= 2;
            k++;
        }
        total += k;
    }
    printf("%d",total);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		double a;
		a = (double) T / X;
		System.out.println(a);
	}
}


Measured memory_bytes: 23124
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

const int MAX_V = 1000, MAX_E = 2000;

struct edge {
    ll from, to, cost;
};


edge es[MAX_E];
ll d[MAX_V];
bool has_loop[MAX_V];
ll V, E; // Vは頂点数，Eは辺数

// s番目の頂点から各頂点への最短距離を求める
// V * E
void bellman_ford(ll s) {
    for (int i = 0; i < V; ++i) d[i] = -ll_inf;
    d[s] = 0;
    for (int j = 0; j < V - 1; j++) {
        for (int i = 0; i < E; ++i) {
            edge e = es[i];
            if (d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
}


void solve() {
    bellman_ford(0);
    for (int i = 0; i < V - 1; ++i) {
        for (int j = 0; j < E; ++j) {
            edge e = es[i];

            if (d[e.to] < d[e.from] + e.cost) {
                has_loop[e.from] = true;
            }
            if (has_loop[e.from]) {
                has_loop[e.to] = true;
            }
        }
    }
    if (has_loop[V - 1]) cout << "inf" << endl;
    else cout << d[V - 1] << endl;
}

int main() {
    cin >> V >> E;
    rep(i, E) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edge e = {a, b, c};
        es[i] = e;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

import javax.lang.model.util.ElementScanner6;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        for (;;) {
            a = sc.nextInt();
            String op = sc.next();
            b = sc.nextInt();
            if (op.equals("+"))
                System.out.println(a + b);
            else if (op.equals("-"))
                System.out.println(a - b);
            else if(op.equals("*"))
                System.out.println(a * b);
            else if (op.equals("/"))
                System.out.println(a / b);
            else
                break;
        }
    }
}



Measured memory_bytes: 26432
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{

    string s;
    cin>>s;
    ll k=0;
    for(int i=0;i<s.length();i++){
        k+=(s[i]-'0');
    }
    if(k%9==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3720
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

long long n, m;

int main () {
    cin >> n >> m;
    if ( n % m == 0 ) {
        cout << n / m;
    }
    else {
        cout << n / m + 1;
    }
}


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

priority_queue<ll, vector<ll>, greater<ll>> ans;

void solve(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans.push(i);
      solve(n / i);
      return;
    }
  }
  ans.push(n);
}

int main() {
  ll n;
  cin >> n;

  solve(n);

  cout << n << ":";

  while (!ans.empty()) {
    cout << " " << ans.top();
    ans.pop();
  }

  cout << endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[4];
    int i;

    for(i=0; i<3; i++)
    {
        cin>>s[i];
    }
    for(i=0; i<3; i++)
    {
        if(s[0]=='R'&&s[1]=='S'&&s[2]=='S')
        {
            cout<<1;
            break;
        }
        else if(s[0]=='R'&&s[1]=='S'&&s[2]=='R')
        {
            cout<<1;
            break;
        }
        else if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        {
            cout<<3;
            break;
        }
        else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S')
        {
            cout<<2;
            break;
        }
        else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R')
        {
            cout<<2;
            break;
        }
        else if(s[0]=='S'&&s[1]=='R'&&s[2]=='S')
        {
            cout<<1;
            break;
        }
         else if(s[0]=='S'&&s[1]=='S'&&s[2]=='R')
        {
            cout<<1;
            break;
        }
        else
        {
            cout<<0;
            break;
        }

    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#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(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    string s;
    cin >> s;
    string yy = s.substr(0, 2);
    string mm = s.substr(2,2);
    int yy_i = atoi(yy.c_str());
    int mm_i = atoi(mm.c_str());
    bool yymm_flag = true;
    bool mmyy_flag = true;
    bool na_flag = false;
    if(mm_i == 0 || mm_i > 12) {
        yymm_flag = false;
    }
    swap(yy_i, mm_i);
    if(mm_i == 0 || mm_i > 12) {
        mmyy_flag = false;
    }
    if(yymm_flag && mmyy_flag) cout << "AMBIGUOUS" << endl;
    else if(yymm_flag) cout << "YYMM" << endl;
    else if(mmyy_flag) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long int L, R, ans=2020, tmp, i, j;
	
	scanf("%lld %lld", &L, &R);
	
	if(R-L>2019) ans=0;
	else {
		for(i=L; i<R; i++){
			for(j=i+1; j<=R; j++){ 
				tmp=(i*j)%2019;
				if(ans>tmp)ans=tmp;
			}
		}
	}
	
	printf("%lld", ans);
				
	
return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N;
int L[105];
signed main(){
    scanf("%lld",&N);
    rep(i,N){
        scanf("%lld",&L[i]);
    }
    int ans=0;
    rep(i,N-2){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if(L[i]==L[j]||L[i]==L[k]||L[j]==L[k])continue;
                int maxL=max(max(L[i],L[j]),L[k]);
                int L1=min(min(L[i],L[j]),L[k]);
                int L2=L[i]+L[j]+L[k]-maxL-L1;
                if(maxL<L1+L2)ans+=1;
            }
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
int a[100001];
int main()
{
      int n,gg=0;
      std::cin>>n;
      
      for(int i=1;i<=n;i++)std::cin>>a[i];
      
      for(int i=1;i<=n;i++)
      {
            if(a[i]==a[i+1])gg++,i++;
      }
      std::cout<<gg<<std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/


int main(){
	string line;	
	int tot = 0;
	while( getline(cin,line) ){
		bool flag = true;
		for(int i=0,j=line.size()-1;i<j;i++,j--){
			if(line[i] != line[j]){
				flag = false;
			}
		}
		if(flag){
			tot++;
		}
	}
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 1176
s=int(input())
num=[]
while s > 0:
    num.append(s % 100)
    s //= 100

if len(num)==0:
    num.append(0)
if len(num)==1:
    num.append(0)
num.reverse()

if num[0]<=12 and num[0]>0:
    if num[1]<=12 and num[1]>0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if num[1]<=12 and num[1]>0:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 3064
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sortWith( _ > _ ).par
    .zipWithIndex.map(e => if ((e._2 & 1) == 0) e._1 else -e._1)
    .sum

  println(ans)
}


Measured memory_bytes: 28356
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S;
    int Q;
    cin >> S >> Q;

    bool rev = false;
    deque<char> head;
    deque<char> tail;

    rep(i, Q) {
        int T;
        cin >> T;
        if (T == 1) {
            rev = !rev;
        } else if (T == 2) {
            int F;
            char C;
            cin >> F >> C;
            if (rev) {
                if (F == 1) {
                    tail.push_back(C);
                } else {
                    head.push_front(C);
                }
            } else {
                if (F == 1) {
                    head.push_front(C);
                } else {
                    tail.push_back(C);
                }
            }
        }
    }

    if (rev) {
        for (int i = tail.size()-1; 0 <= i; --i) {
            cout << (char) tail[i];
        }
        for (int i = S.size()-1; 0 <= i; --i) {
            cout << (char) S[i];
        }
        for (int i = head.size()-1; 0 <= i; --i) {
            cout << (char) head[i];
        }
    } else {
        for (int i = 0; i < head.size(); ++i) {
            cout << (char) head[i];
        }
        cout << S;
        for (int i = 0; i < tail.size(); ++i) {
            cout << (char) tail[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 848
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }
  debug(C);
  for (int i = 0; i < N - 1; i++) {
    int current_time = 0;
    for (int j = i; j < N - 1; j++) {
      int departure_time = max(S[j], ((current_time + F[j] - 1) / F[j]) * F[j]);
      debug(departure_time);
      current_time = departure_time + C[j];
    }
    cout << current_time << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main() {

    int a, b, c, x, cnt = 0;
    cin >> a >> b >> c >> x;

    for(int i = 0; i <= c; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= a; ++k) {
                if (x == (i*50 + j * 100 + k * 500)) {
                    ++cnt;
                }   
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll total = 0;
	rep(i, n) {
		cin >> a[i];
		total += a[i];
	}
	ll ans = 1e10, kuma = 0;
	rep(i, n) {
		kuma += a[i];
		if (i + 1 < n)ans = min(ans, abs(kuma * 2 - total));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n = input()
for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, raw_input().split())
    r = ((xa-xb)**2 + (ya-yb)**2)**.5
    if ra+rb<r: print 0
    elif ra-rb>r: print 2
    elif rb-ra>r: print -2
    else: print 1

Measured memory_bytes: 4296
#include<iostream>

using namespace std;

int main() {
    int rate[2], ans = 0;

    cin >> rate[0] >> rate[1];

    for(int i = 0; i < 2; i++) {
        switch (rate[i]) {
            case 1:
                ans += 300000;
                break;
            case 2:
                ans += 200000;
                break;
            case 3:
                ans += 100000;
                break;
            default:
                break;
        }
    }

    if(rate[0] == 1 && rate[1] == 1) {
        ans += 400000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n, k;
    cin >> n >> k;
    int p[n];
    rep(i, n) cin >> p[i];
    sort(p, p+n);
    int ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

ll factorial(ll n) {
	ll ans=1;
	rep(i, 1, n+1) {
		ans = (ans*i)%MOD;
	}
	return ans;
}




int main(){
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if (abs(n - m) >= 2) {
		cout << "0" << endl;
	}
	else {
		if (n == m) {
			ans = (2 *(factorial(n))*(factorial(n))) % MOD;
		}
		else {
			ans = (factorial(n)*factorial(m)) % MOD;
		}
		cout << ans << endl;
	}


	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ARC073C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

n=hoge[0]
t=hoge[1]

total=n*t
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
for i in range(0,n-1):
	if(hoge[i+1]-hoge[i]<t):
		total-=t-(hoge[i+1]-hoge[i])
print(total)

Measured memory_bytes: 27348
import math

def keta(a):
    count=1
    while a>=10:
        a/=10
        count+=1
    return count


N=int(input())
mi=10
for i in range(1,int(N/math.sqrt(N)+1)):
    if N%i==0:
        j=int(N/i)
        if mi>max(keta(i),keta(j)):
            mi=max(keta(i),keta(j))

print(mi)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1e12;

vector<LL> pos;

struct ans{
	LL val,lef,rig;
	void build(){
		val=INF;
		lef=INF;
		rig=INF;
	}
	void update(LL x){
		val=min(INF,val+x);
		lef=min(INF,lef+x);
		rig=min(INF,rig+x);
	}
	void swaps(LL x,LL y){
		val=min(val,y);
		lef=val-x;
		rig=val+x;
	}
}kosong;

ans merge(ans a,ans b){
	ans hasil;
	hasil.val=min(a.val,b.val);
	hasil.lef=min(a.lef,b.lef);
	hasil.rig=min(a.rig,b.rig);
	return hasil;
}

struct segment{
	LL L,R,lazy;
	ans ret;
	segment *ki,*ka;
	void build(LL x,LL y){
		L=x;
		R=y;
		lazy=0;
		ret.build();
		if(L==R)return;
		LL mid=(L+R)/2;
		ki=new segment;
		ki->build(x,mid);
		ka=new segment;
		ka->build(mid+1,y);
		ret=merge(ki->ret,ka->ret);
		return;
	}
	void balance(){
		if(!lazy)return;
		ki->ret.update(lazy);
		ki->lazy+=lazy;
		ka->ret.update(lazy);
		ka->lazy+=lazy;
		lazy=0;
	}
	void update(LL x,LL y){
		if(L==R){
			ret.swaps(x,y);
			return;
		}
		balance();
		LL mid=(L+R)/2;
		if(x<=mid)ki->update(x,y);
		else ka->update(x,y);
		ret=merge(ki->ret,ka->ret);
	}
	ans query(LL x,LL y){
		if(L>=x && R<=y)return ret;
		if(L>y || R<x)return kosong;
		balance();
		return merge(ki->query(x,y),ka->query(x,y));
	}
}data;

LL minimum_time(int N, int Q, int A, int B, vector<int> X) {
	kosong.build();
	data.build(1,N);
	pos.push_back(A);
	pos.push_back(B);
	for(auto isi : X)pos.push_back(isi);
	data.update(pos[0],0);
	for(LL i=1;i<=Q;i++){
		LL temp=min(data.query(1,pos[i+1]).lef+pos[i+1],data.query(pos[i+1],N).rig-pos[i+1]);
		data.lazy+=abs(pos[i+1]-pos[i]);
		data.ret.update(abs(pos[i+1]-pos[i]));
		data.update(pos[i],temp);
	}
	return data.query(1,N).val;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int N,Q,A,B,no;
	vector<int> V;
	cin >> N >> Q >> A >> B;
	for(int i=1;i<=Q;i++){
		cin >> no;
		V.push_back(no);
	}
	cout << minimum_time(N,Q,A,B,V) << '\n';
	return 0;
}

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

vector<int> f(vector<int> v){
  vector<int> res;
  for(int i=0;i<v.size();i++)
    if(v[i]>0)
      res.push_back(v[i]);
  return res;
}

bool check(vector<int> v){
  for(int i=0;i<v.size();i++)
    if(v[i]!=i+1)return false;
  return true;
}

int main(){
  int n;
  while(cin>>n, n){
    vector<int> v;

    v.clear();
    for(int i=0;i<n;++i){
      int x;
      cin>>x;
      v.push_back(x);
    }
    int ans=0,cnt=0;

    while( !check(v) ){

      ans++;
      if(ans>10000){
        ans=-1;
        break;
      }

      int size=v.size();
      for(int i=0;i<size;++i){
          v[i]--;
      }
      
      v.push_back( size );

      v=f(v);
    }
    
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3172
<?php
while($s = trim(fgets(STDIN))){

$s = str_split($s);
for( $i=0 ; $i < count($s); $i++){
	if($s[$i]=='@'){
		for($j=0;$j<$s[$i+1];$j++){
			print($s[$i+2]);
		}
		$i+=2;
	}
	else{
		print($s[$i]);
	}
	
}
print("\n");
}

Measured memory_bytes: 6600
#include<bits/stdc++.h>
using namespace std;
#define int long long int

const int mod=1e9+7;

int power(int a,int b){
	if(b==0)return 1LL;
	int s=power(a,b/2LL);
	s*=s;
	s%=mod;
	if(b&1LL)return (s*a)%mod;
	return s;
}

int inv(int a){
	return power(a,mod-2);
}

int MOD(int n){
	return ((n%mod)+mod)%mod;
}

int nCr(int n,int r){
	if(r>n)return 0LL;
	if(n-r<r)r=n-r;
	int ans=1;
	for(int i=0;i<r;i++){
		ans*=(n-i);
		ans=MOD(ans);
		ans*=inv(i+1);
		ans=MOD(ans);
	}
	return ans;
}



signed main(){

	int n,a,b;
	cin>>n>>a>>b;
	int ans=power(2,n)-1LL;
	ans=MOD(ans);
	ans-=nCr(n,a);
	ans=MOD(ans);
	ans-=nCr(n,b);
	ans=MOD(ans);
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    ll n=s.size();
    string t="";
    ll res=0;
    rep(i,n-1){
        t=t+s[i];
        if(t.size()%2==1) continue;
        bool ifeven=true;
        rep(j, t.size()/2){
            if(t[j]!=t[j+t.size()/2]) ifeven=false;
        }
        if(ifeven) chmax(res, (ll)i+1);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
S = int(input())
if S <= 2:
    print(0)
elif S <= 5:
    print(1)
else:
    series = [0,0,0,1,1,1]
    m = 10**9 +7
    for i in range(6,S+1):
        series.append((series[i-3] + series[i-1]) %m)
    print(series[S])

Measured memory_bytes: 9184
N=list(input())
H=[]
for i in range(len(N)) :
    if N[i] == "U" or N[i] == "D" :
            pass
    else:
        if i % 2 == 1 :
            if N[i] == "L" :
                pass
            else :
                H.append("No")
        else:
            if N[i] == "R" :
                pass
            else :
                H.append("No")
if "No" in H :
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[3000][3000];
int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	if (s[0] == '<') dp[1][1] = 1;
	else dp[1][0] = dp[1][1] = 1;
	for (int i = 2; i < N; i++) {
		if (s[i - 1] == '<') {
			for (int j = 1; j < i; j++) {
				(dp[i][j] += dp[i - 1][j - 1]) %= MOD;
			}
			(dp[i][i] += dp[i - 1][i - 1]) %= MOD;
		}
		else {
			for (int j = 0; j < i; j++) {
				ll t = dp[i - 1][i - 1];
				if (j > 0) (t += MOD - dp[i - 1][j - 1]) %= MOD;
				(dp[i][j] += t) %= MOD;
			}
		}
		for (int j = 1; j <= i; j++) (dp[i][j] += dp[i][j - 1]) %= MOD;
	}
	cout << dp[N - 1][N - 1] << endl;
}

Measured memory_bytes: 68864
<?php
fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++) {
	fscanf(STDIN, "%s", $s[]);
}
fscanf(STDIN, "%s", $t);

$c = 0;
for ($i = 0; $i < $n; $i++) {
	if (strpos($s[$i], '?') !== false) {
		$sa[] = str_replace('?', 'a', $s[$i]);
		$sz[] = str_replace('?', 'z', $s[$i]);
	} else {
		$sa[] = $sz[] = $s[$i];
	}
	if ($s[$i] == $t) $c++;
}
$sa[] = $sz[] = $t;
sort($sa);
sort($sz);
$sa = array_flip($sa);
$sz = array_flip($sz);
$max = $sa[$t] + 1;
$min = $sz[$t] + 1;
if ($c) $min -= $c;
echo implode(' ', range($min, $max)), "\n";

Measured memory_bytes: 8696
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := map[string]int{}
	for i := 0; i < n; i++ {
		m[next()]++
	}

	max := 0
	for _, v := range m {
		if v > max {
			max = v
		}
	}

	ans := make([]string, 0)
	for k, v := range m {
		if v == max {
			ans = append(ans, k)
		}
	}
	sort.Sort(sort.StringSlice(ans))

	for i := range ans {
		puts(ans[i])
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	pair<int,int> ab[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>ab[i].first>>ab[i].second;
	}
	sort(ab,ab+n);
	multiset<int> memo;
	int now=0,ans=0;
	for (int i = 0; i < m+1; ++i)
	{
		while (now<n&&ab[now].first<=i)
		{
			memo.insert(ab[now].second);
			++now;
		}
		if (memo.size()>0)
		{
			auto itr=memo.end();
			--itr;
			ans+=(*itr);
			memo.erase(itr);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>
int main()
{
  int K,X,a,b,i;
  scanf("%d %d",&K,&X);
  a=X-(K-1);
  b=X+(K-1);
  for(i=a;i<=b;i++)
  {
    printf("%d\t",i);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	int t=min(b,d)-max(a,c);
	if(t<0) cout<<0<<endl;
	else cout<<t<<endl;
	
	return 0;
}

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

int main()
{
	int n;
	string s, t;
	cin >> n >> s >> t;

	string ans = "";
	for (int i = 0; i < n; i++)
	{
		ans += s[i];
		ans += t[i];
	}

	cout << ans << endl;

	return 0;
}

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

struct S {
  int from;
  int to;
  int cost;
};

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n, m;
  cin >> n >> m;
  vector<S> adj( m );
  vector< vector<int> > dist( n, vector<int>( n, numeric_limits<int>::max() / 3 ) );

  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;  --b;
    adj[i] = S{a, b, c};
    dist[a][b] = c;
    dist[b][a] = c;
  }

  for (int i = 0; i < n; ++i) dist[i][i] = 0;
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < n; ++i) {
      for (int k = 0; k < n; ++k) {
        dist[i][k] = min(dist[i][k], dist[i][j] + dist[j][k]);
      }
    }
  }

  int ans = 0;
  for (auto s : adj) {
    bool found = false;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dist[i][s.from] + s.cost + dist[s.to][j] == dist[i][j]) {
          // used
          found = true;
          break;
        }
      }

      if (found) break;
    }
    if (!found) ++ans;
  }

  cout << ans << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll n,a,b,c,d;
mi dp;
ll solve(ll num){
	if(num==0) return 0;
	if(num==1) return d;
	if(dp.count(num)) return dp[num];
	ll ans=inf;
	if(num < ans/d) ans = num*d;
	ll l2,r2,l3,r3,l5,r5;
	l2 = (num/2)*2;
	r2 = ((num+1)/2)*2;
	l3 = (num/3)*3;
	r3 = ((num+2)/3)*3;
	l5 = (num/5)*5;
	r5 = ((num+4)/5)*5;
	
	ans = min(ans , solve(l2/2) + a + llabs(num-l2)*d);
	ans = min(ans, solve(r2/2) + a + llabs(num-r2)*d);
	ans = min(ans, solve(l3/3) + b + llabs(num-l3)*d);
	ans = min(ans, solve(r3/3) + b + llabs(num-r3)*d);
	ans = min(ans, solve(l5/5) + c + llabs(num-l5)*d);
	ans = min(ans, solve(r5/5) + c + llabs(num-r5)*d);
	
	dp[num]=ans;
	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	cin>>t;
	while(t--){
		cin>>n>>a>>b>>c>>d;
		ll ans = solve(n);
		cout<<ans<<"\n";
		dp.clear();
	}
	
	return 0;
}

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

using namespace std;

const int N = 1e3 + 7 , mod = 1e9 + 7 ;

int n , m; 
string s ;

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
       // freopen("in.in" , "r" , stdin) ; 
        cin>>s ; 
        n = s.size() ; 
        for(int i = 0 ; i  <n ; i++){
                if(s[i] == '?'){
                        s[i]= 'D' ; 
                }
        }
        cout<<s ; 
        return 0;
}


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

int main(){
    int a,b,c,d;    cin>>a>>b>>c>>d;
    if((abs(a-b)<=d && abs(b-c)<=d)||abs(a-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<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++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double bs=6*m;
  long double as=((h*60+m)*360)/720;
  long double cs=abs(as-bs);
  if(cs>180)cs=360-cs;
  long double degree=cs;
  long double A=a*a;
  long double B=b*b;
  long double AB=a*b;
  long double  radian = degree * M_PI / 180;
  long double tmp=cos(radian);
  long double d=A+B-2*AB*tmp;
  d=sqrtl(d);
  cout<<fixed<<setprecision(15)<<d<<endl;
}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,d,ans=0;
	double a[105][105]={};
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			double dist=0;
			for(int k=0;k<d;k++)
			{
				dist+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			if(!fmod(sqrt(dist),1))ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}







Measured memory_bytes: 512
// by The_One_Solver
#include<bits/stdc++.h>
using namespace std;
long long a,b,x;
int main()
{
    cin>>a>>b>>x;
    long long q=a,n=b;
    if(a%x!=0)
    {
        a-=a%x;
    }
    if(b%x!=0)
    {   long long  c=b-(b%x);
        if(c>=a)
           b-=b%x;
    }
    if(q%x!=0)
    cout<<((b/x)-(a/x));
    else cout<<((b/x)-(a/x))+1;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 500000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll po(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = po(a, b / 2);
	z = z*z%mod;
	if (b % 2 == 1)z = z*a%mod;
	return z;
}
int main()
{
	invinit();
	int n, a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	ll ka = a * inv[a + b] % mod, kb = b * inv[a + b] % mod;
	ll r = 0;
	for (int i = 0; i <= n - 1; i++)
	{
		ll sa = com(n - 1 + i, n - 1)*ka%mod*po(ka, n - 1) % mod*po(kb, i);
		ll sb = com(n - 1 + i, n - 1)*kb%mod*po(kb, n - 1) % mod*po(ka, i);
		r = (r + (sa + sb) % mod*(n + i)) % mod;
	}
	printf("%lld\n", r * 100 % mod*inv[a + b] % mod);
}

Measured memory_bytes: 12032
#include <iostream>
#define ffor(a, b, c) for (int a=b; a<=c; a++)
using namespace std;

int n, act[100001][3], dp[100001][3];

int main() {
	cin>>n;
	ffor (i, 1, n) cin>>act[i][0]>>act[i][1]>>act[i][2];
	ffor (i, 1, n) {
		ffor (j, 0, 2) {
			ffor (k, 0, 2) {
				if (j!=k) dp[i][j] = max(dp[i][j], dp[i-1][k]+act[i][j]);
			}
		}
	}
	// ffor (i, 1, n) {
	// 	ffor (j, 0, 2) {
	// 		cout<<dp[i][j]<<" ";
	// 	} cout<<endl;
	// }
	cout<<max(dp[n][0],max(dp[n][1], dp[n][2]))<<endl;
}

Measured memory_bytes: 2560
n = int(input())
li = []
for i in range(n):
    x = int(input())
    li.append(x)
p = max(li)
r = li.index(p)
li.remove(p)
q = max(li)
for i in range(n):
    if i == r:
        print(q)
    else:
        print(p)

Measured memory_bytes: 12520
#include <iostream>
#include <atcoder/all>
using namespace std;
using z=long long;
int main(){z N,Q;cin>>N>>Q;atcoder::fenwick_tree<z> b(N);for(z i=0;i<N;i++){z a;cin>>a;b.add(i,a);}for(z i=0;i<Q;i++){z w,e,r;cin>>w>>e>>r;if(w)cout<<b.sum(e,r)<<endl;else b.add(e,r);}}


Measured memory_bytes: 8224
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>



int main() {
	int H, W;
	scanf("%d %d", &H, &W);
	char **s = new char*[H];
	for (int i = 0; i < H; i++) {
		s[i] = new char[W + 1];
	}
	for (int i = 0; i < H; i++) {
		scanf("\n%s", s[i], W + 1);
	}
	int res = 0;
	int **cx = new int*[H];
	int **cy = new int*[H];
	for (int y = 0; y < H; y++) {
		cx[y] = new int[W];
		cy[y] = new int[W];
		for (int x = 0; x < W; x++) {
			if (s[y][x] == '#') continue;
			if (x != 0 && s[y][x - 1] == '.') {
				cx[y][x] = cx[y][x - 1];
			}
			else {
				cx[y][x] = 1;
				for (int i = x + 1; i < W; i++) {
					if (s[y][i] == '#')break;
					else cx[y][x]++;
				}
			}
			if (y != 0 && s[y - 1][x] == '.') {
				cy[y][x] = cy[y - 1][x];
			}
			else {
				cy[y][x] = 1;
				for (int i = y + 1; i < H; i++) {
					if (s[i][x] == '#')break;
					else cy[y][x]++;
				}
			}
			if (res < cx[y][x] + cy[y][x] - 1)res = cx[y][x] + cy[y][x] - 1;
		}
	}
	printf("%d", res);
}



Measured memory_bytes: 35584
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x;
    int cnt=8;
    
    scanf("%d", &x);
    
    for (int i=400; i<2000; i=i+200) {
        if (x>=i&&x<=i+199) {
            printf("%d", cnt);
        }else {
            cnt--;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

int main(void) 
{
	string s;
	int w;
	cin >> s >> w;


	for (int i=0;i<SZ(s);i+=w)
	{
		printf("%c",s[i]);
	}
	printf("\n");


	return 0;
}


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

using namespace std;

struct p{
	int l;
	int r;
}a[1000000];

bool cmp(p xx,p yy){
	return xx.l>yy.l;
}

int main(){
	int n,h;
	int c=0;
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[c++].l);
		a[c].r=1;
		scanf("%d",&a[c++].l);
	}
	sort(a,a+c,cmp);
	int sum=0;
	for(int i=0;i<c;i++)
	{
		if(a[i].r==1)
		{
			sum++;
			h-=a[i].l;
			if(h<=0)
			{
				printf("%d",sum);
				return 0;
			}
		}
		else if(a[i].r!=1)
		{
			if(h%a[i].l==0) sum+=h/a[i].l;
			else sum+=h/a[i].l+1;
			printf("%d",sum);
			return 0;
			
		}
	}
}

Measured memory_bytes: 1920
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 22500000
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int f[maxn+5];
void init()
{
	int l=1,r=10;
	for(int i=1;i<=7;i++)
	{
		for(int j=l;j<=r-1;j++)
			f[j]=i;
		l*=10; r*=10;
	}
	for(int i=l;i<=maxn;i++)
		f[i]=8;
}
ll s;
ll solve1()
{
	int l=1,r=0;
	ll res=0,now=0;
	while(l<10000000)
	{
		while(r<maxn &&  now<s)
			r++,now+=f[r];
		if(now==s)
			(res=(res+1)%mod);
		now-=f[l];
		l++;
	}
//	cerr<<res<<endl;
	return res;
}
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
ll solve2()
{
	ll maxx=s/8,res=maxx;
	for(int i=1;i<=maxx;i++)
	{
		if(s%i==0)
		{
			int len=s/i;
			ll temp=9ll*quickpow(10,len-1)%mod;
			temp=(temp+mod-i)%mod;
			res=(res+temp)%mod;
		}
	}
	return res;
}
int main()
{
	init();
	scanf("%lld",&s);
	printf("%lld\n",(solve1()+solve2())%mod);
}


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

int main()
{
    int a, b, c, d, in;
    cin >> in;
    a = in / 1000;
    b = (in / 100) % 10;
    c = (in / 10) % 10;
    d = in % 10;
    string op1, op2, op3;
    if(a + b + c + d == 7){
        op1 = "+";
        op2 = "+";
        op3 = "+";
    }
    if(a - b + c + d == 7){
        op1 = "-";
        op2 = "+";
        op3 = "+";
    }
    if(a + b - c + d == 7){
        op1 = "+";
        op2 = "-";
        op3 = "+";
    }
    if(a + b + c - d == 7){
        op1 = "+";
        op2 = "+";
        op3 = "-";
    }
    if(a - b - c + d == 7){
        op1 = "-";
        op2 = "-";
        op3 = "+";
    }
    if(a - b + c - d == 7){
        op1 = "-";
        op2 = "+";
        op3 = "-";
    }
    if(a + b - c - d == 7){
        op1 = "+";
        op2 = "-";
        op3 = "-";
    }
    if(a - b - c - d == 7){
        op1 = "-";
        op2 = "-";
        op3 = "-";
    }
    cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define ss second
#define pp pop_back
#define in insert
#define ld long double
#define sz(v) (int)v.size()
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " "
#define endl '\n'
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define lmax 9223372036854775807
#define v3(type, v, x, y, z) vector<vector<vector<type>>> v(x, vector<vector<type>>(y, vector<type>(z)))
#define v2(type, v, n, m) vector<vector<type>> v(n, vector<type>(m))

const ll MOD=1e9+7;
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vpii;
typedef vector<pll > vpll;


inline ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = (n%p) * (n%p) % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}


int main()
{
	ll i,j,n,m,k,ans,t=1;
	// cin>>t;
	while(t--)
	{
		cin>>n>>m>>k;
		cout<<k<<" "<<n<<" "<<m<<endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long N;
    cin >> N;
    
    long long A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    long long min_move = min(A, min(B, min(C, min(D, E))));

    long long cnt = 4;
    cnt += (N + min_move - 1) / min_move;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256