akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	k, n := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	max := k + a[0] - a[n-1]
	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] > max {
			max = a[i+1] - a[i]
		}
	}
	io.Println(k - max)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 12532
'use strict';
const main = input => {
  const n = parseInt(input[0], 10);
  input.shift();
  input.pop();
  let s = new Array(n);
  s = input;
  s = s.map(val => [...val].sort((x,y)=>x>y?1:-1).toString()).sort();
  // console.log(s);
  let t = s[0], val = 0, ans = 0;
  for(let i=1; i<n; i++) {
    if (s[i] == t) val++;
    else {
      ans += val*(val+1)/2;
      val = 0;
      t = s[i];
    }
  }
  if (val) ans += val*(val+1)/2;
  console.log(ans);
  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

int main() {
  int N,K;
  cin>>N>>K;
  int A=1;
  vector<int> ni;
  while(A<=N){
    ni.push_back(A);
    A*=2;
  }
  int S=ni.size();
  vector<int64_t> seg(A*2-1);
  vector<pair<int64_t,int>> p(N);
  int64_t B=0,Z=0;
  for(int i=0;i<N;i++){
    int64_t a;
    cin>>a;
    B+=a;
    B-=K;
    p[i]=make_pair(B,i);
    if(B>=0){
      Z++;
    }
  }
  sort(p.begin(), p.end());
  for(int i=0;i<N;i++){
    int x=p[i].second;
    x++;
    int Q=A+x-2;
    while(Q>0){
      if(Q%2==1){
        Z+=seg[Q];
        Q--;
      }
      Q--;
      Q/=2;
    }
    Q=A+x-2;
    while(true){
      seg[Q]++;
      if(Q==0){
        break;
      }
      Q=(Q-1)/2;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]-=i+1;
    }

    sort(ALL(a));

    ll med = a[n/2];
    ll ans = 0;
    rep(i, n)ans += abs(a[i]-med);

    cout << ans << endl;
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
int solve(vector<int> h,int n,vector<int> dp){
    if(n==1)return h[n];
    else if(n==2) return min(h[2],h[1]);
    if(dp[n]!=-1)return dp[n];
    dp[n]=min(abs(h[n]-h[n-1])+solve(h,n-1,dp),abs(h[n]-h[n-2])+solve(h,n-2,dp));
    return dp[n];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n;cin>>n;
    vector<int> v(n,0),dp(n+4,INT_MAX);
    for(int i=0;i<n;i++)cin>>v[i];dp[0]=0;
    for(int i=0;i<n-1;i++){
        dp[i+1]=min(dp[i+1],dp[i]+abs(v[i+1]-v[i]));
        if(i+2<n)dp[i+2]=min(dp[i+2],dp[i]+abs(v[i+2]-v[i]));
    }cout<<(dp[n-1]);
    //for(auto x:dp)ce(x);
    
    

  }


Measured memory_bytes: 3972
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX MAX000
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................

int W, H;
char c[100][100];
void grid_dfs(int y, int x) {
	int i, j;
	c[y][x] = '0';
	for (i = -1; i <= 1; i++) {
		for (j = -1; j <= 1; j++) {
			int nx = x + i;
			int ny = y + j;
			if (nx < 0 || W <= nx) continue;
			if (ny < 0 || H <= ny) continue;
			if (c[ny][nx] == '0') continue;
			grid_dfs(ny, nx);
		}
	}
}
signed main(void)
{
	int i, j, k;
	while (1) {
		cin >> W >> H;
		if (W == 0) break;
		rep(i, H) rep(j, W) {
			reader(c[i][j]);
		}
		/*rep(i, H) {
			writerArr(c[i],W);
		}*/
		int cnt = 0;
		rep(i, H) rep(j, W) {
			if (c[i][j] == '1') {
				cnt++;
				grid_dfs(i, j);
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{

    int x,y,x2,y2;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    double a;
    int n;
};
vector<int> v[2010];

int a,b,c,o[13015],i,k,d,n,m,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int l[3][3333];

long long x,y,z,v1,v2;
P u[500600];
S j[6001000];
queue<int> q,q1;
stack<int> s;
//queue<P> q;

//deque<int> d;
//'1'==49;
//'A'==65;
//'a'==97;
map<int, int > p1,p2;
string r,r1;
//char r[1010];

bool as(P a,P b)
{
    return atan2(a.y2,a.x2)<atan2(b.y2,b.x2);
}

int f(int t,int w)
{
    if(w==a-1) return max(o[w]-o[w+1],o[w+1]-o[w]);
    if(l[t][w]>=0) return l[t][w];
    if(t)
    {
        int k=max(o[w]-o[a],o[a]-o[w]);
        for(int h=w+1;h<a;h++)
            k=max(k,f(0,h));
        return l[t][w]=k;
    }
    int k=max(o[w]-o[a],o[a]-o[w]);
        for(int h=w+1;h<a;h++)
            k=min(k,f(1,h));
        return l[t][w]=k;
}

int main()
{
    scanf("%d %d %d",&a,&b,&o[0]);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    memset(l,-1,sizeof(l));
    printf("%d",f(1,0));
}


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

def main():
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for i in range(h)]
  b=[list(map(int,input().split())) for i in range(h)]
  dp=[[[0]*(80*(h+w+1)+1) for i in range(w)] for j in range(h)]
  dp[0][0][abs(a[0][0]-b[0][0])]=1
  for i in range(h):
    for j in range(w):
      c=abs(a[i][j]-b[i][j])
      if i!=0 or j!=0:
        for k in range(80*(i+j+1)+1):
          dp[i][j][k]=dp[i-1][j][abs(k-c)]|dp[i-1][j][k+c]|dp[i][j-1][abs(k-c)]|dp[i][j-1][k+c]
  for i in range(80*(h+w+1)+1):
    if dp[h-1][w-1][i]==1:
      print(i)
      break

if __name__=='__main__':
  main()

Measured memory_bytes: 679688
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  char s;
  cin >> s;
  if('A' <= s && s <= 'Z'){
    cout << 'A' << endl;
  }else{
    cout << 'a' << endl;
  }
}

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

int main() {
int a1,a2,a3;cin>>a1>>a2>>a3;
if(a1+a2+a3>=22)cout<<"bust"<<endl;
else cout<<"win"<<endl;
	
	return 0;
}

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

using namespace std;

int n,A,B,C;
int l[8];

int dfs(int cnt,int a,int b,int c){
    if(cnt==n){
        if(min({a,b,c})>0)
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else
            return 10000000;
    }

    int ans1 = dfs(cnt+1,a,b,c);
    int ans2 = dfs(cnt+1,a+l[cnt],b,c)+10;
    int ans3 = dfs(cnt+1,a,b+l[cnt],c)+10;
    int ans4 = dfs(cnt+1,a,b,c+l[cnt])+10;
    return min({ans1,ans2,ans3,ans4});
}

int main(){
    cin>>n>>A>>B>>C;

    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int ans = dfs(0,0,0,0);
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
ll b[2222];
int main(){
    ll n,  k;
    while(cin>>n>>k){
        ll ans=0, mod=1e9+7;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
            b[i]=0;
            for(int j=0; j<i; ++j){
                if(a[j]>a[i]){
                    ++b[i];
                }
            }
            ans+=b[i]*k;
            ans%=mod;
        }
        ll tmp=k*(k-1)/2;
        tmp%=mod;
        for(int i=0; i<n; ++i){
            b[i]=0;
            for(int j=0; j<n; ++j){
                if(a[j]<a[i]){
                    ++b[i];
                }
            }
            ans+=(tmp*b[i])%mod;
            ans%=mod;
        }
        cout<<ans<<endl;
    }
  return 0;
}




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

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

using namespace std;

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

    long int n, m; cin >> n >> m;
    
    if (n>=2&&m>=2) cout << (n-2) * (m-2) << "\n";
    else if (n==1) {
        if (m!=1) cout << m-2 << "\n";
        else cout << 1 << "\n";
    }
    else if (m==1) {
        if (n!=1) cout << n-2 << "\n";
        else cout << 1 << "\n";
    }

    return 0;
}

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

using namespace std;

int main()
{
  int64_t N, L;

  cin >> N >> L;

  int64_t S = N*(N + 1)/2 + N * (L - 1);
  if(L >= 0)
    {
      cout << S - L << endl;
    }
  else if(L < 0 && N + L - 1 < 0)
    {
      cout << S - (L + N - 1) << endl;
    }
  else
    {
      cout << S  << endl;
    }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int r;
    cin>>r;
    cout<<r*r<<newl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long 

int n;
ll t[111111];
ll a[111111];

ll getA0(){
    ll s0=0,s1=0;
    
    rep(i,n){
        if(i%2){
            s1+=2*t[i];
        }
        else{
            s0+=2*t[i];
        }
    }
    
    return (s0-s1)/2;
}
int main(){
    cin>>n;
    rep(i,n)cin>>t[i];
    
    a[0]=getA0();
    
    //cout<<a[0]<<endl;
    
    for(int i=1;i<=n-1;i++){
        a[i]=(t[i-1]*2-a[i-1]);
    }
    
    rep(i,n){
        cout<<a[i];
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main(void){
    
    //????????????????????°
    
    int N;
    cin >> N;
    
    //????????????????????£??¨???????????????
    
    int A[30], B[30], C[30], D[30], i = 0;
    while(true){
        A[i] = 0;
        B[i] = 0;
        C[i] = 0;
        D[i] = 0;
        if(i==29) break;
        i++;
    }
    
    //??\?±?????????????????????????
    int h, f, r, v;
    for (int i = 0; i < N; i++) {
        cin >> h >> f >> r >> v;
        
        //A?£?
        if(h == 1){
            A[(f - 1) * 10 + r - 1] += v;
        }
        
        //B?£?
        if(h == 2){
            B[(f - 1) * 10 + r - 1] += v;
        }
        
        //C?£?
        if(h == 3){
            C[(f - 1) * 10 + r - 1] += v;
        }
        
        //D?£?
        if(h == 4){
            D[(f - 1) * 10 + r - 1] += v;
        }
    }
    
    
    //??????????????¨??????????????????
    
    for(int i = 0; i < 30; i++){
        cout << " " << A[i];
        if(i % 10 == 9) cout << endl;
    }
    
    cout << "####################" << endl;
    
    for(int i = 0; i < 30; i++){
        cout << " " << B[i];
        if(i % 10 == 9) cout << endl;
    }
    
    cout << "####################" << endl;
    
    for(int i = 0; i < 30; i++){
        cout << " " << C[i];
        if(i % 10 == 9) cout << endl;
    }
    
    cout << "####################" << endl;
    
    for(int i = 0; i < 30; i++){
        cout << " " << D[i];
        if(i % 10 == 9) cout << endl;
    }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int h, w;
	cin >> h >> w;
	vector<string>grid;
	for(int i = 0; i < h + 2; i++){
		if(i == 0 || i == h + 1){
			string s;
			for(int j = 0; j < w + 2; j++){
				s += '#';
			}
			grid.push_back(s);
		}else{
			string temp_s;
			cin >> temp_s;
			temp_s = "#" + temp_s + "#";
			grid.push_back(temp_s);
		}
	}

	for(int i = 0; i < grid.size(); i++)cout << grid[i]<< endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,max=0,ans=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (max<a[i]){
            max=a[i];
        }
    }
    for (int i=0; i<n; i++){
        if (a[i]!=max){
            if(abs(max/2-a[i])<abs(max/2-ans))    
                ans=a[i];
        }
    }
    printf("%d %d\n",max,ans);
	return 0 ;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e6+5;
char s[N];
int f, n, k, bit[N];
int main()
{
    scanf("%s", s); n = strlen(s);
    for(int i = 0; i < n; ++i) bit[i] = (s[n-i-1]-'0')*9;
    for(int i = 0, k = 0; i < n||k; ++i) bit[i] += k, k = bit[i]/10, f += (bit[i] %= 10);
    for(int k = 1; k <= n; ++k)
    {
        for(int i = 0, d = 9; d; ++i) 
            f -= bit[i], bit[i] += d, d = bit[i]/10, f += (bit[i] %= 10);
        if(f <= 9*k) return printf("%d\n", k), 0;    
    }
    return 0;
}   

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
ll n,m;
vg graph;
vec dp;
ll func(ll ver) {
	if(dp[ver]!=0)
		return dp[ver];
	ll res = 0;
	for(auto i: graph[ver])
		res = max(res,1 + func(i));	
	return dp[ver] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,u,v;
	cin >> n >> m;
	graph.resize(n + 1);
	dp.assign(n+1,0);
	for(i = 0 ; i < m ; i++) {
		cin >> u >> v;
		graph[v].pb(u);
	}
	ll ans = 0;
	for(i = 1; i <= n ; i++) {
		ans = max(ans,func(i));
	}	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11008
'use strict'
function Main(input) {
  const Num = input.split("\n").map(Number)[0]
  let S = input.split("\n")[1];
  // console.log({ Num, S });

  let SCode = [];
  let NCode = [];

  for (let i = 0; i < S.length; i++) {
    SCode.push(S.charCodeAt(i));
  }
  // console.log({ SCode });

  NCode = SCode.map(function (value) {
    let nValue = value + Num;
    // console.log({ nValue, value, Num });
    if (nValue > 90) {
      nValue = nValue - 26;
    }
    return nValue;
  })

  // console.log({ NCode });
  let Ans = NCode.map(function (value) {
    let nValue = String.fromCharCode(value)
    return nValue;
  })
  console.log(Ans.join(''));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22084
# 158-B
n, a, b = list(map(int, input().split()))
count = -1
if n == 0:
    count = 0
else:
    e_1 = int(n / (a+b)) * a
    e_2 = min(n%(a+b), a)
    count = e_1 + e_2
print(count)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int mod=1e9+7;
string s[1005];
int dp[1005][1005];
int main() {
    int t=1;
    //cin >> t;
    while(t--){
        int h,w,i,j;
        cin >> h >> w;
        for(i=0;i<h;i++){
            cin >> s[i];
        }
        dp[0][0]=1;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(s[i][j]=='#'){
                    dp[i][j]=0;
                    continue;
                }
                if(i>0){
                    dp[i][j]+=dp[i-1][j];
                    dp[i][j]=dp[i][j]%mod;
                }
                if(j>0){
                    dp[i][j]+=dp[i][j-1];
                    dp[i][j]=dp[i][j]%mod;
                }
            }
            
        }
        cout << dp[h-1][w-1];
    }
}

Measured memory_bytes: 9460
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  ll res=k;
  rep(i,n-1){
    res*=k-1;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, K, q;
    cin >> n >> K >> q;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll fans = 1e10;
    for(int i = 0; i < n; i++)
    {
        ll delim = a[i];
        vector<ll> ans;
        int j = 0;
        while(j < n)
        {
            vector<ll> tmp;
            int k;
            for(k = j; k < n; k++)
            {
                if(a[k] >= delim)
                {
                    tmp.push_back(a[k]);
                }
                else
                {
                    k++;
                    break;
                }
            }
            j = k;
            int size = tmp.size();
            sort(tmp.begin(), tmp.end());
            for(int m = 0; m <= size - K && m < q; m++)
            {
                ans.push_back(tmp[m]);
            }
        }
        sort(ans.begin(), ans.end());
        if(ans.size() >= q)
        {
            fans = min(fans, ans[q-1] - ans[0]);
        }
    }
    cout << fans << endl;
}



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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

struct mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    bool operator <(const mint& r){return this->x<r.x;}
    bool operator ==(const mint& r){return this->x==r.x;}
    bool operator !=(const mint& r){return this->x!=r.x;}
    void operator++() {
        x++;
    }
    void operator--() {
        x--;
        if(x<0) x += mod;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main() {
    ll N;
    cin>>N;
    vector<mint> v(N);
    rep(i,N) cin>>v[i].x;
    vector<mint> S(N);
    rep(i,N) {
        if(i==0) S[i] = v[i];
        else S[i] = S[i-1] + v[i];
    }
    mint ans = 0;
    rep(i,N-1){
        ans += S[N-i-2]*v[N-i-1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6428
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;cin >> n;
  vi p(n);
  rep(i,n) cin >> p[i];

  vsort(p);

  cout << p[sz(p) - 1] - p[0] << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;

const long long mod=1e9+7;

int main(){
  int N;  /* 総階段数 */
  int M;  /* 総穴数 */
  unsigned int ret = 1;
  unsigned int flag = 0;

  //cout << "N is" << endl;
  cin >> N;
  //cout << "M is" << endl;
  cin >> M;

  //bool ana[N];
  vector<int> ana(N+1, true);
  unsigned long long int dp[N+1];

  for(int i=0; i<M; i++){
      int ana_cnt;
      cin >> ana_cnt;
      ana[ana_cnt] = false;
  }


    /* dp[0], dp[1]の初期化 */
    dp[0] = 1;

    /* 2段目以上 */
    if(ana[1]){
        dp[1] = 1;
    }
    else{
        dp[1] = 0;
    }

    /* 2以降の計算 */
    for(int i=2; i<N+1; i++){
        /* フィボナッチ数列 */
        if(ana[i]){
            dp[i] = (dp[i-1] + dp[i-2]) % mod;
        }
        else{
            dp[i] = 0;
        }
    }

    cout << dp[N] << endl;

  //cin >> ret;
  return (0);
}

Measured memory_bytes: 1408
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

s=input()

l = len(s)

if (l % 2 != 0):
    print('No')
    sys.exit()

for i in range(len(s)):
    if (i % 2 == 0 and s[i] != 'h') or (i % 2 == 1 and s[i] != 'i'):
        print('No')
        sys.exit()

print('Yes')


Measured memory_bytes: 2940
N = list(map(int, input()))
K = int(input())


dp = [[[0] * 2 for _ in range(K + 1)] for _ in range(len(N) + 1)]
dp[0][0][0] = 1
for i in range(len(N)):
    for j in range(K + 1):
        for is_smaller in range(2):
            for l in range(10):
                if not is_smaller and l > N[i] or l != 0 and j + 1 > K:
                    continue
                i_ = i + 1
                j_ = j
                is_smaller_ = is_smaller

                if l != 0:
                    j_ += 1

                if not is_smaller and l < N[i]:
                    is_smaller_ = 1
                dp[i_][j_][is_smaller_] += dp[i][j][is_smaller]
print(dp[len(N)][K][0] + dp[len(N)][K][1])


Measured memory_bytes: 9152
#include <stdio.h>
#include <vector>
using namespace std;

const long long mod = 1000000007;
long long inv[100005] = {0,1}, fact[100005] = {1,1}, ifact[100005] = {1,1};

long long comb(int n, int k)
{
	return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}

int N;
long long ans[100005];
vector<int> pos[100005];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<=N;i++){
		int x; scanf ("%d",&x);
		pos[x].push_back(i);
	}

	for (int i=2;i<=N+1;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}

	for (int i=1;i<=N+1;i++) ans[i] = comb(N+1,i);
	int r = 0;
	for (int i=1;i<=N;i++) if (pos[i].size() == 2){
		r = pos[i][1] - pos[i][0];
	}

	r = N - r;

	for (int i=0;i<=r;i++) ans[i+1] = (ans[i+1] + mod - comb(r,i)) % mod;
	
	for (int i=1;i<=N+1;i++) printf ("%lld\n",ans[i]);

	return 0;
}

Measured memory_bytes: 9856
def main():
    key_str = input()
    substring = input()
    answer = "z" * len(key_str)
    for i in range(len(key_str) - len(substring) + 1):
        if key_str[i] == substring[0] or key_str[i] == "?":
            for j in range(len(substring)):
                if not key_str[i + j] == substring[j] and not key_str[i + j] == "?":
                    break
            else:
                answer = min((key_str[:i] + substring + key_str[i + len(substring):]).replace("?", "a"), answer)
    print(answer if not answer == "z" * len(key_str) else "UNRESTORABLE")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func chmax(a *int64, b int64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func count(N, W int, ws []int, vs []int64) int64 {
	// Definition of DP
	var dp [101][100001]int64

	for i := 0; i < N; i++ {
		for sumW := 0; sumW <= W; sumW++ {
			if sumW-ws[i] >= 0 {
				chmax(&dp[i+1][sumW], dp[i][sumW-ws[i]]+vs[i])
			}
			chmax(&dp[i+1][sumW], dp[i][sumW])
		}
	}

	return dp[N][W]
}

func main() {
	var N, W int
	fmt.Scanf("%d %d", &N, &W)

	ws := make([]int, N)
	vs := make([]int64, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &ws[i], &vs[i])
	}

	fmt.Println(count(N, W, ws, vs))
}


Measured memory_bytes: 81792
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  string ans = "NO";
  for(int i = a; i <= b*a; i += a){
    if(i % b == c){
      ans = "YES";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int n;
    cin >> n;

    vector<vector<int>> a(2, vector<int>(n));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    vector<int> sum1(n);
    vector<int> sum2(n);
    int tmp1 = 0, tmp2 = 0;

    for (int i = 0; i < n; i++) {
        tmp1 += a[0][i];
        sum1[i] = tmp1;
    }
    for (int i = n-1; i >= 0; i--) {
        tmp2 += a[1][i];
        sum2[i] = tmp2;
    }

    vector<int> sum(n);
    for (int i = 0; i < n; i++) {
        sum[i] = sum1[i] + sum2[i];
    }
    
    cout << *max_element(sum.begin(), sum.end()) << endl;

    return 0; 

}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
 
struct Point {
    double x;
    double y;
};
void print(Point p) {
    printf("%.8f %.8f\n",p.x,p.y);
}
 
int n;
 
void koch(Point p1, Point p2,int depth) {
    if(n==depth) return;
    Point s;
    s.x = (2*p1.x+p2.x)/3;
    s.y = (2*p1.y+p2.y)/3;
 
    Point t;
    t.x = (p1.x+2*p2.x)/3;
    t.y = (p1.y+2*p2.y)/3;
 
    Point u;
    u.x=(t.x-s.x)/2-(t.y-s.y)*sqrt(3.0)/2+s.x;
    u.y=(t.x-s.x)*sqrt(3.0)/2+(t.y-s.y)/2+s.y;
 
    koch(p1,s,depth+1);
    print(s);
    koch(s,u,depth+1);
    print(u);
    koch(u,t,depth+1);
    print(t);
    koch(t,p2,depth+1);
}
 
int main() {
    cin>>n;
    Point p1,p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    print(p1);
    koch(p1,p2,0);
    print(p2);
 
    return 0;
}

Measured memory_bytes: 1200
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H, N = map(int, raw_input().split())
S = sum(map(int, raw_input().split()))
print "Yes" if H <= S else "No"

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dp[5050][5050];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i=N-1;i>=0;i--){
        for(int j=N-1;j>i;j--){
            if(S[i] == S[j]) chmax(dp[i][j],dp[i+1][j+1] + 1);
            chmin(dp[i][j],j-i);
            chmax(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 98688
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

const int MOD = 1000000007;
int main() {
    ll d, t, s; cin >> d >> t >> s;
    cout << ((t*s >= d) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

int main(){
	double x,y;
	int a,b,c,d,e,f;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(double)(a*f-d*c)/(a*e-d*b);
		x=(double)(b*f-e*c)/(b*d-a*e);
		//y+=0.0005;
		//x+=0.0005;
		if(x==0.0)x=fabs(x);
		if(y==0.0)y=fabs(y);
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 636
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
w=[[0,0,0] for i in range(0,M)]
for i in range(0,M):
    w[i][0],w[i][1],w[i][2]=map(int,input().split())

ans=min(a)+min(b)
for i in range(0,M):
    test=a[w[i][0]-1]+b[w[i][1]-1]-w[i][2]
    if test<ans:
        ans=test

print(ans)


Measured memory_bytes: 75972
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

vector<vector<char>> ban(55,vector<char>(55));
vector<vector<int>> ans(55,vector<int>(55));

int main() {
    int N;cin >> N;
    vector<double> retu(N);
    double avg = 0;
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
        avg += retu.at(i);
    }
    avg /= N;
    int ans = 0;
    double sa = 114514.0;
    for(int i = 0;i<N;i++){
        if(sa > abs(avg-retu.at(i))){
            sa = abs(avg-retu.at(i));
            ans = i;
        }
    }

    cout << ans << endl;
}


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

int main(){
  int a,b,t,ans;
  cin >> a >> b >> t;
  ans = 0;
  ans = t/a * b;
  if(t < a){
    ans = 0;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

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

var mem []int
var nMem []int

func main() {
	sc := newScanner()
	var n = sc.readInt64()
	var x = sc.readInt()
	var m = sc.readInt()

	var ans int64 = int64(x)
	mem = make([]int, 0, 100000)
	mem = append(mem, x)
	var a int64 = 1
	for i := 0; i < 100000; i++ {
		a++
		x = x * x % m
		if i, ok := contains(x); ok {
			nMem = mem[i:]
			var zanLen = (n - int64(len(mem)))
			ans += (zanLen / int64(len(nMem))) * sumI()
			var g = zanLen % int64(len(nMem))
			for j := 0; j < int(g); j++ {
				ans += int64(nMem[j])
			}
			break
		}
		mem = append(mem, x)
		ans += int64(x)
		if a == n {
			break
		}
	}
	fmt.Println(ans)
}

//////////////////
//////////////////
//////////////////

func contains(num int) (int, bool) {
	for i := range mem {
		if mem[i] == num {
			return i, true
		}
	}
	return -1, false
}

func sumI() int64 {
	var sum int64 = 0
	for i := range nMem {
		sum += int64(nMem[i])
	}
	return sum
}

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

int main()
{
    double n, m, x, sum=0;
    cin >> n >> m;

//    int arr[m];

    for(int i=1;i<=m;i++)
    {
        cin >>x;
        sum=sum+x;
    }

    if(sum>n) cout << "-1" <<endl;
    else if (sum==n) cout << "0" <<endl;
    else cout << n-sum << endl;

    return 0;
}



Measured memory_bytes: 3784
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
    int x, k;
    cin >> k >> x;
    if(500 * k >= x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 256
while true do
  str=gets.chomp
  if str=='0' then
    break
  else
    char=str.split(//)
    len=char.length
    num=Array.new
    sum=0
    for i in 0...len do
      num[i]=char[i].to_i
      sum+=num[i]
    end
    puts sum
  end
end

Measured memory_bytes: 8848
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int[] a = new int[N];
		int max = 0;
		int min = 1000000000;

		for (int i = 0; i < N; i++) {
			a[i] = reader.nextInt();
			if (a[i] > max) {
				max = a[i];
			}
			if (a[i] < min) {
				min = a[i];
			}
		}
		reader.close();
		System.out.print(Math.abs(max - min));
	}
}



Measured memory_bytes: 22736