akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define fi first
#define se second
using namespace std;


signed main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, int> > d;
        set<pair<int, int> > st;
        rep(i, 0, n){
            int x, y;
            cin >> x >> y;
            d. push_back(make_pair(x, y));
            st. insert(make_pair(x, y));
        }
        int MAX = 0;
        rep(i, 0, n){
            rep(j, i + 1, n){
                int dy = d[j].se - d[i].se;
                int dx = d[j].fi - d[i].fi;
                pair<int, int> p1 = make_pair(d[j].fi + dy, d[j].se - dx);
                pair<int, int> p2 = make_pair(d[i].fi + dy, d[i].se - dx);
                pair<int, int> p3 = make_pair(d[j].fi - dy, d[j].se + dx);
                pair<int, int> p4 = make_pair(d[i].fi - dy, d[i].se + dx);
                if((st.count(p1) && st.count(p2))||(st.count(p3) && st.count(p4))){
                    MAX = max(MAX, dy*dy + dx*dx);
                }
            }
        }
        cout << MAX << endl;
    }
}

Measured memory_bytes: 1324
def fib(n)
	f = []
	fib2(n, f)
end

def fib2(n, f)
	f[0] = 1
	f[1] = 1
	for i in 2..n
		f[i] = f[i - 2] + f[i - 1]
	end
	return f[n]
end

n = gets.chomp.to_i
puts fib(n)

Measured memory_bytes: 8692
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/

#include <bits/stdc++.h>
using namespace std;

/*
use these format of input when number of inputs not provided
while(scanf("%lld",&n)!=EOF)
*/

#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< int , int >
#define vpii vector< pii >
#define mii unordered_map< int , int >
#define mci map< char , int >
#define pq priority_queue
#define str string
#define len length()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl cout <<  endl
#define sp " "
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define itern(n) for (int i=0; i<n; i++)
#define iterni(n) for (int i=0; i<n; i++)
#define iternj(n) for (int j=0; j<n; j++)
#define iternk(n) for (int k=0; k<n; k++)
#define iterng(n) for (int g=0; g<n; g++)
#define riterni(n) for (int i=n-1; i>=0; i--)
#define riternj(n) for (int j=n-1; j>=0; j--)
#define riternk(n) for (int k=n-1; k>=0; k--)
#define riterng(n) for (int g=n-1; g>=0; g--)
#define sz(x) ((int)(x).size())
#define pi acos(1);                   /* pi */
#define inf (int)(1e9+7)
#define fl(x) int(x)
#define mod 998244353 
#define yes "Yes"
#define no "No"
#define null NULL
#define mac (int)(1e7)
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
/*-----functions-----*/
//gcd
/*
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

//disjoint set union functions
int volume[4];
int parent[4];

void initialise_dsu() {
	for (int i=0; i<mac; i++)volume[i]=1;
	for (int i=0; i<mac; i++)parent[i]=i;
}

int find_set(int v) {
    return (v==parent[v]?v:parent[v]=find_set(parent[v]));
}

void union_sets(int a,int b) {
	a=find_set(a);
	b=find_set(b);
	if (a!=b) {
		if (volume[a]<volume[b])swap(a,b);
		parent[b]=a;
		volume[a]+=volume[b];
	}
}
//#------------------------------complete template------------------------------#//
*/


