akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
// i want to become the best
class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	    long mod = (long)1e9+7;
	    long[] suffmod = new long[n];
	    suffmod[n-1]=list[n-1]%mod;
	    for(int k = n-2;k>=0;k--){
	    	suffmod[k] = (suffmod[k+1]+list[k])%mod; 
	    }
	    long ans = 0;
	    for(int i = 0;i<n-1;i++){
	    	ans = (ans + (list[i]*(suffmod[i+1]))%mod)%mod;
	    }
	    System.out.println(ans);	
	}
}
class pair implements Comparable<pair>{
		long a = 0;
		int b = 0;
		public pair(long a,int b){
			this.a = a;
			this.b = b;
		}
		@Override
		public int compareTo(pair p){
			if(this.a == p.a) return -(Integer.compare(this.b,p.b));
			else return -(Long.compare(this.a,p.a));
		}
		@Override
		public String toString(){
			return a+" "+b;
		}
	}


Measured memory_bytes: 63164
n = list(map(str,input()))
a = 0
for i in range(len(n)):
    a += int(n[i])
b = len(n)-1
c = 0
for i in range(len(n)):
    c += int(n[i]) * (10 ** b)
    b -= 1
if c % a == 0:
    print("Yes")
else :
    print("No")






Measured memory_bytes: 3060
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {		
		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
		List<String> list = new ArrayList<String>();
		
		while(scanner.hasNext()) {
			String num = scanner.nextLine();
			String[] input = num.split(" ");
			int number1 = Integer.parseInt(input[0]);
			String op = input[1];
			int number2 = Integer.parseInt(input[2]);
			int result = 0;
			if("?" .equals(op)) {
				break;
			}else {
				if(number1 >= 0 && number1 <= 20000 && number2 >= 0 && number2 <= 20000) {
					if("+" .equals(op)) {
						result = number1+number2;
						list.add(String.valueOf(result));
					}else if("-" .equals(op)) {
						result = number1-number2;
						list.add(String.valueOf(result));
					}
					else if("*" .equals(op)) {
						result = number1*number2;
						list.add(String.valueOf(result));
					}
					else if("/" .equals(op)) {
						result = number1/number2;
						list.add(String.valueOf(result));
					}
				}
			}			
		}
		for(int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 26036
import math
import bisect


n = int(input())

a = list(map(int, input().split()))
a.sort()

ncr = 0
ans = [0, 0]

id = bisect.bisect_left(a[:n-1], a[n-1]//2)
if abs(a[-1]/2 - a[id]) < abs(a[-1]/2 - a[id-1]):
    ans = id
else:
    ans = id-1

print(a[-1], a[ans])


Measured memory_bytes: 14348
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 4000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

const int maxn = 1e6+5;
int n, m;
struct node {
    int to, next, w;
    bool operator < (const node& a) const {
        return w > a.w;
    }
} e[maxn<<1];
int cnt, head[maxn];
void add(int u, int v, int w) {
    e[cnt] = node{v, head[u], w};
    head[u] = cnt++;
}
bool vis[maxn];
int dis[maxn];
void SPFA(int st, int ed) {
    priority_queue<node> q;
    memset(dis,INF,sizeof(dis));
    memset(vis,false,sizeof(vis));
    dis[st] = 0;
    q.push(node{st, 0, 0});
    while (!q.empty()) {
        node u = q.top();
        q.pop();
        if(vis[u.to]) continue;
        vis[u.to] = 1;

        for (int i = head[u.to]; ~i; i = e[i].next) {
            int to = e[i].to;
            if (dis[to] > dis[u.to] + e[i].w) {
                dis[to] = dis[u.to] + e[i].w;
                q.push(node{to, 0, dis[to]});
            }
        }
    }
    printf("%d\n", dis[ed] == INF?-1:dis[ed]/2);
}
map<int, int>mp[maxn];
void init() {
    cnt = 0;
    memset(head,-1,sizeof(head));
    for (int i = 1 ; i <= n ; i ++) {
        mp[i].clear();
    }
}
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++n;
    return mp[x][y];
}
int main() {
    scanf("%d%d",&n,&m);
        init();
        int endd=n;
        for (int i=1; i<=m; i++) {
            int x,y,w;
            scanf("%d%d%d",&x,&y,&w);
            int newX=getPoint(x,w);
            int newY=getPoint(y,w);

            add(newX,newY,0);
            add(newY,newX,0);
            add(x,newX,1);
            add(newX,x,1);
            add(y,newY,1);
            add(newY,y,1);
        }
        SPFA(1,endd);

    return 0;
}


Measured memory_bytes: 94324
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  double ans = 0;
  for (int i = 1; i < n; i++) {
    if (i == 1) ans = (a[0] + a[1]) / 2;
    else ans = (ans + a[i]) / 2;
  }
  cout << setprecision(20) << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
dp=[[0 for i in range(3)]for j in range(N)]

L=[]
for i in range(N):
    a,b,c=map(int,input().split())
    L.append([a,b,c])

dp[0][0]=L[0][0]
dp[0][1]=L[0][1]
dp[0][2]=L[0][2]

for i in range(1,N):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+L[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+L[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+L[i][2]
print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))
    

Measured memory_bytes: 44148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
  int N,Y; cin >> N >> Y;
  int x = -1,y = -1,z = -1;
  for(int i = 0; i <= N; i++){
    for(int j = 0; i+j <= N; j++){
      int k = N-i-j;
      if(10000*i + 5000*j + 1000*k == Y){
         cout << i << " " << j << " " << k << endl;
         return 0;
      }
    }
  }
  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;
typedef pair<int, int> pr;

void push_queue(queue<pr> &q, vector<bool> &seen, int next, int distance) {
    if(seen[next]== false) q.push(make_pair(next, distance));
    seen[next] = true;
}


int main() {
    int N, X, Y;
    cin >> N >> X >> Y;

    X--;
    Y--;

    queue<pr> q;
    vector<int> dist(N);
    for(int i = 0; i < N; i++) {
        vector<bool> seen(N, false);
        q.push(make_pair(i, 0));
        seen[i] = true;
        while(q.size() >= 1) {
            pr c = q.front(); q.pop();

            int past_pos = get<0>(c);
            int past_dist = get<1>(c);
            // cout  << past_pos << ":" << past_dist << endl;
            dist[past_dist]++;

            if (past_pos >= 1) push_queue(q, seen, past_pos - 1, past_dist + 1);
            if (past_pos <= N-2) push_queue(q, seen, past_pos + 1, past_dist + 1);
            if (past_pos == X) push_queue(q, seen, Y, past_dist + 1);
            if (past_pos == Y) push_queue(q, seen, X, past_dist + 1);

            // if(past_pos >= 1 && seen[past_pos-1]== false) q.push(make_pair(past_pos-1, past_dist+1));
            // if(past_pos <= N-2 && seen[past_pos+1]== false) q.push(make_pair(past_pos+1, past_dist+1));
            // if(past_pos == X && seen[Y]== false) q.push(make_pair(Y, past_dist+1));
            // if(past_pos == Y && seen[X]== false) q.push(make_pair(X, past_dist+1));
        }
    }

    for(int i = 1; i < N; i++) {
        cout <<  dist[i] / 2 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,A,B,a[5030];
long long f[5030][5030];
int main()
{
	scanf("%d%d%d",&n,&A,&B);
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	f[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=i-1;j>=0;j--)
			{
				if(a[i]<a[j]) f[i][j]=min(f[i-1][j]+B,f[i][j]);
				else f[i][j]=min(f[i-1][j]+A,f[i][j]),f[i][i]=min(f[i][i],f[i-1][j]);
			}
	long long ans=f[0][1];
	for(int i=1;i<=n;i++) ans=min(ans,f[n][i]);
	printf("%lld\n",ans);
	return 0;
}	

Measured memory_bytes: 197888
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	map<ll, ll> M;
	rep(i, N) {
		map<ll, ll>::iterator it = M.lower_bound(A[i]);
		if(M.size() == 0 || it == M.begin()) {
			M[A[i]]++;
		} else {
			it--;
			M[(*it).first]--;
			if(M[(*it).first] == 0) {
				M.erase(it);
			}
			M[A[i]]++;
		}
	}

	ll ans = 0;
	for(pair<ll, ll> item: M) {
		ans += item.second;
	}
	cout << ans  << endl;
	

}


Measured memory_bytes: 9980
#include <iostream>
#include <map>
#include <vector>
using namespace std;

#include <algorithm>

int main()
{

    int inputCount;
    cin >> inputCount;

    map<string, int> countDic{};
    for (int loop = 0; loop < inputCount; loop++)
    {
        string tmp;
        cin >> tmp;
        if (countDic.find(tmp) == countDic.end())
        {
            countDic[tmp] = 0;
        }
        countDic[tmp]++;
    }

    int maxCnt = 0;
    for (auto loop = countDic.begin(); loop != countDic.end(); ++loop) {
        //std::cout << "key = " << loop->first           // キーを表示
        if (maxCnt < loop->second) {
            maxCnt = loop->second;
        }
    }

    vector<string> maxKeyList;
    for (auto loop = countDic.begin(); loop != countDic.end(); ++loop)
    {
        if (loop->second == maxCnt)
        {
            bool flag = true;
            for (int loop2 = 0; loop2 < maxKeyList.size(); loop2++) {
                if (loop->first == maxKeyList[loop2]) {
                    false;
                    break;
                }
            }
            if (flag) {
                maxKeyList.push_back(loop->first);
            }
        }
    }

    sort(maxKeyList.begin(), maxKeyList.end());
    for (int loop = 0; loop < maxKeyList.size(); loop++) {
        cout << maxKeyList[loop] << endl;
    }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll a,b,c,k;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>a>>b>>c>>k;

    ll res=0;
    ll take=min(k,a);
    res+=take;
    k-=take;
    take=min(k,b);
    k-=take;
    take=min(k,c);
    res -= take;
    out(res);
  

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=100-p;
    a.push_back(tie(s,p,i));
    sort(a.begin(),a.end());
  }
  for(int i=0;i<n;i++){
    cout<<get<2>(a[i])<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
  } else {
    for(int i=0;i<b;i++){
      cout<<a;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (u == s) {
        a--;
    } else {
        b--;
    }
    printf("%d %d\n", a, b);
}


Measured memory_bytes: 384
function bubbleSort(A,N){
   for(var i=0;i<N;i++){
      for(var j=N-1;j>=i+1;j--){
         if(A[j][1]<A[j-1][1]){
            var memo=A[j];
            A[j]=A[j-1];
            A[j-1]=memo;
         }
      }
   }
}
function selectionSort(A,N){
   for(var i=0;i<N;i++){
      var minj=i;
      for(var j=i;j<N;j++){
         if(A[j][1]<A[minj][1])minj=j;
      }
      var memo=A[i];
      A[i]=A[minj];
      A[minj]=memo;
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
var arr=Arr.shift().split(" ");
var arrA=arr.map(function(v){return v.split("");});
var arrB=arr.map(function(v){return v.split("");});
bubbleSort(arrA,n);
selectionSort(arrB,n);
console.log(arrA.join(" ").replace(/,/g,""));
console.log("Stable");
console.log(arrB.join(" ").replace(/,/g,""));
console.log((arrA.join(" ")===arrB.join(" "))?"Stable":"Not stable");

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

int a, b, c, n;

int main()
{
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> a >> b >> c;

        if (a > c) swap(a, c);
        if (b > c) swap(b, c);

        cout << (a * a + b * b == c * c ? "YES" : "NO") << endl;
    }

    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[100010],b[100010];
signed main(){
	cin>>n;
	int x=0;
	rep(i,n){
		cin>>a[i];
		a[i]*=2;
		if(i==0||i%2)x+=a[i];
		else x-=a[i];
	}
	x/=2;
	b[1]=x;
	for(int i=2;i<=n;i++)b[i%n]=a[i-1]-b[i-1];
	rep(i,n-1)cout<<b[i]<<" ";
	cout<<b[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int x;
    cin >> x;
    vector<bool> dp(x + 200, 0);
    dp[0] = true;
    for(int i = 0; i <= x; i++) {
        if(dp[i]) {
            for(int j = 0; j < 6; j++) {
                dp[i + 100 + j] = true;
            }
        }
    }
    cout << dp[x] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000], y[100000];
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> n;
	m = 100;
	for (i = 0; m < n; i++) {
		m *= 1.01;
	}
		
	cout << i<< endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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;
}

vector<int> prime_factor(int n){
	vector<int>res;
	for (int i = 2;i*i <= n; ++i) {
		while (n % i == 0) {
			res.push_back(i);
			n /= i;
		}
	}
	if (n != 1)res.push_back(n);
	return res;
}

int main(){
	int n, m;
	cin >> n >> m;
    if(m == 1){puts("1");return 0;}
	vector<int>v = prime_factor(m);
	COMinit();
	int cnt = 1, p = v[0];
	long long res = 1;
	for(int i = 1; i < v.size(); ++i){
		if(p != v[i])res *= COM(n - 1 + cnt, n - 1), p = v[i], cnt = 0;
		cnt++;
		res %= MOD;
	}
	res *= COM(n - 1 + cnt, n - 1);
	res %= MOD;
	cout << res << endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){
    ll N,D;
    ll A[200005];
    cin>>N>>D;
    ll ret = D*(N-1);
    for(int i = 0;i < N;i++){
        cin>>A[i];
        ret += A[i];
    }
    for(int i = 1;i < N;i++){
        A[i]=min(A[i-1]+D,A[i]);
    }
    for(int i = N-2;i >=0;i--){
        A[i]=min(A[i+1]+D,A[i]);
    }
    for(int i = 1;i < N-1;i++){
        ret += A[i];
    }
    cout<<ret<<endl;
    
}


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

namespace MS2020D
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            long[] A = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(input[i]);
            }
            bool kanemoti = true;
            long kane = 1000;
            long kabu = 0;
            //Console.WriteLine(kane);
            for (int i = 0; i < N - 1; i++)
            {
                if (kanemoti == true)
                {
                    //Console.WriteLine(A[i]);
                    //株を持っていない
                    if (A[i] >= A[i + 1])
                    {
                    }
                    else
                    {
                        //Console.WriteLine(kane);
                        kabu += kane / A[i];
                        //Console.WriteLine(kabu);
                        kane %= A[i];
                        //Console.WriteLine(kane);
                        kanemoti = false;
                    }
                }
                else
                {
                    //株を持っている
                    if (A[i] <= A[i + 1])
                    {
                    }
                    else
                    {
                        kane += kabu * A[i];
                        kabu = 0;
                        kanemoti = true;
                    }
                }
            }
            if (kanemoti == false)
            {
                kane += kabu * A[N - 1];
                kabu = 0;
            }
            Console.WriteLine(kane);
        }
    }
}


Measured memory_bytes: 27544
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

struct Guy{
  int m;
  int L;
};

Guy guys[100];
int N,M;

long long ans(int a,int b)
{

  if(a==N)return 0;
  int ret;
  if((guys[a].m & b)==0){
    ret=max(ans(a+1,b),ans(a+1,b|guys[a].m)+guys[a].L);
  }
  else ret=ans(a+1,b);

  return ret;
}

int main()
{
  int L,s,e;
  while(1){
    cin>>N;
    if(N==0)break;
    for(int i=0;i<N;i++){
      cin>>M>>L;
      guys[i].L=L;
      guys[i].m=0;
      for(int j=0;j<M;j++){
	cin>>s>>e;
	s-=6;
	e-=6;
	for(int k=s;k<e;k++){
	  guys[i].m+=(1<<k);
	}
      }
    }
    cout<<ans(0,0)<<endl;
  }
  return 0;
}

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

using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}

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

    int n; cin >> n;

    vector<vector<int>> counter(n, vector<int>(26, 0));
    rep(i, n) {
        string s; cin >> s;
        for (auto c : s) {
            counter[i][c-'a']++;
        }
    }
    
    string ans;
    rep(i, 26) {
        int chars = INT_MAX;
        rep(j, n) {
            chmin(chars, counter[j][i]);
        }
        if (chars > 0) {
            string add(chars, 'a'+i);
            ans += add;
        }
    }
        
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> mf;
long long modfact(int n){
  if (mf.size() > n){
    return mf[n];
  } else {
    if (mf.empty()){
      mf.push_back(1);
    }
    for (int i = mf.size(); i <= n; i++){
      long long next = mf.back() * i % MOD;
      mf.push_back(next);
    }
    return mf[n];
  }
}
long long modbinom(int n, int k){
  if (k < 0 || k > n){
    return 0;
  } else {
    return modfact(n) * modinv(modfact(k)) % MOD * modinv(modfact(n - k)) % MOD;
  }
}
int main(){
  int N;
  cin >> N;
  vector<int> a(N + 1);
  for (int i = 0; i <= N; i++){
    cin >> a[i];
    a[i]--;
  }
  vector<int> cnt(N, 0);
  for (int i = 0; i <= N; i++){
    cnt[a[i]]++;
  }
  int d;
  for (int i = 0; i < N; i++){
    if (cnt[i] == 2){
      d = i;
    }
  }
  int pos = -1;
  int sum = 0;
  for (int i = 0; i <= N; i++){
    if (a[i] == d){
      if (pos == -1){
        pos = i;
      } else {
        sum = pos + (N - i);
      }
    }
  }
  for (int i = 1; i <= N + 1; i++){
    long long ans = 0;
    ans += modbinom(N - 1, i);
    ans += modbinom(sum, i - 1);
    ans += (modbinom(N - 1, i - 1) - modbinom(sum, i - 1)) * 2;
    ans += modbinom(N - 1, i - 2);
    ans += MOD;
    cout << ans % MOD << endl;
  }
}

Measured memory_bytes: 5100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int t = 1;
  vector<ll> memo(n, -1);
  vector<bool> reach(n, false);
  int cnt = 0;
  int min;
  rep(i, n) {
    if (reach[t - 1]) {
      //   cout << cnt << "回目に到達した" << t << "は" << memo[t - 1]
      //        << "回目にも到達している。" << endl;
      cnt -= memo[t - 1];
      min = memo[t - 1];
      break;
    };
    reach[t - 1] = true;
    memo[t - 1] = cnt;
    t = a[t - 1];
    cnt++;
  }
  //   cout << min << "回目から" << cnt << "回でループする" << endl;
  t = 1;
  if (k >= (min + cnt)) k = min + ((k - min) % cnt);
  rep(i, k) { t = a[t - 1]; }
  cout << t << endl;
}

