akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        a: [usize1;n]
    }
    let mut used = std::collections::HashSet::new();
    used.insert(0);
    let mut cur = 0;
    let mut ret = 0;
    loop {
        ret += 1;
        let next = a[cur];
        if next == 1 {
            break;
        } else if used.contains(&next) {
            ret = -1;
            break;
        } else {
            used.insert(next);
            cur = next;
        }
    }
    println!("{}", ret);
}

Measured memory_bytes: 8444
import sys
import itertools

N = int(input())
S = sys.stdin.read().split()

max_len = 0
for key, group in itertools.groupby(sorted(S)):
	length = len(list(group))
	if length > max_len:
		max_len = length
		ans = []
	
	if max_len == length:
		ans.append(key)

print('\n'.join(ans))


Measured memory_bytes: 23476
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

const ll mod = 1000000007;
ll modPow(ll a, ll n, ll md){
  if (n == 0) return 1;
  if (n == 1) return a % md;
  if (n % 2 == 1) return (a * modPow(a, n-1, md)) % md;
  ll t = modPow(a, n/2, md);
  return (t * t) % md;
}

int main(){
  string s;
  cin >> s;
  ll n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
  dp[0][0] = 1;
  rep(i, n){
    ll x = modPow(10, i, 13);
    if (s[n-i-1] == '?'){
      rep(j, 13)rep(k, 10){
        dp[i+1][(j+k*x)%13] += dp[i][j];
        dp[i+1][(j+k*x)%13] %= mod;
      }
    }
    else{
      ll k = s[n-i-1] - '0';
      rep(j, 13){
        dp[i+1][(j+k*x)%13] += dp[i][j];
        dp[i+1][(j+k*x)%13] %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;
  
  return 0;
}

Measured memory_bytes: 16704
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace __gnu_pbds;
using namespace std;
typedef tree<
ll,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
struct Node
{
    ll pos, val, color;
    bool operator<( const Node &A) const
    {
        return A.val > val;
    }
};


int main()
{
    set<string>st;
    ll n, m, k, t;
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<"\n";
    return 0;
}



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

#define N 101

vector<vector<int> > dp(N, vector<int>(N));
int p[N+1];

// dp[i][j] := [Mi, Mj]におけるminimum number of scalar multiplications 

int main(){
    
    int n;
    cin >> n;
    
    for (int i = 1; i < n+1; i++) cin >> p[i-1] >> p[i];
    
    
    // l はchain lengthを表す変数である.
    // l == 1のとき計算回数は0である.
    for (int l = 2; l <= n; l++){
        
        // 変数iは区間の左端を表す
        // 左端が動ける範囲の上限は, n - l + 1である
        // 具体例を考えてみよ
        for (int i = 1; i <= n-l+1; i++){
            
            // jは右端の上限値を表す
            int j = i + l - 1;
            
            dp[i][j] = (1<<20);
            
            // 今回調べる区間は, [i, j-1]
            for (int k = i; k < j; k++){
                
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }
    
    cout << dp[1][n] << endl;
}



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

int main() {
  int N;
  int X;
  int Y;
  cin >> N >> X >> Y;
  vector<int> Dist(N);
  for (int i=1;i<=N;i++){
    for (int j=i+1;j<=N;j++){
      Dist.at(min(j-i,abs(X-i)+abs(Y-j)+1))++;
    }
  }
  for (int i=1;i<=N-1;i++){
    cout << Dist.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> d(N, 0);
    rep(i, N) cin >> d[i];
    rep(j,N-1) {
        for (int k = j + 1; k < N; k++) ans += d[j] * d[k];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	unordered_set<int> s;
	bool f = false;
	int count = 0;
	for (int i = 0; i < n;) {
	    count++;
		if (v[i] == 2) {
			f = true;
			break;
		}
		else if (s.find(v[i]) != s.end()) {
			break;
		}
		else {
			s.insert(v[i]);
			i = v[i] - 1;
		}
	}
	if (f) {
		cout << count << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 4772
M, D = list(map(int, input().split()))
# 22 >=
count = 0
for m in range(M + 1):
    for d in range(D + 1):
        d10 = d // 10
        d1 = d % 10
        if d10 >= 2 and d1 >= 2 and m == d1 * d10:
            count += 1

print(count)

Measured memory_bytes: 39536
N, M = map(int, input().split())  #数字
S = [list(map(int, input().split())) for i in range(M)]  #数字、複数行複数列

A = [0] * N
cou = [0] * N

for i, j in S:
    if i - 1 == 0 and j == 0 and N != 1:
        print(-1)
        exit()    
    if cou[i - 1] == 0:
        A[i - 1] = j
        cou[i - 1] += 1
    elif A[i - 1] != j:
        print(-1)
        exit()    

if A[0] == 0 and N >= 2:
    A[0] = 1

A = [str(i) for i in A]
print(''.join(A))#間隔なし

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[u].pb(v);
    }
    vector<int> indeg(n+1,0);
    vector<int> dp(n+1,0);
    for(int i=1;i<=n;i++){
        for(int j=0;j<adj[i].size();j++){
            indeg[adj[i][j]]++;
        }
    }
    priority_queue<int,vector<int>,greater<int>> pq;
    for(int i=1;i<=n;i++){
        if(indeg[i]==0){
            pq.push(i);
        }
    }

    while(!pq.empty()){
        int u = pq.top();
        pq.pop();
        for(int i=0;i<adj[u].size();i++){
            indeg[adj[u][i]]--;
            if(indeg[adj[u][i]]==0){
                pq.push(adj[u][i]);
            }
            dp[adj[u][i]] = max(dp[adj[u][i]],dp[u]+1);
        }
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int w2,h2,n,w1=0,h1=0;
    cin>>w2>>h2>>n;
    int x,y,a;
    rep(i,n){
        cin>>x>>y>>a;
        if(a==1) w1=max(w1,x);
        else if(a==2) w2=min(w2,x);
        else if(a==3) h1=max(h1,y);
        else if(a==4) h2=min(h2,y);
    }
    if(w1<w2&&h1<h2) cout<<(h2-h1)*(w2-w1);
    else cout<<0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

struct UFT{
    vector<int> par;
    vector<int> siz;
    UFT(int n) : par(vector<int>(n)), siz(vector<int>(n, 1)){ For(i, n) par[i] = i; }
    void unite(int x, int y){ if(!same(x = find(x), y = find(y))){ par[x] = y; siz[y] += siz[x]; } }
    int find(int x){ return (par[x] == x) ? x : (par[x] = find(par[x])); }
    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return siz[find(x)]; }
    void print() const{ Couts(par); }
};

int main(void){
    Cin(int, n, m);
    UFT uft(n+1);
    Rep(m){
        Cin(int, a, b);
        uft.unite(a, b);
    }
    int ans = 1;
    For(i, n+1) Maxi(ans, uft.size(i));
    Cout(ans);
}


Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <numeric>

using namespace std;

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

	
	int n, k;
	cin >> n >> k;

	vector<int> freq(n + 1, int(2e9));

	int nrUnique = 0;

	for (int i = 0; i < n; ++i) {
		int nr;
		cin >> nr;

		if (freq[nr] == int(2e9)) {
			++nrUnique;
			freq[nr] = 1;
		}
		else ++freq[nr];
	}

	partial_sort(begin(freq), begin(freq) + max(nrUnique - k, 0), end(freq));

	cout << std::accumulate(begin(freq), begin(freq) + max(nrUnique - k, 0), 0);

	//system("pause");

	return 0;
}

Measured memory_bytes: 1024
S, T = $<.read.split

firstOccurrenceInS = {}
firstOccurrenceInT = {}
puts S.size.times.all?{|i|
	(firstOccurrenceInS[S[i]]||=i) ==
	(firstOccurrenceInT[T[i]]||=i)
} ? 'Yes' : 'No'


Measured memory_bytes: 2556
#include <iostream>
using namespace std;
int main() {
	int n, ma, mb;
	scanf("%d%d%d", &n, &ma, &mb);
	int a[n], b[n], c[n];
	for (int i = 0; i < n; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]);
	int dp[405][405];
	fill(dp[0], dp[0] + 405 * 405, 1e9);
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 404; j >= 0; j--) {
			if (j < a[i]) break;
			for (int k = 404; k >= 0; k--) {
				if (k < b[i]) break;
				dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
			}
		}
	}
	int ans = 1e9;
	int k = min(400 / ma, 400 / mb);
	for (int i = 1; i <= k; i++) ans = min(ans, dp[i * ma][i * mb]);
	printf("%d\n", ans == 1e9 ? -1 : ans);
	return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		vector<double> x(n, 0), y(n, 0);
		cin >> n;
		for(int i=0; i<n; i++)cin >> x[i] >> y[i];
		vector<int> p(n, 0);
		for(int i=0; i < n; i++)p[i] = i;
		double d = 0.0;
		do{
			for(int i=0; i < n-1; i++){
				d += sqrt((x[p[i]]-x[p[i+1]])*(x[p[i]]-x[p[i+1]]) + (y[p[i]]-y[p[i+1]])*(y[p[i]]-y[p[i+1]]));
			}
		}while(next_permutation(p.begin(), p.end()));
		for(int i = 1; i <= n; i++)d/=i;
		cout << setprecision(12) <<d << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  ll n;
  cin >> n;
  ll ans = 1000000000005;
  ll m = (ll)sqrt(n);
  rep2(i, 1, m + 1) {
    if (n % i == 0) ans = min(ans, (i - 1) + (n / i - 1));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,ans =0;
	cin>>n;
	while (n>0)
	{
		ans+=n%10;
		n/=10;
	}
	if (ans==1)
	{
		ans+=9;
	}
	printf("%d\n",ans );
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll gcd (ll x,ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}

int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> left(n+1),right(n+1);
    rep(i,n) {
        left[i+1]=gcd(left[i],a[i]);
    }
    rrep(i,n) {
        right[i]=gcd(right[i+1],a[i]);
    }
    
    ll ans=0;
    rep(i,n) {
        ans=max(ans,gcd(left[i],right[i+1]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
use std::io;


fn main() {
    let (n, t) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ct = Vec::new();
    for _ in 0..n {
        let i = read::<usize>();
        ct.push((i[0], i[1]));
    }

    let ans = ct.iter()
        .filter(|x| x.1 <= t)
        .map(|x| x.0)
        .min();

    match ans {
        Some(x) => println!("{}", x),
        None => println!("TLE"),
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
//23/12/2019
#include<bits/stdc++.h>

using namespace std;

#define debug printf("Debug\n");
#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define p_b(x) push_back(x)
#define m_p(x) make_pair(x,y)

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
vector<ll>v;


int main(){
    _fastio
    ll a,b;
    cin>>a>>b;
    cout<<6-(a+b)<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	long long int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            var C = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var ans = 0;

            for(var i = 0; i <= A; i++)
            {
                for(var j = 0; j <= B; j++)
                {
                    for(var k = 0; k <= C; k++)
                    {
                        if (i * 500 + j * 100 + k * 50 == X) ans++;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
L,R,d = map(int, input().split())
X = L//d
Y = R//d
if L%d == 0 and R%d == 0:
  if L>R:
    print(X-Y+1)
  else:
    print(Y-X+1)
else:
  if L >R:
    print(X-Y)
  else:
    print(Y-X)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll N = nextLong();
  for (ll a = 1; a <= 3500; a++) {
    for (ll b = 1; b <= 3500; b++) {

      ll P = N*a*b;
      ll Q = 4*a*b - N*(a+b);
      if (Q != 0 && P % Q == 0 && P / Q > 0) {
        ll c = P / Q;
        cout << a << ' ' << b << ' ' << c << endl;
        return 0;
      }

    }
  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;

  vector<int64_t> SUM(N + 1);
  SUM[0] = 0;
  for (int64_t i = 1; i <= N; ++i) {
    SUM[i] = SUM[i - 1] + i;
  }

  while (N) {
    int64_t left = 1;
    int64_t right = N;
    while (left < right) {
      int64_t mid = left + (right - left) / 2;
      if (SUM[mid] == N) {
        for (int64_t i = mid; i >= 1; --i) {
          cout << i << endl;
        }
        return 0;
      } else if (SUM[mid] < N) {
        left = mid + 1;
      } else {  // SUM[mid] > N
        right = mid;
      }
    }
    cout << left << endl;
    N -= left;
  }

  return 0;
}


Measured memory_bytes: 78464
n = gets.to_i
st = []
n.times do 
    s,t = gets.split
    st << [s,t.to_i]
end
(n-1).times{|i| st[i+1][1] += st[i][1]}
x = gets.chomp

puts st[n-1][1] - st[st.map{|e| e[0]}.index(x)][1]


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

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

int n, m, c;
int b[20];

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

    int cntr = 0;
    while(n--)
    {
        int sum = c;
        for(int i = 0; i < m; i++)
        {
            int aux;
            cin >> aux;
            sum += aux * b[i];
        }

        if(sum > 0)
            cntr++;
    }

    cout << cntr << '\n';

    return 0;
}   

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

e = []

for i in range(n):
    e.append((1+p[i])/2)

tmp = sum(e[:k])
maxV = tmp

for i in range(n-k):
    tmp += e[i+k] - e[i]
    maxV = max(maxV, tmp)

print(maxV)

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

int main()
{
    long long int n,W;
    cin >> n >> W;
    
    long long int w[n],v[n];
    
    
    for(long long int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    
    long long int dp[n+1][W+1];
    memset(dp, 0, sizeof(dp[0][0]) * (n+1) * (W+1));
    
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=W;j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else if(j<w[i-1]){
                dp[i][j] = dp[i-1][j];
            } 
            else{
                dp[i][j] = (dp[i-1][j]>(dp[i-1][j-w[i-1]]+v[i-1])) ? dp[i-1][j] : (dp[i-1][j-w[i-1]]+v[i-1]);
            }
        }
    }
    
    cout << dp[n][W] << endl;

    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cmath>
#include <iomanip>

#define SIZE 100

using namespace std;

double Minkp1(int, double [], double []);
double Minkp2(int, double [], double []);
double Minkp3(int, double[], double[]);
double Minkpinf(int, double [], double []);

int main(void){
	int n;
	double x[SIZE], y[SIZE];
	double p1, p2, p3, pinf;

	cin >> n;

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

	p1 = Minkp1(n, x, y);
	p2 = Minkp2(n, x, y);
	p3 = Minkp3(n, x, y);
	pinf = Minkpinf(n, x, y);
	
	
	cout << fixed << setprecision(8);
	cout << p1 << "\n";
	cout << p2 << "\n";
	cout << p3 << "\n";
	cout << pinf << "\n";

	return 0;
}

double Minkp1(int n, double x[], double y[]) {
	double dist = 0.0;
	for (int i = 0; i < n; i++) {
		dist += abs(x[i] - y[i]);
	}
	return dist;
}


double Minkp2(int n, double x[], double y[]) {
	double dist = 0.0;
	for (int i = 0; i < n; i++) {
		dist += pow(x[i] - y[i], 2);
	}
	return sqrt(dist);
}


double Minkp3(int n, double x[], double y[]) {
	double dist = 0.0;
	for (int i = 0; i < n; i++) {
		dist += pow(abs(x[i] - y[i]), 3);
	}
	return pow(dist, 1.0/3.0);
}


double Minkpinf(int n, double x[], double y[]) {
	double dist = 0.0;
	double tmp = 0.0;
	for (int i = 0; i < n; i++) {
		tmp = abs(x[i] - y[i]);
		if (dist < tmp) {
			dist = tmp;
		}
	}
	return dist;
}

Measured memory_bytes: 3416
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.nextLine();
		String str2_m = sc.nextLine();

		str2_m = "0 " + str2_m + " 0";

		String[] str2 = str2_m.split(" ");

		int n = Integer.parseInt(str1) + 2;

		List<Integer> d = new ArrayList<Integer>();
		List<Integer> s = new ArrayList<Integer>();
		List<Boolean> bIsLarge = new ArrayList<Boolean>();
		for (int i = 0; i < str2.length; i++) {
			d.add(Integer.parseInt(str2[i]));
		}

		for (int i = 0; i < n - 1; i++) {
			int a = Integer.parseInt(str2[i]) + 5000;
			int a1 = Integer.parseInt(str2[i + 1]) + 5000;

			if (a > a1) {
				s.add(a - a1);
				bIsLarge.add(true);
			} else {
				s.add(a1 - a);
				bIsLarge.add(false);
			}
		}

		int sum = s.stream().mapToInt(Integer::intValue).sum();

		for (int i = 0; i < n - 2; i++) {
			if (bIsLarge.get(i) == bIsLarge.get(i + 1)) {
				System.out.println(sum);
			} else {
				if (d.get(i) < d.get(i + 2)) {
					if (bIsLarge.get(i)) {
						System.out.println(sum - s.get(i) * 2);
					} else {
						System.out.println(sum - s.get(i + 1) * 2);
					}
				} else {
					if (bIsLarge.get(i)) {
						System.out.println(sum - s.get(i + 1) * 2);
					} else {
						System.out.println(sum - s.get(i) * 2);
					}
				}
			}

		}

		sc.close();
	}

}


Measured memory_bytes: 69052
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string.h>

using namespace std;

int main()
{
	int A,B;

	cin >> A >> B;
	if (abs(A - B) % 2)
	{
		cout << "IMPOSSIBLE" << endl;
	}
	else
	{
		cout << (A + B) / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#B
N, L = map(int, input().split())
apple = []
for i in range(N):
    apple.append(L + i)
j = 0
for i in range(N):
    if apple[i] == 0:
        a = apple[i]
        del apple[i]
        j += 1
        break
#print(j)
#print(apple)
if j == 0:
    if not 0 in apple:
        if apple[0] < 0:
            del apple[-1]
        elif apple[0] > 0:
            del apple[0]
print(sum(apple))
#print(apple)

Measured memory_bytes: 3064
// g++ -std=c++11 -o2 -Wall ABC097A.cpp -o ./out/ABC097A.out
// ./out/ABC097A.out

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;


int main() {
//  freopen("./input/input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

int n , a , b;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	int ans ;
	ans = min(n*a,b);
	printf("%d",ans);
	
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Add.ar;
        var res = Enumerable.Repeat(1, nm[0]).ToArray();
        var set = new HashSet<int> { 0 };
        for(var i = 0; i < nm[1]; i++)
        {
            var input = Add.ar;
            res[input[0] - 1]--;
            res[input[1] - 1]++;
            if (set.Contains(input[0] - 1))
                set.Add(input[1] - 1);
            if (res[input[0] - 1] == 0) set.Remove(input[0] - 1);
        }
        WriteLine(set.Count());
    }
}

public class Add
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 22980
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;

int main()
{
  //"Don't regret anything you do, because in the end it makes you who you are."
  int t;
  cin >> t;
  cout << t+t*t+t*t*t;
  return 0;
}


Measured memory_bytes: 3592
//
// Created by Hideaki Imamura on 2020-03-10.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll N, K;
vector<ll> A, pos, neg;
ll n_zero, n_pos, n_neg;

// 積がx以下の(i,j)の数 for (pos, neg)
ll f(ll x) {
    ll ret = 0;
    int j = n_pos - 1;
    for (int i = n_neg - 1; i >= 0; i--) {
        while (j >= 0 && neg[i] * pos[j] <= x) j--;
        ret += n_pos - 1 - j;
    }
    return ret;
}

// 積がx以下の(i,j)の数 for (pos, pos) or (neg, neg)
ll g(ll x) {
    ll ret = n_pos * n_neg + n_zero * (n_pos + n_neg) + (n_zero * (n_zero - 1)) / 2;
    int j = n_neg - 1;
    for (int i = 0; i < n_neg - 1; i++) {
        while (j >= 0 && neg[i] * neg[j] <= x) j--;
        ret += min((int)n_neg - j - 1, (int)n_neg - i - 1);
    }
    j = 0;
    for (int i = n_pos - 1; i >= 1; i--) {
        while (j < n_pos && pos[i] * pos[j] <= x) j++;
        ret += min(i, j);
    }
    return ret;
}

int main() {
    cin >> N >> K;
    n_zero = 0;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.push_back(a);
        if (a == 0) {
            n_zero++;
        } else if (a > 0) {
            pos.push_back(a);
        } else {
            neg.push_back(a);
        }
    }
    sort(A.begin(), A.end());
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    n_pos = pos.size();
    n_neg = neg.size();

    if (K <= n_pos * n_neg) {
        ll l = - 1e18 - 1ll;
        ll r = 0;
        while (r - l > 1) {
            ll m = (l + r) / 2;
            if (f(m) >= K) {
                r = m;
            } else {
                l = m;
            }
        }
        cout << r << endl;
    } else if (K <= n_pos * n_neg + n_zero * (n_pos + n_neg) + (n_zero * (n_zero - 1)) / 2) {
        cout << 0 << endl;
    } else {
        ll l = 0;
        ll r = 1e18 + 1ll;
        while (r - l > 1) {
            ll m = (l + r) / 2;
            if (g(m) >= K) {
                r = m;
            } else {
                l = m;
            }
        }
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 4468
//ABC166 B

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n,k;
lint d;


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

/*   rep(i,n){
    scanf("%s",&s[i]);
  } */
  
  lint m;
  lint a[n+1];
  rep(i,n+1){
    a[i] = 0;
  }
  rep(i,k){
    cin >> d;
    rep(j,d){
      cin >> m;
      a[m]++;
    }
  }

  reps(i,1,n+1){
    if(a[i] == 0) ans++;
  }
  
  printf("%lld\n",ans);
}


Measured memory_bytes: 3760
import numpy as np


def partsolve(A, x, positive, zero, negative):
    """
    :param A:
    :param x:
    :return: Aの積のペアの中で、x以下となるペアの個数
    """
    count = 0
    if x >= 0:
        count = len(zero) * len(A)
    P = x // positive
    Pc = np.searchsorted(A, P, side='right')
    count += Pc.sum()

    N = (-x-1) // -negative
    Nc = np.searchsorted(A, N, side='right')
    Nc = len(A) - Nc
    count += Nc.sum()

    count -= np.count_nonzero(A * A <= x)
    return count // 2

def solve(N, K, As):
    A = np.array(sorted(As), np.int64)
    positive = A[A > 0]
    zero = A[A == 0]
    negative = A[A < 0]

    left = -10 ** 18
    right = 10 ** 18
    while right - left > 1:
        mid = left + (right - left) // 2
        c = partsolve(A, mid, positive, zero, negative)
        if c < K:
            left = mid
        else:
            right = mid
    return right



if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))



Measured memory_bytes: 32332
def solve():
  n = input()
  a = int(n[-1])
  if a == 0 or a == 1 or a == 6 or a == 8:
    print("pon")
  if a == 2 or a==4 or a == 5 or a == 7 or a == 9:
    print("hon")
  if a == 3:
    print("bon")
  return 0
 
if __name__ == "__main__":
  solve()


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

int main()
{
  int n,m;
  cin >> n >> m;
  
  string a[n],b[m];
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  
  int ans = 0;
  for(int h = 0; h <= n-m; h++){   
    for(int w = 0; w <= n-m; w++){
      for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
          if(a[h+i][w+j] == b[i][j]){
            ans++;
          }//if
        }//for
      }//for
      if(ans == m * m){
        cout << "Yes" << endl;
        return 0;
      }
      ans = 0;
    }//for
  }//for

  cout << "No" << endl;
}

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

int main() {
	string s;
	cin>>s;
	int od = (s.size()+1)/2;
	int ev = s.size()/2;
	int o1=0;
	int e1=0;
	int o2=0;
	int e2=0;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='0')e1++;
		else o1++;
	}
	for(int i=1;i<s.size();i+=2){
		if(s[i]=='0')e2++;
		else o2++;
	}
	bool odd,even;
	if(e1>=o1) even = true;
	else false;
	if(e2>=o2) odd = true;
	else false;

	if(even && !odd) cout << o1 + e2 << endl;
	else if(!even && odd) cout << e1 + o2 << endl;
	else if(even && odd) cout << min(e1,e2) + min(o1,o2) << endl;
	else cout << min(o1,o2) + min(e1,e2) << endl;
}


Measured memory_bytes: 512
/*
ID: taoxiaa1
PROG: concom
LANG: C++
*/
//URAL ID:248353QC
#include<bits/stdc++.h>
using namespace std;
//FILE *fin, *out;
//fin = fopen("money.fin", "r");
//out = fopen("money.out", "w");
//ofstream fout("money.out");
//ifstream fin("[图片]money.in");
#define ll long long
#define M 998244353
const int N=300005;
ll fac[N]={1,1},inv[N]={1,1},f[N]={1,1};
ll C(ll a,ll b){
    if(b>a)return 0;
    return fac[a]*inv[b]%M*inv[a-b]%M;
}
void init(){//快速计算阶乘的逆元
    for(int i=2;i<N;i++){
        fac[i]=fac[i-1]*i%M;
        f[i]=(M-M/i)*f[M%i]%M;
        inv[i]=inv[i-1]*f[i]%M;
    }
}
int main(){
     init();
     int n;
     scanf("%d",&n);
     ll a,b,k;
     scanf("%lld%lld%lld",&a,&b,&k);
     long long ans=0;
     for(int i=0;i<=n;i++){
          long long sum=1ll*i*a;
          if((k-sum)>=0&&(k-sum)%b==0){
               long long j=(k-sum)/b;
               if(j>n)continue;
               ans+=(C(n,i)*C(n,j));
               ans%=M;
          }
     }
     printf("%lld\n",ans);
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,rr=0,ans=0;
  string s;
  cin >> n >> s;
  for(long i=0;i<n;i++) if(s[i]=='R') rr++;
  ans=rr;
  for(long i=0;i<rr;i++) if(s[i]=='R') ans--;
  cout << ans << endl;
}

Measured memory_bytes: 3720
import java.util.*;

class Main{
    //
    static final long DIV = 100000007L;
    static final int MAX = 2000000000;
    //static long[] fac = new long[MAX];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        s = s.replaceAll("ABC", "1");
        char[] ary = s.toCharArray();
        int ans = 0;
        for(int i = 0;i < ary.length;i++){
            if(ary[i]=='1')ans++;
        }
        System.out.println(ans);
    }

    static long modpow(long n){
        long ans =1;
        long a = 2;
        long m = n;
        while(m>0){
            if((m&1)==1)ans = ans*a % DIV;
            a = a * a % DIV;
            m >>= 1;
        }
        return ans;
    }

    static long modcomb(long n,long r){
        return 1;
    }
    
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include "math.h"


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

  int N;
  double x;

  scanf("%d", &N);

  if(N % 2 == 0){
    printf("%.10f\n", 0.5);
  }else{
    x = (double)(N+1)/2/N;
    printf("%.10f\n", x);
  }

  return 0;
}


Measured memory_bytes: 128
MOD=10**9+7
N,M=[int(s) for s in input().split()]
ls=[1 for _ in range(N+1)]
for i in range(M):
  ls[int(input())]=0
for n in range(2,N+1):
  if ls[n]!=0:
    ls[n]=(ls[n-1]+ls[n-2])%MOD
print(ls[N])

Measured memory_bytes: 7064
s=input()
t=input()
ans=float('inf')
for i in range(len(s)-len(t)+1):
    a=s[i:i+len(t)]
    tans=0
    for i in range(len(t)):
        tans+=(t[i]!=a[i])
    ans=min(ans,tans)
print(ans)

Measured memory_bytes: 67660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin); // see Input & Output
        freopen((name+".out").c_str(), "w", stdout);
    }
}

ll dp[105][100005];

int main(){
    int n, w; cin >> n >> w;
    vi a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    memset(dp, 0x3f3f3f, sizeof(dp)); //fill dp with a large value
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if (j - b[i - 1] >= 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - b[i - 1]] + a[i - 1]);
            }
        }
    }
    int ans = -1;
    for (int i = 0; i <= 100000; i++) {
        if(dp[n][i] <= w){
            ans = i;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 85624
import Data.List
import Control.Monad

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- sort <$> map sort <$> replicateM n getLine :: IO [String]
    print (sum $ map (s . length) $ group ss)


s 1 = 0
s n = s (n - 1) + (n - 1)



Measured memory_bytes: 114044
sx,sy,tx,ty = map(int, input().split())
dx,dy = (tx-sx),(ty-sy)
p1 = "U"*dy+"R"*dx
p2 = "D"*dy+"L"*dx
p3 = "L"+"U"*(dy+1)+"R"*(dx+1)+"D"
p4 = "R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(p1+p2+p3+p4)

Measured memory_bytes: 3060
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N = intinput()

    # 出力
    print(N*(1+N)//2)


# EOF

Measured memory_bytes: 5160
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 305;
const int md2 = 998244353;
const int md = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

void solve() {
    string s; cin >> s;
    if (s.back() == 's') {
        s += "e";
    }
    s += "s";
    cout << s << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
x='YES'
for i in l:
  if i%2:
    x='NO'
    break
print(x)

Measured memory_bytes: 3828
n = int(input())
a = list(map(int, input().split()))
ans = 1
i = 0
while i<=n-1 and ans<= 10**18:
    ans *= a[i]
    i += 1
if 0 in a:
    print('0')
elif ans <= 10**18:
    print(ans)
else:
    print('-1')

Measured memory_bytes: 84648
#include <stdio.h>
#include <math.h>
int main(void) {
	int n, i;
	double data[1000], m, alpha;

	while (1) {
		scanf("%d ", &n);
		if (n == 0)
			break;

		for (m = 0.0, i = 0; i < n; i++) {
			scanf("%lf ", data+i);
			m += data[i];
		}
		m /= n;
		for (alpha = 0.0, i = 0; i < n; i++) {
			data[i] -= m;
			alpha += data[i] * data[i];
		}
		printf("%.4lf\n", sqrt(alpha / n));
	}
	return 0;
}

Measured memory_bytes: 668
#include <stdio.h>
int main(void){
	int a[51],b[51],n,r,p,c,i;
	while(scanf("%d %d",&n,&r),n+r){
		for(i=0;i<n;i++)
			a[i]=n-i;
		while(r--){
			scanf("%d %d",&p,&c);
			for(i=0;i<c;i++){
				b[i]=a[p+i-1];
			}
			for(i=0;i<p-1;i++){
				b[c+i]=a[i];
			}
			for(i=p+c-1;i<n;i++){
				b[i]=a[i];
			}
			for(i=0;i<n;i++){
				a[i]=b[i];
			}
		}
		printf("%d\n",a[0]);
	}
	return 0;
}

Measured memory_bytes: 600
<?php
# 整数の入力
fscanf(STDIN, "%d %d %d", $red, $green, $blue);
fscanf(STDIN, "%d", $n);

$cnt = 0;
while($green <= $red) {
    $cnt++;
    $green *= 2;
}
while($blue <= $green) {
    $cnt++;
    $blue *= 2;
}
echo $cnt > $n ? "No" : "Yes";
?>

Measured memory_bytes: 16196
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10 ;

int main () {
    int n, x;
    cin >> n;
    for (int i = 1  ; i <= n ; ++ i) {
        cin >> x;
        if (x % 2 == 0) {
            if (! (x % 3 == 0 || x % 5 == 0))
                return !puts("DENIED");
        }
    }
    puts("APPROVED");
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

K = INT()
A, B = MAP()

ans = False
i = 1
while i <= B:
    if A <= K*i <= B:
        ans = True
        break
    i += 1 

if ans:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 61756
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = sc.nextInt()

    println(abc131b(n, l))
}

private fun abc131b(n: Int, l: Int): Int {
    val apples = (1..n).map { l + it - 1 }
    val ans = apples.sortedBy { Math.abs(it) }.drop(1).sum()

    return ans
}


Measured memory_bytes: 36036
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S;cin>>K>>S;
  long long count=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-(i+j)<=K&&S-(i+j)>=0){
        count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] bunny=new int [N+1];
        int[] count=new int[N+1];
        int K, m, num, R, p, q, sum=0;
        K = sc.nextInt();
        for(int i=0; i<K; i++) {
        	m= sc.nextInt();
        	for(int j=0; j<m; j++) {
        		num = sc.nextInt();
        		bunny[num] = i;
        	}
        }
        R = sc.nextInt();
        for(int i=0; i<R; i++) {
        	p = sc.nextInt();
        	q = sc.nextInt();
        	if(bunny[p] == bunny[q]) {
        		count[p]=1;
        		count[q]=1;
        	}
        }
        for(int i=1; i<=N; i++){
            sum += count[i];
        }
        	System.out.printf("%d\n", sum);
	}
}


Measured memory_bytes: 33320
s=input()
L=len(s)
l=s[:L//2]
r=s[L//2+1:]
def check(S,d):
    for i in range(d//2):
        if S[i]!=S[-i-1]:return False
    return True
if check(l,L//2) and check(r,L//2) and check(s,L):print("Yes")
else:print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
long long int a[maxn];
int right_low[maxn];
long long int dp[maxn];
int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    stack<int> st;
    right_low[n]=n+1;
    st.push(n);
    for(int i=n-1;i>=1;i--)
    {
        while(!st.empty() && a[st.top()]>=a[i])
            st.pop();
        if(st.empty()) right_low[i]=n+1;
        else right_low[i]=st.top();
        st.push(i);
    }
    //for(int i=1;i<=n;i++)   cout<<right_low[i]<<" ";cout<<endl;
    dp[n]=a[n];
    for(int i=n-1;i>=1;i--)
    {
        dp[i]=dp[right_low[i]]+(right_low[i]-i)*a[i];
    }
    long long int ans=0;
    for(int i=1;i<=n;i++) ans+=dp[i];
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4992