int main() {
	fast;
	string s;
	cin >> s;
	for (int i=0; i<s.length()-1; i++) {
		if (s[i]==s[i+1]) {
			cout << "Bad";
			return 0;
		}
	}
	
	cout << "Good";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF=1e9;
const ll MOD=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;
int d[1003];
set<int> st;
int to_i(string s) {
    int n;
    stringstream ss;
    ss<<s;
    ss>>n;
    return n;
}
int main() {
    cin>>n;
    rep(i,n) cin>>d[i];
    rep(i,n) {
        string s;
        s=string(1, d[i]+'0');
        st.insert(to_i(s));
        rep(j,n) if(i<j) {
            s+=string(1, d[j]+'0');
            st.insert(to_i(s));
            if(s.size()==6) break;
        }
    }
    rep(i,1000000) {
        if(!st.count(i)) {
            cout<<i<<endl;
            break;
        }
    }

    return 0;
}

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

int main(void){
    int n, ans = 0;
    bool zohe[100] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        zohe[in - 1] = true;
    }
    for (int i = 0; i < 100; i++) {
        if (zohe[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int D;
int C[26];
int S[365][26];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand26(1, 26);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  REP(i,D) cout << rand26(mt) << '\n';

  return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      string s;
      cin>>s;
      ll sum=0;
      for(int i=0;s[i];i++){
        sum+=(s[i]-'0');
      }
      if(sum%9==0) cout<<"Yes";
      else cout<<"No";
      
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define taskname "VirtualACM"
using namespace std;

int tt, nT = 1;

template<typename T>
void Read(T &x)
{
    bool neg = false;
    char c;
    for (c = getchar(); !isdigit(c); c = getchar())
        if (c == '-') neg = true;
    x = c - '0';
    for (c = getchar(); isdigit(c); c = getchar())
        x = x * 10 + c - '0';
    if (neg) x = -x;
}

template<typename T>
void Write(T x)
{
    if (x < 0)
    {
        putchar('-');
        Write(-x);
        return;
    }
    if (x > 9) Write(x / 10);
    putchar(x % 10 + '0');
}

void Enter()
{
    string a, b;   cin >> a >> b;
    while (a.length() < b.length()) a = '0' + a;
    while (b.length() < a.length()) b = '0' + b;
    if (a > b) cout << "GREATER";
    else if (a < b) cout << "LESS";
    else cout << "EQUAL";
}

void Init()
{

}

void Solve()
{

}

void PrintRes()
{

}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    //Read(nT);
    for (tt = 1; tt <= nT; ++tt)
    {
        Enter();
        Init();
        Solve();
        PrintRes();
    }
}


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

using namespace std;

long long N;

int findOfDigits(long long n) {
    int sum = 0;
    while (n > 0) {
        sum += 1;
        n /= 10;
    }
    return sum;
}

void solve() {
    int res = 12;
    for (long long i = 1; i <= (long long) pow(N, 0.5); ++i) {
        if (N % i == 0) {
            res = min(max(findOfDigits(i), findOfDigits(N / i)), res);
        }
    }
    printf("%d\n", res);
}

int main() {
    cin >> N;
    solve();
    return 0;
}

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

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

  cout<<800*N-(N/15)*200<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	
	int n, m;
	cin >> n >> m;

	vector<int>p;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		p.push_back(x);
	
	
	}
	long long int ans = 0;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; i + j <= min(n,m); j++) {

			vector<int>a;
			long long int r = 0;

			for (int x = 0; x < i; x++) {
				a.push_back(p[x]);
				r += p[x];
			}
			for(int x=0;x<j;x++) {
				a.push_back(p[n-x-1]);
				r += p[n-x-1];
			}
			int d = m - i - j;
		
			sort(a.begin(), a.end());

			for (int x = 0; x < d&&x<a.size(); x++) {
				if (a[x] > 0)break;
				r -= a[x];
			}
			ans = max(ans, r);
		}

	}

	cout << ans << endl;
	return 0;



}

Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int 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(all(a));
	sort(all(b));
	sort(all(c));
	ll res = 0;
	for (ll x : b)
	{
		res += (lower_bound(all(a), x) - a.begin())*(c.end() - upper_bound(all(c), x));
	}
	cout << res << endl;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// b==2) 1,3,5,7,...でk>=1
// b==3) 1,2, 4,5, 7,8,

int n, k;
ll res;

signed main() {
	cin >> n >> k;
	if (k==0) return cout << n*n << ln, 0;
	repst(b,k+1,n) {
		int cy = n/b;
		res += cy * (b-k);
		int st = b * cy, to = n;
		res += max(0ll, to%b - k + 1);
	}
	cout << res << ln;
}

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

int main() {
 
  int N;
  cin >> N;
  
  vector<int> L(N);
  for(int i=0; i<N; i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  
  int ans=0;
  
  for(int i=0; i<N; i++){
   for(int j=i+1; j<N; j++){
     for(int k=j+1; k<N; k++){
       if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)){
         if(L.at(k) < L.at(i) + L.at(j)){
           ans++;
         }
       }
     }
   }
  }
  
 cout << ans << endl; 
 
}


Measured memory_bytes: 3552
x = input()
x = int(x)

