akhauriyash/Code-Regression huggingface dataset:
number   = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]
name_tag = []

while number > 0:
  number, a = divmod(number-1, 26)
  name_tag.append(a)
  
reverse_name_tag = reversed(name_tag)
for i in reverse_name_tag:
  print(alphabet[i], end="")


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
multimap<int,string> invert(map<string, int> & mymap)
{
	multimap<int, string> multiMap;

	map<string, int> :: iterator it;
	for (it=mymap.begin(); it!=mymap.end(); it++)
	{
		multiMap.insert(make_pair(it->second, it->first));
	}

	return multiMap;
}

int main()
{
    int a,b,c,n,i,j,k,f;
    vector<int>v;
   string s;
   map<string,int>mymap;
   cin>>n;
   getchar();
   while(n--)
   {
       cin>>s;
       mymap[s]++;
   }
//   map<string,int>::iterator itr;
//for(itr=mymap.begin();itr!=mymap.end();itr++)
//   {
//       cout<<itr->first<<endl;
//   }
   multimap<int,string>newmap=invert(mymap);
   multimap<int,string>::iterator it;
   for(it=newmap.begin();it!=newmap.end();it++)
   {
       b=it->first;
   }
//   cout<<b<<endl;
   for(it=newmap.begin();it!=newmap.end();it++)
   {
          if(it->first==b)
          {
              cout<<it->second<<endl;
          }
   }

    return 0;
}


Measured memory_bytes: 37760
s = gets.chomp!.split(" ")
s = s.map{|item| item=item.to_i}
trees = Array.new(s[0],0)
trees = trees.map{|item| item = gets.chomp!.to_i}
trees = trees.sort
answer = trees[s[0]-1]

for i in s[1]-1..s[0]-1
	if trees[i]-trees[i-s[1]+1]<answer then answer = trees[i]-trees[i-s[1]+1] end
end

puts answer

Measured memory_bytes: 5240
#include <stdio.h>

int main(void)
{

  int w,h,x,y,r;

  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

  if((x-r)>=0&& (y-r)>=0 && y<=(h-r) && x<=(w-r))
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }

  return 0;

}

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