Measured memory_bytes: 5624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, K, i, j, D[20], judge;
    string S;

    cin >> N >> K;

    for(i=1; i<=K; i++){
        cin >> D[i];
    }

    while(1){
        judge = 1;

        S = to_string(N);

        for(i=0; i<S.size(); i++){
            for(j=1; j<=K; j++){
                if(S[i]-'0' == D[j]){
                    judge = 0;
                }
            }
        }

        if(judge==1){
            cout << N << endl;
            break;
        }

        N++;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int aMultiplyB = a * b;
    
    if (aMultiplyB % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	int d = n % 10;
	n /= 10;
	int c = n % 10;
	n /= 10;
	int b = n % 10;
	n /= 10;
	int a = n % 10;
	int ans1, ans2, ans3,x,y,z;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				if (i == 0) {
					ans1 = a + b;
				}
				if (i == 1) {
					ans1 = a - b;
				}
				if (j == 0) {
					ans2 = ans1 + c;
				}
				if (j == 1) {
					ans2 = ans1 - c;
				}
				if (k == 0) {
					ans3 = ans2 + d;
				}
				if (k == 1) {
					ans3 = ans2 - d;
				}
				if (ans3 == 7) {
					x = i;
					y = j;
					z = k;
					
				}
				ans1 = 0;
				ans2 = 0;
				ans3 = 0;
			}
			
		}
		
	}
	cout << a;
	if (x == 0) {
		cout << "+";
	}
	if (x == 1) {
		cout << "-";
	}
	cout << b;
	if (y == 0) {
		cout << "+";
	}
	if (y == 1) {
		cout << "-";
	}
	cout << c;
	if (z == 0) {
		cout << "+";
	}
	if (z == 1) {
		cout << "-";
	}
	cout << d;
	cout << "=7" << endl;
	return 0;
}


