akhauriyash/Code-Regression huggingface dataset:
#include <iostream>  
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
const int MAX_N = 2e6 + 5; 
int N = 2e6, fac[MAX_N], ifc[MAX_N]; 
int fpow(int x, int y) {
	int res = 1; 
	while (y) {
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
int C(int n, int m) {
	if (n < m || n < 0 || m < 0) return 0; 
	else return 1ll * fac[n] * ifc[m] % Mod * ifc[n - m] % Mod; 
} 
int F(int x, int y, int _x, int _y) { 
	int _1 = abs(x - _x), _2 = abs(y - _y); 
	return C(_1 + _2, _1); 
} 
struct Node { int x, y, op; } p[10]; 
int X[10], Y[10]; 
int solve(int x1, int y1, int x2, int y2) {
	int res = 0; 
	for (int x = X[3]; x <= X[4]; x++) { 
		res = (res + 1ll * F(x1, y1, x, Y[4]) * F(x, Y[4] + 1, x2, y2) % Mod * (x + Y[4] + 1)) % Mod; 
		res = (res + 1ll * (Mod - 1) * F(x1, y1, x, Y[3] - 1) % Mod * F(x, Y[3], x2, y2) % Mod * (x + Y[3])) % Mod; 
	} 
	for (int y = Y[3]; y <= Y[4]; y++) { 
		res = (res + 1ll * F(x1, y1, X[4], y) * F(X[4] + 1, y, x2, y2) % Mod * (X[4] + y + 1)) % Mod; 
		res = (res + 1ll * (Mod - 1) * F(x1, y1, X[3] - 1, y) % Mod * F(X[3], y, x2, y2) % Mod * (X[3] + y)) % Mod; 
	} 
	return res; 
} 

int main () { 
	for (int i = 1; i <= 6; i++) scanf("%d", X + i); 
	for (int i = 1; i <= 6; i++) scanf("%d", Y + i); 
	for (int i = fac[0] = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
	ifc[N] = fpow(fac[N], Mod - 2); 
	for (int i = N - 1; ~i; i--) ifc[i] = 1ll * ifc[i + 1] * (i + 1) % Mod;
	
	p[1] = (Node){X[1] - 1, Y[1] - 1, 1}; 
	p[2] = (Node){X[1] - 1, Y[2], Mod - 1}; 
	p[3] = (Node){X[2], Y[1] - 1, Mod - 1}; 
	p[4] = (Node){X[2], Y[2], 1};
	
	p[5] = (Node){X[6] + 1, Y[6] + 1, 1}; 
	p[6] = (Node){X[5], Y[6] + 1, Mod - 1}; 
	p[7] = (Node){X[6] + 1, Y[5], Mod - 1}; 
	p[8] = (Node){X[5], Y[5], 1}; 

	int ans = 0; 
	for (int i = 1; i < 5; i++) 
		for (int j = 5; j < 9; j++) 
			ans = (ans + 1ll * p[i].op * p[j].op % Mod * solve(p[i].x, p[i].y, p[j].x, p[j].y)) % Mod; 
	printf("%d\n", ans); 
    return 0; 
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,x[100],y[100],d1=0,d2=0,d3=0,di=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i];
  for(int i=0;i<n;i++)cin>>y[i];
  for(int i=0;i<n;i++){
    d1+=abs(x[i]-y[i]);
    d2+=pow(x[i]-y[i],2);
    d3+=pow(abs(x[i]-y[i]),3);
    if(di<abs(x[i]-y[i]))
      di=abs(x[i]-y[i]);
  }
  cout<<fixed<<setprecision(10)<<d1<<endl;
  cout<<fixed<<setprecision(10)<<sqrt(d2)<<endl;
  cout<<fixed<<setprecision(10)<<cbrt(d3)<<endl;
  cout<<fixed<<setprecision(10)<<di<<endl;
  return 0;
}


Measured memory_bytes: 3476
N,K = map(int,input().split())
X = [int(i) for i in input().split()]

min_cost = float('inf')

for i in range(N-K+1):
    l = X[i]
    r = X[i+K-1]
    tmp_l = abs(l) + abs(r-l)
    tmp_r = abs(r) + abs(l-r)
    tmp = min(tmp_l,tmp_r)

    if min_cost > tmp:
        min_cost = tmp

print(min_cost)

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
 	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b(n);
	rep(i, n) cin >>a[i];
	sort(all(a));
	
	int as2 = a[n-1], as1;
	int mnas = 2e9+9;
	int ps = lower_bound(all(a), as2/2) - a.begin();
	
	for(int i= max(0,ps-10); i<min(n-1, ps+10); i++){
		int w = abs(as2 - a[i]*2);
		if(mnas > w){as1 = a[i]; mnas = w;}
	}
	
	cout << as2 << " " <<as1 <<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, 1, -1, 0, 1, -1, 1, -1};

int board[51][51];
int w, h;

void slove(void){
	int cnt = 0;
	queue<pint> q;
	rep(i, h){
		rep(j, w){
			if (board[i][j] == 1){
				q.push(mp(i, j));
				cnt++;
				/*
				rep(k, h){
					rep(l, w){
						printf("%d", board[k][l]);
					}
					printf("\n");
				}
				*/
				while(!q.empty()){
					pint now = q.front(); q.pop();
					rep(i, 8){
						int nowy = now.fi + dy[i];
						int nowx = now.se + dx[i];
						if (0 <= nowy && nowy <= h - 1 && 0 <= nowx && nowx <= w - 1 && board[nowy][nowx] == 1){
							board[nowy][nowx] = 0;
							q.push(make_pair(nowy, nowx));
						}
					}
				}
			}
		}
	}

	printf("%d\n", cnt);
	return;
}

void scan(int w, int h){
	rep(i, h) rep(j, w) cin >> board[i][j];

	slove();
	return;
}

int main(void){
	rep(i, 1000){
		cin >> w >> h;

		if (w == 0) break;
		scan(w, h);
	}
	return 0;
}

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


int main() {
  int M1,D1;
  int M2,D2;
  
  cin>>M1>>D1;
  cin>>M2>>D2;
  
  if(M1!=M2)
    cout<<'1'<<endl;
  else
    cout<<'0'<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static boolean[] p=new boolean[50000];
	public static int counter(int n){
		int c=0,i,j;
		for(i=2;i<=n/2;i++){
			if(p[i]&&p[n-i]) c++;
//			for(j=2;i+j<=n;j++){
//				if(p[j]){
//					if(i+j==n){
//						c++;
////						System.out.println(i+" "+j);
//					}
//				}
//			}//
		}//
		return c;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,i,j;
		Arrays.fill(p, true);
		for(i=2;i<50000;i++){
			if(p[i])
			for(j=2;i*j<50000;j++){
				p[i*j]=false;
			}
		}
		while(true){
			n=sc.nextInt();
			if(n==0) break;
			System.out.println(counter(n));
		}
	}
}

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

int main(){
  int a,b,c,d,k;
  cin>>a>>b>>c>>d>>k;
  if(a==c){
  cout<<d-b-k<<endl;
  }
  else{
  ll time=0;
  time=(c-a)*60+d-b-k;
  cout<<time<<endl;
  }
}

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    vector<queue<char>> queues(3);
    for(int k = 0; k < 3; k++) {
        string str;
        cin >> str;
        for(int i = 0; i < str.length(); i++) {
            queues[k].push(str[i]-'a');
        }
    }

    char cur = 0;
    while(1) {
        if(queues[cur].empty()) {
            cout << (char)(cur + 'A') << endl;
            return 0;
        }
        char next = queues[cur].front();
        queues[cur].pop();
        cur = next;
    }
    return 0;
}

