akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::*;
use std::collections::BinaryHeap;
use std::cmp::Ordering;
 
use std::cmp;
 
fn main() {
    // 最も大きいものを貪欲に取っていくのが最適
    solve();
}
fn solve() {
    let n = read::<usize>();
    let mut a = read_vec::<usize>(n);
    let mut memo_max = vec![0; n + 10];
    let mut x = a[0];
    for i in 0..n {
        memo_max[i + 1] = cmp::max(memo_max[i], a[i]);
    }
 
    let mut heap = BinaryHeap::new();
    let mut cnt = 0;
    let mut ans = vec![0; n];
    //println!("{:?}", memo_max);
    for i in (0..n).rev() {
        if memo_max[i] >= a[i] {
            // 使われない
            ans[i] = 0;
            heap.push(Node { val: -(a[i] as i64) });
        } else {
            if memo_max[i + 1] > memo_max[i] {
                ans[i] += (cnt + 1) * (memo_max[i + 1] - memo_max[i]);
                cnt += 1;
            }
            //これよりも右にあるa[i]より大きいもんはmemo_max[i]になる
            while let Some(Node { val }) = heap.pop() {
                let val_plus = -val;
                if val_plus < memo_max[i] as i64 {
                    heap.push(Node { val: val });
                    break;
                } else {
                    cnt += 1;
                    ans[i] += (val_plus as usize - memo_max[i]);
                }
            }
        }
    }
    for i in &ans {
        println!("{}", i);
    }
}
 
fn solve_() {
    let n = read::<usize>();
    let mut a = read_vec::<usize>(n);
    let sum = a.iter().fold(0, |acc, i| acc + i);
    let mut v = vec![];
    for i in 0..sum {
        let ma = a.iter().fold(0, |acc, i| cmp::max(acc, *i));
        let mut new = n;
        for j in (0..n).rev() {
            if a[j] == ma {
                new = j;
            }
        }
        v.push(new + 1);
        let huga = new;
        for j in (0..n) {
            if a[j] == ma {
                new = j;
            }
        }
        a[new] -= 1;
        println!("{}:{}:{:?}", huga + 1, new + 1, a);
    }
    println!("{:?}", v);
}
 
 
#[allow(dead_code)]
fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for i in 0..n {
        let a = read::<T>();
        v.push(a);
    }
    v
}
 
#[allow(dead_code)]
#[derive(Copy, Clone, Eq, PartialEq)]
struct Node {
    val: i64,
}
impl Ord for Node {
    fn cmp(&self, other: &Node) -> Ordering {
        other.val.cmp(&self.val)
    }
}
impl PartialOrd for Node {
    fn partial_cmp(&self, other: &Node) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}
#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}

Measured memory_bytes: 8572
n = int(input())
a = list(map(int, input().split()))
SUM = sum(a) 
ans = []
l = [[0, SUM]]
for i in range(n):
    l.append([l[i][0] + a[i], SUM - (l[i][0] + a[i])])
for i in l:
    ans.append(abs(i[0] - i[1]))
print(min(ans))

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

