akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define endl "\n"
#define rep(i,n) for(int i=0;i<=n;i++)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;


int main(){
    fast;
    bool ans=false;
    int n;
    cin >> n;
    int curr = 0;
    int a,b;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a==b) curr++;
        else curr=0;
        if(curr==3){
            ans=true;
            break;
        }
    }
    if(ans) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 3652
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn binary_search_left(v: &Vec<(usize, usize)>, x: usize) -> usize {
    let mut l: isize = -1;
    let mut r: isize = v.len() as isize;
    while r - l > 1 {
        let m = (r + l) / 2;
        if v[m as usize].0 < x {
            l = m;
        } else {
            r = m;
        }
    }
    r as usize
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut a = vec![];
    let mut b = vec![];
    for i in 0..m {
        let (ai, bi): (usize, usize) = parse!(it, 2);
        a.push((ai - 1, i));
        b.push((bi - 1, i));
    }
    a.sort();
    b.sort();
    let mut removed = vec![false; m];
    let mut l = 0;
    let mut ret = 0;
    for (bi, i) in b {
        if removed[i] {
            continue;
        }
        ret += 1;
        let r = binary_search_left(&a, bi);
        for i in l..r {
            removed[a[i].1] = true;
        }
        l = r;
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 12540
#include<iostream>
#include<cstring>
const int N = 1e5+10;

typedef long long ll;

ll a[N];

using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll cnt = 0;
    ll cnt1 = 0;
    ll f = 0;

    for (int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
        if(a[i] % 4 == 0) cnt ++;
        else if(a[i] % 2 == 0) cnt1++;
    }

    if(cnt1 % 2 == 1)
    {
        cnt1 --;
        f++;
    }

    n -= cnt1;
    n -= cnt*2;
    if(n <= 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = long.Parse(_[0]);
            var k = long.Parse(_[1]);

            var d = new Dictionary<long,long>();
            for(var i = 0; i < n; i++){
                var __ = Console.ReadLine().Split();
                var a = long.Parse(__[0]);
                var b = long.Parse(__[1]);

                if(d.ContainsKey(a)){
                    d[a] += b;
                }else{
                    d.Add(a,b);
                }
            }

            var count = 0L;
            foreach(var item in d.OrderBy(i => i.Key)){
                count += item.Value;
                if(count >= k){
                    Console.WriteLine(item.Key);
                    break;
                }
            }

        }
    }
}


Measured memory_bytes: 20812
n, x = map(int, input().split())
a = list(map(int, input().split()))
c = 0
if a[0] > x:
    c += a[0] - x
    a[0] = x
for i in range(1, n):
    if a[i - 1] + a[i] > x:
        c += a[i - 1] + a[i] - x
        a[i] = x - a[i - 1]
print(c)

Measured memory_bytes: 14068
#ABC 098 C Attention

#いちいち全部数え直さない方がいい説
n = int(input())
s = input()
cnt = 0
cnt_list = []

for i in range(1,n):
    if s[i] == "E":
        cnt += 1
cnt_list.append(cnt)
for j in range(1,n):
    if s[j-1] == "W":
        cnt += 1
    if s[j] == "E":
        cnt -= 1
    cnt_list.append(cnt)

print(min(cnt_list))

Measured memory_bytes: 15520
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
a=a1+a2+a3
n=int(input())
k="No"
c=[0,0,0,0,0,0,0,0,0]
for i in range(n):
    b=int(input())
    if b in a:
        c[a.index(b)]=1
c=[0]+c
if c[1]==1 and c[2]==1 and c[3]==1:
    k="Yes"
elif c[1]==1 and c[4]==1 and c[7]==1:
    k="Yes"
elif c[1]==1 and c[5]==1 and c[9]==1:
    k="Yes"
elif c[2]==1 and c[5]==1 and c[8]==1:
    k="Yes"
elif c[3]==1 and c[6]==1 and c[9]==1:
    k="Yes"
elif c[4]==1 and c[5]==1 and c[6]==1:
    k="Yes"
elif c[7]==1 and c[8]==1 and c[9]==1:
    k="Yes"
