akhauriyash/Code-Regression huggingface dataset:
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    A.sort()
    comb = [0 for _ in range(N)]  # comb[i] = i_C_(K-1)
    v = 1
    for i in range(K - 1, N):
        comb[i] = v
        v *= i + 1
        v *= mod_inv(i - K + 2, MOD)
        v %= MOD
    ans = 0
    for i, a in enumerate(A):
        ans += a * (comb[i] - comb[N - i - 1])
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20068
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {

    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while (A >= B) {
        B *= 2;
        K--;
    }
    while (B >= C) {
        C *= 2;
        K--;
    }

    cout << (K >= 0 ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
using static System.Math;
class Simple
{
    string s;
    void Solve() {
        //input
        s = io.String;
        //cal
        var ans = new string(s.Where((c, i) => i % 2 == 0).ToArray());
        //ret
        WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  vector<vector<int>> dp(m,vector<int>(10000,inf));
  dp[0][0]=0;
  rep(i,m){
    int a,b;cin>>a>>b;
    vector<int> c(b);
    int key=0;
    rep(j,b){
      cin>>c[j];
      key|=(1<<(c[j]-1));
    }
    rep(j,(1<<n)+1){
      int I=max((int)0,i-1);
      dp[0][j]=dp[0][j];
      dp[0][j|key]=min(dp[0][j|key],dp[0][j]+a);
    }
  }
  rep(i,10){
    //cout<<dp[0][i]<<"\n";
  }
  if(dp[0][(1<<n)-1]==inf){
    dp[0][(1<<n)-1]=-1;
  }
  cout<<dp[0][(1<<n)-1]<<"\n";
  return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,n) for(int i=0; i<(n); i++)
    using ll = long long;
    using P = pair<int,int>;
    int main()
    {
        int n;
        ll k;
        cin >> n >>  k;
        vector<int> a(n);
        rep(i,n){
            cin >> a[i];
            a[i]--;
        }

        vector<int> to;
        to.push_back(0);
        rep(i,n){
            int now = to.back();
            to.push_back(a[now]);


        }
        int visited[n+1];
        rep(i,n)visited[i] = 0;
        int s,end;
        rep(i,n){
            if(visited[to[i]]){
                end = i;
                break;
            }
            visited[to[i]] = 1;
        }
        rep(i,n){
            if(to[i] == to[end]){
                s = i;
                break;
            }
        }
        int len = end - s;

        if(k <s ){
            cout << to[k]+1 << endl;
            return 0;
        }
        k-=s;
        cout << to[k%len+s]+1 << endl;
        
        return 0;
    }

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

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> vp;
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        vp.push_back({{s,-p},i+1});
    }
    sort(vp.begin(), vp.end());
    for(auto p : vp)    cout << p.second << endl;
    return 0;
}

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

typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++){
    if(i%2==1) continue;
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

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

	ll a = 0;
	for (int i = 1; i <= n; i++) {
		if (i % k == 0) {
			a++;
		}
	}

	ll b = 0;
	for (int i = 1; i <= n; i++) {
		if (i % k == k / 2) {
			b++;
		}
	}

	ll ans = a * a * a;
	if (k % 2 == 0) {
		ans += b * b * b;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,t;

int main(){
	cin>>n>>t;
	int m=inf;
	for(int i=0;i<n;i++){
		int A,B;
		cin>>A>>B;
		if(B<=t) m=min(m,A);
	}
	if(m==inf) cout<<"TLE"<<endl;
	else cout<<m<<endl;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
candles = gets.split.map(&:to_i)
min = nil

# 座標0以上に存在してるろうそくを取得
candles_0_right = candles.map { |position| position >= 0 ? position : nil }.compact
# 座標0以下に存在してるろうそくを取得
candles_0_left  = candles.map { |position| position <= 0 ? position : nil }.compact.reverse

# まず右に行って、途中で左に折り返すパターン
k.step(1, -1) do |i| # i = 3, 2, 1 (折り返すまでに右側から取得する個数)
  current = 0 # 現時点での座標、スタート時には0
  time = 0 # 移動に費やした時間

  # 座標0以上に存在しているろうそくの個数が、取得したい個数よりも少ない場合は諦める
  next if i > candles_0_right.count

  # 右側からi個取得したあとの座標を更新し、移動時間に足し込む
  time += (candles_0_right[i-1] - current).abs
  current = candles_0_right[i-1]

  # ここから折り返し、k-i個を取得する
  if k - i > 0
    # 座標0以下に存在しているろうそくの個数が、取得したい個数よりも少ない場合は諦める
    next if k - i > candles_0_left.count

    # 左側からk-i個取得した場合の移動時間を計算する
    time += (candles_0_left[k-i-1] - current).abs
  end
  min = [min, time].compact.min
end

# 逆パターン
k.step(1, -1) do |i|
  current = 0
  time = 0
  next if i > candles_0_left.count
  time += (candles_0_left[i-1] - current).abs
  current = candles_0_left[i-1]
  if k - i > 0
    next if k - i > candles_0_right.count
    time += (candles_0_right[k-i-1] - current).abs
  end
  min = [min, time].compact.min
end

puts min


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  vi d(k); rep(i, k) std::cin >> d[i];
  srep(i, n, n * 100) {
    bool ok = true;
    int tmp = i;
    while (tmp != 0) {
      int remain = tmp % 10;
      rep(i, k) if (remain == d[i]) ok = false;
      tmp /= 10;
    }
    if (ok) {
      std::cout << i << "\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long result;
long long mbak;
void power(long long m,long long n)//m的n次方 
{
	if(n==0)
	{
		result=1;
		return;
	}	
	if(n==1)
	{
		result=(m*result%1000000007);
		return ;
	}
	if(n%2==0)
	{
		power((m*m)%1000000007,n/2);
		return ;
	} 
	result=(m*result)%1000000007;
	power(m,n-1);

}
int main()
{
	result=1;
	long long m;
	long long n;
	cin>>m>>n;
	mbak=m;
	m=m%1000000007;
	power(m,n); 
	//cout<<10460353203%1000000007<<endl;
	cout<<result<<endl;
	return 0;
} 


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

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

  ll ans = 0;
  char c = ' ';
  for (ll i = 0; i < N; i++) {
    if (S[i] != c) {
      ans++;
      c = S[i];
    }
  }

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
using ll = long long;
using namespace std;
int main() {
	int n, m;
	char A[10101][10101];
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (i != 0 && j != 0 && i != n - 1 && j != m - 1 && A[i][j] == '#')
				if (A[i + 1][j] != '#' && A[i][j + 1] != '#' && A[i - 1][j] != '#' && A[i][j - 1] != '#') {
					cout << "No" << endl;
					return 0;
				}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int n,k;
int dp[100001],a[100001];
int fun(int n)
{
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    //for(int i=0;i<n;i++)cout<<dp[i]<<endl;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j<0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            //cout<<dp[i]<<endl;
        }
    }
    return dp[n];
}
int32_t main()
{
    IOS;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)dp[i]=INT_MAX;
    cout<<fun(n-1)<<endl;
    return 0;
}


Measured memory_bytes: 5176
fun main(args: Array<String>) {
    val s = readLine()!!
    val left = s.substring(0 until s.length / 2)
    val right = s.reversed().substring(0 until s.length / 2)

    var sum = 0
    for (i in left.indices) {
        if (left[i] != right[i]) {
            sum++
        }
    }
    println(sum)
}




Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,ans,a[200005],b,c,e,f,g,cnt;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<=n;i++){
		if(a[i]<a[i+1])ans++;	
	}
	ans=min(ans,n+1-ans);
    for(int i=1;i<=n+1;i++){
		ll x=a[i-1],y=a[i];
		if(x==y)continue;
		if(x<y){
			e=y-x+b;
			f=min(b,y-x+c);
			g=min(c,y-x);
			while(e>y){
				cnt++;
				e=f;
				f=g;
				g=0;
			}
			b=e;
			c=f;
		}else{
			e=b;
			f=min(c,max(y-x+b,0LL));
			g=0;
			while(e>y){
				cnt++;
				e=f;
				f=g;
				g=0;
			}
			b=e;
			c=f;
		}
	}
	ans=min(ans,cnt);
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
X,K,D = map(int, input().split())

if (abs(X)>=K*D):
    ans = abs(abs(X)-K*D)
else:
    
    m = abs(X)//D
    remk = K - m

    now = abs(X)-m*D

    if remk%2==0:
        ans = now
    else:
        ans = abs(now-D)



    
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>


int main() {
    long long N;
    std::cin >> N;
    std::vector<long long> A(N,0);
    for(long long i=0;i<N;i++){
        std::cin >> A[i];
    }
    std::vector<bool> psb(N,true);

    std::sort(A.begin(),A.end());

    long long cnt=0;
    for(long long i=0;i<N;i++){
        if(psb[i] == true) {
            cnt++;

            for (long long j = 1; A[i] * j <= A[N-1]; j++) {
                auto itrFound_left = std::lower_bound(A.begin()+i+1, A.end(), A[i] * j) ;
                auto itr_Found_right = std::upper_bound(A.begin()+i+1, A.end(), A[i] * j) ;
                if (*itrFound_left == A[i]*j) {
                    for(long long k=itrFound_left - A.begin();k<itr_Found_right - A.begin();k++) {
                        psb[k] = false;
                    }
                }
                if(*itrFound_left == A[i]){
                    psb[i] = false;
                    cnt --;
                }
            }
        }
    }
    std::cout << cnt;
    return 0;
}



Measured memory_bytes: 4820
a = int(input())
l = [input() for i in range(a)]
d = {}
for i in range(a):
  if l[i] not in d:
    d[l[i]] = 1
  else:
    d[l[i]] += 1
max_v = max(d.values())
keys = [k for k, v in d.items() if v == max_v]
keys.sort()
for x in keys:
  print(x)

Measured memory_bytes: 35220
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s >> N;
	while (N) {
		map<string, int>m;
		m[s] = 0;
		int box = 1;
		while (1) {
			while (s.size() < N) {
				s += '0';
			}
			sort(s.begin(), s.end());
			string t = s;
			reverse(t.begin(), t.end());
			int a = 0, b = 0;
			for (int i = 0; i < N; i++) {
				a *= 10;
				b *= 10;
				a += s[i] - '0';
				b += t[i] - '0';
			}
			//cout << a << " " << b << endl;
			if (m.find(to_string(b - a)) == m.end()) {
				m[to_string(b - a)] = box;
			}
			else {
				cout << m[to_string(b - a)] << " " << b - a << " " << box - m[to_string(b - a)] << endl;
				break;
			}
			s = to_string(b - a);
			box++;
		}
		cin >> s >> N;
	}
	return 0;
}

Measured memory_bytes: 3308
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int h, n;
	cin >> h >> n;
	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum >= h) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