dp = [0 for i in range(100)]
for i in range(6):
  dp.append(1)

i = 106

while i <= x+5:
  if dp[i - 100] + dp[i - 101] + dp[i - 102] + dp[i - 103] + \
  dp[i - 104] + dp[i - 105] == 0:
    dp.append(0)
  else:
    dp.append(1)
  i = i + 1
  
print(dp[x])

Measured memory_bytes: 3864
N, M = map(int,input().split())
ls = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int,input().split())
    ls[p-1].append((y, i))
ids = [None]*M
for i in range(N):
    ls[i].sort()
    for j in range(len(ls[i])):
        y,k = ls[i][j]
        ids[k] = "{:0>6}{:0>6}".format(i+1,j+1)
print(*ids, sep="\n")

Measured memory_bytes: 37556
#include <bits/stdc++.h>
inline long long read();
using namespace std;
int main()
{
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {
        ans+=s[i]-'0';
    }
    ans=max(ans,(int)(s.length()-1)*9+s[0]-'1');
    cout<<ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

bool dp[6000][1<<13];

ll const B = 1000000007;
ull p[6000], thash[6000];
ull shash[13];

int n,m;
int len;
char t[6000];
char ss[13][6000];
int sslen[13];

int solve(){
    rep(i,n){
        ull x = 0;
        for(int j=0;ss[i][j];j++) x = x*B + ss[i][j];
        shash[i] = x;
    }
    p[0] = 1;
    thash[0] = 0;
    rep(i,len) thash[i+1] = thash[i]*B + t[i];

    rep(i,len+1)rep(j,1<<n) dp[i][j] = false;
    rep(i,len+1) dp[i][0] = true;
    rep(pos,len){
        rep(mask,1<<n){
            if(!dp[pos][mask]) continue;
            rep(i,n){
                if(mask>>i&1) continue;
                if(pos+sslen[i] > len) continue;
                ull h1 = shash[i];
                ull h2 = thash[pos+sslen[i]] - thash[pos] * p[sslen[i]];
                // if(h1 != h2) continue;
                dp[pos+sslen[i]][mask|1<<i] |= h1 == h2; // t.substr(pos,ss[i].size()) == ss[i];
            }
        }
    }

    int ans = 0;
    rep(i,len+1){
        if(dp[i][(1<<n)-1]){
            ++ans;
        }
    }
    return ans;
}

signed main(){
    p[0] = 1;
    rep(i,5001) p[i+1] = p[i]*B;

    while(scanf("%d%d",&n,&m), n){
        len = 0;
        rep(i,n){
            scanf("%s",ss[i]);
            sslen[i] = strlen(ss[i]);
        }
        rep(i,m){
            static char buf[6000];
            scanf("%s",buf);
            int l;
            for(l=0; buf[l]; l++) t[l+len] = buf[l];
            len += l;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 42128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x=1,N,K;
  cin >> N >> K;
  for (int i=0;i<N;i++){
    if (x*2>=x+K){
      x=x+K;
    }
    else
      x=x*2;
  }
  cout << x << endl;
  
}

Measured memory_bytes: 256
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "container/heap"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	h := &IntHeap{}
	heap.Init(h)
	for i := 0; i < N; i++ {
		heap.Push(h, NextInt())
	}

	for i := 0; i < N/2-1; i++ {
		heap.Pop(h)
	}
	m1 := (*h)[0]
	heap.Pop(h)
	m2 := (*h)[0]
	fmt.Println(m2 - m1)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

// An IntHeap is a min-heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 7168
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input=Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        string result;

        if (a == 1) a = 14;
        if (b == 1) b = 14;

        if (a < b)
            result = "Bob";
        else if (a > b)
            result = "Alice";
        else
            result = "Draw";

        Console.WriteLine(result);

    }
}

Measured memory_bytes: 11092
import collections

s = input()
K = int(input())

l = len(s)
sub = set()

if l <= 50:
    for i in range(l):
        for j in range(i+1):
            sub.add(s[j:i+1])
    #print(sub)
    subl = list(sub)
    subl.sort()
    #print(subl)
    print(subl[K-1])

else:
    cl = collections.Counter(s).most_common()
    cl.sort(key=lambda x: x[0])
    #print(cl)
    d = 0
    while len(sub) < K:
        be = cl[d][0]
        for i in range(l):
            if s[i] == be:
                for j in range(K):
                    sub.add(s[i:min(i+j+1,l)])
        d += 1
    #print(sub)
    subl = list(sub)
    subl.sort()
    print(subl[K-1])


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

const int lim = 50;
int main() {
  string str, hint;
  cin >> str >> hint;
  char cha[lim], hin[lim];
  for (int i = 0; i < str.length(); i++) {
    cha[i] = str[i];
  }
  cout << endl;
  for (int j = 0; j < hint.length(); j++) {
    hin[j] = hint[j];
  }
  bool flag = true, suc = false;
  for (int i = str.length() - hint.length() + 1; i >= 0; i--) {
    flag = true;
    for (int j = 0; j < hint.length(); j++) {
      if (cha[i + j] != '?' && cha[i + j] != hin[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      for (int j = 0; j < hint.length(); j++) {
        cha[i + j] = hin[j];
        suc = true;
      }
      for (int j = 0; j < str.length(); j++) {
        if (cha[j] == '?') {
          cha[j] = 'a';
        }
      }
    }
  }
  if (!suc) {
    cout << "UNRESTORABLE" << endl;
  } else {
    for (int i = 0; i < str.length(); i++)
      cout << cha[i];
  }
  return 0;
}


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int n,m;
const int mnmax=50;
char board[mnmax][mnmax],pattern[mnmax][mnmax];

bool match(int y,int x){
  rep(i,m){
    rep(j,m){
      if(board[i+y][j+x]!=pattern[i][j])return false;
    }
  }
  return true;
}

int main(){
  cin>>n>>m;
  rep(y,n){
    rep(x,n){
      cin>>board[y][x];
    }
  }
  rep(y,m){
    rep(x,m){
      cin>>pattern[y][x];
    }
  }
  bool exist=false;
  rep(dy,n-m+1){
    rep(dx,n-m+1){
      if(match(dy,dx)){
        exist=true;
        break;
      }
    }
  }
  cout<<(exist?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<in>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9+7;
ll power(ll num,ll g,ll mod)
{
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

  
int main() { 
    string s;
    cin >> s;

    if (s == "MON") cout << 6;
    if (s == "TUE") cout << 5;
    if (s == "WED") cout << 4;
    if (s == "THU") cout << 3;
    if (s == "FRI") cout << 2;
    if (s == "SAT") cout << 1;
    if (s == "SUN") cout << 7;

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int N, K, A, res;
pair<int, int> a[200001];
set<int>st;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		++a[A].first;
		st.insert(A);
	}
	for (int i = 0; i <= 200000; ++i) {
		a[i].second = i;
	}
	sort(a, a + 200001);
	for (int i = 0; st.size() > K; ++i) {
		st.erase(a[i].second);
		res += a[i].first;
	}
	cout << res << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long sum = 0;



		for(int i = 1; i <= N; i++){
			for (int k = 1; k <= N; k++){
				for (int l = 1; l <= N; l++){

					int x = i;
					int y = k;
					int z = l;
					int tmp;

					while (x % y != 0){
						tmp = (x % y);
						x = y;
						y = tmp;
					}

					while (y % z != 0){
						tmp = (y % z);
						y = z;
						z = tmp;
					}

					sum += z;

				}
			}
		}

		System.out.print(sum);

	return;

	}
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 0 && b > 0) cout << "Positive" << endl;
  else if (a < 0 && b < 0 && (b - a + 1) % 2 == 0) cout << "Positive" << endl;
  else if (a < 0 && b < 0) cout << "Negative" << endl;
  else cout << "Zero" << endl;
  return 0;
}

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

int h, w;
char field[400][400];
int black = 0;
int white = 0;
pair<int, int> direction[4] = { make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0), make_pair(0, -1) };

void dfs(int y, int x, char prev) {
    field[y][x] = 'x';
    char next;
    if (prev == '#') {
        black++;
        next = '.';
    } else {
        white++;
        next = '#';
    }
    for (auto d: direction) {
        int ny = y + d.first;
        int nx = x + d.second;
        if (0 <= ny && ny < h && 0 <= nx && nx < w && field[ny][nx] == next) {
            dfs(ny, nx, next);
        }
    }
}

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

    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> field[i][j];
        }
    }

    long long total = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (field[i][j] == '#') {
                black = 0;
                white = 0;
                dfs(i, j, '#');
                total += (long long) black * white;
            }
        }
    }

    cout << total << '\n';

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        A[a-1] = i+1;
    }
    for(int i=0;i<n;i++) cout << A[i] << ' ';
    cout << endl;


}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