Measured memory_bytes: 3636
a, b, c = map(int, input().split())
ans = 0

if a == b == c and a%2==0:
    ans = -1
else:
    for i in range(10**9):
        if a%2==1 or b%2==1 or c%2==1:
            break
        x = a
        y = b
        z = c
        a = y//2 + z//2
        b = x//2 + z//2 
        c = x//2 + y//2
        ans +=1

print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int c = 0;
		if(s.charAt(0)==t.charAt(0)){
			c++;
		}
		if(s.charAt(1)==t.charAt(1)){
			c++;
		}
		if(s.charAt(2)==t.charAt(2)){
			c++;
		}
		
		System.out.println(c);
		
	}

}

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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    int A,B,C;
    cin>>A>>B>>C;

	cout<<max(0, C - (A - B))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main(void){
  int N; cin >> N;
  int inp;
  int odd = 0;
  rep(i,N){
    cin >> inp;
    if(inp%2 == 1){
      odd += 1;
    }
  }
//  cout << odd << endl;
  if(odd%2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n, a[100], i, max, min;

    scanf("%d", &n);

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

    max = a[0];
    min = a[0];

    for(i=0; i<n; i++){
        if(max < a[i])
            max = a[i];
        
        if(min > a[i])
            min = a[i];
    }

    printf("%d\n", abs(max-min));

    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, s = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    s += r - l + 1;
  }
  cout << s << endl;
}



Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i[n];
    
    for(int j = 0; j < n; j++){
        int m;
        cin >> m;
        i[j] = m;
    }
    
    for(int k = n-1; k >= 0; k -= 1){
        if(k == n-1){
            cout << i[k];
        }
        else{
            cout << " " << i[k];
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 main(){
    ll n; cin>>n;
    vector<ll> a(n), b(n), c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> b_upper(n);
    rep(i,n){
        auto itr=upper_bound(c.begin(), c.end(), b[i]);
        b_upper[i]=c.end()-itr;
    }
    rep(i,n-1){
        b_upper[n-2-i]+=b_upper[n-1-i];
    }
    ll res=0;
    rep(i,n){
        auto itr=upper_bound(b.begin(), b.end(), a[i]);
        ll index=itr-b.begin();
        res+=b_upper[index];
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
  int A,B,C,D,E;
  cin >>A>>B>>C>>D>>E;
  int k[5]={A,B,C,D,E};
  int time =0;
  int min=9;
  int f=0;
  for(int i=0;i<5;i++){
    if(k[i]%10 < min && k[i]%10 !=0) {
      min=k[i]%10;
      f =i;
    }
  }
  for(int i =0;i<5;i++){
    if(i!=f){
      if(k[i]%10 != 0)
      time=time +  k[i]+(10 - k[i]%10);
      else time=time +  k[i];
    }else{
      time +=k[i];
    }
  }
    cout<<time<<endl;
  return 0;
}


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

#define ll long long
const ll MAXN=200001;
ll n,k;
ll a[MAXN];

ll count(ll x){
	ll ret=0;
	ll ok,ng,mid;
	
	for (int i=0; i<n; i++){
		if (a[i]>=0){
			ok=-1,ng=n;
			while (ng-ok>=2){
				mid=(ok+ng)>>1;
				if (a[i]*a[mid]<=x) ok=mid;
				else ng=mid;
			}
			if (ok>=i) ret+=ok;
			else ret+=ok+1;
		}
		else{
			ng=-1,ok=n;
			while (ok-ng>=2){
				mid=(ok+ng)>>1;
				if (a[i]*a[mid]<=x) ok=mid;
				else ng=mid;
			}
			if (ok<=i) ret+=n-1-ok;
			else ret+=n-ok;
		}
	}
	return (ret)>>1;
}

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

	cin>>n>>k;
	for (int i=0; i<n; i++) cin>>a[i];
	sort(a,a+n);
	ll st=-2e18,ed=2e18;
	while (ed-st>=2){
		ll mid=(st+ed)>>1;
		if (count(mid)<k) st=mid;
		else ed=mid;
	}
	cout<<ed<<endl;
	return 0;
}

Measured memory_bytes: 1792
N = int(input())

def sum_10(n):
  return sum([int(l) for l in str(n)])

li=[]
for i in range(1,N//2 +1):
    if N - N//2 <= N - i <= N:
      li.append(sum_10(i)+sum_10(N - i))
print(min(li))      

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new long[n];
            var r = ReadSplit();
            var max = 500000;
            var h1 = new int[max];
            var h2 = new int[max];
            for (int i = 0; i < n; i++)
            {
                l[i] = r[i].Long();
                if (max < l[i] + i + 1) continue;
                if(l[i] + i + 1 >= 0) h1[l[i] + i + 1] += 1;
                if (i - l[i] + 1 >= 0) h2[i - l[i] + 1] += 1;
            }

            long ans = 0;
            for (int i = 0; i < max; i++)
            {
                ans += (long)h1[i] * (long)h2[i];
            }
            
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 43160
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n,x;
    cin>>n>>x;
    int m[110];
    int sum=0;
    rep(i,n){
        cin>>m[i];
        sum+=m[i];
    }
    int nokori=x-sum;
    int min=*min_element(m,m+n);
    int tmp=nokori/min;
    cout<<tmp+n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(long long i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODI 10000
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii four_Dir[4] = { 
	{ -1 ,0 },{ 0 ,1 },
	{ 1 ,0 },{0,-1}
};
signed main() {
	char str[100001];
	scanf("%s", str);

	int ans = 0,len = strlen(str);
	REP(i, len-1) {
		if (str[i] != str[i + 1]) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<string> t(h);
    rep(i, h) t[i] = s[i];

    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') {
            int cnt = 0;
            for (int dy = -1; dy <= 1; dy++) {
                for (int dx = -1; dx <= 1; dx++) {
                    if (i + dy >= 0 && i + dy <h && 0 <= j + dx && j + dx < w) {
                        cnt += s[i+dy][j+dx] == '#' ? 1 : 0;
                    }
                }
            }
            t[i][j] = '0' + cnt;
        }
    }

    rep(i, h) put(t[i])

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d,x,y;
  cin >> a >> b >> c >> d;
  x = a / d; 
  y = c / b; 
  a = a % d;
  c = c % b;
  if (a != 0) {
    x += 1;
  } if (c != 0) {
    y += 1;
  }
  if (x >= y) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[110000];
  int b[110000] = {0};
  int counter;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i]%2 != 0) b[i]++;
  }
  
  for(int i = 0; i < N; i++){
    if(b[i] == 1) counter++;
  }
  
  if(counter%2 == 0) cout << "YES" <<endl;
  if(counter%2 != 0) cout << "NO" << endl;
}