r,tama=[],[0]

for i in range(n):
    x,h=xh[i]
    tmpr=bisect.bisect_left(r,x)
    h-=(tama[-1]-tama[tmpr])*a
    tmp=0
    if h>0:
        tmp=math.ceil(h/a)
    tama.append(tmp)
    tama[i+1]+=tama[i]
    r.append(x+2*d)

print(tama[-1])
# print(r)


Measured memory_bytes: 121176
import sys

n = int(input())
task_dead = [[0,0]]*(n+1)

for i in range(n):
    task_dead[i+1] = list(map(int,input().split()))
task_dead = sorted(task_dead, key=lambda x:x[1])

stack = [0]*(n+1)
for i,task in enumerate(task_dead):
    if i!=0:
        stack[i] = stack[i-1]+task[0]
        if stack[i] > task[1]:
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 58272
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int ans = Math.max(a+b,Math.max(a-b,a*b));
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20948
package main

import "fmt"

func searchMin(A [10000]int, n int) int {
	ans := 10000000
	for i := 0; i < n; i++ {
		if ans > A[i] {
			ans = A[i]
		}
	}
	return ans
}

func searchMax(A [10000]int, n int) int {
	ans := -1000000
	for i := 0; i < n; i++ {
		if ans < A[i] {
			ans = A[i]
		}
	}
	return ans
}

