akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();

			out.println((a+b)%24);

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>                          
using namespace std;                                               
int main(){
	int j,i;
	string s,t;
	getline(cin,s);
	getline(cin,t);
    for(i=s.size()-t.size();i>=0;i--)
	{
		for(j=0;j<t.size();j++)
		{
			if(s[j+i]!=t[j]&&s[i+j]!='?') break;
		}
	    if(j==t.size())break;
    }
    if(i<0) cout<<"UNRESTORABLE";
    else{
    	for(j=0;j<t.size();j++)
    	{
    		s[i+j]=t[j];
		}
		for(i=0;i<s.size();i++)
		{
			if(s[i]=='?') s[i]='a';
		}
		cout<<s;
	}
	return 0;
}                        

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
		int n, i, chain[100];
		cin >> n;
		for ( i = 0; i < n; i++ )
		{
			cin >> chain[i];
		}
		for ( i = n - 1; i >= 0; i--)
		{
			cout << chain[i];
			if ( i == 0 )break;
			cout << " ";
		}
        cout << endl;
	return 0; 
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

vector<int> adj[100001];
bool visited[100001] = {false};
int distanc[100001] = {0};

int ld(int x)
{
    if (!visited[x])
    {
        visited[x] = true;
        int dist = 0;
        if (adj[x].empty())
        {
            distanc[x] = 0;
            return distanc[x];
        }
        
        for(int k=0; k<adj[x].size(); k++)
        {
            
            dist = max(dist, ld(adj[x][k]));
        }

        distanc[x] = dist + 1;
        return distanc[x];
    }
    else
    return distanc[x];
}

