akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
using namespace std;


long long n, x;
long long work(long long h, long long w) {
	if (w < h) {
		return h + w + work(w, h - w);
	}
	if (w % h == 0) return 2 * w;
	return 2 * h * (w / h) + 3 * (w % h) + work(h - w % h, w % h);
}
int main() {
	scanf("%lld%lld", &n, &x);
	if (x * 2 == n) {
		printf("%lld\n", 3 * x);
		return 0;
	}
	if (x * 2 < n) {
		printf("%lld\n", 4 * x + work(n - 2 * x, x));
	}
	else {
		printf("%lld\n", x + work(n - x, x));
	}
	return 0;
}


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

int main(void){
    int N,M;
    cin>>N>>M;
    string A[N],B[M];

    for(int i=0;i<N;i++)
        cin>>A[i];
    for(int i=0;i<M;i++)
        cin>>B[i];
    bool ans=false;

    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            bool eq=true;
            for(int k=0;k<M;k++){
                string sub=A[i+k].substr(j,M);
                if(sub!=B[k]){
                    eq=false;
                    break;
                }
            }
            if(eq){
                ans=true;
                break;
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

ll mpow(ll a, ll n){
    ll res = 1;
    while (n > 0){
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, m, ans = 0; sc(n), sc(m);
    bool check = true;
    vector<int> s(m), c(m), x(n,-1);
    rep(i, 0, m) sc(s[i]), sc(c[i]);
    rep(i, 0, m){
        if (x[s[i]-1]==-1 || x[s[i]-1]==c[i]) x[s[i]-1] = c[i];
        else check = false;
        if (!check) break;
    }
    rep(i, 0, n){
        if (x[i] == -1){
            if (i == 0) ans += mpow(10, n-i-1);
        }else{
            if (i == 0 && x[i] == 0){
                if (n == 1){
                    ans = 0;
                    break;
                }
                check = false;
            }
            ans += x[i] * mpow(10, n-i-1);
        }
    }
    if (n == 1 && m == 0) ans = 0;
    if (check) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3704
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, a, b] <- getIntList
  let loop = n `div` (a + b)
  let remain = n `mod` (a + b)
  if remain <= a
    then print $ loop * a + remain
    else print $ (loop + 1) * a


Measured memory_bytes: 636
import math
n, d = map(int, input().split())
x = [[int(i) for i in input().split()] for j in range(n)]

res = 0
for i in range(n-1):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x[i][k] - x[j][k])**2
        if math.sqrt(tmp).is_integer():
            res += 1

print(res)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
	"math"
)

func main() {
	sc := NewScanner()

	x := sc.NextInt()
	a := sc.NextInt()
	b := sc.NextInt()

	da := math.Abs(float64(a - x))
	db := math.Abs(float64(b - x))
	if da < db {
		fmt.Printf("A\n")
	} else {
		fmt.Printf("B\n")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int n, d1, d2, cnt;

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; ++i){
        scanf("%d%d", &d1, &d2);
        if (d1 == d2){
            ++cnt;
        }
        else{
            cnt = 0;
        }
        if (cnt == 3){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}


Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
S = input()

n = 0
best_n = 0
length = len(S)

for i in range(length):
    if (S[i] in ['A', 'C', 'G', 'T']):
        n += 1
        if (i == length - 1) and (n > best_n):
            best_n = n
    else:
        if (n > best_n):
            best_n = n
            n = 0
print(best_n)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    K = inputInt()
    x = inputList()
    
    ans = 0
    for i, val in enumerate(x):
        tmp = min(val-0, abs(K-val))
        ans += tmp * 2
        
    print(ans)
    
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
/*

	TRY_TO_BE8T_ME

*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define FIO ios::sync_with_stdio(0);
ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
int main() 
{
	FIO;
	ll i,j,k,c=0,n,m,d=0,w,x,y,z;
	cin>>w>>x>>y>>z;
	c=abs(x-w);
	d=abs(y-x);
	if((c<=z&&d<=z)||abs(y-w)<=z)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
int x,y,GCD;
ll factorial(ll n){
    ll fac=1;
    for(int i=1;i<=n;i++){
        fac=(fac*i)%MOD;
    }
    return fac;
}
ll modinv(long long a) {
    long long b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD; 
    if (u < 0) u += MOD;
    return u;
}

int main(){
    FAST
    ll x,y;
    cin >> x >> y;
    if((2*x-y)%3 == 0 && (2*y-x)%3 == 0 && 2*x-y >=0 && 2*y-x>=0){
        ll n = (2*x-y)/3;
        ll m = (2*y-x)/3;
        cout << factorial(n+m) * modinv(factorial(n))%MOD * modinv(factorial(m))%MOD;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    set< char > st;
    for( int i = 0; i < s.size(); ++i ) {
        st.insert( s[i] );
    }

    if( st.size() == s.size() ) cout << "yes";
    else cout << "no";
    cout << endl;
    return 0;
}



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

p.sort()

if n == 0:
    print(x)
else:
    for i in range(0, 100):
        if (x-i) not in p:
            print(x-i)
            exit()
        if (x+i) not in p:
            print(x+i)
            exit()


Measured memory_bytes: 9180
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N = xs[0];
   let ans = 0;
   for(var i=1; i<=xs[0]; i++){
      if(i%3==0||i%5==0){
      ans += 0
      }else{
      ans += i
      //console.log(i)
      }
   }
   console.log (ans);

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 32420
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int a,b,c;
      cin>>a>>b>>c;
      if(a==b&&b!=c||a==c&&c!=b||b==c&&b!=a)
            cout<<"Yes"<<endl;
      else
            cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;
int a[100010];
signed main(){
    int n;
    cin >> n;
    rep(i,n)cin >> a[i];

    int m = 0;
    int sum = 0;
    int mini = INF;
    rep(i,n){
        if(a[i] < 0)m++;
        sum += abs(a[i]);
        mini = min(mini,abs(a[i]));
    }
    if(m%2 == 0)cout << sum << endl;
    else cout << sum - 2*mini << endl;


    
     
     
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc125.contest.atcoder.jp/tasks/abc125_d


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

struct Node{
	int x,y,num;
};

int N;
int A[110],B[110],C[110],D[110];
P p[110],p2[110];
bool F[110],F2[110];
Node n[110];
Node n2[110];

bool com(Node a,Node b){
	return a.x<b.x;
}

bool com2(Node a,Node b){
	return a.y>b.y;
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i]>>B[i];
		Node s;
		s.x=A[i],s.y=B[i],s.num=i;
		n[i]=s;
	}
	REP(i,N){
		cin>>C[i]>>D[i];
		Node s;
		s.x=C[i],s.y=D[i],s.num=i;
		n2[i]=s;
	}
	sort(n2,n2+N,com);
	int ans=0;
	REP(i,N){
		vector<Node> v;
		REP(j,N){
			if(F[j]==false&&n[j].x<n2[i].x&&n[j].y<n2[i].y){
				v.push_back(n[j]);
			}
		}
		if(v.empty())continue;
		sort(v.begin(),v.end(),com2);
		int p=v[0].num;
		F[p]=true;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
struct Lazy_BIT {
	vector<T> x, lazy;
#define SZ(a) (a&-a)
#define LEFT(a) (a - SZ(a))
#define UP(a) (a + SZ(a))

	Lazy_BIT(int n) :x(n + 1), lazy(n + 1) {}
	T sum(int r) {
		T ret = 0;
		for (int k = r; 0 < k; k = LEFT(k)) {
			ret += lazy[k] * SZ(k) + x[k];
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && cp < x.size(); cp = UP(cp)) {
				ret += lazy[cp] * (r - LEFT(cp));
			}
		}
		return ret;
	}
	void add(int r, int v) {
		for (int k = r; 0 < k; k = LEFT(k)) {
			lazy[k] += v;
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && cp < x.size(); cp = UP(cp)) {
				x[cp] += v * (r - LEFT(cp));
			}
		}
	}


};


int main()
{
	int n, q;
	cin >> n >> q;
	Lazy_BIT<ll> fen(n);

	REP(i, q) {
		int m;
		scanf("%d", &m);
		if (m) {
			int s, t;
			scanf("%d %d", &s, &t);

			printf("%lld\n", fen.sum(t) - fen.sum(s - 1));
		}
		else {
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);

			fen.add(t, x);
			fen.add(s - 1, -x);
		}
	}

	return 0;
}


Measured memory_bytes: 4436
L = list (map ( int , input().strip().split(" " ) ) ) ;
L.sort() ; 


b ="No" ;
if L[0] == L[1] and L[1] == L[2] :
	pass ; 
elif L[0] == L[1] or L[1] == L[2] :
	b ="Yes" ;
print ( b ) ;

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, k;
    cin >> n >> k;
    vector<ll> Positive, Negative;
    Positive.emplace_back(0);
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x == 0)  --k;
        else if(x > 0)  Positive.emplace_back(x);
        else    Negative.emplace_back(-x);
    }
    if(k <= 0){
        cout << 0 << endl;
        return 0;
    }
    Negative.emplace_back(0);
    reverse(Negative.begin(), Negative.end());
    ll ans = 1e+15;
    int np = Positive.size(), nn = Negative.size();
    --np, --nn;
    for(int i = 0; i <= min(np, k); ++i){
        if(k - i > nn)  continue;
        chmin(ans, min(Positive[i] * 2 + Negative[k - i], Positive[i] + Negative[k - i] * 2));
    }
    for(int i = 0; i <= min(nn, k); ++i){
        if(k - i > np)  continue;
        chmin(ans, min(Negative[i] * 2 + Positive[k - i], Negative[i] + Positive[k - i] * 2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  unordered_map<string, ll> m;
  rep(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }

  ll M;
  cin >> M;
  rep(i, M) {
    string s;
    cin >> s;
    m[s]--;
  }

  ll ans = 0;
  for (auto mm : m) ans = max(ans, mm.second);
  ANS;
  return 0;
}

Measured memory_bytes: 3628
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    H = string_to_int(inputs[0])

    prev_h = -1
    max_count = 0
    count = 0
    for h in H:
        if prev_h == -1:
            prev_h = h
            continue

        if prev_h < h:
            max_count = max(max_count, count)
            count = 0
        else:
            count += 1

        prev_h = h
    max_count = max(max_count, count)
    return max_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 15444
Scanf.scanf "%d %d" (fun n m ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort (fun a b -> compare b a) a;
    let b = Array.make n 0 in
    b.(0) <- a.(0);
    for i = 1 to n - 1 do
        b.(i) <- b.(i - 1) + a.(i)
    done;

    let count_guest happiness =
        let count i =
            let rec loop l r =
                if l = r then l - 1 else
                    let m = (l + r) / 2 in
                    if a.(m) + a.(i) < happiness then loop l m else loop (m + 1) r
            in
            loop 0 n
        in
        let rec loop i acc =
            if i = n then acc else
                let v = count i in
                if v < 0 then acc else
                    loop (i + 1) (acc + v + 1)
        in
        loop 0 0
    in

    let rec loop l r =
        if l = r then l else
            let mm = (l + r) / 2 in
            let count = count_guest mm in
            if count > m then loop (mm + 1) r else loop l mm
    in
    let target = loop 0 200000 in

    let calc_happiness target =
        let count lim i =
            let rec loop l r =
                if l = r then l - 1 else
                    let m = (l + r) / 2 in
                    if a.(m) + a.(i) < target then loop l m else loop (m + 1) r
            in
            loop 0 (min lim n)
        in
        let rec loop i rest acc =
            if i = n then rest * (target - 1) + acc else
                let v = count rest i in
                let h = if v < 0 then 0 else a.(i) * (v + 1) + b.(v) in
                    loop (i + 1) (rest - v - 1) (acc + h)
        in
        loop 0 m 0
    in
    calc_happiness target |> Printf.printf "%d\n"
)

Measured memory_bytes: 7556
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string C){
    cout << (char)(C[0]+1)<< endl;
    return;
}

int main(){
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int arr[3];
    for(int j=0;j<3;j++)
    {
        cin>>arr[j];
    }
    std::map<int,int> freq;
    for (int c :arr)
    {
        // check if key 'c' exists in the map or not
        std::map<int,int>::iterator it = freq.find(c);

        // key already present in the map
        if (it != freq.end()) {
            it->second++;	// increment map's value for key 'c'
        }
            // key not found
        else {
            freq.insert(std::make_pair(c, 1));
        }
    }
int flag=0;
    for (auto &e: freq) {
        if(e.second==2)
        {
            flag=1;
            break;
        } else{
            flag=0;
            }
    }
    if(flag>0)
    {
        cout<<"Yes";
    } else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
maxsi_list = []

for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxss = float('-inf')
    maxi = -1
    maxii = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
        if s[i] > maxss:
            maxii = i
            maxss = s[i]
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs
    maxsi_list += [maxii+1]
best_ans = ans
best_score = prev_score
mergin = 1300
for tt in range(31):
    for dd in range(D):
        last = [0] * 26
        score = 0
        for d in range(1, D+1):
            if dd == (d-1):
                maxc = 0
                maxci = -1
                for i in range(26):
                    cost = c[i] * (d - last[i])
                    if maxc < cost:
                        maxc = cost
                        maxci = i+1
                prev_a = ans[dd]
                ans[dd] = maxci
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score+mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score

    for dd in range(D):
        last = [0] * 26
        score = 0
        prev_a = ans[dd]
        ans[dd] = maxsi_list[dd]
        for d in range(1, D+1):
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score+mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score

for a in best_ans:
    print(a)

Measured memory_bytes: 73528
import java.io.*;
import java.util.*;

public class Main{
	static int z = 0;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		for (int i = A; i <= B; i++) {
			if(i % K == 0){
				System.out.println("OK");
				System.exit(0);
			}
		}
		System.out.println("NG");
	}	

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

		public double nextDouble(String x) 
		{

			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}


	}
}

Measured memory_bytes: 32628
a,b,c,x,y = map(int,input().split())

ans = 0
# abがお得なパターン
if a + b >= c * 2:
    ans += c * min(x,y) * 2
    nokori = max(x,y) - min(x,y)
    # aが残ったパターン
    if max(x,y) == x:
        # abのがお得
        if a > c*2:
            ans += c * nokori * 2
        else:
            ans += a * nokori
    else:
        if b > c*2:
            ans += c * nokori * 2
        else:
            ans += b * nokori
else:
    ans += a * x + b* y

print(ans)



Measured memory_bytes: 9204
// Created by sz
#include <bits/stdc++.h>
using namespace std;

long long  N, M, down[100005], up[100005], a[100005];
vector<int> edges[100005];

void dfs(int cur, int pre){
    long long ans = 1;
    
    auto I = find(edges[cur].begin(), edges[cur].end(), pre);
    if (I != edges[cur].end()) edges[cur].erase(I);
    
    for(auto i:edges[cur]){
        if(i != pre){
            dfs(i, cur);
            (ans *= (1ll+ down[i]))%= M;
        }
    }
    down[cur] = ans;
}

void dfs2(int cur, int pre){
    int n = edges[cur].size();
    if (n){
        vector<long long> L(n); L[0] = 1;
        vector<long long> R(n); R.back() = 1;
        for (int i=1;i<n;i++) L[i] = L[i-1] * (down[edges[cur][i-1]] + 1) % M;
        for (int i=n-2;i>=0;i--) R[i] = R[i+1] * (down[edges[cur][i+1]] + 1) % M;
        for (int i=0;i<n;i++){
            int y = edges[cur][i];
            up[y] = 1 + up[cur] * L[i] % M * R[i] % M;
            dfs2(y, cur);
        }
    }
    a[cur] = down[cur] * up[cur] % M;
    
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>N>>M;
    int x,y;
    for(int i = 0; i< N-1; i++){
        cin>>x>>y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    up[1] = 1;
    dfs(1,0);
    dfs2(1, 0);
    for(int i = 1; i<=N; i++)cout<<a[i]<<" \n"[i==N];
    return 0;
}



Measured memory_bytes: 19200
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res


n = I()
P = LI()
bit = BIT(n + 1)
cnt = 0
for i in range(n):
    if not bit.sum(P[i] - 1):
        cnt += 1
    bit.add(P[i], 1)


print(cnt)




Measured memory_bytes: 65780
#include<iostream>

using namespace std;


int xx(int a,int b){
	return a*a+b*b;
}

int main(){
	while(1){
		int w,h;
		cin>>h>>w;
		int Nw=0,Nh=0;

		int mini=100000;
		if(w==0 && h==0)break;


		for(int j=1;j<=10000;j++){
			for(int i=1;(i<j && i*j<=20000);i++){
				if(xx(i,j)>xx(w,h) || (xx(i,j)==xx(w,h) && i>h)){
					if(xx(i,j)<mini || (xx(i,j)==mini && Nh>i)){
						mini=xx(i,j);
						Nw=j,Nh=i;
					}
				}
			}
		}
		cout<<Nh<<" "<<Nw<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(a+b==c||b+c==a||a+c==b) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, x, y = list(map(int, readline().split()))
    tmd = collections.defaultdict(list)
    tmd[x-1] += [y-1]
    tmd[y-1] += [x-1]
    for i in range(n):
        if i == 0:
            tmd[i] += [i + 1]
        elif i == n - 1:
            tmd[i] += [i - 1]
        else:
            tmd[i] += [i + 1]
            tmd[i] += [i - 1]

    res = [0] * (n - 1)
    for i in range(n):
        ql = [[0, i]]
        ql = collections.deque(ql)
        fq = collections.defaultdict(list)
        fq[i]
        while len(ql):
            cost, tmp = ql.popleft()
            for tmv in tmd[tmp]:
                if tmv not in fq:
                    ql.append([cost + 1, tmv])
                    fq[tmv]
                    res[cost] += 1
    for i in range(len(res)):
        res[i] //= 2
    print(*res, sep="\n")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 80092
#include<bits/stdc++.h>
#define ll long long
#define pub push_back 
#define pob pop_back 
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<iomanip>
#include<cmath>
using namespace std ;
int main()
{
	int a , size ;
	cin >> a ;
	size = log10(a) + 1 ;
	int ans;
	int arr[3] = {9 , 909 , 90909} ;
	if(size == 1)
	    ans = a;
	if(size == 3)
	    ans = 10 + (a-100) ;
	if(size == 5)
	    ans = 910 + (a-10000) ;
	if(size % 2 == 0)
	    ans = arr[size/2 - 1] ;
	    cout << ans<<endl ;
	return 0 ;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)

def main():
    X,Y,A,B,C = map(int,input().split())
    P = sorted(list(map(int,input().split())),reverse=True)
    Q = sorted(list(map(int,input().split())),reverse=True)
    R = list(map(int,input().split()))

    print(sum(sorted(P[:X]+Q[:Y]+R,reverse=True)[:X+Y]))

if __name__ == "__main__":
  main()


Measured memory_bytes: 110188
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  private final int MOD = (int) (1e9 + 7);

  private void solve(Scanner in, PrintWriter out) {
    int N = in.nextInt();
    int M = in.nextInt();
    char[] S = in.next().toCharArray();
    int[] right = new int[N];
    Arrays.fill(right, -1);
    for (int i = 0; i < M; i++) {
      int l = in.nextInt() - 1;
      int r = in.nextInt() - 1;
      if (right[l] < r) right[l] = r;
    }

    int max = 0;
    for (int i = 0; i < N; i++) {
      max = Math.max(max, i);
      max = Math.max(max, right[i]);
      right[i] = max;
    }

    int[] sum = new int[N];
    for (int i = 0; i < N; i++) sum[i] = S[i] - '0';
    for (int i = 0; i < N - 1; i++) sum[i + 1] += sum[i];

    long[][] dp = new long[N + 1][N + 1];
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
      for (int usedOne = 0; usedOne < N; usedOne++) {
        int r = right[i];
        int restOne = sum[r] - usedOne;
        if (restOne < 0) continue;
        if (restOne > 0) {
          dp[i + 1][usedOne + 1] += dp[i][usedOne];
          if (dp[i + 1][usedOne + 1] >= MOD) dp[i + 1][usedOne + 1] -= MOD;
        }
        if (r - i + 1 != restOne) {
          dp[i + 1][usedOne] += dp[i][usedOne];
          if (dp[i + 1][usedOne] >= MOD) dp[i + 1][usedOne] -= MOD;
        }
      }
    }
    out.println(dp[N][sum[N - 1]]);
  }

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(in, out);
    in.close();
    out.close();
  }
}


Measured memory_bytes: 105836
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) printf("%lld\n", num)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll d;
    cin >> d;
    
    if(d==25) {
        puts("Christmas");
    }else if(d==24) {
        puts("Christmas Eve");
    }else if(d==23) {
        puts("Christmas Eve Eve");
    }else if(d==22) {
        puts("Christmas Eve Eve Eve");
    }
    
    
    
    
    
    
    
}


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

int main() {
  int n;
  cin >> n;
  bool ans  = false;
  rep(i,26)rep(j,16){
    int sum = 4*i + 7*j;
    if(sum == n){
      ans  = true;
    }
  }
  puts(ans?"Yes":"No");
 }


Measured memory_bytes: 256
/**
 *   created: 20 August 2019  11:36:13
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n,w;
		cin>>n>>w;
		vll v(n);
		rep(i,0,n){
			cin>>v[i].first>>v[i].second;
		}
		vector< vl > mem(n,vl(w+1,0));
		mem[0][w-v[0].first] = v[0].second;
		rep(i,1,n){
			rep(j,0,w+1){
				if(j>=v[i].first)
					mem[i][j-v[i].first] = max(mem[i-1][j-v[i].first], mem[i-1][j]+v[i].second); 
				mem[i][j] = max(mem[i][j],mem[i-1][j]);
			}
		}
		ll res = 0;
		rep(i,0,w+1){
			res = max(mem[n-1][i],res);
		}
		cout<<res;
	}
	return 0;
}


Measured memory_bytes: 79488
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict

class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)
    
    def groups(self):
        if isinstance(self.parent,list):
            return list(map(lambda x: x<0, self.parent)).count(True)
        else: # self.parent: defaultdict
            return list(map(lambda x: x<0, self.parent.values())).count(True) 

class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

Xi = defaultdict(CountUp())
Yi = defaultdict(CountUp())
N = int(input())
xy = []
for _ in range(N):
    x, y = inpl()
    xi = Xi[x]
    yi = Yi[y]
    xy.append((xi,yi))
Nx = len(Xi)
Ny = len(Yi)
Nxy = Nx + Ny
uf = UnionFind(Nx+Ny)
for xi, yi in xy:
    uf.merge(xi,yi+Nx)

gi = defaultdict(CountUp())
Ng = uf.groups()
edges = [0]*Ng
nx = [0]*Ng
ny = [0]*Ng
for i in range(Nx):
    nx[gi[uf.root(i)]] += 1
for i in range(Nx,Nxy):
    ny[gi[uf.root(i)]] += 1
for xi, yi in xy:
    edges[gi[uf.root(xi)]] += 1

ans = 0
for g in range(Ng):
    ans += nx[g]*ny[g] - edges[g]
print(ans)

Measured memory_bytes: 25072
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string n;
  cin >> n;
  if ((n[0] == n[1] && n[1] == n[2]) || n[1] == n[2] && n[2] == n[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

ll fn(ll num, ll x) {
  if(num == -1) return 0;
  else return (num / x) +1;
}
int main() {
  ll a, b, x; cin >> a >> b >> x;
  ll ans = 0;
  cout << fn(b, x) - fn(a-1, x) << endl;
  // if(b % x == 0)
    // ans = (b/x) - (a/x) + 1;
  // else ans = (b/x) - (a/x);
  // cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<ll> h;
const ll INF = 1e12;

bool check()
{
    --h[0];
    for (int i = 0; i < N - 1; ++i)
    {
        if (h[i] > h[i + 1])
        {
            return false;
        }
        else if (h[i] < h[i + 1])
        {
            --h[i + 1];
        }
    }

    return true;
}

int main()
{
    cin >> N;
    h.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> h[i];

    if (check())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int n, a[101], i, j, k, b[101][101], l,m;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) scanf("%d %d", &a[i - 1], &a[i]);

	for (i = 1; i <= n; i++) b[i][i] = 0;
	for (l = 2; l <= n; l++) {
		for (i = 1; i <= n - l + 1; i++) {
			j = i + l - 1;
			b[i][j] = 1000000000;
			for (k = i; k <= j - 1; k++) {
				m = b[i][k] + b[k + 1][j] + a[i - 1] * a[k] * a[j];
				if (b[i][j] > m) b[i][j] = m;
			}
		}
	}
	printf("%d\n", b[1][n]);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
ll MAX=9223372036854775807;

int main(){
    fast_io;
    int n;
    cin>>n;
    double a[n],s=0;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    	s+=a[i];
    }
    s/=((double)n);
    int id=0;
    double ans=abs(s-a[0]);
    fo(i,1,n-1){
    	if(abs(s-a[i])<ans){
    		id=i;
    		ans=abs(s-a[i]);
    	}
    }
    show(id);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long num;
    long sum = 0;
    cin>>num;
    long t[num];
    for(int i =0;i<num;i++)
        cin>>t[i];
    for(int i = 1; i<num;i++){
        if(t[i]<t[i-1]) {
            sum  = sum + t[i-1]-t[i];
            t[i] = t[i-1];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - GeT AC
	var N, Q int
	fmt.Scan(&N, &Q)
	var S string
	fmt.Scan(&S)

	var count int
	var flag int
	sum := make([]int, N)
	for i := 0; i < N; i++ {
		if S[i] == 'A' {
			flag = 1
		} else if S[i] == 'C' && flag == 1 {
			flag = 0
			count++
		} else {
			flag = 0
		}

		sum[i] = count
	}

	var l, r int

	sc.Split(bufio.ScanWords)
	for i := 0; i < Q; i++ {
		l = nextInt()
		r = nextInt()
		fmt.Println(sum[r-1] - sum[l-1])

	}
}


Measured memory_bytes: 5764
import sys
input = sys.stdin.readline

MAX = 10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0

for i in range(N):
    ans += A[i]*(C(i, K-1)-C(N-i-1, K-1))
    ans %= MOD

print(ans)

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

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

using namespace std;

const int IINF = INT_MAX;
typedef pair<string,string> s2;
int n,d;
string name[210];
unordered_map<string,int> memo;

void dfs(int cur,string s,const string &target,int cost,int &mini){
  if( cost >= mini ) return;
  if( cost > d ) return;
  //cout << s << endl;
  if( cur >= target.size() ) {
    rep(i,s.size()) if( i >= target.size() && s[i] != ' ' ) ++cost;
    mini = min(mini,cost);

    return;
  }
  if( s[cur] == target[cur] ) {
    dfs(cur+1,s,target,cost,mini);
    return;
  }

  if( memo.count(s) ) if( memo[s] <= cost )return;

  string ns;
  //  Delete
  if( s[cur] != ' ' ) {
    ns = s.substr(0,cur) + s.substr(cur+1) + " ";
    dfs(cur,ns,target,cost+1,mini);
  }

  // Insert
  ns = s.substr(0,cur) + target[cur] + s.substr(cur);
  dfs(cur+1,ns,target,cost+1,mini);

  // Replace
  if( s[cur] != ' ' ) {
    ns = s;
    ns[cur] = target[cur];
    dfs(cur+1,ns,target,cost+1,mini);
  }

  // Swap
  ns = s;
  if( ns[cur+1] == target[cur] ) {
    swap(ns[cur+1],ns[cur]);
    dfs(cur+1,ns,target,cost+1,mini);
    swap(ns[cur+1],ns[cur]);
  }
  if( memo.count(s) ) memo[s] = min(memo[s],cost);
  else memo[s] = cost;
}

int compute(string a,string b){
  if( (int)a.size() > (int)b.size() ) swap(a,b);
  a = a + string((int)b.size()-(int)a.size(),' ');
  memo.clear();
  int mini = b.size();
  dfs(0,a,b,0,mini);
  return mini;
}

int main(){




  while( cin >> n,n ){
    cin >> d;
    rep(i,n) cin >> name[i];
    vector<s2> vec;
    rep(i,n) REP(j,i+1,n){
      int dist = compute(name[i],name[j]);
      string a = name[i], b = name[j];
      if( a > b ) swap(a,b);
      if( dist <= d ) vec.push_back(s2(a,b));
    }
    sort(vec.begin(),vec.end());    
    rep(i,vec.size()) cout << vec[i].first << "," << vec[i].second << endl;
    cout << (int)vec.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1280