func seekSum(A [10000]int, n int) int {
	ans := 0
	for i := 0; i < n; i++ {
		ans += A[i]
	}
	return ans
}

func main() {
	var n, min, max, sum int
	var A [10000]int

	fmt.Scan(&n)
	
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}
	
	min = searchMin(A, n)
	max = searchMax(A, n)
	sum = seekSum(A, n)

	fmt.Println(min, max, sum)

}


Measured memory_bytes: 2096
import java.util.Scanner;

public class Main {
    
    private static Scanner scan = new Scanner(System.in);
    private static final int N = Integer.parseInt(scan.next());
    private static final int A = Integer.parseInt(scan.next());
    private static final int B = Integer.parseInt(scan.next());
    private static int[] h;

    public static void main(String[] args) {

	h = new int[N];
	int hMax = 0;
	for (int i = 0; i < N; i++) {
	    h[i] = Integer.parseInt(scan.next());
	    hMax = (h[i] > hMax ? h[i] : hMax);
	}

	int maxCount = (hMax % B == 0 ? hMax/B : hMax/B+1);
	int ans = binarySearch(1, maxCount);

	System.out.println(ans);
	scan.close();
    }

    private static int binarySearch(int from, int to) {
	if(from == to) return from;

	int x = (from+to)/2;
	return enough(x) ? binarySearch(from, x) : binarySearch(x+1, to);
    }