Measured memory_bytes: 1152
MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n - 1):
    b[-i - 2] = b[-i-1] + a[-i-1]
ans = 0
for i in range(n - 1):
    ans += a[i] * b[i]
print(ans % MOD)


Measured memory_bytes: 94256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {

	ll N, K;
	cin >> N >> K;
	vll A(N);
	rep(i, N) cin >> A[i];

	ll arg_min = min_element(all(A)) - A.begin();
	
	ll ans = INF;
	rep(i, K) {
		ll left = arg_min - i, right = arg_min + K - i - 1;
		ll a = ceil((double)left / (K - 1));
		ll b = ceil(double(N - right - 1) / (K - 1));
		ans = min(ans, a + b + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int x[102];

int main() {
    int n, m, a;
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%d", x+i);
    x[n+1] = 2020;
    scanf("%d", &m);
    while(m--) {
        scanf("%d", &a);
        if(x[a] < (x[a+1] - 1)) x[a]++;
    }
    for(int i=1; i<=n; i++) printf("%d\n", x[i]);
}



Measured memory_bytes: 2080
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	string S;
	string abc = "ABC";

	cin >> N;
	cin >> S;

	size_t p = 0;
	unsigned int ans = 0;

	p = S.find(abc);

	while (p < S.size()) {
		ans += 1;
		p = S.find(abc, p + 2);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 5;
const ll MOD = 998244353;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    int n;
    cin >> n;
    int mask = 0;
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        mask ^= a[i];
    }
    for(int i=0;i<n;i++) {
        cout << (mask ^ a[i]) << " ";
    }
    return 0; 
}



Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  int answer = 0;
  cin >> n >> m >> c;
  vector<int> a(m);
  vector<int> b(m);
  for(int i = 0;i < m;i++){
    cin >> b[i];
  }
  for(int i = 0;i < n;i++){
    int sum = c;
    for(int j = 0;j < m;j++){
      int a;
      cin >> a;
      sum += a*b[j];
    }
    if(sum > 0) answer++;
  }
  cout << answer << endl;
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 3e5 + 5;
int A[N], B[N];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        for(int i = 0; i < n; ++i) {
            scanf("%d", &A[i]);
        }
        for(int i = 0; i < n; ++i) {
            scanf("%d", &B[i]);
        }

        priority_queue <pair<int, int>  > Q;
        for(int i = 0; i < n; ++i) {
            // if(A[i] != B[i])
                Q.push({B[i], i});
        }

        bool flag = true; ll ans = 0;
        while(!Q.empty()) {
            auto tp = Q.top(); Q.pop();
            if(B[tp.second] == A[tp.second]) continue;
            if(B[tp.second] < A[tp.second]) {
                flag = false;
                break;
            }
            int u = tp.second;
            int pr = (u - 1 + n) % n, nx = (u + 1) % n;
            // debug(tp);
            // break;
            if (A[u]>=B[pr]&&A[u]>=B[nx]) {
                if ((A[u]-B[u])%(B[pr]+B[nx])!=0) { flag = false; break; }
                ans+=(B[u]-A[u])/(B[pr]+B[nx]);
                B[u]=A[u]; continue;
            }
            if (B[u]<B[pr]+B[nx])  { flag = false; break; }
            ans+=B[u]/(B[pr]+B[nx]);
            B[u]%=B[pr]+B[nx];
            if (B[u] < A[u]) { flag = false; break; }
            Q.push({B[u],u});
        }

        if(flag == false) printf("-1\n");
        else printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3956
fn main() {
    let n: usize = read();
    let result: u16 = (0..n).fold(0u16, |mut sum, _| {
        let e: u32 = read();
        if is_prime(e) {
            sum += 1;
        }
        sum
    });
    println!("{}", result);
}

fn is_prime(e: u32) -> bool {
    if e == 2 {
        return true;
    }
    if e == 0 || e == 1 || e % 2 == 0 {
        return false;
    }
    let root: u32 = (e as f64).sqrt().ceil() as u32;
    let mut i = 3;
    while i <= root {
        if e % i == 0 {
            return false;
        }
        i += 2;
    }
    true
}

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


Measured memory_bytes: 5128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int>adj[],bool*vis,int i,int *count){
	vis[i]=true;
  	for(auto x:adj[i]){
    	if(!vis[x])
          dfs(adj,vis,x,count);
    }
	*count = *count+1;
}
int main(){
int n,m;
  cin>>n>>m;
  vector<int>adj[n+1];
  while(m--){
  int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  bool vis[n+1]={false};
  int count=0,len=0;
  for(int i=1;i<=n;i++){
  	if(!vis[i]){
    	dfs(adj,vis,i,&count);
      len=max(len,count);
      	count=0;
    }
  }
  cout<<len<<endl;
}


Measured memory_bytes: 24148
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, k) = intList()
    val a = intList()
    val nn = n - 1
    val kk = k - 1
    val c = nn / kk + if (nn % kk != 0) {
        1
    } else {
        0
    }
    println(c.toString())
}