Measured memory_bytes: 256
// Created by Tanuj Jain
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = 0x3f3f3f3f;
int knight_moves[8][2]={{-2,-1},{-1,-2},{1,-2},{2,-1},{-2,1},{-1,2},{1,2},{2,1}};
int moves[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	//#ifndef ONLINE_JUDGE
	//freopen("inputf.in","r",stdin);
	//freopen("outputf.in","w",stdout);
	//#endif

	int row,col,k;
	cin>>row>>col>>k;
	char grid[row][col];
	for(int i=0;i<row;i++)
	{
		for(int j=0;j<col;j++)
			cin>>grid[i][j];
	}
	int res=0;
	for(int mask=0; mask<(1<<(row+col));mask++)
	{
		int count=0;
		for(int i=0;i<row;i++)
		{
			for(int j=0;j<col;j++)
			{
				if(grid[i][j]!='#')
					continue;
				//if the current row or the current col is set dont consider it
				if((mask&(1<<i) | mask&(1<<row+j))!=0)
					continue;
				count++;
			}
		}
		if(count==k)
			res++;
	}
	cout<<res;
	
}	

Measured memory_bytes: 3576
def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))

    for i, _a in enumerate(a[k:]):
        if a[i] < _a:
            print("Yes")
        else:
            print("No")
    
    return