const ll inf = 1e9;

struct compress{
    map<ll,int> idx;
    map<int,ll> value;
    vector<ll> cmp;
    int N;
    compress(vector<ll> v){
        for(auto& x:v) cmp.push_back(x);
        sort(cmp.begin(),cmp.end());
        cmp.erase(unique(cmp.begin(),cmp.end()),cmp.end());
        N = cmp.size();
        for(int i=0;i<N;i++) idx[cmp[i]] = i;
    }
    int id(ll val){return idx[val];}
    ll val(int id){return cmp[id];}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X,D;
    cin >> N >> X >> D;
    if(D==0){
        cout << (X? N+1:1) << endl;
        return 0;
    }

    if(D<0) D *= -1,X *= -1;
    using vp = vec<pair<ll,ll>>;
    unordered_map<ll,vp> m;
    vp em;

    for(ll i=0;i<=N;i++){
        ll j = N-i;
        ll ma = (2*i-N)*X+(N*(N-1)/2-2*j*(j-1)/2)*D;
        ll mi = (2*i-N)*X+(2*i*(i-1)/2-N*(N-1)/2)*D;
        ll d = (mi<0? mi+((-mi)/(2*D)+1)*2*D:mi);
        ll mod = d%(2*D);
        assert(d>=0);
        if(!m.count(mod)) m[mod] = em;
        m[mod].emplace_back(mi,ma);
    }