Measured memory_bytes: 49640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2)  return EOF; }
  return *p1++;
}

inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=3000005;

struct modi{  
  int x,y,r;  
}Stk[N]; int pnt;  
int fat[N],rnk[N],size[N];  
  
inline int Fat(int u){  
  return u==fat[u]?u:Fat(fat[u]);  
}

int cot[N];
int flag=0;

inline int Merge(int x,int y){  
  x=Fat(x); y=Fat(y); if (x==y) return 0;  
  if (rnk[x]>rnk[y]) swap(x,y);  
  Stk[++pnt].x=x; Stk[pnt].y=y; Stk[pnt].r=0;  
  if (rnk[x]==rnk[y]) rnk[y]++,Stk[pnt].r=1;  
  fat[x]=y; cot[size[y]]--; cot[size[x]]--; size[y]+=size[x]; cot[size[y]]++;
  if (size[y]>3) flag=1;
  return 1;  
}

inline void Back(int t){  
  for (;pnt>t;pnt--){
    int x=Stk[pnt].x,y=Stk[pnt].y;
    fat[Stk[pnt].x]=Stk[pnt].x;  
    if (Stk[pnt].r) rnk[Stk[pnt].y]--;
    cot[size[y]]--; size[y]-=size[x]; 
    cot[size[y]]++; cot[size[x]]++; 
  }  
}