bool solve() {
    string S;
    cin >> S;
    int N = S.size();
    for ( int i = 0; i < N/2; i++ ) {
        if ( S[i] != S[N-1-i] ) return false;
    }
    for ( int i = 0; i < (N-1)/2/2; i++ ) {
        if ( S[i] != S[(N-1/2)-1-i] ) return false;
    }
    for ( int i = (N+3)/2-1, j = N-1; i < j; i++, j-- ) {
        if ( S[i] != S[j] ) return false;
    }
    return true;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> b(2);
    b.at(0)=1000000001;
    b.at(1)=-1;
    for(int i=0;i<n;i++){
        if(b.at(b.size()-1)>=a[i]){
            b.push_back(a[i]);
            continue;
        }
        for(int j=1;j<b.size();j++){
            if(b.at(j)<a[i]){
                b.at(j)=a[i];
                break;
            }
        }
    }
    cout<<b.size()-1<<endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <regex>
using namespace std;
pair<string,string> ab[11];
int N;

string replace_string(string before, string from, string to) {
	vector<int> p;
	int i = 0, j = 0;
	while(i < before.size()) {
		if(before[i]==from[0]) {
			i++;
			j = 1;
			while(1) {
				if(i >= before.size()) break;
				if(before[i]==from[j]) {
					i++, j++;
				}else {
					break;
				}
			}
			if(j == from.size()) p.push_back(i-j);
		}else{
			i++;
		}
		j = 0;
	}
	// for(int i=0;i<p.size();i++) cout << p[i] << ((i==p.size()-1)?"\n":" ") << endl;
	string res = before;
	int cnt = 0;
	for(int i=0;i<p.size();i++) {
		res = res.substr(0,cnt+p[i]) + to + res.substr(cnt+p[i]+from.size());
		cnt += (to.size()-from.size());
	}
	return res;
}

int dfs(string now, string to, int cnt) {
	if((int)now.size() >= (int)to.size()) {
		if(now == to) {
			return cnt;
		}else{
			return INT_MAX;
		}
	}
	int res = INT_MAX;
	for(int i=0;i<N;i++) {
		string before = now;
		string after = replace_string(before, ab[i].first, ab[i].second);
		// cout << before << " " << after << endl;
		if(after==before) continue;
		else res = min(res,dfs(after, to, cnt+1));
	}
	return res;
}

int main() {
	while(1) {
		cin >> N;
		if(N==0) break;
		for(int i=0;i<N;i++) {
			string a,b;
			cin >> a >> b;
			ab[i] = make_pair(a,b);
		}
		string fi, en;
		cin >> fi >> en;
		int ans = dfs(fi,en, 0);
		cout << ((ans == INT_MAX) ? -1: ans) << endl;
	}
}


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

int main(){
  string s;

  cin >> s;

  if(s == "SAT"){
    cout << 1;
  }else if(s == "SUN"){
    cout << 7;
  }else if(s == "MON"){
    cout << 6;
  }else if(s == "TUE"){
    cout << 5;
  }else if(s == "WED"){
    cout << 4;
  }else if(s == "THU"){
    cout << 3;
  }else if(s == "FRI"){
    cout << 2;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a,b;
    bool check=false;
    cin>> a;
    for (int i =0;i<3;i++){

        b= a%10;
        if(b==7) {check =true;
        break;
        }
        a=a/10;

    }
    if(check) cout<< "Yes\n";
    else cout<<"No\n";

return 0;
}



Measured memory_bytes: 3676
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int k[10],w[10];
    
    rep(i,0,10){
        cin >> w[i];
    }
    rep(i,0,10){
        cin >> k[i];
    }
    
    sort(k,k+10,greater<int>());
    sort(w,w+10,greater<int>());
    
    cout <<w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;
    return 0;   
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> prime_factorize(ll N) {
  vector<ll> res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    while (N % a == 0) {
      N /= a;
    }
    res.push_back(a);
  }

  if (N != 1) res.push_back(N);
  return res;
}

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

  set<int> pairwise;
  vector<int> setwise(1000000 + 1, 0);
  vector<ll> v0 = prime_factorize(A[0]);
  for (auto i : v0) {
    pairwise.insert(i);
    setwise[i]++;
  }

  bool is_pairwise = true;
  for (int i = 1; i < N; i++) {
    vector<ll> v = prime_factorize(A[i]);
    for (auto j : v) {
      // check pairwise
      if (is_pairwise) {
        if (pairwise.count(j) == 0)
          pairwise.insert(j);
        else
          is_pairwise = false;
      }
      // check setwise
      setwise[j]++;
    }
  }
  bool is_setwise = true;
  for (auto i : setwise) {
    if (i == N) is_setwise = false;
  }

  if (is_pairwise)
    cout << "pairwise coprime" << endl;
  else if (is_setwise)
    cout << "setwise coprime" << endl;
  else
    cout << "not coprime" << endl;
}


