akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInteger
	print $ n * ( n - 1 ) `div` 2

Measured memory_bytes: 508
#include<iostream>
using namespace std;
int const N = 101;
int main(){
  int num[N],M[N];
  int n,max,min;
  for(int i=1;i<=100;i++){
    num[i] = 0;
  }
  while(cin >> n){
    num[n]++;
  }
  max = num[1];
  min = num[1];
  for(int i=1;i<=100;i++){
    if(max < num[i])
      max = num[i];
  }
  for(int i=1;i<=100;i++){
    int count = 0;
    if(max == num[i])
      cout << i << endl;
    
  }

  
}

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

int main(void){
	int n,w;
	int pt=0;
	int inputw,inputv;
	long long dp[101][100001];
	cin>>n>>w;

	for(int i=0;i<=n;i++){
		for(int j=0;j<=i*1000;j++){
			dp[i][j]=LLONG_MAX;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		cin>>inputw>>inputv;
		for(int j=0;j<=i*1000;j++){
			if(dp[i][j]<w){
				dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
				if(dp[i][j]+inputw<=w){
					dp[i+1][j+inputv]=dp[i][j]+inputw;
					pt=max(pt,j+inputv);
				}
			}
		}
	}
    	cout<<pt<<endl;

    	return 0;
    }


Measured memory_bytes: 78720
count = 0

def Merge(arr, left, mid, right):

    global count

    inf = 10000000000
    n1 = mid - left
    n2 = right - mid
    L = arr[left:left + n1] + [inf]
    R = arr[mid:mid + n2] + [inf]

    i = j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            arr[k] = L[i]
            i += 1
            count += 1      
        else:
            arr[k] = R[j]
            j += 1
            count += 1
            
def MergeSort(arr, left, right):
    if (left + 1) < right:
        mid = int((left + right)/2)
        MergeSort(arr, left, mid)
        MergeSort(arr, mid, right)
        Merge(arr, left, mid, right)

def Main():
    n = int(input())
    arr = [int(a) for a in input().split()]

    MergeSort(arr, 0, n)

    print(*arr)
    print(count)

Main()


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

void draw_chessboard(int h, int w)
{
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cout << (((i+j) % 2 == 0) ? '#' : '.');
        }
        cout << endl;
    }
}