const ll P=1e9+9;

ll fac[N],inv[N],iinv[N];

int tot;
int us[20],vs[20],ws[20];
int n,m;

inline ll Pow(ll a,int b){
  ll ret=1;
  for (;b;b>>=1,a=a*a%P)
    if (b&1)
      ret=ret*a%P;
  return ret;
}

inline void Pre(int n){  
  fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
  inv[0]=1; for (int i=1;i<=n/3;i++) (inv[i]=inv[i-1]*6)%=P;
  for (int i=1;i<=n/3;i++) inv[i]=Pow(inv[i],P-2);
  iinv[1]=1; for (int i=2;i<=n;i++) iinv[i]=(P-P/i)*iinv[P%i]%P;  
  iinv[0]=1; for (int i=1;i<=n;i++) iinv[i]=iinv[i]*iinv[i-1]%P;  
}

inline ll Calc(int a,int b,int c){
  if (b>a) return 0;
  return fac[a]*inv[(a-b)/3]%P*iinv[(a-b)/3]%P;
}

int main(){
  read(n); read(m); n*=3;
  Pre(n);
  tot=0;
  for (int i=1;i<=n;i++) fat[i]=i,size[i]=1;
  flag=0; cot[1]=n;
  for (int i=1;i<=m;i++){
    ++tot;
    read(us[tot]),read(vs[tot]),read(ws[tot]);
    if (ws[tot]==0)
      Merge(us[tot],vs[tot]),tot--;      
  }
  if (flag){
    printf("0\n");
    return 0;
  }
  ll Ans=Calc(cot[1],cot[2],cot[3]);
  int tmp=pnt;
  for (int i=1;i<(1<<tot);i++){
    flag=0; int c=0;
    for (int j=1;j<=tot;j++)
      if (i>>(j-1)&1)
	Merge(us[j],vs[j]),c++;   
    if (!flag){
      if (c&1)
	(Ans+=P-Calc(cot[1],cot[2],cot[3]))%=P;
      else
	(Ans+=Calc(cot[1],cot[2],cot[3]))%=P;
    }
    Back(tmp);
  }
  printf("%lld\n",Ans);
  return 0;
}