    private static boolean enough(int T){
	long count = 0;
	for (int i = 0; i < N; i++) {
	    int rest = h[i] - T*B;
	    if(rest > 0) {
		count += (rest % (A-B) == 0 ? rest/(A-B) : rest/(A-B)+1);
	    }
	}
	return count <= T;
    }
}


Measured memory_bytes: 46964
#include<stdio.h>
#include<math.h>
int main(){
  double ox,oy,bx,by,x,y,ol,bl,l,s=0,S;
  scanf("%lf,%lf %lf,%lf",&ox,&oy,&bx,&by);
  bl=hypot(ox-bx,oy-by);
  while(scanf("%lf,%lf",&x,&y)!=EOF){
    ol=hypot(ox-x,oy-y);
    l =hypot(bx-x,by-y);
    S=(bl+ol+l)/2;
    s+=sqrt(S*(S-bl)*(S-ol)*(S-l));
    bl=ol;
    bx=x;
    by=y;
  }
  printf("%f\n",s);
  return 0;
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
const int MAX = (2e5)+1;

int n;
char s[MAX];
map<char, int> pos;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	n = strlen(s);
	for(int i = 0; i < n; i++) pos[s[i]]++;
	long long ans = 1ll * n * (n+1) / 2 + 1;
	for(auto p: pos) ans -= 1ll * p.second * (p.second+1) / 2;
	cout << ans;
}


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

int main(){
	int n,d;
	cin >> n >> d;
	int ans = (n + (2*d + 1) -1)/(2*d + 1);
	cout << ans << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    char c;
    cin >> c;
    c++;
    cout << c << endl;
}

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