int main(void){
int a,b,c;
cin >>a>>b>>c;
int d,e,f,g,h,i;
d = abs(b-a)+abs(c-b);
e = abs(c-a)+abs(b-c);
f = abs(a-b)+abs(c-a);
g = abs(c-b)+abs(a-c);
h = abs(a-c)+abs(b-c);
i = abs(b-c)+abs(a-b);
cout<<min({d,e,f,g,h,i}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  ll ans = INFL;
  rep(i,101){
    ll tmp = 0;
    rep(j,n){
      tmp += (a[j]-i)*(a[j]-i);
    }
    chmin(ans,tmp);
  }
  print(ans);
  return 0; 
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll a, b, c; cin >> a >> b >> c;
	cout << b * a / 2 << endl;
}

Measured memory_bytes: 256
import random
import time
import copy
start = time.time()
D = int(input())
s = [[0 for j in range(26)] for i in range(D)]
c = list(map(int, input().split(" ")))
result = []
total = -10000000
for i in range(D):
    a = list(map(int, input().split(" ")))
    for j, k in enumerate(a):
        s[i][j] = int(k)
while(1):
    result_tmp = []
    total_tmp=0
    last = [0 for i in range(26)]
    for i in range(D):
        score = [0 for i in range(26)]

        for j in range(26):
            score[j] = s[i][j]
            for k in range(26):
                if j != k:
                    score[j] -= (i + 1 - last[k]) * c[k]
        score_sort = sorted(score, reverse=True)
        score_max = score_sort[0]

        tmp = []
        for j in range(26):
            if score_max >= 0 and score_max*0.95 <= score[j]:
                tmp.append(j)
            if score_max < 0 and score_max*1.05 <= score[j]:
                tmp.append(j)

        score_max = random.choice(tmp)

        result_tmp.append(score_max)
        last[score_max] = i + 1
        total_tmp += score[score_max]
    if total < total_tmp:
        total=total_tmp
        result = result_tmp.copy()
    end = time.time()
    if end - start > 1.9:
        break
for i in range(D):
    print(result[i]+1)


Measured memory_bytes: 9868
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> arr(n);
    ll sum=0;
    rep (i,0,n)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    ll a1=sum/n;
    ll a2=a1+1;
    ll ans1=0,ans2=0;
    rep (i,0,n)
    {
        ans1+=((arr[i]-a1)*(arr[i]-a1));
        ans2+=((arr[i]-a2)*(arr[i]-a2));
    }
    cout<<min(ans1,ans2)<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll func(ll i){
  if(i%4==0) return i;
  else if(i%4==1) return 1;
  else if(i%4==2) return 1^i;
  else return 0;
}


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

  ll A,B; cin>>A>>B;
  ll ans = func(A-1) ^ func(B);

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


Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

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


    int n,m,l;
    
    cin >> n >> m >> l;
    
    int a[n][m];
    int b[m][l];
    long long int c[n][l];

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    
    for(int j=0; j<m; j++){
        for(int  k=0; k<l; k++){
            cin >> b[j][k];
        }
    }

    
    for(int k=0; k<l; k++){
        for(int i=0; i<n; i++){
            c[i][k] = 0;
            for(int j=0; j<m; j++){
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int k=0; k<l-1; k++){
            cout << c[i][k] << " ";
        }
        cout << c[i][l-1];
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
    ll n,m,a,b;
    cin>>n;
    string s;
    vector<string> v,v1;
    v.push_back(" ");
    REP(i,1,n)
    {
        cin>>s;
        v.push_back(s);        
    }
    v1=v;
    sort(v1.begin(),v1.end());
    REP(i,1,n)
    {
        REP(j,i+1,n)
        {
            if(v1[i]==v1[j])
            {
                cout<<"No";
                return 0;
            }
        }
    }
    REP(i,2,n)
    {
        if(v[i-1].back()!=v[i].front())  
        {
            cout<<"No";
            return 0;
        }      
    }
    cout<<"Yes";
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if(a+b >= 10) cout << "error" << endl;
  else cout << a+b << endl;
  return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    X=I()
    
    #nまでの素数を列挙(n loglogn)
    n = 2*(10**6)

    #is_prime[i]にはi+1が素数か否かを示すboolが入る，[0]に1の素数判定がある．
    is_prime = [True]*(n+1)
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i

    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    
    for i in table:
        if i>=X:
            print(i)
            exit()

main()


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 2 && b == 2)cout << "Yes" << endl;
    else if(a == 4 || a == 6 || a == 9 || a == 11){
        if(b == 4 || b == 6 || b == 9 || b == 11){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else if(a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12){
        if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}


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

const int64_t INF = (int64_t)1e18 + 1;

int main()
{
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

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

    int64_t l = -INF, r = INF;
    while (l + 1 < r)
    {
        int64_t x = (l + r) / 2;

        int64_t count = 0;
        for (int i = 0; i < N; i++)
        {
            if (A.at(i) < 0)
            {
                int l = -1, r = N;
                while (l + 1 < r)
                {
                    int c = (l + r) / 2;
                    if (A.at(i) * A.at(c) < x)
                        r = c;
                    else
                        l = c;
                }
                count += N - r;
            }
            else
            {
                int l = -1, r = N;
                while (l + 1 < r)
                {
                    int c = (l + r) / 2;
                    if (A.at(i) * A.at(c) < x)
                        l = c;
                    else
                        r = c;
                }
                count += l + 1;
            }
            if (A.at(i) * A.at(i) < x)
                count--;
        }
        count /= 2;

        if (count < K)
            l = x;
        else
            r = x;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
  int n,x,sum,cc=-1,aa=-1,bb=-1;
  cin>>n>>x;
  for(int i=0;i<=n;i++){
    for(int j=0;i+j<=n;j++){
    sum=i*10000+j*5000+(n-i-j)*1000;
    if(sum==x){
      aa=i;
      bb=j;
      cc=n-i-j;
    }
    }
  }
  cout<<aa<<" "<<bb<<" "<<cc<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
int CalcSummation(int n){
  if(n == 1 || n == 0){
    return 1;
  }else{
    return n + CalcSummation(n-1);
  }
}

int main() {
  INIT;
  
  int n;
  cin >> n;
  cout << CalcSummation(n) << endl;
  
  return 0;
}

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

int main () {
	int n, m, temp, N = 1000000007;
	cin >> n >> m;
	int a[100001] = {0};
	for (int i = 1; i <= m; i++) {cin >> temp; a[temp] = -1;}
	a[1] = a[1] == -1 ? 0 : 1;
	a[2] = a[2] == -1 ? 0 : a[1] == 0 ? 1 : 2;
	for (int i = 3; i <= n; i++) {
		if (a[i] == -1) a[i] = 0;
		else a[i] = (a[i-1] % N + a[i-2] % N) % N;
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;


ll max_happiness(vector<vector<int>> &mat)
{
    int rows = mat.size();
    int cols = mat[0].size();
    vector<vector<ll>> dp(rows, vector<ll>(cols));
    for(int i=0; i<rows; i++){
        dp[i][cols-1] = mat[i][cols-1];
    }
    for(int i=cols-2; i>=0; i--){
        dp[0][i] = max(dp[1][i+1] + mat[0][i], dp[2][i+1] + mat[0][i]);
        dp[1][i] = max(dp[0][i+1] + mat[1][i], dp[2][i+1] + mat[1][i]);
        dp[2][i] = max(dp[1][i+1] + mat[2][i], dp[0][i+1] + mat[2][i]);
    }

    return max({dp[0][0], dp[1][0], dp[2][0]});
}


int main()
{
    fast
    int n;
    cin >> n;
    vector<vector<int>> mat(3, vector<int>(n));
    for(int i=0; i<n; i++) {cin >> mat[0][i]; cin >> mat[1][i]; cin >> mat[2][i];}
    cout << max_happiness(mat) << '\n';
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

vector<int> b(2 * 200005);
vector<vector<int>> G(2 * 200005);

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint p(n);
    REP(i, n) { cin >> p[i]; }
    int count = 0;
    REP(i,n){
        if (p[i] != i+1){
            count++;
        }
    }
    if (count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	string o, e; cin >> o >> e;
	for (int i = 0; i < o.length(); ++i)
	{
		if (i >= len(e)) cout << o[i];
		else cout << o[i] << e[i];
	}
}

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


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

int main()
{
    long n, k; cin>>n>>k;
    if (k==0) {
        cout<<n*n<<endl;
        return 0;
    }
    long res=0;
    for(long d=k+1; d<=n; ++d) {
        auto x=(n+d-1)/d;
        res+=x*(d-k);
        auto L=(x-1)*d+k;
        auto R=L+d-k-1;
        if (L>n) res-=R-L+1;
        else if (R>n) res-=R-n;
    }
    cout<<res<<endl;
}


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

uint64_t limit;
uint64_t ans;

enum {three = 1, five = 2, seven = 4};

void dfs(uint64_t n, uint64_t m)
{
  if (n > limit) return;
  if (m == (three | five | seven)) ans++;
  dfs(n * 10 + 3, m | three);
  dfs(n * 10 + 5, m | five);
  dfs(n * 10 + 7, m | seven);
}

int main()
{
  cin >> limit;
  dfs(0, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
fn main() {
    let v = read_vec::<usize>();
    let left = v[0] + v[1];
    let right = v[2] + v[3];

    if left > right {
        println!("Left");
    } else if left < right {
        println!("Right");
    } else {
        println!("Balanced");
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000; //10^9

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

    vector<vector<int> > A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        for (int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int ans = 0;
    int temp = 0;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < M; j++){
            temp += A[i][j] * B[j];
        }
        if(temp + C > 0){
            ans++;
        }
        temp = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn calc_sum(n: u32) -> u32{
  let mut n = n;
  let mut sum = 0;
  sum += n / 10000;
  n -= n / 10000 * 10000;
  sum += n / 1000;
  n -= n / 1000 * 1000;
  sum += n / 100;
  n -= n / 100 * 100;
  sum += n / 10;
  n -= n / 10 * 10;
  sum + n
}

fn main() {
  let n: u32 = read();
  let a: u32 = read();
  let b: u32 = read();
  let mut ret = 0;
  for i in 1..n+1 {
    let sum = calc_sum(i);
    if sum >= a && sum <= b {
      ret += i
    }
 }
 println!("{}", ret);
}


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

int main(){
    int64_t A,B,N;
    cin >> A >> B >> N;
    if (N >= B) N = B - 1;
    int64_t C = (A * N) / B,D = A * (N / B);
    cout << C - D << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long li;
typedef int in;
typedef double dub;
#define fst first
#define scnd second
#define pub push_back
#define pob pop_back
#define mkp make_pair
#define lb lower_bound
#define ub upper_bound
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long h,n,a[100005],i,sum;
    while(cin>>h>>n)
    {
        sum=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            sum=sum+a[i];
        }
        if(sum>=h)
        {
            cout<<"Yes"<<endl;
        }
        else
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 1024
N, D = map(int,input().split())
X, Y = [],[]
for i in range(N):
  x,y = map(int,input().split())
  X.append(x)
  Y.append(y)
assert len(X) == N

print(len([(x,y) for x,y in zip(X,Y) if x ** 2 + y ** 2 <= D ** 2]))

Measured memory_bytes: 113916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define MAX 210000
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll g=__gcd(n,m);
    ll l=n*m/g;
    ll N=n/g;
    ll M=m/g;

    for(int i=0;i<g;i++){
    //    cout<<s[i*N]<<" "<<t[i*M]<<endl;
        if(s[i*N]!=t[i*M]){
            cout<<-1;
            return 0;
        }
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 640
N = readline.to_i
A = readline.split.map(&:to_i)

count_4 = A.reject{|x|x%4!=0}
count_2 = (A-count_4).reject{|x|x%2!=0}
others_count = (A-count_4-count_2)

#p count_2
#p count_4
#p others_count

if( (count_2.size > 0 && (count_4.size>=others_count.size)) || (count_2.empty? && (count_4.size>=others_count.size-1)) )
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 17284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}


class data{
public:
	int l, r, d;
};

vector<int> x;
vector<data> d;
vector<queue<data> > que;
set<int> done;
queue<int> q;
int main(){
	int n, m;
	cin >> n >> m;
	x.resize(n); for(int i=0; i<n; i++) x[i]=int_inf; x[0]=0;
	d.resize(m);
	for(int i=0; i<m; i++) cin >> d[i].l>>d[i].r>>d[i].d;
	for(int i=0; i<m; i++){ d[i].l-=1; d[i].r-=1; done.insert(d[i].l); done.insert(d[i].r);}
	que.resize(n);
	
	for(int i=0; i<m; i++){ que[d[i].l].push(d[i]); que[d[i].r].push(d[i]); }
	
	while(1){
		if(done.size()==0) break;
		int f = *done.begin();
		q.push(f);
		x[f]=0;
		while(q.size()){
			int first=q.front();
			while(que[first].size()){
				data d2;
				d2=que[first].front();
				if(d2.l==first){
					q.push(d2.r);
					if(x[d2.r]==int_inf || x[d2.r]==x[d2.l]+d2.d){
						x[d2.r]=x[d2.l]+d2.d;
					}
					else {cout<<"No"<<endl; return 0; }
					que[first].pop();
				}
				else if(d2.r==first){
					q.push(d2.l);
					if(x[d2.l]==int_inf || x[d2.l]==x[d2.r]-d2.d){
						x[d2.l]=x[d2.r]-d2.d;
					}
					else {cout<<"No"<<endl; return 0; }
					que[first].pop();
				}
			}
			done.erase(q.front());
			q.pop();
		}
	}
	
	cout<<"Yes"<<endl;
	return 0;
}
		


Measured memory_bytes: 74496
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    rep(i,N)cin >> a[i] >> b[i] >> c[i];
    int tmp;
    vector<vector<int>> dp(N+1,vector<int> (3,0));
    rep(i,N) rep(j,3) rep(k,3){
        if(j == k)continue;
        if(j == 0)tmp = a[i];
        if(j == 1)tmp = b[i];
        if(j == 2)tmp = c[i];
        chmax(dp[i+1][j],dp[i][k] + tmp);
    }
    int ans = dp[N][0];
    ans = max(ans,dp[N][1]);
    ans = max(ans,dp[N][2]);
    cout << ans << endl;
}



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

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int prev = v[0];
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (prev == v[i]) {
      ans++;
      if (i < n-1) prev = v[i+1] + 1;
    } else prev = v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,k;
bool d[10];

int main(){
	cin>>n>>k;
	REP(i,k){
		int s;
		cin>>s;
		d[s]=1;
	}
	int i=n;
	for(;i<=100000;i++){
		string s=to_string(i);
		for(int j=0;j<s.size();j++){
			if(d[s[j]-'0']){
				break;
			}
			if(j==s.size()-1)
				goto label;
		}
	}
	label: cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=3000000,ans=mzint;
  while(M--){
    vector<pair<int,int>> AAA={make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26)};
    vector<int> BBB={t[AAA[0].first],t[AAA[1].first]};
    int ans2=ans;
    for(int aaa=0;aaa<2;aaa++){
    int d=AAA[aaa].first,q=AAA[aaa].second;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    t[d]=q+1;
    }
    if(ans2>ans){
      ans=ans2;
      t[AAA[0].first]=BBB[0];
      t[AAA[1].first]=BBB[1];
    }
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3628
// F - Simplified Reversi
#include <bits/stdc++.h>

using namespace std;

void rmq_update(vector<int> &t, int i, int val)
{
	for (t[i += t.size() / 2] = val; i /= 2; )
		t[i] = min(t[i * 2], t[i * 2 + 1]);
}

int rmq_query(const vector<int> &t, int l, int r, int def = INT_MAX)
{
	int n = t.size() / 2, a = def, b = def;
	for (int i = l + n, j = r + n; i < j; i /= 2, j /= 2) {
		if (i % 2) a = min(a, t[i++]);
		if (j % 2) b = min(b, t[--j]);
	}
	return min(a, b);
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, q;
	cin >> n >> q;
	long long ans = (long long) (n - 2) * (n - 2);
	vector<int> tx(n * 2, n - 2), ty(n * 2, n - 2);
	for (int qi = 0; qi < q; qi++) {
		int c, x;
		cin >> c >> x;
		x -= 2;
		if (c == 1) {
			int v = rmq_query(tx, x, n);
			ans -= v;
			if (rmq_query(ty, v, v + 1) > x) rmq_update(ty, v, x);
		} else if (c == 2) {
			int v = rmq_query(ty, x, n);
			ans -= v;
			if (rmq_query(tx, v, v + 1) > x) rmq_update(tx, v, x);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6372
import sys
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

for i in range(X+1,Y+1):
  if max(x)<i and min(y)>=i:
    print('No War')
    sys.exit()

print('War')

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];

    sort(H.begin(), H.end(), greater<int>());

    long long res = 0;
    for (int i = K; i < N; i++) res += H[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<map>
    #include<cmath>
    #include<cstdlib>
    using namespace std;
    const int M=200005;
long long int n,m,flag,sum;
int a[M];
int main()
{
   cin>>n>>m;
   cin>>a[1];
   sum=0;
   for(int i=2;i<=n;i++)
   {
        cin>>a[i];
        if(a[i]-a[i-1]>=m)
            sum+=m;
        else if(a[i]-a[i-1]<m)
            sum+=a[i]-a[i-1];
   }
   sum+=m;
   cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n - 1);
  rep(i, n - 1) cin >> b[i];
  rep(i, n) {
    if (i == 0)
      a[i] = b[i];
    else if (i == n - 1)
      a[i] = b[i - 1];
    else
      a[i] = min(b[i - 1], b[i]);
  }
  ll ans = 0;
  rep(i, n) {
    ans += a[i];
    // cerr << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define fastIO_ ios_base::sync_with_stdio(false); cin.tie(false); cout.tie(false);
int main()
{
    int n, m, cntE = 0, cntO = 0;
    cin>>n>>m;
    for (int i=2; i<=n*2-2; i+=2)
        for (int j=i+2; j<=n*2; j+=2)
            cntE += 1;
    for (int i=1; i <= m*2-2; i+=2)
        for (int j=i+2; j<=m*2; j+=2)
            cntO += 1;
    cout<<cntE+cntO<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int lim = 50;
int n, a[55], b[55]; long long c[55]; bool dp[55][55][55];
int main() {
	for (int i = 0; i <= lim; i++) dp[0][i][i] = true;
	for (int i = 1; i <= lim; i++) {
		for (int j = 0; j <= lim; j++) {
			for (int k = 0; k <= j; k++) {
				dp[i][j][k] = dp[i - 1][j][k] || dp[i - 1][j % i][k];
			}
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], c[i] = 1LL << a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	bool feasible = true;
	for (int i = 0; i < n; i++) feasible = feasible && dp[lim][a[i]][b[i]];
	if (!feasible) cout << "-1\n";
	else {
		long long ret = 0;
		for (int i = lim; i >= 1; i--) {
			bool change = false;
			for (int j = 0; j < n; j++) {
				bool unchange = false;
				for (int k = 0; k <= lim; k++) {
					if (dp[i - 1][k][b[j]] && ((c[j] >> k) & 1)) {
						unchange = true;
					}
				}
				if (!unchange) change = true;
			}
			if (change) {
				for (int j = 0; j < n; j++) {
					for (int k = i; k <= lim; k++) {
						if ((c[j] >> k) & 1) c[j] |= 1LL << (k % i);
					}
				}
				ret |= 1LL << i;
			}
		}
		cout << ret << "\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> c(20, 0);
    for(ll i = 0; i < n; i++){
        ll d = a[i]/400;
        c[d]++;
    }
    ll count = 0, next=0;
    for(ll i = 0; i <= 15; i++){
        if(c[i]>0 && i<=7) count++;
        if(c[i]>0 && i>=8) next+=c[i];
    }
    ll MIN = count;
    ll MAX = count+next;
    //if(MAX > 8) MAX = 8;
    if(MIN == 0 && next > 0) MIN = 1;
    cout << MIN << " " << MAX << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>


using namespace std;


bool solve(int n, int m){
	vector<pair<int,int> > d(n);
	for(int i=0;i<n;i++){
		cin>> d[i].second>> d[i].first;
	}
	
	sort(d.rbegin(), d.rend());
	int ans = 0;
	for(int i=0;i<d.size();i++){
		int a = min(d[i].second, m);
		d[i].second -= a;
		m -= a;
		ans += d[i].first * d[i].second;
	}
	
	cout<< ans<< endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n, m;
	while(cin>>n>>m, !(n==0 && m==0)){
		solve(n,m);
	}
	return 0;
}

 

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=100000+9;

int main(){
    GO();

    int T;
  //  cin>>T;
    T=1;
    while(T--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;

        ll ans=max(c*b,max(a*d,max(a*c,b*d)));
        if((0>=a&&0<=b)||(0>=c&&0<=d)) ans=max(ans,0ll);
        cout<<ans<<"\n";

    }

}





















































































































































































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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,A,B,C;
    string S;
    cin >> A>>B>>C>>N;

    if(N<=A){
        cout << N << endl;
    }
    else if(N<=(A+B)){
        cout << A << endl;
    }
    else{
        cout << A - (N - (A + B)) << endl;
    }
}


Measured memory_bytes: 3648
n, m = map(int,input().split())
students = []
for _ in range(n):
    students.append(list(map(int,input().split())))
points = []
for _ in range(m):
    points.append(list(map(int,input().split())))

anslst = []
for i in range(n):
    distance = 10 ** 9
    num = -1
    for j in range(m):
        tmp = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
        if tmp < distance:
            distance = tmp
            num = j + 1
    anslst.append(num)

for p in anslst:
    print(p)

Measured memory_bytes: 9144
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, T = map(int, readline().split())
    A = list(map(int, readline().split()))

    L = []
    Max = 0
    Min = A[0]

    for i in range(1, N):
        if A[i] < Min:
            Min = A[i]
        if A[i] - Min > Max:
            Max = A[i] - Min
        L.append(A[i] - Min)
    print(L.count(Max))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18920
#include <bits/stdc++.h>
using namespace std;
int ctoi(char);
#define MAX_N 200001
#define l long
#define ll long long
#define f(a, b) for (ll i = a; i < b; i++)
#define f0(a) for (ll i=0;i<a;i++)
#define input(d) cin >> d;
#define inputs(n,d) for(int i=0;i<n;i++){cin >> d[i];}
#define output(d) cout << d << endl;
#define outputs(n,d) for(int i=0;i<n;i++){cout << d[i] << endl;}

int main(void) {
	//ll n;
	//l n;
	//ll n,x,t;
	char s[MAX_N];
	ll ans=0;
	input(s);
	//vector<int> d();
	//vector<l> d();
	//vector<ll> d();

	f0(MAX_N){
		int temp=ctoi(s[i]);
		if(temp==-1){
			break;
		}
		ans+=(ll)temp;
	}
	if((ans%9)==0){
		output("Yes")
	}else{
		output("No")
	}
	//output(ans);

	return 0;
}

int ctoi(char c){
	switch(c){
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default : return -1;
	}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
typedef long long ll;
typedef long double ld;

int main()
{
  ld W,H,x,y;cin>>W>>H>>x>>y;
  
  ld S = W*H;
  S /= 2.0000000000000;
  int count=0;
  if (x==W/2) count++;
  if (y==H/2) count++;
  
  cout<<fixed;
  cout<<setprecision(10)<<S<<" ";
  if (count==2)cout<<1<<endl;
  else cout<<0<<endl;
}  

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef ll T;
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lld%lld",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
};
typedef vector<P> polygon;
bool isconvex(polygon A){
    bool ok=1;int n=sz(A);
    rep(i,0,2) A.pb(A[i]);
    rep(i,0,n) ok&=((A[i+1]-A[i])^(A[i+2]-A[i]))>=0;
    return ok;
}

int main(){
    int n;scanf("%d",&n);
    polygon A;
    rep(i,0,n){
        P p;p.read();
        A.pb(p);
    }
    printf("%d\n",isconvex(A));
    return 0;
}

Measured memory_bytes: 3220
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    ll x;
    cin>>x;
    ll y=(x/500)*1000;
    x%=500;
    y+=(x/5)*5;
    cout<<y<<nl;
    return 0;
}


Measured memory_bytes: 256
int main (void)
{
	int H,W,h,w;
  	scanf("%d",&H);	printf(" ");	scanf("%d",&W);
  	puts("");
  	scanf("%d",&h);	printf(" ");	scanf("%d",&w);
  	printf("%d",(H-h) * (W-w));
  	return 0;
}
  	

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
    int ans=0;
    char s[220],s1[220][110],s2[220][110] ;
    scanf("%s",s) ;
    for (int i=strlen(s)-1; i>0; i--){
        if (i%2==0){
            for (int j=0; j<i/2; j++) {
                s1[i][j]=s[j] ;
            }
            
            for (int j=0; j<i/2; j++) {
                s2[i][j]=s[i/2+j];
            }
            if (strcmp(s1[i],s2[i])==0 && ans<i) {
                ans=i ;
            }
        }
    }
    printf ("%d\n",ans) ;
    return 0 ;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String string = in.readLine();
        ArrayList<Character> chars = new ArrayList<>();
        int amount = 0;
        for (int i = 0; i < string.length(); i++) {
            if (!chars.contains(string.charAt(i))) {
                chars.add(string.charAt(i));
                amount++;
            }
        }
        if (amount == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}
/*


 */

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

std::string s;
int all_num_w, all_num_e;
int n;
int num_w, num_e;
std::vector<std::pair<int, int>> vec;
std::vector<int> vec2;
int main() {
    std::cin >> n;
    std::cin >> s;
    vec2.assign(n, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            all_num_w++;
        }
        else {
            all_num_e++;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (s[i] == 'E')
                num_e = all_num_e-1;
            else
                num_e = all_num_e;
            vec.push_back(std::make_pair(0, num_e));
            continue;
        }
        if (s[i-1] == 'W') {
            num_w = vec[i-1].first + 1;
        }
        else {
            num_w = vec[i-1].first;
        }
        if (s[i] == 'E') {
            num_e = vec[i-1].second - 1;
        }
        else {
            num_e = vec[i-1].second;
        }
        vec.push_back(std::make_pair(num_w, num_e));
    }
    auto b = *std::min_element(vec.begin(), vec.end(), [](std::pair<int, int> a, decltype(a) b) {
            return ((a.first + a.second) < (b.first + b.second));
            });
    std::cout << (b.first + b.second) << std::endl;
}


Measured memory_bytes: 7928
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;

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

int main() {

    int N,M;
    cin >> N >> M;
    int outN = 0;
    if(N==1 || N==0) outN = 0;
    else outN = N*(N-1)/2;
    int outM = 0;
    if(M==1 || M ==0) outM = 0;
    else outM = M*(M-1)/2;
    cout << outN + outM << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect


a, b, q = map(int, input().split())
s_list = [-100000000000000000]
t_list = [-100000000000000000]

for i in range(a):
    s = int(input())
    s_list.append(s)
for j in range(b):
    t = int(input())
    t_list.append(t)
s_list.append(100000000000000000)
t_list.append(100000000000000000)

for i in range(q):
    x = int(input())
    s_pos = bisect.bisect_left(s_list, x)
    t_pos = bisect.bisect_left(t_list, x)
    
    s_cand1 = x - s_list[s_pos-1]
    s_cand2 = s_list[s_pos] - x
    t_cand1 = x - t_list[t_pos-1]
    t_cand2 = t_list[t_pos] - x
    
    dist1 = max(s_cand1, t_cand1)
    dist2 = max(s_cand2, t_cand2)
    dist3 = min(s_cand1, t_cand2)*2 + max(s_cand1, t_cand2)
    dist4 = min(s_cand2, t_cand1)*2 + max(s_cand2, t_cand1)
    
    print(min(dist1, dist2, dist3, dist4))

Measured memory_bytes: 12080
import java.util.*;
//解説参照、それを元に作成
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong(); 
    long B = sc.nextLong();
    for (int i=1;i<=B;i++){
      if ((A*i)%B==0){
        System.out.println(A*i);
        break;
      }
    }
  }
}

Measured memory_bytes: 21844