akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define  mp(a,b)      make_pair(a,b)
#define  pb(a)        push_back(a)
#define  SIZE5        100001               /// 1e5+1
#define  SIZE6        1000001              /// 1e6+1
#define  SIZE7        10000001             /// 1e7+1
#define  MOD          1000000007           /// 1e9+7


using namespace std;

typedef long long int ll;


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

    int T = 1;

    for(int test = 1; test <= T; test++)
    {

        ll N, M;
        cin >> N >> M;

        vector<ll> g[N+1];

      	ll H[N+1];
      	for(ll i=1; i<=N; i++)
      	{
            cin >> H[i];
      	}

        for(ll i=0; i<M; i++)
        {
            ll u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        int ans = 0;

        for(int i=1; i<=N; i++)
        {
            if(g[i].size() == 0) ans++;
            else{
                int flg = 1;
                for(auto xx: g[i]){
                    if(H[i] <= H[xx]){
                        flg = 0; break;
                    }
                }
                ans += flg;
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 10252
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  ll N = S.size();
  vector<vector<ll> > dp(N+1, vector<ll>(2,1e16));
  dp[0][0] = 0;
  REP(i, N){
    REP(j, 2){
      if(j == 1){
        chmin(dp[i+1][1], 10-((S[N-1-i]-'0')+1)+dp[i][1]);
        chmin(dp[i+1][0], (S[N-1-i]-'0')+1+dp[i][1]);
      }else{
        chmin(dp[i+1][1], 10-(S[N-1-i]-'0')+dp[i][0]);
        chmin(dp[i+1][0], (S[N-1-i]-'0')+dp[i][0]);
      }
    }
  }
  cout << min(dp[N][1]+1, dp[N][0]) << endl;
}

Measured memory_bytes: 56092
#include<bits/stdc++.h>
using namespace std;
vector<string> t,u;
set< vector<string> > s;

int func(){
  if(s.find(t)!=s.end())return 0;
  string tmp;
  
  for(int i=0;i<2;i++){
    swap(t[0],t[4]);
    swap(t[2],t[6]);
    swap(t[1],t[7]);
    swap(t[3],t[5]);
    for(int j=0;j<4;j++){
      tmp=t[0];
      t[0]=t[1];
      t[1]=t[2];
      t[2]=t[3];
      t[3]=tmp;
      
      tmp=t[4];
      t[4]=t[5];
      t[5]=t[6];
      t[6]=t[7];
      t[7]=tmp;
      for(int k=0;k<3;k++){
        tmp=t[1];
        t[1]=t[4];
        t[4]=t[3];
        t[3]=tmp;

        tmp=t[5];
        t[5]=t[7];
        t[7]=t[2];
        t[2]=tmp;
        s.insert(t);
      }
    }
  }
  if(u!=t)cout<<'a'<<endl;
  return 1;
}

int main(){
  t.resize(8);
  while(cin>>t[0]){
    s.clear();
    for(int i=1;i<8;i++)cin>>t[i];
    u=t;
    sort(u.begin(),u.end());
    int ans=0;
    do{
      t=u;
      ans+=func();
    }while(next_permutation(u.begin(),u.end()));
    
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6872
#include<stdio.h>
int main(){
  long long int N,M;
  (void)scanf("%lld %lld",&N,&M);
  long long int sum=0;
  int s,i,j;
  int arr[100000];
  for(i=0; i<M;i++){
    (void)scanf("%d",&arr[i]);
  }
  for(j=0;j<M;j++){
    sum=sum+arr[j];
  }
  s=N-sum;
  if(s<0)
    printf("-1\n");
  else
    printf("%d\n",s);
}

Measured memory_bytes: 1740
from typing import List


def cross(a: complex, b: complex) -> float:
    return a.real * b.imag - a.imag * b.real


def distance(i: int, j: int, coordinates: List[complex]) -> float:
    return abs(coordinates[i] - coordinates[j])


if __name__ == "__main__":
    n = int(input())
    points = [tuple(map(float, input().split())) for _ in range(n)]
    min_x_idx = min(range(n), key=lambda x: points[x])
    max_x_idx = max(range(n), key=lambda x: points[x])
    coordinates = [re + 1j * im for re, im in points]
    coordinates.append(coordinates[0])

    ans = distance(min_x_idx, max_x_idx, coordinates)
    i, j = min_x_idx, max_x_idx
    while True:
        if 0 <= cross(coordinates[i + 1] - coordinates[i],
                      coordinates[j + 1] - coordinates[j]):
            j = (j + 1) % n
        else:
            i = (i + 1) % n
        ans = max(ans, distance(i, j, coordinates))

        if min_x_idx == i and max_x_idx == j:
            break

    print(ans)



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

int N;
int num[100];
long long int mem[100][21];
bool vis[100][21];

void rec(int p, int x) {
  int nx;
  if(x < 0 || x > 20) return;
  if(p >= N-1) return;
  if(vis[p][x]) return;

  mem[p][x] = 0;

  nx = x + num[p];
  if(nx >= 0 && nx <= 20) {
    rec(p+1, nx);
    mem[p][x] += mem[p+1][nx];
  }

  nx = x - num[p];
  if(nx >= 0 && nx <= 20) {
    rec(p+1, nx);
    mem[p][x] += mem[p+1][nx];
  }

  vis[p][x] = true;
}

main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> num[i];
  }
  fill(mem[0], mem[100], 0);
  fill(vis[0], vis[100], false);
  mem[N-1][num[N-1]] = 1;
  vis[N-1][num[N-1]] = true;
  rec(1, num[0]);
  cout << mem[1][num[0]] << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main (String[] args){
    Scanner input = new Scanner(System.in);
    
    while (input.hasNext()) {
      int N = input.nextInt();
      String S = input.next();
      
      int[] wBefore = new int[N];
      for (int i = 1; i < S.length(); ++i) {
         if (S.charAt(i - 1) == 'W') {
          wBefore[i] +=wBefore[i - 1] + 1;
        } else {
          wBefore[i] = wBefore[i - 1];
        }
      }

      int[] eAfter = new int[N];
      for (int i = S.length() - 2; i >= 0 ; --i) {
         if (S.charAt(i + 1) == 'E') {
          eAfter[i] += eAfter[i + 1] + 1;
        } else {
          eAfter[i] = eAfter[i + 1];
        }
      }
      
      int minChange = Integer.MAX_VALUE;
      for (int i = 0; i < S.length(); ++i) {
        minChange = Math.min(minChange, wBefore[i] + eAfter[i]);
      }

      System.out.println(minChange);
    }
  }
}

Measured memory_bytes: 31044
#include <cassert>
#include <iostream>
#include <vector>

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

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto &a : A)
    std::cin >> a;

  // Main
  std::vector<int> leftGCD(N + 1, 0);
  std::vector<int> rightGCD(N + 1, 0);
  for (int i = 1; i <= N; ++i)
    leftGCD[i] = gcd(A[i - 1], leftGCD[i - 1]);
  for (int i = N - 1; i >= 0; --i)
    rightGCD[i] = gcd(A[i], rightGCD[i + 1]);

  // Output
  int res = 0;
  for (int i = 0; i < N; ++i)
    chmax(res, gcd(leftGCD[i], rightGCD[i + 1]));
  std::cout << res << std::endl;

  return 0;
}


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

using namespace std;

long long a,b,ans;

long long xorin(long long x){
	long long t = x%4;
	if(t==0) return x;
	if(t==1) return 1;
	if(t==2) return x+1;
	if(t==3) return 0;
}

int main(){
	scanf("%lld%lld",&a,&b);
	ans = xorin(b)^xorin(a-1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int sum,foot;
    int souwa;
    bool turukame = false;

    cin >>sum>>foot;
    
    rep(i,sum+1){
        int j = sum-i;
        souwa = 2*i + 4*j;
        if(souwa == foot){
            turukame = true;
        }
    }
    if(turukame){
        cout <<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

main = do
    [x,y,z,k] <- (map read . words) <$> getLine
    [a,b,c] <- replicateM 3 $ map read . words <$> getLine
    let d = take k $ sortBy (flip compare) [x + y | x <- a, y <- b]
    mapM_ print (take k $ sortBy (flip compare) [x + y | x <- d ,y <- c])

Measured memory_bytes: 419196
import sys
sys.setrecursionlimit(10**6)

a1,a2,a3=map(int,input().split())

cost1=abs(a2-a1)+abs(a3-a1)
cost2=abs(a1-a2)+abs(a3-a2)
cost3=abs(a1-a3)+abs(a2-a3)

ans = min(cost1,cost2,cost3)

print(ans)



Measured memory_bytes: 3064
using namespace std;
#include <bits/stdc++.h>
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int rc = 0, wc = 0;
    int fr = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'R')
            rc++;
        else
            wc++;
        if (s[i] == 'R' && fr == 0)
            fr = i + 1;
    }
   int ans=0;
   for (int i = 0; i < rc; i++)
   {
       if(s[i]=='W')
       ans++;
   }
   cout<<ans<<endl;
}
int main()
{

    FASTIO
    long long int t;
    t = 1;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    int k; cin >> k;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_3_C
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] i = Console.ReadLine().Split(' ');
                int x = int.Parse(i[0]);
                int y = int.Parse(i[1]);
                
                if (x == 0 && y == 0) break;
                Console.WriteLine("{0} {1}", Math.Min(x, y), Math.Max(x, y));
            }
        }
    }
}