Measured memory_bytes: 3636
fun main(){
    val nk = readLine()!!.split(" ").map { it.toLong() }
    val n = nk[0].toInt()
    val k = nk[1]
    val a = readLine()!!.split(" ").map { it.toInt() }
    var count:Long = 0//何回でループになるか数えてる
    val flagList = List(n){ 0 }.toMutableList()//index-1の町に何番目に行くかをまとめてる
    val countList = MutableList(n + 1){ 0 }//index+1番目にどの町にいくか
    flagList[0] = 1
    countList[0] = 1
    var amari = 0//ループに入る前に何回動いたか
    var mae = 0

    tailrec fun mytereport(y: Int) {
        count++
        if (flagList[a[y] - 1] != 0){
            mae = flagList[a[y] - 1]
            amari = mae - 1
            count -= amari
            return
        } else {
            flagList[a[y] - 1] = count.toInt() + 1
            countList[count.toInt()] = a[y]
            mytereport(a[y] - 1)
        }
    }
    mytereport(0)

    if (k > amari){
        val x = (k - amari) % count
        println(countList[amari + x.toInt()])
    } else {
        println(countList[k.toInt()])
    }

}




Measured memory_bytes: 64372
#include<stdio.h>
int main(){
	int p[8][2] = {{1,1},{4,1},{7,1},{1,3},{2,3},{3,3},{1,4},{3,2}};
	int i;
	char s[11],t;
	while(~scanf("%s",s)){
		for(i=0;i<8;i++){
			t=s[p[i][0]-1];
			if(t!='s' &&
				t == s[p[i][0]+p[i][1]-1] &&
				t == s[p[i][0]+p[i][1]*2-1]){
					printf("%c\n",t);
					break;
			}
		}
		if(i==8)puts("d");
	}
	return 0;
}

Measured memory_bytes: 0
X = int(input())
l = [(i+1)*i//2 for i in range(1,10**5)]
def bs_left(l, target): # l=sorted, target以上の値をもつ要素のうち一番左のindexを返す
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    if low == len(l):
        return -1
    return low
id = bs_left(l,X)

print(id+1)

Measured memory_bytes: 7016
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, fa[100010], dep[100010], siz[100010];
vector<int> g[100010];
void dfs(int p){
	siz[p]=1;
	for(auto t: g[p]){
		if(t==fa[p]) continue;
		fa[t]=p; dep[t]=dep[p]+1;
		dfs(t);
		siz[p]+=siz[t];
	}
}
int main(){
	scanf("%d", &n);
	int u, v;
	for(int i=1;i<n;i++){
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	int d=dep[n];
	int k=n;
	for(int i=0;i<(dep[n]-1)/2;i++)
		k=fa[k];
	if(siz[k]>=n-siz[k]) puts("Snuke");
	else puts("Fennec");
	return 0;
}

Measured memory_bytes: 11520
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main(){
  clr(d,-1);
  ll n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  ll index = n;
  ll mx = 1000000000;
  d[n] = mx+1;
  while(1){
    ll mn = index;
    per(i,max(0LL,index-m),index){
      if(s[i]=='0'){
        d[i] = mx;
        mn = min(mn,i);
      }
    }
    if(mn==0)break;
    if(index==mn){
      cout << -1 << endl;
      return 0;
    }
    index = mn;
    mx--;
  }
  rep(i,1,n+1){
    if(d[i]==-1){
      d[i] = d[i-1];
    }
  }
  vector<ll> ans;
  ll c = 1;
  rep(i,1,n+1){
    if(d[i]!=d[i-1]){
      ans.pb(c);
      c = 0;
    }
    c++;
  }
  rep(i,0,ans.sz){
    cout << ans[i];
    if(i!=ans.sz-1)cout << " ";
  }
  cout << endl;
  return 0;
}

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

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	
	if(t.length()<=s.length() || t.length()>(s.length()+1))
	cout<<"No";
	int l=0;
	for(int i=0;i<s.length();i++)
	{
	    if(s[i]!=t[i])
	    l=1;
	}
	
	if(l==1)
	cout<<"No";
	else
	cout<<"Yes";
	
	return 0;
}


Measured memory_bytes: 3620
H,W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
  S[i] = ["."] + S[i] + ["."]
S = [["."]*(W+2)] + S + [["."]*(W+2)]
ans = [[0]*W for _ in range(H)]
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == "#":
      ans[i-1][j-1] = "#"
      continue
    cnt = 0
    for k in range(i-1, i+2):
      for l in range(j-1, j+2):
        if S[k][l] == "#":
          cnt += 1
    ans[i-1][j-1] = str(cnt)
for a in ans:
  print("".join(a))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n,-1);
	int ans = 0;
	rep(i,n){
		cin >> a[i];
		a[i]--;
		if(a[a[i]] == i) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections,math
sys.setrecursionlimit(1000000)

INF = float("inf")

N,Q = map(int,sys.stdin.readline().split())
COM = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param

parents = list(range(N))
def find(x):
  while parents[x] != x:
    x = parents[x]
    parents[x] = parents[parents[x]]
  return x
def union(s,t):
  sp = find(s)
  tp = find(t)
  if sp == tp:
    pass
  elif sp < tp:
    parents[sp] = tp
  else:
    parents[tp] = sp

for com,x,y in COM:
    if com == 0:
        union(x,y)
    else:
        if find(x) == find(y):
            print(1)
        else:
            print(0)


Measured memory_bytes: 21124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i;
	int j;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='A')
		{
			break;
		}
	}
	for(j=s.size();j>0;j--)
	{
		if(s[j]=='Z')
		{
			break;
		}
	}
		cout<<j-i+1;
	return 0;
 } 

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<string>s(n);
  cin>>s;
  map<string,int> mp;
  for(auto si:s)mp[si]++;
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;


}