int main()
{
    int n, m, p, q, t, i, j;
    cin>>n>>m;
    
    while(m--)
    {
        cin>>p>>q;
        adj[p].push_back(q);
    }
    
    for(i=1; i<=n; i++)
    {
        if (!visited[i])
        {
            t = ld(i);
        }
    }
    
    cout <<*max_element(distanc , distanc + n + 1);
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> coins;
    coins.push_back(1);
    
    int limit = 6;
    while(limit <= n) {
        coins.push_back(limit);
        limit *= 6;
    }
    limit = 9;
    while(limit <= n) {
        coins.push_back(limit);
        limit *= 9;
    }
   // for(int j : coins) cout << j << ' ';
   // cout << endl;
    int dp[n + 1];
    dp[0] = 0;

    for(int i = 1; i <= n; i++) {
        dp[i] = 1e6;
    }

    for(int i = 1; i <= n; i++) {
        for(int j : coins) {
           if(j <= i and dp[i - j] + 1 < dp[i])
                dp[i] = dp[i - j] + 1;

        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const long long INF = 9e9;

template<class T> inline bool chmin(T &a,T b){
  if(a > b){
    a = b;
    return true;
  }
  else
    return false;
}

using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  rep0(i,N){
    cin >> h[i];
  }
  long long dp[N];
  rep0(i,N){
    dp[i] = INF;
  }
  dp[0]=0;
  rep1(i,N-1){
    rep1(j,K){
      if(i-j>=0){
        chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
bool isPal(string &s){
	int left = 0, right = s.size() - 1;
	while (right > left){
		if (s[left] != s[right]){
			return false;
		}
		left++, right--;
	}
	return true;
}
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin>>s;
	string a;
	for (int i=0; i<s.size()/2; i++){
		a = a + s[i];
	}
	string b;
	for (int i=s.size()/2+1; i<s.size(); i++){
		b = b + s[i];
	}
	if (isPal(a) == true && a == b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
h, w = map(int,input().split())
a = [input() for _ in range(h)]
c = 0

#行の中で「....」があれば取り除く.
while "."*w in a:
    a.remove("."*w) #removeは該当要素のうち最初の要素を削除
    c += 1
    
#行と列の入れ替え
a = ["".join(column) for column in zip(*a)]
while "."*(h-c) in a:
    a.remove("."*(h-c))

#行と列を再度入れ替えて出力.
for row in zip(*a):
    print("".join(row))

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int x, y;
    while(1) {
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) {
            break;
        }
        if(x < y) {
            printf("%d %d\n", x, y);
        } else {
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        for (int i = 0; i < m; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int max_l = l[0];
        int min_r = r[0];
        for (int i = 1; i < m; i++) {
            max_l = Math.max(max_l, l[i]);
            min_r = Math.min(min_r, r[i]);
        }
        if (min_r - max_l < 0) {
            System.out.println(0);
        } else {
            System.out.println(min_r - max_l + 1);
        }
        sc.close();
    }
}

Measured memory_bytes: 79964
#include<iostream>
#include<vector>
#include<memory>
#include<algorithm>

struct node {

	int index;
	int depth;
	int parent;
	std::vector<int> id_list;
	node() :index{ -1 }, depth{ 0 }, parent{-1}, id_list{}{}
};


void set_depth(std::vector<node>*const list_, int index) {
	auto&ref = *list_;
	for (auto e : ref[index].id_list) {
//		std::cout << index << "\n";
/*		auto it = std::find_if(std::begin(ref), std::end(ref)
			, [=](auto&x) {return x.index == e; }
		);

		if (it != std::end(ref)) {
			it->depth = ref[index].depth + 1;
			set_depth(list_, it->index);
		}*/
		ref[e].depth += ref[index].depth + 1;
		set_depth(list_, ref[e].index);
	}

}

void set_parent(std::vector<node>*const list_, int index) {
	auto& ref = *list_;
	for (const auto& e : ref[index].id_list) {

		auto it = std::find_if(std::begin(ref), std::end(ref)
			, [=](auto x) {return x.index == e; });

		if (it != std::end(ref)) {
			it->parent = index;
			set_parent(list_, it->index);
		}
	}
}

int main() {
	int n;
	std::cin >> n;

	std::vector<node> tree;
	tree.resize(n);


	for (int i{}; i < n;++i) {
		int index_;
		std::cin >> index_;
		tree[index_].index = index_;

		int size_;
		std::cin >> size_;
		tree[index_].id_list.resize(size_);
		
//		std::cout << index_<<" "<<size_<<" ";
		for (auto& ce : tree[index_].id_list) {
			std::cin >> ce;
			tree[ce].parent = index_;
//			std::cout << ce << " ";
		}//std::cout << "\n";
	}

	/*
	for (auto&e : tree) {
		std::cout << e.index<<" "<<e.id_list.size() << "\n";
	}*/

	int root_id{};
	for (int i{}; i < n; ++i) {
		if (tree[i].parent == -1) {
			root_id = i;
//			std::cout << i << "\n";
			break;
		}
	}
//	std::cout << root_id << "\n";
	set_depth(&tree, root_id);
	//set_parent(&tree, root_id);


	for (const auto&e : tree) {
		std::cout << "node " << e.index << ": ";
		std::cout << "parent = " << e.parent<<", ";
		std::cout << "depth = " << e.depth << ", ";
		std::cout << (e.parent == -1 ? "root"
			: e.id_list.empty() ? "leaf" : "internal node") << ", ";

		std::cout << "[";
		if (!e.id_list.empty()) {
			std::cout << e.id_list[0];
			if (e.id_list.size() != 1)
				for (unsigned i{ 1 }; i < e.id_list.size(); ++i)
					std::cout << ", " << e.id_list[i];
		}
		std::cout << "]\n";

	}
	return 0; 
}


Measured memory_bytes: 7232
#include <stdio.h>

int main(int argc, char *argv[])
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);

	if( (a==5 && b==7 && c==5) || (a==5 && b==5 && c==7) || (a==7 && b==5 && c==5) )
		printf("YES");
	else printf("NO");

	return 0;
}

Measured memory_bytes: 2092
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
// https://qiita.com/drken/items/b97ff231e43bce50199a
int main() {
    ll a,b;
    std::cin >> a>>b;
    ll x,y;
    extGCD(a,b,x,y);
    std::cout << x<<" "<<y << std::endl;
}



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

typedef long long int ll;

int main()
{
	ios::sync_with_stdio(0);
	ll n,k;
	cin >> n >> k;
	ll i,j;
	ll a[n];
	for(i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	bool dp[k+1];
	for(i=0;i<=k;i++)
		dp[i]=false;
	dp[0]=true;
	for(i=0;i<n;i++)
	{
		if(a[i]<=k)
			dp[a[i]]=true;
	}
	for(i=1;i<=k;i++)
	{
		if(!dp[i])
		{
			for(j=0;j<n;j++)
			{
				if(a[j]<=i)
				{
					if(!dp[i-a[j]])
					{
						dp[i]=true;
						break;
					}
				}				
				else
					break;
			}
		}
	}
	if(dp[k])
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

Measured memory_bytes: 384
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	string s,t;
	int c=INT_MAX;
	cin>>s>>t;
	for(int i=0;i<=s.size()-t.size();++i){
		int C=0;
		for(int j=0;j<t.size();++j){
			if(t[j]!=s[j+i]) ++C;
		}
		c=min(c,C);
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,m;
vi a;
vp ans;

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	ans=vp(n);
	a=vi(n);
	for(auto i=ans.begin();i!=ans.end();i++) (*i).second=i-ans.begin()+1;
	for(auto i=a.begin();i!=a.end();i++) cin>>*i;
	for(int i=0;i<m;i++){
		int b;
		cin>>b;
		for(auto it=a.begin();it!=a.end();it++){
			if(*it<=b){
				ans[it-a.begin()].first--;
				break;
			}
		}
	}
	sort(ans.begin(),ans.end());
	cout<<ans[0].second<<endl;
}

Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  vector<int> A(3);
  for(int i=0; i<3; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  cout << A[0]*A[1]/2 << endl;
  
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int N = 2e5+5;
int a[N];

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
    //fileIO();
    int n,k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    sort(a+1,a+n+1);
    //for(int i = 1; i <= n; i++)cout << a[i] <<" ";
    //cout << endl;
    int cnt = 0;
    for(int i = 1; i <= n-k;i++)
    {
        cnt += a[i];
    }
    cout << cnt;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = 10**15+5
min_arg = 0
for i, j in enumerate([a,b,c,d,e], 1):
    if j < m:
        min_arg = i
        m = j

print(N//m + (N%m!=0) + 4)

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

using namespace std;

class Card {
public:
    uint8_t suit;
    int32_t num;

    Card() {
        suit = 'S';
        num = 1;
    }

    Card(string str) {
        suit = str[0];
        num = str[1] - 48;
    }
};

bool operator< (const Card &c1, const Card &c2) {
    return c1.num < c2.num;
} ;

ostream& operator<< (ostream& os, const Card& c) {
    os << c.suit << c.num;
    return os;
}

template<typename T>
vector<T> bubble_sort(vector<T> v) {
    for (uint32_t i = 0; i < v.size(); i++) {
        for (uint32_t j = v.size() - 1; j > i; j--) {
            if (v[j] < v[j - 1]) {
                swap(v[j], v[j - 1]);
            }
        }
    }

    return v;
}

template<typename T>
vector<T> insertion_sort(vector<T> v) {
    for (uint32_t i = 0; i < v.size(); i++) {
        uint32_t mini = i;
        for (uint32_t j = i; j < v.size(); j++) {
            if (v[j] < v[mini]) {
                mini = j;
            }
        }

        if (i != mini) {
            swap(v[i], v[mini]);
        }
    }

    return v;
}

template<typename T>
void print(vector<T> v) {
    for (uint32_t i = 0; i < v.size() - 1; i++) {
        cout << v[i] << " ";
    }
    cout << v[v.size() - 1] << endl;
}

bool is_stable(vector<Card> v1, vector<Card> v2) {
    for (int32_t i = 1; i <= 9; i++) {
        uint32_t j = 0, k = 0;
        while (1) {
            while (v1[j].num != i && j < v1.size()) j++;
            while (v2[k].num != i && k < v2.size()) k++;
            if (j >= v1.size() || k >= v2.size()) break;
            if (v1[j].suit != v2[k].suit) return false;
            j++;
            k++;
        }
    }

    return true;
}

int main() {
    int32_t N;

    cin >> N;

    vector<Card> A(N);

    for (int32_t i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        A[i] = Card(temp);
    }

    vector<Card> B = bubble_sort(A);
    print(B);
    cout << (is_stable(A, B) ? "Stable" : "Not stable") << endl;

    vector<Card> C = insertion_sort(A);
    print(C);
    cout << (is_stable(A, C) ? "Stable" : "Not stable") << endl;

    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l; cin >> n >> l;
  vector<string> S(n);
  rep(i, n) cin >> S[i];
  sort(all(S));
  rep(i, n) cout << S[i];
  cout << endk;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> h(n);
	for( auto &k : h ) cin >> k;
	bool flag = true;
	for( int i = 1; i < n; ++i ){
		if( h[i-1] > h[i] ){
			flag = false;
			break;
		}
		if( h[i-1] < h[i] ) --h[i];
	}
	if( flag ) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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


//main関数
int main() {
	int N;
	scanf("%d",&N);
	N = N % 10;
	if(N == 2 || N==4 || N == 5 || N==7 || N==9 ){
		printf("hon");
	} else if ( N==0 || N==1 || N==6 || N==8){
		printf("pon");
	}else{
		printf("bon");
	}
	return 0;
}

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

int main(void){
	int n;
	char henzi[100][3];
	int x = 0;
	int y = 0;
	int s = 0;
	int i = 0;

	scanf("%d", &n);
	while(i < n)
	{
		scanf("%s",  henzi[i]);
		i++;
	}

	for(i = 0;i < n; i++)
	{
		if((int)strlen(henzi[i]) == 1)
			x++;
		else
			y++;

		if (x < y)
		{
			s++;
			break;
		}
	}

	if((x == y) && !s)
		printf("YES\n");
	else
		printf("NO\n");

	
	return 0;
}



Measured memory_bytes: 2140
<?php
// Your code here!
    $N = intval(trim(fgets(STDIN)));
    
    for($i=0;$i<$N;$i++){
        $A[] = intval(trim(fgets(STDIN)));
    }
    
    arsort($A);
    $Asave = $A;
    $max1 = array_shift($A);
    $max2 = array_shift($A);
    foreach($Asave as $key => $value){
        if($value == $max1){
            // echo $max2;
            $ans[$key] = $max2;
        }else{
            // echo $max1;
            $ans[$key] = $max1;
        }
    }
    // var_dump($A);
    ksort($ans);
    // var_dump($ans);
    for($i=0;$i<count($ans);$i++){
        echo $ans[$i]."\n";
    }
  
?>

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

const int SIZE=1e5;

int N,M;
int P[SIZE],A[SIZE],B[SIZE],C[SIZE];

int dp[SIZE];
signed main(){
    scanf("%lld%lld",&N,&M);
    for(int i=0;i<M;i++)scanf("%lld",&P[i]),P[i]--;
    for(int i=0;i<N-1;i++)scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);

    for(int i=0;i<M-1;i++){
        dp[min(P[i],P[i+1])]++;
        dp[max(P[i],P[i+1])]--;
    }
    int ans=0;

    for(int i=0;i<N-1;i++){
        dp[i+1]+=dp[i];
        ans+=min(dp[i]*A[i],C[i]+dp[i]*B[i]);
    }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int sum = 0;
    string s;

    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '+') {
            sum++;
        } else {
            sum--;
        }
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
s = input()
if int(s[:2]) >= 1 and int(s[:2]) <= 12 and int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[:2]) >= 1 and int(s[:2]) <= 12:
    print('MMYY')
elif int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        int k=n%1000;
        int c=1000-k;
        cout<<c<<endl;


    }
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
ln = list(map(int, input().split()))
min_ln = []
for i in range(n):
    if i == 0:
        min_ln.append(0)
    elif i == 1:
        min_ln.append(abs(ln[1] - ln[0]))
    else:
        min_ln.append(min(abs(ln[i] - ln[i-1]) + min_ln[i-1], abs(ln[i] - ln[i-2]) + min_ln[i-2]))
print(min_ln[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    int n;
    cin >> n;
    int a[n];
    int bit = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        bit = bit ^ a[i];
    }
    if(!bit){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
s,xor,cnt,l,r=0,0,0,0,0
for l in range(n):
    while(r<n):
        if s+a[r]==xor^a[r]:
            s+=a[r]
            xor=xor^a[r]
            r+=1
            if r ==n: cnt +=(r-l)*(r-l+1)/2
        else:
            s-=a[l]
            xor = xor & ~a[l]
            cnt +=r-l
            break
print(int(cnt))

Measured memory_bytes: 24584
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

void dijkstra(vector<vector<data>>& tree,vector<ll>& d,ll start){
  ll i,K=tree[start].size(),N=d.size(),cnt=1;
  data x;
  d[start]=0;
  priority_queue<data,vector<data>,greater<data>> que;
  rep(i,K){
    que.push(data(tree[start][i].second,tree[start][i].first));
  }
  while(cnt<N){
    x=que.top();que.pop();
    if(d[x.second]>0)continue;
    d[x.second]=x.first;
    cnt++;
    K=tree[x.second].size();
    rep(i,K){
      if(d[tree[x.second][i].first]<0){
        que.push(data(d[x.second]+tree[x.second][i].second,tree[x.second][i].first));
      }
    }
  }
}


int main(){
  ll i,N,M,ans=0,term,p;
  cin>>N>>M;
  if(N==1){
    if(M==1){
      cout<<1<<endl;
    }else{
      cout<<M-2<<endl;
    }
    return 0;
  }
  if(M==1){
    cout<<N-2<<endl;
  }else{
    cout<<(N-2)*(M-2)<<endl;
  }
  return 0;
}

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

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

  vector<int> a(n);
  for ( int i = 0; i < n; i++ ) cin >> a[i];

  vector<int> dp(2001, 0);
  dp[0] = 1;  
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 2000; j >= 0; j-- ) {
      if ( !dp[j] ) continue;
      if ( j+a[i] < 2001 ) dp[j+a[i]] = 1;      
    }
  }

  int q;
  cin >> q;
  while ( q-- ) {
    int m;
    cin >> m;
    if ( dp[m] ) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3124
n = int(input())

persons = [0] * 120

for i in range(n):
	b, f, r, v = map(int, input().split())
	index = 30*(b-1) + 10*(f-1) + r - 1
	persons[index] += v

for j in range(4):
	if j >= 1:
		print("#"*20)
	for h in range(3):
		for w in range(10):
			print(" %d" %(persons[w + h * 10 + j * 30]), end='')
		print()


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<string>> S(H, vector<string>(W));
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++)
      cin >> S.at(i).at(j);
  
  for (int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      if (S.at(i).at(j) == "snuke")
        cout << (char)('A'+j) << i+1 << endl;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(K):
        B = [0] * (N + 1)
        for i in range(N):
            B[max(i - A[i], 0)] += 1
            B[min(i + A[i] + 1, N)] -= 1
        for i in range(1, N):
            B[i] += B[i-1]
        A = B
        if sum(A[:-1]) == N * N:
            break
    print(' '.join(str(i) for i in A[:-1]))
main()


Measured memory_bytes: 171640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<((a*b)%2?"Odd":"Even")<<endl;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> c[i][j];
    }
  }

  int all_black = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (c[i][j] == '#') {
        ++all_black;
      }
    }
  }

  int ans = 0;
  for (int h = 0; h < 1 << H; ++h) {
    for (int w = 0; w < 1 << W; ++w) {
      int black = 0;
      for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
          if ((h & 1 << i || w & 1 << j) && c[i][j] == '#') {
            ++black;
          }
        }
      }

      if (all_black - black == K) {
        ++ans;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3584
while True:
    try:
        n  = input()
        while(len(n) != 1):
            s = ''
            for i in range(0,len(n) - 1):
                s += str((int(n[i]) + int(n[i + 1])) % 10)
            n = s
        print(n)
    except:
        break


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j <= i; j++) {
				sum += a[0][j];
			}
			for (int j = i; j < n; j++) {
				sum += a[1][j];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    int K,T;
    cin >> K >> T;
    vector<int> A(T);
    REP(i,T) cin >> A[i];
    sort ALL(A);
    reverse ALL(A);
    if(K == 1) cout << A[0] - 1 << endl;
    int ans = 0,C = A[0],N = 0;
    REPP(i,1,T){
        if(N < C) N += A[i];
        else C += A[i];
    }
    ans = abs(C - N) - 1;
    ans = max(0,ans);
    cout << ans << endl;
}

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

using namespace std;

int main(void)

{
    string s, prev, str;
    int i, a, counter = 0;
    cin>>s;
    a = s.size();
    str += s[0];
    if(a == 1)
        counter = 1;
    else{
    for(i = 0; i < a;){
        if(str.empty())
            str += s[i];
        if(!str.compare(prev)){ //mile jai
            i++;
            str += s[i];
        }
        else{
            counter++;
            //cout<<str<<endl;
            prev = str;
            str.clear();
            i++;
        }
    }
    }
    printf("%d\n", counter);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

vi E[200'050];
int main() {
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,0,n-1) {
        int x;
        cin >> x;
        x--;
        E[x].pb(i+1);
    }
    rep(i,0,n) cout << E[i].size() << endl;
   return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	
	int a,b;
	cin>>a>>b;
	int ans = -1;
	for(int i=1;i<1e5;i++){
		if(int(i * 0.08) == a && int(i * 0.1) == b){
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const long long mod = 1e9 + 7;
int n;

void copy(long long a[N][N], long long b[N][N]) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			a[i][j] = b[i][j];
		}
	}
}

void mult_mat(long long a[N][N], long long b[N][N]) {
	long long c[N][N];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			c[i][j] = 0;
			for (int k = 0; k < n; k++) {
				c[i][j] = (c[i][j] + (a[i][k] * b[k][j]) % mod) % mod;
			}
		}
	}
	
	copy(a, c);
}

void mat_exp(long long m[N][N], long long k) {
	
	long long ans[N][N];
	for (int i = 0; i < n; i++) {
		ans[i][i] = 1;
	}

	while (k) {
		if (k & 1) {
			mult_mat(ans, m);
		}
		mult_mat(m, m);
		k >>= 1;
	}

	copy(m, ans);
}

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

	long long k, mat[N][N];

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> mat[i][j];
		}
	}

	mat_exp(mat, k);

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans = (ans + mat[i][j]) % mod;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 384
use std::io;
use std::collections::HashMap;
fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let a:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let b: i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let mut tax:HashMap<(i32, i32), Vec<i32>> = HashMap::new();
	for i in (1..1010) {
		
			let mut m = tax.insert((i*8/100, i*10/100), vec![]);
			if m == None {
				let mut v = vec![i];
				tax.insert((i*8/100, i*10/100), v);
			}else{
				let mut v = m.unwrap();
				v.push(i);
				tax.insert((i*8/100, i*10/100), v);
			}
		
	}
	match tax.get(&(a, b)) {
		None => println!("-1"),
		Some(v) => println!("{}", v[0]),
	};
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;

using ll = long long;
ll x, a, b;

int main(){
    scan(x);
    for(ll i = -200; i <= 200; i++){
        for(ll j = -200; j <= 200; j++){
            if(i*i*i*i*i - j*j*j*j*j == x){
                print(i, j);
                return 0;
            }
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3636
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

import math

def get_num_of_reachable(H, W):
    if H == 1 or W == 1: return 1
    else: return math.ceil((H*W)/2)

def main():
    H, W = map(int, input().split())
    print(get_num_of_reachable(H, W))

if __name__ == "__main__":
    try:
        assert get_num_of_reachable(4, 5) == 10
        assert get_num_of_reachable(7, 3) == 11
        assert get_num_of_reachable(1000000000, 1000000000) == 500000000000000000
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int s = 0;
    scanf("%ld", &s);
    int a[500000] = {0};
    a[1] = s; int flag = 0; int m = 0;
    for(int i = 1; ; i++){
        if(a[i] % 2 == 0){
            a[i+1] = a[i] / 2;
        }else {
            a[i+1] = 3 * a[i] + 1;
        }
        if(s == 2 || s == 1){
            m = 4;
            flag = 1;
        }else {
            if(i > 1){
                if(a[i-1] == 4 && a[i] == 2 && a[i+1] == 1){
                    m = i + 2;
                    flag = 1;
                }
            }
        }
        if(flag == 1) break;
    }
    printf("%d\n", m);
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cassert>

using namespace std;

struct Tag {
    int t, n, pos;

    Tag() {}
    Tag(int t, int n, int p) : t(t), n(n), pos(p) {}

    bool operator < (const Tag &other) const {
        return t > other.t;
    }
};

vector<int> speed;
bool speedcmp(const Tag &t1, const Tag &t2) {
    return speed[t1.n] < speed[t2.n];
}

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        speed.resize(N);
        vector<int> lap(N, 0);
        for(int i = 0; i < N; ++i) {
            cin >> speed[i] >> lap[i];
            lap[i] *= 2;
        }

        int ans = 0;
        vector<int> nt(2, 0);
        priority_queue<Tag> q;
        for(int i = 0; i < N; ++i) {
            q.push(Tag(0, i, 0));
        }
        while(!q.empty()) {
            Tag t = q.top();
            q.pop();

            ans = t.t;
            vector<Tag> v;
            v.push_back(t);
            while(!q.empty() && q.top().t == t.t) {
                v.push_back(q.top());
                q.pop();
            }
            sort(v.begin(), v.end(), speedcmp);
            for(int i = 0; i < v.size(); ++i) {
                const Tag &tag = v[i];
                //cout << tag.t << ' ' << tag.n << ' ' << tag.pos << endl;
                if(i > 0) assert(speed[tag.n] >= speed[v[i-1].n]);
                if(lap[tag.n] == 0) continue;

                int next = tag.t + speed[tag.n];
                int np = 1-tag.pos;
                if(nt[np] > next) next = nt[np];
                nt[np] = next;
                q.push(Tag(next, tag.n, np));
                lap[tag.n]--;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>

using namespace std;




int main()
{
	int a[105][105],b[105][105];//r??????c??????
	int c,r,count=0;
	while(cin>>r>>c)
	{
		int sum=0;
		memset(b,0,105*105*sizeof(int));
		for(int i=1;i<=r;i++)
			for(int j=1;j<=c;j++)
				cin>>a[i][j];
		for(int i=1;i<=r;i++)
			for(int j=1;j<=c;j++)
			{	b[i][j]=a[i][j];
		
			
			sum+=a[i][j];
			if(j==c)
				{
					b[i][j+1]=sum;
					
			sum=0;
			continue;
			}
		
		
		}
		for(int j=1;j<=c;j++)
			for(int i=1;i<=r;i++)
			{	
		
			
			sum+=a[i][j];
			if(i==r)
				{
					b[i+1][j]=sum;
					count+=sum;
			sum=0;
			continue;
			}
		
		
		}
			b[r+1][c+1]=count;
			for(int i=1;i<=r+1;i++)
				{
					for(int j=1;j<=c+1;j++)
					{
						cout<<b[i][j];
						if(j!=c+1)
							cout<<" ";
			if(j==c+1)
				cout<<endl;
					}
			}





	
	
	
	
	}




	
	
	



}

Measured memory_bytes: 3152
#虚無うめ
n,k=map(int,input().split())
lists=list(map(int,input().split()))
import collections
lists=collections.Counter(lists).most_common()
lists=lists[::-1]
if len(lists)<=k:
    print(0)
else:
    c=0
    for i in range(len(lists)-k):
        c+=lists[i][1]
    print(c)

Measured memory_bytes: 39348
n = gets.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.each do |x|
  h[x] += 1
end
s = h.select{|k, v| v >= 4}.keys.sort_by{|x| -x}
t = h.select{|k, v| v >= 2}.keys.sort_by{|x| -x}
ans = 0
ans = s[0] * s[0] if s.size > 0
ans = [ans, t[0] * t[1]].max if t.size > 1
puts ans

Measured memory_bytes: 15112
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] S = s.split("");
    String str = "";
    for(int i = 0;i < S.length;i++){
      if(!(str.equals("")) && S[i].equals("B")){
        str = str.substring(0, str.length() - 1);
      }
      else if(!(S[i].equals("B"))){
        str += S[i];
      }
    }
    System.out.println(str);
    
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <tuple>
using namespace std;

tuple<int, int, int> judge(int n, int y){
    for(int a = 0; a <= n; a++){
        for(int b = 0; b <= n; b++){
            int c = n - a - b;
            if (c < 0)continue;
            if(y == a*10000 + b*5000 + c*1000){
                return forward_as_tuple(a, b, c);
            }
        }
    } 
    return forward_as_tuple(-1, -1, -1);
}

int main(void){
    // Your code here!
    int N, Y;
    cin >> N >> Y;
    
    int ans[3];
    tie(ans[0], ans[1], ans[2]) = judge(N, Y);
    
    cout << ans[0] << ' ' <<  ans[1]  <<' ' <<  ans[2] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int Fib[45];

int fibonacci(int n){
if(Fib[n] != -1) return Fib[n];
if(n == 0 || n == 1) 
    return Fib[n] = 1;
else 
    return Fib[n] = fibonacci(n - 1) + fibonacci(n - 2);
}

int main(){
    int n, i;
    for(i = 0; i < 45; i++) Fib[i] = -1;

    scanf("%d", &n);
    printf("%d\n", fibonacci(n));
    return 0;
}



Measured memory_bytes: 2076
#include<iostream>
#include<string>

int main()
{
    std::string S;
    std::cin >> S;
 
    if("RRS" == S || "SRR" ==S) 
    {
        std::cout << "2";
    }
    if("SSS" == S) 
    {
        std::cout << "0";
    }
    if("RSR" == S || "RSS"== S || "SSR"== S || "SRS"== S)
    {
        std::cout << "1";
    }
    if("RRR" == S)
    {
        std::cout << "3";
    }
    return 0;
}

Measured memory_bytes: 3584
strength = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

A, B = [strength.index(n) for n in map(int, input().split())]
if A > B:
    print('Alice')
elif A < B:
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 9192
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,t=0,h=0;
	cin >> n;
	for (; n > 0; n--)
	{
		string taro, hanako;
		cin >> taro >> hanako;
		if (taro < hanako){ h += 3; }
		else if (taro>hanako){ t += 3; }
		else { t += 1; h += 1; }
	}
	cout <<t<< " " << h << endl;
	return 0;

}

Measured memory_bytes: 3180
import java.util.Arrays;
import java.util.Scanner; 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for(int i=0; i<n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int side1 = 0, side2 = 0;
		for(int i=1; i<n; i++) {
			if(arr[i] == arr[i-1]) {
				side1 = side2;
				side2 = arr[i];
				i++;
			}
		}
		System.out.println((long) side1 * side2);
	}
}


Measured memory_bytes: 48900
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

#define COMB_MAX (int)1e6 + 10
ll f[COMB_MAX], rf[COMB_MAX];
ll inv(ll x) {
	ll res = 1;
	ll k = mod - 2;
	ll y = x;
	while (k) {
		if (k & 1) res = (res * y) % mod;
		y = (y * y) % mod;
		k /= 2;
	}
	return res;
}
void init() {
	f[0] = 1;
	rep(i, 1, COMB_MAX) f[i] = (f[i - 1] * i) % mod;
	rep(i, 0, COMB_MAX) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
	if (k<0 || k>n || n < 0)return 0;
	ll a = f[n]; // = n!
	ll b = rf[n - k]; // = (n-k)!
	ll c = rf[k]; // = k!

	ll bc = (b * c) % mod;

	return (a * bc) % mod;
}
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	init();
	ll ans = 0;
	rep(r, k - 1, n)ans += a[r] * C(r, k - 1) % mod, ans %= mod;
	rep(l, 0, n - k + 1)ans += mod - a[l] * C(n - l - 1, k - 1) % mod, ans %= mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19388
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
infants = []
for i, A in enumerate(map(int, input().split(' '))):
    infants.append((-A, i + 1))
infants.sort()
dp = [[-1 for _ in range(N + 1)] for _ in range(N + 1)]


def search(i, l):
    # i番目の幼児を見ていて左にl人配置している
    if i == N:
        return 0
    if dp[i][l] != -1:
        return dp[i][l]
    (act_val, pos) = infants[i]
    act_val = -act_val
    ans = max(search(i + 1, l + 1) + abs(l + 1 - pos) * act_val,
              search(i + 1, l) + abs(N - i + l - pos) * act_val)
    dp[i][l] = ans
    return ans


print(search(0, 0))

Measured memory_bytes: 175560
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;

int main()
{
	char a[20] , b[20] , c[20];
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	if(a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0])
		printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,n,h,w;
    cin>>N;
    for(n=1;n<=3500;n++)
    {
        for(h=1;h<=3500;h++)
        {
            long long tmp=n*h*N;
            long long tmp2=4*h*n-N*h-N*n;
            if(tmp2==0) continue;
            if(tmp%tmp2==0&&tmp2>0)
            {

                    cout<<n<<" "<<h<<" "<<tmp/tmp2<<endl;
                    return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	int W,N;
	int k=1;
	while(cin>>W,W!=0){
		cin>>N;
		char comma;
		vector<int> c(N);
		vector<int> weight(N);
		vector< vector<int> >	dp(N+1,vector<int>(W+1));
		vector<	vector<int> >	m(N+1,vector<int>(W+1));
		for(int i=0;i<N;i++){
			cin>>c[i]>>comma>>weight[i];
		}
	
		
		for(int i=0;i<=W;i++){
			dp[N][i]=0;
			m[N][i]=0;
		}
		
		for(int i=N-1;i>=0;i--){
			for(int j=0;j<=W;j++){
				if(j<weight[i])
					dp[i][j]=dp[i+1][j];
				
				else{
				dp[i][j]=max(dp[i+1][j],dp[i+1][j-weight[i]]+c[i]);
				}
			}
		}
		cout<<"Case "<<k++<<":"<<endl;
		cout<<dp[0][W]<<endl;
		for(int i=W;i>=0;i--){
			if(dp[0][W]!=dp[0][i]){
				cout<<i+1<<endl;
				break;
			}
		}
		
		
		
	}
}

Measured memory_bytes: 8988
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {

	string S;

	cin >> S;

	int Q;

	cin >> Q;

	int count = 0;

	REP(i, Q) {
		int Q;
		cin >> Q;

		if (Q == 1) {
			count++;
		}
		else if(count%2 == 0){
			int F;
			cin >> F;
			char c;
			cin >> c;

			if (F == 1) {
				S.insert(S.begin(), c);
			}
			else {
				S.push_back(c);
			}
		}
		else {
			int F;
			cin >> F;
			char c;
			cin >> c;

			if (F == 2) {
				S.insert(S.begin(), c);
			}
			else {
				S.push_back(c);
			}
		}
	}

	if (count % 2 != 0) {
		reverse(ALL(S));
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 900
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int sum = 0;
        String ans = "Yes";
        
        for (int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
//            pw.println(a[i]);
        }
        for (int i=0; i<n; i++)
            sum += a[i];
        
        double line = (sum * (1.0 / (4.0 * m)));
        Arrays.sort(a);

        for (int i = n-1; i >= n-m; i--) {
//            pw.print(a[i] + " ");
            if (a[i] < line)    ans = "No";
        }
//        pw.println();
//        pw.println(line);
        pw.println(ans);
        pw.flush();
    }
}

Measured memory_bytes: 21844