akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

typedef long long ll;

const int N=5e3+5,Mo=1e9+7;

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

int t[N<<1],nxt[N<<1],lst[N],l;
void add(int x,int y) {t[++l]=y;nxt[l]=lst[x];lst[x]=l;}

int n,x,y,f[N][N],sz[N],g[N],h[N],a[N];

void dfs(int x,int y) {
	rep(i,x) if (t[i]!=y) dfs(t[i],x);
	sz[x]=1;f[x][1]=1;
	rep(i,x)
		if (t[i]!=y) {
			fo(j,1,sz[x]+sz[t[i]]) h[j]=0;
			fo(j,1,sz[x]) {
				inc(h[j],(ll)f[x][j]*g[t[i]]%Mo);
				fo(k,1,sz[t[i]])
					inc(h[j+k],(ll)f[x][j]*f[t[i]][k]%Mo);
			}
			fo(j,1,sz[x]+sz[t[i]]) f[x][j]=h[j];
			sz[x]+=sz[t[i]];
		}
	fo(i,1,sz[x]) inc(g[x],(ll)f[x][i]*a[i]%Mo);
}

int main() {
	scanf("%d",&n);
	fo(i,1,n-1) {
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	a[0]=Mo-1;
	fo(i,1,n) if (!(i&1)) a[i]=(ll)a[i-2]*(i-1)%Mo;
	dfs(1,0);
	printf("%d\n",Mo-g[1]);
	return 0;
}

Measured memory_bytes: 97152
{-# LANGUAGE BangPatterns #-}

import Control.Applicative ((<$>))
import Data.Maybe (fromJust)
import Data.Vector.Unboxed (Vector, unsafeFreeze, unsafeThaw, fromList, toList)
import Data.Vector.Unboxed.Mutable (IOVector, unsafeRead, unsafeSwap)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

type Start  = Int
type End    = Int
type Order  = Int
type Appear = Int
type Card   = (Appear, Char, Order)

ft :: Card -> Int
ft (a, _, _) = a
td :: Card -> Int
td (_, _, a) = a

toCard :: [(Int, [String])] -> [Card]
toCard [] = []
toCard ((idx, [a, x]):rest) = (idx, head a, read x) : toCard rest

main :: IO ()
main
    =   getLine
    >>  fromList . toCard . zip [0..] . map words . lines <$> getContents
    >>= unsafeThaw
    >>= \cards -> quickSort 0 (MV.length cards - 1) cards
    >>= isStable 0
    >>  unsafeFreeze cards
    >>= mapM_ toPrint . toList


quickSort :: Start -> End -> IOVector Card -> IO (IOVector Card)
quickSort start end cards
    | start >= end = return cards
    | otherwise    = do
        p <- partition start end cards
        quickSort start (p - 1) cards
        quickSort (p + 1) end cards


partition :: Start -> End -> IOVector Card -> IO Int
partition !start !end !cards = do
    card <- unsafeRead cards end
    checkAndSwap cards (td card) (start - 1) start
  where
    checkAndSwap !cards !pivot !i !j
        | j == end  = do
            unsafeSwap cards (i + 1) end
            return (i + 1)
        | otherwise = do
            card <- unsafeRead cards j
            case (td card) <= pivot of
                True -> do
                    unsafeSwap cards (i + 1) j
                    checkAndSwap cards pivot (i + 1) (j + 1)

                False -> do
                    checkAndSwap cards pivot i (j + 1)


isStable :: Int -> IOVector Card -> IO ()
isStable i cards
    | MV.length cards - 1 == i =
        putStrLn "Stable"

    | otherwise = do
        card1 <- unsafeRead cards i
        card2 <- unsafeRead cards (i + 1)
        if (td card1) == (td card2) && (ft card1) > (ft card2) then
            putStrLn "Not stable"
        else
            isStable (i + 1) cards


toPrint :: Card -> IO ()
toPrint (_, c, x) = putStrLn $ c : ' ' : show x


Measured memory_bytes: 11796
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path; ll pre = 0;
int main() {
	cin >> N;
	vl A(N), B(N);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < N; i++) cin >> B[i];
	vl P, Q;
	ll sum = 0;
	for (i = 0; i < N; i++) {
		if (A[i] > B[i]) P.push_back(A[i] - B[i]);
		else if (B[i] > A[i]) {
			ans++; sum += B[i] - A[i];
		}
	}
	if (sum <= 0) cout << 0;
	else {
		sort(P.begin(), P.end());
		reverse(P.begin(), P.end());
		for (i = 0; i < P.size(); i++) {
			ans++;
			sum -= P[i];
			if (sum <= 0) break;
		}
		if (sum > 0) cout << -1;
		else cout << ans;
	}
}

Measured memory_bytes: 2428
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  ll n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> a(n);
  forn(i,n){
    cin >> a[i].ff >> a[i].ss;
  }
  sort(all(a));
  ll i = 0;
  ll ans = 0;
  while (m){
    if (a[i].ss){
      ans += a[i].ff;
      a[i].ss--;
      m--;
    } else {
      i++;
    }
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

k (k-1) (k-1)

*/

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string sr;
    cin>>sr;
    if(sr.length()<6)
        cout<<"No";
    else
    {
        if(sr[2]==sr[3]&&sr[4]==sr[5])
            cout<<"Yes";
        else
            cout<<"No";
    }


return 0;
}


Measured memory_bytes: 256
# from sys import stdin
import math

X = int(input())

# for i in range(33):
ans = 0
for i in range(int(math.sqrt(X))+1):
    for x in range(11):
        # print(i,x)
        if i**x <= X and i**x > ans:
            ans = i**x
print(ans)


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

int main(){

    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;

    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(i*500+j*100+k*50==x) ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        long a=in.nextLong();
        long count=0;
        long b=in.nextLong();
        while(a<=b){
            count++;
            a=a*2;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
import time
start=time.time()
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
d=read()
c=list(reads())
s=[[]for i in range(d)]
for i in range(d):
    s[i]=list(reads())
contestcount=26
last=[0 for i in range(contestcount)]
maxscore=0
backup=()
score=0
t=[0 for i in range(d)]
for i in range(d):#日にち
  dele=0
  for j in range(contestcount):
        dele-=c[j]*(i+1-last[j])
  for j in range(contestcount):#貪欲法
    hoge=maxscore
    hoge+=s[i][j]
    hoge-=dele
    hoge+=c[j]*(i+1-last[j])
    if hoge>=score:
      backup=(j,last[j])
      score=hoge  
    #print(score,backup)
  maxscore=score
  last[backup[0]]=backup[1]
  t[i]=backup[0]
  #print(backup[0]+1)
backup=t[:]
import random
while(time.time()-start<1.8):
  ran1=random.randint(0,d-1)
  ran2=random.randint(0,d-1)
  newscore=0
  if ran1==ran2:
    if ran2!=0:
      ran2-=1
    else:ran2+=1
  t[ran1],t[ran2]=t[ran2],t[ran1]
  for i in range(d):
    newscore+=s[i][t[i]]
    last[t[i]]=i+1
    for j in range(contestcount):
        newscore-=c[j]*(i+1-last[j])
  #print(newscore,score,ran1,ran2)
  if newscore>score:
    score=newscore
  else:t=backup[:]
for i in range(d):
  print(t[i]+1)

Measured memory_bytes: 79332
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    bool f = false;
    for(int i=0; i<3; i++)
        if(S[i]==S[i+1])
            f = true;

    if(f)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    ll a=100000;
    while (n--) {
        a=(a*105)/100;
        a=(a+999)/1000*1000;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 2980
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static long K;

    static int[] a, b;

    static void input()
    {
        cin = new Scanner();

        N = cin.nextInt();
        K = cin.nextLong();

        a = new int[N];
        b = new int[N];

        for(int i = 0; i < N; i++)
        {
            a[i] = cin.nextInt();
            b[i] = cin.nextInt();
        }
    }
    static void solve()
    {
        input();
        Array.Sort(a, b);
        long iter = 0;
        for(int i = 0; i < N; i++)
        {
            iter += b[i];
            if (iter >= K)
            {
                WriteLine(a[i]);
                return;
            }
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 16064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> W){
    ll sun = accumulate(W.begin(),W.end(),0);
    ll cnt = 0;
    ll ans = INT16_MAX;
    for (int i = 0; i < N; i++)
    {
        cnt += W[i];
        sun -= W[i];
        ans =min(ans,abs(cnt-sun));
    }

    cout << ans << endl;
    
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> W(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&W[i]);
    }
    solve(N, std::move(W));
    return 0;
}


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

ll n, s, ans = -1;

inline ll read() {
	ll s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline ll f(ll b, ll n) {
	ll ans = 0;
	while(n)	ans += n % b, n /= b;
	return ans;
}

int main() {
	n = read(), s = read();
	ll u = sqrt(n) + 1;
	for(ll i = 2; i <= u; ++i)	if(f(i, n) == s) { ans = i; break; }
	if(n == s) { ans = n + 1; }
	if(ans == -1 && n > s) {
		ll c = n - s;
		u = c / (u - 1) + 1;
		for(ll i = u; i >= 1; --i) {
			ll b = c / i + 1;
			if(!(c % i) && s >= i && (s - i) < b && i < b) {
				ans = b;
				break;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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


int main() {

  int N;
  string S;
  cin >> N >> S;

  vector<int> num(26,0);
  for(int i = 0;i < N;i++) {
    int n = S.at(i) - 'a';
    num.at(n)++;
  }

  long long ans = 1;
  for(int i = 0;i < 26;i++) {
    ans *= (num.at(i)+1);
    ans %= MOD;
  }

  cout << --ans << endl;

}



Measured memory_bytes: 512
N,Y=map(int,input().split())
Y//=1000
x,y,z=-1,-1,-1
for i in range(min(N,Y//10),-1,-1):
    n=N-i
    t=Y-10*i
    for j in range(min(n,t//5),-1,-1):
        if n-j==t-5*j:
            x,y,z=i,j,n-j
            break
    else:continue
    break
print(x,y,z)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll b,ll n)
{
    if(n>=b)
    {
        return f(b,(n/b))+(n%b);
    }
    return n;
}
int main()
{
    ll n,s;
    cin>>n>>s;
    if(n==s)
    {
        cout<<(n+1)<<endl;
        return 0;
    }
    else if(n<s)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll MinAns=INT_MAX;
    for(ll i=2;i*i<=n;i++)
    {
        if(f(i,n)==s)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    ll X=n-s;
    for(ll j=sqrt(X);j>=1;j--)
    {
        if((n-s)%j==0)
        {
            ll i=((n-s)/j)+1;
            if(f(i,n)==s)
            {
                //MinAns=min(MinAns,i);
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }

    val sum = Array(n) {0}
    var sumAll = 0

    for (i in 0 until n) {
        sumAll += t[i]
        sum[i] += t[i]
        if (i > 0) {
            sum[i] += sum[i - 1]
        }
    }

    var ans = Int.MAX_VALUE
    for (i in 0 until n-1) {
        ans = Math.min(ans, Math.abs(sum[i] - (sumAll - sum[i])))
    }
    println(ans)
}

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

#define ld long double
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define nl '\n'
#define pii pair <ll, ll>
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846264
#define y1 abacaba
#define fn "abc"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pcnt(i) __builtin_popcount(i)
#define lcm(a,b) (a * b) / __gcd(a, b)
#define chill_wave ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pressF freopen("rsq.in", "r", stdin); freopen("rsq.out", "w", stdout);

using namespace std;

const long long MXN = 1e6 + 23;
const long long MAXN = 2e3 + 1;
const long long MOD = 1e9 + 7;
const long long MAXLOG = 20;
const long long INF = 1e18;

inline void f_math(bool ok = 0) { chill_wave if(ok) { pressF; } }

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

int n, a[MXN], sum;

int main() {

    f_math();
   	
 	cin >> n;    
 	for(int i = 1; i <= n; i++) {
 		cin >> a[i];
 		sum += a[i];
 	}
 	sort(a + 1, a + 1 + n);
 	if(sum % 10 != 0) cout << sum;
 	else {
 		bool was = 0;	
 		for(int i = 1; i <= n; i++) {
 			if(a[i] % 10 != 0) {
 				cout << sum - a[i];
 				was = 1;
 				break;
 			} 
 		}
 		if(!was) cout << was;
 	}  
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W && H && W)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}


Measured memory_bytes: 3876
#include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#define INF 10000
using namespace std;
short d[8][8][8][8][8][8][8][8];
int dpos[4] = { 1, -1, 4, -4 };

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b; *b = tmp;
	return;
}

void bfs() {
	vector<int> card(8);
	for (int i = 0; i < 8; ++i) card[i] = i;
	queue<vector<int> >  q;

	d[0][1][2][3][4][5][6][7] = 0;
	q.push(card);

	while (q.size()) {
		vector<int> b = q.front(); q.pop();

		int pos0;
		for (int i = 0; i < 8; ++i) if (b[i] == 0) pos0 = i;
		for (int i = 0; i < 4; ++i) {
			int npos = pos0 + dpos[i];

			if (0 <= npos && npos <= 7 && !(pos0 == 3 && npos == 4) && !(pos0 == 4 && npos == 3)) {
				vector<int> tmp = b;
				swap(&tmp[pos0], &tmp[npos]);
				if (d[tmp[0]][tmp[1]][tmp[2]][tmp[3]][tmp[4]][tmp[5]][tmp[6]][tmp[7]] == INF) {
					q.push(tmp);
					d[tmp[0]][tmp[1]][tmp[2]][tmp[3]][tmp[4]][tmp[5]][tmp[6]][tmp[7]] =
						d[b[0]][b[1]][b[2]][b[3]][b[4]][b[5]][b[6]][b[7]] + 1;
				}
			}
		}
	}
	return;
}

int main() {
	int min;
	vector<int> b(8);

	for (int i = 0; i < 8; ++i)
		for (int j = 0; j < 8; ++j)
			for (int k = 0; k < 8; ++k)
				for (int l = 0; l < 8; ++l)
					for (int m = 0; m < 8; ++m)
						for (int n = 0; n < 8; ++n)
							for (int o = 0; o < 8; ++o)
								for (int p = 0; p < 8; ++p)
									d[i][j][k][l][m][n][o][p] = INF;

	bfs();
	while (cin >> b[0]) {
		for (int i = 1; i < 8; ++i) cin >> b[i];
		cout << d[b[0]][b[1]][b[2]][b[3]][b[4]][b[5]][b[6]][b[7]] << endl;
	}
	return 0;
}

Measured memory_bytes: 34144
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class Main {
	static int mod = 1000000007;
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	static int gcd(int a,int b)
	{
		if(b==0)
			return a;
		return gcd(b, a%b);
	}
	
	public static void main(String[] args) {

		
		int n=in.nextInt();
		int x=in.nextInt();
		int[] a=new int[n+1];
		a[0]=x;
		for(int i=1;i<=n;i++)
		{
			a[i]=in.nextInt();
		}
		Arrays.sort(a);
		int[] aa=new int[n];
		for(int i=1;i<=n;i++)
		{
			aa[i-1]=a[i]-a[i-1];
		}
		int gcd=aa[0];
		for(int i=1;i<n;i++)
		{
			gcd=gcd(gcd, aa[i]);
		}
		out.println(gcd);
		out.close();

	}

	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

	private static void tr(Object... o) {
		if (!(System.getProperty("ONLINE_JUDGE") != null))
			System.out.println(Arrays.deepToString(o));
	}
}




Measured memory_bytes: 26724
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int n;
string s;
int ans=0;
int main()
{
	cin >> s;
	n=s.size();
	repp(i, 1, n)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll max(ll a, ll b){
  return a>b?a:b;
}

int main(){
    ios_base::sync_with_stdio(false);cout.tie(NULL);
    ll n, x, x1, y1;
    cin>>n>>x;
    ll ans, maxer;
    ll sum = 0;
    ll dp[n][2];
    ll i, a[n], b[n];
    fo(i,n){
      cin>>a[i];
      if(a[i]>x){
        sum+=(a[i]-x);
        a[i] = x;
      }
      b[i] = a[i];
    }
    dp[0][0] = 0;
    if(b[0] + b[1] > x){
        dp[0][1] = b[0] + b[1] - x;
        b[0] -= dp[0][1];
    }

    for(i=1;i<n;i++){
      //first
      if(a[i-1]+a[i]>x){
        dp[i][0] = a[i-1] + a[i] - x;
        a[i] -= dp[i][0];
      }
      else
        dp[i][0] = 0;
      dp[i][0] += dp[i-1][0];
      // if(i<n && a[i]+a[i+1]>x){
      //   y1 = a[i+1] + a[i] - x;
      // }
      //dp[i][0]  = max(0,max(x1,y1));
      // maxer = max(x1,y1);
      // dp[i][0] = max(0,maxer);
      // a[i] = a[i] - dp[i][0];
      //check for n as no n+1
    }

    for(i=1;i<n;i++){
      if(b[i-1]+b[i]>x){
        dp[i][1] = b[i-1] + b[i] - x;
        b[i] -= dp[i][1];
      }
      else
        dp[i][1] = 0;
      dp[i][1] += dp[i-1][1];
      // if(i<n && b[i]+b[i+1]>x){
      //   y1 = b[i+1] + b[i] - x;
      // }
      // maxer = max(x1,y1);
      // dp[i][1] = max(0,maxer);
      // b[i] = b[i] - dp[i][1];
    }
    // 
    // fo(i,n)
    //   cout<<dp[i][0]<<" ";
    // cout<<endl;
    // fo(i,n)
    //   cout<<dp[i][1]<<" ";
    // cout<<endl;

    cout<<sum+min(dp[n-1][0],dp[n-1][1])<<endl;

    return 0;
}


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

#define ii pair <ll, ll>
#define ll long long
#define X first
#define Y second

const ll N = 3E5 + 10;

ll n, m;
ll a[N], Sum[N], d[N];

void Input()
{
    cin >> n;
    for (ll i = 1; i <= n; i++) scanf("%lld", &a[i]);
}

bool check(ll mid, ll k)
{
    ll pos = upper_bound(a + 1, a + 1 + m, mid) - (a + 1);
    if (pos > m) pos = m;
    if (Sum[pos] / mid + (m - pos) >= k) return true;
    return false;
}

void Solve()
{
    for (ll i = 1; i <= n; i++) d[a[i]]++;
    for (ll i = 1; i <= n; i++) if (d[i] > 0) a[++m] = d[i];
    sort(a + 1, a + 1 + m);
    for (ll i = 1; i <= m; i++) Sum[i] = Sum[i - 1] + a[i];

    for (ll k = 1; k <= n; k++) {
        ll x;
        ll l = 1, r = 1e9;
        ll ans = 0;
        while (l <= r) {
            ll mid = l + r >> 1;
            if (check(mid, k)) {
                ans = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        printf("%lld\n", ans);
    }
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    ll testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    vector<vector<int>> c(3,vector<int>(3,0));
    rep(i,3) rep(j,3) cin >> c[i][j];
    vector<int> a(3,0),b(3,0);
    if((c[2][0]-c[0][0]+c[2][1]-c[0][1])%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    a[2]=(c[2][0]-c[0][0]+c[2][1]-c[0][1])/2;
    b[0]=c[2][0]-a[2];
    b[1]=c[2][1]-a[2];
    b[2]=c[2][2]-a[2];
    if((c[1][0]-b[0]==c[1][1]-b[1]) && (c[1][1]-b[1]==c[1][2]-b[2])){
        a[1]=c[1][0]-b[0];
    }else{
        cout<<"No"<<endl;
        return 0;
    }
    if((c[0][0]-b[0]==c[0][1]-b[1]) && (c[0][2]-b[2]==c[0][1]-b[1])){
        a[1]=c[0][0]-b[0];
    }else{
        cout<<"No"<<endl;
        return 0;
    }
    cout<< "Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a[n]={0};
  int ans1=0,ans2=0;
  rep(i,m){
    int num;
    string s;
    cin>>num>>s;
    if(s=="AC" && a[num-1]!= -1){
      ans1++;
      ans2+=a[num-1];
      a[num-1]= -1;
    }else if(a[num-1] != -1){
      a[num-1]++;
    }
  }
  cout<<ans1<<" "<<ans2<<endl;

  return 0;
}


Measured memory_bytes: 1024
program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,m,n,a,b,k,l
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) k,a,b
    if(a+2>=b .or. k<=a)then
        write(*,*)k+1
        stop
    end if
    l=k-a+1
    m=a+(l/2)*(b-a)+mod(l,2)
    write(*,*)m


  
    stop
end program sample
  



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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    string s;cin>>s;
    int len=s.size();
    if(s[0]==s[len-1]) len--;
    if(len%2==0) puts("Second");
    else puts("First");
    return 0;
}



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

int main(){

    int n;
    cin >> n;

    vector<int> r(9,0);

    rep(i,n){
        int t;
        cin>> t;
        int te=400;
        for(int j=1;j<=9;j++){
            if(j==9){
                r[8]++;
            }else if(t<j*te){
                r[j-1]++;
                break;
            }
        }
    }
    int mi=0;
    int ma=0;
    rep(i,8){
        if(r[i]>0){
            mi++;
            ma++;
        }
    }
    mi=max(1,mi);
    ma+=r[8];

    cout << mi <<" " << ma <<endl;

    return 0;
}

Measured memory_bytes: 256
#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() {
  int n, k;
  cin >> n >> k;
  rep(i,n) {
    int m; cin >> m;
  }
  cout << (n+k-3)/(k-1) << endl;
}


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

const int mod = 1e9 + 7;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define forn(i,s,n) for (int i=(int)(s);i<(int)(n);i++)

int main(){
   ll int a,b,c,d;
   cin>>a>>b>>c>>d;
   ll int s=b*d;
   ll int p=a*c;
   ll int m=a*d;
   ll int n=b*c;
   cout<<max(s,max(p,max(m,n)))<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	if (n == 1) cout << "Hello World" << endl;
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}


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

int main() {
  long long N,maxW;
  long long W[110];
  long long V[110];
  long long dp[110][100010]={0};
  
  cin>>N>>maxW;
  
  for (int i=0;i<N;i++){
    cin>>W[i]>>V[i];
  }
  
  for (int i=0;i<N;i++){
    for(int sum_W=0;sum_W<maxW+1;sum_W++){
      if(sum_W-W[i]>=0){
        dp[i+1][sum_W]=max(dp[i+1][sum_W],dp[i][sum_W-W[i]]+V[i]);
      }
      dp[i+1][sum_W]=max(dp[i+1][sum_W],dp[i][sum_W]);
    }
  }
  //cout<<N<<" "<<maxW<<endl;
  cout<<dp[N][maxW]<<endl;
  return 0;
}

    
  
    

  
                       
                   




Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {

    string anagram1,anagram2;
    int anagram1_size,anagram2_size;
    bool flag;

    cin >> anagram1;
    cin >> anagram2;


    anagram1_size = anagram1.length();
    anagram2_size = anagram2.length();

    sort(anagram1.begin(),anagram1.end());
    sort(anagram2.begin(),anagram2.end(),greater<int>());
    
    flag = anagram1_size < anagram2_size;
    
    
    for(int i = 0 ; i < min(anagram1_size,anagram2_size); i++) {
        if(anagram1[i] < anagram2[i]) {
            cout << "Yes" << endl;
            return 0;
        } else if (anagram1[i] > anagram2[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,m,q=list(map(int, input().split()))
conditions=[]
for i in range(q):
    conditions.append(list(map(int, input().split())))
max=0
for i0 in range(1,m+1):
    for i1 in range(i0, m+1):
        for i2 in range(i1, m+1):
            for i3 in range(i2, m+1):
                for i4 in range(i3, m+1):
                    for i5 in range(i4, m+1):
                        for i6 in range(i5, m+1):
                            for i7 in range(i6, m+1):
                                for i8 in range(i7, m+1):
                                    for i9 in range(i8, m+1):
                                        a=[i0,i1,i2,i3,i4,i5,i6,i7,i8,i9]
                                        score=0
                                        for condition in conditions:
                                            if(a[condition[1]-1]-a[condition[0]-1]==condition[2]):
                                                score+=condition[3]
                                        if score>max:
                                            max=score

print(max)

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

int main() {
    long long N,buf;
    vector<int> ans;
    cin >> N;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0){
            buf = N/i;
            if(to_string(buf).length()>to_string(i).length()){
                ans.push_back(to_string(buf).length());
            }else{
                ans.push_back(to_string(i).length());
            }
        }
    }
    sort(ans.begin(),ans.end());
    cout << ans.at(0) << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b,c,e,d,f,t,i,j,k;
    cin>>t>>a;
    b=t-(2*a);
    if(b<=0)
        cout<<"0"<<endl;
    else
        cout<<b;
    return 0;
}


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

int main(){
  int x, y, z;
  cin >> x >> y >> z;
  cout << z  << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))
out = 0
for i in range(1, n):
  out += B[A[i]]
  if A[i+1] == A[i] + 1:
    out += C[A[i]]
out += B[A[n]]
print(out)

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

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


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

string s;
void in(){
    cin >> s;
}

void solve(){

    rep(i,0,3){
        if(s[i] == s[i + 1]){
            print("Bad");
            return;
        }
    }
    print("Good");

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
const int INF = 1 << 30;
const int INF_NEG = INF * -1;

struct sPoint{
    int x, y, breadth;
};

int H, W;
vector<string> A;
int breadth[20][20];

// #define GBN_DEBUG

int bfs(int startX, int startY)
{
    sPoint start = {startX, startY, 0};
    queue<sPoint> qPoint;
    qPoint.push(start);
    
    while(!qPoint.empty()){
        sPoint c = qPoint.front(); // current point
        qPoint.pop();

    
        if (c.x == W - 1 && c.y == H - 1) // ゴールなら
            return c.breadth; // 現在地の幅を返す
        
        if (c.y + 1 < H && A[c.y + 1][c.x] == '#'){ // 下を探索
            A[c.y + 1][c.x] = 'x';
            breadth[c.y + 1][c.x] = c.breadth + 1;
            sPoint next = {c.x, c.y + 1, c.breadth + 1};
            qPoint.push(next);
        }
        if (c.x + 1 < W && A[c.y][c.x + 1] == '#'){ // 右を探索
            A[c.y][c.x + 1] = 'x';
            breadth[c.y][c.x + 1] = c.breadth + 1;
            sPoint next = {c.x + 1, c.y, c.breadth + 1};
            qPoint.push(next);
        }
    }

    return 0;
}

int main()
{
    cin >> H >> W;
    A.resize(H + 9);
    rep(i, 20) rep(j, 20) breadth[i][j] = -1;
    rep(i, H) cin >> A[i];
    int ret = bfs(0, 0);

    if (!ret){ // ゴールに到達できなかった場合
        puts("Impossible"); return 0;
    }

#ifdef GBN_DEBUG
    cout << ret << endl << endl;
    if (ret){
        rep(i, H) cout << A[i] << endl;
    }
#endif

    // bfs() で通れた場所に 'x' 印
    // 以下で最短経路の道を 'o' に変更
    int x = W - 1, y = H - 1;
    int b = ret;
    while(b >= 0){
        A[y][x] = 'o';
        if (breadth[y - 1][x] == b - 1) --y; // 上か左のどちらかに幅が１つ小さい場所があるはず
        else --x;
        --b;

        if (y < 0) y = 0;
        if (x < 0) x = 0;
    }
    A[0][0] = 'o';
#ifdef GBN_DEBUG
    rep(i, H) cout << A[i] << endl;
#endif

    bool ans = true;
    rep(y, H){
        if (!ans) break;
        rep (x, W){
            if (A[y][x] == 'x' || A[y][x] == '#'){
                ans = false;
                break;
            }
        }
    }

    if (ans) puts("Possible");
    else puts("Impossible");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	lnt n,m;
	std::cin >> n >> m;
	if(n==1) {
		print(mint(m+1));
		return 0;
	}
	lnt x = m/(n-1);
	print(mint(m+1)+mint(2)*(mint(x)*mint(m+1))-mint(n-1)*mint(x)*mint(x+1));
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2;    












    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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


struct E {
	int p;
	int a;
	int b;
	bool operator<(const E &left) const {

		return p < left.p;
	}
};

int main() {
	int n;
	cin >> n;
	
	vector<E> es(n);
	rep(i , n) {
		int a, b;

		cin >> a >> b;
		E e;
		e.p = abs(a + b);
		e.a = a;
		e.b = b;
		es.push_back(e);
	}

	sort(es.rbegin(), es.rend());


	ll ans = 0;

	rep(i, n) {
		if (i % 2 == 0) {
			ans += (ll) es[i].a;
		} else {
			ans -= (ll) es[i].b;
		}
		
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584