Measured memory_bytes: 6428
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int w = sc.nextInt();
		for(int i = 0; i < s.length(); i += w) {
			System.out.print(s.charAt(i));
		}
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int main(void){
    int n,b,f,r,v,i,g;
    int a[4][3][10]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        if(b==1){
            if(f==1)
                a[0][0][r-1]+=v;
            else if(f==2)
                a[0][1][r-1]+=v;
            else if(f==3)
                a[0][2][r-1]+=v;
        }
        else if(b==2){
            if(f==1)
                a[1][0][r-1]+=v;
            else if(f==2)
                a[1][1][r-1]+=v;
            else if(f==3)
                a[1][2][r-1]+=v;
        }
        else if(b==3){
            if(f==1)
                a[2][0][r-1]+=v;
            else if(f==2)
                a[2][1][r-1]+=v;
            else if(f==3)
                a[2][2][r-1]+=v;
        }
        else if(b==4){
            if(f==1)
                a[3][0][r-1]+=v;
            else if(f==2)
                a[3][1][r-1]+=v;
            else if(f==3)
                a[3][2][r-1]+=v;
        }
    }
    for(int j=0;j<4;j++){
        for(i=0;i<3;i++){
            for(g=0;g<10;g++){
                printf(" %d",a[j][i][g]);
            }
            printf("\n");
        }
        if(j<3)
        printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 1804
#include<cstdio>
#include<algorithm>
int par[100000]={};
int rank[100000]={};
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rank[i]=0;
	}
}
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(rank[x]<rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rank[x]==rank[y])rank[x]++;
	}
}
int same(int x,int y){
	if(find(x)==find(y))return 1;
	else return 0;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	init(n);
	long long int a[n]={};
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	int b[n]={};
	int x,y;
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		unite(x,y);
	}
	int k[n]={};
	for(int i=0;i<n;i++){
		k[find(i)]++;
	}
	int kk=0;
	for(int i=0;i<n;i++){
		if(k[i]!=0){
			k[i]=kk;
			kk++;
		}
	}
	for(int i=0;i<n;i++){
		b[i]=k[find(i)];
	}
	long long int ans=0;
	long long int p[n-m];
	long long int q[n-m];
	for(int i=0;i<n-m;i++){
		p[i]=1000000000000000;
	}
	for(int i=0;i<n;i++){
		if(p[b[i]]>a[i]){
			p[b[i]]=a[i];
			q[b[i]]=i;
		}
	}
	for(int i=0;i<n-m;i++){
		ans+=a[q[i]];
		a[q[i]]=-1;
	}
	std::sort(a,a+n);
	int e=-1;
	for(int i=0;i<n;i++){
		if(e==-1 && a[i]>0){
			e=0;
			if(i>m+2){
				ans=-1;
				break;
			}
		}
		if(e>=0){
			if(e>=n-m-2)break;
			ans+=a[i];
			e++;
		}
	}
	if(e==-1)ans=-1;
	if(n-m==1)printf("0\n");
	else if(ans!=-1)printf("%lld\n",ans);
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 4096
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;

	if (N % 2) {
		rep1(i, M) {
			cosp(i);
			co(N - i);
		}


	}
	else {
		int n = N / 2;
		rep1(i, (M + 1) / 2) {
			cosp(i);
			co(N - i + 1);



		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			cosp(i);
			co(N - i);
		}
	}



	Would you please return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
