akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

ll check(ll i, ll T1, ll T2, ll V1, ll V2) {
	ll y1 = i * (T1 * V1 + T2 * V2);
	ll y2 = y1 + T1 * V1;
	ll y3 = y2 + T2 * V2;
	ll cnt = 0;

	if(sign(y1) * sign(y2) < 0) {
		++cnt;
	}

	if(sign(y2) * sign(y3) < 0) {
		++cnt;
	}

	cnt += (y1 == 0);
	cnt += (y2 == 0);
	cnt += (y3 == 0);

	return cnt;
}

void solve() {
	ll T1 = fetch<ll>();
	ll T2 = fetch<ll>();
	ll A1 = fetch<ll>();
	ll A2 = fetch<ll>();
	ll B1 = fetch<ll>();
	ll B2 = fetch<ll>();

	ll V1 = A1 - B1;
	ll V2 = A2 - B2;

	if(V1 == 0) {
		cout << "infinity\n";
		return;
	}

	if(V1 != 0 && V2 == 0) {
		cout << "0\n";
		return;
	}

	ll value = T1 * V1 + T2 * V2;

	if(value == 0) {
		cout << "infinity\n";
		return;
	}

	if(value < 0) {
		V1 = -V1;
		V2 = -V2;
	}

#ifdef __LOCAL
	for(ll i = 0;; ++i) {
		ll x;
		cout << (x = check(i, T1, T2, V1, V2)) << ' ';

		if(x == 0) {
			break;
		}
	}

	cout << '\n';
#endif

	ll low = 0, high = 1;

	if(check(low, T1, T2, V1, V2) <= 1) {
		cout << "0\n";
		return;
	} 

	while(check(high, T1, T2, V1, V2) > 1) {
		high += high;
	}

	while(high - low > 1) {
		ll mid = (low + high) / 2;

		if(check(mid, T1, T2, V1, V2) > 1) {
			low = mid;
		} else {
			high = mid;
		}
	}

	ll answ = 2 * (low + 1);

	while(true) {
		ll to_add = check(high, T1, T2, V1, V2);

		if(to_add == 0) {
			break;
		} else {
			answ += to_add;
			++high;
		}
	}

	cout << answ - 1 << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n%10==3){
        printf("bon");
        return 0;
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        printf("pon");
        return 0;
    }
    printf("hon");
    return 0;
}

Measured memory_bytes: 1728
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

seq_list = {}
i = 1
for seq in itertools.permutations(range(1, n+1), n):
    seq_list['_'.join(map(str, seq))] = i
    i += 1

a = seq_list['_'.join(map(str, p))]
b = seq_list['_'.join(map(str, q))]
print(abs(a-b))


Measured memory_bytes: 8520
N, M = gets.split.map(&:to_i)
uv_list = M.times.map { gets.split.map(&:to_i) }
S, T = gets.split.map(&:to_i)

node_list = Array.new(N)
uv_list.each do |(u, v)|
  node_list[u] ||= []
  node_list[u].push(v)
end

visit = {}
queue = [[S, 0]]
INF = 2 << 60
min = INF
while !queue.empty?
  a, d = queue.shift
  if visit[[a, d % 3]] && visit[[a, d % 3]] <= d / 3
    next
  end
  visit[[a, d % 3]] = d / 3
  if d % 3 == 0 && a == T
    min = d if d < min
    next
  end
  next_d = d + 1
  (node_list[a] || []).each do |v|
    queue.push([v, next_d])
  end
end
puts(min == INF ? -1 : min / 3)


Measured memory_bytes: 51348
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n, m;
pi a[MAXN];
int dp[MAXN][3][3];