Measured memory_bytes: 15952
s, t = io.read('*l'), io.read('*l')

ans = nil

for i = 1, #s - #t + 1 do
    local ss = s:sub(1, i - 1) .. t .. s:sub(i + #t)
    local valid = true
    for j = 1, #s do
        if s:byte(j) ~= 63 and s:byte(j) ~= ss:byte(j) then
            valid = false; break
        end
    end
    if valid then
        local t = ss:gsub('?', 'a')
        if ans == nil or ans > t then ans = t end
    end
end

print(ans or 'UNRESTORABLE')


Measured memory_bytes: 760
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll N,M;
    cin >>N>>M;
    ll a,ans=0;
    rep(i,M){
        cin >> a;
        ans+=a;
    }

    //-----------------------------------



    cout << ((ans>N) ? -1 : N-ans) <<endl;


    return (0);
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
 
  vector<int> b(n);
  for(int j=0; j<n; j++){
   b[j] = a[j];
  }
  
  sort(b.begin(), b.end());
  
  if(b[n-2]==b[n-1]){
    for(int k=0; k<n; k++){
      cout << b[n-1] << endl;
    }
  }
  else{
    for(int l=0; l<n; l++){
      if(a[l]==b[n-1]){
        cout << b[n-2] << endl;
      }
      else{
        cout << b[n-1] << endl;
      }
    }
  }
  
}