    auto solve = [&](vp p){
        vec<ll> v;
        for(auto& x:p){
            v.push_back(x.first);
            v.push_back(x.second);
            v.push_back(x.second+2*D);
        }
        compress cmp(v);
        int n = p.size();
        ll res = 0;
        vvec<ll> L(cmp.N),R(cmp.N);
        for(int i=0;i<n;i++){
            L[cmp.id(p[i].first)].push_back(i);
            R[cmp.id(p[i].second)].push_back(i);
        }

        set<int> s;
        for(int i=0;i<cmp.N-1;i++){
            for(auto& x:L[i]) s.insert(x);
            if(!s.empty()) res += (cmp.val(i+1)-cmp.val(i))/(2*D);
            for(auto& x:R[i]) s.erase(x);
        }
        return res;
    };

    ll ans = 0;
    for(auto& x:m) ans += solve(x.second);
    cout << ans << endl;

}


Measured memory_bytes: 99480
#include <bits/stdc++.h>
using namespace std;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool ok = true;
  if (s.size() != a+b+1) ok = false;
  if (s[a] != '-') ok = false;
  for(int i=0;i < s.size();i++){
    if (((s[i] < 48) || (57 < s[i])) && i != a) ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] li = new int[200001];
        for(int i = 0; i < n; i++){
            li[sc.nextInt()]++;
        }
        ArrayList<Balls> bl = new ArrayList<Balls>();
        for(int i = 0; i < 200001; i++){
            if(li[i] == 0) continue;
            bl.add(new Balls(i, li[i]));
        }
        Collections.sort(bl);
        int ans = 0;
        int len = bl.size()-k;
        for(int i = 0; i < len; i++){
            ans += bl.get(i).count;
        }
        System.out.println(ans);
    }
}

class Balls implements Comparable<Balls>{
    int kind, count;
    public Balls(int k, int c){
        this.kind = k;
        this.count = c;
    }
    
    public int compare(Balls b1, Balls b2){
        if(b1.count < b2.count){
            return -1;
        }else if(b1.count > b2.count){
            return 1;
        }else{
            return 0;
        }
    }
    
    public int compareTo(Balls b){
        if(this.count < b.count){
            return -1;
        }else if(this.count > b.count){
            return 1;
        }else{
            return 0;
        }
    }
}


Measured memory_bytes: 64776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, q;
vector<int> et[200000];
int p, x;
int val[200000];