void solve(){
	if(n == 2){
		puts("-1");
		return;
	}
	for(int i=0; i<3; i++){
		for(int j=0; j<i; j++){
			dp[m][i][j] = 1;
			dp[m][j][i] = 1;
		}
	}
	for(int i=m-1; i>=0; i--){
		if(a[i].second >= 3){
			memcpy(dp[i], dp[i + 1], sizeof(dp[i]));
			continue;
		}
		for(int j=0; j<3; j++){
			for(int k=0; k<j; k++){
				if(pi(k, j) == a[i]) continue;
				if(j == a[i].first || j == a[i].second){
					dp[i][j][k] |= dp[i + 1][j][k];
					dp[i][j][k] |= dp[i + 1][a[i].first + a[i].second - j][k];
				}
				if(k == a[i].first || k == a[i].second){
					dp[i][j][k] |= dp[i + 1][j][k];
					dp[i][j][k] |= dp[i + 1][a[i].first + a[i].second - k][j];
				}
				dp[i][k][j] = dp[i][j][k];
			}
		}
	}
	int px = -1, py = -1;
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			if(dp[0][i][j]){
				px = i, py = j;
			}
		}
	}
	if(px == -1) assert(0);
	for(int i=0; i<m; i++){
		if(a[i].second >= 3){
			putchar('^');
			continue;
		}
		int j = px, k = py;
		if(j == a[i].first || j == a[i].second){
			bool val = (j == a[i].first) ^ (!dp[i + 1][j][k]);
			if(!val){
				putchar('v');
				if(j == a[i].first) j = a[i].second;
			}
			else{
				putchar('^');
				if(j == a[i].second) j = a[i].first;
			}
		}
		else if(k == a[i].first || k == a[i].second){
			bool val = (k == a[i].first) ^ (!dp[i + 1][j][k]);
			if(!val){
				putchar('v');
				if(k == a[i].first) k = a[i].second;
			}
			else{
				putchar('^');
				if(k == a[i].second) k = a[i].first;
			}
		}
		else putchar('^');
		px = j;
		py = k;
	}
	puts("");
}

bitset<50005> bs[50005];

void report(int x){
	bool chk[MAXN] = {};
	char ans[MAXN] = {};
	chk[x] = 1;
	for(int i=m-1; i>=0; i--){
		if(chk[a[i].first] == chk[a[i].second]){
			ans[i] = '^';
			continue;
		}
		if(chk[a[i].first]) ans[i] = '^';
		else ans[i] = 'v';
		chk[a[i].first] = chk[a[i].second] = 1;
	}
	cout << ans << endl;
}

int main(){
	int t;
	scanf("%d %d %d",&n,&m,&t);
	for(int i=0; i<m; i++){
		scanf("%d %d",&a[i].first,&a[i].second);
		a[i].first--;
		a[i].second--;
	}
	if(t == 1){
		for(int i=0; i<n; i++) bs[i].set(i);
		for(int i=0; i<m; i++){
			bs[a[i].first] = bs[a[i].second] = (bs[a[i].first] | bs[a[i].second]);
		}
		for(int i=0; i<n; i++){
			if(bs[i].count() == n){
				report(i);
				return 0;
			}
		}
		puts("-1");
		return 0;
	}
	if(t == 2){
		solve();
		return 0;
	}
}


Measured memory_bytes: 310400
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    ll l;
    cin>>l;
    cout<<sp(12)<<(l*l*l)/(double)27<<endl;



return 0;

}


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

void fail(){
    cout << -1 << endl;
    exit(0);
}

int main(){
    int i, j, k;
    string S;
    cin >> S;
    int N = S.size();
    S = ' ' + S;
    
    for(i=1; i<N; i++){
        if(S[i] != S[N-i]) fail();
    }
    if(S[1] == '0' || S[N] == '1') fail();

    int top = 1;
    for(i=1; i<N; i++){
        printf("%d %d\n", top, i+1);
        if(S[i] == '1') top = i+1;
    }
    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
using namespace std;
const int maxn = 3010;
double a[maxn];
double dp[maxn][maxn];
int main ()
{
    int n;
    cin>>n;

    fori(i,0,n-1) cin>>a[i];

    dp[0][0] = 1;
    fori(i,1,n)
    {
        dp[i][0] = (1.0-a[i]);
        dp[0][i] = 0.0;
    }

    fori(i,1,n)
    {
        fori(j,0,n)
        {
            if (j==0)
            {
                // bat dau tu 0;
                dp[i][j] = (1.0-a[i-1])*dp[i-1][j];
            }
            else
            {
                dp[i][j] = a[i-1]*dp[i-1][j-1] + (1.0-a[i-1])*dp[i-1][j];
            }
        }
    }
    double ans=0.0;
    fori(i,n/2+1,n)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b) {
        return a.second < b.second;
    });
    int time = 0;
    for (auto x: v) {
        time += x.first;
        if(time > x.second){
            cout <<"No";
            return;
        }
    }
    cout << "Yes";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3328
H, W = list(map(int, input().split()))

if H ==1 or W ==1:
  print(1)
