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

int main(){
    int H, W;
    cin >> H >> W;
    vector<int> count(26, 0);
    for (int i = 0; i < H*W; i++) {
        char c;
        cin >> c;
        count[c-'a']++;
    }
    int s = 0, t = 0;
    for (int i = 0; i < 26; i++) {
        if (count[i] % 2 == 1) s++;
        if (count[i] % 4 >= 2) t++;
    }
    if (H*W % 2 == 1) {
        if (s == 1 && t*2 <= H+W-2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if (H%2 ^ W%2) {
        if (H % 2 == 1) swap(H, W);
        if (s == 0 && t*2 <= H) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if (H%2==0 && W%2==0) {
        if (s == 0 && t == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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


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

	int k;
	cin >> k;
	vector<string> q;
	for(int i = 1; i < 10; i++) {
		q.push_back(to_string(i));
	}
	
	for(int i = 0; i < (int) q.size() && (int) q.size() < k; i++) {
		string s = q[i];
		int last = s.back()-'0';
		for(int d = 0; d < 10; d++) {
			if(abs(last - d) <= 1) {
				s.push_back('0'+d);
				q.push_back(s);
				s.pop_back();
			}
		}
	}
	
	cout << q[k-1] << endl;
}


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

int main() {
  string S,T;
  cin>>S ;
  cin>>T ;
  int l=S.size();

  string ans="No";
  for (int k=0;k<l;k++){
    int c=0;
  for(int i=0;i<l;i++){
    int j=i+k;
    if(j>l-1)j-=l;
    c+=(S[i]==T[j]);
  }
  if(c==l){
    ans="Yes";
    break;}

  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
p_num, quantum = gets.split.map {|x| x.to_i }
process = Array.new
p_num.times do
  key, time = gets.split
  process << [key, time.to_i]
end

now = 0
while !process.empty? do
  buf = process.shift
  if buf[1] <= quantum then
    now += buf[1]
    puts "#{buf[0]} #{now}"
  else
    now += quantum
    buf[1] -= quantum
    process.push buf
  end
end

Measured memory_bytes: 19156
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int L = sc.nextInt();
		int R = sc.nextInt();
		int l = L % 2019;
		if (R - L > 2019 - l) {
			System.out.println(0);
			return;
		}
		
		int result = 2018;
		for (int i = l; i < l+R-L; ++i) {
			for (int j = i+1; j <= l+R-L; ++j) {
				result = Math.min(result, (i*j)%2019);
			}
		}
		
		System.out.println(result);
		
	}
	
	
	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22484
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

l = [""]*k
for i in range(n):
    l[i%k] += t[i]

res = 0
for x in l:
    prev = ""
    score = 0
    for i in range(len(x)):
        if x[i]=="r":
            if prev!="p":
                score += p
                prev = "p"
            else:
                prev = ""
        elif x[i]=="s":
            if prev!="r":
                score += r
                prev = "r"
            else:
                prev = ""
        else:
            if prev!="s":
                score += s
                prev = "s"
            else:
                prev = ""
    res += score

print(res)

Measured memory_bytes: 6132
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    string ans = "";
    ll v = 1;
    while(N > 0){
        if(N % 26 == 0){
            ans += 'z';
            N--;
            N /= 26;
            continue;
        }else{
            ll v = N % 26;
            char c = 'a' + v-1;
            ans += c;
        }
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    print(ans);

}

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

Measured memory_bytes: 3632
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

ans = 0
0.upto(n - 1) do |i|
  m1 = [a[i], b[i]].min
  a[i] -= m1
  b[i] -= m1

  m2 = [a[i + 1], b[i]].min
  a[i + 1] -= m2
  b[i] -= m2

  ans += m1 + m2
end
puts ans

Measured memory_bytes: 21516
n=int(input())
t,a=map(int,input().split())
lis=list(map(int,input().split()))
li=abs((t-lis[0]*0.006)-a)
l=0
for i in range(1,n):
    if abs((t-lis[i]*0.006)-a) < li:
        li=abs((t-lis[i]*0.006)-a)
        l=i
print(l+1)

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

int main()
{
    int c,k;
    int sum = 0,money = 0;
    vector<int> summoney;

    cin >> c >> k;
    
    for (int i = 0; i < c; i++)
    {
        cin >> money;
        summoney.push_back(money);
    }

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

    for (int j = 0; j < k; j++)
    {
        sum += summoney.at(j);
    }

    cout << sum << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
  int A, B;
  scanf("%d%d", &A, &B);
  if (A > B) swap(A, B);
  int diff = B - A;
  if (diff%2) printf("IMPOSSIBLE");
  else printf("%d", diff/2 + A);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::max;
using std::min;

int
main()
{
  int N;
  cin >> N;
  int max_value = 0;
  int min_value = 0;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    if (i == 0)
    {
      max_value = min_value = A;
    }
    else
    {
      max_value = max(max_value, A);
      min_value = min(min_value, A);
    }
  }
  cout << (max_value - min_value) << endl;
  return 0;
}


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

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

int main(){
  int N; cin >> N;
  long X; cin >> X;
  long x[N];
  long g=0; long mi=0; long ab;
  
  for(int i=0; i<N; i++){
    cin >> x[i];
    if(i==0){
      mi = labs(X-x[0]);
    }
    else{
      ab = labs(X-x[i]);
      if(ab<mi){mi=ab;}
    }
  }
  
  sort(x, x+N);
  for(int i=1; i<N; i++){
    if(i==1){g = labs(x[1]-x[0]);}
    else{g = gcd(g, labs(x[i]-x[i-1]));}
  }
  
  cout << gcd(mi, g);
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int a;
int b;
bool first=true;
while(cin>>a>>b,a*b){
if(first!=true){
cout<<endl;
}else{
first=false;
}
bool j=false;
for(int i=a;i<b+1;i++){
if(i%4==0){
if(i%400==0){
j=true;
cout<<i<<endl;
}else if(i%100==0){
}else{
j=true;
cout<<i<<endl;
}
}else{
}
}
if(j==false)cout<<"NA"<<endl;
}
return 0;
}

Measured memory_bytes: 1160
program garden
  implicit none

  integer :: n, min, max, i, cnt, j, k, t, s
  integer, allocatable :: h(:), h2(:)

  read(*,*) n
  allocate(h(n))
  allocate(h2(n))
  read(*,*) h

  min = minval(h)
  max = maxval(h)


     cnt = min

  
  do j = min, max
     do t = 1, n
        if(h(t) >= j) then
           h2(t) = h(t) - j 
        else
           h2(t) = 0
        end if

        
     end do
     
     do i = 1, n
        if (h2(i) >= 1) then
           if(product(h2(i:n)) == 0) then
              do k = i, n
                 if(h2(k) == 0) then
                    do s = i, k
                       h2(s) = 0
                    end do
                    
                    cnt = cnt + 1
                    exit
                 end if
              end do
              
           else
              cnt = cnt + 1
              exit
           end if
        end if
     end do
     
  end do

  write(*,*) cnt
end program garden

           


Measured memory_bytes: 256
import java.util.*;

public class Main {
        public static void main(String[] args){
            Scanner sc =new Scanner(System.in);
            int n = sc.nextInt();
            int[] h = new int[n];
            for(int i=0;i<n;i++){
                h[i] = sc.nextInt();
            }
            int max = h[0];
            int sum = 1;
            for(int j=1;j<n;j++){
                if(h[j]>=max){
                    sum++;
                    max=h[j];
                }
            }
            System.out.println(sum);
        }

        }


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}


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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

     ll m=b*d;
     ll t=max(b*c,max(a*c,a*d));
     if(m< t){
         cout<<t<<endl;
     }else{
         cout<< m<<endl;
     }
    /*if(a>=0 && c >=0){
        cout<< b*d <<endl;
    }
    else if(b <=0 && d < 0){
        cout<< a*c <<endl;
    }
    else if(b<0 && c>=0){
        cout<<b * c <<endl;
    }
    else if(a>=0 && d<0){
        cout<< a*d<<endl;
    }
    
*/
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


ll mo=1000000007;
ll comb(ll N_, ll C_) {
    const int NUM_=310000;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    ini(n);
    vpii tmp;
    FOR(i,0,n){
        ini(x);
        tmp.push_back({x,i});
    }
    sort(all(tmp));
    reverse(all(tmp));
    vector<vi>dp(n+1,vi(n+1,-INF));
    dp[0][0] = 0;
    FOR(i,0,n){
        int tmp1 = tmp[i].first;
        int pos = tmp[i].second;
        FOR(i1,0,i+1){
            dp[i1+1][i-i1] = max(dp[i1+1][i-i1],dp[i1][i-i1]+(abs(pos-i1)*tmp1));
            dp[i1][i-i1+1] = max(dp[i1][i-i1+1],dp[i1][i-i1]+(abs(pos-(n-1-(i-i1)))*tmp1));
        }
    }
    int rick = 0;
    FOR(i,0,n+1){
        rick = max(rick,dp[i][n-i]);
    }
    out(rick);
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 34616
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N = int(input())
    L = [list(map(int, input().split())) for i in range(N)]
    L.sort(key=lambda v: v[1])
    A_sum = 0
    for a, b in L:
        A_sum += a
        if (b < A_sum):
            print("No")
            return
    print("Yes")
resolve()

Measured memory_bytes: 62628
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int a,b;
    cin>>a;
    for(int i=0;i<9;i++){
      if(111*i<a&&111*(i+1)>=a){
        b=111*(i+1);
      }
    }
    cout<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)
int main(){
    int n;cin>>n;
    string s; cin>>s;
    vector<int> nw(n), nb(n);
    REP(i,n+1){
        if(i==0){
            nw[i]=0; nb[i]=0;
        } else {
            nw[i]=nw[i-1]+(s[i-1]=='.'?1:0);
            nb[i]=nb[i-1]+(s[i-1]=='#'?1:0);
        }
    }
    int ans=3e5;
    REP(i,n+1){
        int a = (nw[n]-nw[i])+(nb[i]-nb[0]);
        if(ans>a){ ans = a; }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   ll A; cin >> A;
   double B; cin >> B;

   ll b = round(B * 100);

   cout << (ll)(A * b / 100) << endl;
 }


Measured memory_bytes: 3780
Module Module1


    Sub main()
        Dim usr = Console.ReadLine()
        Dim startCode = Asc("A")
        Dim endCode = Asc("Z")
        Dim result = "a"

        If Asc(usr) >= startCode And Asc(usr) <= endCode Then
            result = "A"
        End If
        Console.WriteLine(result)
    End Sub
end Module

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数　
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define INTINF 1000000000
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000  //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

#define N_MAX 100
#define W_MAX 1000000000
#define v_MAX 1000

int main()
{
    int X;
    int A;
    int B;
    int ans;

    cin >> X >> A >> B;

    ans = (X - A) % B;

    cout << ans;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int c;
  cin >> c;
  int tmp = 0;
  int ans = 0;
  tmp = (a-b);
  ans = c- tmp;
  if(ans < 0) cout << "0" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456], cnt[213456][2];
signed main() {
	int n, m, a, b, sum = 0, ans = 0; string s, t; cin >> n >> m;
	if (n == 1 || m == 1) { cout << 1 << endl; }
	else {
		if (n * m % 2 == 0) { cout << n * m / 2 << endl; }
		else {
			cout << n * (m - 1) / 2 + n / 2 + 1 << endl;
		}
	}
	return 0;
}

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


  
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string s,t;
    cin>>s;
    cin>>t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++){
        for(int j=0;j<=t.length();j++)
        dp[i][j]=0;
    }
    for(int i=1;i<=s.length();i++){
        for(int j=1;j<=t.length();j++){
            if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string ans="";
    int i=s.length(),j=t.length();
    while(i>0&&j>0){
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
            i--;
            else
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}
    

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int n,k;
  IN2(n,k);
  vector<double>parray(n);
  FOR(i,n){
    cin >> parray.at(i);
  }
  vector<double>kitai(n);
  FOR(i,n){
    kitai.at(i) = (parray.at(i)+1)/2;
  }
  vector<double>ruiseki(n+1,0);
  FOR(i,n){
    ruiseki[i+1] = ruiseki[i] +kitai[i] ;
  }
  double ans;
  FOR(i,n-k+1){
    ans = max(ans,ruiseki[i+k]-ruiseki[i]);
  }
  cout << fixed << setprecision(10);
  OUT(ans);
}

Measured memory_bytes: 4992
#include<stdio.h>

int main() {
  int N;
  int Cost[20], Value[20];
  int diff;
  int max = 0;
  int i;

  scanf("%d", &N);

  for(i = 0; i < N; i++) {
    scanf("%d", &Value[i]);
  }

  for(i = 0; i < N; i++) {
    scanf("%d", &Cost[i]);
  }

  for(i = 0; i < N; i++) {
    diff = Value[i] - Cost[i];
    if(diff > 0) max += diff;
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int arr[4][4];
    for(int i=1;i<4;i++){
        for(int j =1;j<4;j++){
            cin>>arr[i][j];
        }
    }
    int a1,a2,a3,b1,b2,b3;
    a1=0;
    b1=arr[1][1];
    b2=arr[1][2];
    b3=arr[1][3];
    a2 = arr[2][2] - b2;
    a3 = arr[3][3] - b3;
    int data[3][4] = {{-1,-1,-1,-1},{-1,a1,a2,a3},{-1,b1,b2,b3}};
    for(int i=1,m =1;i<4 && m <=3;i++,m++){
        for(int j =1,n =1;j<4 && n <=4;j++,n++){
            if(data[1][m]+data[2][n]!=arr[i][j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;




}








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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

    int H, W;
    cin >> H >> W;

    vector<vector<int>> matrix(10, vector<int>(10));

    FOR(y, 0, 10) {
        FOR(x, 0, 10) {
            cin >> matrix[y][x];
        }
    }

    const unsigned long num_node = matrix.size();

    // 自分の距離は0
    for (int i = 0; i < num_node; ++i) {
        matrix.at(i).at(i) = 0;
    }

    for (int m = 0; m < num_node; ++m) {
        for (int s = 0; s < num_node; ++s) {
            for (int e = 0; e < num_node; ++e) {
                // sからeへmを経由して到達可能
                if (matrix.at(s).at(m) != INT_MAX and matrix.at(m).at(e) != INT_MAX) {
                    matrix.at(s).at(e) = std::min(matrix.at(s).at(e), matrix.at(s).at(m) + matrix.at(m).at(e));
                }
            }
        }
    }

    // 負閉路チェック
    for (int u = 0; u < num_node; ++u) {
        if (matrix.at(u).at(u) < 0) {
            return {};
        }
    }

    LL ans = 0;
    FOR(y, 0, H) {
        FOR(x, 0, W) {
            int a;
            cin >> a;
            if (a != -1) {
                ans += matrix[a][1];
            }
        }
    }

    print(ans);

    return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), t = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		SegTree st = new SegTree(n);
		for(int i=0;i<n;i++) {
			st.update(i,a[i]);
		}
		
		int max = 0;
		List<Integer> sels = new ArrayList<>(),  buys = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int buy = a[i];
			int sel = st.getMax(i+1, n, 0, 0, -1);
			if(sel-buy>max) {
				max = sel - buy;
				sels = new ArrayList<>();
				buys = new ArrayList<>();
				sels.add(sel);
				buys.add(buy);
			}
			else if(sel - buy == max) {
				sels.add(sel);
				buys.add(buy);
			}
		}
		Map<Integer,Integer> smp = new HashMap<>();
		for(int tmp:sels) {
			if(smp.containsKey(tmp))smp.put(tmp, smp.get(tmp)+1);
			else smp.put(tmp, 1);
		}
		Map<Integer,Integer> bmp = new HashMap<>();
		for(int tmp:buys) {
			if(bmp.containsKey(tmp))bmp.put(tmp, bmp.get(tmp)+1);
			else bmp.put(tmp, 1);
		}
		
		int ans = 0;
		for(int key:smp.keySet()) {
			int snum = smp.get(key);
			int bnum = bmp.get(key-max);
			int min = Math.min(snum, bnum);
			ans += min;
		}
		
		System.out.println(ans);
		
	}
}

class SegTree{
	int n;
	int seg[];
	SegTree(int k){
		n = 1;
		while(n<k)n*=2;
		seg = new int[2*n-1];
	}
	
	int getMax(int x, int y, int k, int l, int r){
		if(r < 0)r = n;
		if(x>=r||y<=l)return -1;
		if(x<=l&&y>=r)return seg[k];
		int res = 0;
		res = Math.max(res, getMax(x,y,2*k+1,l,(l+r)/2));
		res = Math.max(res, getMax(x,y,2*k+2,(l+r)/2,r));
		return res;
	}
	
	void update(int i, int v) {
		i += (n-1);
		seg[i] = v;
		while(i>0) {
			i = (i-1)/2;
			seg[i] = Math.max(seg[2*i+1], seg[2*i+2]);
		}
	}
}


//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 45816
import itertools
D,G=map(int,input().split())
p=[0 for i in range(D)]
c=[0 for i in range(D)]
for i in range(D):
    p[i],c[i]=map(int,input().split())

S=list(itertools.product(range(2),repeat=D))
ans=sum(p)
for seq in S:
    score=0
    prove=0
    for i in range(D):
        if seq[i]==1:
            score+=(p[i]*100*(i+1)+c[i])
            prove+=p[i]
    if score>=G:
        if ans>prove:
            ans=prove
        continue
    j=-1
    for i in range(D):
        if seq[i]==0:
            j=i
    for k in range(p[j]):
        prove+=1
        score+=100*(j+1)
        if G<=score:
            break
    if G>score:
        continue
    if ans>prove:
        ans=prove
print(ans)


Measured memory_bytes: 3188
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int x,y,z;

	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
    

    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 256
insideRectangle :: [Integer] -> String
insideRectangle [w, h, x, y, r]
    | x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h  = "Yes"
    | otherwise                                             = "No"

main = do
    given_str <- getLine
    putStrLn((insideRectangle . map read . words) given_str)

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	ll D;
	cin >> D;
	vl C(26);
	for (i = 0; i < 26; i++) cin >> C[i];
	vll S(D, vl(26));
	for (i = 0; i < D; i++) {
		for (j = 0; j < 26; j++) {
			cin >> S[i][j];
		}
	}
	vl T(D);
	vl last(26, -1);
	for (i = 0; i < D; i++) {
		ll pre = 0;
		for (j = 0; j < 26; j++) {
			if (S[i][j]+C[j]*105 > S[i][pre]+C[pre]*105) {
				pre = j;
			}
		}
		T[i] = pre;
	}
	//exit(0);
	//debug用
	for (i = 0; i < D; i++) {
		ans += S[i][T[i]];
		last[T[i]] = i;
		for (j = 0; j < 26; j++) {
			ans -= C[j] * (i - last[j]);
		}
	}
	debug(ans);
	for (ll loop = 0; loop < 10; loop++) {
		for (k = 0; k < D; k++) {
			ll pre2 = 0;
			for (l = 0; l < 26; l++) {
				T[k] = l;
				ll pre = 0;
				vl last2(26, -1);
				for (i = 0; i < D; i++) {
					pre += S[i][T[i]];
					last2[T[i]] = i;
					for (j = 0; j < 26; j++) {
						pre -= C[j] * (i - last2[j]);
					}
				}
				//debug(pre);
				if (ans < pre) {
					ans = pre;
					pre2 = l;
				}
			}
			T[k] = pre2;
		}
	}
	debug(ans);
	for (i = 0; i < D; i++) {
		co(T[i]+1);
	}
}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string atcoder, s, contest;
    cin >> atcoder >> s >> contest;

    cout << atcoder[0] << s[0] << contest[0] << endl;
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc156_a.cpp
 * time   : Sat May  2 19:27:06 2020
 * quest  : A - Beginner
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  cout << ((n >= 10) ? r : (r + 100 * (10 - n))) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

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



int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    Rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(All(a),greater<int>());
    Rep(i,n){
        if(a[0] != b[i]){
            cout << a[0] << "\n";
        }else{
            cout << a[1] << "\n";
        }
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;
void dfs(const _Graph &G, int v, int color) {
    bool flag = true;
    seen[v] = true; // v を訪問済にする
    colors[v] = color;

    // v から行ける各頂点 next_v について
    REP(i, G[v].size()) { 
        int next_v = G[v][i].to;
        if( seen[next_v] == true ) continue; // next_v が探索済だったらスルー
        if(G[v][i].cost % 2 == 0) dfs(G, next_v, color);
        else dfs(G, next_v, -color); // 再帰的に探索=もぐる 
        
    }

}


int main() {
    // 頂点数と辺数
    int N; cin >> N;
    int count = 0;

    // グラフ入力受取 (ここでは無向グラフを想定)
    _Graph _G(N);
    for (int i = 0; i < N-1; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge e = { b,c };
        _G[a].push_back(e);
        e = { a,c };
        _G[b].push_back(e);
    }

   // 頂点 0 をスタートとした探索
   bool istree;
   seen.assign(N, false); // 全頂点を「未訪問」に初期化
   colors.assign(N, 0); // 全頂点を「未訪問」に初期化

    dfs(_G, 0, 1);

   //cout << istree << endl;
   REP(i, N){
       if(colors[i] < 0)colors[i] = 0;
       cout << colors[i] << endl;
   }
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int main(){
    RS(s);
    int x=0,an=0;
    for(int i=0;s[i];i++){
        if(s[i]=='g'){
            if(x>0){
                an++;
                x--;
            }
            else x++;
        }
        else{
            if(x>0){
                x--;
            }
            else{
                x++;
                an--;
            }
        }
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  	long long l,r;
  	long long ans=2*1e+9;
	cin>>l>>r;
  
  if(r-l>=2019){
	cout<<0<<endl;
    return 0;
  }
  for(long long i=l;i<r;i++){
  	for(long long j=l+1;j<=r;j++){
  	if(i<j&&i!=j&&ans>(i*j)%2019)ans=(i*j)%2019;
  	}
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int d[102][102];
int h[100005], l;
int comp_h(int a, int b)
{
	a = h[a];
	b = h[b];
	if (d[a / 102][a % 102] > d[b / 102][b % 102])
		return 1;
	return -1;
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void f1(int n)
{
	h[l] = n;
	int now = l;
	l++;
	while (now > 0)
	{
		if (comp_h((now - 1) / 2, now) > 0)
			swap_h((now - 1) / 2, now);
		now = (now - 1) / 2;
	}
	return;
}
int f2()
{
	l--;
	swap_h(0, l);
	int now = 0;
	for (;;)
	{
		if (2 * now + 2 < l)
		{
			if (comp_h(2 * now + 1, 2 * now + 2) > 0)
			{
				if (comp_h(now, 2 * now + 2) > 0)
					swap_h(now, 2 * now + 2);
				now = 2 * now + 2;
			}
			else
			{
				if (comp_h(now, 2 * now + 1) > 0)
					swap_h(now, 2 * now + 1);
				now = 2 * now + 1;
			}
		}
		else if (2 * now + 1 < l)
		{
			if (comp_h(now, 2 * now + 1) > 0)
				swap_h(now, 2 * now + 1);
			now = 2 * now + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i, j;
	char s[102][102];
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			d[i][j] = 1000000009;
	l = 0;
	if (s[h - 1][w - 1] == '#')
		d[h - 1][w - 1] = 1;
	else
		d[h - 1][w - 1] = 0;
	f1(102 * (h - 1) + w - 1);
	while (l > 0)
	{
		i = f2();
		j = i % 102;
		i /= 102;
		if (i > 0)
		{
			if (s[i][j] == s[i - 1][j])
			{
				if (d[i - 1][j] > d[i][j])
				{
					d[i - 1][j] = d[i][j];
					f1(102 * (i - 1) + j);
				}
			}
			else
			{
				if (d[i - 1][j] > d[i][j] + 1)
				{
					d[i - 1][j] = d[i][j] + 1;
					f1(102 * (i - 1) + j);
				}
			}
		}
		if (j > 0)
		{
			if (s[i][j] == s[i][j - 1])
			{
				if (d[i][j - 1] > d[i][j])
				{
					d[i][j - 1] = d[i][j];
					f1(102 * i + j - 1);
				}
			}
			else
			{
				if (d[i][j - 1] > d[i][j] + 1)
				{
					d[i][j - 1] = d[i][j] + 1;
					f1(102 * i + j - 1);
				}
			}
		}
	}
	if (s[0][0] == '#')
		d[0][0]++;
	printf("%d\n", d[0][0] / 2);
	return 0;
}

Measured memory_bytes: 256
def warshall_floyd(n, d):
    for i in range(n):
        for j in range(n):
            for k in range(n):
                d[j][k] = min(d[j][k], d[j][i] + d[i][k])


H, W = map(int, input().split())

N = 10
d = [None] * N
for i in range(N):
    d[i] = list(map(int, input().split()))

warshall_floyd(N, d)

c = {i: 0 for i in range(N)}
for i in range(H):
    for j in map(int, input().split()):
        if j == -1:
            continue
        c[j] += 1

print(sum(c[i] * d[i][1] for i in range(N)))


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

int main(int argc, const char * argv[]) {
    int n,x;
    while(1){
        cin>>n>>x;
        if(n==0&&x==0){
            break;
        }
        int count=0;
        
        for(int i=1;i!=n+1;++i){
            for(int j=i+1;j>i&&j<n+1;++j){
                for(int k=j+1;k>j&&k<n+1;++k){
                    if(i+j+k==x){
                        ++count;
                    }
                }
            }
            
        }
        cout<<count<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
   cin>>n;
   DL x=(DL)n;
   DL y=(x/3.00);
   printf("%0.12lf\n",y*y*y);
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  if len(s)%2==1:
    return 'No'
  if len(s)//2==s.count('hi'):
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 6096
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;


int n;
const int maxN = 1e5 + 1;
ll a[maxN];
const ll limit = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> n;
    int zero = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) zero = 1;
    }
    if (zero) {
        cout << 0 <<endl;
        return 0;
    }
    ll res = 1;
    int flag = 0;
    for (int i = 0; i < n; i++) {
        if (res > limit / a[i]) {
            flag = 1;
        } 
        res *= a[i];
    }
    if (flag) {
        cout << -1 <<endl;
    } else {
        cout << res <<endl;
    }
    return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

int n;
vector<pii> a;

map<int,int> pf(int m){
  map<int,int> res;
  FOR(i,2,sqrt(m)+1){
    if(m == 1) break;
    while(m%i == 0){
      res[i]++;
      m /= i;
    }
  }
  if(m != 1) res[m]++;
  return res;
}

int rec(vector<pii> &b, int j){
  if(j == sz(b)){
    dump(b);
    int m = 1;
    rep(k,sz(b)) rep(x,b[k].snd) m *= b[k].fst;
    if(n % m == 0 and n/m < m-1){
      return m-1;
    }else return 0;
  }

  int tmp = 0;
  b[j].fst = a[j].fst;
  int nextj = j+1;
  rep(k,a[j].snd+1){
    b[j].snd = k;
    tmp += rec(b, nextj);
  }
  return tmp;
}

signed main(){
  cin >> n;
  map<int,int> f = pf(n);
  for(auto x : f)
    a.pb(x);
  
  vector<pii> init(sz(a));
  int i = 0;
  int ans = rec(init, i);
  //cout << ans + (n-1) << endl;
  cout << ans << endl;
}

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

int main(){
	// sengen
	LL w,h,x,y;
	// nyuryoku
	cin >> w >> h >> x >> y;
	// keisan
	double ans;
	ans = (double)w*h/2;
	int flag = (x + x == w)&&(y + y == h);
	printf("%lf %d\n",ans,flag);
	// syutsuryoku
}

Measured memory_bytes: 3708