void dfs(int p, int v) {
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		val[nv] += val[v];
		dfs(v, nv);
	}
}

signed main() {
	int i;
	
	cin >> n >> q;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	rep(i, q) {
		cin >> p >> x;
		p--;
		val[p] += x;
	}
	dfs(-1, 0);
	
	rep(i, n) {
		cout << val[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 24320
N,Q = list(map(int,input().split()))
S = input()
lr = [list(map(int,input().split())) for i in range(Q)]

count = 0
countList = [0 for i in range(N)]
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        count += 1
    countList[i] = count

for i in range(Q):
    l = lr[i][0]
    r = lr[i][1]
    lCount = countList[l - 1]
    rCount = countList[r - 1]
    print(rCount - lCount)

Measured memory_bytes: 29728
#include <iostream>
#include <set>

int main(){
    while (true) {
        int n;  // I will buy n vegetables.
        int m;  // One bag contains m vegetables.
        
        std::cin >> n >> m;
        std::cin.ignore();
        if ( n==0 && m==0 ) {
            return 0;
        }
        
        // input vegetable's cost.
        std::multiset<int, std::greater<int> > buy;
        int in;
        for (int i=0; i < n ; ++i) {
            std::cin >> in;
            buy.insert(in);
        }
        
        int cost = 0;  // How much must I pay?
        int x = 1;  // This is the 'x'th vegetable in the bag.
        while ( ! buy.empty() ) {
            // the first item in 'buy' is the most expensive.
            std::set<int>::iterator it = buy.begin();
            // the 'm'th item in the bag is free!
            if ( x > m-1 ) {
                x = 1;
            }else{
                cost += *it;
                ++x;
            }
            buy.erase(it);
        }
        
        // output
        std::cout << cost << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const int N = 5e5 + 10;

int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	if(n & 1) {
		cout << 0 << "\n";
	}
	else {
		ll ans = 0;
		ll k = 5, cnt = 1;
		while(n >= k) {
			ans += (n / k) * cnt / 2;
			k *= 5;
		}
		cout << ans << endl;
	}
}

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x-b) > abs(x-a)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

r = ini()
print(r * r)


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


int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  
  if (K < A) {
    cout << A - K << ' ' << B << endl;
  } else if (K < A + B) {
    cout << 0 << ' ' << A + B - K << endl;
  } else {
    cout << 0 << ' ' << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
ll Factrial(ll num){
  if(num==1||num==0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    ll ans=((num*Factrial(num-1))%d9_7);
    return ans;
  }
  return 34;
}
long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=1;
  for(long long i=n;i>=n-k+1;i--){
    ans*=i;
    ans%=mod;
  }
  //cout<<"r";
  ll k1=Factrial(k);
  k1%=mod;
  ans*=digitpower(k1,mod-2);
  ans%=mod;
  return ans;
}
int main(void){
  ll x,y;
  cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0;
    return 0;
  }
  ll minus=(x+y)/3;
  ll y2=y-minus;
  ll x2=x-minus;
  //cout<<minus<<" "<<y2;
  ll ans=linercomb(minus,max(x2,y2),d9_7);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>

int main(int argc, char **argv)
{
        int numA = 0, numB = 0, numC = 0;
        int num1 = 0, num2 = 0;
        std::cin >> numA >> numB >> numC;

        num1 = numA - numB;
        num2 = numC - num1;

        std::cout << (num2 < 0 ? 0 : num2) << std::endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define MOD2 998244353
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;

template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

int main(){
    FAST;
    int n, k, c, j = 0;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    V<int> b(k, -1), e(k, -1);
    loop(i, 0, n) {
        if(s[i] == 'o') {
            b[j++] = i;
            i = i + c;
        }
        if(b[k-1] != -1) {
            break;
        }
    }
    j = k-1;
    loopr(i, n-1, 0) {
        if(s[i] == 'o') {
            e[j--] = i;
            i = i - c;
        }
        if(e[0] != -1) {
            break;
        }
    }
    loop(i, 0, k) {
        if(b[i] == e[i]) {
            cout << b[i]+1 << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3348
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] f = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      f[i] = n;
      sum += n;
    }
    
    double ave = (double)sum/N;
    int ans = 0;
    double min = 1000.0;
    for(int i = 0; i < N; i++){
      double n = Math.abs(ave - f[i]);
      if(n < min){
        ans = i;
        min = n;
      }
    }
    System.out.println(ans);
  }
}

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

const long long INF = 1LL << 60;
long long dp[100010]; 

int main(void)
{	
	dp[0] = 0;
	for (int n = 1; n <= 100000; n++)
	{
		dp[n]= INF;
		int power = 1;
		while (power <= n)
		{
			dp[n] = min(dp[n], dp[n-power]+1);
			power *= 6;
		}
		power = 1;
		while (power <= n)
		{
			dp[n] = min(dp[n], dp[n - power] + 1);
			power *= 9;
		}
	}
	int n; cin >> n;
	cout << dp[n] <<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long arr[100005] , mem[100005];
int main() {
	int n;cin>>n;
	for(int i = 0; i < n; i++)
		cin>>arr[i];
	long long ans = 0;
	for(int i = n-1 ; i> 0 ; i--){
		if(arr[i] <=arr[i-1]){
			mem[i] = mem[i+1] + 1;
		}else{
			mem[i] = 0;
		}
		ans = max(ans,mem[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

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

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

int main()
{
    ll x,res=0;
    cin >> x;
    ll now=100;

    while(1) {
        res++;
        now = now*1.01;
        if (now>=x)
        {
            cout << res << endl;
            break;
        }
    }
    return 0;
}

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

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

 int main() {
   int N;
   cin >> N;
   vector<int> B(N - 1);
   rep(i, N - 1) cin >> B.at(i);

   int ans = B.at(0);

   for (int i = 1; i < N - 1; i++) {
     ans += min(B.at(i - 1), B.at(i));
   }
   ans += B.at(N - 2);
   cout << ans << endl;
 }


Measured memory_bytes: 256
N = int(input())
s = []
for _ in range(N):
    s.append(int(input()))

s.sort()

ans = sum(s)

if ans % 10 != 0:
    print(ans)
    exit()

for i in range(N):
    if (ans - s[i]) % 10 != 0:
        print(ans - s[i])
        exit()

print(0)

Measured memory_bytes: 3060
#include <cstdio>
#include <map>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, a, s;
map<ll,ll> mp;
map<ll,ll>::reverse_iterator it;
int main() {
	int i;
	scanf("%lld", &n);
	while(n--) scanf("%lld", &a), mp[a]++;
	for(it=mp.rbegin(); it!=mp.rend(); it++) {
		if(it->S>=4) {
			if(s>0) s *= it->F;
			else s = it->F * it->F;
			break;
		}
		else if(it->S>=2) {
			if(s>0) {s *= it->F; break;}
			else s = it->F;
		}
	}
	printf("%lld", s);
	return 0;
}

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

#define reg register

using namespace std;

const int MAXN=2e5+1;

string s,b("");
int n,q,rev[MAXN]= {0},tot=0;
struct INS {
	int f,no;
	char c;
} ins[MAXN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>s>>q;
	n=s.length();
	reg int t,f;
	reg char c;
	for(reg int i=1; i<=q; ++i) {
		cin>>t;
		rev[i]=rev[i-1];
		if(t==1) ++rev[i];
		else {
			cin>>f>>c;
			++tot;
			ins[tot].f=f,ins[tot].c=c,ins[tot].no=i;
		}
	}
	if(rev[q]&1) reverse(s.begin(),s.end());
	for(reg int i=1; i<=tot; ++i) {
		if((rev[q]-rev[ins[i].no])&1) {
			if(ins[i].f==1) s+=ins[i].c;
			else b+=ins[i].c;
		} else {
			if(ins[i].f==1) b+=ins[i].c;
			else s+=ins[i].c;
		}
	}
	reverse(b.begin(),b.end());
	cout<<b<<s<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N - 1);
  rep(i,N) cin >> A.at(i);
  rep(i,N) cin >> B.at(i);
  rep(i,N - 1) cin >> C.at(i);
  int sum = 0;
  rep(i,N) {
    sum += B.at(A.at(i) - 1);
  }
  rep(i,N - 1) {
    if(A.at(i) + 1 == A.at(i + 1)) {
      sum += C.at(A.at(i) - 1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
require 'date'

class Today
  def initialize
    @wday = {0 => "Sunday", 1 => "Monday", 2 => "Tuesday", 3 => "Wednesday",
             4 => "Thursday", 5 => "Friday", 6 => "Saturday"}
    @dates = []
    @result = []
    while date = $stdin.gets.chomp.split(' ').map(&:to_i) do
      break if date[0] == 0 && date[1] == 0
      @result.push(Date.new(2004,date[0],date[1]).wday)
    end

    @result.each do |day|
      puts @wday[day]
    end
  end
end

t = Today.new

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

void bubbleSort(int*, int);

int ans = 0;

int main(void){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	bubbleSort(a, n);
	
	for(int i=0; i<n-1; i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;
	cout << ans << endl;
	return 0;
}

void bubbleSort(int* a, int n){
	bool flg = 1;
	while(flg){
		flg = 0;
		for(int j = n-1; j >=1; j--){
			if(a[j] < a[j-1]){
				int bf = a[j];
				a[j] = a[j-1];
				a[j-1] = bf;
				flg = 1;
				ans++;
			}
		}
	}
	return;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[100001];
    int i,j;
    scanf("%s",s);
    for(i='a';i<='z';i++){
        for(j=0;j<strlen(s);j++)if(s[j]==i)break;
        if(j==strlen(s)){
            printf("%c",i);
            return 0;
        }
    }
    puts("None");
    return 0;
}

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

int main(){
  long int n;
  scanf("%ld",&n);
  for(long int i=(int)sqrt(n*1.0);i>0;i--){
    if(n%i==0){
      printf("%ld\n",n/i+i-2);
      return 0;}}
  return 0;
}


Measured memory_bytes: 128
(defun read-a (pos line acc)
  (let ((d (char line pos)))
  (if (char= d #\ )
      (cons pos (concatenate 'string (reverse acc)))
      (read-a (1+ pos) line (push d acc)))))

(defun read-b (start line)
  (let* ((b-str (subseq line start))
         (len (length b-str)))
    ;; len is 1 3 4 (x x.y x.yz)
    (cond ((= len 1)
           (parse-integer b-str))
          ((= len 3)
           (with-input-from-string (in (format nil "~A~A/10" (char b-str 0) (char b-str 2)))
             (read in nil nil)))
          ((= len 4)
           (with-input-from-string (in (format nil "~A~A~A/100"
                                               (char b-str 0) (char b-str 2) (char b-str 3)))
             (read in nil nil))))))

(let* ((l (read-line))
       (pos/a (read-a 0 l nil))
       (b-start (1+ (car pos/a)))
       (a (parse-integer (cdr pos/a)))
       (b (read-b b-start l)))
  (format t "~A~%" (floor (* a b))))


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

int main() {
    string s; cin >> s;
    ll ans = 0;
    rep (i, (1<<s.size()-1)) {
        ll sum = 0, cur = 0;
        rep (j, s.size()) {
            // フラグがたっていたら分割されるように
            if (j > 0 && (i & (1<<j-1))) {
                sum += cur;
                // 
                cur = 0;
            }
            cur = cur * 10 + (s[j] - '0');
            cerr << cur << endl;
        }
        sum += cur;
        ans += sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
DATA = """
10 4 8
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, X, Y = [int(i) for i in get_line().strip().split(" ")]
X-=1
Y-=1
INF = 10 * 20
m = [[0] * N for _ in range(N)]
tt = [0] * N

#print(ret)
#print(len(ret))

for r in range(N):
	for c in range(r+1, N):
		m[r][c] = c - r
		#m[c][r] = m[r][c]
		tt[m[r][c]] += 1
		m[c][r] = m[r][c]

def Set(r, c, v):
	if m[r][c] < v:
		return False
	else:
		tt[m[r][c]] -= 1
		m[r][c] = v
		tt[m[r][c]] += 1
		return True

for r in range(N):
	if not Set(r, Y, m[r][X]+1):
		continue
	for c in range(Y+1, N):
		if not Set(r, c, m[r][c-1]+1):
			break
	for c in range(Y-1, X, -1):
		if not Set(r,c, m[r][c+1]+1):
			break

for t in tt[1:]:
	print (t)

Measured memory_bytes: 113904