akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

double arg(int n){
	if(n==1)return 0;
	else return arg(n-1)+atan(1/sqrt(n-1));
}

int main(){
	double x,y;
	int n;
		while(1){
			cin>>n;
			if(n==-1)break;
			x=sqrt(n)*cos(arg(n));
			y=sqrt(n)*sin(arg(n));
			cout<<x<<endl;
			cout<<y<<endl;
		}
		return 0;
}

Measured memory_bytes: 1344
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for i in range(M)]

min_a = min(a)
min_b = min(b)

set_lis = []

for x, y, c in xyc:
    money = a[x - 1] + b[y - 1] - c
    set_lis.append(money)

set_lis.sort()

print(min(min_a + min_b, set_lis[0]))


Measured memory_bytes: 42912
#include <stdio.h>

int main(void)
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	int xmin = x - r;
	int xmax = x + r;
	int ymin = y - r;
	int ymax = y + r;
	if(xmin >= 0 && xmax <= w && ymin >= 0 && ymax <= h){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')

const int N_MAX = 500000;
const int Q_MAX = 500000;

int N, D;
int d[N_MAX];
int Q;
int q[Q_MAX];

// x[i] : distance to goal after i-th move
int x[N_MAX + 1];
// ng[i] : min-distance to goal from unreachable point after i-th move
int ng[N_MAX + 1];

void solve() {
  x[0] = D;
  REP(i, N) {
    if (x[i] >= d[i]) {
      x[i + 1] = x[i] - d[i];
    } else {
      x[i + 1] = min(x[i], d[i] - x[i]);
    }
  }
  // DUMP(x, N + 1);
  ng[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    if (ng[i + 1] <= d[i] / 2) {
      ng[i] = ng[i + 1];
    } else {
      ng[i] = ng[i + 1] + d[i];
    }
  }
  // DUMP(ng, N + 1);
  REP(i, Q) {
    if (x[N] > 0) {
      puts("YES");
      continue;
    }
    int j = q[i];
    if (x[j - 1] == 0) {
      puts("NO");
      continue;
    }
    if (x[j - 1] >= ng[j]) {
      puts("YES");
      continue;
    }
    puts("NO");
  }
}

void input() {
  scanf("%d%d", &N, &D);
  REP(i, N) scanf("%d", d + i);
  scanf("%d", &Q);
  REP(i, Q) scanf("%d", q + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main()
{
	string s;
	std::cin >> s;
	if (s == "Sunny"){
        std::cout << "Cloudy";
	}
	else if(s == "Cloudy"){
        std::cout << "Rainy";
	}
	else {
        std:cout << "Sunny";
	}

	return 0;
}


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

bool is(string s)
{
    int len = s.length();
    for (int i = 0; i < len; ++i)
        if (i % 2 == 1 && s[i] == 'R')
            return false;
        else if (i % 2 == 0 && s[i] == 'L')
            return false;
    return true;
}

int main()
{
    string s;
    cin >> s;
    cout << (is(s)?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 384
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    int N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    
    sort(A, A + N);
    ll ans;
    ans = A[N-1] - A[0];
    cout << ans << endl;
    
}
 


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i=0;i<n;++i){
    cin >> h[i];
  }
  vector<int> a(m),b(m);
  Graph G(n);
  for(int i=0;i<m;++i){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  int ans=0;
  for(int i=0;i<n;++i){
    bool ok=true;
    for(auto ne : G[i]){
      if(h[i]<=h[ne]) ok=false;
    }
    if(ok){
      ans++;
      //cout << i << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
  int n;
  cin>>n;
  
  cout<<n*n*n<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

bool intersect(int a1, int a2, int b1, int b2) {
	bool o1 = a1 >= b1 && a1 <= b2;
	bool o2 = a2 >= b1 && a2 <= b2;
	return o1 || o2;
}

void solve() {
	const string yes = "War", no = "No War";
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> x_arr(n);
	vector<int> y_arr(m);
	for (int i = 0; i < n; i++) {
		cin >> x_arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y_arr[i];
	}
	sort(x_arr.begin(), x_arr.end());
	sort(y_arr.begin(), y_arr.end());
	// // Check overlap
	// if (intersect(x_arr[0], x_arr[n - 1], y_arr[0], y_arr[m - 1])) {
	// 	cout << yes;
	// 	return;
	// }
	// int range_begin = max(x_arr[0], y_arr[0]);
	// int range_end = min(x_arr[n - 1], y_arr[m - 1]);
	// int z_begin = x + 1;
	// int z_end = y;
	// if (intersect(range_begin, range_end, z_begin, z_end)) {
	// 	cout << no;
	// } else {
	// 	cout << yes;
	// }
	for (int i = x + 1; i <= y; i++) {
		if (i > x_arr[n - 1] && i <= y_arr[0]) {
			cout << no;
			return;
		}
	}
	cout << yes;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
	static long LCM(long x, long y){
		return (x / GCD(x,y)) * y;
	}
	static int LCM(int x, int y) {
		return (int)LCM((long)x, (long)y);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 1;
		for(int i = 0; i < N; i++) {
			long T = sc.nextLong();
			ans = LCM(ans, T);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124
use proconio::{input, marker::Chars};

fn main() {
    input! {
        mut s: Chars,
        mut k: usize,
    }
    let cycle = b'z' - b'a' + 1;

    for c in s.iter_mut() {
        if *c == 'a' {
            continue;
        }
        let sub = b'z' + 1 - *c as u8;
        let sub = sub as usize;
        if k < sub {
            continue;
        } else {
            k -= sub;
            *c = 'a';
        }
    }
    if k != 0 {
        let index = s.len()-1;
        let last = s[index] as u8;
        let last = b'a' + (((last - b'a') as usize + k) % cycle as usize) as u8;
        s[index] = last as u8 as char;
    }

    let s = s.iter().collect::<String>();

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


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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> b(n-1);

    for(int i = 0;i < n-1; i++) cin >> b[i];

    int sum = b[n-2];
    for(int i = n-2;i >= 0; i--){
        if(b[i] < b[i - 1]) sum += b[i];
        else sum += b[i-1];
    }
    sum += b[0];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I "; else cout << A[i] << " ";}}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> item;
  REP(int, i, n)
  {
    string s;
    cin >> s;
    item[s]++;
  }
  cout << SIZE(item, int);

  return 0;
}


Measured memory_bytes: 19144
S=str(input())
T =str(input())
c=len(T)
for i in range(len(S)-len(T)+1):
    count=len(T)
    for n in range(len(T)):
        if S[i+n] == T[n]:
            count -=1
       
    
    
    
    if count <c:
        c=count
print(c)

Measured memory_bytes: 9076
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    count = [0]

    for c in S:
        if c == 'I':
            count.append(count[-1] + 1)
        elif c == 'D':
            count.append(count[-1] - 1)
    return max(count)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


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

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

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<set<int>> adj(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].insert(b);
        adj[b].insert(a);
    }
    
    vector<int> c(n);

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

    sort(c.begin(), c.end());

    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += c[i];
    }

    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (adj[i].size() == 1) {
            q.push(i);
        }
    }

    vector<int> vals(n);

    int idx = 0;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();

        vals[cur] = c[idx++];
        for (int next : adj[cur]) {
            adj[next].erase(cur);
            if (adj[next].size() == 1) {
                q.push(next);
            }
        }
    }

    cout << sum << endl;
    for (int i : vals) {
        cout << i << ' ';
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int h, w;
    cin >> h >> w;
    string s;
    int H, W;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> s;
            if(s == "snuke"){
                H = i + 1;
                W = j + 1;
            }
        }
    }
    cout << (char)('A' + W - 1) << H << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int h[n+1];
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    vector <int> dp(n+1, INT_MAX);
    dp[1]=0;
    for(int i = 2; i <= n; i++){
        for(int j = i-1; j>=max(i-k , 1); j--){
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
            
        }
        // cout << dp[i] << " ";
    }
    cout << dp[n];
}

Measured memory_bytes: 4048
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int hist[300002];

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


	int N;
	cin >> N;
	rep(i, N) {
		int a;
		cin >> a;
		hist[a]++;
	}
	sort(hist + 1, hist + N + 1);

	int k = N + 1;
	int ruiseki = N;
	int mae = 0;
	for (int i = N; i >= 1; i--) {
		while (hist[k - 1] >= i) {
			ruiseki -= hist[--k];
		}
		int ijou = N - k + 1;
		int kei = ijou + ruiseki / i;

		for (int j = mae + 1; j <= kei; j++) co(i);
		mae = kei;
	}
	for (int j = mae + 1; j <= N; j++) co(0);

	Would you please return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
using namespace std;
int main(){
	vector<int> tbl;
	int dp[301] = {0};
	
	
	for(int i=1 ; i*i<= 300 ; i++)tbl.push_back(i*i);
	
	dp[0] = 1;
	
	for(int j = 0; j < tbl.size() ; j++){
		for(int co = tbl[j]; co <= 300 ; co++){
				dp[co] += dp[co-tbl[j]];
		}
	}
	int n;
	while(cin >> n , n){
		cout << dp[n] << endl;
	}
}

	

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

int main() {
  int n;cin>>n;
  map<string,int> mp;
  int cnt=0;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
    cnt=max(cnt,mp[s]);
  }
  for(auto x:mp){
    if(cnt==x.second)cout<<x.first<<endl;
  }
}

Measured memory_bytes: 19232
using System;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var a = read();
		Array.Sort(a);
		int n = h[0], k = h[1];

		MInt M = 0, m = 0, c = 1;
		for (int i = k; i <= n; i++)
		{
			M += c * a[i - 1];
			m += c * a[n - i];

			c *= i;
			c /= i - k + 1;
		}
		Console.WriteLine((M - m).V);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 29788
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val count = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        count[a[i]] = (count[a[i]] ?: 0) + 1
    }
    var sum = 0L
    for (i in 0 until n) {
        sum += a[i]
    }
    val q = sc.nextInt()
    for (_i in 0 until q) {
        val b = sc.nextInt()
        val c = sc.nextInt()
        var old_b = (count[b] ?: 0)
        var old_c = (count[c] ?: 0)
        count[c] = old_b + old_c
        count[b] = 0
        sum -= b.toLong() * old_b + c.toLong() * old_c
        sum += c.toLong() * count[c]!!
        println(sum)
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 75260
#include<stdio.h>
int main (void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}
	
	return 0;

}

Measured memory_bytes: 580
n=gets.to_i
n.times{
	ball=gets.chomp.split(" ").map{|s| s.to_i}
	b0=0
	b1=0
	ok=1
	10.times{|i|
		if ball[i]>b0 then
			b0=ball[i]
		elsif ball[i]>b1 then
			b1=ball[i]
		else 
			ok=0
			break
		end
	}
	if ok==0 then 
		puts "NO"
	else
		puts "YES"
	end
}


Measured memory_bytes: 6864
#include <stdio.h>
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
#define MAX_N 102
int a[MAX_N];
void dump(int n)
{
	int i;
	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;
	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}
int main()
{
	int N, i;
	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}




Measured memory_bytes: 2148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define ll long long

ll a,b,c,d;

ll gcd(ll a,ll b){
	if(b == 0) return a;
	return gcd(b,a%b);
}

int main(){
	cin >> a >> b >> c >> d;
	ll a1 = a - (a % c),a2 = b - (b % c),b1 = a - (a % d),b2 = b - (b % d);
	ll ans1 = (a2 - a1) / c,ans2 = (b2 - b1) / d;
	if(a % c == 0) ans1++;
	if(a % d == 0) ans2++;
	ll e = c * d / gcd(c,d);
	ll c1 = a - (a % e),c2 = b - (b % e);
	if(c1+e < a1 || c1+e < b1) c1 += e;
	if(c2-e > a2 || c2-e > b2) c2 -= e;
	ll ans3 = (c2 - c1) / e;
	if(a % e == 0) ans3++;
	ll ans4 = ans1 + ans2 - ans3;
	cout << b - a + 1 - ans4;
}

Measured memory_bytes: 256
#include <iostream>

constexpr int MAX_N = (int)1e5, MAX_Q = (int)1e3;

using ll = long long int;

int n, q;
ll t;
ll a[MAX_N], d[MAX_N];

int find_l(int first, int last) {
	for (int i = first; i >= last; --i) {
		if (d[i] == 1)
			return i;
	}
	return -1;
}

int find_r(int first, int last) {
	for (int i = first; i <= last; ++i) {
		if (d[i] == 2)
			return i;
	}
	return -1;
}

int main() {
	std::cin >> n >> t >> q;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i] >> d[i];
	int x;
	for (int i = 0; i < q; ++i) {
		std::cin >> x;
		--x;
		ll ans;
		if (d[x] == 2) {
			if (x == 0)
				ans = a[x] - t;
			else {
				int res = find_l(x - 1, 0);
				if (res == -1)
					ans = a[x] - t;
				else {
					ans = (a[res + 1] + a[res]) / 2;
					if (a[x] - ans > t)
						ans = a[x] - t;
				}
			}
		}
		else {
			if (x == n - 1)
				ans = a[x] + t;
			else {
				int res = find_r(x + 1, n - 1);
				if (res == -1)
					ans = a[x] + t;
				else {
					ans = (a[res] + a[res - 1]) / 2;
					if (ans - a[x] > t)
						ans = a[x] + t;
				}
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 4648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  int s,t;
  cin >> s >> t;
  if(s<=t)cout << "unsafe";
  else cout << "safe";
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

inline void write_bool(bool b, const string &tval, const string &fval) {
  cout << (b ? tval : fval) << endl;
} 
inline void YESNO(bool b) { return write_bool(b, "YES", "NO"); }
inline void YesNo(bool b) { return write_bool(b, "Yes", "No"); }
inline void yesno(bool b) { return write_bool(b, "yes", "no"); }


int main() {
  int n, d;
  while (cin >> n >> d) {
    cout << (n + 2 * d) / (2 * d + 1) << endl;
  }
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

	struct Restaurant {
		std::string name;
		int point;
		int index;
	};
	std::vector<Restaurant> list(N);
	for(int i = 0; i < N; i++) {
		auto &r = list[i];
		std::cin >> r.name >> r.point;
		r.index = i;
	}

	std::sort(list.begin(), list.end(), [](const Restaurant &a, const Restaurant &b) {
		if(a.name == b.name) {
			return a.point > b.point;
		}
		return a.name < b.name;
	});

	for(const auto &i : list) {
		std::cout << i.index + 1 << std::endl;
	}

	return 0;
}


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

int main() {
  int i, j, input;
  cin>>input;
  string str;
  cin>>str;
  int l=str.size();
  if(l>input){
    string s(str.begin(), str.begin()+input);
    cout<<s<<"...";
  }
  else{
    cout<<str;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string N;
	cin >> N;
	cout << "ABC" + N << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int a = sc.nextInt();
			int b = sc.nextInt();
			int ans = 0;
			
			if(b==1) {
				System.out.println(0);
				return;
			}
			
			b -= a;
			if(b<=0) {
				System.out.println(1);
				return;
			}
			
			
			while(true) {
				if((b>0)) {
					ans++;
					b -= (a-1);
				}
				if(b<=0) {
					break;
				}
			}
			
			System.out.println(ans+1);
		}
	}


Measured memory_bytes: 23636
#!/mnt/c/Users/moiki/bash/env/bin/python
D,G = map(int, input().split())
points = [ [int(j) for j in input().split()] for _ in range(D)]
points = [ [x[0], x[1], 100*e*x[0]] for e,x in enumerate(points, 1)]

ans = float("inf")
for i in range(1<<D): # for complete bonus bit set 
    lg = G
    cnt = 0
    for d in range(D):
        if i & (1<<d) != 0:
            lg -= points[d][1] # complete bonus
            # lg -= (100*(d+1))*points[d][0] # normal points
            lg -= points[d][2] # normal points
            cnt += points[d][0]
            if lg <= 0:
                break
    if lg <= 0:
        ans = min(ans, cnt)
        continue
    
    # other points
    for d in range(D-1, -1, -1):
        if i & (1<<d) != 0: continue

        if lg <= points[d][2]:
            quot = (lg+(100*(d+1)-1)) // (100*(d+1)) # carryUp
            lg -= 100*(d+1)*quot
            cnt += quot;  break
        else:
            cnt += points[d][0]
            lg -= points[d][2]
    if lg <= 0:
        ans = min(ans, cnt)
        continue
print(ans)


Measured memory_bytes: 40688
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	in_v(int, d, N);
	sort_v(d);
	unique_v(d);
	out(d.size());
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int32_t main(){
	int n, m, k;
    cin >> n >> m >> k;
    int count = 0;
    vector<int> a(n), b(m);
      for(int i = 0; i<n; i++)
        cin >> a[i];
      for(int i = 0; i<m; i++) cin >> b[i];

    int l = 0;
    int sum = 0;
    while(l < n && sum + a[l] <= k){
        sum+=a[l];
        l++;
    }

    int r = 0;
    while(r<m && sum + b[r] <= k){
        sum+=b[r];
        r++;
    }

    int total = l + r;

    l--;
    while(l>=0){
        sum-=a[l];
        while(r<m && sum+b[r] <= k){
            sum+=b[r];
            r++;
        }
        l--;
        total = max(total, l+r+1);
    }
    cout << total << "\n";
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>

using namespace std;

int main()
{
    long N, M, n;

    cin >> N >> M;

    if (N == 1 && M == 1) {
        n = 1;
    }
    else if (N == 1 || M == 1) {
        n = M + N - 3;
    }
    else if (N == 2 || M == 2) {
        n = 0;
    }
    else {
        n = (M - 2) * (N - 2);
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	bool co=true;
	for(int i=s.size()/2 -1;i>=0;i--){
		co=true;
		for(int j=0;j<i;j++){
			if(s[j]!= s[i+j]){
				co=false;
			}
		}
		if(co){
			ans=i*2;
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys

a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
count = 0
res = 0
for el in a:
    if b[count] != el:
        res += 1
    count += 1
print(res)


Measured memory_bytes: 73780
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int n;
string s;
ll DP(string a,string b){
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    ll dp[20][20];
    lol(i,20)lol(j,20)dp[i][j]=0;
    dp[0][0]=1;
    lol(i,a.size()+1){
	lol(j,b.size()+1){
	    if(i<a.size()){
		if(a[i]==s[n+i+j])dp[i+1][j]+=dp[i][j];
	    }
	    if(j<b.size()){
		if(b[j]==s[n+i+j])dp[i][j+1]+=dp[i][j];
	    }
	}
    }
    return dp[a.size()][b.size()];
}
int main(){
    cin>>n>>s;
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
	string a="",b="";
	int x=i;
	for(int j=0;j<n;j++){
	    if(x%2==0)a.push_back(s[j]);
	    else b.push_back(s[j]);
	    x/=2;
	}
	ans+=DP(a,b);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
M = int(input())
if M <= 399:
    pass
elif 400 <= M and M <= 599:
    print("8")
elif M <= 799:
    print("7")
elif M <= 999:
    print("6")
elif M <= 1199:
    print("5")
elif M <= 1399:
    print("4")
elif M <= 1599:
    print("3")
elif M <= 1799:
    print("2")
elif M <= 1999:
    print("1")

Measured memory_bytes: 9180
class Array
  def lcm
    inject(:lcm)  
  end
  def gcd
    inject(:gcd)
  end
end

while input = gets
  a,b = input.split().map(&:to_i)
  i = [a,b].lcm
  j = [a,b].gcd
  puts ("#{j} #{i}")
end


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

using namespace std;

const int maxn = 100100;
const int maxj = 17;

int n,res,mask,nn,a[maxn],cnt[maxn],dp[(int)1<<maxj],good[(int)1<<maxj];

int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<n;i++) {
        int x,y,z;
        cin>>x>>y>>z;
        a[x]^=z;
        a[y]^=z;
    }
    for (int i=0;i<n;i++) cnt[a[i]]++;
    for (int i=1;i<=maxj;i++) {
        res+=cnt[i]/2;
        cnt[i]%=2;
    }
    for (int i=1;i<=maxj;i++)
        if (cnt[i]!=0) {
            mask|=(1<<i);
            nn++;
        }
    for (int tt=0;tt<(1<<maxj);tt++) {
        int x=0;
        for (int i=0;i<maxj;i++)
            if (tt&(1<<i)) x^=i;
        good[tt] = (x==0);
    }
    for (int tt=0;tt<(1<<maxj);tt++) {
        if (tt&1) continue;
        int u=tt;
        while (u>0) {
            if (good[u]) dp[tt] = max(dp[tt],dp[tt^u] + 1);
            u = (u-1)&tt;
        }
    }
    cout<<res+nn-dp[mask];
}


Measured memory_bytes: 1664
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var count = 0;
            var num = 1;
            while (num <= n)
            {
                if (num % 10 == 0 && num.ToString().Length % 2 == 0)
                {
                    num *= 10;
                    continue;
                }
                count++;
                num++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
import sys
from heapq import heappush, heappop

def sieve(n):
    is_prime = [True] * (n + 1)
    prime_list = []
    
    is_prime[0] = is_prime[1] = False
    prime_list.append(2)
    
    for i in range(3, n + 1, 2):
        if is_prime[i]: prime_list.append(i)
        for j in range(i * i, n + 1, i):
            is_prime[j] = False
            
    return prime_list
    
primes = sieve(40000)

def factorization(n):
    ret = []
    for prime in primes:
        while n % prime == 0:
            ret.append(prime)
            n /= prime
    if n > 1: ret.append(n)
    
    return ret
            
    
    
if __name__ == '__main__':
    n = sys.stdin.readline()
    n = int(n)
    
    ans = factorization(n)
    sys.stdout.write(str(n) + ': ')
    sys.stdout.write(' '.join(map(lambda x: str(x), ans)) + '\n')
        

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

using namespace std; 

ll n; 

ll cal(ll a, ll b) {
  if (a > b) swap(a, b); 
  return a + (b - a - 1) / 2; 
}

int main() {  
  ll a, b; 
  cin >> n >> a >> b; 
  if (a % 2 == b % 2) {
    cout << (b - a) / 2 << '\n'; 
  }
  else {
    cout << min(cal(a, b), cal(n - a + 1, n - b + 1)); 
  }
  return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
vector<int> a[1000];
bool v[1000];
int s, prevv[1000], n, m, x, y;
void dfs(int cur){
	v[cur] = true;
	for (auto e : a[cur]){
		if (e == s){
			prevv[e] = cur;
		}
		if (!v[e]){
			prevv[e] = cur;
			dfs(e);
		}
	}
}
vector<int> optimize(vector<int> p){
	bool b[n];
	fill(b, b + n, false);
	for (int i = 0; i < p.size(); i++) b[p[i]] = true;
	for (int i = 0; i < p.size(); i++){
		int temp = i - 1;
		if (i == 0) temp = p.size() - 1;
		for (auto e : a[p[i]]){
			if (b[e] && e != p[temp]){
				vector<int> np;
				np.emplace_back(p[i]);
				int cur = i;
				while (p[cur] != e){
					cur++;
					if (cur == p.size()) cur = 0;
					np.emplace_back(p[cur]);
				}
				return optimize(np);
			}
		}
	}
	return p;
}
int main(){
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++){
		scanf("%d %d", &x, &y);
		a[x - 1].emplace_back(y - 1);
	}
	for (s = 0; s < n; s++){
		fill(v, v + n, false);
		fill(prevv, prevv + n, -1);
		dfs(s);
		if (prevv[s] != -1){
			vector<int> p;
			p.emplace_back(s);
			int cur = prevv[s];
			while (cur != s){
				p.emplace_back(cur);
				cur = prevv[cur];
			}
			vector<int> bruh = optimize(p);
			printf("%d\n", bruh.size());
			for (int i = 0; i < bruh.size(); i++) printf("%d\n", bruh[i] + 1);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 384
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S="00"+input()
    S=S[::-1]
    N=len(S)-1
    
    def calc(x,nxt):
        # 今見てる数字,次の桁の数字,を受けて
        # 今使う,繰り上がり，を返す

        if x<=4:
            return x,0
        elif x>=6:
            return 10-x,1
        else:
            # 次が5なら，そのあと5以上ががくればお得，そうでなくとも損しない
            if nxt<5:
                return 5,0
            else:
                return 5,1
    
    kuri=0
    ans=0
    for i in range(N):
        now=int(S[i])
        nxt=int(S[i+1])
        now+=kuri
        temp,kuri = calc(now,nxt)
        
        ans+=temp
        
    print(ans)
        

main()


Measured memory_bytes: 78964
#include<bits/stdc++.h>
#define LL long long
#define maxn 200010
#define inf 0x3f3f3f3f3f3f
using namespace std;

LL dp[100010];

LL a[1010], b[1010];

int main(){
	int n, w;
	cin >> w >> n;
	LL ma = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i];
		ma = max(ma, b[i]);
	}
	for(int i = 0; i <= w + ma; ++i){
		dp[i] = inf;
	}
	for(int i = 0; i <= w + ma; ++i){
		if(i % a[0] == 0){
			dp[i] = b[0] * (i / a[0]);
		}
	}
	for(int i = 1; i < n; ++i){
		for(int j = a[i]; j <= w + ma; ++j){
			dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
		}
	}
	LL ans = inf;
	for(int i = w; i <= w + ma; ++i){
		ans = min(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
if n==1:
  if a==[0,1]:
    print(2)
  elif a==[0,2]:
    print(3)
  else:
    print(-1)
  exit()
if n==0:
  if a==[1]:
    print(1)
  else:
    print(-1)
  exit()



subt=[0]*(n)
if a[0] == 0:
  subt[0]=2
elif a[0]== 1:
  subt[0]=1
else:
  print(-1)
  exit()

for i in range(n-1):
  #subt[i+1]=subt[i]-subt[i]*2
  #print(subt[i])
  if a[i+1] > subt[i]-1:
    if i<n-1:
      print(-1)
      #print(n)
      #print(subt[i])
      exit()
      #pass
    elif a[i+1] > subt[i]:
      print(-1)
      exit()
      #pass
  else:  
    subt[i+1]=(subt[i]-a[i+1])*2
if a[n]> subt[-1]:
  print(-1)
  exit()
if a[n] > subt[-2]:
  subt[-1]=a[n]
else:
  subt[-1]=a[n]
  for j in range(2,n):
    if (subt[-j]-a[-j])*2 < subt[1-j]:
      print(-1)
      exit()
    if (subt[-j]-a[-j]) <= subt[1-j]:
      pass
    else:
      subt[-j]=subt[1-j]+a[-j]
  
    #pass
  
print(sum(subt)+1)
    
#print(subt)

Measured memory_bytes: 674484
#include <iostream>
#include <string>
#include <cstdlib>

int main(void) {
  int s;
  std::cin >> s;
  int s1, s2;
  s1 = s / 100;
  s2 = s - s1*100;
  bool s1_judge = false, s2_judge = false;
  if ((1 <= s1) && (s1 <= 12)) {
    s1_judge = true;
  }
  if ((1 <= s2) && (s2 <= 12)) {
    s2_judge = true;
  }

  if (s1_judge) {
    if (s2_judge) {
      std::cout << "AMBIGUOUS" << std::endl;
    } else {
      std::cout << "MMYY" << std::endl;
    }
  } else {
    if (s2_judge) {
      std::cout << "YYMM" << std::endl;
    } else {
      std::cout << "NA" << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {s: String};

    if s == "SUN" {
        println!("7")
    } else if s == "MON" {
        println!("6")
    } else if s == "TUE" {
        println!("5")
    } else if s == "WED" {
        println!("4")
    } else if s == "THU" {
        println!("3")
    } else if s == "FRI" {
        println!("2")
    } else {
        println!("1")
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

const int MAX=510000;
const int mod=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a){
  return modpow(a,mod-2);
}

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }
}

ll com(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  ll H,W,A,B;
  cin>>H>>W>>A>>B;
  init();
  ll ans=0;
  ll mod=1e9+7;
  rep(i,W-B) (ans+=com(H-A-1+B+i,B+i)*com(A+W-B-i-2,A-1)%mod)%=mod;
  cout<<ans<<endl;
}


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

int main()
{
    int n ;cin>>n;
    int arr[n+1][4];
    int ar[n+1][4];
    for(int i = 1 ; i<= n ;i++ ){
        for(int j = 1 ; j<=3 ; j++){
            cin>>arr[i][j];
        }
    }
    ar[1][1]=arr[1][1];ar[1][2]=arr[1][2];ar[1][3]=arr[1][3];
    for(int i = 2 ; i<=n ; i++){
        ar[i][1]=max(ar[i-1][2] , ar[i-1][3])+arr[i][1];
        ar[i][2]=max(ar[i-1][1] , ar[i-1][3])+arr[i][2];
        ar[i][3]=max(ar[i-1][2] , ar[i-1][1])+arr[i][3];
        
    }
    cout<<max( ar[n][1] , max(ar[n][2] , ar[n][3]));
    return 0;
}

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


int main(){
	int n; cin >> n;
	set<int> s;
	rep(i,n){
		int a;cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
	return 0;

}


	







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

void swap(int* x, int* y) {
	int temp = *x;
	*x = *y;
	*y = temp;
}

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

	int a[w+1];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}

	int ops;
	cin >> ops;

	while (ops--) {
		int x, y;
		scanf("%d,%d", &x, &y);

		swap(a[x], a[y]);
	}

	for (int i = 1; i <= w; i++) 
		cout << a[i] << endl;

	return 0;
}

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

int main(){
  int a, b, c, sum;
  cin >> a >> b >> c;
  sum = a + b + c;
  if(sum % 2 == 0){
    if ( sum == a * 2 || sum == b * 2 || sum == c * 2 ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;


int main() {
   int h,w; cin >> h >> w;

   vector<string> a(h);
   rep(i,h) cin >> a[i];

   vector<bool> r(h,false);
   vector<bool> c(w,false);

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(a[i][j] == '#'){
                r[i] = true;
                c[j] = true;
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        if(r[i]){
            for (int j = 0; j < w; ++j) {
                if(c[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256