akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int a = iin(), b = iin(), c = iin(), d = iin();
    iout(a * b > c * d ? a * b : c * d);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


Measured memory_bytes: 128
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
struct pr{
  bool operator()(const int* p,const int* q)const{
    if(*p==*q)
      return p<q;
    else
      return *p>*q;
  }
};
int main(){
  int i;
  int n,m;
  scanf("%d%d",&n,&m);
  int a[1000000]={};
  set<int*,pr> b;
  for(i=0;i<n;++i)
    b.insert(a+i);
  while(m--){
    int p,q;
    scanf("%d%d",&p,&q);
    --p;
    set<int*,pr>::iterator it=b.find(a+p);
    int* r=*it;
    b.erase(it);
    a[p]+=q;
    b.insert(r);
    printf("%d %d\n",*b.begin()-a+1,**b.begin());
  }
  return 0;
}

Measured memory_bytes: 51976
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll ans=0;
  map<ll,ll> m;
  m[0]++;
  ll a=0;
  rep(i,n){
    ll o;
    cin >> o;
    a+=o;
    m[a]++;
  }
  for(pair<ll,ll> b: m){
    ll v=b.second;
    ans+=(v-1)*v/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
package main

import (
	"fmt"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1768
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int x; cin >> x;
  int max = 1;
  FOR(i, 1, x) {
    FOR(k, 2, x) {
      if (pow(i, k) <= x && pow(i, k) > max) max = pow(i, k);
      if (pow(i, k) > x) break;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 888
import sys
from pprint import pprint
def main():
    for line in sys.stdin:
        H,W = map(int, line.split())

        if H == 0 and W == 0:
            break

        else:
            t = []
            for _ in range(H):
                t.append(list(input()))

            x,y = 0,0
            cnt = 0
            while True:
                cnt += 1
                if t[x][y] == ">":
                    y += 1
                elif t[x][y] == "v":
                    x += 1
                elif t[x][y] == "<":
                    y -= 1
                elif t[x][y] == "^":
                    x -= 1
                elif t[x][y] == ".":
                    f = 0
                    break

                if cnt > H * W:
                    f = 1
                    break
                else:
                    pass

            if f == 0:
                print(y, x)
            elif f == 1:
                print("LOOP")


if __name__ == "__main__":
    main()

Measured memory_bytes: 8396
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pob pop_back
#define forr(x) for(ll i = 0; i < x; i++)
#define forrr(x) for(ll j = 0; j < x; j++)
#define F first
#define S second
#define endl '\n'
#define pi pair<ll, ll>
#define mp make_pair
const ll N = 1e5 + 5, inf = 1e9 + 5;

ll n;
ll W;
ll w[N];
ll v[N];
ll dp[105][N];

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> W;
	forr(n)
		cin >> w[i] >> v[i];
	ll ans = 0;
	for(ll i = 0; i < n; i++)
		for(ll j = 0; j <= W; j++)
		{
			if(i > 0)
				if(j >= w[i])
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
				else
					dp[i][j] = dp[i - 1][j];
			else if(j >= w[i])
					dp[i][j] = v[i];
			ans = max(ans, dp[i][j]);
		}
	cout << dp[n - 1][W];
	return 0;
}


Measured memory_bytes: 80128
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
res = 0
for x in range(N-1):
  res += B[x]
  if A[x] + 1 == A[x+1]:
    res += C[A[x] - 1]
print(res + B[-1])

Measured memory_bytes: 9136
#include <iostream>

using namespace std;

const int K[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(int argc, char const *argv[])
{
    int a;
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    cin >> a;
    cout << K[--a];

    return 0;
}

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

int main(void){
  int i,j;
  int s;
  int a[1000000];
  scanf("%d",&s);
  a[0]=s;
  for(i=0;i<1000000;i++){
    if(a[i]%2==0){
      a[i+1]=a[i]/2;
    }else{
      a[i+1]=3*a[i]+1;
    }
    for(j=0;j<i;j++){
      if(a[i+1]==a[j]){
	printf("%d\n",i+2);
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = scanner.nextInt();
        int h = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println((double) w * h / 2);
        if((x ==  (double) w / 2) && (y == (double) h / 2)){
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}


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


int main (){
    int N, M;
    cin>>N>>M;
  	if(M==1){
		cout<<0<<endl;
    }
 	else if(M-N<1){
    	cout<<1<<endl;
  	}
  	else{
    	cout<<((M-1)%(N-1)==0?(M-1)/(N-1):(M-1)/(N-1)+1)<<endl;
  	}
}

Measured memory_bytes: 256
import kotlin.math.sqrt

fun main(args: Array<String>) {
    val ND = readLine()!!;
    val NDSplited = ND.split(" ");
    val N = NDSplited[0].toLong()
    val D = NDSplited[1].toLong()

    val xyList = mutableListOf<Pair<Long, Long>>()
    for (n in 1..N) {
        val xy = readLine()!!
        val xySplited = xy.split(" ")

        xyList.add(Pair(xySplited[0].toLong(), xySplited[1].toLong()))

    }

    var counter = 0
    for (pair in xyList) {
        val value = (pair.first * pair.first) + (pair.second * pair.second)
        if (sqrt(value.toDouble()) <= D) {
            counter++
        }
    }
    println(counter)
}

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

int main() {

int A,B,C,X;
int temp = 0;
cin >> A >> B >> C >> X;

int cnt = 0;

for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
        for(int k=0; k<=C; k++){
            temp = 500 * i + 100 * j + 50 * k;
            if (temp == X){
                cnt++;
            }
        }
    }
}

cout << cnt << endl;

}


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

using static Input;
using static Util;
class Program
{
    static int N;
    static long[] A;
    static void INPUT()
    {
        N = NextInt();
        A = LineLong();
    }

    static void OUT()
    {
        var s = new long[N];
        s[N - 1] = A[N - 1];
        for (int i = N - 2; i >= 0; i--)
        {
            s[i] = A[i] + s[i + 1] % MOD;
        }
        var ans = 0L;
        for (int i = 0; i < N - 1; i++)
        {
            ans += (A[i] * s[i + 1]) % MOD;
            ans %= MOD;
        }
        Console.WriteLine(ans);
    }

    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}


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

int main(){

  int a,b,c,d,e;
  int C=0,D=0,E=0;
  int t;

  cin>>a>>b>>c>>d>>e;

  if(a < 0){
    while(true){
      ++a;
      ++C;
      if(a==0) break;
    }
    D = 1;
  }
    
  while(true){
    ++a;
    ++E;
    if(a==b) break;
  }

  cout << c*C + d*D + e*E << endl;
    
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int index=-1;
    if(t.size()>s.size())
    {
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(int i=0;i<=s.size()-t.size();i++)
    {
        bool no=false;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]==t[j]||s[i+j]=='?')
            {
                continue;
            }
            else
            {
               
                no=true;
            }
        }
        if(!no){
            index=i;
        }
    }
    if(index!=-1)
    {
        for(int i=0;i<min(index,(int)s.size());i++)
        {
            if(s[i]=='?')
            {
                cout<<"a";
            }
            else{
                cout<<s[i];
            }
        }
        for(int i=0;i<t.size();i++)
        {
            cout<<t[i];
        }
        for(int i=t.size()+index;i<s.size();i++)
        {
            if(s[i]=='?')
            {
                cout<<"a";
            }
            else{
                cout<<s[i];
            }
            
        }
    }
    else
    {
        cout<<"UNRESTORABLE";
    }
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	string s;
	string t;
	lli a,b;
	string u;

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

	if(s==u)a--;
	else b--;

	cout<<a<<" "<<b<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int N;
int A[212345];
int main(){
  cin>>N;
  rep(i,N)cin>>A[i];

  int right = 0;
  ll ans=0,sum=0;
  for(int left=0;left<N;left++){
    while(right<N){
      if(sum+A[right]==(sum^A[right])){
        sum+=A[right];
        right++;
      }else{
        break;
      }
    }
    ans+=right-left;
    sum-=A[left];
    if(right==left)right++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int a, b, c, d, i;
  scanf("%d %d %d %d", &a, &b ,&c, &d);
  i=0;
  while(a > 0 && c > 0){
    if(i % 2 != 0){
      a -= d;
    }else{
      c -= b;
    }
    i++;
  }
  if(a > 0)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int[N];
        // 偶数の数全体と、数え上げ偶数の数
        int totalEven = 0;
        int cntEven = 0;

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            if (A[i] % 2 == 0) {
                totalEven++;
            }
            if (A[i] % 6 == 0 || A[i] % 10 == 0) {
                cntEven++;
            }
        }

        if (totalEven == cntEven) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e6+6;
const long long int inf=INT_MAX;
vector<pair<long long int , long long int > >adj[MAX];
int n,m ;
multiset<pair<long long int, long long int> >q;
long long int dis[MAX];
void init(int n){
	for(int i=0;i<n;i++){
		dis[i]=inf;
	}
}
void shortest_paths(int s){
	int i,j,k;
	dis[s]=0;
	q.insert(make_pair(0,s));
	while(!q.empty()){
		pair<long long int , long long int >p=*q.begin();
		int u=p.second;
		//int d=p.second;
		q.erase(*q.begin());
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].first;
			int d=adj[u][i].second;
			if(dis[v]>dis[u]+d){
				dis[v]=dis[u]+d;
				q.insert(make_pair(dis[v],v));
			}
		}

	}

}
int main(){
	long long int i,j,k, n ,m,s;
	cin>>n>>m>>s;
	for(i=0;i<m;i++){
		long long int x,y,z;
		scanf("%lld %lld %lld" , &x, &y, &z);
		adj[x].push_back(make_pair(y,z));
		//adj[y].push_back(make_pair(x,z));
	}
	init(n);
	shortest_paths(s);
	for(i=0;i<n;i++){
		if(dis[i]==inf)
			cout<<"INF"<<"\n";
		else
		printf("%lld\n" , dis[i]);
	}

}


Measured memory_bytes: 43172
#include<iostream>
#include<vector>
using namespace std;
int main()  {
	int n,k,q;
	cin>>n>>k>>q;
	vector<int> score(n+1,k);
	for(int i=1;i<=q;++i) {
		int x;
		cin>>x;
		score[x]++;
	}
	int ans = 0;
	for(int i=1;i<=n;++i) {
		if(score[i] - q > 0) {
			cout<<"Yes"<<endl;
		}else {
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 1024
def main():
    s = input()

    n = len(s)
    for i in range(n // 2):
        s = s[:-2]
        if s[0:n//2-i-1] == s[n//2-i-1:n-i*2-2]:
            print(n-i*2-2)
            return

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  string s;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> s;
    if(s == "AC") ac++;
    if(s == "WA") wa++;
    if(s == "TLE") tle++;
    if(s == "RE") re++;
  }
  
  cout << "AC x "  << ac << endl;
  cout << "WA x "  << wa << endl;
  cout << "TLE x "  << tle << endl;
  cout << "RE x "  << re << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[10][10];

string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}

int main(){
  clr(d,0);
  ll n;
  cin>>n;
  rep(i,1,n+1){
    string s = ntos(i);
    ll a = s[0]-'0';
    ll b = s[s.sz-1]-'0';
    d[a][b]++;
  }
  ll ans = 0;
  rep(i,1,10){
    rep(j,1,10){
      ans += d[i][j]*d[j][i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n; cin >> n;
	
	int root;
	Int maxx = 0;

	//root = sqrt(n);

	for (int i = 1; i <= n; i++) {
		for (int j = 2; j <= n; j++) {
			if (pow(i, j) > maxx && pow(i, j) <= n) maxx = pow(i, j);
		}
	}
	if (n == 1) cout << 1;
	else cout << maxx;


	return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) (((a) >> (b)) & 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int p[20];
  for (int i = 0; i < N; i++) cin >> p[i];

  sort(p, p + N, greater<int>());

  int sum = p[0] / 2;
  for (int i = 1; i < N; i++) {
    sum += p[i];
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static long max(long a, long b)
{
    return a < b ? b : a;
}

int main(int argc, char **argv)
{
    int n, w;
    scanf("%d %d", &n, &w);
    long val[n][w + 1];
    for (int i = 0; i < n; i++) {
        int wi, vi;
        scanf("%d %d", &wi, &vi);
        for (int j = 0; j <= w; j++) {
            if (i == 0) {
                val[i][j] = j < wi ? 0 : vi;
                continue;
            }
            val[i][j] = j < wi
                ? val[i - 1][j]
                : max(val[i - 1][j], val[i - 1][j - wi] + vi);
        }
    }
    printf("%ld\n", val[n - 1][w]);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 78336
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	x,y=1,1

	for _ in range(n):
		a,b=MI()
		k=max((x-1)//a,(y-1)//b)+1
		#print(k,x,y)
		x,y=k*a,k*b

	print(x+y)



if __name__ == "__main__":
	main()


Measured memory_bytes: 64124
#include<stdio.h>

int main()
{
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i = a; i <= b; i++){
		if(c % i == 0) count += 1;
	}
	printf("%d\n",count);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define scd(n) scanf("%d",&n)
#define scl(n) scanf("%I64d",&n)
#define mp(x,y) make_pair(x,y)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define fi first
#define se second

const int mx = 2e5+100;

int main() {
    int a,b,c,ans;
    scd(a);
    scd(b);
    scd(c);
    ans = a*100+b*10+c;
    if(ans%4 == 0) printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, c, d;
  cin >> a >> b >>c >> d;
  if((abs(a - b) <= d && abs(b - c) <= d)|| abs(a - c) <= d){
    cout << "Yes" << endl;
  }else{
    puts("No");
  }
  

}


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

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

    for(int i = 0;i < s.size();i++){
        s.insert(0, 1, s[s.size()-1]);
        s = s.substr(0, s.size()-1);
        if(s.compare(t)==0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
long long gcd (long long a, long long b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}
int main() {
	fast;
	lli k,sum=0,i,j,l;
	cin>>k;
	for(i=1;i<=k;i++)
	{
		for(j=1;j<=k;j++)
		{
			for(l=1;l<=k;l++)
			{
				sum+=gcd(i,gcd(j,l));
			}
		}
	}
	cout<<sum;
	
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
using namespace std;
int main(){
  int n;cin >> n;
  double a[n];
  string s[n];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> s[i];
  }
  double ans = 0;
  for(int j = 0; j < n; j++){
    if(s[j] == "JPY")ans+=a[j];
    else ans+= a[j]*380000;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
    static void Main() {
        string w = Console.ReadLine();
        string[] t;
        int ans = 0;
        while((t = Console.ReadLine().Split().ToArray())[0] != "END_OF_TEXT") {
            ans += t.Count(s => string.Compare(s, w, true) == 0);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 17100
def f_f():
    import numpy as np

    n = int(input())
    x, y = np.array([input().split() for _ in range(n)], dtype="int64").T

    a = np.arctan2(x, y)
    i = a.argsort()
    x, y, a = x[i], y[i], a[i]

    x, y = np.concatenate([x, x]), np.concatenate([y, y])
    a = np.concatenate([a, a+2*np.pi])

    xcs, ycs = x.cumsum(), y.cumsum()
    items = np.arange(1, n+1)[None,:]
    l = np.arange(n)[:,None]

    dx = xcs[l+items-1]-xcs[l]+x[l]
    dy = ycs[l+items-1]-ycs[l]+y[l]

    print((dx*dx+dy*dy).max()**0.5)

if __name__ == "__main__":
    f_f()


Measured memory_bytes: 20524
#include<bits/stdc++.h>
using namespace std;
int ans,k,n,a[200001];
int main()
{
	scanf("%d%d",&k,&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)ans=max(ans,a[i]-a[i-1]);
	ans=max(ans,k-a[n]+a[1]);
	printf("%d",k-ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int N;
int d[300000];

int main(void) {
	int i;
	int ok_max = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &d[i]) != 1) return 1;
	}
	for (i = 0; i < N && i <= ok_max; i++) {
		int this_max = i + d[i] / 10;
		if (this_max > ok_max) ok_max = this_max;
	}
	if (i < N) {
		puts("no");
		return 0;
	}
	ok_max = N - 1;
	for (i = N - 1; i >= 0 && i >= ok_max; i--) {
		int this_max = i - d[i] / 10;
		if (this_max < ok_max) ok_max = this_max;
	}
	if (i >= 0) {
		puts("no");
		return 0;
	}
	puts("yes");
	return 0;
}



Measured memory_bytes: 2908
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  int N; cin>>N;
  N = N % 10;
  if(N==3){
    cout<<"bon";
  } else if(N == 0 or N== 1 or N== 6 or N == 8){
    cout<<"pon";
  } else cout<<"hon";

  cout<<endl;


  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}


int main(void){
    int h,w;
    string s;
    cin>>h>>w;
    vector<vector<int>> m(h+2,vector<int>(w+2,0));
    rep(i,h){
        cin>>s;
        rep(j,w){
            if(s[j]=='#'){
                m[i+1][j+1]=1;
            }else{
                m[i+1][j+1]=0;
            }
        }
    }
    bool flg=false;
    REP(i,1,h+1){
        REP(j,1,w+1){
            if(m[i][j]==1){
                if(m[i][j-1]+m[i][j+1]+m[i-1][j]+m[i+1][j]==0)flg=true;
            }
        }
    }
    string ans="Yes";
    if(flg==true)ans="No";
    cout<<ans<<endl;

}



Measured memory_bytes: 256
import heapq

N = int(input())
R = [list(map(int,input().split())) for _ in range(N)]
B = [list(map(int,input().split())) for _ in range(N)]
R.sort()
B.sort()

# 青い点をx座標が小さい順にみていき、
# ペアにできる赤い点のうちy座標が最も大きいものをペアとする。
ans = 0
RS = [False for _ in range(N)]
for bx,by in B:
  pair = []
  for i in range(N):
    rx,ry = R[i]
    if rx > bx:
      break
    if ry > by or RS[i]:
      continue
    heapq.heappush(pair,[-ry,i])
  if len(pair) > 0:
    _,idx = heapq.heappop(pair)
    RS[idx] = True
    ans += 1
print(ans)


Measured memory_bytes: 40176
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  int ans[H][W]={};
  rep(i,H) rep(j,W) ans[i][j]=(i<B)^(j<A);
  rep(i,H){
    rep(j,W) cout << ans[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;
void solve(){
    int a, b;
    cin >> a >> b;
    int n = b - a;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        sum += i;
    }
    cout << sum - b << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
def main():
    N,*A=map(int, open(0).read().split())
    B=[]
    for a in A:
        x=bisect(B,-a)
        if x>=len(B):
            B.append(-a)
        else:
            B[x]=-a
    print(len(B))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14092
N,Y=map(int,input().split())
# x+y+z=N
# 10000x+5000y+1000z=Y
# となるような正整数(x,y,z)はあるか？
ans=[-1,-1,-1]
for x in range(N+1):
  for y in range(N-x+1):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
      ans=[x,y,z]
print(ans[0],ans[1],ans[2])

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

using namespace std;

int main() {
  int n, p;
  scanf("%d %d", &n, &p);
  int k0 = 0, k1 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a % 2 == 0) {
      k0++;
    } else {
      k1++;
    }
  }
  long long ans;
  if (k1 == 0) {
    ans = (1LL << n);
  } else {
    ans = (1LL << (n - 1));
  }
  if (p == 1) {
    ans = (1LL << n) - ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
e=10**9+7
n,m=map(int,input().split())
l=[]
d={}
for i in range(m):
    d[int(input())]=0
k=[0]*(n+1)
k[0]=1
for i in range(1,n+1):
    if i==1:
        try:
            c=d[i]
        except:
            k[i]=1
    else:
        try:
            c=d[i]
        except:
            k[i]=(k[i-1]+k[i-2])%e
print(k[-1])


Measured memory_bytes: 15076
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int H, W;
        {int[] a = in.ii(); H = a[0]; W = a[1];}
        char[][] S = new char[H][W];
        for(int i = 0; i < H; i++){
            S[i] = in.s().toCharArray();
        }
        final int inf = Integer.MAX_VALUE/2;
        int n = H*W;
        int[][] d = new int[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j){
                    continue;
                }
                int h1 = i/W;
                int w1 = i%W;
                int h2 = j/W;
                int w2 = j%W;
                boolean f = S[h1][w1] == '.' && S[h2][w2] == '.' && (h1 == h2 && Math.abs(w1-w2) == 1 || w1 == w2 && Math.abs(h1-h2) == 1);
                if(f){
                    d[i][j] = 1;
                } else {
                    d[i][j] = inf;
                }
            }
        }
        for(int k = 0; k < n; k++){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    if(d[i][j] > d[i][k] + d[k][j]){
                        d[i][j] = d[i][k] + d[k][j];
                    }
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(ans < d[i][j] && d[i][j] < inf){
                    ans = d[i][j];
                }
            }
        }
        out.println(ans);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22868
# -*- coding: utf-8 -*-
n = int(input())
from collections import  defaultdict
d = defaultdict(int)
for i in range(n):
    d["".join(sorted((input())))] += 1
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ret = 0
for k in d.values():
    if k == 1:
        continue
    ret += combinations_count(k,2)
print(ret)

Measured memory_bytes: 18236
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string str;
  std::cin >> str;
  std::vector<bool> exist(26, false);
  for (auto c : str) {
    if (exist[c - 'a']) {
      std::cout << "no" << std::endl;
      return 0;
    }
    exist[c - 'a'] = true;
  }
  std::cout << "yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

		while (true) {

			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[] stone = new int[n];
			int in = m;
			int cur = 0;
			
			while(true){
				if(in == 0){
					if(stone[cur] == m){
						System.out.println(cur);
						break;
					}else{
						in = stone[cur];
						stone[cur] = 0;
					}
				}else{
					stone[cur]++;
					in--;
				}
				cur = (cur + 1) % n;
			}
			
			
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int  input(string *s)
{
    int num=0,i=0;
    char p[1000];
    cin.getline(p,999);
    while(p[i]!='\0')
    {
       if(p[i]!=' ')
       {
           s[num]+=p[i];
           i++;
       }
       else
       {
           num++;
           i++;
       }   
    }
    s[++num]+=p[i-1];
    return num;
}

int len(string s)
{
    int i=0;
    while(s[i]!='\0')
    {
        i++;
    }
    return i;
}

int eval(string s)
{
    int val=0;
    int n=len(s);
    for(int i=0;i<n;i++)
    {
        val+=int(s[i]-48)*pow(10,n-1-i);
    }
    return val;
}

int main(int argc, char const *argv[])
{
    string s[1000];
    int n,a,b;
    vector<int> v(1000,0);
    n=input(s);
    for(int i=0;i<n;i++)
    {
        if(s[i]=="+")
        {
            a=*(v.end()-1);
            b=*(v.end()-2);
            v.pop_back();
            v.pop_back();
            v.push_back(a+b);
        }
        else
        {
            if(s[i]=="-")
            {
                a=*(v.end()-1);
                b=*(v.end()-2);
                v.pop_back();
                v.pop_back();
                v.push_back(b-a);
            }
            else
            {
                if(s[i]=="*")
                {
                    a=*(v.end()-1);
                    b=*(v.end()-2);
                    v.pop_back();
                    v.pop_back();
                    v.push_back(a*b);
                }
                else
                {
                    v.push_back(eval(s[i]));
                    //cout<<*(v.end()-1)<<" ";
                }
            }
        }
    }
    cout<<*(v.end()-1)<<endl;
    //system("pause");
    return 0;
}



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

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

  int minimalpath = 0;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    if (2*x > (2*abs(K-x))) {
        minimalpath += 2*abs(K-x);
    }
    else
        minimalpath += 2*x;
  }
    
  cout << minimalpath << endl;
}


Measured memory_bytes: 256
import  scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val n: Int = readInt()
    val k: Int = readInt()
    val ans: Int = (1 to n)
      .toList
      .foldLeft(1)((acc, x) => if (2 * acc > acc + k) acc + k else 2 * acc)
    println(ans)
  }
}


Measured memory_bytes: 25424
#include<bits/stdc++.h>
using namespace std;
int n,hb,big;
char ch;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>ch;
		if(ch=='I') hb++;
		else hb--;
		big=max(big,hb);
	}
	cout<<big<<endl;
	return 0;
}

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

int main(){
	ll n, m;
//	for(int i = 2; i <= 70; i++, i++)
//		cout << i << " "<< f(i) << endl;
	while(cin >> n){
		ll ans = n / 10;
		ll x = 50;
		while(x <= n){
			ans += n / x;
			x *= 5;
		}
		if(n % 2 == 1) cout << 0 << endl;
		else cout << ans << endl;	
	}
	return 0;	
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
int a,b,i;
char op;


for(i=1;i<10000;i++){
scanf("%d %c %d",&a,&op,&b);
if(op=='+') 
printf("%d\n",a+b);
else if(op=='-') 
printf("%d\n",a-b);
else if(op=='*')
printf("%d\n",a*b);
else if(op=='/')
printf("%d\n",a/b);
else if(op=='?')
break;
}

return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N, K; cin >> N >> K;
    vector<bool> v(N, false);
    for (int i = 0; i < K; ++i) {
        int d; cin >> d;
        for (int j = 0; j < d; ++j) {
            int a; cin >> a;
            v[a-1] = true;
        }
    }

    int ans = 0;
    for (auto i : v) if (!i) ans += 1;
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}
ll combination(ll n, ll r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1)%MOD + combination(n - 1, r)%MOD);
}
ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}
ll a[110];
int Comb[1010][1010];
int main() {
    int n; cin >> n;
    if(n<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;

	return 0;
}

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

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.Read;
            var b = cin.Read;
            if(a.Equals("H"))
            {
                WriteLine(b);
            }
            else
            {
                if (b.Equals("H"))
                {
                    WriteLine("D");
                }
                else
                {
                    WriteLine("H");
                }
            }
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e6 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
bool f; 
int lps[N], g[N], dis[N];
 
int calc(int cur, int org){
    if(cur == org)  {
        f = 1;
        return -1;
    }
    if(dis[cur] != -1)
        return dis[cur];
    if(g[cur] == -1)
        return dis[cur] = 0;
    dis[cur] = 1 + calc(g[cur], org);
    return dis[cur];
}
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s, t;
    cin >> s >> t;
    int tl = t.length();
    for(int i = 1, l = 0; i < tl; i++){
        while(l > 0 && t[i] != t[l])
            l = lps[l-1];
        if(t[i] == t[l])
            lps[i] = l + 1, l++;
    }   
    /*int i = 1, l = 0;
    while(i < tl){
        if(t[i] == t[l]){
            l++;
            lps[i] = l;
            i++;
        }
        else{
            if(l != 0)
                l = lps[l-1];
            else
                lps[i] = 0, i++;
        }
    }  */
    string tmp = s;
    while(tmp.length() < tl)
        tmp += s;
    s = tmp + tmp;
    int sl = (s.length());
    int i = 0, l = 0;
    for(int i = 0; i < sl; i++)
        g[i] = dis[i] = -1;
    while(i < sl){
        if(s[i] == t[l])
            i++, l++;
        if(l == tl){
            int u = (i-l)%sl;
            int v = (i)%(sl>>1);
            if(u < (sl >> 1)){
                g[u] = v;
            }
            l = lps[l-1];
        }
        else if(i < sl && t[l] != s[i]){
            if(l != 0)
                l = lps[l-1];
            else
                i += 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < (sl >> 1); i++){
        if(g[i] != -1){
            f = 0;
            int x = calc(g[i], i);
            if(f)
                return cout << -1, 0;
            dis[i] = 1 + x;
            ans = max(ans, dis[i]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 30384
import java.util.*;

class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   long MOD = 1_000_000_007;
   int[] S = new int[N];
   int[] T = new int[M];
   for(int i=0;i<N;i++){
    S[i] = sc.nextInt();
   }
   for(int i=0;i<M;i++){
    T[i] = sc.nextInt();
   }
   long[][] dp = new long[N+1][M+1];
   for(int i=1;i<=N;i++){
     for(int j=1;j<=M;j++){
       if(S[i-1] ==T[j-1]){
         dp[i][j] = dp[i-1][j]+dp[i][j-1]+1;
       }else{
         dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])+MOD;     
     }
       dp[i][j] %= MOD;
   }
   }
   System.out.println(dp[N][M]+1);
 }
}

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

import collections
c = collections.Counter(S).most_common()

m = c[0][1]
ans = []
for a, b in c:
    if b == m:
        ans.append(a)

for a in sorted(ans):
    print(a)



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

int d[10]{};

int main()
{
    ////////////////////////////////////////////////
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	
    ////////////////////////////////////////////////
    
    ll n{},k{};
    cin>>n>>k;
    for(ll i=0;i<k;i++){
        int t{};
        cin>>t;
        d[t] = 1;
    }
    for(ll i=n;i<1000005;i++){
        string s = to_string(i);
        for(ll j=0;j<s.size();j++){
            if(d[ s[j] - '0']){
                goto j;
            }
        }
        cout<<i;
        break;
        j:;
    }
    
    return 0;
}


Measured memory_bytes: 256