else:

  if H*W % 2 == 0:
    print(H*W//2)
  elif H % 2 == 1 and W % 2 ==1:
    print(int(H*W/2) +1)

  

Measured memory_bytes: 2940
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, T = ni()
    val c, t = Array.ofDim[Int](N)
    rep(N) { i =>
      c(i) = ni()
      t(i) = ni()
    }

    var ms = 1001
    rep(N) { i =>
      if (t(i) <= T) ms = min(ms, c(i))
    }

    if (ms == 1001) out.println("TLE")
    else out.println(ms)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 3e5 + 10, X_NUM = 2;
const ll MOD = 1e9 + 7;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

vector<ll> values_x = {100, 10000};
vector<ll> values_invx;
vector<pair<ll, ll>> revert[MAX_N];
vector<ll> digest[MAX_N];

int N;
char S[MAX_N];
map<vector<ll>, int> occur;
ll ans;

void init() {
    scanf("%d", &N); scanf("%s", S + 1);
    for (int i = 0; i < X_NUM; i++) values_invx.push_back(inv(values_x[i]));
    for (int i = 0; i < X_NUM; i++) {
        ll v = 0, px = 1;
        for (int j = 1; j <= N; j++) {
            switch (S[j]) {
            case '<': {
                (px *= values_invx[i]) %= MOD;
            }; break;
            case '>': {
                (px *= values_x[i]) %= MOD;
            }; break;
            case '+': {
                (v += px) %= MOD;
            }; break;
            case '-': {
                (v += MOD - px) %= MOD;
            }; break;
            }
            digest[j].push_back(v);
        }
    }
    for (int i = 0; i < X_NUM; i++) {
        ll a = 1, b = 0; // ax + b
        revert[0].emplace_back(a, b);
        for (int j = 1; j <= N; j++) {
            switch (S[j]) {
            case '<': {
                (a *= values_x[i]) %= MOD;
                (b *= values_x[i]) %= MOD;
            }; break;
            case '>': {
                (a *= values_invx[i]) %= MOD;
                (b *= values_invx[i]) %= MOD;
            }; break;
            case '+': {
                (b += MOD - 1) %= MOD;
            }; break;
            case '-': {
                (b += 1) %= MOD;
            }; break;
            }
            revert[j].emplace_back(a, b);
        }
    }
    for (int i = 1; i <= N; i++)
        occur[digest[i]]++;
}

void solve() {
    for (int i = 0; i < N; i++) {
        vector<ll> target;
        for (int j = 0; j < X_NUM; j++) {
            ll t = (digest[N][j] - revert[i][j].second + MOD) * inv(revert[i][j].first) % MOD;
            target.push_back(t);
        }
        ans += occur[target];
        occur[digest[i + 1]]--;
    }
    printf("%lld\n", ans);
}

int main() {
    init();
    solve();
}


Measured memory_bytes: 88704
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('Inf')] * n
dp[0] = 0

for i in range(n):
    for j in range(i+1, i+k+1):
        if j < n:
            dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]))
            
print(dp[-1])

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

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

typedef pair<int,pair<pair<int,int>,int>> PACK;

