akhauriyash/Code-Regression huggingface dataset:
program codefestival_2016_qualA_c
    use,intrinsic :: iso_fortran_env
    implicit none
    character(1000000):: s
    integer(int64):: k,n,i,cost,nind

    read*, s
    n = len_trim(s)
    read*, k

    do i=1,n
        if (s(i:i) == 'a') cycle
        cost = 1+ichar('z') - ichar(s(i:i))
        if (cost <= k) then
            s(i:i) = 'a'
            k=k-cost
        end if
    end do
    nind = (ichar(s(n:n)) - ichar('a'))
    
    s(n:n) = char(mod(nind+k, 26_8) + ichar('a'))

    print'(a)', trim(s)
end program codefestival_2016_qualA_c

Measured memory_bytes: 1596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0) puts("0");
	else printf("%lld",MIN(a*b,MIN(b*c,c*a)));
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
long long ans=0,height=0;
long long cal(long long a,long long b)
{
    long long s=1;
    for(long long i=1;i<=b;i++)
    {
        s*=a;
    }
    return s;
}
int main()
{
    long long h;
    scanf("%lld",&h);
    while(h)
    {
        if(h==1||h==0)
        {
            ans+=cal(2LL,height);
        }
        else
        {
            ans+=cal(2LL,height);
            height++;
        }
        h/=2;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
    unsigned long long k,n=0,m;
    int i;
    string s;
    cin >> s >> k;

    for(i=0;i<s.size();i++)
    {
        if(s[i]!='1')
        {
            cout << s[i] << endl;
            break;
        }
        if(s[i]=='1')
            n++;
        if(n>=k)
        {
            cout << s[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool stA = false;
  bool stB = false;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'A') stA = true;
    if (S[i] == 'B') stB = true;
  }
  if (stA && stB)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>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; }
const int MOD = 998244353;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 0; i < K; i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define w 0
#define g 1
#define b 2
int a[101][101];
int n,color[101],d[101],f[101],tt;
void dfs_v(int u)
{  int v;
   color[u]=g;
   d[u]=++tt;
   for(v=0;v<n;v++)
   {  if(a[u][v]==0)  continue;
      if(color[v]==w) dfs_v(v);
   }
   color[u]=b;
   f[u]=++tt;
}
void dfs()
{  int u;
   for(u=0;u<n;u++)  color[u]=w;
   tt=0;
   for(u=0;u<n;u++)
     if(color[u]==w)  dfs_v(u);
   for(u=0;u<n;u++)
     printf("%d %d %d\n",u+1,d[u],f[u]);
}
int main()
{  int i,t,k,p,j,u;
   scanf("%d",&n);
   k=n;
   for(i=0;i<n;i++)
     for(j=0;j<n;j++)
       a[i][j]=0;
   while(k)
   {  scanf("%d%d",&t,&p);
      t=t-1;
      for(i=0;i<p;i++)
      {  scanf("%d",&u);
         u=u-1;
         a[t][u]=1;
      }
      k--;
   }
   dfs();
}


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

int main(void){

    const double pi = 3.141592653589;
    double r;

    double area;
    double circumference;
    
    std::cin >> r;
    
    area = r * r * pi;
    circumference = 2 * (double)r * pi;
    
    printf("%.5lf %.5lf", area, circumference);

    return 0;
}

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

int solve(vector<int>& latest, vector<int>& before, int curr, int x){
    int best=curr;
    for(int i=0; i<latest.size(); i++) {
        if((1<<i)&x)
            best = min(best, curr-latest[i]);
        else
            best = min(best, curr-before[i]);
    }
    return best;
}

int main() {
    int n;
    cin>>n;
    vector<int> v(n+1);
    vector<int> latest(21, 0), before(21, 0);
    long long ans = 0;
    for(int i=1; i<=n; i++){
        cin>>v[i];
        ans += solve(latest, before, i, v[i]);
        for(int j=0; j<21; j++) {
            if(v[i]&(1<<j)){
                before[j] = latest[j];
                latest[j] = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;

const int N=1005;

struct node{
	int x,y;
	node(){}
	node(int x,int y):x(x),y(y){}
};
int n,m,d,sx,sy,x,y,ans;
int dx[4]={0,1,-1,0},dy[4]={1,0,0,-1},dep[N][N];
bool vis[N][N];
char s[N][N];
queue<node> q;

int main(){
	int i,j; node k;
	scanf("%d%d%d",&n,&m,&d);
	for (i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for (j=1;j<=m;j++) if (s[i][j]=='S') sx=i,sy=j;
	}
	q.push(node(sx,sy)); ans=n+m;
	vis[sx][sy]=1;
	while (!q.empty()){
		k=q.front(); q.pop();
		x=k.x; y=k.y;
		ans=min(ans,min(min(x-1,n-x),min(y-1,m-y)));
		if (dep[x][y]==d) continue;
		for (i=0;i<4;i++){
			x=k.x+dx[i]; y=k.y+dy[i];
			if (x<1||x>n||y<1||y>m) continue;
			if (vis[x][y]||s[x][y]!='.') continue;
			dep[x][y]=dep[k.x][k.y]+1;
			vis[x][y]=1;
			q.push(node(x,y));
		}
	}
	printf("%d\n",(ans+d-1)/d+1);
	return 0;
} 

Measured memory_bytes: 4992
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
d,x = gi
a = []
rep n do
  a << gif
end

ans = x

a.each do |aa|
  i = 0
  while aa*i+1 <= d
    ans += 1
    i+=1
  end
end
puts ans


Measured memory_bytes: 2300
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug == false) {
            return;
        }
        System.out.println(str);
    }

    public static void main(String[] args) {

        int  N;
        int[] pList;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            pList = new int[N];
            for(int i =0 ; i < N;i++){
                pList[i] = sc.nextInt();
            }
        }

        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for(int i : pList){
            queue.add(i);
        }
        int h = N /2;
        int under = 0;
        int top = 0;
        for(int i = 0;i < h;i++){
            under = queue.poll();
        }
        top = queue.poll();


        debug(under+"");
        debug(top+"");
        int result = 0;
        if(under <top){
            result = top -under;
        }
        System.out.println(result);

    }

}


Measured memory_bytes: 50224
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
c = n.times.map { |i| (x[i] - y[i]).abs }
p c.sum
p c.map { |i| i ** 2 }.sum ** 0.5
p c.map { |i| i ** 3 }.sum ** (1 / 3.to_f)
p c.max


Measured memory_bytes: 6928
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    # parse input
    N, D = map(int, input().split())
    count = 0
    for i in range(N):
        X, Y = map(int, input().split())
        if X * X + Y * Y <= D * D:
            count += 1

    print(count)


# tests
T1 = """
4 5
0 5
-2 4
3 4
4 -4
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
"""

T2 = """
12 3
1 1
1 1
1 1
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
result
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 9312
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int r;
    int ans;
    cin >> r;
    ans = r*r;
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if (a == 1) or (b == 1):
    if (a ==1) and (b != 1):
        print('Alice')
    elif (a != 1) and (b == 1):
        print('Bob')
    else:
        print('Draw')
    exit()
if a > b:
    print('Alice')
elif a == b:
    print('Draw')
else:
    print('Bob')

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

int main(void) {
  string S, ans;
  cin >> S;
  int l, d;
  
  l = (S[0]-'0')*10 + (S[1]-'0');
  d = (S[2]-'0')*10 + (S[3]-'0');
  
  if(l>=1 && l<=12){
    if(d>=1 && d<=12)
      ans = "AMBIGUOUS";
    else
      ans = "MMYY";
  }
  else{
    if(d>=1 && d<=12)
      ans = "YYMM";
    else
      ans = "NA";
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  int a, b, c; cin >> a >> b >> c;
  if (c>=a && c<=b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
target_strings = input()
num_of_order = int(input())

for i in range(num_of_order):
    order = input().split(" ")
    if order[0] == "replace":
        target_strings = target_strings[:int(order[1])] + \
        order[3] + target_strings[int(order[2])+1:]
    
    elif order[0] == "reverse":
        string2 = target_strings[int(order[1]):int(order[2])+1]
        target_strings = target_strings[:int(order[1])] + \
        string2[::-1] +\
        target_strings[int(order[2])+1:]
       
    else:
        print(target_strings[int(order[1]):int(order[2]) + 1])


Measured memory_bytes: 5616
#include <iostream>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
    int n,k;cin>>n>>k;
    int a = k;
    k--;
    int b = pow(k,n-1);
    cout << a * b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, ll>;

int main()
{
    int x[4], y[4];
    for (int i = 0; i < 2; ++i) cin >> x[i] >> y[i];
    
    int dx = x[1] - x[0];
    int dy = y[1] - y[0];


    x[2] = x[1] - dy, y[2] = y[1] + dx;
    x[3] = x[0] - dy, y[3] = y[0] + dx;
    
    printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a[4],b[4],i,j;
  const int k[4][4]={
    { 1, 2, 3, 4},
    { 2,-1, 4,-3},
    { 3,-4,-1, 2},
    { 4, 3,-2,-1}
  };
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      int c[4]={0};
      for(j=0;j<4;j++)scanf("%d",&a[j]); 
      for(j=0;j<4;j++)scanf("%d",&b[j]);
      for(j=0;j<16;j++){
	if(k[j/4][j%4]>0)c[k[j/4][j%4]-1]+=a[j/4]*b[j%4];
	else        c[-1*(k[j/4][j%4]+1)]-=a[j/4]*b[j%4];
      }
      printf("%d %d %d %d\n",c[0],c[1],c[2],c[3]);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(a[i]>a[i-1]&&a[i]<a[i+1]) ans++;
    if(a[i]<a[i-1]&&a[i]>a[i+1]) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && a != c) {
    cout << "Yes" << endl;
  } else if (a == c && a != b) {
    cout << "Yes" << endl;
  } else if (b == c && c != a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

a = INT()
b = INT()
arr = [1, 2, 3]
for i in range(3):
    if a != arr[i] and b != arr[i]:
        print(arr[i])

Measured memory_bytes: 60268
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  char x;
  cin >> x;
  if(x <= 'Z') cout << "A" << endl;
  else cout << "a" << endl;
}

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

int main() {
  int N,a,b,c,d;
  
  cin >> N ;
  
  a=N/1000;
  b=(N-1000*a)/100;
  c=(N-1000*a-100*b)/10;
  d=(N-1000*a-100*b-10*c);
    
  if (a==b && b==c) {
    cout << "Yes" << endl;
    }
  else if (b==c && c==d){
    cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
   }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

enum ePhase{Right = 0,DownLeft,Down,UpRight,PhaseMax};
using namespace std;
#define MAX 12

void downLeft(int N, int m[][MAX], int &i, int &j){
  int t = m[i][j];
  do{
    m[++i][--j] = ++t;
  }while( j > 1 && i < N );
}
void upRight(int N, int m[][MAX], int &i, int &j){
  int t = m[i][j];
  do{
    m[--i][++j] = ++t;
  }while( i > 1 && j < N );
}

int main(){
  int CaseNumber = 1;
  int map[MAX][MAX];
  while( true ){
    int N;
    int i, j;
    int progress = 1;
    int phase = Right;

    cin >> N;
    if( N == 0 ) break;

    cout << "Case " << CaseNumber << ":\n";
    CaseNumber++;

    i = 1; j = 1;
    map[i][j] = 1;
    while( progress <= N * N ){
      switch( phase ){
      case Right:
	++j;
	if( j > N ){
	  //phase = Down;
	  --j;
	  ++i;
	}
	break;
      case DownLeft:
	downLeft( N, map, i, j );
	progress = map[i-1][j+1];
	break;
      case Down:
	++i;
	if( i > N ){
	  //phase = Right;
	  --i;
	  ++j;
	}
	break;
      case UpRight:
	upRight( N, map, i, j );
	progress = map[i+1][j-1];
	break;
      }
      phase = ( phase + 1 ) % PhaseMax;
      map[i][j] = ++progress;
    }

    for(int i = 1; i <= N; ++i){
      cout << setw(3) << map[i][1];
      for(int j = 2; j <= N; ++j){
	cout << setw(3) << map[i][j];
      }
      cout << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 0
H, W = list(map(int, input().split()))
A = [['' for i in range(W + 1)] for j in range(H + 1)]
dp = [[0 for i in range(W + 1)] for j in range(H + 1)]
for i in range(1, H + 1):
    a = input()
    for j in range(W):
        A[i][j + 1] = a[j]
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if A[i][j] == '#':
            dp[i][j] = 0
        elif i == 1 and j == 1:
            dp[i][j] = 1
        elif i == 1:
            dp[i][j] = dp[i][j - 1]
        elif j == 1:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
print(dp[H][W] % 1000000007)


Measured memory_bytes: 166172
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int mod=1e9+7,M=2e5+10;
int s[M],a[M],n;
int main(){
	n=read();
	LL ans=0;
	F(i,1,n){
		a[i]=read();
		ans=(ans+1ll*a[i]*s[i-1])%mod;
		s[i]=s[i-1]+a[i];
		s[i]%=mod;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 5080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, long[] A)
        {
            int[] zeros = new int[60];
            int[] ones = new int[60];
            foreach (long a in A)
            {
                for (int i = 0; i < 60; ++i)
                {
                    if (((1L << i) & a) != 0) { ++ones[i]; } else { ++zeros[i]; }
                }
            }
            const int M = 1000000007;
            long ans = 0;
            for (int i = 0; i < 60; ++i)
            {
                ans += (((1L << i) % M) * (Math.BigMul(zeros[i], ones[i]) % M)) % M;
                ans %= M;
            }
            return ans;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(N, A));
        }
    }
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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


Measured memory_bytes: 256
def main():
    import collections
    import copy
    N,K = map(int, input().split())
    V = collections.deque(map(int, input().split()))

    answer = [[0]*(K+1) for _ in range(K+1)]


    for i in range(1,K+1):
        for j in range(max(1,i//2),min(i+1,N+1)):
            opt = 0
            for k in range(j+1):
                tmp = copy.deepcopy(V)
                tmp2 = collections.deque()
                for _ in range(k):
                    tmp2.append(tmp.popleft())
                for _ in range(j-k):
                    tmp2.append(tmp.pop())
                tmp2 = list(tmp2)
                tmp2.sort()
                for l in range(min(i-j,j)):
                    if tmp2[l] < 0:
                        tmp2[l] = 0
                S = sum(tmp2)
                if S > opt:
                    opt = S
            answer[i][j] = opt
    Ans = 0
    for i in range(K+1):
        for j in range(K+1):
            if answer[i][j] > Ans:
                Ans = answer[i][j]
    print(Ans)

main()

Measured memory_bytes: 61148
#include<bits/stdc++.h>
using namespace std;
int n,m,f[233333],vis[233333];
vector<int>v[233333];
queue<int>q;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	q.push(1);vis[1]=1;
	while(!q.empty()){
		int t=q.front();q.pop();
		for(int i=0;i<v[t].size();i++){
			int x=v[t][i];
			if(vis[x])continue;
			f[x]=t;
			vis[x]=1;
			q.push(x);
		}
	}
	int flg=1;
	for(int i=1;i<=n;i++)flg&=vis[i];
	if(flg){
		puts("Yes");
	    for(int i=2;i<=n;i++)printf("%d\n",f[i]);
	}else puts("No");
}

Measured memory_bytes: 14164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;
#define all(vec) vec.begin(),vec.end()
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;

const int dy[4]={0,0,1,-1};
const int dx[4]={1,-1,0,0};
int R,C,sy,sx,gy,gx;
vector<string> graph;
int hosuu[22][22];

int main(){
  cin >> R >> C;
  graph.resize(R);//ここが書けてなかった
  rep(i,R){
    cin >> graph[i];
  }
   vector<i_i> res(0);
  rep(i,R){
    rep(j,C){
      if(graph[i][j]=='.'){
        res.push_back(make_pair(i,j));
      }
    }
  }
  int ans=0;
  for(int k=0;k<res.size();k++){
    rep(i,R) rep(j,C) hosuu[i][j]=0;
    int sy=res[k].first;
    int sx=res[k].second;
    queue<pair<int,int> > q;
    q.push(make_pair(sy,sx));
    while(!q.empty()){
      int y,x;
      tie(y,x)=q.front();
      q.pop();
      rep(dir,4){
        int ny=y+dy[dir];
        int nx=x+dx[dir];
        if(0<=ny&&ny<R&&0<=nx&&nx<C&&graph.at(ny).at(nx)=='.'&&hosuu[ny][nx]==0){//ここが書けてなかった
          hosuu[ny][nx]=hosuu[y][x]+1;
          q.push(make_pair(ny,nx));
        }
      }
      hosuu[sy][sx]=-1;
    }
    rep(i,R){
      rep(j,C){
        if(hosuu[i][j]>ans) ans=hosuu[i][j];
      }
    }
  }
  cout << ans << endl;
  
  /*
  priority_queue<int> que;
  rep(i,R){
    rep(j,C){
      que.push(hosuu[i][j]);
    }
  }
  int ans1=que.top();
  que.pop();
  int ans2=que.top();
  cout << ans1+ans2 << endl;
  rep(i,R){
    rep(j,C){
      if(j==C-1){
        cout << hosuu[i][j] << endl;
        continue;
      }
      cout << hosuu[i][j];
    }
  } 
  cout << sy << sx << endl;
  */
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string line1;
    string line2;
	getline(cin, line1);
  	getline(cin,line2);
    for(int i = 0; i<line1.size();i++) {
        if(line1[i] != line2[i]) {
            cout << "No\n";
            return 0; 
        }
    }
    if(line2.size() == line1.size()+1){
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>
#include<iomanip>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	int n;
	cin >> n;
	double p[n];
	for (int i = 0;i < n;++i) {
		cin >> p[i];
	}
	double dp[n+1][n+1];
	dp[0][0] = 1;
	for (int i = 1;i <= n;++i) {
		dp[0][i] = 0;
	}
	for (int i = 1;i <= n;++i) {
		dp[i][0] = dp[i-1][0]*(1.0-p[i-1]);
	}
	for (int i = 1;i <= n;++i) {
		for (int j = 1;j <= n;++j) {
			if (j > i) {
				dp[i][j] = 0;
				continue;
			} 
			dp[i][j] = dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*p[i-1];
		}
	}
	double ans = 0;
	for (int i = n/2+1;i <= n;++i) {
		ans += dp[n][i];
	}
	cout << fixed << setprecision(10) << ans << '\n';
	return;
}

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



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

int main(){
  int n,m;
  cin>>n>>m;
  int k[m],s[m][20];
  for(int i=0;i<m;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      cin>>s[i][j];
    s[i][j]--;
    }
  }
  int p[m];
  for(int i=0;i<m;i++) cin>>p[i];
  	int ans=0;
 	 for(int bit=0;bit<(1<<n);bit++){
    	int a=0;
    
    	for(int i=0;i<m;i++){
      	  int count=0;	
          for(int j=0;j<k[i];j++){
        		if(bit&(1<<s[i][j])) count++;
            }
            if(count%2==p[i]) a++;
        }
	    if(a==m) ans++;
     }

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

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    ll ans = 1e9;
    rep(bit, 1 << n) {
        int b[m] = {0};
        ll cost = 0;
        rep(i, n) {
            if (bit & (1 << i)) {
                rep(j, m) b[j] += a[i][j];
                cost += c[i];
            }
        }
        bool ok = true;
        rep(i, m) if (b[i] < x) ok = false;
        if (ok) ans = min(ans, cost);
    }

    if (ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int INF = 1001001001;
int h, w; 
int ch, cw, dh, dw; 
vector<string> s;
vvi cnt;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<P> now, nxt;
vector<vector<bool>> seen;

void dfs(int x, int y, int depth){
    nxt.pb({x, y});
    seen[x][y] = true;
    cnt[x][y] = min(cnt[x][y], depth);
    rep(i, 4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx < 0 || nx >=h || ny < 0 || ny >= w) continue;
        if(s[nx][ny] == '#') continue;
        if(seen[nx][ny]) continue;
        dfs(nx, ny, depth);
    }
}

void dfs2(int x, int y, int depth){
    rep(i, 5){
        rep(j, 5){
            int nx = x - 2 + i;
            int ny = y - 2 + j;
            if(nx < 0 || nx >=h || ny < 0 || ny >= w) continue;
            if(s[nx][ny] == '#') continue;
            if(cnt[nx][ny] > depth + 1){
                cnt[nx][ny] = depth + 1;
                nxt.pb({nx, ny});
            }
        }
    }
}

void Main(){
    cin >> h >> w;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    s.resize(h);
    rep(i, h) cin >> s[i];
    cnt.resize(h, vi(w, INF));
    seen.resize(h, vector<bool>(w, false));

    int c = 0;
    now.pb({ch, cw});
    while(!now.empty()){
        for(auto [x, y] : now) dfs(x, y, c);
        now = nxt;
        nxt.clear();
        /*
        rep(i, h){
            rep(j, w){
                cout << cnt[i][j] << " ";
            }
            cout << endl;
        }
        */
        for(auto [x, y] : now) dfs2(x, y, c);
        now = nxt;
        nxt.clear();
        /*
        rep(i, h){
            rep(j, w){
                cout << cnt[i][j] << " ";
            }
            cout << endl;
        }
        */
        if(cnt[dh][dw] != INF){
            cout << cnt[dh][dw] << endl;
            return;
        }
        c++;
    }
    cout << -1 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 8976
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 2 4");
            //Alice
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 1 2");
            //Borys
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("58 23 42");
            //Borys
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int N = wkArr[0];
        int A = wkArr[1];
        int B = wkArr[2];

        while (true) {
            if (++A == B) {
                Console.WriteLine("Borys");
                break;
            }
            if (--B == A) {
                Console.WriteLine("Alice");
                break;
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int m = scn.nextInt();
		int[] h = new int[n+1];
		for(int i=1; i<=n; i++){
			h[i] = scn.nextInt();
		}
      	int[] a = new int[m];
      	int[] b = new int[m];
      	for(int i=0; i<m; i++){
			a[i] = scn.nextInt();
          	b[i] = scn.nextInt();
		}
      	int[] max = new int[n+1];
      	for(int i=0; i<m; i++){
          max[a[i]] = Math.max(max[a[i]], h[b[i]]);
          max[b[i]] = Math.max(max[b[i]], h[a[i]]);
        }
      	int count = 0;
      	for(int i=1; i<max.length; i++){
          if(h[i]>max[i]) count++;
        }
      	System.out.println(count);
	}
}


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

int main(void){
	int time;
	cin >> time;
	int s = 0, m = 0, h = 0;

	s = time % 60;
	time /= 60;
	m = time % 60;
	h = time / 60;

	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 1e5+1)
	sc.Buffer(buf, 1e5+1)

	sc.Scan()
	S := []byte(sc.Text())

	changes := make([]int, 1)
	changes[0] = 0
	var now byte = 'R'
	for i, el := range S {
		if el != now {
			changes = append(changes, i)
			if now == 'R' {
				now = 'L'
			} else {
				now = 'R'
			}
		}
	}
	changes = append(changes, len(S))

	result := make([]int, len(S))
	for i := 0; i < len(changes)-1; i++ {
		even := i%2 == 0
		num := changes[i+1] - changes[i]
		if even {
			result[changes[i+1]-1] += num%2 + num/2
			result[changes[i+1]] += num / 2
		} else {
			result[changes[i]-1] += num / 2
			result[changes[i]] += num%2 + num/2
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	for i, res := range result {
		if i != 0 {
			writer.WriteString(" ")
		}
		writer.WriteString(strconv.Itoa(res))
	}
	writer.Flush()
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n + 1], dp[n + 1];
	foe(i, 1, n)
	cin >> arr[i];
	dp[1] = 0;
	dp[2] = abs(arr[2] - arr[1]);
	foe(i, 3, n)
	dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	cout << dp[n];
}

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


int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll sum = 0, cnt = 0;
  rep(i,n) {
    if(a[i]>b[i]) sum += a[i]-b[i];
    else cnt += (b[i]-a[i])/2;
  }
  cout << (sum>cnt? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 3668
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
ll ara[Max+10];

ll dp[2][3002][3002];

ll call(ll i,ll j,ll turn)
{
    if(i>j)
        return 0;

    ll &ret=dp[turn][i][j];


      if(~ret)
        return ret;




       ret=max(ara[i]-call(i+1,j,turn^1),ara[j]-call(i,j-1,turn^1));



       return ret;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;


       cin>>n;

       input(ara,n);

       memset(dp,-1,sizeof(dp));

       cout<<call(0,n-1,0)<<endl;





}



Measured memory_bytes: 144680
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

int K;
vector<long> A(100005);

int main() {
  cin >> K;
  rep(i,K) {
    cin >> A.at(i);
  }

  long ma = 2;
  long mi = 2;
  for (int i=K-1; i>=0; i--) {
    if (A.at(i) > ma) {
      cout << -1 << endl;
      return 0;
    }
    mi = max(mi, A.at(i));
    if (mi%A.at(i) != 0) {
      mi = mi/A.at(i)*A.at(i) + A.at(i);
    } else {
      mi = mi/A.at(i)*A.at(i);
    }
    ma = ma/A.at(i)*A.at(i)+(A.at(i)-1);
    if (mi > ma) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << mi << ' ' << ma << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int 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
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
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 = 1e8;
const ll infl = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vector<tuple<ll,ll,ll>> PY;
  set<ll> s;
  rep(i,m) {
    ll p,y;
    cin >> p >> y;
    PY.push_back(make_tuple(y,p,i));
  }
  sort(all(PY));
  vector<pair<int,string>> citys;
  map<ll,ll> mp;
  for(auto c:PY){
    mp[get<1>(c)]++;
    ll x = mp[get<1>(c)];
    //足りない桁数計算
    string pstr = to_string(get<1>(c));
    int p_digits = 6-(int)pstr.size();
    ll num = get<1>(c) * 1e6 + x;
    string st = to_string(num);  
    string res;
    rep(i,p_digits) res+="0"; 
    res+=st;
    citys.push_back({get<2>(c),res}); 
  }
  sort(all(citys));
  rep(i,m) cout << citys[i].second << endl;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> prefs(M);
  vector<int> years(M);

  int p, d;
  for (int m = 0; m < M; m++) {
	cin >> p >> d;
	prefs[m] = p;
	years[m] = d;
  }

  vector<vector<int>> a(N, vector<int>(0));
  for (int i = 0; i < M; i++) {
	a[prefs[i]-1].push_back(years[i]);
  }

  for (int i = 0; i < N; i++) {
	sort(a[i].begin(), a[i].end());
  }

  for (int i = 0; i < M; i++) {
	auto itr = lower_bound(a[prefs[i]-1].begin(), a[prefs[i]-1].end(), years[i]);
	printf("%06d%06d\n", prefs[i], distance(a[prefs[i]-1].begin(), itr) + 1);
  }


  return 0;
}


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

int main(){
	for(int i=0; i<5; i++){

		int C;
		
		cin >> C ;


		cout << (1000-C)/500 + (1000-C)/100-5*((1000-C)/500) + 
				(1000-C)/50-2*((1000-C)/100) + (1000-C)/10-5*((1000-C)/50) +
				(1000-C)/5-2*((1000-C)/10) + (1000-C)-5*((1000-C)/5) << endl;
	}



}


Measured memory_bytes: 2988
a, b = input().split(' ')
a = int(a)
b = int(b)
ans = 0

if b == 1:
    ans = 0

elif a >= b:
    ans = 1

else:
    ans = int((b-1)/(a-1))
    if (b-1)%(a-1) != 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	for i := 1; i < 10000; i++ {
		x := k * i
		if a <= x && x <= b {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool CheckWin(ll X, ll Y)
{
    return abs(X - Y) > 1;
}

void _main()
{
    ll X, Y;
    cin >> X >> Y;
    cout << (CheckWin(X, Y) ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    stringstream geek(a);
    int x=0;
    geek>>x;
    int c=sqrt(x);
    if((c*c)==x)
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;

}

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

fn main() {
    let n: i32 = read();

    println!("{}", n * 800 - 200 * (n / 15));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXIM 1000003

ll mod = 1e9 + 7;

void solve(){
    ll n;
    cin >> n;
    set<pll> p;
    rep(i,0,n){
        ll x,y;
        cin >> x >> y;
        p.insert({x,y});
    }
    ll ans1=0,ans2=0;
    set<ll> add,sub;    
    for(auto x:p){
        add.insert(x.ff + x.ss);
        sub.insert(x.ff - x.ss);
        ans1 = max(ans1,x.ff + x.ss - *add.begin());
        ans2 = max(ans2,x.ff - x.ss - *sub.begin());
    }
    cout << max(ans1,ans2) << br;
}
	

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 34860
#include <iostream>
#include <string>
#define llint long long

using namespace std;

string s, t, u;
llint a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	
	if(s == u && a >= 1) a--;
	if(t == u && b >= 1) b--;
	
	cout << a << " " << b << endl;
	return 0;
}

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; } 
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, pair<T*, int> a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
#define LOG
#endif

string s;

bool read() {
	if (!(cin >> s))
		return false;
	return true;
}

void solve() {
	forn(j, sz(s))
		forn(i, j)
			if (s[i] == 'C' && s[j] == 'F') {
				puts("Yes");
				return;
			}
	puts("No");
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif
    
    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		ld stime = gett();
		solve();
		cerr << "Time: " << gett() - stime << endl;
		//break;
	}
	
    return 0;
}

Measured memory_bytes: 764
import Control.Applicative
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S

main = do
  n <- readLn :: IO Int
  xs <- readInts <$> B.getContents
  let ans = S.size $ S.fromAscList $ map fst $ lis $ zip xs $ reverse [1..n]
  print ans

lis :: Ord a => [a] -> [a]
lis = S.toList . snd . foldl go (S.empty, S.empty)
  where
    go (acc, acc0) x = case S.lookupGT x acc of
      Nothing -> let acc1 = S.insert x acc in (acc1, acc1)
      Just g -> (S.insert x (S.delete g acc), acc0)

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readInts :: B.ByteString -> [Int]
readInts = map readInt . B.words


Measured memory_bytes: 50164
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n,m;
	cin>>n>>m;
	vector<int> A;
	vector<pair<int,int>> B;
	int a,b,c;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	sort(all(A));
	rep(i,m){
		cin>>b>>c;
		B.push_back(pair<int,int>{c,b});
	}
	sort(all(B));
	reverse(all(B));
	int idx = 0;
	bool ok = false;
	rep(i,m){
		rep(j,B[i].second){
			if(idx >= n){
				ok = true;
				break;
			}
			if(B[i].first <= A[idx]){
				ok = true;
				break;
			}else{
				//cout<<B[i].first<<" ";
				A[idx] = B[i].first;
				idx++;
			}
		}
		if(ok) break;
	}
	ll sum = 0;
	rep(i,n){
		//cout<<A[i]<<" ";
		sum+=A[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1784