if __name__ == "__main__":
    main()



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

int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<int> X(a);
    vector<int> Y(b);
    vector<int> C(c);

    for(int i = 0; i < a; i++) cin>>X[i];
    for(int i = 0; i < b; i++) cin>>Y[i];
    for(int i = 0; i < c; i++) cin>>C[i];

    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    sort(C.begin(),C.end());

    vector<int> z;

    for(int i = 0; i < x; i++) z.push_back(X[a-i-1]);
    for(int i = 0; i < y; i++) z.push_back(Y[b-i-1]);

    sort(z.begin(),z.end());

    for(int i = 0; i < x+y; i++){
        if(!C.empty() && C.back() > z[i]){
            z[i] = C.back();
            C.pop_back();
        } else break;
    }

    ll res = 0;
    for(int i : z) res+=i;
    cout<<res;

}


Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 22
int a[N][N], f[1 << N] = {1}, n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
    for (int s = 0; s < (1 << n); s++) {
        int i = __builtin_popcount(s);
        for (int j = 1; j <= n; j++)
            if (s & (1 << (j - 1)) && a[i][j])
                f[s] = (f[s] + f[s ^ (1 << (j - 1))]) % mod;
    }
    printf("%d\n", f[(1 << n) - 1]);
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001


bool sortbysec(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<1>(a) < get<1>(b)); 
}