elif c[3]==1 and c[5]==1 and c[7]==1:
    k="Yes"
print(k)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll cnt[n]={};
    ll cnt2[n]={};
    vector<ll> a(n);
    rep(i,n){cin>>a.at(i);a[i]--;}
    rep(i,n){
        repr(j,i+1,n){
            if(a[i]>a[j]){
                cnt[i]++;
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(i==j){continue;}
            if(a[i]>a[j]){
                cnt2[i]++;
            }
        }
    }
    ll res=0; 
    rep(i,n){
        res += ll(cnt2[i])*(k*(k-1)/2%MOD);
        res %= MOD;
    }
    rep(i,n){
        res += cnt[i]*k;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using pll = pair<ll, ll>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> X(N), L(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> L[i];
    vector<pll> is(N);
    for (int i = 0; i < N; i++) is[i] = make_pair(X[i] - L[i], X[i] + L[i]);
    sort(is.begin(), is.end());
    vector<pll> res;
    for (auto& x : is) {
      if (res.empty() || res.back().snd <= x.fst) {
        res.push_back(x);
        continue;
      }
      if (res.back().snd <= x.snd) {
        continue;
      }
      res.pop_back();
      res.push_back(x);
    }
    cout << res.size() << endl;
  }
  return 0;
}


Measured memory_bytes: 5492
#include<stdio.h>
#include<string.h>

int main(){

    int a, b, c, d, e, f = 0;
    double x, y;

    while ( (fscanf(stdin, "%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f )) != EOF){
        y  = f - d * ((double)c / a);
        y /= e - d * ((double)b / a);
        x  = (double)c / a - ((double)b / a) * y;

        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    cout<<(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

def is_prime(n):
    if n <= 1:
        return False

    if n == 2:
        return True

    if n % 2 == 0:
        return False

    for i in range(3, math.ceil(math.sqrt(n)), 2):
        if n % i == 0:
            return False

    return True


X = int(input())
while True:
    if is_prime(X):
        print(X)
        break

    X += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  double A, B, H, M;
  double H_rad, M_rad, Z_rad, ans;
  double A_x, A_y, B_x, B_y;
  cin >> A >> B >> H >> M;
  H_rad = 360.0 / 12 * (H + M / 60) * M_PI / 180.0;
  M_rad = 360.0 / 60 * M * M_PI / 180.0;
  H_rad = 2*M_PI - H_rad + M_PI / 2.0;
  M_rad = 2*M_PI - M_rad + M_PI / 2.0;
  A_x = A*cos(H_rad);
  A_y = A*sin(H_rad);
  B_x = B*cos(M_rad);
  B_y = B*sin(M_rad);
  ans = sqrt((B_x-A_x) * (B_x-A_x) + (B_y-A_y) * (B_y-A_y));
  
  printf("%0.20f", ans);
}

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

int main()
{   int a[100001],n,i,len=0;
    scanf("%d",&n);
    a[0]=0;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
            len+=abs(a[i]-a[i-1]);
    }
    a[n+1]=0;
    len+=abs(a[n]);
    for(i=1;i<=n;i++){
        if(i==0){
            printf("%d\n",len);
        }else{
            if(a[i]>=a[i-1]&&a[i]<=a[i+1]){
                printf("%d\n",len);
            }
            else if(a[i]<=a[i-1]&&a[i-1]<=a[i+1]){
                printf("%d\n",len-2*abs(a[i]-a[i-1]));
            }
            else if(a[i]<=a[i+1]&&a[i+1]<=a[i-1]){
              printf("%d\n",len-2*abs(a[i]-a[i+1]));  
            }
            else if(a[i+1]<=a[i]&&a[i]<=a[i-1]){
                printf("%d\n",len);
            }
            else if(a[i-1]<=a[i+1]&&a[i+1]<=a[i]){
                printf("%d\n",len-2*abs(a[i+1]-a[i]));
            }
            else if(a[i+1]<=a[i-1]&&a[i-1]<=a[i]){
                printf("%d\n",len-2*abs(a[i]-a[i-1]));
            }
        }
    }
    
    

    return 0;
}


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

int n;
int d[100010];
int sg[100010];
int x,y;
vector<int> g[100010];

void dfs(int o,int fa)
{
	d[o] = 1;
    for (int i=0;i<g[o].size();i++) 
		if (g[o][i]!=fa) 
		{
			dfs(g[o][i],o);
			d[o]+=d[g[o][i]];
		}
}

int dfs2(int o,int fa) 
{
    if (o!=1 && g[o].size()==1)
	   return sg[o] = 0;
	   
    for (int i=0;i<g[o].size();i++)
        if (g[o][i] != fa)
            sg[o] ^= dfs2(g[o][i],o) + 1;
    return sg[o];
}

int main()
{
	cin>>n;
	for (int i=1;i<n;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,-1);
	dfs2(1,-1);
	if (sg[1]) return 0*puts("Alice");
	return 0*puts("Bob");
}


Measured memory_bytes: 12800
a,b,c = map(int,input().split())
x = 1
lst = []
while True:
    r = (a*x-c)%b
    if  r == 0:
        ans = "YES"
        break
    if r in lst:
        ans = "NO"
        break
    lst.append(r)
    x += 1
    
print(ans)


Measured memory_bytes: 2940
def det(n):
    seven = range((n // 7) + 1)
    four = range((n // 4) + 1)
    for i in seven:
        for p in four:
            if (i*7 + p*4) == n:
                return 'Yes'
    return 'No'
x = int(input())
print(det(x))

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  ll ans = 0;
  if (N & 1) {
    ans = (N * (N / 2));
  } else {
    ans = (N * ((N - 1) / 2)) + N / 2;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

// 163
/* c
int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = 0;
    }
    for(int i = 0; i < n - 1; i++){
        int x;
        cin >> x;
        a[x - 1]++;
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }
}
*/
/* d */
int main(){
    ll mod = pow(10, 9) + 7;
    ll n, k;
    cin >> n >> k;

    ll max = 0;
    ll min = 0;
    ll ans = 0;

    for(int i = k; i <= n; i++){
        min = static_cast<long long>(i) * (0 + i - 1) / 2;
        max = i * (n + (n - i + 1)) / 2;
        ans += (max - min + 1);
        ans %= mod;
    }
    cout << ans + 1 << endl;
}




Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int main(){
    ll n;
    cin>>n;
    map<string,ll> m;
    string s;
    m["AC"]=0;
    m["WA"]=0;
    m["TLE"]=0;
    m["RE"]=0;
    while(n){
        cin>>s;
        m[s]++;
        n--;
    }

    cout<<"AC x "<<m["AC"]<<endl;
     cout<<"WA x "<<m["WA"]<<endl;
      cout<<"TLE x "<<m["TLE"]<<endl;
       cout<<"RE x "<<m["RE"]<<endl;


}


Measured memory_bytes: 81196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  string s;
  cin>>s;
  int n=s.size();
  rep(i,n)cout<<"x";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI c(n-1), s(n-1), f(n-1);
    REP(i, n-1) cin >> c[i] >> s[i] >> f[i];
    VI ans(n, 0);
    REP(i, n) {
        FOR(j, i, n-1) {
            if(ans[i] < s[j]) ans[i] = s[j];
            else if(ans[i] % f[j] == 0) {
            }
            else ans[i] = ((ans[i] / f[j]) + 1) * f[j];
            ans[i] += c[j];
        }
    }
    REP(i, n) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string a,b,c;
	cin >> a >> b >> c;
	transform(a.begin(),a.end(),a.begin(),::toupper);
	transform(b.begin(),b.end(),b.begin(),::toupper);
	transform(c.begin(),c.end(),c.begin(),::toupper);
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int ans = -1;
    for (int n = 1;;n++) {
        int m = n,
            cnt = 0;
        while (m % 100 == 0) {
            m /= 100;
            cnt++;
        }

        if (cnt == D) N--;

        if (N == 0) {
            ans = n;
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var t = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            var L = int.Parse(line[2]);
            if (t == 0 && d == 0 && L == 0) break;
            getAns(t, d, L);
        }
    }
    static void getAns(int t, int d, int L)
    {
        var count = 0;
        var w = int.Parse(Console.ReadLine().Trim());
        var mt = w >= L ? d : -1;
        for (int i = 1; i < t; i++)
        {
            if (i <= mt) count++;
            w = int.Parse(Console.ReadLine().Trim());
            if (w >= L) mt = i + d;
        }
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 17964
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int Y[]={0,1,0,-1};
int X[]={1,0,-1,0};
  int h,w,n,ny,nx,min=1e9,i,j,x[800010],y[800010],t=0,r,a;
int main(){
  char d[1010][1010]={};
  int c[1010][1010]={};
  scanf("%d %d %d",&h,&w,&n);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf(" %c",&d[i][j]);
      if(d[i][j]=='S')d[y[0]=i][x[0]=j]='#';
    }
  }
  t=0;
  min=1e9;
  for(r=1;r-t;t++){
    for(i=0;i<4;i++){
      a=MIN(MIN(y[t]-1,h-y[t]),MIN(x[t]-1,w-x[t]));
      if(a)a=(a-1)/n+1;
      min=MIN(min,a);//printf("%d\n",min);
      ny=y[t]+Y[i];
      nx=x[t]+X[i];
      if(d[ny][nx]-'.')continue;
      c[ny][nx]=c[y[t]][x[t]]+1;
      d[y[r]=ny][x[r]=nx]='#';
      if(c[ny][nx]<=n){
	a=MIN(MIN(ny-1,h-ny),MIN(nx-1,w-nx));	
	if(a)a=(a-1)/n+1;
	min=MIN(min,a);
	r++;
      }      
    }
  }
  
  printf("%d\n",min+1);
  return 0;
}


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

int main() {
	int N;
	cin>>N;
	vector<double> vec(N);
	for(int i=0; i<N; i++){
		cin>>vec.at(i);
	}
	sort(vec.begin(),vec.end());
	double sum=(vec.at(0)+vec.at(1))/2;

	for(int i=2; i<N; i++){
		sum=(sum+vec.at(i))/2;
	}

	cout <<sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}



ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,e,f,g,h;
ll x[800005],y[800005],z[900005];
ll in[800005];
ll vnum = 0,sum,ans;
bool dame;
bool check[500005];

ll dfs(ll a,ll space){
	ll num = G[a].size();
	vnum += num;
	
    if(num == 0){
        return 0;
    }else{
		for(int i=0;i<num;i++){
			x[i + space] = dfs(G[a][i],vnum);
		}
		sort(x + space,x+num + space);
		ll a = 0;
		for(i = 0;i<num;i++){
			a = max(a,x[i+space] + num - i);
		}
		return a;

    }
}

int main(){
    cin>>n;
    for(i=0;i<n-1;i++){
        cin >> a;
        //i+2番目はaに負けた
        G[a].pb(i+2);        
    }
    p(dfs(1,0));
    //p(ans);
    return 0;
}

Measured memory_bytes: 37248
n = int(input())
nums = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
pres = [0]
for i in nums:
    pres.append(pres[-1] + i)
for i in range(n):
    temp = nums[i] * (pres[n] - pres[i+1])
    ans += temp
    ans %= mod
print(ans)


Measured memory_bytes: 31440
#include <iostream>
using namespace std;
int main() 
{
	double w;
	while (std::cin >> w) {
		if (w <= 48.00)
            		cout << "light fly" << endl;
		 else if (w > 48.00 && w <= 51.00)
			cout << "fly" << endl;
		else if (w > 51.00 && w <= 54.00)
            		cout << "bantam" << endl;
		else if (w > 54.00 && w <= 57.00)
            		cout << "feather" << endl;
		else if (w > 57.00 && w <= 60.00)
            		cout << "light" << endl;
		else if (w > 60.00 && w <= 64.00)
            		cout << "light welter" << endl;
		else if (w > 64.00 && w <= 69.00)
            		cout << "welter" << endl;
		else if (w > 69.00 && w <= 75.00)
            		cout << "light middle" << endl;
		else if (w > 75.00 && w <= 81.00)
            		cout << "middle" << endl;
		else if (w > 81.00 && w <= 91.00)
            		cout << "light heavy" << endl;
		else if (w > 91.00)
            		cout << "heavy" << endl;
    }
	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  double max_C = 0;
  int su_wa = 100*a, su = 0;
  auto update = [&](int x, int y, int z, int w) {
    double res = c*z + d*w;
    res /= double(100*(a*x+b*y)+c*z+d*w);
    if (res > max_C) {
      max_C = res;
      su_wa = 100*(a*x+b*y)+c*z+d*w;
      su = c*z+d*w;
    }
    return res;
  };
  for (int x = 0; x <= 30; ++x) {
    for (int y = 0; y <= 30; ++y) {
      if (x == 0 && y == 0) continue;
      for (int z = 0; z <= f; ++z) {
        if (f - 100*(a*x+b*y) - c*z < 0) break;
        int max_w = (f - 100*(a*x+b*y) - c*z)/d; //wの範囲を絞る
        for (int w = 0; w <= max_w; ++w) {
          double X = c*z+d*w;
          X /= double(a*x+b*y);
          if (X > e) break;
          update(x,y,z,w); 
        }
      }
    }
  }
  cout << su_wa << " " << su << endl; 
  return 0;
}

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  char s[10];
  cin >> s;
  int n1=s[5]-'0',n2=s[6]-'0'; 
  if (n1==0 && n2<5) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int d, s, t;
    cin>>d>>s>>t;
    cout<<((d <= s*t) ? "Yes\n" : "No\n");
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);

	ll X,K,D; cin>>X>>K>>D;
	X = abs(X);
	ll stc = X/D;
	cerr << stc << endl;
	if(stc >= K){
		ll ans = X - K*D;
		cout << ans << endl;
		return 0;
	}

	ll nokori = K-stc;
	cerr << nokori << endl;
	if(nokori%2 == 1){
		ll ans = X - (stc+1)*D;
		ans = abs(ans);
		cout << ans << endl;
		return 0;
	}else{
		ll ans = X - (stc)*D;
		ans = abs(ans);
		cout << ans << endl;
		return 0;
	}

}


Measured memory_bytes: 3628
# coding: utf-8
# Here your code !

def func():
    try:
        line = input()
        line = input().rstrip()
        numbers = line.split(" ")
    except:
        print("input error")
        return -1
        
    numbers.reverse()
    result=""
    for item in numbers:
        result += item+" "
    
    print(result.rstrip(" "))

func()

Measured memory_bytes: 7428
#include <bits/stdc++.h>
#define MAX_N 100000
#define INF 0x3f3f3f3f
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, a[MAX_N+5], f[MAX_N+5];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int i = 2; i <= n; i++) {
		f[i] = INF;
		for (int j = 1; j <= m; j++) if (i > j)
			f[i] = min(f[i], f[i-j]+abs(a[i]-a[i-j]));
	}
	return printf("%d\n", f[n]), 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if(c == 'A') cout << "T" << '\n';
  if(c == 'T') cout << "A" << '\n';
  if(c == 'C') cout << "G" << '\n';
  if(c == 'G') cout << "C" << '\n';
  
  return 0;
  
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vl h(n);
    rep(i, n) cin >> h[i];
    ll ans = h[0];
    REP(i, 1, n) {
        if(h[i] >= h[i-1]) ans += h[i] - h[i-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;

int main() {
	int k, x;
	scanf("%d%d", &k, &x);
	for (int i = k - 1;i >= 0;i--) {
		printf("%d ", x - i);
	}
	for (int i = 1;i <= k - 1;i++) {
		printf("%d ", x + i);
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import product

H, W, K = map(int, input().split())
tiles = []
n = 0
for h in range(H):
    row = list(input())
    tiles.append(row)

cols, rows = [0] * W, [0] * H
for x in range(W):
    c = 0
    for y in range(H):
        if tiles[y][x] == "#":
            c += 1
    cols[x] = c
for y in range(H):
    c = 0
    for x in range(W):
        if tiles[y][x] == "#":
            c += 1
    rows[y] = c
n = sum(cols)

count = 0
for hy in product([0, 1], repeat=H):
    for hx in product([0, 1], repeat=W):
        c = set()
        for i, fy in enumerate(hy):
            if fy:
                for x in range(W):
                    if tiles[i][x] == "#":
                        c.add((x, i))
        for j, fx in enumerate(hx):
            if fx:
                for y in range(H):
                    if tiles[y][j] == "#":
                        c.add((j, y))
        if n - len(c) == K:
            count += 1
print(count)


Measured memory_bytes: 9108
N = int(input())
d = dict()
keys = ['AC', "WA", "TLE", "RE"]
for _ in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

for key in keys:
  if key in d:
    c = d[key]
  else:
    c = 0
  query = key + ' x ' + str(c)
  print(query)


Measured memory_bytes: 9188
import bisect
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
C.sort()
cnt = 0

for b in B:
    a_index = bisect.bisect_left(A,b)
    c_index = bisect.bisect_right(C,b)
    cnt += a_index*(len(C)-c_index)

print(cnt)



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

int main(){
  int N;cin >> N;
  double v[50];
  for(int i = 0;i < N;++i)
    cin >> v[i];
  sort(v, v + N);
  for(int i = 0;i < N - 1;++i){
    v[i + 1] = (v[i] + v[i + 1]) / 2;
  }
  cout << v[N - 1];
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
long long arr[(int) 1e5+5][3];
long long dp[(int) 1e5 +5][4];
int n;
long long f(int i, int prev){
    if(i>=n){
        return 0;
    }
    if(dp[i][prev]>-1){
        return dp[i][prev];
    }
    long long ans = -1;
    for(int j = 0;j<3;j++){
        if(j!=prev){
            ans = max(ans, arr[i][j] + f(i+1, j));
        }
    }
    return dp[i][prev] = ans;
}
int main(){
    cin>>n;
    for(int i = 0;i<n;i++) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
        for(int j = 0;j<3;j++){
            dp[i][j] = -1;
        }
        dp[0][3] = -1;
    }
    cout<<f(0, 3)<<endl;
    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
	int N;
	cin >> N;
	int64_t f0, f1, f2;
	f0 = 2;
	f1 = 1;
	int64_t sum;


	for (int64_t i = 2; i <= N; ++i) {
		f2 = f0 + f1;
		f0 = f1;
		f1 = f2;
		sum = f2;
	}

	if (N == 1) {
		cout << 1 << endl;
	}
	else {
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(A,P);
    cout << (3*A + P) /2 << endl;
}

Measured memory_bytes: 256
from fractions import Fraction


def inverse(f):
    return Fraction(f.denominator, f.numerator)


N = int(input())
A = list(map(int, input().split()))
ans = []
reverse = []

for i in A:
    ans.append(Fraction(1, i))
    reverse.append(Fraction(i, 1))

print(float(inverse(sum(ans))))


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,x;
int fat[9];
string a,b;
int orda,ordb;
string s;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=n;i>=1;i--){
        s+=(char)('0'+i);
    }
    fat[0]=1;
    for(int i=1;i<=n;i++){
        fat[i]=i*fat[i-1];
    }

    for(int i=0;i<n;i++){
        cin>>x;
        a+=(char)('0'+x);
    }
    for(int i=0;i<n;i++){
        cin>>x;
        b+=(char)('0'+x);
    }

    for(int i=0;i<fat[n];i++){
        bool val=next_permutation(s.begin(),s.end());
        if(s==a)orda=i;
        if(s==b)ordb=i;
    }
    cout<<abs(orda-ordb);
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n-1):
  if a[i] <= x:
    x = x - a[i]
    count += 1
if a[n-1] == x:
  count += 1
    
print(count)

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

int main() {
  std::string str;

  int n, h;
  while(1) {
    std::cin >> str;
    if(str == "-") break;
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
      std::cin >> h;
      str = str.substr(h, str.size() - h) + str.substr(0, h);
    }
    std::cout << str << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N,M;
    cin >> N >> M;
    priority_queue<ll> A;
    for (ll i = 0;i<N;i++) {
        ll a;
        cin >> a;
        A.push(a);
    }
    for (ll i = 0;i<M;i++) {
        ll a = A.top(); //最大値を取り出す
        A.pop();        //最大値削除
        a /= 2;         //割引
        A.push(a);      //割引後の値を追加
    }
    ll ans = 0;
    while (!A.empty()) {
        ll a = A.top();
        ans += a;
        A.pop();
    }
    cout << ans << endl;

}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000
#define ll long long
using namespace std;
int main()
{
    int a;
    string s;
    bool ans = false;
    cin >> a >> s;
    if (a % 2 == 1)
        cout << "No"
             << "\n";
    else if (s.substr(0, a / 2) == s.substr(a / 2, a / 2))
        cout
            << "Yes"
            << "\n";
    else
        cout << "No"
             << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

string s;
int p = 700;

int main(){

    cin >> s;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'o'){
            p = p + 100;
        } else if(s[i] == 'x'){
            continue;
        }
    }

    cout << p;





    



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX 500000
#define INF 1000000000
int cut =0;
int L[MAX],R[MAX];
void marge(int *A,int left,int mid,int right,int n){
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(int i=0;i<n1;i++) L[i] = A[left+i];
    for(int i=0;i<n2;i++) R[i] = A[mid+i];
    L[n1] = INF;
    R[n2] = INF;
    int i=0;
    int j=0;
    for(int k=left;k<right;k++){
        cut++;
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
        }
        else
        {
            A[k] = R[j];
            j++;
        }
    }
}
void margeSort(int *A,int n,int left,int right){
    
    if(left+1 < right){
        int mid = (left+right)/2;
        margeSort(A,n,left,mid);
        margeSort(A,n,mid,right);
        marge(A,left,mid,right,n);
    }
}

int main(){
    int A[MAX];
    int n;
    cut =0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    margeSort(A,n,0,n);
    for(int i=0;i<n;i++){
        if(i !=0)putchar(' ');
        cout << A[i];
    }
    putchar('\n');

    cout << cut << endl;
    return 0;
}


Measured memory_bytes: 6908
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, d = 0, ans = 0;
bool bo[40], tr = true;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		d ^= a;
		REP(i, 40) {
			if (a & (1ll << i)) {
				bo[i] = true;
				break;
			}
		}
	}
	REPR(i, 37) {
		bool a = false, b = false;
		if ((d & (1ll << i)))a = true;
		if ((d & (1ll << (i + 1))))b = true;
		if(a != b){
			if (bo[i])ans++;
			else tr = false;
		}
	}
	cout << (tr ? ans : -1) << endl;
}



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

int main () {
  char A;
  cin>>A;
  if(A=='a' || A=='i' || A=='u' || A=='e' || A=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	String str = sca.next();
	String ans = "Yes";
	if(str.length() % 2 == 1) {
		ans = "No";
	}
	else {
		for(int i = 0; i < str.length()-1; i=i+2) {
			if(str.charAt(i) == 'h' && str.charAt(i+1) == 'i') {

			}
			else {
				ans = "No";
				break;
			}
		}
	}
	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

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

int main(){
  string s;cin>>s;
  bool flag=true;
  for(int i=1;i<(int)s.size();i++)if(s[i]!='9'){
    flag=false;
    break;
  }
  cout<<9*(int)(s.size()-1)+(int)(s[0]-'0')-(flag?0:1)<<endl;
  return 0;
}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0: break
    s = [int(x) for x in input().split()]
    m = sum(s) / len(s)
    tmp = 0
    for _ in s:
        tmp += (_ - m) ** 2
    alpha = (tmp / len(s)) ** 0.5
    print(format(alpha,  '.6f'))


Measured memory_bytes: 5680
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;


int main() {

	int n, a, b;

	cin >> n >> a >> b;
	if (a*n > b)cout << b << endl;
	else cout << a*n << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2:
  print(-1)
else:
  M = N - 1 + (N - 1) * (N - 2) // 2 - K
  print(M)
  for i in range(N - 1):
    print("1 {}".format(i + 2))
  M -= N - 1
  a = N
  b = N - 1
  while M > 0:
    print("{} {}".format(a, b))
    b -= 1
    if b == 1:
      a -= 1
      b = a - 1
    M -= 1

Measured memory_bytes: 42216