akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<int> v;

void init_uf(int n){
    v.assign(n,-1);
}

int find_(int x){
    if(v[x]<0) return x;
    v[x]=find_(v[x]);
    return v[x];
}

int same_(int a,int b){
    if(find_(a)==find_(b)) return 1;
    return 0;
}

void union_(int a,int b){
    if(same_(a,b)) return;
    int a_p=find_(a),b_p=find_(b);
    if(a_p>b_p) swap(a_p,b_p);
    v[a_p]+=v[b_p]; v[b_p]=a_p;
}

void print_v(){
    rep(i,v.size()) cout<<v[i]<<" ";
    cout<<endl;
}

int size_(int a){
    return -v[find_(a)];
}

int main(){
    int n,m; cin>>n>>m;
    vector<pair<ll,int>> a(n);
    rep(i,n){
        ll A; cin>>A;
        a[i]=mk(A,i);
    }
    sort(al(a));
    init_uf(n);
    rep(i,m){
        int x,y; cin>>x>>y;
        union_(x,y);
    }
    map<int,int> s,cnt;
    rep(i,n){
        int x=find_(i);
        if(!(s.count(x))){
            s[x]=0; cnt[x]=0;
        }
        s[x]++;
    }
    int N=s.size();
    if(N==1) cout<<0<<endl;
    else{
    int r=2*(N-1);
    ll ans=0;
    set<int> q;
    rep(i,n){
        ll A; int st;
        tie(A,st)=a[i];
        int x=find_(st);
        if(!(q.count(x))){
            q.insert(x);
            cnt[x]++;
            ans+=A;
            r--;
        }
    }
    rep(i,n){
        if(r==0) break;
        ll A; int st;
        tie(A,st)=a[i];
        int x=find_(st);
        if(q.count(x)){
            q.erase(x);
            continue;
        }
        if(cnt[x]<N-1 && cnt[x]<s[x]){
            cnt[x]++;
            ans+=A;
            r--;
        }
    }
    if(r==0) cout<<ans<<endl;
    else cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 16256
using System;
class aoj
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] u = Console.ReadLine().Split(' ');
        double a = double.Parse(u[0]), b = double.Parse(u[1]);
        double[] c = new double[n];
        double f = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++)
        {
            double d = int.Parse(Console.ReadLine());
            c[i] = d;
        }
        Array.Sort(c);
        Array.Reverse(c);
        double e = f;
        double g , h = f / a; 
        for (int i = 1; i <= n; i++)
        {
            e += c[i-1];
            g = e / (a + b * i);
            if (g < h)
                goto stop;
            h = g;
        }
        stop:;
        double k = Math.Floor(h);
        Console.WriteLine(k);
    }
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(long &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      std::string xs, ys; scan(xs, ys);
      long res = 1;
      for(long i = 0; i < n; ) {
         if( i == 0 ) {
            res = (xs[i] != ys[i] ? 6 : 3);
         }
         else {
            if( xs[i-1] == ys[i-1] ) {
               res = res * 2 % mod;
            }
            else {
               if( xs[i] != ys[i] ) {
                  res = res * 3 % mod;
               }
            }
         }
         if( xs[i] == ys[i] ) i += 1;
         else i += 2;
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

int main(){
  string s, t;
  cin >> s >> t;
  vector<vector<int>> arf(26,vector<int>(0));
  for(int i=0; i<(int)s.size(); ++i){
    int x=s[i]-'a';
    arf[x].push_back(i+1);
  }
  for(int i=0; i<26; ++i){
    arf[i].push_back(INF);
  }
  long long ans=0;
  int num=0;
  for(int i=0; i<(int)t.size(); ++i){
    int x=t[i]-'a';
    if(arf[x].size() == 1){ cout << -1 << endl; return 0;}
    auto itr = upper_bound(arf[x].begin(),arf[x].end(),num);
    int newnum;
    if(*itr == INF) newnum = arf[x][0];
    else newnum = *itr;
    if(newnum <= num){
      ans += s.size() - num + newnum;
    }else{
      ans += newnum - num;
    }
    num = newnum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1216
n,m=map(int,input().split())
arr=[]
for i in range(n):
	a,b=map(int,input().split())
	arr.append((a,b))
arr.sort()
count=0
i=0
ans=0
while(count<m):
	if(count+arr[i][1]>m):
		ans+=(m-count)*arr[i][0]
		count=m
	else:
		ans+=arr[i][0]*arr[i][1]
		count+=arr[i][1]
	i+=1
print(ans)



Measured memory_bytes: 16892
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let x: u64 = read();
    let ans = (x / 11) * 2;
    println!(
        "{}",
        if x % 11 == 0 {
            ans
        } else if x % 11 > 6 {
            ans + 2
        } else {
            ans + 1
        }
    );
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

string s, rs;

int main() {
	cin >> s;
	rs = s;
	reverse(rs.begin(), rs.end());
	s += 'E';
	rs += 'E';
	int ans = 0;
	int i = 0, j = 0;
	while (true) {
		if (s[i] == 'E' && rs[j] == 'E') {
			ans /= 2;
			break;
		}
		if (s[i] == rs[j]) ++i, ++j;
		else {
			if (s[i] == 'x') {
				++i;
				++ans;
			}
			else if (rs[j] == 'x') {
				++j;
				++ans;
			}
			else {
				ans = -1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, n, x, y;
  string s, t, u;
  cin >> a;
  pr(a * 800 - a / 15 * 200);

  return 0;
}

Measured memory_bytes: 3616
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
//#pragma comment(linker, "/STACK:102400000,102400000")

const int N=1e5+10;
int pre[N];
int main()
{
    int u,v;
    int n,m;
    scanf("%d%d",&n,&m);
    memset(pre,0,sizeof(pre));
    while(m--){
        scanf("%d%d",&u,&v);
        pre[u]++;
        pre[v]++;
    }
    for(int i=1;i<=n;i++)
    if(pre[i]&1){
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int A,B;
  cin>>A>>B;
  int pr;
  if(A>=13){
      pr=B;
  }
  else if(A>=6){
      pr=B/2;
  }
  else{
      pr=0;
  }
  cout<<pr<<endl;
  
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
	int n,i;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	
	if(n%2==0){
		for(i=0;i<n;i+=2){
			cout << a[n-1-i] << " ";
		}
		for(i=0;i<n;i+=2){
			cout << a[i] << " " ;
		}
		cout << endl;
	}else{
		for(i=0;i<n;i+=2){
			cout << a[n-1-i] << " ";
		}
		for(i=1;i<n;i+=2){
			cout << a[i] << " ";
		}
		cout << endl;
	}
}
			

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

int main() {
  int n, i, ans = 0;
  ;
  cin >> n;
  vector<int> h(n);
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }

  for (i = 1; i < n; i++) {
    if (h[i - 1] > h[i]) {
      ans += h[i - 1] - h[i];
    }
  }
  ans += h[n - 1];
  cout << ans << "\n";
  return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 && b!= 1)
    {
       cout<<"Alice"<<endl;
       return 0;
    }
    else if(b==1 && a!= 1)
    {
      cout<<"Bob"<<endl;
      return 0;
    }
    else if(a>b) cout<<"Alice"<<endl;
    else if(b>a) cout<<"Bob"<<endl;
    else
        cout<<"Draw"<<endl;

}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int tmp = 1;
    vector<int> block;
    for(i = 1;i < n;++i){
        if(s.at(i-1) == s.at(i)){
            ++tmp;
        }else{
            block.push_back(tmp);
            tmp = 1;
        }
    }
    block.push_back(tmp);
    ll len = 2*k+1;
    if(len > block.size()){
        cout << n-1 << endl;
        return 0;
    }
    tmp = 0;
    for(i = 0;i < len;++i){
        tmp += block.at(i);
    }
    --tmp;
    for(i = len;i < block.size();++i){
        tmp += block.at(i)-1;
    }
    int ans = tmp;
    for(i = 1;i <= block.size() - len;++i){
        tmp -= block.at(i-1);
        tmp += block.at(i-1)-1;
        tmp -= block.at(i + len-1)-1;
        tmp += block.at(i + len-1);
        if(ans > tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

void solve(std::string s, std::string t)
{
    ll N = s.size();
    ll M = t.size();
    vector<vec> dp(N + 1, vec(M + 1, -1e+18));
    vector<vector<pair<ll, ll>>> back(N + 1, vector<pair<ll, ll>>(M + 1, pair<ll, ll>(-1, -1)));
    dp[0][0] = 0;
    for (ll i = 0; i <= N; i++)
    {
        for (ll j = 0; j <= M; j++)
        {
            if (i + 1 <= N and dp[i + 1][j] < dp[i][j])
            {
                dp[i + 1][j] = dp[i][j];
                back[i + 1][j] = {i, j};
            }
            if (j + 1 <= M and dp[i][j + 1] < dp[i][j])
            {
                dp[i][j + 1] = dp[i][j];
                back[i][j + 1] = {i, j};
            }
            if (i + 1 <= N and j + 1 <= M and s[i] == t[j])
            {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                back[i + 1][j + 1] = {i, j};
            }
        }
    }

    // Back Track
    string ans;

    ll ci = N;
    ll cj = M;
    while (dp[ci][cj] != 0) //(ci != -1 and cj != -1)
    {
        pair<ll, ll> b = back[ci][cj];
        ll pi = b.first;
        ll pj = b.second;
        if (pi + 1 == ci and pj + 1 == cj)
        {
            //cout << ci << "," << cj << endl;
            ans = s.substr(ci - 1, 1) + ans;
        }
        ci = pi;
        cj = pj;
    }
    cout << ans << endl;
}

signed main()
{
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 214656
import java.util.*;
 
public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char[] s = S.toCharArray();
		boolean A = true;
		if(N%2 != 0) {
			A = false;
		}
		for(int i = 0; i < N/2; i++) {
			if(s[i] != s[(N/2)+i]) {
				A = false;
				break;
			}
		}
		if(A == true) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(void) {
	int S, h, m, s;
        scanf("%d", &S);
        h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;	
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 592
package main

import (
	"fmt"
)

func main() {
	var n,k int
	fmt.Scan(&n,&k)

	count := 0
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		if h >= k {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctype.h>

using namespace std;

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

    string S;
    cin >> S;

    S[K-1] = tolower(S[K-1]);

    cout << S << endl; 

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
using namespace std;
 
#define IL inline
#define RE register
#define DB double
#define RT return
#define LL long long
#define INF 1e9+10
#define MAXN 1001000
#define MOD 1000000007
#define MAXM 1001000
#define FOR(i,a,b) for(RE int i=(a); i<=(b); i++)
#define FOR2(i,a,b) for(RE int i=(a); i>=(b); i--)
#define reset(a) memset(a,0,sizeof(a))
#define reset2(a) memset(a,50,sizeof(a)) 
#define lson(x) x<<1
#define rson(x) x<<1|1
#define pq priority_queue
#define P pair<int,int>
 
IL int read()
{
	RE int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}
	RT x*f;
} 
int main()
{
	RE int a=read(),ans=0;
	FOR(i,1,a)
	{
		RE int x=i,num=0;
		while(x)
		{
			x/=10;
			num++;
		}
		if(num%2==1) ans++;
	}
	cout<<ans;
	RT 0;	
} 

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

int main(){
    int A, B, C, D;
    int tun = 1;
    cin >> A >> B >> C >> D;
    while(A > 0 && C > 0)
    {
        if(tun % 2 == 1)
        {
            C -= B;
        }
        else
        {
            A -= D;
        }
        tun++;
    }
    if(tun % 2 == 0)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    int n;
    cin >> n;
    vec fml(n);
    rep(i, n){
        cin >> fml[i];
    }
    long long int dp[101][21];
    memset( dp, 0, sizeof(dp) );
    dp[1][fml[0]] = 1;
    rep(i, n-1){
        rep(j, 21){
            if( dp[i][j] > 0 ){
                int plus = j + fml[i];
                int minus = j - fml[i];
                if( plus <= 20 ) dp[i+1][plus] += dp[i][j];
                if( minus >= 0 ) dp[i+1][minus] += dp[i][j];
            }
        }
    }
    cout << dp[n-1][fml[n-1]] << endl;
}

Measured memory_bytes: 1216
#include<stdio.h>

int main(){
    int N,i,j,ans = 0;
    scanf("%d",&N);
    int d[N];
    for(i = 0; i < N; i++){
        scanf("%d",&d[i]);
    }
    for(i = 0; i < N; i++){
        for(j = i + 1; j < N; j++){
            if(d[i] == d[j]){
                d[j] = 0;
            }
        }
    }
    for(i = 0; i < N; i++){
        if(d[i] == 0){
            continue;
        } else {
            ans++;
        }
    }
    printf("%d",ans);
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  bool appear[26] = {};
  for(int i = 0; i < S.size(); i++) {
    appear[S[i] - 'a'] = true;
  }
  for(int i = 0; i < 26; i++) {
    if(appear[i]) continue;
    cout << (char) (i + 'a') << endl;
    return (0);
  }
  
  cout << "None" << endl;
}

Measured memory_bytes: 512
def main():
    n=input()
    a="Yes"
    if n[0]==n[1]==n[2]==n[3]:
        print("Yes")
    elif n[0]==n[1]==n[2]:
        print("Yes")
    elif n[3]==n[2]==n[1]:
        print("Yes")
    else:
        print("No")

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
a_li = list(map(int,input().split()))

four = 0
two = 0

for i in range(n):
    if a_li[i]%4 == 0:
        four += 1
    elif a_li[i]%2 == 0:
        two += 1

s = n//2

if s <= four:
    print("Yes")
    exit()
    
tmp = n - four*2

if tmp <= two:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define mod 1000000007
 
void solve() {
    unordered_map<string, int> mp;
    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << "\nWA x " << mp["WA"] << "\nTLE x " << mp["TLE"] <<"\nRE x " << mp["RE"];
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3592
result = [0,0]

while line = gets
  a,b,c = line.split(",").map(&:to_i)

  # first condition produced recrangle
  if a**2 + b** 2 == c**2
    result[0] += 1
  elsif a == b
    result[1] += 1
  end
end

puts result.join("\n")

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int X,A;
  cin >> X >> A;
  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    int sa[n+1];
    sa[0]=0;
    int mi=0;
    rep(i,0,n){
        sa[i+1]=sa[i];
        if(s[i]=='(')sa[i+1]++;
        else sa[i+1]--;
        Min(mi,sa[i+1]);
    }
    //cout<<mi<<endl;
    int r=mi;
    reverse(s.begin(),s.end());
    sa[0]=0;
    mi=0;
    rep(i,0,n){
        sa[i+1]=sa[i];
        if(s[i]==')')sa[i+1]++;
        else sa[i+1]--;
        Min(mi,sa[i+1]);
    }
    reverse(s.begin(),s.end());
    rep(i,0,-r)cout<<'(';
    cout<<s;
    rep(i,0,-mi)cout<<')';
    cout<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector< int>
#define all(v)   v.begin(),v.end()  
#define take(n)   ll int n;cin>>n;
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
int main() {
	speed();
int n,m;
    cin>>n>>m;
    vector<int>v(m);
    int sum=0;
    for(int i=0;i<m;i++){
        cin>>v[i];
        sum+=v[i];
    }
    if(sum>n){
        cout<<"-1";
    }
    else{
         cout<<abs(sum-n);
    }
    
	return 0;
}

 

Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const int MAXN = 2007;
const int MOD = 1000000007;
const int INF = 1000000000;
const LL LINF = INF * (LL)INF;
const LD PI = acos(-1.0);

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	//freopen("hear.in", "r", stdin);
	//freopen("hear.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0)
	{
		cout << "Zero";
		return 0;
	}
	if (a > 0)
	{
		cout << "Positive";
		return 0;
	}
	if ((b - a + 1) & 1)
		cout << "Negative";
	else cout << "Positive";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,m;
  cin>>n>>m;
  vector<int> hs(n);
  for(int i=0;i<n;i++) cin>>hs[i];

  vector<int> ans(n,1);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(hs[a]<=hs[b]) ans[a]=0;
    if(hs[b]<=hs[a]) ans[b]=0;
  }

  cout<<accumulate(ans.begin(),ans.end(),0)<<newl;
  return 0;
}


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

using namespace std;



int main(int argc, char* argv[])
{

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;
  const int n = s.size();

  bool ok = s[0] == 'A'; s[0] = tolower(s[0]);

  bool foundC = false;
  for (int i = 2; i < n-1; ++i)
  {
    if (s[i] == 'C')
    {
      foundC = true;
      s[i] = 'c';
      break;
    }
  }
  ok = ok && foundC;

  for (auto c : s) ok = ok && islower(c);

  if (ok) cout << "AC\n";
  else cout << "WA\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  string T; cin >> T;
  ll dr = 0;
  for(ll i = 0; i < T.size(); i++) {
  	if (T[i] == '?') T[i] = 'D';
  }
  cout << T;
}

Measured memory_bytes: 3752
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
     console.log(a * b,(a + b) * 2)//????????????????????????
  }(params[0],params[1])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i) 
        cin >> h[i];
    int ans = 0;
    bool ok = false;
    while (!ok) {
        int mn = 101;
        int pidx = 0;
        for (int i = 0; i < n; ++i) {
            if (h[i] == 0) {
                if (i > 0 && h[i - 1] == 0) {
                    pidx = i + 1;
                    continue;
                }
                for (int j = pidx; j < i; ++j) {
                    h[j] -= mn;
                }
                if (mn != 101) ans += mn;
                pidx = i + 1;
                mn = 101;
                continue;
            }
            mn = min(h[i], mn);
        }
        for (int i = pidx; i < n; ++i) h[i] -= mn;
        if (mn != 101) ans += mn;
        int csum = 0;
        for (int i = 0; i < n; ++i) {
            csum += h[i];
        }
        if (csum == 0) ok = true;
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n,t;
vi a;

int main(){
  cin >> n >> t;
  a.resize(n);
  rep(i,n) cin >> a[i];

  vi mn(n);
  vi mx(n);
  int mini=INF, maxi=0;
  rep(i,n){
    if(a[i] < mini) mini = a[i];
    mn[i] = mini;
  }
  rep(i,n){
    if(a[i] > maxi) maxi = a[i];
    mx[i] = maxi;
  }
  int ans = 1;
  int dmaxi = a[0]-mn[0];
  rrep(i,n-1){
    if(a[i] - mn[i] > dmaxi){
      dmaxi = a[i] - mn[i];
      ans = 1;
    }
    else if(a[i] - mn[i] == dmaxi){
      ans++;
    }
    else continue;
  }
  cout << ans << endl;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();

		BigDecimal bd1 = new BigDecimal(a);
		BigDecimal bd2 = new BigDecimal(b);
		BigDecimal result = bd2.multiply(bd1);
		String ans = result.toString();
		int index = ans.indexOf(".");
		System.out.println(ans.substring(0,index));
	}
}


Measured memory_bytes: 27224
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int n, num, ans;
	double t, h, w, b;
	for (; ~fscanf(stdin, "%d", &n), n; P(d, ans)) {
		fscanf(stdin, "%d%lf%lf", &num, &h, &w);
		ans = num;
		h /= 100.0;
		b = w / (h*h);
		t = fabs(22.0 - b);
		n--;
		while (n--) {
			fscanf(stdin, "%d%lf%lf", &num, &h, &w);
			h /= 100.0;
			b = w / (h*h);
			if (fabs(22.0 - b) < t) t = fabs(22.0 - b), ans = num;
			else if (fabs(22.0 - b == t)) ans = ans < num ? ans : num;
		}
	}
	return 0;
}

Measured memory_bytes: 628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApp9
{
    class Program
    {
        public static void Main(string[] args)
        {
            double a = double.Parse(Console.ReadLine());
            double b = a * 2 * Math.PI;
            double c = a * a * Math.PI;
            Console.WriteLine("{0} {1}", c, b);
        }
    }
}

Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
using namespace std;
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

signed main(){

    fastIO
    
    int x;
    cin >> x;
    int ans = (x/500)*1000;
    x -= (x/500)*500;
    // trace(x);
    cout << ans + ((x/5)*5) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
string u="aiueo";
 

int main(){
    int n;
    while(cin >> n,n){
        vector<string> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        vector<string> t;
        for (int i = 0; i < n; i++) {
            string v="";
            bool f=true;
            for (int j = 0; j < s[i].length(); j++) {
                if(f){
                    v.pb(s[i][j]);
                    f=false;
                }
                for (int k = 0; k < 5; k++) {
                    if(s[i][j]==u[k]) f=true;
                }
            }
            t.pb(v);
        }
        bool c=true;
        for (int i = 1; i <= 51; i++) {
            set<string> st;
            bool f=true;
            for (int j = 0; j < n; j++) {
                string v=t[j].substr(0,i);
                if(st.find(v)!=st.end()){
                    f=false;
                }
                st.insert(v);
            }
            if(f){
                cout << i << endl;
                c=false;
                break;
            }
        }
        if(c) cout << "-1" << endl;
    }
    return 0;
}



Measured memory_bytes: 3244
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	String a = sc.next();

    	if(Character.isUpperCase(a.charAt(0))) {
    		System.out.println("A");
    	} else {
    		System.out.println("a");
    	}


    }
}

Measured memory_bytes: 26988
def get_prime_list(n):
    L = tuple(range(2,n+1))
    for i in range(2,int((n+1)**0.5)):
        if i not in L:
            continue
        L = tuple(j for j in L if j <= i) + tuple(j for j in L if j > i and j % i != 0)
    return L

Q = int(input())
lr = [tuple(map(int,input().split())) for _ in range(Q)]
prime_list = get_prime_list(100000)
like_num = tuple(i for i in prime_list if (i+1)//2 in prime_list)
L = [0] * 100002
for i in range(3,100001,2):
    if i in like_num:
        L[i] = L[i-2]+1
    else:
        L[i] = L[i-2]
for l,r in lr:
    print(L[r]-L[l-2])

Measured memory_bytes: 75352
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var a = Read();
        var b = Read();   
        var c = Read();
        Console.WriteLine((a - c) * (c - b) > 0 ? "Yes" : "No");
    }

    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int Read()
    {
        int res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	static int n;
	static int[] A;

	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		A = new int[n];
		String[] str = br.readLine().split(" ");

		for(int i = 0; i < n; i++){
			A[i] = Integer.parseInt(str[i]);
		}

		int q = Integer.parseInt(br.readLine());
		int[] m = new int[q];
		String[] str2 = br.readLine().split(" ");

		for(int i = 0; i < q; i++){
			m[i] = Integer.parseInt(str2[i]);
		}

		for(int i = 0; i < q; i++){
			if(solve(0 , m[i])){
				System.out.println("yes");
			}else{
				System.out.println("no");
			}
		}
	}

	public static boolean solve(int i, int m){
		if(m == 0){
			return true;
		}
		if(i >= n){
			return false;
		}
		boolean res = solve(i + 1, m) ||solve(i + 1, m - A[i]);
		return res;
	}
}

Measured memory_bytes: 24896
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS
int H, W;
char c[21][21];
P n[11];
int N = 0;
P s;
int po[11] = { 1,2,4,8,16,32,64,128,256,512,1024 };
int dp[1024][11];

bool flag = true;
int CalcCost(P p1, P p2) {
	Q q;
	q.push(p1);
	int cost[20][20];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cost[i][j] = 100000;
		}
	}
	cost[p1.first][p1.second]=0;
	while (!q.empty()) {
		int x = q.front().first,
			y = q.front().second; q.pop();
		int dh[4] = { 1 , -1 , 0 ,  0 };
		int dw[4] = { 0 ,  0 , 1 , -1 };
		for (int i = 0; i < 4; i++) {
			int th = x + dh[i],
				tw = y + dw[i];
			if (0 <= th && th < H && 0 <= tw && tw < W) {
				if (c[th][tw] != 'x' && cost[th][tw] > cost[x][y] + 1) {
					if (p2 == make_pair(th, tw)) {
						return cost[x][y] + 1;
					}
					else {
						cost[th][tw] = cost[x][y] + 1;
						q.push(make_pair(th, tw));
					}
				}
			}
		}
	}
	return -1;
}

void CalcStartToPoint() {
	Q q;
	q.push(s);
	int cost[20][20];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cost[i][j] = 100000;
		}
	}
	cost[s.first][s.second] = 0;
	int count = 0;
	while (!q.empty()) {
		int h = q.front().first,
			w = q.front().second; q.pop();
		if (c[h][w] == '*') {
			count++;
			for (int i = 0; i < N; i++) {
				if (n[i] == make_pair(h, w)) {
					dp[po[i]][i] = cost[h][w];
					break;
				}
			}
		}
		int dh[4] = { 1 , -1 , 0 ,  0 };
		int dw[4] = { 0 ,  0 , 1 , -1 };
		for (int i = 0; i < 4; i++) {
			int th = h + dh[i],
				tw = w + dw[i];
			if (0 <= th && th < H && 0 <= tw && tw < W) {
				if (c[th][tw] != 'x' && cost[th][tw] > cost[h][w] + 1) {
					cost[th][tw] = cost[h][w] + 1;
					q.push(make_pair(th, tw));
				}
			}
		}
	}
	if (count!=N) {
		flag = false;
	}
}

int main() {
	while (1) {
		scanf("%d%d", &W, &H);
		if (H == 0) {
			break;
		}
		N = 0;
		for (int i = 0; i < H; i++) {
			scanf("%s", c[i]);
			for (int j = 0; j < W; j++) {
				if (c[i][j] == '*') {
					n[N++] = make_pair(i, j);
				}
				else if (c[i][j] == 'o') {
					s = make_pair(i, j);
				}
			}
		}
		for (int i = 0; i < po[N]; i++) {
			for (int j = 0; j < N; j++) {
				dp[i][j] = 1000000;
			}
		}
		flag = true;
		CalcStartToPoint();
		if (flag == false) {
			printf("-1\n");
			continue;
		}
		int cost[11][11] = {};
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				cost[j][i] = cost[i][j] = CalcCost(n[i], n[j]);
			}
		}
		for (int i = 0; i < po[N]; i++){
			for (int j = 0; j < N; j++){
				for (int k = 0; k < N; k++) {
					if ((i & po[k]) == 0 && j!=k) {
						dp[i + po[k]][k] = min(dp[i][j] + cost[j][k], dp[i + po[k]][k]);
					}
				}
			}
		}
		int ans = 1000000;
		for (int i = 0; i < N; i++) {
			ans = min(ans, dp[po[N]-1][i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	ll n;cin>>n;ll sum=0;
	for(ll i=1;i<=n;i++){
		ll m=n/i;
		sum+=(i*(m)*(m+1))/2;
	}
	cout<<sum;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);	
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3584
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        X: usize,
    }
    let mut ans = 0;
    let mut total = 0;
    for i in 1..1000000{
        total += i;
        if total >= X{
            ans = i;
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<vector>

using namespace std;

map<char, int> maxChar;
int maxCount = 0;
char c;

int getAns(string s, int step) {
	bool isSame = true;
	set<char> sc;
	for (int i = 0; i < s.length(); i++) {
		sc.insert(s[i]);
		if (sc.size() > 1) {
			isSame = false;
			break;
		}
	}

	if (isSame)
		return step;

	string s1;
	bool isLess = false;
	for (int i = 0,j = 0; i < s.length(); i++, j++) {
		if (s[j] != c) {
			if (!isLess && (s[j + 1] == c || j == s.length() - 1)) {
				if (j == s.length() - 1)
					break;
				isLess = true;
				j--;
				continue;
			}
			if (j + 1 < s.length() && s[j + 1] == c) {
				s1.push_back(c);
			} else {
				s1.push_back(s[j]);
			}
		} else{
			s1.push_back(c);
		}
	}

	return getAns(s1, step + 1);
}

int main() {
	string t;
	cin >> t;
	//for (int i = 0; i < t.length(); i++) {
	//	if (maxChar.find(t[i]) == maxChar.end()) {
	//		maxChar[t[i]] = 1;
	//	} else {
	//		maxChar[t[i]] ++;
	//	}
	//}


	//for (auto& m : maxChar) {
	//	if (m.second > maxCount) {
	//		maxCount = m.second;
	//	}
	//}

	//vector<int> chars;

	//if (maxCount == 1) {
	//	chars.push_back(t[t.length() / 2]);
	//} else {

	//	int minDif = 1111;
	//	int mid = t.length() / 2;
	//	set<char> verge;
	//	for (auto& m : maxChar) {
	//		if (m.second == maxCount) {
	//			chars.push_back(m.first);
	//		}
	//	}
	//}

	int ans = 1111;
	set<char> vis;
	//for (auto & v : chars) {
	//	c = v;
	//	int tmp = getAns(t, 0);
	//	if (tmp < ans)
	//		ans = tmp;
	//}

	for (int i = 0; i < t.length(); i++) {
		c = t[i];
		if (vis.find(c) == vis.end()) {
			vis.insert(c);
			int tmp = getAns(t, 0);
			if (tmp < ans)
				ans = tmp;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int g=200005;
int n,a[g],b[g],m;
long long s;

int main()
{
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		for(;a[i]<a[b[m]];m--)
			s+=(long long)a[b[m]]*(b[m]-b[m-1])*(i-b[m]);
		b[++m]=i;
	}
	for(;m;m--)
		s+=(long long)a[b[m]]*(b[m]-b[m-1])*(n-b[m]+1);
	printf("%lld",s);
	return 0;
}


Measured memory_bytes: 1792
// Problem : B - 1%
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#define XOX
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define ll          long long
#define ld          long double
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
#define vvd(a,b,name)    vector<vector<double>> name(a,vector<double>(b,-1))
//const ld pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

void solve(){
	vector<ll> ci;
	double p=100;
	double r=1.01;
	rep(i,0,3765){
		p*=r; 
		p=floor(p);
		ci.pb(p);
		
	}
	ll x;cin>>x;
	int ans=lower_bound(all(ci),x)-ci.begin();
	cout<<ans+1<<endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int ans=0,x=1;
	for(int i=0;i<n;i++){
		if(a[i]==x){
			x++;
			ans++;
		}
	}
	if(ans==0)
	cout<<-1<<endl;
	else
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N, R = MI()

HR = R if N >= 10 else R+(100 * (10 - N))

print(HR)


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

int main(){
	string str;
	string word;
	int cnt = 0;
	cin >> word;
	string::iterator wp, sp;
	wp = word.begin();
	while(wp != word.end()){
		*wp = tolower(*wp);
		wp++;
	}
	while(true){
		cin>>str;
		if(string::npos != str.find("END_OF_TEXT",0)) break;
		sp = str.begin();
		while(sp != str.end()){
			*sp = tolower(*sp);
			sp++;
		}
		if(str == word) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________



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

  long double a[n], ans = 0.0;

  for(int i = 0; i < n; i++)
  {
    long double x; 
    cin >> x;
    ans += 1.0/x;
  }

  cout << fixed << setprecision(12) << 1.0/ans;

 return 0;
}

Measured memory_bytes: 256