int spf[0];
void sieve(){
	spf[1] = 1;
	for(int i=2;i<MAXN;i++) spf[i] = i;

	for(int i=4;i<MAXN;i+=2) spf[i] = 2;

	for(int i=3; i*i<MAXN;i++){
		if(spf[i]==i){
			for(int j=i*i;j<MAXN;j+=i){
				if(spf[j]==j) spf[j] = i;
			}
		}
	}
}
bool custom(const pair<int, int>& a,  
               const pair<int, int>& b) 
{ 
    if(a.first==b.first) return a.second < b.second;
	return a.first > b.first; 
}

// A.reize(unique(A.begin(),A.end())- A.begin());
#define int long long
void solve(){
	int n; cin>>n;
	int a[n];
	bool zero= false;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]==0) zero = true;
	}
	if(zero){cout<<0<<endl; return ;}

	int res = a[0];
	for(int i=1;i<n;i++){
		int tmp = res;
		tmp*=a[i];
		if(tmp < res){cout<<-1<<endl; return ;}
		if(tmp > (long long)1e18) {cout<<-1<<endl; return ;}
		res = tmp;
	}
	cout<<res<<endl;
	// 1 000 000 000 000 000 001
}

signed main() {
IOS;
	int t=1; 
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}




vector<int> getFactorization(int x){

	vector<int> primeFactors;
	while(x>1){
		primeFactors.pb(spf[x]);
		x /= spf[x];
	}
	return primeFactors;
}