using namespace std;
#define CODE 'a'-'A';
int main() {
	string code;
	getline(cin, code);
	for (int i = 0; i < (int)code.size(); ++i) {
		if (code[i] >= 'a'&&code[i] <= 'z') {
			code[i] -= CODE;
		}
		else if (code[i] >= 'A'&&code[i] <= 'Z') {
			code[i] += CODE;
		}
	}
	cout << code << endl;
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
using namespace std;
const int mod=1e9+7;
int arr[21][21];
ll dp[21][(ll)1<<21];
int n;
ll add_self(ll &p, ll q)
{
    p+=q;
    if(p>=mod) p-=mod;
}
ll DP(int bit)
{
    int pos=__builtin_popcount(bit);
    if(pos>=n) return 1;
    if(dp[pos][bit]!=-1) return dp[pos][bit];
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        if(arr[pos][i] && !(bit&(1<<i)))
        {
            ans=(ans+DP(bit|(1<<i)))%mod;
        }

    }
    return dp[pos][bit]=ans;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            scanf("%d", &arr[i][j]);
    }
    ll ans=DP(0);


    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 344448
//65 - A 90 - Z 97 - a 122 - z
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, a;
    cin >> n >> a;
    n = n * n;
    cout << n - a;


    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
void Add(T &a, const T &b) {
    int val = ((a % MOD) + (b % MOD)) % MOD;
    if (val < 0) {
        val += MOD;
    }
    a = val;
}

template <typename Monoid>
struct SegmentTree {
private:
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func UPDATE, OPERATION;
    const Monoid E;
    int SIZE = 1;
    vector<Monoid> node;

public:
    // SegmentTree(int n, const Func update, const Monoid &e)
    //     : UPDATE(update), E(e) {
    //     OPERATION = UPDATE;
    //     while (SIZE < n) SIZE *= 2;
    //     node.assign(SIZE * 2, E);
    // }

    SegmentTree(int n, const Func operation, const Func update, const Monoid &e) 
        : OPERATION(operation), UPDATE(update), E(e) {
            while (SIZE < n) SIZE *= 2;
            node.assign(SIZE * 2, E);
        }

    void set(int a, const Monoid &val) { node[a + SIZE] = val; }

    void build() {
        for (int k = SIZE - 1; k > 0; k--) {
            node[k] = OPERATION(node[2 * k], node[k * 2 + 1]);
        }
    }

    void update(int a, const Monoid &val) {
        int k = a + SIZE;
        node[k] = UPDATE(node[k], val);
        while (k >>= 1) node[k] = OPERATION(node[2 * k], node[2 * k + 1]);
    }

    Monoid query(int a, int b) {
        Monoid leftVal = E, rightVal = E;
        for (int left = a + SIZE, right = b + SIZE; left < right; left >>= 1, right >>= 1) {
            if (left & 1) leftVal = OPERATION(leftVal, node[left]), left += 1;
            if (right & 1) right -= 1, rightVal = OPERATION(rightVal, node[right]);
        }
        return OPERATION(leftVal, rightVal);
    }