int main(){
  int w,h;
  while(cin>>w>>h,w){
    vector<vector<int>> s(h,vector<int>(w));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>s[i][j];
      }
    }
    vector<int> c(4);
    for(int i=0;i<4;i++){
      cin>>c[i];
    }
    const int INF=1e8;
    vector<vector<vector<int>>> dp(h,vector<vector<int>>(w,vector<int>(4,INF)));
    dp[0][0][0]=0;
    priority_queue<PACK,vector<PACK>,greater<PACK>> que;
    que.push(make_pair(0,make_pair(make_pair(0,0),0)));

    auto isrange=[w,h](int x,int y){return 0<=x && x<h && 0<=y && y<w;};
      
    int res=1e9;
    while(!que.empty()){
      auto buf=que.top();
      que.pop();
      int cost=buf.first;
      auto state=buf.second;
      pair<int,int> place=state.first;
      int dir=state.second;
      if(place.first==h-1 && place.second==w-1){
	res=cost;
	break;
      }
      if(cost>dp[place.first][place.second][dir]){
	continue;
      }
      int pat;
      if((pat=s[place.first][place.second])!=4){
	int todir=(dir+pat)%4;
	int tox=place.first+dx[todir];
	int toy=place.second+dy[todir];
	if(isrange(tox,toy) && dp[tox][toy][todir]>cost){
	  dp[tox][toy][todir]=cost;
	  auto tostate=make_pair(make_pair(tox,toy),todir);
	  auto quing=make_pair(cost,tostate);
	  que.push(quing);
	}
      }
      for(int i=0;i<4;i++){
	int todir=(dir+i)%4;
	int tox=place.first+dx[todir];
	int toy=place.second+dy[todir];
	if(isrange(tox,toy) && dp[tox][toy][todir]>cost+c[i]){
	  dp[tox][toy][todir]=cost+c[i];
	  auto tostate=make_pair(make_pair(tox,toy),todir);
	  auto quing=make_pair(dp[tox][toy][todir],tostate);
	  que.push(quing);
	}
      }
    }

    cout<<res<<endl;
  }

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector< int > a(A), b(B);
	vector< int > x(M), y(M), c(M);
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	rep(i, M) cin >> x[i] >> y[i] >> c[i];
	int ans = LINF;
	int amin = LINF, bmin = LINF;
	rep(i, A) chmin(amin, a[i]);
	rep(i, B) chmin(bmin, b[i]);
	chmin(ans, amin + bmin);
	rep(i, M) {
		chmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

const int N = 1010;
const int mo = 1e+9+7;

int pri[N],k;
int f[N],n;
bool bz[N];
int w[N];

int main(){
	scanf("%d",&n);
	fo(i,2,n)
	if (!bz[i]){
		pri[++k]=i;
		fo(j,2,n/i)bz[i*j]=1;
	}
	fo(i,1,n){
		int x=i;
		fo(j,1,k){
			while(x%pri[j]==0){
				x/=pri[j];
				w[j]++;
			}
		}
	}
	int ans=1;
	fo(i,1,k)
	ans=1ll*ans*(w[i]+1)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ int a,b,s[100000],i,sum=0;
scanf("%d %d",&a,&b);
for(i=0;i<b;i++)
	{scanf("%d",&s[i]);
sum+=s[i];
}
if(sum>=a) printf("Yes");
else printf("No");
return 0;
}

Measured memory_bytes: 512
s = input()
str1 = int(s[0:2])
str2 = int(s[2:])

if (1 <= str1 <= 12) and (1 <= str2 <= 12):
    print('AMBIGUOUS')
elif (0 <= str1 <= 99) and (1 <= str2 <= 12):
    print('YYMM')
elif (1 <= str1 <= 12) and (0 <= str2 <= 99):
    print('MMYY')
else:
    print("NA")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,k,s;cin>>n>>k>>s;
    rep(i,k)cout<<s<<' ';
    ll l;
    if(s==1e9)l=1e9-1;
    else l=s+1;
    rep(i,n-k)cout<<l<<' ';
    cout<<endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  double a = 0;
  rep (i, N) {
    double tmp = 1;
    a += tmp / A[i];
  }
  double tmp = 1;
  double result = tmp / a;
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
static const int N = 3;
static const int N2 = 9;
static const char dir[4] = { 'u', 'r', 'd', 'l' };

struct Puzzle {
    int f[N2]; // f[i] = i+1となっているときに答え
    int space; // 0がある場所の添字
    string path; // 移動を文字列で管理している
    bool operator<(const Puzzle& p) const
    {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) {
                continue;
            }
            return f[i] > p.f[i];
        }
        return false;
    }
};

// このパズルが答えであるとき
bool isTarget(Puzzle p)
{
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != (i + 1)) {
            return false;
        }
    }
    return true;
}

string bfs(Puzzle s)
{
    queue<Puzzle> Q; // パズルをキューに入れる(深さ幅優先なので)
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true; // 入力の写像をtrue(探索済み)にする

    while (!Q.empty()) {
        u = Q.front(); // 一番最初に入れたキューの中身をセット
        Q.pop();
        if (isTarget(u)) { //もしターゲットなら移動の順序を返す
            return u.path;
        }
        // スペースのある位置は(sx, sy)
        int sx = u.space / N;
        int sy = u.space % N;

        rep(r, 4)
        {
            // スペースの移動先の場所を(tx, ty)
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            // もし枠の外に移動していたら無視
            if (tx < 0 || ty < 0 || tx >= N || ty >= N) {
                continue;
            }
            // u: 移動前の盤, v: 移動後の盤
            v = u;
            // コマを交換
            v.space = tx * N + ty; // 新しいスペースの置き場所
            swap(v.f[u.space], v.f[v.space]);
            if (!V[v]) {
                V[v] = true; // vを探索済みにする
                v.path += dir[r]; // 経路を追加する
                Q.push(v); // 探索済みの経路をQに追加する
            }
        }
    }

    return "unsolvable";
}

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

    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2; // スペースを9として扱う
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
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 int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}