int main()
{
    int h, w;

    while(true)
    {
        cin >> h >> w;
        draw_chessboard(h, w);
        if(h==0 && w ==0)
            break;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 3005;

ff dp[N], p[N];
int n;

void solve() {
   dp[0] = 1;

   for (int i = 1; i <= n; ++i) for (int j = n; j >= 0; --j)
   {
      dp[j] *= (1-p[i]);
      if (j > 0) dp[j] += dp[j-1]*p[i];
   }
   ff total = 0;
   for (int j = (n+1)/2; j <= n; ++j) {
      total += dp[j];
   }
   cout << total << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i) cin >> p[i];
   solve();

   return EXIT_SUCCESS;
}


Measured memory_bytes: 512
<?php

fscanf(STDIN, "%d %d", $n, $k);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

function dfs_nl($v, $cnt = 0) {
    global $A;
    global $k;

    /* echo "v: $v, cnt: $cnt, G: " . $A[$v], PHP_EOL; */
    if ($cnt === $k) {
        return $v + 1;
    }

    return dfs_nl($A[$v] - 1, $cnt + 1);
}

$trail = [];
function dfs_l($v, $cnt = 0) {
    global $A;
    global $trail;
    global $k;

    if (isset($trail[$v])) {

        // 残りのループ回数
        $k - $cnt;

        // 1回のループ回数
        $trail[$v] - $cnt;

        $k = $cnt + ($k - $cnt) % ($trail[$v] - $cnt);

        $trail = [];
    }

    if ($cnt === $k) {
        return $v + 1;
    }

    $trail[$v] = $cnt;

    return dfs_l($A[$v] - 1, $cnt + 1);
}

if ($n >= $k) {
    // ループに入らないパターン

    echo dfs_nl(0);
} else {
    // ループに入るパターン
    echo dfs_l(0);

}


Measured memory_bytes: 105980
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

struct Stone{
  int x,d;
  Stone(){}
  Stone(int x, int d):x(x),d(d){}
};

int danger(Stone &a, Stone &b){ return abs(a.x-b.x)*(a.d+b.d);}

const int INF = 1<<30;
int N,M;
vector<Stone>s[256];
int dp[160][16][80];

int main(){
  while(scanf("%d%d", &N,&M) && N||M){
    for(int i=0;i<256;i++) s[i].clear();
    for(int i=0;i<N;i++){
      int k; scanf("%d", &k);
      while(k--){
	int x,d; scanf("%d%d",&x,&d);
	s[i].push_back(Stone(x,d));
      }
    }

    for(int i=0;i<160;i++) for(int j=0;j<16;j++) for(int k=0;k<80;k++) dp[i][j][k] = INF;
    for(int j=0;j<2;j++) for(int i=0;i<s[j].size();i++) dp[j][i][M-j] = 0;
    for(int i=0;i<N;i++){
      for(int j=0;j<s[i].size();j++){
	for(int k=0;k<s[i+1].size();k++){
	  for(int m=0;m<=M;m++) 
	    dp[i+1][k][m] = min(dp[i+1][k][m], dp[i][j][m]+danger(s[i][j],s[i+1][k]));
	}
	if(i<N-1){
	  for(int k=0;k<s[i+2].size();k++){
	    for(int m=1;m<=M;m++)
	      dp[i+2][k][m-1] = min(dp[i+2][k][m-1], dp[i][j][m]+danger(s[i][j],s[i+2][k]));
	  }
	}
      }
    }
    /*    for(int i=0;i<=M;i++){
      for(int j=0;j<N;j++){
	for(int k=0;k<10;k++) printf("%d ", dp[j][k][i]); puts("");
      }puts("");
      }*/
    int res = INF;
    for(int i=0;i<s[N-1].size();i++) for(int m=0;m<=M;m++) res = min(res, dp[N-1][i][m]);
    for(int i=0;i<s[N-2].size();i++) for(int m=1;m<=M;m++) res = min(res, dp[N-2][i][m]);
    printf("%d\n", res);
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int cnt[10];

int main()
{
  string s;
  cin >> s;

  if(s == "keyence"){
    cout << "YES" << endl;
    return 0;
  }

  int n = s.size();
  string t = "keyence";

  rep(i, n){
    repi(j, i, n){
      int cnt = 0;
      int k;
      for(k = 0; k < n; k++){
        if(k < i or j < k){
          if(s[k] != t[cnt]){
            break;
          }else{
            cnt++;
          }
        }
      }
      if(t.size() == cnt and s.size() == k){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


int main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  ll ans = 1;
  int ins = 0;
  rep(i,n-1){
    if(ins == -1 && A[i] < A[i+1]){
      ans++;
      ins = 0;
    }
    else if(ins == 1 && A[i] > A[i+1]){
      ans++;
      ins = 0;
    }
    else if(ins == 0 && A[i] < A[i+1]) ins = 1;
    else if(ins == 0 && A[i] > A[i+1]) ins = -1;
    //cout << i << " " << ins << endl;
  }
  cout << ans << endl;
}




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

A = [A[0]] + [b for a,b in zip(A,A[1:]) if a != b]

if len(A) < 2:
    print(1000)
    exit()

diff = [a-b for a,b in zip(A[1:],A)]
B = [A[0]] if diff[0] > 0 else []

for i,(d1,d2) in enumerate(zip(diff, diff[1:]),start=1):
    if d1*d2 < 0:
        B.append(A[i])
B.append(A[-1])
t = iter(B)
c = 1000
for a,b in zip(t,t):
    c = c//a*b + c%a

print(c)


Measured memory_bytes: 9224
a, b, k = [int(i) for i in input().split()]

x = max(a, b)
y = min(a, b)
gcd = 0
if x % y == 0:
    gcd = y
else:
    while x % y != 0:
        z = x % y
        x = y
        y = z
    else:
        gcd = z

list_gcd = list()

for i in range(1, int(gcd/2) + 1):
    if gcd % i == 0:
        list_gcd.append(i)

list_gcd.append(gcd)
print(list_gcd[-k])


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

int main(void){
   long long A,V,B,W,T;
   cin>>A>>V;
   cin>>B>>W;
   cin>>T;
   long long D=abs(A-B);
   long long dist=(V-W)*T;
   if(dist>=D){
      cout<<"YES"<<endl;
   }else{
      cout<<"NO"<<endl;
   }
   return 0;
}


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


int main() {
  string A, B;
  cin >> A >> B;
  int C = 0;
  int p = A.size();
  int q = B.size();
  int r = 0;
  if(p == q) {
    for(int i = 0; i < p; i++) {
      if(A.at(i) != B.at(i)) {
        r++;
      }
      
    }
    cout << r << endl;
  }
  else {
  for(int i = 0; i < p-q; i++) {
    int cnt = 0;
    for(int j = 0; j < B.size(); j++) {
      if(A.at(i+j) != B.at(j)) {
        cnt++;
      }
    }
    if(i == 0) {
      C = cnt;
    }
    else {
      C = min(C,cnt);
    }
  }
  cout << C << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    int K, N=0;
    cin >> S >> K;
    while(1){
        if(S[N] == '1') N++;
        else break;
    }
    if(N >= K) cout << 1 << "\n";
    else cout << S[N] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

int main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    int m=sqrt(n)+1;
    ll a[k+1][m+1];
    ll b[k+1][m+1];
    repf(i,1,m+1) 
    {
        a[1][i]=min(i,(ll)n);
        b[1][i]=n/i;
    }
    repf(i,2,k+1)
    {
        a[i][0]=0;
        repf(j,1,m+1)
        {
            a[i][j]=(a[i][j-1]+b[i-1][j])%mod;
        }
        b[i][m]=a[i][n/m];
        repb(j,m-1,1)
        {
            b[i][j]=(b[i][j+1]+(a[i-1][j]*(n/j-n/(j+1)))%mod)%mod;
        }
    }
    cout<<b[k][1]<<endl;
}
 

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll l = a[0], r = a[0];
  ll ans = 0;

  priority_queue<ll> que;
  que.push(a[0]);
  for(ll i = 1; i < N; i++) {
    ans += que.top();
    que.pop();
    que.push(a[i]);
    que.push(a[i]);
  }  
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 6936
from copy import deepcopy
import itertools


def read():
    return int(input())


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


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


a, b, c, k = readmap()

if k % 2:
    print(b-a)
else:
    print(a-b)

Measured memory_bytes: 3700
while True:
 result = 0
 i = input().split()
 if i[1] == '+':
  result = int(i[0]) + int(i[2])
 elif i[1] == '-':
  result = int(i[0]) - int(i[2])
 elif i[1] == '*':
  result = int(i[0]) * int(i[2])
 elif i[1] == '/':
  result = int(i[0]) // int(i[2])
 elif i[1] == '?':
  break
 print(result)

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  char X, Y;
  cin >> X >> Y;

  if (X - Y > 0) cout << ">" << endl;
  else if (X == Y) cout << "=" << endl;
  else cout << "<" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a,b,c,x;
        int count=0;
        scanf("%d", &a);
        scanf("%d", &b);
        scanf("%d", &c);
        scanf("%d", &x);
        for(int i=0; i<=a ;i++){
                for(int j=0; j<=b ;j++){
                        for(int k=0; k<=c ;k++){
                                if(500*i+100*j+50*k == x) count++;
                        }
                }
        }
        printf("%d",count);

        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;

void check( int a , int b , int c , int d ) 
{
	if ( c < a ) 
	{
		check ( c , d , a , b ) ; 
		return ; 
	}
	if ( c > b ) 
	{
		cout << "0\n";
	}
	else
	{
		cout << min(d-c,b - c) << endl ; 
	}

}

int main()
{
	ios_base::sync_with_stdio(0);	
	int a , b , c , d ;
	cin >> a >> b >> c >> d ;
	check(a,b,c,d) ; 
	return 0 ;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(100005, 0);
    for (Int i = 0; i < n; i++) {
        Int x, y;
        cin >> x >> y;
        x--;
        y--;
        a[x]++;
        a[y + 1]--;
    }
    for (Int i = 0; i <= 100000; i++) {
        a[i + 1] += a[i];
    }
    Int res = 0;
    for (Int i = 0; i <= 100000; i++) {
        if (a[i] >= i) {
            res = i;
        }
    }
    dump(res);
    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int c = 0;
  if (s[0] == 'o') c++;
  if (s[1] == 'o') c++;
  if (s[2] == 'o') c++;
  cout << 700 + 100*c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

string s;

int main(){
	cin>>s;
	ll head = 0;
	ll ans = 0;
	for(int i = 0; i<s.size(); ++i){
		if(s[i] == 'A'){	
			while(s[i] == 'A'){
				++head; ++i;
			}
		}
		if(s[i] == 'B' && s[i+1] == 'C'){
			ans += head;
			i += 1;
		}else{
			head = 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
a = []
for i in range(n):
    a+=[list(map(int, input().split()))]
    a[i]+=[sum(a[i])]
    print(*a[i])
a=list(zip(*a[::-1]))
for i in range(m):print(sum(a[i]),end=' ')
print(sum(a[m]))

Measured memory_bytes: 7884
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	getline(cin,a);
	int n;
	int js=0;
	n=a.size();
	for(int i=0;i<n;i++)
	{
		if(a[i]=='9')
		{
			js++;
		}
	} 
	if(js==0)
	{
		cout<<"No";
		return 0;
	}
	if(js!=0)
	{
		cout<<"Yes";
		return 0;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}
void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  string s;
  cin>>s;
  if(s[s.length()-1]!='s') s+="s";
  else s+="es";
  cout<<s<<endl;
}

int main(){
    optimizeIO();
    {solve();}
}


Measured memory_bytes: 7020
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    LL num=0;

    LL min,max,N;
    cin>>N>>min>>max;

    FOR(i,1,N+1){

        int a=i;
        int b=0;
       // cerr<<"a:"<<a<<endl;
        do{

            b+=a%10;
            a/=10;
            //cerr<<"a2:"<<a<<"b:"<<b<<endl;
            
        }while(a>9);

        b+=a;

        if(min<=b&&b<=max){
           // cerr<<"ok:"<<i<<endl;
            num+=i;
        }


    }

    cout<<num<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string s;
  cin >> s;

  if (s=="Sunny"){
    cout << "Cloudy" << endl;
  }else if (s=="Cloudy"){
    cout << "Rainy" << endl;;
  }else{
    cout << "Sunny" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
def main():
    n = int(input())
    s = input()
    mod = 1000000007
    c = Counter(s)
    ans = 1
    for v in c.values():
        ans = ans * (v + 1) % mod
    print(ans - 1)
if __name__ == '__main__':
    main()


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

int main() {
	float ans = 1000000;
	int t_ans=0;
	int n,t,a;cin>>n>>t>>a;
	vector<float>h(n);
	for(int i=0;i<n;++i)cin>>h[i];
	for(int i=0;i<n;++i){
		float temp = t - h[i] * 0.006;
		if(abs(temp-a)<ans){
			ans=abs(temp-a);
			t_ans=i+1;
		}
		//cout<<temp<<endl;
	}
	cout<<t_ans<<endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = [list(map(int,input().split())) for _ in range(h)]
memo = {}
def dfs(nv,vl,cost):
    if nv==1:
        return cost
    if nv in memo.keys():
        return cost+memo[nv]
    vl_ = vl.copy()
    vl_.append(nv)
    ret = []
    for i in range(10):
        if not i in vl_:
            ret.append(dfs(i,vl_,cost+c[nv][i]))
    return min(ret)
cost = []
for i in range(10):
    memo[i] = dfs(i,[],0)
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            ans += memo[a[i][j]]
print(ans)

Measured memory_bytes: 3444
fn main() {
	let mut s = String::new();
	use std::io::{Read, Write};
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut it = s.split_whitespace();
	let n: usize = it.next().unwrap().parse().unwrap();
	let s: Vec<_> = it.next().unwrap().chars().collect();
	let q: usize = it.next().unwrap().parse().unwrap();
	let out = std::io::stdout();
	let mut out = std::io::BufWriter::new(out.lock());
	for k in it.map(|a| a.parse::<usize>().unwrap()) {
		let mut ans = 0u64;
		let mut cnt = (0, 0, 0);
		for i in 0..s.len() {
			match s[i] {
				'D' => cnt.0 += 1,
				'M' => {
					cnt.1 += 1;
					cnt.2 += cnt.0;
				},
				'C' => {
					ans += cnt.2;
				}
				_ => (),
			}
			if i < k - 1 { continue; }
			match s[i - (k - 1)] {
				'D' => {
					cnt.0 -= 1;
					cnt.2 -= cnt.1;
				}
				'M' => {
					cnt.1 -= 1;
				}
				_ => (),
			}
		}
		writeln!(out, "{}", ans).unwrap();
	}
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	int L=0,R=1e9;
	for(int i=0;i<m;++i){
		int l,r; cin>>l>>r;
		L=max(L,l),R=min(R,r);
	}
	cout<<(R-L>=0?R-L+1:0)<<"\n"s;
}

Measured memory_bytes: 256
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=1;i<=n;i++){
        if(a[i] == a[i - 1])continue;
        --a[i];
        if(a[i] < a[i - 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,i,ans=0;
  cin>>n;
  vector<int64_t> a(n);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    if(i>0&&a.at(i)<a.at(i-1)){
      ans+=a.at(i-1)-a.at(i);
      a.at(i)=a.at(i-1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(n);
    llin(a);
    llin(b);
    ll p=0;
    ll c=0;
    ll d=0;
    ll e=0;
    FOR(i,0,n-1){
        cin >>p;
        if(p<=a){
            c++;
        }else if(p>b){
            e++;
        }else{
            d++;
        }
    }
    sal(min(min(c,d),e));
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100010][2];
int a[3];
vector<char>ans;
int main(){
    int n; scanf("%d%d%d%d", &n, &a[0], &a[1], &a[2]);
    for (int i = 1; i <= n; i++) scanf(" %s", s[i]), s[i][0] -= 'A', s[i][1] -= 'A';
    for (int i = 1; i <= n; i++){
        char cx = s[i][0], cy = s[i][1];
        int &x = a[cx];
        int &y = a[cy];
        if (x == 0 && y == 0){
            puts("No");
            return 0;
        }
        if (x > y) x--, y++, ans.push_back('A' + cy);
        else if (x < y) y--, x++, ans.push_back('A' + cx);
        else {
            char nx = s[i + 1][0], ny = s[i + 1][1];
            if (i == n || (i < n && nx == cx && ny == cy)) x--, y++, ans.push_back('A' + s[i][1]);
            else {
                if (cx == nx || cx == ny) y--, x++, ans.push_back('A' + cx);
                else if (cy == nx || cy == ny) x--, y++, ans.push_back('A' + cy);
            }
        }
        assert(a[0] >= 0 && a[1] >= 0 && a[2] >= 0);
    }
    puts("Yes");
    for (char ch : ans) printf("%c\n", ch);
    return 0;
}

Measured memory_bytes: 4096
//2012情報オリンピック本選問題1「JJOOII」
#include<stdio.h>
#include<string.h>

#define max 1000001

int main(void)
{
	char *JOIList, c;
	//f1:for文用,cnt:連続している文字数カウント
	//k:文字列レベル,out:最大文字列レベル,m:文字列の長さ
	int f1, cnt = 0, k = 0, out = 0, sw = 0, m;

	JOIList = new char [max];
	scanf("%s",JOIList);

	m = strlen(JOIList);
	c = JOIList[0];
	for(f1 = 0; f1 <= m; f1++){
		//同じ文字が連続しているか
		if(c == JOIList[f1])
			cnt++;
		else{
			//現在調べていた文字がJであった。
			if(c == 'J'){
				k = cnt;
				sw = 1;
			}
			//現在調べていた文字がOで前の文字列がJと続いていた
			else if(c == 'O' && sw == 1){
				if(k >= cnt){
					k = cnt;
					sw = 2;
				}
				else
					sw = 0;
			}
			//現在調べていた文字がIで前の文字列がOと続いていた
			else if(c == 'I' && sw == 2){
				sw = 0;
				//IがOより多かった
				if(k <= cnt){
					if(out < k){
						out = k;
					}
				}
			}
			else
				sw = 0;
			cnt = 1;
			c = JOIList[f1];
		}
	}

	printf("%d\n",out);

	return 0;
}

Measured memory_bytes: 0
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freans("output.txt","w",stdout)
#define read freans("input.txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;

int main()
{
    int S = 0,T = 0;
    string s;
    cin >> s;
    int sum = s.length();
    for(int i=0;i<s.length();i++)
    {
        if(s[i] == 'S')
            S++;
        else if(s[i] == 'T' && S) sum-=2,S--;
    }
    cout << sum << endl;




    return 0;
}








Measured memory_bytes: 644
/*input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1500+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,m;
    cin>>n>>m;
    int sum=0;
    REP(i,m){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>n){
        cout<<"-1";
    }
    else{
        cout<<n-sum;
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>A>>B;
    if(A+B >= 10) cout<<"error"<<endl;
    else cout<<A+B<<endl;
}

Measured memory_bytes: 256
import numpy as np


def main():
    input()
    a = [int(i) for i in input().split()]
    a.sort()
    dp = np.zeros(a[-1] + 1, dtype=np.int)
    for ai in a:
        if dp[ai] == 0:
            dp[ai] = 1
            dp[ai * 2:a[-1] + 1:ai] = 2
        else:
            dp[ai] = 2
    # print(dp)
    print(len(dp[dp == 1]))


if __name__ == '__main__':
    main()
    

Measured memory_bytes: 51480
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var n, k int
	fmt.Fscan(read, &n, &k)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(read, &h[i])
	}
	sort.Ints(h)

	cnt := 0
	for i := 0; i < n-k; i++ {
		cnt += h[i]
	}
	fmt.Fprintln(write, cnt)
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	
	while (cin >> n >> m, n, m){
		bool num[510][510] = {false};
		int a, b;
		
		for (int i = 0; i < m; i++){
			cin >> a >> b;
			num[a][b] = true;
			num[b][a] = true;
		}
		
		bool member[510] = {false};
		for (int i = 2; i <= n; i++){
			if (num[1][i]){
				member[i] = true;
				for (int j = 2; j <= n; j++){
					if (num[i][j])  member[j] = true;
				}
			}
		}
		
		int count = 0;
		for (int i = 2; i <= n; i++){
			if (member[i])  count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	int n, k;
	cin >> n >> k;
	vector <ld> v(n);
	for (auto &i : v) {
		cin >> i;
		i = ((double)(i + 1) / 2.0);
	}
	vector <ld> sums(n + 1); sums[1] = v[0];
	for (int i = 1; i <= n; ++i) {
		sums[i] = sums[i - 1] + v[i - 1];
	}
	ld ans = 0;
	for (int i = k; i <= n; ++i) {
		ans = max(ans, sums[i] - sums[i - k]);
	}
	cout << fixed << setprecision(20) << ans;
}                        

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int n,m,ans[9];
pair<int,int>sc[9];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++) {
		cin>>sc[i].first>>sc[i].second;
		if(sc[i].first==1&&sc[i].second==0&&n>1) {
			cout<<-1<<endl;
			return 0;
		}
		for(int j=0;j<i;j++)
			if(sc[i].first==sc[j].first&&sc[i].second!=sc[j].second) {
				cout<<-1<<endl;
				return 0;
			}
	}
	if(n==1) {
		if(m==0) cout<<0<<endl;
		else cout<<sc[0].second<<endl;
		return 0;
	}
	if(m==0) {
		cout<<1;
		while(n>1) cout<<0,n--;
		return 0;
	}
	memset(ans,-1,sizeof(ans));
	sort(sc,sc+m);
	for(int i=1;i<sc[0].first;i++) ans[i]=i==1?1:0;
	for(int i=0;i<m-1;i++) {
		ans[sc[i].first]=sc[i].second;
		for(int j=sc[i].first+1;j<sc[i+1].first;j++) ans[j]=0;
	}
	ans[sc[m-1].first]=sc[m-1].second;
	int pos=sc[m-1].first;
	while(pos<n) ans[++pos]=0;
	for(int i=1;i<=n;i++) cout<<ans[i];
	return 0;
}

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

#define ll long long

int main () {
  ll h, w;
  cin >> h >> w;
  ll dp[10][10];
  for (ll i = 0; i < 10; i++) {
    for (ll j = 0; j < 10; j++) {
      cin >> dp[i][j];  
    }  
  }  
  for (ll k = 0; k < 10; k++) {
    for (ll i = 0; i < 10; i++) {
      for (ll j = 0; j < 10; j++) {
        if (dp[i][j] > dp[i][k] + dp[k][j]) {
          dp[i][j] = dp[i][k] + dp[k][j];  
        }  
      }  
    }  
  }
  ll ans = 0;
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      ll s;
      cin >> s;
      if (s != -1) {
        ans += dp[s][1];
      }
    }  
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int N=100007;
int n,pw[N][2],pp=0,mx,L,R,M;
struct pos{
	int x,id,w;
	bool operator<(const pos&p)const{return x<p.x;}
}ps[N*2];
int dfn[N],low[N],scc[N],tk=0,ss[N],sp=0,I[N],tr1[N],tr2[N];
std::vector<int>e[N];
bool in[N];
void mins(int&a,int b){if(a>b)a=b;}
void tj(int w){
	dfn[w]=low[w]=++tk;
	in[ss[++sp]=w]=1;
	for(int i=0;i<e[w].size();++i){
		int u=e[w][i];
		if(!dfn[u]){
			tj(u);
			mins(low[w],low[u]);
		}else if(in[u])mins(low[w],dfn[u]);
	}
	if(dfn[w]==low[w]){
		int u;
		do in[u=ss[sp--]]=0,scc[u]=w;while(u!=w);
	}
}
void ae(int a,int b){
	e[a].push_back(b);
}
void ae1(int w,int l,int r){
	if(l>r)return;
	if(l<=w&&w<=r)ae1(w,l,w-1),ae1(w,w+1,r);
	else for(w+=mx,l+=mx-1,r+=mx+1;r-l>1;l>>=1,r>>=1){
		if(~l&1)ae(w,tr1[l+1]);
		if(r&1)ae(w,tr1[r-1]);
	}
}
void ae2(int w,int l,int r){
	if(l>r)return;
	if(l<=I[w]&&I[w]<=r)ae2(w,l,I[w]-1),ae2(w,I[w]+1,r);
	else for(w+=mx,l+=mx-1,r+=mx+1;r-l>1;l>>=1,r>>=1){
		if(~l&1)ae(tr2[l+1],w);
		if(r&1)ae(tr2[r-1],w);
	}
}
bool chk(){
	for(int i=0;i<mx*3;++i)dfn[i]=0,e[i].clear();
	for(int i=2;i<mx;++i)ae(i/2,i),ae(mx*2+i,mx*2+i/2);
	for(int i=1;i<=pp;++i){
		int j=I[i],l0,r0;
		ae(mx+i>>1,mx+j);
		ae(mx+i,mx*2+(mx+i>>1));
		l0=std::upper_bound(ps+1,ps+pp+1,(pos){ps[i].x-M})-ps;
		r0=std::lower_bound(ps+1,ps+pp+1,(pos){ps[i].x+M})-ps-1;
		ae1(i,l0,r0);
		ae2(j,l0,r0);
	}
	tj(1);
	for(int i=1;i<=n;++i)if(scc[mx+pw[i][0]]==scc[mx+pw[i][1]])return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;++i){
		scanf("%d%d",&x,&y);
		ps[++pp]=(pos){x,i,0};
		ps[++pp]=(pos){y,i,1};
	}
	std::sort(ps+1,ps+pp+1);
	for(mx=1;mx<pp+2;mx<<=1);
	for(int i=1;i<=pp;++i)pw[ps[i].id][ps[i].w]=i;
	for(int i=1;i<=pp;++i){
		int x=pw[i][0],y=pw[i][1];
		I[x]=y,I[y]=x;
	}
	for(int i=1;i<mx;++i)tr1[i]=i,tr2[i]=mx*2+i;
	for(int i=1;i<=pp;++i)tr1[mx+i]=mx+I[i],tr2[mx+i]=mx+i;
	L=0,R=1e9;
	while(L<R){
		M=L+R+1>>1;
		if(chk())L=M;
		else R=M-1;
	}
	printf("%d\n",L);
	return 0;
}

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

bool isPrime(int num){
     for(int i=6;i<num;i+=7){
	  if(num%i==0) return false;
     }
     for(int i=8;i<num;i+=7){
	  if(num%i==0) return false;
     }
     return true;
}

int main(){
     int num;
     while(cin>>num,num!=1){
	  cout<<num<<":";
	  for(int i=7;i-1<=num;i+=7){
	       if(num%(i-1)==0&&isPrime(i-1)) cout << " " << i-1;
	       if(num%(i+1)==0&&isPrime(i+1)) cout << " " << i+1;
	  }
	  cout<<endl;
     }
     return 0;
}

Measured memory_bytes: 864
k = int(input())
a, b = map(int, input().split())

if a > k:
    temae = (a//k)*k
    if a <= temae + k <= b or a <= temae <= b:
        print('OK')
    else:
        print('NG')
else:
    if a <= k <= b:
        print('OK')
    else:
        print('NG')

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

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

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var vi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var even = new Dictionary<int, int>();
            var odd = new Dictionary<int, int>();
            for (var i = 0; i < vi.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (even.ContainsKey(vi[i])) even[vi[i]]++;
                    else even.Add(vi[i], 1);
                }
                else
                {
                    if (odd.ContainsKey(vi[i])) odd[vi[i]]++;
                    else odd.Add(vi[i], 1);
                }
            }
            var evenOrder = even.Select(dict => new { X = dict.Key, Count = dict.Value }).OrderByDescending(x => x.Count).ToArray();
            var oddOrder = odd.Select(dict => new { X = dict.Key, Count = dict.Value }).OrderByDescending(x => x.Count).ToArray();

            var evenMax = evenOrder[0].Count;
            var oddMax = oddOrder[0].Count;
            if (evenOrder[0].X == oddOrder[0].X)
            {
                var tmpEven = evenOrder.Length > 1 ? evenOrder[1].Count : 0;
                var tmpOdd = oddOrder.Length > 1 ? oddOrder[1].Count : 0;
                if (tmpEven > tmpOdd) evenMax = tmpEven;
                else oddMax = tmpOdd;
            }

            var answer = vi.Length - evenMax - oddMax;
            Console.WriteLine(answer);
        }
    }
}


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

using namespace std;

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

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

    int q;
    cin >> q;
    while (q--) {
        int b, e, k;
        cin >> b >> e >> k;
        cout << count(vt.begin() + b, vt.begin() + e, k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int r;
  cin >> r;
  cout << fixed << setprecision(15) << 2 * (22.0 / 7.0) * r << endl;

  return 0;
}

Measured memory_bytes: 3804
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: i,j,k,n,ans=0,a,b,c,m1,m2,o
    integer(int64), allocatable:: l(:)

    read*, n
    allocate(l(n))
    read*, l(:)
    
    do i=1,n-2
        a = l(i)
        do j=i+1,n-1
            b = l(j)
            do k=j+1,n
                c = l(k)
                if (a /= b .and. b/=c .and. c/=a) then
                    m1 = max(a,b,c)
                    m2 = min(a,b,c)
                    o=0
                    if (m1 /= a .and. m2 /= a) o = a
                    if (m1 /= b .and. m2 /= b) o = b
                    if (m1 /= c .and. m2 /= c) o = c
                    if (m1 < m2+o) then
                        ans=ans+1
                    end if
                end if
            end do
        end do
    end do
    print'(i0)', ans
end program main

Measured memory_bytes: 2932
from collections import deque
N,Q = map(int, input().split())
G = [[] for _ in range(N)]
count = [0]*N
for i in range(N-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(Q):
    p,x = map(int, input().split())
    count[p-1]+=x
q = deque([0])
flag = [False]*N
while q:
    v = q.pop()
    flag[v] = True
    for w in G[v]:
        if flag[w]:
            continue
        count[w]+=count[v]
        q.append(w)
print(*count)


Measured memory_bytes: 105236
import collections

N, M = map(int,input().split())
Hl = list(map(int,input().split()))
l0 = [1]*N

for i in range(M):
    A, B = map(int,input().split())
    if Hl[A-1] > Hl[B-1]:
        l0[B-1] = 0
    elif Hl[A-1] < Hl[B-1]:
        l0[A-1] = 0
    else:
        l0[A-1] = 0
        l0[B-1] = 0

count = 0
for value in l0:
    count += value

print(count)

Measured memory_bytes: 20460
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
bool num[8] = { false };

int main(void) {
	ll n,a,f=0;
	cin >> n;
	for (ll i = 0;i < n;i++) {
		cin >> a;
		if (0 <= a&&a < 400)num[0] = true;
		if (400 <= a&&a < 800)num[1] = true;
		if (800 <= a&&a < 1200)num[2] = true;
		if (1200 <= a&&a < 1600)num[3] = true;
		if (1600 <= a&&a < 2000)num[4] = true;
		if (2000 <= a&&a < 2400)num[5] = true;
		if (2400 <= a&&a < 2800)num[6] = true;
		if (2800 <= a&&a < 3200)num[7] = true;
		if (a >= 3200)f++;
	}
	ll min = 0, max = 0;
	for (ll i = 0;i < 8;i++) {
		if (num[i]) {
			min++;
			max++;
		}
	}
	if (min == 0)cout << 1 << " " << max + f << endl;//全てレートが3200以上の時
	else cout << min << " " << max + f << endl;
	return 0;
}

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

def count(a,b):
    if a+b >= n:
        ans = l
    else:
        if b == 0:
            ans = l[:a]
        else:
            ans = l[:a]+l[-b:]

    check = sum(ans)
    
    if k-a-b> 0:
        ans.sort()

        for i in range(min(k-a-b,len(ans))):
            if ans[i] < 0:
                check -= ans[i]
            else:
                break
    return check
sub = 0
for i in range(min(n,k)+1):
    for j in range(min(n,k)-i+1):
        sub = max(sub,count(i,j))
print(sub)


Measured memory_bytes: 3064