Measured memory_bytes: 4848
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string t;
  cin >> t;
  for(int i = 0; i < t.length(); i++){
    if(t[i] == '?') cout << 'D';
    else cout << t[i];
  }
  cout << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    ll n,k;
    cin>>n>>k;
    vll vec(n);
    rep(i,n)cin>>vec[i];
    ll sum=0;
    sort(all(vec));
    for(ll i=0;i<k;i++){
        sum+=vec[i];
    }
    cout<<sum<<nl;
    
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3640
def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

# 拡張ユークリッドアルゴリズム
# (d, x, y): d=ax+by を満たすd, x, yを求める
# aとbが互いに素な整数であればgcd(a,b)=d=1, ax=1 (mod b)
# xは法bの元でaの乗法逆元a^-1になる
def exEuclid(a, b):
    if (b==0):
        return (a, 1, 0)
    else:
        (dd, xx, yy) = exEuclid(b, a % b)
        return (dd, yy, xx - (a//b)*yy)

def main(n,a):
    MOD=10**9+7
    sum1=0
    sum2=0
    for i in range(n):
        sum1=(sum1+a[i])%MOD
        sum2=(sum2+(a[i]*a[i]))%MOD

    aa=(sum1*sum1-sum2+MOD)%MOD

    d,x,y=exEuclid(2,MOD)
    if x<0:
        x+=MOD
    #print(x)

    return (aa*x)%MOD

def main2(n,a):
    MOD=10**9+7
    ruiseki=[0]*n
    ruiseki[0]=a[0]
    for i in range(1,n):
        ruiseki[i]=(ruiseki[i-1]+a[i])%MOD
    sum=0
    for i in range(n-1):
        sum=(sum+(a[i]*(ruiseki[n-1]-ruiseki[i]))%MOD)%MOD
    return sum

if __name__=='__main__':
    n,a=readinput()
    ans=main2(n,a)
    print(ans)


Measured memory_bytes: 31568
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define sqr(x) ((x) * (x))
#define db double
const int N = 16;
const int ST = 1 << (N + 1);
db x[N], y[N], a[N], d[N][N];
db sum[ST], dp[ST], f[ST];
int n;

int main(void) {
  cin >> n;
  re0 (i, n) {
    cin >> x[i] >> y[i] >> a[i];
  }
  int all = 1 << n;
  re0 (st, all) re0 (i, n) if (st >> i & 1) sum[st] += a[i];
  re0 (i, n) re0 (j, n)
    d[i][j] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
  fill(dp, dp + all, 1e18);
  re0 (st, all) {
    if (__builtin_popcount(st) <= 1) dp[st] =0;
    re0 (i, n) re0 (j, n)
    if (st >> i & 1 && !(st >> j & 1))
      dp[st | 1 << j] = min(dp[st | 1 << j], dp[st] + d[i][j]);
  }
  // re0 (st, all) cout << sum[st] << " "; cout << "\n";
  // re0 (st, all) cout << dp[st] << " "; cout << "\n";
  re0 (st, all) {
    f[st] = (sum[st] - dp[st]) / __builtin_popcount(st);
    for (int S = st; S; S = (S - 1) & st)
      f[st] = max(f[st], min(f[S], f[S ^ st]));
  }
  printf("%.10f\n", f[all - 1]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>


using namespace std;

int main(){

    int A, P;
    cin >> A >> P;
    
    
    if (P%2 == 0) {
        if (A%2 == 0) {
            cout << (A*3+P)/2 <<endl;
        }else{
            cout << ((A-1)*3+P)/2 + 1 << endl;
        }
    }else{
        if (A%2 == 0) {
            cout << ((A-1)*3+P)/2 + 1 <<endl;
        }else{
            cout << (A*3+P)/2 << endl;
        }
        
    }
    
    
    
    
    
    return 0;
    
}


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

x = 0
y = 0

counts = 0
for item in inputs:
    counts += item.count('#')

if counts != (H + W - 1):
    ans = 'Impossible'
else:
    for _ in range(H + W - 2):
        if x + 1 < W and inputs[y][x + 1] == '#':
            x += 1
        elif y + 1 < H and inputs[y + 1][x] == '#':
            y += 1
    ans = 'Possible' if y == H - 1 and x == W - 1 else 'Impossible'

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;


int main(){
  ll n, m;
  cin >> n >> m;
  ll box[110000];
  map<ll, ll> mp;
  mp[0] = 1;
  ll ans = 0;
  rep(i, n){
    ll a;
    cin >> a;
    a = a%m;
    box[i] = i == 0 ? a : (box[i-1] + a)%m;
    mp[box[i]]++;
  }
  for(pair<ll, ll> x : mp){
    ans += x.second * (x.second - 1)/2;
  }
  cout << ans <<endl;
}
  

Measured memory_bytes: 8144
def get_result(V, C, N):
    return sum([V[i]-C[i] for i in range(N) if V[i] >= C[i] ])

N = int(input())
V = [int(s) for s in input().split(" ")]
C = [int(s) for s in input().split(" ")]
result = get_result(V, C, N)
print(result )


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

int main(){
  int n,m;cin>>n>>m;
  int nmin;
  int nmax;
  cin >>nmax>>nmin;
  int l,r;
  for(int i=1;i<m;++i){
    cin >>l>>r;
    nmin=min(nmin,r);
    nmax=max(nmax,l);
  }
  if(nmax>nmin)cout << 0 << endl;
  else cout << nmin-nmax+1<<endl;
  return 0;
}


Measured memory_bytes: 256
//It is made by M_sea
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;

int w[N],cnt[20],f[1<<16],sxor[1<<16];

int main() {
    int n=read();
    for (re int i=1;i<n;++i) {
        int u=read()+1,v=read()+1,val=read();
        w[u]^=val,w[v]^=val;
    }
    for (re int i=1;i<=n;++i) ++cnt[w[i]];
    int ans=0,s=0;
    for (re int i=1;i<=15;++i) ans+=cnt[i]/2,s|=(cnt[i]&1)<<(i-1);
    for (re int i=1;i<(1<<15);++i) f[i]=f[i>>1]+(i&1);
    for (re int i=1;i<(1<<15);++i) --f[i];
    for (re int i=1;i<(1<<15);++i)
        for (re int j=1;j<=15;++j)
            if (i&(1<<(j-1))) sxor[i]^=j;
    for (re int i=1;i<(1<<15);++i) {
        if (sxor[i]) continue;
        for (re int j=i&(i-1);j;j=(j-1)&i)
            if (!sxor[j]) f[i]=min(f[i],f[j]+f[i^j]);
    }
    printf("%d\n",ans+f[s]);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    vl T(N);
    rep(i, N) {
        if (S[i] == '?') T[i] = 3;
        else T[i] = S[i] - 'A';
    }

    vl C(4); // 何もなし, A, AB, ABC
    C[0] = 1;
    rep(i, N){
        if(T[i] <= 2){
            (C[T[i] + 1] += C[T[i]]) %= MOD;
        }else{
            vl tmp = C;
            repr(j, 3)(C[j + 1] += C[j]) %= MOD;
            rep(j, 4)(C[j] += 2 * tmp[j]) %= MOD;
        }
    }

    cout << C[3] << endl;
}

Measured memory_bytes: 4224
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String ,Integer> M = new HashMap<>();
        
        int N = sc.nextInt();
        
        for(int i=0;i<N;i++){
            int q = sc.nextInt();
            
            if(q == 0){
                M.put(sc.next(),sc.nextInt());
            }else{
                System.out.println(M.get(sc.next()));
            }
        }
    }
}


Measured memory_bytes: 194360
import java.util.Scanner;

public class Main {

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

        int x = sc.nextInt();

        //最大で購入可能な個数を算出
        int max = x / 100;

        //最大で購入可能な金額誤差
        int max_d = max * 5;

        int xd = x - max * 100;

        if (max_d >= xd){
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300300;
ll pre[N] , suf[N];
int n ;
ll a[N];
multiset<ll>ms;

int main(){

cin>>n;
for(int i=1;i<=3*n;i++)cin>>a[i];

ll sum=0;
for(int i=1;i<=3*n;i++){

    sum+=a[i];
    ms.insert(a[i]);
    if( ms.size()>=n ){

        if( ms.size()>n ){
            ll x = *ms.begin();
            sum-=x;
            ms.erase( ms.begin() );
        }
        pre[i]=sum;
    }
    else pre[i]=-(1ll<<50);

    if( i>1 )pre[i]=max( pre[i],pre[i-1] );

}

ms.clear();
sum=0;
for(int i=3*n;i>0;i--){

    sum+=a[i];
    ms.insert(a[i]);
    if( ms.size()>=n ){

        if( ms.size()>n ){
            ll x = *ms.rbegin();
            sum-=x;
            ms.erase( --ms.end() );
        }
        suf[i]=sum;
    }
    else suf[i]=(1ll<<50);

    if( i+1<=3*n )suf[i]=min(suf[i],suf[i+1]);
}


ll best = -(1ll<<50);
for(int i=1;i<3*n;i++)
    best=max( best , pre[i]-suf[i+1] );

cout<<best<<endl;
return 0;
}


Measured memory_bytes: 12032
N,M=map(int,input().split())
XYZ=[]
for i in range(M):
  x,y,z=map(int,input().split())
  XYZ.append([x,y,z])
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rnk=[0]*(n+1)
  def find(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.find(self.root[x])
      return self.root[x]
  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    elif self.rnk[x]>self.rnk[y]:
      self.root[x]+=self.root[y]
      self.root[y]=x
    else:
      self.root[y]+=self.root[x]
      self.root[x]=y
      if self.rnk[x]==self.rnk[y]:
        self.rnk[y]+=1
  def count(self,x):
    return -self.root[self.find(x)]
uf=UnionFind(N)
for i in range(M):
  uf.unite(XYZ[i][0],XYZ[i][1])
ans=-1
for i in range(len(uf.root)):
  if uf.root[i]<0:
    ans+=1
print(ans)

Measured memory_bytes: 21400
#include <bits/stdc++.h>
#define read(x) scanf("%d",&x)
#define write(x) printf("%d",x)
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(){

	int a,n;
	cin>>a>>n;
	int sum = 0,x;
	rep(i,n){
		cin>>x;
		sum += x;

	}
	if(sum>=a) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 int main(){
     string s;
     string ans;
     cin >> s;
     for(int i=0; i<s.length();i++){
         switch(s[i]){
             case '0':
                ans.push_back('0');
                break;
             case '1':
                ans.push_back('1');
                break;
             case 'B':
                if(!ans.empty()){
                    ans.pop_back();
                }
                break;
         }
     }
     cout << ans << endl;
 }

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i=0; i<N; i++) {
    cin >> K.at(i);
    for (int j=0; j<K.at(i); j++) {
      cin >> A.at(i).at(j);
    }
  }
  // 出てきた回数がNと同じなら全員が好きと答えたことになる
  int answer = 0;
  for (int i=1; i<M+1; i++) {
    int counter = 0;
    for (int j=0; j<N; j++) {
      for (int k=0; k<K.at(j); k++) {
        if (A.at(j).at(k) == i) {
          counter++;
        }
      }
    }
    if (counter == N) {
      answer++;
    }
  }
  cout << answer << endl;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int N;

int main(){
  cin.tie(0);
  
  cin>>N;
  
  while(N>=0) {
    if(N%4==0) {
      cout<<"Yes"<<endl;
      return 0;
    }
    N-=7;
  }
  
  cout<<"No"<<endl;
  
  return 0;
}


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

class Solver extends Main{
	Solver(){
		
	}
}//Solver_end

@SuppressWarnings("unchecked")
class Main{
	static int imax=Integer.MAX_VALUE;
	static long lmax=Long.MAX_VALUE;
	
	public static void main(String[] args) throws FileNotFoundException{
		
		Scanner sc=new Scanner(System.in);
		
		int n=readI(sc);
		int[] num=new int[n];
		
		for(int i=0;i<n; i++){
			num[i]=readI(sc)-1;
		}
		
		int prev=0;
		int cur=num[0];
		int cnt=1;
		
		
		while(cur!=1 && num[cur]!=-1){
			prev=cur;
			cur=num[cur];
			num[prev]=-1;
			cnt+=1;
		}
		
		puts(cur==1 ? cnt : -1);
		
		new Solver();
	}//main_end
	
//---------------------------------------------------------------------------
	static int readI(Scanner sc){
		return Integer.parseInt(sc.nextLine().trim());
	}
	static long readL(Scanner sc){
		return Long.parseLong(sc.nextLine().trim());
	}
	static String readS(Scanner sc){
		return sc.nextLine().trim();
	}
	static int[] readlnI(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToInt(Integer::parseInt).toArray();
	}
	static long[] readlnL(Scanner sc, String dl){
		return Arrays.stream(sc.nextLine().trim().split(dl)).mapToLong(Long::parseLong).toArray();
	}
	static String[] readlnS(Scanner sc, String dl){
		return sc.nextLine().trim().split(dl);
	}
	@SuppressWarnings("unchecked")
	static <T> void puts(T... args){
		for(int i=0; i<args.length-1; i++){
			System.out.printf("%s ",args[i]);
		}
		System.out.println(args[args.length-1]);
	}
	static void puts(int[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void puts(long[] ary){
		for(int i=0; i<ary.length-1; i++){
			System.out.printf("%d ",ary[i]);
		}
		System.out.println(ary[ary.length-1]);
	}
	static void bs(){
		System.out.println("");
	}
	static int sum(int[] ary){
		int sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static long sum(long[] ary){
		long sum=0;
		for(int i=0; i<ary.length; i++) sum+=ary[i];
		return sum;
	}
	static void tblSort(int[][] tbl){
		Arrays.sort(tbl, new Comparator<int[]>(){
			@Override
			public int compare(int[] a, int[] b){
				if(a[0]==b[0]){
					return b[1]-a[1];
				}else{
					return b[0]-a[0];
				}
			}
		});
	}
}


Measured memory_bytes: 97224
//ABC071B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	for(char c = 'a';c<='z';c++){
		int flag = 1;
		for(int i=0;i<s.size();i++){
			if(c == s.at(i)){
				flag = 0;
			}
		}
		if(flag == 1){
			cout << c << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
int main(){
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    rep(i,0,h){
        rep(j,0,w){
            if((i<b)^(j<a))cout<<"1";
            else cout<<"0";
        }
        cout<<endl;
    }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var average = vals.Average();
            var dists = vals.Select(x => Math.Abs(x - average)).ToArray();
            var min_avg = 100000.0;
            var result = 0;
            foreach(var i in Enumerable.Range(0, N))
            {
                if(dists[i] < min_avg)
                {
                    result = i;
                    min_avg = dists[i];
                }
            }
            Console.WriteLine(result);
        } 
    }
}


Measured memory_bytes: 13396
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}
	//コンビネーション(n,r)
	ull combination(int n, int r) {
		if (r * 2 > n) r = n - r;
		ull dividend = 1;
		ull divisor = 1;
		for (int i = 1; i <= r; ++i) {
			dividend *= (n - i + 1);
			divisor *= i;
		}
		return dividend / divisor;
	}

	void Swap(int* left, int* right)
	{
		int temp = *left;
		*left = *right;
		*right = temp;
	}

int main() {
	int N,i,b,j;
	vector<int> Bi(200, 0) , ans(200, 0);
	cin >> N;
	REP(i, N) {
		cin >> b;
		Bi[i] = b;
	}
	int index;
	REP(i, N) {
		index = -1;
		REP(j, N - i) {
			if (Bi[j] == j + 1) 
				index = j;
		}
		if (index == -1) {
			cout << "-1" << endl;
			return 0;
		}
		Bi.erase(Bi.begin() + index);
		ans[N - 1 - i] = index + 1;
	}
	REP(i, N) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(M);
	for (int i = 0; i < M; i++)
	{
		cin >> X[i];
	}
	// X地点のソート
	sort(X.begin(), X.end());
	
	// X間の距離を算出する
	vector<int> distance(M - 1);
	for (int i = 0; i < M - 1; i++)
	{
		distance[i] = X[i + 1] - X[i];
	}
	
	// X間の距離の値をソート
	sort(distance.begin(), distance.end());
	
	int answer = 0;
	
	int moveCount = max(M - N, 0);
	// コマの移動
	for (int i = 0; i < moveCount; i++)
	{
		answer += distance[i];
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1024
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define INF 2147483647
#define MOD 10000007
#define REP(i, lower, upper) for (long long i = lower; count_ver < upper; i++)
typedef long long ll;
using namespace std;

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
vector<long long> divisor(long long n) {// if 2,it's prime
  vector<long long> ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  return (ret);
}

void execute(){

  ll n;
  cin>>n;
  string ans = "";
  for (int i = 1; i < 99;i++){
    if(n <= pow(26,i)){
      n -= 1;
      for (int j = 0; j < i;j++){
        ans += char('a' + n % 26);
        n /= 26;
      }
      break;
    }else{
      n -= pow(26, i);
    }
  }
  reverse(ans.begin(),ans.end());
  cout<< ans <<endl;
}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


Measured memory_bytes: 3480
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int a,b;

	cin>>a>>b;

	if(a>b) cout<<"a > b"<<endl;
	else if(a<b) cout<<"a < b"<<endl;
	else cout<<"a == b"<<endl;

	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

#define MAX_N 100000

int N;
int A[MAX_N];

void set() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
}

void solve(int n) {
	while (A[n] > 0) {
		A[n + 1] = A[n + 1] % A[n];
		swap(A[n], A[n + 1]);
	}
	if (n == N - 2)return;
	solve(n + 1);
}

int main() {
	set();
	solve(0);
	cout << A[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int countR = 0;
  int countB = 0;

  int n;
  string s;
  cin>>n>>s;
 
  for(int i=0;i<n;i++){
    if(s[i]=='R')
    countR++;
    else if(s[i]=='B')
    countB++;
  }  
  if(countR > countB)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  double T, X;
  cin>>T>>X;
  cout << T/X << endl;
  return 0;
}


Measured memory_bytes: 256
h,w,m=(int(i) for i in input().split())
l1=[]
l2=[0]*h
l3=[0]*w
for i in range(m):
    x,y=(int(i) for i in input().split())
    l1.append((x,y))
    l2[x-1]+=1
    l3[y-1]+=1
m1=max(l2)
m2=max(l3)
m3=max(m1,m2)
if(m1>m2):
    l4=[0]*w
    k=l2.index(m1)
    for i in range(m):
        if(l1[i][0]!=k+1):
           l4[l1[i][1]-1]+=1
    k1=max(l4)
    print(m3+k1)
else:
    l4=[0]*h
    k=l3.index(m2)
    for i in range(m):
        if(l1[i][1]!=k+1):
           l4[l1[i][0]-1]+=1
    k1=max(l4)
    print(m3+k1)

Measured memory_bytes: 56600
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
  for {
    a,b := 0,0
    op := ""
    fmt.Scan(&a)
    fmt.Scan(&op)
    if op == "?"{break}
    fmt.Scan(&b)
    if op == "+"{
      fmt.Println(a+b)
    }else if op == "-"{
      fmt.Println(a-b)
    }else if op == "/"{
      fmt.Println(a/b)
    }else{
      fmt.Println(a*b)
    }
  }
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1160
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


ll A[2][101];
ll S[2][101];

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<tuple<ll, ll, ll>> v;
    rep (i, N) {
        ll t, x, y;
        cin >> t >> x >> y;
        v.pb({t, x, y});
    }
    tuple<ll, ll, ll> c;
    rep (i, N) {
        ll t = get<0>(v[i]);
        ll x = get<1>(v[i]);
        ll y = get<2>(v[i]);
        ll dt = abs(t - get<0>(c));
        ll dx = abs(x - get<1>(c));
        ll dy = abs(y - get<2>(c));
        if (dx + dy > dt) {
            cout << "No" << endl;
            return 0;
        }
        if ((dx + dy) % 2 != dt % 2) {
            cout << "No" << endl;
            return 0;
        }
        c = {t, x, y};
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
	ll a, b, d;
	while(cin >> a >> b >> d, a) {
		bool ok = false;
		ll x = 50000, y = 50000;
		for(ll k = 1; k <= 50000; k++) {
			if((d-b*k)%(a-b)==0 && (d-a*k)%(b-a)==0) {
				ok = true;
				ll tx, ty;
				tx = (d-b*k)/(a-b);
				ty = (d-a*k)/(b-a);
				if(tx < 0 || ty < 0) {
					ok = false;
				} else if(a*tx+b*ty < a*x+b*y) {
					x = tx, y = ty;
				}
			}

			if((d+b*k)%(a+b)==0 && (d-a*k)%(-a-b)==0) {
				ok = true;
				ll tx, ty;
				tx = (d+b*k)/(a+b);
				ty = (d-a*k)/(-a-b);
				if(tx < 0 || ty < 0) {
					ok = false;
				} else if(a*tx+b*ty < a*x+b*y) {
					x = tx, y = ty;
				}
			}

			if((d-b*k)%(-a-b)==0 && (d+a*k)%(a+b)==0) {
				ok = true;
				ll tx, ty;
				tx = (d-b*k)/(-a-b);
				ty = (d+a*k)/(a+b);
				if(tx < 0 || ty < 0) {
					ok = false;
				} else if(a*tx+b*ty < a*x+b*y) {
					x = tx, y = ty;
				}
			}

			if(ok) {
				break;
			}
		}

		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

double sum,ans;
int n,x,d;

int main(int argc,char *argv[]){
#ifdef GCURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	cin>>n>>x>>d;
	sum=2.0*n*x+1.0*n*(2.0*n-1.0)*d;
	while(n)ans+=sum/2.0/n,sum-=sum/n/n,--n;
	printf("%.12f\n",ans); 
	return 0; 
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let mut x: i32 = read();
    let mut score = 0;

    while x >= 500 {
        x = x - 500;
        score = score + 1000;
    }

    while x >= 5 {
        x = x - 5;
        score = score + 5;
    }

    println!("{}", score);
}

Measured memory_bytes: 4352