signed main(){
    LCIN(N,K);
    ll cls;
    if(N>K){
        N=N%K;
    }
    while(1){
        cls=abs(N-K);
        if(N>cls){
            N=cls;
        }else{
            break;
        }
    }
    printf("%lld\n",N);    

    return 0;
}

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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  if(N+M+X>21){
    cout << "bust";
  }
  else{
    cout << "win";
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long double ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll d,t,s;
    cin >> d>>t>>s;
    if(t >= (d/s))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3740
import kotlin.math.min

fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val s = List(h) { readString() }

    val dp = MutableList(h) { MutableList(w) { Int.MAX_VALUE } }
    dp[0][0] = if (s[0][0] == '#') {
        1
    } else {
        0
    }

    val dx = listOf(1, 0)
    val dy = listOf(0, 1)
    for (i in 0 until h) {
        for (j in 0 until w) {
            for (dir in 0..1) {
                val ni = i + dx[dir]
                val nj = j + dy[dir]
                
                if (ni >= h || nj >= w) continue
                
                val add = when {
                    s[ni][nj] == '#' && s[i][j] == '.' -> 1
                    else -> 0
                }
                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add)
            }
        }
    }
    println(dp[h - 1][w - 1])
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

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

int main() {
    int n, m;
    int l_max = 0, r_min = 100001;
    int l_tmp, r_tmp;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> l_tmp >> r_tmp;
        if (l_tmp > l_max)
            l_max = l_tmp;
        if (r_tmp < r_min)
            r_min = r_tmp;
    }
    int num = r_min >= l_max ? r_min - l_max + 1 : 0;
    cout << num << endl;

    return 0;
}


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

int avd(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
int main() {
	
	const int MOD = 1000000007;

	int N, M;
	long long int tmp = 1;
	cin >> N >> M;

	if (N == M) {

		for (int i = N; i >= 1; i--)tmp = (tmp*i) % MOD;
		tmp = (tmp*tmp) % MOD;
		tmp = (tmp * 2) % MOD;
		cout << tmp << endl;

	}
	else if (avd(N, M) == 1) {

		for (int i = min(N, M); i >= 1; i--)tmp = (tmp*i) % MOD;
		tmp = (tmp*tmp) % MOD;
		tmp = (tmp*(min(N, M) + 1)) % MOD;
		cout << tmp << endl;

	}
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<Integer, Integer> m = new HashMap<>();
		for(int i=0; i<N; i++) {
			int d = sc.nextInt();
			if(m.containsKey(d)) {
				m.put(d, m.get(d)+1);
			} else {
				m.put(d, 1);
			}
		}
		int M = sc.nextInt();
		for(int i=0; i<M; i++) {
			int t = sc.nextInt();
			if(!m.containsKey(t)) {
				System.out.println("NO");
				return;
			} else {
				if(m.get(t) == 0) {
					System.out.println("NO");
					return;
				} else {
					m.put(t, m.get(t)-1);
				}
			}
		}
		System.out.println("YES");
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 136844
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s.length() < 26) {
        map<char,ll> m;
        for (ll i = 0;i < s.length();i++) {
            m[s[i]] = 1;
        }
        for (ll i = 0;i < 26;i++) {
            if (m[(char)('a'+i)] == 0) {
                s += (char)('a' + i);
                break;
            }
        }
        cout << s << "\n";
    } else {
        s += '0';
        if (next_permutation(s.begin(),s.end())) {
            for (ll i = 0;s[i] != '0';i++) {
                cout << s[i];
            }
            cout << "\n";
        } else {
            cout << -1 << "\n";
        }
    }
}

Measured memory_bytes: 256
Tree = {}
Parents = {}
n = gets.to_i
n.times do
  i, _, *c = gets.split(' ').map(&:to_i)
  c.each do |m|
    Parents[m] = i
  end
  Tree[i] = c
end
Tree.sort.each do |i, n|
  if Parents[i].nil?
    t = 'root'
  elsif n.empty?
    t = 'leaf'
  else
    t = 'internal node'
  end
  p = t == 'root' ? -1 : Parents[i]
  depth = -> (d, j) do
    return d if Parents[j].nil?
    return depth.(d + 1, Parents[j])
  end
  puts "node #{i}: parent = #{p}, depth = #{depth.(0, i)}, #{t}, #{n.inspect}"
end


Measured memory_bytes: 32668
#include <stdio.h>
#include <stdlib.h>

const int N = 10000;

