akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main() {
    int N, K;
    std::string S;
    std::cin >> N >> K >> S;

    std::vector<int> nums;
    nums.reserve(100000);

    int cnt = 0;
    int current = 1;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == ('0' + current)) {
            ++cnt;
        } else {
            nums.push_back(cnt);
            cnt = 1;
            current = 1 - current;
        }
    }

    if (cnt != 0) {
        nums.push_back(cnt);
    }

    if (nums.size() % 2 == 0) {
        nums.push_back(0);
    }

    int sum[nums.size() + 1] = {0};
    for (size_t i = 0; i < nums.size(); ++i) {
        sum[i+1] = sum[i] + nums[i];
    }

    const int add = 2 * K + 1;
    int ans = 0;
    for (size_t i = 0; i < nums.size(); i += 2) {
        const int left = i;
        const int right = std::min(i + add, nums.size());
        const int tmp = sum[right] - sum[left];
        ans = std::max(ans, tmp);
    }

    std::printf("%d\n", ans);

    return 0;
}


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

namespace ABC_Training
{

    public class Program
    {
        static void Main(string[] args)
        {
            var nkq = Console.ReadLine().Split(' ');
            var n = int.Parse(nkq[0]);
            var k = int.Parse(nkq[1]);
            var q = int.Parse(nkq[2]);

            //int[] points = new int[n];
            var points = Enumerable.Repeat(0, n).ToArray();
            for(int i = 0;i < q; i++)
            {
                var idx = int.Parse(Console.ReadLine()) - 1;
                points[idx]++;
            }
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(points[i] - q + k > 0 ? "Yes" : "No");
            }
        }
    }
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int s;
    cin >> s;
    int pos = 2;
    map< int, int > mp;
    do {
        mp[s] = 1;
        if( s % 2 == 0 ) s = s / 2;
        else s = 3 * s + 1;
        ++pos;


    } while( mp[s] == 0 );
    cout << pos - 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 998244353;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  set<int> s[m];
  rep(i, m) {
    int k;
    cin >> k;
    rep(j, k) {
      int s1;
      cin >> s1;
      s1--;
      s[i].insert(s1);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(i, 1 << n) {
    vector<int> p2(m);
    rep(j, n) {
      if (i & (1 << j)) {
        rep(k, m) {
          if (s[k].count(j)) (p2[k] += 1) %= 2;
        }
      }
    }
    if (p == p2) ans++;
  }
  cout << ans << endl;
}


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

int main() {
	int N ;
    cin >> N ;
    int N2 = N;
    int sum = 0;
    for(int i = 0; i < 9; i++){
    	sum += N % 10;
        N /= 10;
    }
    if(N2 % sum == 0){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}


Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
xn = [int(x) for x in input().split()]

diffs = []
ranges = []
for i in range(N - K + 1):
  diffs.append(xn[i+K -1] - xn[i])
  ranges.append((i, i + K - 1))
  
sums = []
for diff, range_ in zip(diffs, ranges):
  r = min(abs(xn[range_[0]]), abs(xn[range_[1]]))
  sums.append(r+diff)
print(min(sums))


Measured memory_bytes: 18248
O = input()
E = input()
password = []
if (len(O)+len(E))%2 != 0:
    for i in range(len(O)):
        password.append(O[i])
        if i == (len(O)-1): break
        password.append(E[i])
else:
    for i in range(len(E)):
        password.append(O[i])
        password.append(E[i])


print(*password, sep='')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
//const ll mod=1e9+7;
const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d) {
    cout << "Left" << endl;
  }
  else if(a+b<c+d) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import math
from collections import defaultdict

def prime_fact(n):
    count = defaultdict(int)
    for p in range(2, math.ceil(math.sqrt(n)) + 1):
        while n % p == 0:
            count[p] += 1
            n //= p
    if n != 1:
        count[n] += 1
    return count


def submit():
    n = int(input())
    primes = prime_fact(n)

    ans = 0
    for p, c in primes.items():
        pw = 1
        while c - pw >= 0:
            c -= pw
            ans += 1            
            pw += 1
    print(ans)
            


if __name__ == "__main__":
    submit()

Measured memory_bytes: 9480
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    ll L,R; cin >> L >> R;
    if (R-L > 3000){
        cout << 0 << endl;
        return 0;
    }
    ll mn = 5000;
    for(ll i = L; i < R; i++){
        for(ll j = i+1; j <= R; j++){
            ll check = (i%2019)*(j%2019)%2019;
            mn = min(mn,check);
        }
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

n,m=gets.split.map(&:to_i)
parentarray=Array.new(n,0)
union=UnionFind.new(n)

m.times{
    x,y,z=gets.split.map(&:to_i)
    union.unite(x-1,y-1)
}

n.times{|i|
    parentarray[i]=union.get_parent(i)
}

puts  parentarray.uniq.count

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


int main() {
    int N;
    std::cin >> N;
    std::map<std::string, std::vector<std::pair<int, int>>> city_rests;

    for (int i = 0; i < N; i++) {
        std::string city;
        int point;
        std::cin >> city >> point;
        if (city_rests.find(city) == city_rests.end()) {
            city_rests[city] = std::vector<std::pair<int, int>>();
        }
        city_rests[city].emplace_back(std::make_pair(i, point));
    }

    for (auto city : city_rests) {
        std::sort(city.second.begin(), city.second.end(), [](std::pair<int, int> &lhs, std::pair<int, int> &rhs) { return lhs.second > rhs.second; });
        for (auto rest : city.second) {
            std::cout << rest.first + 1 << std::endl;
        }
    }
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN],c[MAXN];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int ans=0;
        memset(c,0,sizeof(c));
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]>n) ans++;
            else
            {
                c[a[i]]++;
            }
        }
        for(int i=1;i<=n;i++)
        {
            if(c[i])
            {
                if(c[i]>i)
                {
                    ans+=c[i]-i;
                }
                if(c[i]<i)
                {
                    ans+=c[i];
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	ll ans = min(A + B + 1, C) + B;
	cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
X=list(map(int,input().split()))
L=[]
for i in range(n):
    l=[i,X[i]]
    L.append(l)
LS=sorted(L,key=lambda x:x[1])
LSM=[0]*n
for i in range(n):
    if i<n//2:
        LSM[LS[i][0]]=LS[n//2][1]
    else:
        LSM[LS[i][0]]=LS[n//2-1][1]
for i in range(n):
    print(LSM[i])

Measured memory_bytes: 45380
let scanInts () = stdin.ReadLine().Split() |> Array.map int

let [|n|] = scanInts ()

// mod4
// 0-> ok
// 3-> 3, 7OK
// 2-> 2, 6, 10, 14ok
// 1-> 1.5.9,13,17, 21ok..

match n % 4 with
| 0 -> "Yes"
| 1 -> if n < 21 then "No" else "Yes"
| 2 -> if n < 14 then "No" else "Yes"
| 3 -> if n < 7 then "No" else "Yes"

|> printfn "%s"

Measured memory_bytes: 14040
#include<stdio.h>
#include<stdlib.h>
#include<string.h>



int main()
{
	int i;
	char str[81] = { 0 }, *p = NULL;
	double buf[81] = { 0 };

	while (fgets(str, 81, stdin) != NULL)
	{
		//printf("%s",str);
		i = 0;
		for (p = strtok(str, " \n"); p != NULL; p = strtok(NULL, " \n"))
		{
			//printf("%s ", p);
			if (strlen(p) == 1)
			{
				switch (*p)
				{
				case '+': buf[i - 2] += buf[i - 1];
						  buf[i] = 0; --i;
						  break;
				case '-': buf[i - 2] -= buf[i - 1];
						  buf[i] = 0; --i;
						  break;
				case '*': buf[i - 2] *= buf[i - 1];
						  buf[i] = 0; --i;
						  break;
				case '/': buf[i - 2] /= buf[i - 1];
						  buf[i] = 0; --i;
					      break;
				default:buf[i] = atof(p);
						++i; break;
				}
			}
			else
			{
				 buf[i]= atof(p);;
				 ++i;
			}
		}

		printf("%.6f\n",buf[0]);
	}


	return 0;
}


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

# In[15]:


import sys
input = sys.stdin.readline
N, M = map(int, input().split())


# In[ ]:


"""
4 2
1 3
2 4
"""


# In[19]:


l_ = 0
r_ = N
for i in range(M):
    l, r = map(int, input().split())
    l_ = max(l_, l)
    r_ = min(r_, r)


# In[21]:


#print(l_, r_)
ids = r_-l_+1
if ids < 0:
    print(0)
else:
    print(ids)


# In[ ]:






Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#define N 1010
#define max(a, b)(a < b ? b : a)

char a[N],b[N];
int c[N][N];

int LCS(){
  const int a_size = strlen(a) - 1; 
  const int b_size = strlen(b) - 1;
  int i,j,m;
  memset(c,0,sizeof(c));
  for(i = 1; i < a_size + 1;++i){
    for(j = 1;j < b_size + 1;++j){
      m = max(c[i][j - 1],c[i - 1][j]);
      if(a[i - 1] == b[j - 1]){
        m = max(m,c[i - 1][j - 1] + 1);
      }
      c[i][j] = m;
    }
  }
  return c[a_size][b_size];
}

int main(){
  int c[N];
  int n, i;
  scanf("%d\n", &n);
  for(i = 0;i < n;i++){
    fgets(a,N,stdin);
    fgets(b,N,stdin);
    c[i]=LCS();
  }
  
  for(i=0;i<n;i++){
    printf("%d\n",c[i]);
  }
  
}



Measured memory_bytes: 5844
#include <stdio.h>

int Q ;
char ans[35] ;

void DFS ( int , int , int ) ;

int main ( )
{
	//freopen ( "input.txt" , "rt" , stdin ) ;
	//freopen ( "output.txt" , "w+t" , stdout ) ;
	while ( scanf ( "%d" , &Q ) == 1 && Q ) {
		DFS ( Q , 0 , -1 ) ;
	}
	return 0 ;
}

void DFS ( int source , int sum , int idx )
{
	if ( sum > 0 && sum <= Q ) {
		
		ans[idx] = source + '0' ;
		ans[idx + 1] = '\0' ;
		if ( sum == Q ) {
			for ( int i = 0 , j = 0 ; ans[i] ; j++ ) {
				if ( ( j & 1 ) == 1 && ans[i] ) {
					putchar ( ' ' ) ;
				}
				else {
					printf ( "%d" , ans[i] - '0' ) ;
					i++ ;
				}
			}
			putchar ( '\n' ) ;
		}
	}
	for ( int i = source ; i > 0 ; i-- ) {
		if ( sum + i <= Q ) {
			DFS ( i , sum + i , idx + 1 ) ;
		}
	}
}

Measured memory_bytes: 1028
using System;
class Program{
  static void Main(string[] args){
    string s = Console.ReadLine();
    int p=10;
    string t="[ATGC]";
    string w=t;
    for(int i=0;i<10;i++){
      if(!System.Text.RegularExpressions.Regex.IsMatch(s,w)){
        p=i;break;
      }
      w+=t;
    }
    Console.WriteLine(p);
  }
}

Measured memory_bytes: 13908
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k;
    cin >> n >> k;
    int ans = k;
    while (--n) {
        ans *= k-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 998244353;
const ll INF = 1LL << 60; //MAX 9223372036854775807
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
//演算の定義
auto query = [](ll x, ll y) { return max(x, y); };
//単位元
const ll unit =-INF;
struct SegTree
{
  private:
    ll n;
    vector<ll> node;

  public:
    SegTree(vector<ll> v)
    {
      node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); //最小値なので残りはINFで埋める
      n = 1LL << 64 - __builtin_clzll(v.size());
      for (ll i = 0; i < v.size(); i++)
        node[i + n - 1] = v[i]; //最下段から構築
      for (ll i = n - 2; i >= 0; i--)
        node[i] = query(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(ll x, ll val)
    {
      x += (n - 1);  // 最下段index
      node[x] = val; //valを加算などするときは+=
      while (x > 0)
      {
        x = (x - 1) / 2;
        node[x] = query(node[2 * x + 1], node[2 * x + 2]);
      }
    }

    // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
    ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
    {
      // 最初に呼び出されたときの対象区間は [0, n)
      if (r < 0)
        r = n;
      // 要求区間と対象区間が交わらない -> 適当に返す
      if (r <= a || b <= l)
        return unit;
      // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
      if (a <= l && r <= b)
        return node[k];
      // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
      // 左側の子を vl ・ 右側の子を vr としている
      // 新しい対象区間は、現在の対象区間を半分に割ったもの
      ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
      ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
      return query(vl, vr);
    }
};
int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> v(n);
vector<ll> dp(n+1);
dp[n]=1;
rep(i,n){
  cin >> v[i].first >> v[i].second;
}
sort(v.begin(),v.end());
vector<ll> t(n,-INF);
t[n-1]=v[n-1].first +v[n-1].second;
SegTree s(t);
rep(i,n){
  dp[n-i-1]=dp[n-i];
  auto itr1 = lower_bound(v.begin(), v.end(), make_pair(v[n-i-1].first +v[n-1-i].second,0LL));
  ll u=itr1-v.begin();
  ll mx=max(v[n-i-1].first +v[n-1-i].second,s.getmin(0, u));
  s.update(n-i-1, mx);
  pair<ll,ll> p={mx ,0};
  auto itr = lower_bound(v.begin(), v.end(), p);
  dp[n-i-1]=mod(dp[n-i-1]+dp[itr-v.begin()]);
}
cout << dp[0] << endl;
return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
string s;
signed main() {
  cin>>s;
  int n=s.size();
  if(s[0]==s[n-1]){
    if(n%2)puts("Second");
    else puts("First");
    }
  else {
    if(n%2)puts("First");
    else puts("Second");
    }
	ggr
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private struct Item
        {
            public int v;
            public int w;
            public Item(int v, int w)
            {
                this.v = v;
                this.w = w;
            }
        }
        private static void SolveA(string[] args)
        {
            int[] hw = ReadAndParseIntArr();
            int h = hw[0];
            int w = hw[1];
            int[,] c = new int[h+1, w+1];
            for(int i=1;i<h+1;++i)
            {
                int[] tmpc = ReadAndParseIntArr();
                for(int j=0;j<tmpc.Length;++j)
                {
                    c[i, j+1] = tmpc[j];
                }
            }

            int maxWidth = 0;
            int[,] dp = new int[h+1, w+1];
            
            for(int i=1;i<=h;++i)
            {
                for(int j=1;j<=w;++j)
                {
                    if(c[i,j] == 1)
                    {
                        dp[i, j] = 0;
                    }
                    else
                    {
                        dp[i,j] = Math.Min(dp[i-1,j-1], Math.Min(dp[i-1,j], dp[i, j-1])) +1;
                        maxWidth = Math.Max(maxWidth, dp[i, j]);
                    }
                }
            }
            Console.WriteLine(maxWidth * maxWidth);
        }
        
    }
}



Measured memory_bytes: 52700
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, LL> Vec2;
LL h, w, n, m, s, t, ans = 0, a[100000], b[100000], num = 1, sum = 0, dp[3200][3200] = {};
string str;
int main() {
	cin >> n >> m;
	a[0] = m / 10000;
	m %= 10000;
	a[1] = m / 5000;
	m %= 5000;
	a[2] = m / 1000;
	b[0] = a[0], b[1] = a[1], b[2] = a[2];
	while (a[0] > -1) {
		a[1] = b[1], a[2] = b[2];
		while (a[1] > -1) {
			if (a[0] + a[1] + a[2] == n) {
				cout << a[0] << " " << a[1] << " " << a[2] << endl;
				return 0;
			}
			a[1] -= 1;
			a[2] += 5;
		}
		a[0] -= 1;
		b[1] += 2;
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  string S;
  cin >> S;

  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
    cout << "Bad"<<endl;
    return 0;
  } else{
    cout << "Good" <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
void trozen()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans=(n%x==0)?(n/x):(n/x+1);
    ans=ans*t;
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
	int n,i,j;
	scanf("%d",&n);
	printf("%d\n",n*(n-1)/2-n/2);
	if(n&1){
		for(i=1;i<n;i++){
			for(j=i+1;j<=n;j++){
				if(i+j!=n)printf("%d %d\n",i,j);
			}
		}
	}else{
		for(i=1;i<n;i++){
			for(j=i+1;j<=n;j++){
				if(i+j!=n+1)printf("%d %d\n",i,j);
			}
		}
	}
}

Measured memory_bytes: 128
A=int(raw_input())
B=int(raw_input())
C=int(raw_input())
X=int(raw_input())
r=0
for a in xrange(A+1):
  for b in xrange(B+1):
    for c in xrange(C+1):
      if 500*a+100*b+50*c==X:
        r+=1
print(r)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  int n;
  cin>>n;
  npairs(int,int,v,n);
  double sum = 0;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      sum+=sqrt(pow(v[i].first-v[j].first,2)+pow(v[i].second-v[j].second,2));
    }
  }
  cout<<setprecision(12)<<sum/n;
}


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

#define INF              1e15
#define EPS               1e-9
#define MOD             1000000007
#define Pi               3.14159265358979323846264338327950288419716939937510

#define umap             unordered_map
#define uset             unordered_set
#define fi               first
#define se               second
#define ll               long long 
#define vi               vector<int>
#define pii             pair<int,int>
#define vll             vector<ll>
#define pll              pair<ll,ll>
#define pb               push_back
#define pob             pop_back
#define pf               push_front
#define pof             pop_front
#define maxE(a,n)           *max_element(a,a+n);
#define minE(a,n)           *min_element(a,a+n);
#define all(x)             x.begin(), x.end()

#define fast             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fori(i,a,n)         for (ll  i=a;i<n;i++)
#define ford(i,a,n)         for (ll  i=n-1;i>=a;i--)

ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}

using namespace std;


void solve(){

    string s;
    cin>>s;

    int  n = s.size();
    if(s[n-1] != 's'){
      s = s + 's';
    }
    else{
      s = s + "es";
    }

    cout<<s<<endl;

}


int main(){

  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  fast;
  ll t = 1;


  while(t--){
    solve();
  }
}


Measured memory_bytes: 3660
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define ll long long int

int main ()
{
    ll a , b , c , ans;
    cin>>a>>b>>c;

    if ( a % 2 == 0 || b % 2 == 0  || c % 2 == 0 )
    {
        cout<<0<<endl;
    }
    else 
    {
        ans = min( min( a*b, a*c ) , (b *c) ); 
        cout<<ans<<endl;
    }
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S;
	cin >> T;

	LL ans = INF;
	for(int i=0; i<=S.size()-T.size(); i++){
		LL v = 0;
		for(int j=0; j<T.size(); j++){
			if(S[i+j] != T[j]){
				v++;
			}
		}
		if(v < ans){
			ans = v;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3740
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	multiset<ll> tes;
	vector<ll> ket;
	for(int i=0;i<N;i++){
		ll a;
		scanf("%lld",&a);
		ket.push_back(a);
	}
	for(int i=0;i<4;i++)
	 ket.push_back(0);
	sort(ket.begin(),ket.end());
	reverse(ket.begin(),ket.end());
	int vs=ket.size();
	ll fir=0,sec=0;
	for(int i=1;i<vs;i++){
		if(fir==0){
			if(ket[i]==ket[i-1]){
				fir=ket[i];
				i++;
			}
		}
		else if(sec==0){
			if(ket[i]==ket[i-1]){
				sec=ket[i];
			}
		}
		else{
			break;
		}
	}
	cout<<fir*sec<<endl;
	return 0;
}

Measured memory_bytes: 1400
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parents =[-1]*n

  def find(self, x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
    
  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x)==self.find(y)

  def members(self, x):
    root=self.find(x)
    return list(i for i in range(self.n) if self.find(i) == root)

  def roots(self):
    return list(i for i, x in enumerate(self.parents) if x < 0)

  def group_count(self):
    return len(self.roots)

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

adj=[]
N, M = map(int, input().split())
for m in range(M):
  a,b=map(int, input().split())
  adj.append([a-1,b-1])

ans = 0
for i in range(M):
  uf = UnionFind(N)
  for j in range(M):
    if i == j:
      continue
    uf.union(*adj[j])
  if len(set(uf.roots()))!=1:
    ans += 1
print(ans)

Measured memory_bytes: 9304
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)

using namespace std;

int main()
{
	int N, L;
	pair<string,string> tmp[100];
	cin >> N >> L;
	REP(i, N) {
		cin >> tmp[i].second;
	}
	REP(i, N) {
		tmp[i].first= tmp[i].second[0];
		
	}
	sort(tmp,tmp + N);
	
	REP(i, N) {
		cout << tmp[i].second;
	}
	cout << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  map<string, int> m;
  while(N--) {
    string s; cin>>s;
    
    ++m[s];
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

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

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long

using namespace std;

const int N = 2e5 + 50;
ll pw[N];
ll mod = 1e9 + 7;
ll a[N];
ll b[N];

ll gcd(ll a, ll b) {
      while (b) { a %= b, swap(a, b); }
      return a;
}

map<pair<ll, ll>, pair<ll, ll>> s;

ll mul(ll a, ll b) {
      a %= mod;
      b %= mod;
      return (a * b) % mod;
}

ll add(ll a, ll b) {
      a %= mod;
      b %= mod;
      return (a + b + mod) % mod;
}

int main() {
      cin.sync_with_stdio(0);
      pw[0] = 1;
      for (int i = 1; i < N; ++i) pw[i] = mul(pw[i - 1], 2);
      int n;
      cin >> n;
      for (int i = 0; i < n; ++i) {
            cin >> a[i] >> b[i];
      }
      ll ox = 0;
      ll oy = 0;
      ll t = 0;
      for (int i = 0; i < n; ++i) {
            if (!a[i] && !b[i]) {
                  t++;
                  continue;
            }
            ll f = gcd(llabs(a[i]), llabs(b[i]));
            a[i] /= f;
            b[i] /= f;
            if (b[i] == 0) {
                  ox++;
            } else if (a[i] == 0) {
                  oy++;
            } else {
                  if (a[i] < 0) a[i] *= -1, b[i] *= -1;
                  if (b[i] < 0) s[{-b[i], a[i]}].second++;
                  else s[{a[i], b[i]}].first++;
            }
      }
      ll d = add(add(pw[ox], pw[oy]), -1);
      ll ans = d;
      for (auto i : s) {
            ll d = add(add(pw[i.second.first], pw[i.second.second]), -1);
            ans = mul(ans, d);
      }
      cout << add(add(ans, t), -1);
      return 0;
}

Measured memory_bytes: 23852
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 



 
signed main(){
    int n,d;
    cin>>n>>d;
    cout<<(n-1)/(2*d +1) +1;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
// for copy
// for(int i=0;i<N;++i) {
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

int main(void) {
  int a,b;
  cin >> a >> b;
  if (0<a && a<10 && 0<b && b<10)
    pr(a*b);
  else
    pr("-1");
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int w,s;
  
  cin>>s>>w;
  
  if(w>=s)
  {
    
    cout<<"unsafe"<<"\n";
    
  }
  else
  {
      cout<<"safe"<<"\n";
  
  }
}


Measured memory_bytes: 3620
import math
from decimal import Decimal
n, m, d = map(int, input().split())
if d == 0:
    t = math.exp(float(Decimal.from_float(math.log(n)+math.log(m-1)-2*math.log(n))))
    print(t)
else:
    t = 2.0 * (n - d)*(m-1) / n ** 2
    print(t)

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


int main() {
string S;
cin >> S;
bool flag1 = true;
bool flag2 = true;
for(int i = 0;i<S.size();i++){
    if(i%2 == 0){
        if(S[i] == 'L'){
         flag1 = false;
        break;
        }
    }
    if(i%2 == 1){
        if(S[i] == 'R'){
            flag2 = false;
          break;
        }
    }
}
if(flag1 && flag2) cout << "Yes" << endl;
else cout << "No" << endl;
}

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

int n;

vector<int> v;
vector<int> vv;


int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    int mx=v.back();
    for(int i=1;i<=mx;i++){
        if((mx%i)==0){
            vv.push_back(i);
        }
    }
    sort(vv.begin(),vv.end());
    long long int ans=0;
    for(int i=0;i<v.size();i++){
        int id=lower_bound(vv.begin(),vv.end(),v[i])-vv.begin();
        ans+=vv[id]-v[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3556
import math
N=int(input())

length = int(math.log10(N))+1
sum_num=0

for i in range(length):
    if (i+1)%2!=0:
        if (i+1) != length:
            sum_num += 10**(i)*9
        else:
            sum_num += N-10**i+1
print(sum_num)

Measured memory_bytes: 3060
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
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))

N,L = inm()
S = []
for _ in range(N):
    S.append(input())

S.sort()
print(''.join(S))


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

using namespace std;

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

    if(S.at(0) != 'A'){
	cout << "WA" << endl;
	return 0;
    }
    int sum = 0;
    for(int i = 2; i < S.size()-1; i++){
	if(S.at(i) == 'C') sum++;
    }
    if(sum != 1){
	cout << "WA" << endl;
	return 0;
    }
    sum = 0;
    for(int i = 0; i < S.size(); i++){
	if('A' <= S.at(i) && S.at(i) <= 'Z') sum++;
    }
    if(sum > 2){
	cout << "WA" << endl;
	return 0;
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
#include <sstream>
#include  <list>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/

int cmd(int a, int b)
{
    return a>b;
}
int main()
{
    int t;
    cin >>t;
    int a[t],sum=0;
    for(int i=0;i<t;i++){
        cin >>a[i];
        sum+=a[i];
    }
    sort(a,a+t,cmd);
    if(sum%10==0){
        for(int i=t-1;i>=0;i--){
            if(a[i]%10!=0){
             sum-=a[i];
             if(sum%10!=0)
                break;
            }
    }
    }
    if(sum%10==0)
        sum=0;
    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)




int main(){
    long long n, a, b;
    cin >> n >> a >> b;

    if((b-a)%2 == 0) cout << (b-a)/2 << endl;
    else{
        cout << min((a-1), (n-b)) + 1 + (b-a-1)/2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int v[30],c[30];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(v[i]>c[i]) sum+=v[i]-c[i];
    }
    cout<<sum<<endl;
    return 0;
}




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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int m[n] = {0};
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    m[a - 1]--;
  }
  for (int i = 0; i < n; i++) {
    if (m[i] >= k - q) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll h, w;
  cin >> h >> w;
  vvc a(h, vc(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  vll h_flag(h, 0), w_flag(w, 0);
  rep(i, h) rep(j, w)
  if (a[i][j] == '#')
  {
    h_flag[i]++;
    w_flag[j]++;
  }
  rep(i, h)
  {
    if (h_flag[i] == 0)
      continue;
    rep(j, w)
    {
      if (w_flag[j] == 0)
        continue;
      cout << a[i][j];
    }
    cout << endl;
  }
  return;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N;
    int A[2][100];
    cin>>N;
    int A1[100];
    int A2[100];
    rep(i,2) rep(j,N) cin>>A[i][j];
    A1[0]=A[0][0];
    rep(i,N-1) A1[i+1]=A1[i]+A[0][i+1];
    A2[N-1]=A[1][N-1];
    rep(i,N-1) A2[N-2-i]=A2[N-1-i]+A[1][N-2-i];
    int ans=0;
    rep(i,N) ans=max(ans,A1[i]+A2[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}


int main(){
	IOS;
	cout.precision(30) ;
	string s ; cin >> s ;
	ll k ; cin >> k ;
	k-- ;
	int fin1 = 0 ;
	while(fin1 < (int)s.size() && s[fin1] == '1') fin1++ ;
	if(k < fin1) cout << 1 << endl;
	else cout << s[fin1] << endl ;
	return 0;
}


Measured memory_bytes: 256
#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
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    int ans=0;
    rep(i,n){
        ans+=min(2*abs(x[i]),2*abs(x[i]-k));
    }
cout<<ans;
return 0;
}

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


int main(){
  int n;
  cin >>n;
  ll b =1e18;
  vector<ll>A(n);
  rep(i,n) {
    cin >>A[i];
    if(A[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i,n){
    if(b/ans>=A[i]) {
    ans*=A[i];
    }else{
    cout<<-1<<endl;
    return 0;
  }
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3980