    inline Monoid operator[](int a) { return node[a + SIZE]; }
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree<long long> seg(n, 
        [](long long a, long long b) { return min(a, b); },
        [](long long a, long long b) { return b; }, 
        (1ll << 31) - 1);

    REP(i, q) {
        int com, x;
        cin >> com >> x;
        if (com == 0) {
            long long y;
            cin >> y;
            seg.update(x, y);

        } else {
            int y;
            cin >> y;
            cout << seg.query(x, y + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4856
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int N, L;
  scanf("%d %d", &N, &L);
  std::vector<std::string> str_set(N);

  for (int i = 0; i < N; ++i) {
    std::cin >> str_set[i];
  }
  std::sort(str_set.begin(), str_set.end());
  for (const std::string &str : str_set) {
    std::cout << str;
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = input[0]
  const sum = N.split('').map(x => parseInt(x)).reduce((a, b) => a + b)
  console.log(N % sum === 0 ? 'Yes' : 'No')
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30472
#include <bits/stdc++.h>
using namespace std;
int main() {
  
    string weatherforecast, weatherprediction;
    cin >> weatherforecast >> weatherprediction;
    int ans = 0;

    for(int i = 0; i<3; i++){
        if(weatherforecast[i] == weatherprediction[i]){
            ans+=1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  puts ((InputLine.to_i >= 30) ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){

int x,a,b,c,d;

scanf("%d %d %d", &x,&a,&b);

c = x - a;

d = c % b;

printf("%d",d);

return 0;

}

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


int main(){
  int n,q;
  int ans = 0;

  cin >> n; vector<int> S(n);
  for(int i=0;i<n;++i){
    cin >> S.at(i);
  }
  cin >> q; vector<int> T(q);
  for(int i=0;i<q;++i){
    cin >> T.at(i);
  }

  for(int i=0;i<q;++i){
    for(int j=0;j<n;++j){
      if(T.at(i) == S.at(j)){
        ans += 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<ctype.h>
int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  char str[n+1];
  scanf("%s",str);
  str[k-1]=tolower(str[k-1]);
  printf("%s\n",str);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n,h;
    int count=0, M = -200000;
    vector<int> H;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h;
        H.push_back(h);       
    }
  	H.push_back(1000000001);
    for(int i=0;i<n;i++){
        if(H[i]>=H[i+1]){
            count++;
        }else{
            if(M<count){
                M=count;
            }
           count=0;
        }
      //cout << "c" << count <<"M" << M << endl;
    }
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int c=0,n,a[114];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<n-1;i++)if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1]))c++;
	cout<<c<<endl;
	return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();

    List<Character> list = new ArrayList<>();
    List<Integer> result = new ArrayList<>();


    for (int i = 0; i < S.length(); i++) {
      switch (S.charAt(i)) {
        case 'A':
        case 'T':
        case 'C':
        case 'G':
          list.add(S.charAt(i));
          break;
        default:
          if (!list.isEmpty()) {
            result.add(list.size());
            list = new ArrayList<>();
          }
          break;
      }
    }
    if (!list.isEmpty()) {
      result.add(list.size());
    }
    if (result.isEmpty()) {
      System.out.println(0);
    } else {
      System.out.println(result.stream().max((a, b) -> a.compareTo(b)).get());
    }
  }
}


Measured memory_bytes: 28624
def main():
    x, n = map(int, input().split(" "))
    p =[]
    dif = 1e2
    ans = 0
    l_a = [i for i in range(102)]
    if n != 0:
        p = list(map(int, input().split(" ")))
    for ele in l_a[::-1]:
        if abs(x - ele) <= dif and ele not in p:
            ans = ele
            dif = abs(x - ele)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
import sys

A = 10000
B = 5000
C = 1000

input = input()
inputs = input.split(' ')
n = int(inputs[0])
y = int(inputs[1])

for i in range(n+1):
    for j in range(n+1):
        if (A*i + B*j + C*(n-i-j) == y) & (n-i-j >= 0):
            print(str(i) + ' ' + str(j) + ' ' + str(n-i-j))
            sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3064