int main (void)
{
	int n , m;
	int i , j;
	while(scanf("%d %d" , &n , &m))
	{
		int ok = 1 , go = 0;
		if(n == 0 && m == 0)
		{
			return 0;
		}
		for(i = 0 ; i < n ; i++)
		{
			//printf("%d" , i);
			if(ok)
			{
				go = 1;
				for(j = 0; j < m ; j++)
				{
					if(go)
					{
						printf("#");
						go = 0;
					}
					else
					{
						printf(".");
						go = 1;
					}
				}
				printf("\n");
				ok = 0;
			}
			else
			{
				go = 0;
				for(j = 0; j < m ; j++)
				{
				
					if(go)
					{
						printf("#");
						go = 0;
					}
					else
					{
						printf(".");
						go = 1;
					}
				}
				printf("\n");
				ok = 1;
				//system("pause");
			}
			//system("pause");
		}
		printf("\n");
	}
} 


Measured memory_bytes: 2100
n = int(input())
d = sorted(map(int,[input() for i in range(n)]),reverse = True)
#list d 内の要素間で大きさを比較して同じ数である数aを数える。
a = 0
ans = 0
#
if n != 1:
     for j in range(n-1):
         if d[j]==d[j+1]:
             a+=1

ans = n - a
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int f1, f2, temp, m[10];
	for(f1 = 0; f1 < 10; f1++)
	{
		scanf("%d",&m[f1]);
	}
	for(f1 = 0; f1 < 9; f1++)
	{
		for(f2 = f1 + 1; f2 < 10; f2++)
		{
			if(m[f1] < m[f2]){
				temp = m[f1];
				m[f1] = m[f2];
				m[f2] = temp;
			}
		}
	}
	for(f1 = 0; f1 < 3; f1++)
	{
		printf("%d\n",m[f1]);
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (s.charAt(i) == 'R') {
				ans++;
			}
		}
		if (s.equals("RSR")) {
			ans = 1;
		}
		System.out.println(ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(),(a).rend())
#define ll long long
#define pb(a) push_back(a)

#define PRINTV(v) {for(ll deB=0; deB<(v).size(); deB++){cout << (v)[deB] << " ";}cout << endl;}

int main(){
	
	
	ll N;
	cin >> N;
	cout << ((N%1000 == 0)?0:1000-(N%1000)) << endl;
	
	return 0;

abnormal:
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

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

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

    int count = 0;
    REP(i, N){
        int ai;
        cin >> ai;
        if(((i+1) % 2 == 1) and (ai % 2 == 1)){
            count += 1;
        }
    }


    cout << count << endl;

    return 0;
}


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

using namespace std;

#define int64 long long 
#define fi first
#define se second
const int mod = (int) 1e9 + 7;

const int nax = 2e5 + 5;


void test_case(){
	int64 n;
	cin >> n;
	if(n < 2){
		cout<<"0";
		return;
	}
	int64 ans = 1;
	int64 t = 1, ni = 1, e = 1;
	for(int i=0; i<n; i++){
		t = (t * 10LL)%mod;
		ni = (ni * 9LL)%mod;
		e = (e * 8LL)%mod;
	}
	ni = (2LL * ni)%mod;
	ans = (t - ni + e)%mod;
	ans = (ans + mod)%mod;
	//ans = (ans * n)%mod;
	//ans = (ans*(n-1))%mod;
	cout<<ans;
}