Measured memory_bytes: 4436
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  int n;
  cin>>n;
  vector<int> v;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    int x;
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int j=0;
  for(int i=2; i<n; i+=2) {
    a[i] = v[j];
    j++;
  }
  a[0] = v[j];
  j = n-1;
  for(int i=1; i<n; i+=2) {
    a[i] = v[j];
    j--;
  }
  ll ans0=0;
  for(int i=0; i<n-1; i++) {
    ans0+=abs(a[i]-a[i+1]);
  }
  sort(v.rbegin(), v.rend());
  j=0;
  for(int i=2; i<n; i+=2) {
    a[i] = v[j];
    j++;
  }
  a[0] = v[j];
  j=n-1;
  for(int i=1; i<n; i+=2) {
    a[i] = v[j];
    j--;
  }
  ll ans1 = 0;
  for(int i=0; i<n-1; i++) {
    ans1+=abs(a[i]-a[i+1]);
  }
  std::cout << max(ans0, ans1) << std::endl;
  return 0;
}



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

int top,S[1000];

void push(int x)
{
	S[++top]=x;
}

int pop()
{
	return S[top--];
}

int main()
{
	int a,b;
	top=0;
	char s[100];
	while (scanf("%s",s)!=EOF)
	{
		if (s[0]=='+')
		{
			a=pop();
			b=pop();
			push(a+b); 
		}
		else if(s[0]=='-')
		{
			a=pop();
			b=pop();
			push(b-a);
		}
		else if (s[0]=='*')
		{
			a=pop();
			b=pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf ("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2100
import math
from decimal import Decimal

def main():
  A, B = input().split()
  # A = int(A)
  # B = float(B)
  res = Decimal(A) * Decimal(B)
  # res = A * int(B * 100) / 100
  print(int(res))

if __name__ == "__main__":
  main()

Measured memory_bytes: 10076
#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define ZERO 0ll
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i]) 
typedef long long ll;
typedef long double ld;
using namespace std;


    
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	//cin>>tces;
	while(tces--){
		int n,m;
		cin>>n>>m;
		vi adj[n+5];
		vi v(n+5);
		FORR(i,n){
			cin>>v[i];
		}
		FORR(i,m){
			int a,b;
			cin>>a>>b;
			adj[a].pb(b);
			adj[b].pb(a);
		}
		int ans=0;
		FORR(i,n){
			int f=1;
			for(auto it:adj[i]){
				if(v[it]>=v[i]){
					f=0;
					break;
				}
			}
			if(f){
				ans++;
			}
		}
		cout<<ans;
	}
	
return 0;
}

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

using namespace std;

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

    if (a - 10 < 0 && b - 10 < 0)
    {
        printf("%d\n", a * b);
    }
    else
    {
        printf("-1\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
typedef long long int64;
static const int MAXN = 1e5 + 4;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int n, d1 = -1, d2 = -1;
int occ[MAXN];

int64 fact[MAXN], fact_inv[MAXN];

inline int64 qpow(int64 base, int exp)
{
    int64 ans = 1;
    for (; exp; exp >>= 1, (base *= base)__) if (exp & 1) (ans *= base)__;
    return ans;
}

inline void preprocess()
{
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) fact[i] = fact[i - 1] * i _;
    fact_inv[MAXN - 1] = qpow(fact[MAXN - 1], MODULUS - 2);
    for (int i = MAXN - 2; i >= 0; --i) fact_inv[i] = fact_inv[i + 1] * (i + 1)_;
}

inline int64 binom(int n, int m)
{
    if (n < m || m < 0) return 0;
    return fact[n] * fact_inv[m]_ * fact_inv[n - m]_;
}

int main()
{
    preprocess();

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) occ[i] = -1;
    for (int i = 0, a; i < n + 1; ++i) {
        scanf("%d", &a); --a;
        if (occ[a] == -1) occ[a] = i;
        else { d1 = occ[a], d2 = i; break; }
    }

    printf("%d\n", n);
    for (int i = 2; i <= n + 1; ++i) {
        int64 ans = binom(n + 1, i);
        ans -= binom(n + 1 - (d2 - d1 + 1), i - 1);
        printf("%lld\n", (ans _ + MODULUS)_);
    }

    return 0;
}


Measured memory_bytes: 3072
n=int(input())
dic={}
for i in range(n):
  s=input()
  if s in dic:
    dic[s]+=1
  else:dic[s]=1
sc=[[] for _ in range(n+1)]
mx=0
for i in dic:
  sc[dic[i]].append(i)
  mx=max(mx,dic[i])

for i in sorted(sc[mx]):
  print(i)

Measured memory_bytes: 101284
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e3+100;
int head[maxn],cnt;
int vis[maxn],vis2[maxn];
struct node{
	int nxt,to;
}e[maxn*4];
void add(int a,int b){
	e[++cnt].nxt=head[a],e[cnt].to=b,head[a]=cnt;
}
vector<int>ans;
void work(vector<int>v,int x){
	int flag=0;
	vector<int>cmp;
	for(int y:v){
		if(y==x)flag=1;
		if(!flag)continue;
		cmp.push_back(y);
	}
	if(cmp.size()==0)return ;
	int sz=ans.size();
	if(!sz||sz>cmp.size())ans=cmp;
}
void dfs(int u,vector<int>v){//dbg(u);
	if(vis2[u])return ;
	if(vis[u]){
		work(v,u);
		return ;
	}
	vis[u]=1;
	v.push_back(u);
	for(int i=head[u];i;i=e[i].nxt){
		int to=e[i].to;
		dfs(to,v);
	}
}
void solve()
{
	int n,m;
	scdd(n,m);
	rep1(i,m){
		int x,y;
		scdd(x,y);
		add(x,y);
	}
	vector<int>v;
	rep1(i,n){
		dfs(i,v);
	}
	if(ans.size()==0){
		printf("-1\n");
		return ;
	}
	printf("%d\n",ans.size());
	for(int x:ans)printf("%d\n",x);
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


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

int main() {
	int x, y;

	cin >> x >> y;

	while (x != 0 || y != 0) {
		if (x < y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}

	return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>

int main(void){
  int x=0,cost,pay,coin[4],i,tmp[4],money[4]={10,50,100,500};
  while(scanf("%d",&pay)&&pay!=0){
    if(x!=0) putchar('\n');
    cost=0;
    for(i=0;i<4;i++) scanf("%d",&coin[i]);
    cost+=10*coin[0]+50*coin[1]+100*coin[2]+500*coin[3];
    tmp[3]=(cost-pay)/500;
    coin[3]-=tmp[3];
    //printf("%d\n",tmp[3]);
    tmp[2]=(cost-pay-500*tmp[3])/100;
    coin[2]-=tmp[2];
    //printf("%d\n",tmp[2]);
    tmp[1]=(cost-pay-500*tmp[3]-100*tmp[2])/50;
    coin[1]-=tmp[1];
    //printf("%d\n",tmp[1]);
    tmp[0]=(cost-pay-500*tmp[3]-100*tmp[2]-50*tmp[1])/10;
    coin[0]-=tmp[0];
    //printf("%d\n",tmp[0]);
    for(i=0;i<4;i++) if(coin[i]>0) printf("%d %d\n",money[i],coin[i]);
    x++;
  }
  return 0;
}

Measured memory_bytes: 604
n,m = map(int,input().split(" "))
ar = [[] for i in range(n)]
for i in range(m):
    l = list(map(int,input().split(" ")))
    ar[l[0]-1].append(l[1]-1)
    ar[l[1]-1].append(l[0]-1)
for r in ar[0]:
    if n - 1 in ar[r]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 50136
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
}


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

using ll = long long; 

/*
dp[i][j] - maximum score first player can be more than opponent at range from i to j.

option 1: choose the first to remove
dp[i][j] = -dp[i+1][j] + A[i]
option 2: choose the last to remove 
dp[i][j] = -dp[i][j-1] + A[j]
*/
int main() {
	int n;
	scanf("%d", &n);
	vector<int> A(n);
	
	for (int i = 0; i < n; i++) {
	    scanf("%d", &A[i]);
	}
	
	vector<vector<ll>> dp(n, vector<ll>(n));
	
	for (int i = n; i >= 0; i--) {
	    for (int j = i; j < n; j++) {
	        ll choose_first = (i+1 > j ? 0 : -dp[i+1][j]) + A[i];
	        ll choose_last = (j-1 < i ? 0 : -dp[i][j-1]) + A[j];
	        dp[i][j] = max(choose_first, choose_last);
	    }
	}
	
	printf("%lld", dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>

int main(){
  int i,j,minj,n,w,c=0;
  int a[100];

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    minj=i;
    
    for(j=i;j<n;j++){

      if(a[j]<a[minj]) minj=j;
      
    }
    
    if(a[i]!=a[minj]){
      w=a[i];
      a[i]=a[minj];
      a[minj]=w;
      c++;
    }
    
  }
  
  for(i=0;i<n;i++){
    
    printf("%d",a[i]);
    
    if(i!=n-1) printf(" ");
  }
  
  printf("\n%d\n",c);
  
  return 0;
}



Measured memory_bytes: 2128
s1 = input()
s2 = input()

dp = [[0]*(len(s2)+1) for i in range(len(s1)+1)]

for i in range(len(s1)+1):
    dp[i][0] = i
for i in range(len(s2)+1):
    dp[0][i] = i

for i in range(1, len(s1)+1):
    for j in range(1, len(s2)+1):
        tmp = dp[i-1][j-1]
        if s1[i-1] != s2[j-1]:
            tmp += 1

        dp[i][j] = min(tmp, min(dp[i-1][j]+1, dp[i][j-1]+1))

print(dp[len(s1)][len(s2)])




Measured memory_bytes: 41952
n, _p = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("").map(&:to_i)
ans = 0

if _p == 2 || _p == 5
    n.times do |i|
        ans += i+1 if s[i] % _p == 0
    end
    puts ans
    exit
end

h = Hash.new(0)
digit = 1
tmp = 0
(n-1).downto(0) do |i|
    tmp += s[i] * digit % _p
    h[tmp % _p] += 1
    digit *= 10
    digit %= _p
end

h.each do |key, value|
    ans += value * (value-1) / 2 if 2 <= value
end

puts ans + h[0]

Measured memory_bytes: 14972
N,L=map(int,raw_input().split())
S=[]
for i in range(N):
    S.append(raw_input())
#print S
S_num=[]
for i in range(N):
    s_num=""
    for alpha in S[i]:
        s_num+="{:0=2}".format(ord(alpha)-ord("a")+1)
    S_num.append([int(s_num),i])

S_num.sort()
S_sort=[str(s_num[0]) if len(str(s_num[0]))%2==0 else "0"+str(s_num[0]) for s_num in S_num]
S_num_sort="".join(S_sort)
#print S_num_sort

S_num_2=[S_num_sort[i*2:i*2+2] for i in xrange(len(S_num_sort)/2)]
#print S_num_2
S_alpha=[chr(96+int(s_num_2)) for s_num_2 in S_num_2]
Ans="".join(S_alpha)

print Ans

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    vector<pll> P(4);
    vector<ll> A(4);
    ll v[] = {1, 2, 4, 8};
    for (int i = 0; i < 4; i++) {
        cin >> A[i];
        P[i] = {v[3 - i] * A[i], i};
    }


    priority_queue<pll, vector<pll>, greater<pll>> Q;
    for (int i = 0; i < 4; i++) {
        Q.push(P[i]);
    }

    ll N;
    cin >> N;

    N *= 4;

    ll ans = 0;
    while(N) {
        pii p = Q.top();
        Q.pop();
        ll i = p.second;
        ll vv = v[i];
        ans += A[i] * (N / vv);
        N %= vv;
    }
    cout << ans << endl;

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
from random import *
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(365)]
for i in range(365):
    cand=0
    for j in range(26):
        if s[i][cand]<s[i][j]:
            cand=j
    #print(cand+1)
    #print(randrange(1,26))
for i in range(365):
    print(i%26+1)

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

#define ll long long

int main(){
    int n;
    cin >> n;
    vector<tuple<string, int,int >> restaurants(n);
    for(int i = 0; i < n; i++){
        string s;
        int p;
        cin >> s >> p;
        restaurants[i] = make_tuple(s, -p, i + 1);
    }
    sort(restaurants.begin(), restaurants.end());
    
    for(auto x : restaurants){
        int i;
        tie(ignore, ignore, i) = x;
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int h;
int w;
int c;

int count(vector< vector<int> > &p, int b, int i, int j){
  int cnt = 1;
  for(int k = 0; k < 4; ++k){
    if(i+dx[k] >= 0 && i+dx[k] < h && 
       j+dy[k] >= 0 && j+dy[k] < w &&
       p[i+dx[k]][j+dy[k]] == b){
      p[i+dx[k]][j+dy[k]] = -1;
      cnt += count(p,b,i+dx[k],j+dy[k]);
    }
  }

  return cnt;
}

void change(vector< vector<int> > &p, int b, int c, int i, int j){
  for(int k = 0; k < 4; ++k){
    if(i+dx[k] >= 0 && i+dx[k] < h && 
       j+dy[k] >= 0 && j+dy[k] < w &&
       p[i+dx[k]][j+dy[k]] == b){
      p[i+dx[k]][j+dy[k]] = c;
      change(p, b, c, i+dx[k], j+dy[k]);
    }
  }
}

int solve(vector< vector<int> > p, int C[6]){
  for(int i = 0; i < 5; ++i){
    if(C[i] != C[i+1])
      change(p,C[i],C[i+1],0,0);
  }
  p[0][0] = -1;
  return count(p,C[5],0,0);
}

int main(){
  while(cin >> h >> w >> c, h){
    vector< vector<int> > p(h, vector<int>(w));
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j)
	cin >> p[i][j];

    int ans = 0;
    for(int a = 1; a < 7; ++a){
      for(int b = 1; b < 7; ++b){
	for(int d = 1; d < 7; ++d){
	  for(int e = 1; e < 7; ++e){
	    int C[6] = {p[0][0],a,b,d,e,c};
	    ans = max(ans, solve(p,C));
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3124
import java.util.Scanner;

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

	if(a<b && b<c){
		System.out.println("Yes");
	}
	else{
		System.out.println("No");
	}
	sc.close();
}
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
ll n;

int main(){
    cin >> n;
    cout << 800*n - (n/15)*200 << endl;
}

Measured memory_bytes: 256