Measured memory_bytes: 80684
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=209;
	namespace linebasis{
		int a[69];
		inline void insert(int x){
			for(int i=63;~i;i--)
				if((x>>i)&1){
					if(!a[i]) return a[i]=x,void();
					else x^=a[i];
				}
		}
		inline bool check(int x){
			for(int i=63;~i;i--)
				if((x>>i)&1) x^=a[i];
			return !x;
		}
	}using namespace linebasis;

	int n,A[N];char s[N];
	int main(){
		int T=read<int>();
		while(T--){
			n=read<int>();
			for(int i=1;i<=n;i++) A[i]=read<int>();
			cin>>s+1;

			memset(a,0,sizeof a);
			int peg=0;
			for(int i=n;i>=1;i--)
				if(s[i]=='1' && !check(A[i])) peg=1;
				else insert(A[i]);

			if(!peg) puts("0");
			else puts("1");
		}
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int n,A,B,C;
vector<int>l(8);
int dfs(int cnt=0,int a=0,int b=0,int c=0){
    if(cnt==n){
        return (min({a,b,c})>0)?abs(a-A)+abs(b-B)+abs(c-C)-30:INF;
    }
    return min({dfs(cnt+1,a,b,c),dfs(cnt+1,a+l[cnt],b,c)+10,dfs(cnt+1,a,b+l[cnt],c)+10,dfs(cnt+1,a,b,c+l[cnt])+10});
}
int main(){
    cin>>n>>A>>B>>C;
    REP(i,n)IN(l[i]);
    OUT(dfs());
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
S = list(input())
ans = 0
for i in range(1, N-1):
    temp = []
    left = S[:i]
    right = S[i:]
    for i in left:
        if i in right and i not in temp:
            temp.append(i)
    ans = max(ans, len(temp))
print(ans)

Measured memory_bytes: 3064
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 2e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;
int a[MAXN];
int xx[MAXN],xxcnt;
int sum[MAXN];

int lowbit(int x){
    return x&-x;
}

void update(int x,int d){
    while(x<MAXN){
        sum[x]+=d;
        x+=lowbit(x);
    }
}

int query(int x){
    int ret=0;
    while(x){
        ret+=sum[x];
        x-=lowbit(x);
    }
    return ret;
}

void work(){
    scanf("%d",&n);
    xxcnt=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        xx[xxcnt++]=a[i];
    }
    sort(xx+1,xx+xxcnt);
    int tmpcnt=xxcnt;
    xxcnt=2;
    for(int i=2;i<tmpcnt;i++){
        if(xx[i]!=xx[i-1]) xx[xxcnt++]=xx[i];
    }
    long long ans=0;
    for(int i=1;i<=n;i++){
        int x=lower_bound(xx+1,xx+xxcnt,a[i])-xx;
        update(x,1);
        ans+=i-1-query(x-1);
    }
    printf("%lld\n",ans);
}

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






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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     ll n,k;
     cin >> n >> k;
     ll a[n];
     for(int i=0 ; i<n ; i++)
        cin >> a[i];
     for(int i=k ; i<n ; i++)
     {
         if(a[i] > a[i-k])
            cout << "Yes\n";
         else
            cout << "No\n";
     }

    return 0;
}