int main(){
	int t=1;
	//cin>>t;
	while(t--){
		test_case();
	}
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a < b) {
        return gcd(b, a);
    }
    int c;
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    for (int x = lcm(A, B); x >= A; x -= A) {
        if (x % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
string s;
int main(){
	cin>>s;
	if(s=="ABC")cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int     main(void)
{
    int a, b, i;

    i = scanf("%d %d", &a, &b);
    for (i = 0; i <= 1009; i++) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            printf("%d", i);
            return 0;
        }
    }
    printf("-1");
    return (0);
}

Measured memory_bytes: 128
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)

	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	Nstr := strings.Split(s, " ")[0]
	N, _ := strconv.Atoi(Nstr)

	a, _ := strconv.Atoi(strings.Split(s, " ")[1])
	b, _ := strconv.Atoi(strings.Split(s, " ")[2])

	var sumSumValue int
	for i := 0; i < N+1; i++ {
		var sumValue int
		for _, ns := range strings.Split(strconv.Itoa(i), "") {
			tmp, _ := strconv.Atoi(ns)
			sumValue += tmp
		}
		if sumValue >= a && sumValue <= b {
			sumSumValue += i
		}
	}

	fmt.Println(sumSumValue)
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i< n; i++) cin >> a[i];

  vector<int> b = a;
  sort(b.rbegin(), b.rend());
  for(int i=0; i < n; i++){
    int ans = b[0];
    if(b[0] == a[i]) ans = b[1];
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;



int N;
vector<int> hist; // カードの分布

/*
	異なる数字からなるk枚の組を、e列作成することを考える。
	Ai を、横kマス 縦eマス に並べたい。
	
	方法
		Aをソートする
		Aを先頭から取り出し、左上から左下に向かって埋めていく。
		同じ数字がe個連続したら、それ以降の同じ数字は捨てる
	
	
	Aとkが与えられたとき、k*eを埋め尽くせるeの最大値 をどうやって求めるか?
	Aのヒストグラム hist[i]
	捨てた数 T = Σmax(0,hist[i]-e)
	N - T >= k*e の場合に埋め尽くすことができる。
	
	N - Σmax(0,hist[i]-e)) >= k*e
	
	0 < e <= N の全てのeに対して kk[e] = (N-Σmax(0,hist[i]-e)))/e を計算しておく。
	各k に対し kk[e] >= k となる最大のeを探す
*/


int main(){
	cin >> N;
	hist.resize(N);
	for ( int i = 0; i < N; i++ ){
		int A;
		cin >> A;
		hist[A-1]++;
	}
	sort( hist.begin(), hist.end(), greater<int>() );
	
	vector<int> kk(N+1);
	{
		int acc = 0;
		int i = 0;
		for ( int e = N; e >= 1; e-- ){
			while ( e < hist[i] && i < N )
				i++;
			acc += i;
			kk[e] = (N-acc)/e;
			
			//cout << " e=" << e << " acc=" << acc << " kk[e]=" << kk[e] << endl;
		}
		kk[0] = INT_MAX;
	}
	
	int e = N;
	for ( int k = 1; k <= N; k++ ){
		while ( kk[e] < k )
			e--;
		cout << e << endl;
	}
	
	return 0;
}



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

cnt=[0]*(10**5+1)

for i in a:
  cnt[i]+=1

xxx=sum(a)

q=int(input())

for i in range(q):
  l,r=map(int,input().split())
  pin=cnt[l]
  cnt[r]+=pin
  cnt[l]=0

  xxx+=(r-l)*pin

  print(xxx)

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

template<typename T>
T modpower(T a, T n, T mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int p = 2019;
    ll res = 0;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int> m(s.size() + 1);
    map<int, int> mp;
    rep (i, s.size()) m[i + 1] = (s[i] - '0') * modpower(10, i, p) % p;
    FOR (i, 1, s.size() + 1) {
        m[i] += m[i - 1];
        m[i] %= p;
    }
    rep (i, s.size() + 1) {
        res += mp[m[i]];
        mp[m[i]]++;
    }
    cout << res << endl;

    return 0;
}



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

int conv(int ch, int a, int b) {
  if ( !isalpha(ch) ) return ch;
  int n = ch - 'a';
  return (char)('a' + (a * n + b) % 26);
}

int valid(int a, int b) {
  int count[26] = {};
  for(int n = 0; n < 26; n++) {
    if ( ++count[conv(n + 'a', a, b) - 'a'] >= 2 )
      return 0;
  }
  return 1;
}

int check(string line, int a, int b) {
  if ( !valid(a, b) ) return 0;

  for(int i = 0; i < (int)line.size(); i++)
    line[i] = conv(line[i], a, b);

  return line.find("that") != string::npos ||
    line.find("this") != string::npos;
}

int main() {
  int T; cin >> T >> ws;
  while(T--) {
    string line;
    getline(cin, line);

    for(int a = 0; a < 26; a++)
      for(int b = 0; b < 26; b++) {
        int res = check(line, a, b);
        if ( res ) {
          for(int i = 0; i < (int)line.size(); i++)
            cout << (char)conv(line[i], a, b);
          cout << endl;
        }
      }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int (i) = (a);(i) < (b);(i)++)
#define Rep(i,n) For(i,0,n)
#define All(a) (a).begin(),(a).end()
#define sp " "
#define Rev(s,a,b) reverse((s).begin()+(a),(s).begin()+(b)+1)//s[a]....s[b] rev

vector<char> boin = {'a','i','u','e','o'};
typedef long long ll;

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> cake(h,vector<char>(w));
    vector<vector<int>> ans(h,vector<int>(w,-1));
    vector<int> st(h,0);
    Rep(i,h){
        Rep(j,w){
            cin >> cake[i][j];
            if(cake[i][j] == '#')st[i]++;
        }
    }
    int cnt = 0;
    int div = 0;
    for(int i = 0;i < h;i++){
        div = 0;
        if(st[i] == 0)continue;
        else cnt++;
        for(int j = 0;j < w;j++){
            ans[i][j] = cnt;
            if(cake[i][j] == '#'){
                cnt++;
                div++;
                if(div == st[i])cnt--;
            }
        }
    }
    
    /*Rep(i,h){
        Rep(j,w){
            cout << ans[i][j] << sp;
        }
        cout << endl;
    }*/

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(ans[i][j] == -1){
                if(i == 0){
                    for(int k = 0;;k++){
                        if(ans[k][j] != -1){
                            for(int l = k-1;l >= 0;l--)ans[l][j] = ans[k][j];
                            break;
                        }
                    }
                }else{
                    for(int k = i;;k--){
                        if(ans[k][j] != -1){
                            for(int l = k;l <= i;l++)ans[l][j] = ans[k][j];
                            break;
                        }
                    }
                }
            }
        }
    }
    Rep(i,h){
        Rep(j,w){
            cout << ans[i][j] << sp;
        }
        cout << endl;
    }
    //cin >> k;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 998244353;