Measured memory_bytes: 11176
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    string s;
    cin>>s;
    ll ans=ll(s.size())*(s.size()+1)/2;
    for(auto x:lcp_array(s,suffix_array(s))) ans-=x;
    cout<<ans<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 15596
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int ans[100][100];
int a[10005];
int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int idx = 0;
    REP(i, N){
        int x;
        cin >> x;
        REP(j, x){
            a[idx] = i + 1;
            idx++;
        }
    }
    idx = 0;
    REP(i, H){
        if(i % 2 == 0){
            REP(j, W){
                ans[i][j] = a[idx];
                idx++;
            }
        }else{
            for(int j = W - 1; j >= 0; j--){
                ans[i][j] = a[idx];
                idx++;
            }
        }
    }
    cout << endl;
    REP(i, H){
        REP(j, W - 1){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][W - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <sys/timeb.h>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 1000000007
#define INFL 2000000000000000000LL
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;

bool WarshallFloyd(vvll &graph, int V) {
	rep(k, V)rep(i, V)rep(j, V) {
		// i->(k)->j
		if (graph[i][k] != INFL && graph[k][j] != INFL) {
			graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
		}
	}
	rep(i, V) {
		if (graph[i][i] < 0) return false;
	}
	return true;
}

int main() {
	int V, E;
	cin >> V >> E;
	vvll G(V);
	rep(i, V) {
		G[i] = vll(V, INFL);
		G[i][i] = 0;
	}
	rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		G[s][t] = d;
	}

	if (WarshallFloyd(G, V)) {
		rep(i, V) {
			rep(j, V) {
				if (G[i][j] == INFL) {
					cout << "INF";
				}
				else {
					cout << G[i][j];
				}
				if (j != V - 1)cout << ' ';
			}
			cout << endl;
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}


	return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define int long long
int n,m,l,r,x,y,ans;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
signed main(void)
{
	read(n),read(m);
	l=1,r=n;
    while (m--)
	{
        read(x),read(y);
        l=l>x?l:x;
        r=r<y?r:y;
    }
    if (l<=r)
    	ans=r-l+1;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <random>
#include <cfloat>
#define norm(X) ((X) * (X))
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

const llong s = 5000000;
const double R = 1e11;
llong n;
double px[105];
double py[105];
llong cnt[105];
double x;
double y;
double r;
llong indx;

int main() {
    
    cin >> n;
    for (llong i = 0; i < n; i++) {
        cin >> px[i];
        cin >> py[i];
    }
    
    for (llong i = 1; i <= s; i++) {
        x = R * cos(i * 2.0 * M_PI / s);
        y = R * sin(i * 2.0 * M_PI / s);
        indx = 0;

        r = 1e32;

        //cout << x << ' ' << y << endl;
        for (llong j = 0; j < n; j++) {
            double d = norm(x - px[j]) + norm(y - py[j]);

            if (d < r) {
                indx = j;
                r = d;
            }
        }

        cnt[indx]++;
    }

    for (llong i = 0; i < n; i++) {
        printf("%.*lf\n", DBL_DIG, (double)cnt[i] / (double)s);
    }

    return 0;
}


Measured memory_bytes: 256
/* 
 * Project: M-SOLUTIONS プロコンオープン 2020 A - Kyu in AtCoder
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/25
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int x;

void solve() {

    if (x >= 1800) {
        printf("%d\n", 1);
        return;
    } else if (x >= 1600) {
        printf("%d\n", 2);
        return;
    }  else if (x >= 1400) {
        printf("%d\n", 3);
        return;
    } else if (x >= 1200) {
        printf("%d\n", 4);
        return;
    } else if (x >= 1000) {
        printf("%d\n", 5);
        return;
    } else if (x >= 800) {
        printf("%d\n", 6);
        return;
    } else if (x >= 600) {
        printf("%d\n", 7);
        return;
    } else {
        printf("%d\n", 8);
        return;
    }
}

int main() {

    scanf("%d", &x);

    solve();

}

Measured memory_bytes: 3244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * YAML
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		Main main = new Main();

		StringTokenizer query = new StringTokenizer(br.readLine(), ".");
		List<String> lines = new ArrayList<>();
		Obj[] objs = new Obj[50_000];

		//read
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			lines.add(line);
		}

		//parse
		for (int i = 0; i < lines.size(); i++) {
			String line1 = lines.get(i);

			//parent
			int n = 0;
			for (int j = 0; j < line1.length(); j++) {
				if (line1.charAt(j) == ' ') n++;
				else break;
			}
			if (objs[n] == null) {
				objs[n] = main.new Obj();
			}

			//prop
			words = line1.substring(n).split(":");
			if (words.length == 1) {
				//prop: object
				String line2 = lines.get(i + 1);
				//self
				int m = 0;
				for (int j = 0; j < line2.length(); j++) {
					if (line2.charAt(j) == ' ') m++;
					else break;
				}
				if (objs[m] == null) {
					objs[m] = main.new Obj();
				}
				String key = words[0];
				objs[n].props.put(key, main.new Prop<Obj>(objs[m]));
			} else {
				//prop: string
				String key = words[0];
				String string = words[1].substring(1);
				objs[n].props.put(key, main.new Prop<String>(string));
			}
		}

		Obj obj = objs[0];
		Object value = null;
		while (query.hasMoreTokens()) {
			value = obj.get(query.nextToken());
			if (value == null) break;
			if (value instanceof Obj) {
				obj = (Obj) value;
			} else {
				if (query.hasMoreTokens()) {
					value = null;
					break;
				}
			}
		}

		String ans = "";
		if (value == null) {
			ans = "no such property";
		} else if (value instanceof String) {
			ans = "string \"" + value + "\"";
		} else if (value instanceof Obj) {
			ans = "object";
		}
		System.out.println(ans);

	} //end main

	class Obj {
		Map<String, Prop> props;

		Obj() {
			props = new HashMap<>();
		}

		Object get(String key) {
			if (props.containsKey(key)) {
				return props.get(key).value;
			} else {
				return null;
			}
		}
	}

	class Prop<T> {
		T value;

		Prop(T value) {
			this.value = value;
		}
	}
}

Measured memory_bytes: 26076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <stack>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i ++)
using ll = long long;
int N;
string str;
int S[200001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    cin >> str;
    rep(i, N) S[i] = str[i] == 'R' ? 0 : 1;
    int numzero = 0;
    int numswap = 0;
    rep(i, N) if (S[i] == 0) numzero ++;
    rep(i, numzero) if (S[i] == 1) numswap ++;
    int ans = numswap;  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 5e5+10;
const ll mod = 1000000007;

ll fact[MAX], inv[MAX], finv[MAX];

void pre_nCk(){
  fact[1] = inv[1] = finv[1] = 1;
  fact[0] = finv[0] = 1;
  for(int i = 2; i < MAX; i++){
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

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

int main(){
  pre_nCk();
  ll n, m; cin >> n >> m;
  ll ans = 0;
  int c;
  for(int i = 0; i <= n; i++){
    if(i % 2 == 0) c = 1;
    else c = -1;
    ll tmp1 = fact[m]*finv[m-i]%mod;
    ll tmp2 = fact[m-i]*finv[m-n]%mod;
    ans += c*nCk(n,i)*tmp1%mod*tmp2%mod*tmp2%mod;
    ans %= mod;
  }
  cout << (ans+mod)%mod << endl;
}
  

Measured memory_bytes: 15308
N = int(input())

S = []
for i in range(N):
    S.append(input())

n = [0,0,0,0]
for i in range(N):
    if S[i]=='AC':
        n[0] += 1
    elif S[i]=='WA':
        n[1] += 1
    elif S[i]=='TLE':
        n[2] += 1
    elif S[i]=='RE':
        n[3] += 1

print('AC x '+str(n[0]))
print('WA x '+str(n[1]))
print('TLE x '+str(n[2]))
print('RE x '+str(n[3]))


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

ans = 0
count = 0
for i in range(n - 1):
    if a[i] >= a[i + 1]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)

print(ans)


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

int compare_int(const void *a,const void *b){
  return *(long*)a-*(long*)b;
}

int main(void){
  long N;
  long ans = 0;
  scanf("%ld",&N);

  long long A[N];
  for(int i = 0;i < N;i++) scanf("%lld",&A[i]);

  qsort(A,N,sizeof(long),compare_int);

  for(int i = 0;i < N;i++){
    int sample = A[i];
    int counter = 0;
    while(1){
      if(i+counter >= N) break;
      if(A[i+counter] != sample) break;
      counter++;
    }
    if(counter%2 != 0) ans++;
    i += counter-1;
  }

  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 1788
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] a = new boolean[N];

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

        int[] dp = new int[N+1];
        int b = 1000000007;
        for (int i = N; i >= 0; i--) {
            if (i == N) {
                dp[i] = 1;
                continue;
            }
            if (a[i]) {
                dp[i] = 0;
                continue;
            }
            if (i+2 > N) {
                dp[i] = dp[i+1]%b;
                continue;
            }
            dp[i] = (dp[i+1] + dp[i+2])%b;
        }
        System.out.println(dp[0]);
    }
}

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

#define ln '\n'
#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 FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll deposit = 100;
    int ans = 0;
    while (deposit < x) {
        deposit = (ll)((double)deposit * 1.01);
        ans++;
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
			double a=scan.nextDouble();
			double x,y;
			x=a*a*3.141592653589;
			y=a*2*3.141592653589;
			System.out.printf("%.6f %.6f",x,y);
		scan.close();
}
}


Measured memory_bytes: 28244
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
#define Nmax 1000000000000
using namespace std;
ll a[200000];
int k;
void add(ll arr[], int n, int lo, int hi, int val)
{
    arr[lo] += val;
    if (hi != n - 1)
       arr[hi + 1] -= val;
}
void updateArray(ll arr[], int n)
{

    for (int i = 1; i < n; i++)
        arr[i] += arr[i - 1];
}
void printArr(ll arr[], int n)
{
    updateArray(arr, n);
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}
int segmt[800000];
void build(int p,int l,int r){
    if(l==r) {
        if(a[l]>=k) segmt[p]=1;
        else segmt[p]=0;
        return ;
    }
    int mid=(l+r)/2;
    build(2*p+1,l,mid);
    build(2*p+2,mid+1,r);
    segmt[p]=segmt[2*p+1]+segmt[2*p+2];
}
int query(int p,int ql,int qr,int l,int r){
    if(ql<=l && r<=qr) return segmt[p];//Total overlap
    if(r<ql || l>qr) return 0; //no overlap
    int mid=(l+r)/2;
    return query(2*p+1,ql,qr,l,mid)+query(2*p+2,ql,qr,mid+1,r);
}
int main()
{
    IOS;
	int n;cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	ll dp[n][3];
	memset(dp,0,sizeof dp);
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int m,n,x,y=0;
    cin >> m >> n;
    while(n--)
    {
        cin >> x;
        y+=x;
    }
    if(y >= m)cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
let () =
  let dp = Array.make 3 0 in
  String.iter (function
    | 'a' -> dp.(0) <- 1 + dp.(0)
    | 'b' -> dp.(1) <- 1 + dp.(1)
    | 'c' -> dp.(2) <- 1 + dp.(2)) (read_line ());
  print_endline @@
  if Array.fold_left max min_int dp - Array.fold_left min max_int dp <= 1
  then "YES"
  else "NO"


Measured memory_bytes: 640
#include<cstdio>
#include<queue>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
struct edge{
	int to,nxt,cap,flow;
}e[30005];
int a[105],first[105],cur[105],dis[105],S,T,n,tot=0;
ll min(ll x,ll y) {return x<y?x:y;}
void addedge(int u,int v,int w)
{
	e[++tot].to=v;
	e[tot].cap=w;
	e[tot].nxt=first[u];
	first[u]=tot;
}
int bfs()
{
	queue<int> q;
	for(int i=1;i<=n+2;i++) dis[i]=INF;
	dis[S]=0;q.push(S);
	while(q.size())
	{
		int x=q.front();q.pop();
		for(int i=first[x];i;i=e[i].nxt)
		if(e[i].cap>e[i].flow&&dis[e[i].to]==INF)
		{
			dis[e[i].to]=dis[x]+1;
			q.push(e[i].to);
		}
	}
	return dis[T]!=INF;
}
ll dfs(int x,ll low)
{
	if(x==T||low==0) return low;
	ll ret=0,st;
	for(int i=cur[x];i;i=e[i].nxt)
	{
		cur[x]=i;
		if(dis[e[i].to]==dis[x]+1&&(st=dfs(e[i].to,min(low,e[i].cap-e[i].flow)))>0)
		{
			ret+=st;
			low-=st;
			e[i].flow+=st;
			e[((i-1)^1)+1].flow-=st;
			if(!low) break;
		}
	}
	return ret;
}
ll dinic()
{
	ll ret=0;
	while(bfs())
	{
		for(int i=1;i<=n+2;i++) cur[i]=first[i];
		ret+=dfs(S,INF);
	}
	return ret;
}
int main()
{
	ll ans=0;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	S=n+1;T=n+2;
	for(int i=1;i<=n;i++)
	if(a[i]>0)
	{
		ans+=a[i];
		addedge(i,T,a[i]);
		addedge(T,i,0);
	}
	else
	{
		addedge(S,i,-a[i]);
		addedge(i,S,0);
	}
	for(int i=1;i<n;i++)
	for(int j=2;j*i<=n;j++)
	{
		addedge(i,j*i,INF);
		addedge(j*i,i,0);
	}
	ans-=dinic();
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int n, m;
vector<pair<int,int>> e;
vector<pair<int,int>> v[101010];
int d[101010];
int z[101010];
int b[101010];

int dfs(int x) {
	z[x] = 1;
	int r = 0;
	for (auto u : v[x]) {
		if (z[u.first]) continue;
		int h = dfs(u.first);
		if (h) b[u.second] = 1-b[u.second];
		r += h;
	}
	if (d[x]%2 == 1) r++;
	return r%2;
}

int main() {
	cin >> n >> m;
	if (m%2 == 1) {
		cout << "-1\n";
		return 0;
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		e.push_back({a,b});
		d[a]++;
		v[a].push_back({b,i});
		v[b].push_back({a,i});
	}
	dfs(1);
	for (int i = 0; i < m; i++) {
		if (b[i]) swap(e[i].first,e[i].second);
		cout << e[i].first << " " << e[i].second << "\n";
	}
}


Measured memory_bytes: 15092
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i, b, e)	  for (int i = (int)b; i < (int)e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    int n, k;
    cin >> n >> k;
    vi a(n);
    fore(i, 0, n)
    {
    	cin >> a[i];
    }
    sort(all(a));
    ll tot = 0;
    fore(i, 0, n-k)
    {
    	tot += a[i];
    }
    cout << tot << endl;
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 1024
import math
 
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
 
input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d or x, x);
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print('not' if d > 1 else r, 'coprime')


Measured memory_bytes: 162284
#include <iostream>
#include <queue>
#include <map>
using namespace std;

unsigned long long int makeID( int (&p)[ 13 ] )
{
	unsigned long long int ret = 0;
	for( int i = 0; i < 13; ++i ){
		ret *= 13;
		ret += p[ i ];
	}
	return ret;
}

unsigned long long int slide( unsigned long long int s, int a, int b )
{
	int p[ 13 ];
	for( int i = 0; i < 13; ++i ){
		p[ 12 - i ] = s % 13;
		s /= 13;
	}
	int t = p[ a ];
	p[ a ] = p[ b ];
	p[ b ] = t;
	return makeID( p );
}

int side[][ 4 ] = {
	{ -1, -1,  2, -1 },
	{ -1,  2,  5, -1 },
	{  0,  3,  6,  1 },
	{ -1, -1,  7,  2 },
	{ -1,  5, -1, -1 },
	{  1,  6,  9,  4 },
	{  2,  7, 10,  5 },
	{  3,  8, 11,  6 },
	{ -1, -1, -1,  7 },
	{  5, 10, -1, -1,},
	{  6, 11, 12,  9 },
	{  7, -1, -1, 10 },
	{ 10, -1, -1, -1 }
};

int solve( map< unsigned long long int, int >& ans, queue< unsigned long long int >& q, int* p, map< unsigned long long int, int >* sub )
{
	int cnt = 1;
	while( cnt <= 10 ){
		int size = q.size();
		for( int i = 0; i < size; ++i ){
			unsigned long long int s = q.front();
			q.pop();
			int pos[ 2 ], a = 0;
			unsigned long long int t = s;
			for( int j = 0; j < 13; ++j ){
				int b = t % 13;
				if( b == 0 ) pos[ a++ ] = 12 - j;
				t /= 13;
			}
			for( int j = 0; j < 2; ++j ){
				int b = pos[ j ];
				for( int k = 0; k < 4; ++k ){
					int c = side[ b ][ k ];
					if( c == -1 ) continue;
					t = slide( s, b, c );
					bool e = ans.find( t ) == ans.end();
					if( sub == NULL ){
						if( e ){
							ans[ t ] = cnt;
							q.push( t );
						}
					}else{
						if( !e ){
							return ans[ t ] + cnt;
						}else if( sub->find( t ) == sub->end() ){
							(*sub)[ t ] = cnt;
							q.push( t );
						}
					}
				}
			}
		}
		++cnt;
	}
	return -1;
}

int main()
{
	map< unsigned long long int, int > ans;
	queue< unsigned long long int > q;


	int p[ 13 ];
	for( int i = 0; i < 13; ++i ){
		p[ i ] = i;
	}
	p[ 12 ] = 0;
	unsigned long long int s = makeID( p );
	ans[ s ] = 0;
	q.push( s );

	solve( ans, q, p, NULL );

	while( !q.empty() )q.pop();

	while( cin >> p[ 0 ] && p [ 0 ] != -1 ){
		for( int i = 1; i < 13; ++i ){
			cin >> p[ i ];
		}
		queue< unsigned long long int > qq;
		s = makeID( p );
		qq.push( s );
		int r;
		map< unsigned long long int, int > u;
		if( ans.find( s ) != ans.end() ){
			r = ans[ s ];
		}else{
			r = solve( ans, qq, p, &u );
		}
		if( r >= 0 ){
			cout << r << endl;
		}else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5144
N = input()
A = N[0]
B = N[1]
C = N[2]
D = N[3]

op = ('+', '-')

flag = False
for op1 in op:
    for op2 in op:
        for op3 in op:
           if eval(A+op1+B+op2+C+op3+D) == 7:
                flag = True
                break
        if flag: break
    if flag: break

print(A+op1+B+op2+C+op3+D+'=7')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    cout << n*n*n;

    cout << endl;
    return 0;
}

Measured memory_bytes: 764
n = int(input())
Hs = list(map(int, input().split()))
 
ans = 0
count = 0
for h1, h2 in zip(Hs[:-1], Hs[1:]):
    if h1 >= h2:
        count += 1
    
    else:
        ans = max(ans, count)
        count = 0
 
ans = max(ans, count)
print(ans)

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

int main(){
    using namespace std;
    constexpr unsigned long C = 26;
    unsigned long D;
    cin >> D;
    vector<unsigned long> c(C);
    for(auto&& i : c)cin >> i;
    vector v(D, vector<unsigned long>(C));
    for(auto&& i : v)for(auto&& j : i)cin >> j;

    vector last(C, vector<unsigned long>{0});
    vector<unsigned long> ans(D);

    for(unsigned long i{0}; i < D; ++i){
        unsigned long mx{0}, mxi{0};
        for(unsigned long j{0}; j < C; ++j){
            unsigned long tmp{v[i][j] + c[j] * (i + 1 - last[j].back())};
            if(tmp > mx){
                mx = tmp;
                mxi = j;
            }
        }
        ans[i] = mxi;
        last[mxi].push_back(i + 1);
    }
    for(auto&& i : last)i.push_back(D + 1);

    mt19937_64 mt{random_device{}()};
    uniform_int_distribution<unsigned long> uid(1, D);

    auto start = chrono::system_clock::now();

    do for(unsigned long iter{0}; iter < 131072; ++iter){
        unsigned long d{uid(mt)};
        auto f = ans[d - 1];
        unsigned long tmp{c[f] * (*upper_bound(begin(last[f]), end(last[f]), d) - d) * (d - *prev(lower_bound(begin(last[f]), end(last[f]), d))) + v[d - 1][f]};
        unsigned long mx{tmp}, mxi{0};
        for(unsigned long i{0}; i < C; ++i){
            unsigned long temp{c[i] * (*upper_bound(begin(last[i]), end(last[i]), d) - d) * (d - *prev(lower_bound(begin(last[i]), end(last[i]), d))) + v[d - 1][i]};
            if(temp > mx){
                mx = temp;
                mxi = i;
            }
        }
        if(mx > tmp){
            last[f].erase(lower_bound(begin(last[f]), end(last[f]), d));
            last[mxi].insert(upper_bound(begin(last[mxi]), end(last[mxi]), d), d);
            ans[d - 1] = mxi;
        }
    } while(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count() > 1800);

    for(const auto& i : ans)cout << i + 1 << endl;

    return 0;
}

Measured memory_bytes: 3740
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| String::from_str(n).unwrap());
    let a = it.next().unwrap();

    for c in a.chars() {
        if c == '9' {
            println!("Yes");
            return;
        }
    }
    println!("No");
    return;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
ll int dp[200007]={0},f[200007]={0};ll int ans=0;ll int in[200007]={0};
void dfs(ll int start,vector<ll int> v[],ll int parent)
{

	f[start]=-1;
	for(ll int i=0;i<v[start].size();i++)
	{
		if(f[v[start][i]]!=-1)
			dfs(v[start][i],v,start);
		dp[start]=max(dp[start],dp[v[start][i]]+1);
	}
}
int main()
{
    fast;
    ll int n,m;
    cin>>n>>m;
    ll int i,x,y;
    vector<ll int> v[n+1];
    for(i=1;i<=m;i++)
    {
    	cin>>x>>y;
    	v[x].PB(y);
    }
    for(i=1;i<=n;i++)
    {
    	if(f[i]!=-1)
    	dfs(i,v,0);
    }
    for(i=1;i<=n;i++)
    	ans=max(ans,dp[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 14048
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll lcm(ll i,ll j){
  if(i<j){
    swap(i, j);
  }
  ll r=i%j;
  ll x=i*j;
  while(r!=0){
    i=j;
    j=r;
    r=i%j;
  }
  return x/j;
}

int twofac(ll a){
  int f=0;
  while(a%2==0){
    a/=2;
    f++;
  }
  return f;
}

int main(){
  int n, m;

  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
    if(a[i]%2==1){
      cout << 0 << endl;
      return 0;
    }
    a[i]/=2;
  }
  int oe=twofac(a[0]);
  repo(i, n-1){
    if(oe!=twofac(a[i])){
      cout << 0 << endl;
      return 0;
    }
  }
  ll l=1;
  rep(i, n){
    l=lcm(l, a[i]);
    if(l>m){
      cout << 0 << endl;
      return 0;
    }
  }
  ll x=l, ans=0;
  while(x<=m){
    ans++;
    x+=2*l;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,x,y;vi a[N];
int mul(int x,int y){
  return ((x%M)*(y%M))%M;
}
int add(int x,int y){
  return ((x%M)+(y%M))%M;
}
pii dfs(int u,int p=0){
  pii dpu={1,1};
  //black,white
  for(auto i:a[u])
    if(i!=p)
      {
        pii dpi=dfs(i,u);
        dpu.F=mul(dpu.F,dpi.S);
        dpu.S=mul(dpu.S,add(dpi.F,dpi.S));
      }
  return dpu;
}
void solve(){
  cin>>n;
  rep(i,0,n-2){
    cin>>x>>y;
    a[x].pb(y);
    a[y].pb(x);
  }
  auto z=dfs(1);
  cout<<add(z.F,z.S);
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 57216
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
 
 
 
int main(){
    
    int n,T,t[200000];
    long long ans=0;
    
    cin>>n>>T;
    rep(i,0,n)cin>>t[i];
    rep(i,0,n-1){
        if(t[i+1]-t[i]>=T)ans+=T;
        else ans+=t[i+1]-t[i];
    }
    ans+=T;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=305;
int n,m,mx,mxid,ans=INF;
int cnt[maxn],a[maxn][maxn];
bool no[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n)rep(j,m)cin>>a[i][j],a[i][j]--;
	rep(i,m){
		rep(j,m)cnt[j]=0;
		rep(j,n)rep(k,m){
			if(!no[a[j][k]]){
				cnt[a[j][k]]++;
				break;
			}
		}
		mx=-1;
		rep(j,m)if(cnt[j]>mx){
			mx=cnt[j];
			mxid=j;
		}
		ans=min(ans,mx);
		no[mxid]=true;
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.Serialization.Formatters;
using System.Text;
using System.Threading.Tasks;
class name
{

    static void Main()
    {

        long[] sei = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long gum = sei[0];
        long[] dem = new long[gum + 5];
        long ans = 0;
            for (int d = 1; d < gum + 1; d++)
        {
            long som = gum / d;
            ans += (d * som * (som + 1)) / 2;
        }
        
        Console.WriteLine(ans);

    }

}

Measured memory_bytes: 28128
import math
import string
import collections
from collections import Counter


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, k = map(int, input().split())
l = readints()
ll = sorted(l)
sum = 0
for i in range(k):
    sum += ll[-(i+1)]
print(sum)


Measured memory_bytes: 68792
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main(void)
{
    char s[80];
    int i, len, a;
     
    gets(s);
     
    len = strlen(s);
     
    for(i = 0;i < len;i++){
         
        a = islower(s[i]);
         
        if(a != 0){
            s[i] = toupper(s[i]);
        }
    }
    printf("%s\n", s);
     
    return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] A = new double[N];
		double tmp;
		double ans = 0;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextDouble();
 		}
		for(int i=0;i<N;i++) {
			for(int j=i+1;j<N;j++) {
				if(A[i] > A[j]) {
					tmp = A[i];
					A[i] = A[j];
					A[j] = tmp;
				}
			}
		}
		for(int i=0;i<N;i++) {
			ans += A[i]/Math.pow(2,N-i);
			if(i == 0) {
				ans += A[i]/Math.pow(2,N-i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include<stdio.h>

int main(){
    int i, j, k = 0;
    int n, count;
    int prime[50000];

    for(i = 1; i < 50000; i++) prime[i] = 1;
    for(i = 2; i <= 224; i++) if(prime[i] == 1) for(j = 2; i * j <= 50000; j++) prime[i * j] = 0;

    while(scanf("%d", &n), n != 0){
        count = 0;
        for(i = 2; i < n/2+1; i++){
            if(prime[i] && prime[n-i]) count++;
        }
        printf("%d\n", count);
    }
    return 0;
};

Measured memory_bytes: 796
N, M = map(int, input().split())
A = list(map(int, input().split()))

x = 0

A = sorted(A, reverse=True)

for i in A:    #総投票数
    x += i

if A[M-1] >= x*float(1/(4*M)):
    print('Yes')
else:
    print('No')

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

#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{

    FAST;
    stack<char>stck;

    string s;
    cin>>s;

    //string ans="";


    for(int i=0;i<s.size();i++){
        char ch;
        if(stck.empty()){
          ch=s[i];
        }else{
          ch=stck.top();
        }
        if(ch!=s[i]){
            stck.pop();
        }else{
           stck.push(s[i]);
        }

    }

    /*
    while(!stck.empty()){
        char c=stck.top();
        ans+=c;
        stck.pop();

    }*/


    //reverse(ans.begin(),ans.end());

    cout<<s.size()-stck.size()<<endl;



//     11111000000000


	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
map <char, int> m;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>s;
	m[s[0]]++;m[s[1]]++;m[s[2]]++;m[s[3]]++;
	if(m.size()!=2){
		cout<<"No";
		return 0;
	}
	if(m[s[0]]==2){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

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

int main(){
	string s;int tc,i,flag;map<string,int>yee;
	while(cin>>tc){
		flag=0;tc--;
		getline(cin,s);getline(cin,s);
		char c=s[s.size()-1];
		yee[s]=1;
		while(tc--){
			getline(cin,s);
			if(yee[s]==1||s[0]!=c){
				flag=1;
			}
			yee[s]=1,c=s[s.size()-1];	
		}
		cout<<(flag?"No\n":"Yes\n");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair

/*
a ^ b + a ^ c = a ^ (b+c)
*/

signed main(){
  int n,res=0;
  cin>>n;
  vector<vector<pi>> v(n);
  for(int i=0;i<n;++i){
    int b;
    cin>>b;
    for(int j=0;j<b;++j){
      int x,y;
      cin>>x>>y;
      v[i].emplace_back(x-1,y);
    }
  }
  for(int i=0;i<(1<<n);++i){
    bool val=true;
    for(int p=0;val&&p<n;++p){
      if(!((i>>p)&1))continue;
      for(auto q:v[p]){
        if(((i>>q.first)&1)!=q.second){
          val=false;
          break;
        }
      }
    }
    if(val){
      int s=0,t=i;
      while(t)s+=t&1, t>>=1;
      res=max(res,s);
    }
  }
  cout<<res;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 50;

int main()
{
    int n, r, c, p;
    int before[MAXN];
    int after[MAXN];

    while(cin >> n >> r && (n || r))
    {
        REP(n) { before[i] = after[i] = n - i;}
        
        rep(k,r)
        {
            cin >> p >> c;
            
            for(int i = 0;i < c; i++)
                after[i] = before[i + p - 1];

            for(int i = 0;i < p - 1; i++)
                after[i + c] = before[i];

            REP(MAXN) before[i] = after[i];
        }
        cout << after[0] << endl;

    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
    int var;
    for(int i = 0; i <5;i++){
        cin >> var;
        if(var == 0) {
            cout << (i+1);
            cout << "\n";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3164