Measured memory_bytes: 5220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<deque>
#include<algorithm>
#include<stack>
using namespace std;
const int maxn = 2e5+5;
int main()
{
    int n,m;
    int a[maxn];
    memset(a,0,sizeof(a));
    cin >> n >>m;
    int b,c;
    for(int i = 0; i < m; i ++)
    {

        scanf("%d%d",&b,&c);
        if(b == 1)a[c]++;
        if(c == n)a[b]++;
    }
    bool p = false;
    for(int i = 0; i < n; i ++)
    {
        if(a[i] == 2||a[1]>0 || a[n]>0)
        {
            p = true;break;
        }
    }
    if(p) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 1024
// 
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 200002;
const int mo = 1e9 + 7;

int n, q;

int main() {

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

	map<int, vector<int> > st, en;
	
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
	{
		int s, t, x;
		cin >> s >> t >> x;
		s = max(0, s - x);
		t = max(0, t - x);

		st[s].push_back(x);
		en[t].push_back(x);
	}

	map<int, vector<int> >::iterator it1 = st.begin(), it2 = en.begin();
	multiset<int> xs;

	for (int i = 0; i < q; ++i) {
		int d;
		cin >> d;

		while (it1 != st.end() && it1->first <= d) {
			for (int j = 0; j < it1->second.size(); ++j)
				xs.insert(it1->second[j]);
			++it1;
		}

		while (it2 != en.end() && it2->first <= d) {
			for (int j = 0; j < it2->second.size(); ++j)
				xs.erase(xs.find(it2->second[j]));
			++it2;
		}

		if (xs.empty())
			cout << -1 << endl;
		else
			cout << *xs.begin() << endl;
	}

	return 0;
}

Measured memory_bytes: 54528
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


int main(){
    int K,S;
    cin>>K>>S;
    ll ans=0;
    for(int x=0;x<=K;x++){
        if(x>S) break;
        for(int y=0;y<=K;y++){
            if(x+y>S) break;
            int z = S - x - y;
            if(z > K) continue;
            if(z<0) break;
            if(x+y+z==S) ans++;
///            cerr << x << " " << y << " " << z << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
sts = dict()
mi = 0
bl = 0

for i in range(n):
    ai = int(input())
    if i-ai >= mi:
        sts[i-ai] = ai
        if bl >= ai:
            mi = i-ai
    else:
        print(-1)
        exit()
    bl = ai

for i in sts.values():
    ans += i
print(ans)


Measured memory_bytes: 32560
eval"N,*A="+`dd`.split*?,;
c,d=[0,N].map{|i|y=A[i+N-1];A[i,N].map{|i|y^y=i}}
d+=m=[k=-1]
f=->l,t{l=m[l]until l<0||d[l]==t;l+1}
d.map{|x|m<<k=f[k,x]}
(2*N-1).times{|i|$.=f[$.,c[i%N]];p i+=1-N,A[N]^A[i]if$.==N}

Measured memory_bytes: 96212
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec s(N);
  rep(i, N)cin >> s[i];
  sort(ALL(s));
  ll ans = 0;
  rep(i, N)ans += s[i];
  if(ans%10==0){
    rep(i, N){
      if(s[i]%10!=0){
        cout << ans - s[i];
        return 0;
      }
    }
    cout << 0 << endl;
  }else{
    cout << ans << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

struct X {
    int r, c;
    ll cost;
};

int main() {
    cin >> n;
    V<Pii> v(n);
    REP(i, n) {
        int r, c;
        cin >> r >> c;
        v[i] = {r, c};
    }

    V<V<X>> dp(n, V<X>(n));
    REP(i, n) {
        X x = {v[i].first, v[i].second, 0LL};
        dp[i][i] = x;
    }
    REP2(k, 1, n) {
        REP(i, n-k) {
            int R = dp[i][i].r, C = dp[i+k][i+k].c;
            X x = {R, C, (ll)1e18};
            REP2(j, i, i+k) {
                ll cost = dp[i][j].cost + dp[j+1][i+k].cost + R*C*dp[i][j].c;
                if (x.cost > cost) {
                    x.cost = cost;
                }
            }
            dp[i][i+k] = x;
        }
    }
    std::cout << dp[0][n-1].cost << '\n';

    return 0;
}



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

int check[25][25];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
queue< pair<int, int> > q;
vector< vector<char> > S;

void bfs(int i, int j) {
    for (int k = 0; k < 4; k++) {
        if (check[i+dy[k]][j+dx[k]] < 0 && S[i+dy[k]][j+dx[k]] == '.') {
            check[i+dy[k]][j+dx[k]] = check[i][j] + 1;
            q.push(make_pair(i+dy[k], j+dx[k]));
        }
    }
}

int main() {
    int H, W; cin >> H >> W;
    S.resize(H+2);
    for (int i = 0; i < H+2; i++) S[i].resize(W+2);
    for (int i = 0; i < W+2; i++) S[0][i] = '#';
    for (int i = 1; i <= H; i++) {
        S[i][0] = '#';
        for (int j = 1; j <= W; j++) cin >> S[i][j];
        S[i][W+1] = '#';
    }
    for (int i = 0; i < W+2; i++) S[H+1][i] = '#';
    int ans = -1;
    int cnt;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (S[i][j] == '#') continue;
            for (int k = 0; k < 25; k++) {
                for (int l = 0; l < 25; l++) {
                    check[k][l] = -1;
                }
            }
            q.push(make_pair(i, j));
            check[i][j] = 0;
            while (!q.empty()) {
                bfs(q.front().first, q.front().second);
                q.pop();
            }
            cnt = 0;
            for (int k = 0; k < 25; k++) {
                for (int l = 0; l < 25; l++) {
                    cnt = max(cnt, check[k][l]);
                }
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
INTEGER X,F
CHARACTER(8) A
READ*,X
F=0
WRITE(A,"(I0)")X
DO I=1, LEN_TRIM(A)
	F=F+ICHAR(A(I:I))-ICHAR("0")
ENDDO
PRINT"(A)",MERGE("Yes"," No",mod(x,f)==0)
END

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.chomp).array;
    auto M = max(H, W) * 3 + 10;
    auto B = new long[][](M, M);
    auto C = new long[][](M, M);
    auto X = new int[][](M);
    auto Y = new int[][](M);
    long ans = 0;

    foreach (i; 0..H) {
        foreach (j; 0..W) {
            if (A[i][j] == '#') {
                int r = i + j + max(H, W);
                int c = i - j + max(H, W);
                B[r][c] = 1;
                C[r][c] = 1;
                X[r] ~= c;
                Y[c] ~= r;
            }
        }
    }

    foreach (i; 0..M) {
        foreach (j; 0..M-1) {
            B[i][j+1] += B[i][j];
        }
    }

    foreach (j; 0..M) {
        foreach (i; 0..M-1) {
            C[i+1][j] += C[i][j];
        }
    }

    foreach (i; 0..M) {
        foreach (j; 0..X[i].length) {
            foreach (k; j+1..X[i].length) {
                int len = X[i][k] - X[i][j];
                int a = X[i][j];
                int b = X[i][k];
                int u = i - len;
                int d = i + len;
                if (u >= 0) {
                    ans += B[u][b] - B[u][a-1];
                }
                if (d < M) {
                    ans += B[d][b] - B[d][a-1];
                }
            }
        }
    }

    foreach (i; 0..M) {
        foreach (j; 0..Y[i].length) {
            foreach (k; j+1..Y[i].length) {
                int len = Y[i][k] - Y[i][j];
                int a = Y[i][j];
                int b = Y[i][k];
                int u = i - len;
                int d = i + len;
                if (u >= 0) {
                    ans += C[b-1][u] - C[a][u];
                }
                if (d < M) {
                    ans += C[b-1][d] - C[a][d];
                }
            }
        }
    }

    ans.writeln;
}


Measured memory_bytes: 19324
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int next_go[2000];
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a-1);
	}
	REP(i, n) {
		cin >> next_go[i];
		next_go[i]--;
	}
	vector<pair<long long, long long>> threads;
	REP(i, n) {
		int first_clock = -1;
		int second_clock = 0;
		int now = inputs[i];
		while (second_clock <= 500) {
			if (now == i) {
				if (first_clock == -1) {
					first_clock = second_clock;
				}
				else {
					break;
				}
			}
			now = next_go[now];
			second_clock++;
		}
		if (second_clock >= 500) {
			if (first_clock == -1) {
				cout << -1 << endl;
				return 0;
			}
			threads.push_back(make_pair(first_clock, 0));
		}
		else {
			threads.push_back(make_pair(first_clock, second_clock - first_clock));
		}
	}
	for (int i = 0; i < threads.size(); ++i) {
		if (threads[i].second == 0) {
			//!
			for (int q = 0; q < threads.size(); ++q) {
				if (threads[q].second == 0) {
					if (threads[q].first != threads[i].first) {
						cout << -1 << endl;
						return 0;
					}
				}
				else {
					if (threads[q].first % threads[q].second != threads[i].first % threads[q].second) {
						cout << -1 << endl;
						return 0;
					}
				}
			}
			cout << threads[i].first << endl;
			return 0;
		}
	}
	pair<long long, long long> now = threads[0];
	for (int i = 1; i < threads.size(); ++i) {
		for (long long q = 0; q <= 500; ++q) {
			if (q == 500||(q != 0&&now.first >= (2e18-now.first) / q)) {
				cout << -1 << endl;
				return 0;
			}
			long long next_go = now.first + q * now.second;
			if (next_go % threads[i].second == threads[i].first) {
				now.first = next_go;
				break;
			}
		}
		long long hoge = gcd(now.second, threads[i].second);
		if (threads[i].second >= (2e18) / (now.second) * hoge) {
			now.second = 2e18;
		}
		else {
			now.second *= threads[i].second / hoge;
		}
	}
	cout << now.first << endl;
}


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

int main() {
    int a, b, c, d, p, bc;
    std::scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
    bc = (p > c) ? b + (p-c) * d : b;
    (a * p < bc) ? printf("%d\n", a * p) : printf("%d\n", bc);
    return 0;
}



Measured memory_bytes: 2716
import java.util.Scanner;

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

		String s = sc.next();
		String t = sc.next();

		if(t.substring(0, t.length() - 1).equals(s)){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


		sc.close();
	}
}


Measured memory_bytes: 26996