string S;
int K;
vector<int> v;

ll dp[305][305][605];

ll buf0[605][605];
ll buf1[605][605];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> S >> K;
    int cnt = 0;
    int sum = 0;
    for(char c : S){
        if(c == '0'){
            v.push_back(cnt);
            cnt = 0;
        }else{
            cnt++;
            sum++;
        }
    }
    if(cnt != 0) v.push_back(cnt);
    K = min(K, (int)S.size());
    dp[0][0][0] = 1;
    int tmp = 0;
    int sz = v.size();
    for(int i = 0; i < v.size(); i++){
        for(int j = 0; j <= 300; j++){
            for(int k = 0; k <= 600; k++){
                buf0[j][k] = 0;
                buf1[j][k] = 0;
            }
        }
        for(int j = 0; j <= tmp+K; j++){
            for(int k = 0; k <= 2*K; k++){
                if(dp[i][j][k] == 0) continue;
                // [0, v[i]]
                int l = max(tmp+v[i], j);
                buf0[l][k+v[i]+j-l] += dp[i][j][k];
                buf0[l][k+v[i]+j-l] %= MOD;
                buf0[j+v[i]+1][k-1] -= dp[i][j][k];
                buf0[j+v[i]+1][k-1] %= MOD;
                // [v[i]+1, sum-tmp]
                buf1[j+v[i]+1][k+1] += dp[i][j][k];
                buf1[j+v[i]+1][k+1] %= MOD;
                buf1[j+v[i]+sum-tmp+1][k+sum-tmp+1] -= dp[i][j][k];
                buf1[j+v[i]+sum-tmp+1][k+sum-tmp+1] %= MOD;
            }
        }
        for(int j = 1; j <= 300; j++){
            for(int k = 1; k <= 600; k++){
                buf1[j][k] += buf1[j-1][k-1];
                buf1[j][k] %= MOD;
            }
        }
        for(int j = 1; j <= 300; j++){
            for(int k = 600; k >= 0; k--){
                buf0[j][k] += buf0[j-1][k+1];
                buf0[j][k] %= MOD;
            }
        }
       
        for(int j = 0; j <= 300; j++){
            for(int k = 0; k <= 600; k++){
                dp[i+1][j][k] = buf0[j][k]+buf1[j][k];
                dp[i+1][j][k] %= MOD;
            }
        }
        tmp += v[i];
    }
    ll ans = 0;
   
    for(int i = 0; i <= 2*K; i+=2){
        ans += dp[sz][sum][i];
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
}

Measured memory_bytes: 432988
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let n: usize = parse_line().unwrap();
    let mut t = vec![];
    let mut a = vec![];
    for _ in 0..n {
        let (x, y): (usize, usize) = parse_line().unwrap();
        t.push(x);
        a.push(y);
    }

    let mut t_num = 1;
    let mut a_num = 1;
    for i in 0..n {
        let mut t_ratio = t_num / t[i];
        if t_ratio * t[i] < t_num {
            t_ratio += 1;
        }
        let mut a_ratio = a_num / a[i];
        if a_ratio * a[i] < a_num {
            a_ratio += 1;
        }
        let ratio = std::cmp::max(t_ratio, a_ratio);
        t_num = ratio * t[i];
        a_num = ratio * a[i];
    }
    println!("{}", t_num + a_num);
}


Measured memory_bytes: 2236