akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
suma = 0
maxa = max(A)
bin = format(maxa,'b')
for i in range(len(bin)):
    count1 = 0
    for j in range(N):
        if (A[j] >> i) & 1 == 1:
            count1 += 1
    suma = (suma+(N-count1)*count1*((2**i))%(10**9+7))%(10**9+7)
print(suma)

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

int main(void){
	int a , i;
	char s[100000],ans[100000];
	
	scanf("%s",s);
	a = strlen(s);
	
	for(i = 0;i*2 < a;i++){
		ans[i] = s[i*2];
	}
	printf("%s",ans);
	
	return 0;
}

Measured memory_bytes: 384
import itertools

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

lis=sorted(p)

for i,j in enumerate(itertools.permutations(lis)):
  if list(j)==p:
    a=i
  if list(j)==q:
    b=i
    
print(abs(a-b))

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{  
  int N,Q; cin>>N; cin>>Q;
  vector<tuple<int,int,int> > event;
  for (int i = 0; i < N; i++)
  {
    int S,T,X;cin>>S>>T>>X;
    event.emplace_back(S - X,1,X);
    event.emplace_back(T - X,-1,X);
  }
  vector<int> D(Q);
  for (int i = 0; i < Q; i++)
  {
    cin>>D[i];
  }

  sort(ALL(event));
  vector<int> ANS(Q);
  set<int> se;
  int t = 0;
  int id = 0;
  for (int i = 0; i < Q; i++)
  {
    t = D[i];
    for ( ;id < (int)event.size() && get<0>(event[id]) <= t ; id++)
    {
      if(get<1>(event[id]) == 1)
      {
        se.insert(get<2>(event[id]));
      }
      else
      {
        se.erase(get<2>(event[id]));
      }
    }
    if(se.empty())
    {
      ANS[i] = -1;
    }
    else
    {
      ANS[i] = *se.begin();
    }
    
    // DEBUG(ANS);
  }
  for (int i = 0; i < Q; i++)
  {
    cout<<ANS[i]<<endl;
  }
    
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 25152
#include<bits/stdc++.h>
#define ll long long
const int N=200005;
using namespace std;
bool cmp(int a,int b)
{
	return a>b; 
}
int k,n,a[N],b[N];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	    cin>>a[i],b[a[i]]++;
	sort(b+1,b+1+n,cmp);
	for(int i=1;i<=k;i++) n-=b[i];
	cout<<n;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
        public class Main {
        static int threshold(int x,int y,int z){
            return x*x+y*y+z*z+x*y+x*z+y*z;
        }
        public static void main(String[]args){
            Scanner sc = new Scanner(System.in);
            int N= sc.nextInt();
            int f[]= new int[N];
            int sqN=(int)Math.sqrt(N);
            for(int n=1; n<N+1; n++) {
                for(int x=1; x<sqN+1; x++){
                    if(x*x>n){
                        break;
                    }
                    for(int y=1; y<sqN+1; y++){
                        if(x*x+y*y+x*y>n){
                            break;
                        }
            for(int z=1; z<sqN+1;z++){
              
                if(threshold(x,y,z)>n){
                    break;
                }else{
                    if(threshold(x,y,z)==n){
                        f[n-1]++;
                      break;
                    }
                }
            } 
                    }
                }
            }
              
            for(int i=0; i<N; i++){
                System.out.println(f[i]);
            }
        }
    }


Measured memory_bytes: 39052
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans = []
for i in range(x):
    for j in range(y):
        for m in range(z):
            if (i+1) * (j+1) * (m+1) > k:
                break
            ans.append(a[i] + b[j] + c[m])

ans.sort(reverse=True)
for i in ans[:k]:
    print(i)

Measured memory_bytes: 8708
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,s=0,i;
  cin>>n;
  int b[n-1];
  for(i=0;i<n-1;i++)
  cin>>b[i];
  s=b[0]+b[n-2];
  for(i=0;i<n-2;i++)
  {
    s+=min(b[i],b[i+1]);
  }
  cout<<s;
}

Measured memory_bytes: 256
#include "iostream"
#include "string" 
using namespace std;

int main()
{
	char s[26];
	string str;
	cin >> str;
	int len;
	len = str.size();
	int a = 0;
	for (int i = 0; i < len; i++)
		s[i] = str.c_str()[i];

	for (int i = 0; i < len; i++)
	{
		for (int j=i+1;j<len;j++)
		{
			if (s[i] == s[j])
			{
				cout << "no" << endl;
				j = len;
				i = len;
				a = 1;
			}
		}
	}
	if (a==0)
	{
		cout << "yes"<< endl;
	}
	return 0;
}


Measured memory_bytes: 256
/**
*    created: 05.07.2020 17:46:46
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n;
    cin >> n;
    cout << "ABC" << n << endl; 
    return 0;
}

Measured memory_bytes: 3652
import math
import sys

N, M = map(int, input().split())

vote = []
vote = list(map(int, input().split()))
sum_n = sum(vote)

i = 0
while i < M:
    max_n = max(vote)
    if max_n < math.ceil(sum_n / (4 * M)):
        print("No")
        sys.exit()
    vote.pop(vote.index(max_n))
    i += 1

print("Yes")

Measured memory_bytes: 3064
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[15][15]={},x,y,ans=0;
  string s;
  cin >> n;
  for(int i=1; i<=n; i++) {
    s=to_string(i);
    x=(int)(s[0]-'0'),y=(int)(s[s.size()-1]-'0');
    a[x][y]++;
  }
  for(int i=0; i<=9; i++) {
    for(int j=0; j<=9; j++) {
      ans+=a[i][j]*a[j][i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <map>
using namespace std;
#define ll long long
map<int, int> mm;
int a[100005];
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mm[a[i]]++;
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (mm[a[i]] < a[i]) {
            sum += mm[a[i]];
            mm[a[i]] = 0;
        }
        if (mm[a[i]] > a[i]) {
            sum += mm[a[i]] - a[i];
            mm[a[i]] = a[i];
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 5120
from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back

using namespace std;

int main(){
	string s;
	cin>>s;
	int ss=s.size(),gk=ss%2,poss=0;
	rep(i,0,ss-2){
		if(s[i]!=s[i+2]){
			poss=1;
		}
	}
	if(poss==0){
		cout<<"Second";
		return 0;
	}
	if(s[0]==s[ss-1]){
		if(gk==0){
			cout<<"First";
			return 0;
		}
		else{
			cout<<"Second";
			return 0;
		}
	}
	else{
		if(gk==0){
			cout<<"Second";
			return 0;
		}
		else{
			cout<<"First";
			return 0;
		}
	}
return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	long long mn=1LL<<55;
	int res=0;
	for(int i=0;i<n;i++){
		if(a[i]<mn) res++;
		mn=min(mn,a[i]);
	}
	cout << res << "\n";
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	 double  n,t;
	 cin>>n;
	 t=n/1000;
	 t=ceil(t);
	 cout<<(t*1000)-n;


}


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

namespace Atc_0043
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            if (S.Contains("a") && S.Contains("b") && S.Contains("c"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 25764
open System

let K = stdin.ReadLine() |> int

let rec f (x,y) =
    (10 * x + 7,y)
    |> (fun (x,y) -> if x % K = 0 then y elif K % 2 = 0 then -1 elif K % 5 = 0 then -1 else f (x % K , y + 1))

f (0,1)
|> printfn "%d"


Measured memory_bytes: 30048
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){
    int h,w;
    int i,j;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            if(i==0||i==h-1){
                for(j=0;j<w;j++){
                printf("#");
                }
                printf("\n");
            }
            else{
                printf("#");
                for(j=1;j<w-1;j++){
                    printf(".");
                }
                printf("#");
                printf("\n");
            }
            
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2952
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 01:01:58 2020

@author: liang
"""
#ゼロパディング＋インデックス
#str(1).zfill(6) + str(a.index(2) + 1).zfill(6)
#index(x) が重い => indexを使わなくて良いようにする

N, M = map(int, input().split())
#d = [list() for _ in range(N)]
dic = dict()
dic2 = dict()
P = list()

#insert O(M)
for i in range(M):
    p, y = map(int,input().split())
    #d[p-1].append(y)
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
    P.append((p,y))

#year sort O(N log N) => 重い　dict使用
#for i in range(N):
#    d[i].sort()
for key in dic.keys():
    dic[key].sort()

for key in dic.keys():
    for i in range(len(dic[key])):
        dic2[dic[key][i]] = i+1
#search O(M)***
for i in range(M):
    p, y = P[i]
    #ans = str(p).zfill(6)+str(d[p-1].index(y)+1).zfill(6)
    # zfill 重い？
    ans = ''
    ans += '0'*( 6 - len(str(p))) + str(p)
    #t = dic[p].index(y)+1
    t = dic2[y]
    ans += '0'*( 6 - len(str(t))) + str(t)
    print(ans)

Measured memory_bytes: 45536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define uid uniform_int_distribution
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpop(x) __builtin_popcountll((ulli)x)
#define blead(x) __builtin_clzll((ulli)x)
#define btrail(x) __builtin_ctzll((ulli)x)
const double PI = acos(-1);
template<class my>
using ind_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) (int)(x).size()

using lli   = long long;
using ulli  = unsigned long long int;
using pll   = pair<lli, lli>;
using ttt   = pair<lli, pll>;
using vttt  = vector<ttt>;
using vll   = vector<pll>;
using vl    = vector<lli>;
using vi    = vector<int>;
using vvi   = vector<vector<int>>;
using cd    = complex<long double>;

#ifdef tejasp
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.ff); __p(a.ss); cout << "} "; }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : ";__p(arg1); cout<<endl;
}
template<typename Arg1>
void __t(const char *name, Arg1 &&arg1)
{ cout<<name<<" : { "; for (auto p : arg1) __p(p); cout<<"}"<<endl; }
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	int bracket=0,i=0;
	for(; ;i++)
		if(names[i]==','&&bracket==0)
			break;
		else if(names[i]=='(')
			bracket++;
		else if(names[i]==')')
			bracket--;
	cout.write(names,i)<<" : ";
	__p(arg1);  cout<<"| ";
	__f(names+i+1,args...);
}
template<typename Arg1, typename Arg2>
void __f(const char *names, Arg1 arg1[], Arg2 &&arg2){
    int i=0;
	for(; ;i++) if(names[i]==',') break;
	cout.write(names,i)<<" : { ";
	fol(i,0,arg2) __p(arg1[i]);
	cout << "} "<<endl;
}
#define trace(...) { cout<<"Line:"<<__LINE__<<" | "; __f(#__VA_ARGS__, __VA_ARGS__); }
#define cotra(...) { cout<<"Line:"<<__LINE__<<" | "; __t(#__VA_ARGS__, __VA_ARGS__); }
#else
#define endl '\n'
#define trace(...)
#define cotra(...)
#endif

lli dp[102][100010];

void tejas_919(int kkkk)
{
    int n, W;
    cin>>n>>W;
    fol(i,1,n+1)
    {
        int w, v;
        cin>>w>>v;
        fol(j,0,W+1) dp[i][j]=dp[i-1][j];
        fol(j,0,W-w+1)
        {
            dp[i][j+w]=max(dp[i][j+w],dp[i-1][j]+v);
        }
    }
    cout<<*max_element(dp[n],dp[n]+W+1)<<endl;
}

int main()
{
    #ifndef tejasp
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #endif
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
}


Measured memory_bytes: 78464
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
b = [i for i in b if i>a]
b.sort()
b = b[::-1]
if h <= sum(b):
	num,i = 0,0
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h+a-1)//a + len(b)
print(num)

Measured memory_bytes: 22680
#include<iostream>
#include<utility>
#include<vector>
using namespace std;
int main(){
	int n,C;
	cin >> n >> C;
	vector<pair<int,int>> time[30];
	int tmax=0,smin=1e5;
	for(int i=0;i<n;i++){
		int s,t,c;
		cin >> s >> t >> c;
		time[c-1].push_back(make_pair(s,t));
	}
	int sum[200002]={};
	for(int i=0;i<C;i++){
		if(time[i].size()==0) continue; //vectorのsizeの返り値がsize_t(unsigned int)なので0の時-1するとまずい
		int box[200002]={};
		for(int j=0;j<time[i].size();j++){
			box[time[i][j].first*2-1]++;
			box[time[i][j].second*2]--;
		}
		for(int j=1;j<200002;j++) box[j]+=box[j-1];
		for(int j=0;j<200002;j++) if(box[j]>0) sum[j]++;
	}
	int ans=0;	
	for(int i=0;i<200002;i++){
		ans=max(ans,sum[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  string s;
  cin>>s;
  long long int count = 0;
  for(int i=0,j=n-1;i<n && j>=0 && i<j;i++,j--)
  {
    while(i<n && s[i]=='R')
    	i++;
    while(j>=0 && s[j]=='W')
      	j--;
    if(i<n && j>=0 && i<j)
    {
      swap(s[i],s[j]);
      count++;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main(){
  int x1,x2,x3,x4;
  int y1,y2,y3,y4;

  cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2 - x1;
  int dy = y2 - y1;

  x3 = x2 + (-1)*dy;
  y3 = y2 + dx;
  x4 = x3 + (-1)*dx;
  y4 = y3 + (-1)*dy;
  printf("%d %d %d %d",x3,y3,x4,y4);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    int cnt=0;
    For(i,0,n-1)if(s[i]!=s[i+1]) cnt++;
    ans=n-1-max(cnt-2*k,0);
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;

    int count = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count += 1;
        }
    }
    std::cout << count << std::endl;
    return 0;
}



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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

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

using namespace std;

void dfs(vector<vector<int> > &v,int x,int y) {
	v[x][y] = 0;
	REP(i, 8) {
		int nx = x + dx[i], ny = y+dy[i];
		if (nx >= 0 && ny >= 0 && nx < v.size() && ny < v[0].size() && v[nx][ny] == 1) {

			dfs(v, nx, ny);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int w, h, cnt = 0;
		cin >> w >> h;
		if (!w) break;
		vector<int> dm(w);
		vector<vector<int> > v(h, dm);
		REP(i, h)REP(j, w) cin >> v[i][j];
		REP(i, h)REP(j, w)
			if (v[i][j] == 1) {
				dfs(v, i, j);
				cnt++;
			}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll solve(ll n){
    ll ans=1;
    for(int i=2;i<=n;i++)ans*=i;
    return ans;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=n*n*n;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
long long int N;
int ans=10;
int check(long long int a,long long int b){
  int la=0,lb=0;
  while(a>0){
    a/=10;
    la++;
  }

  while(b>0){
    b/=10;
    lb++;
  }
    return max(la,lb);
}
int main(){
  scanf("%lld",&N);
  for(long long int i=1;i*i<=N;i++){
    if(N%i==0){
      long long int j=N/i;
      ans=min(check(i,j),ans);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> f(n + 1);
	vector<int> q;
	q.push_back(n);
	int ans = -1;
	while (q.size()) {
		++ans;
		vector<int> next;
		for (int x : q) {
			if (!x) {
				next.clear();
				break;
			}
			int y = x - 1;
			if (!f[y]) {
				f[y] = 1;
				next.push_back(y);
			}
			for (int a = 6; a <= x; a *= 6) {
				y = x - a;
				if (!f[y]) {
					f[y] = 1;
					next.push_back(y);
				}
			}
			for (int a = 9; a <= x; a *= 9) {
				y = x - a;
				if (!f[y]) {
					f[y] = 1;
					next.push_back(y);
				}
			}
		}
		q = next;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 912
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string v[4] = {"dream", "dreamer", "erase", "eraser"};
  for (int i = 0; i < 4; i++) {
    reverse(v[i].begin(), v[i].end());
  }
  bool f1 = false;
  int i = 0;
  while (true) {
    if (i >= s.size() || f1) {
      break;
    }
    bool f3 = true;
    for (int j = 0; j < 4; j++) {
      bool f2 = true;
      for (int k = 0; k < v[j].size(); k++) {
        if (v[j][k] != s[i + k]) {
          f2 = false;
        }
      }
      if (f2) {
        i += v[j].size();
        f3 = false;
      }
    }
    if (f3) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 512
// template {{{
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

using ld = long double;
using ll = long long;

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int N = 3050;
bool vis[N][2*N];
double mem[N][2*N], p[N];
int n;
double dp(int cur, int h)
{
    if (cur == n) return (h >= 0) ? 1.0 : 0.0;
    double &ret = mem[cur][h+n];
    if (vis[cur][h+n]) return ret;
    vis[cur][h+n] = true;
    return ret = p[cur] * dp(cur + 1, h + 1) + (1.0-p[cur]) * dp(cur + 1, h - 1);
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i];
    cout << fixed << setprecision(12) << dp(0, 0) << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


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

int main(){
    double p = 3.1415926535;
    int r;
    cin >> r;
    double ans = r*2.0*p;
    printf("%lf\n",ans);

}

Measured memory_bytes: 3764
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[int(input()) for i in range(m)]
for i in range(n):
    sumab=0
    for j in range(m):
        sumab=sumab+a[i][j]*b[j]
    print(sumab)



Measured memory_bytes: 6012
# Aizu Problem 00125: Day Count
#
import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    y1, m1, d1, y2, m2, d2 = [int(_) for _ in line.split()]
    if y1 == m1 == d1 == y2 == m2 == d2 == -1:
        break
    date1 = datetime.date(y1, m1, d1)
    date2 = datetime.date(y2, m2, d2)
    print((date2 - date1).days)

Measured memory_bytes: 8232
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector <int> G[100005];
bool ok;
int color[100005], cnt, edge, CA, CB;
void dfs(int u){
   cnt++;
   for(int i=0;i<G[u].size();i++){
      int v = G[u][i];
      if (color[v]){
         if (color[u] == color[v]) ok = 0;
         continue;
      }
      else{
         edge++;
         color[v] = 3 - color[u];
         dfs(v);
      }
   }
}
int main(){
   scanf("%d %d",&n,&m);
   while(m--){
      int x,y;
      scanf("%d %d",&x,&y);
      G[x].push_back(y);
      G[y].push_back(x);
   }
   long long ans = 1ll * n * n;
   long long totalv = 0, totale = 0;
   for(int i=1;i<=n;i++){
      if (color[i]) continue;
      if (G[i].empty()) continue;
      ok = 1;
      cnt = 0;
      edge = 0;
      color[i] = 1;
      dfs(i);
      if (ok) ans -= (1ll * cnt * cnt - 2);
      else ans -= (1ll * cnt * cnt - 1);
      if (ok) ans -= 2ll * (totalv * cnt - 2ll * CA - 1ll * CB);
      else ans -= 2ll * (totalv * cnt - CA - CB);
      totalv += cnt;
      if (ok) CA++;
      else CB++;
   }
   printf("%lld",ans);
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
using namespace std;
string toUpper(string s){
    for(int i=0;i<=s.size()-1;i++){
        s[i]=toupper(s[i]);
    }
    return s;
}

int main(void){
    string W,T;
    int count=0;
    cin>>W;
    W=toUpper(W);
    while(1){
        cin>>T;
        if(T=="END_OF_TEXT")break;
        T=toUpper(T);
        if(T==W)count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) {
        cin >> A[i];
        A[i]--;
    }

    vector<vector<int>> nex(62, vector<int>(N));
    rep(i,N) nex[0][i] = A[i];
    rep(i,61) {
        rep(j,N) {
            nex[i+1][j] = nex[i][nex[i][j]];
        }
    }

    int ans = 0;
    int cur = 0;
    while (K > 0) {
        if (K&1) {
            ans = nex[cur][ans];
        }
        K >>= 1;
        cur++;
    }

    cout << ans+1 << ln;
}

Measured memory_bytes: 53356
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	alist := make([]int, n)

	for i := 0; i < n; i++ {
		alist[i] = nextInt()
	}
	sort.Ints(alist)

	dif := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			dif += alist[i]
		} else {
			dif -= alist[i]
		}
	}

	fmt.Println(abs(dif))

}
func abs(a int) int {
	return int(math.Abs(float64(a)))
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll x;
		scanf("%lld",&x);
		//int shuru = 100;
		ll shuru = 100;
		int cnt = 0;
		while (shuru < x)
		{
			shuru+=shuru/100;
			cnt++;
			//cerr << imie(cnt);
		}
		printf("%d",cnt);
		
		return 0;  
}  

/*
               
 

*/


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

using namespace std;
typedef long long ll;

const int N = 3010;
int n;
ll a[N], pref[N];
ll dp[N][N][2];
bool vis[N][N][2];

ll solve(int l, int r, int t)
{
	if (l > r)
		return 0;
	ll &ret = dp[l][r][t];
	if (vis[l][r][t])
		return ret;
	vis[l][r][t] = true;
	if (t == 0)
	{
		ll val = max(a[l] + solve(l + 1, r, 1), a[r] + solve(l, r - 1, 1));
		ret = val;
	}
	else
	{
		ll val = min(-a[l] + solve(l + 1, r, 0), -a[r] + solve(l, r - 1, 0));
		ret = val;
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	memset(dp, -1, sizeof(dp));
	memset(vis, false, sizeof(vis));
	ll ans = solve(1, n, 0);
	cout << ans;

	return 0;
}

Measured memory_bytes: 159744
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
int a[MAXN][MAXN];
int upto[MAXN];
bool sports[MAXN];
int n, m;
int cnt[MAXN];
void bruteforce(){
	int res = n;
	for(int msk = 1; msk < (1 << m); msk++){
		vector<int> kaunt(m + 1);
		for(int i = 1; i <= m; i++) kaunt[i] = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				int val = a[i][j] - 1;
				if(msk & (1 << val)) {
					kaunt[val + 1]++;
					break;
				}
			}
		}
		int tmpmx = 0;
		for(int i = 1; i <= m; i++) tmpmx = max(tmpmx, kaunt[i]);
		res = min(res, tmpmx);
	}
	printf("%d\n", res);
}
bool check(int v){
	//printf("Checking %d\n", v);
	for(int i = 1; i <= m; i++){
		sports[i] = true;
		cnt[i] = 0;
	}
	for(int i = 1; i <= n; i++) upto[i] = 1;
	bool start = true;
	while(true){
		bool fails = false;
		for(int i = 1; i <= n; i++){
			bool moved = false;
			while(upto[i] <= m && !sports[a[i][upto[i]]]) {moved = true; upto[i]++;}
			if(upto[i] > m) return false;
			if(moved || start) cnt[a[i][upto[i]]]++;
		}
		//for(int i = 1; i <= m; i++) if(sports[i]) printf("%d : %d\n", i, cnt[i]);
		//printf("\n");
		for(int i = 1; i <= m; i++) if(sports[i] && cnt[i] > v){
			sports[i] = false;
			fails = true;
		}
		start = false;
		if(!fails) return true;
	}
}
int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			scanf("%d", &a[i][j]);
		}
	int ans = n;
	int lo = 1, hi = n - 1;
	while(lo <= hi){
		int md = (lo + hi) / 2;
		if(check(md)) {ans = md; hi = md - 1;}
		else lo = md + 1;
	}
	printf("%d\n", ans);
	//bruteforce();
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int m,f,r,i;
	for(i=0;i<50;i++){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		if(m==-1||f==-1){
			cout<<"F"<<endl;
		}
		else if(r>=50){
			cout<<"C"<<endl;
		}
		else if((m+f)>=80){
			cout<<"A"<<endl;
		}
		else if((m+f)>=65&&(m+f)<80){
			cout<<"B"<<endl;
		}
		else if((m+f)>=50&&(m+f)<65){
			cout<<"C"<<endl;
		}
		else if((m+f)>=30&&(m+f)<50){
			cout<<"D"<<endl;
		}
		else if((m+f)<=30){
			cout<<"F"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
N = int(input())
A = list(map(int, input().split()))
swap = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if i != minj:
        swap += 1
print(" ".join(list(map(str, A))))
print(swap)

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

main() {
	int N, Y;
	cin >> N >> Y;
	int a = 0, b = 0, c =0;
	bool flag = false;
	for (int i = 0; i <= N; ++i) {
		for(int j = 0; j <= N - i; ++j) {
			int total = 10000 * i + 5000 * j + 1000 * (N - i -j);
			if (Y ==  total ) {
				a = i;
				b = j;
				c = N - i - j;
				flag = true;
			}
		}
	}
	if (flag ==true) {
		cout << a << " " << b << " " << c << endl;
	} else {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,ans;
string s;
bool can[101];
bool pos[11];
bool pin[1001];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;
    cin >> s;

    rep(i,0,n)
    {
        ll d = s[i]-'0';

        rep(j,0,100)
        {
            if(can[j])
                pin[j*10+d]=true;
        }

        rep(j,0,10)
        {
            if(pos[j])
                can[j*10+d]=true;
        }

        pos[d] = true;
    }

    rep(i,0,1000)
        ans+=pin[i];

    cout << ans;

    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
template <class T>
void print(T& x){cout << x << '\n';}

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> c){

  if((c[0][0]-c[0][1] == c[1][0]-c[1][1] && c[1][0]-c[1][1] == c[2][0]-c[2][1])&&
     (c[0][1]-c[0][2] == c[1][1]-c[1][2] && c[1][1]-c[1][2] == c[2][1]-c[2][2])&&
     (c[0][2]-c[0][1] == c[1][2]-c[1][1] && c[1][2]-c[1][1] == c[2][2]-c[2][1])&&
     (c[0][0]-c[1][0] == c[0][1]-c[1][1] && c[0][1]-c[1][1] == c[0][1]-c[1][1])&&
     (c[1][0]-c[2][0] == c[1][1]-c[2][1] && c[1][1]-c[2][1] == c[1][1]-c[2][1])&&
     (c[2][0]-c[0][0] == c[2][1]-c[0][1] && c[2][1]-c[0][1] == c[2][1]-c[0][1])){
    print(YES);
  }else{
    print(NO);
  }

}

int main(){
  std::vector<std::vector<long long>> c(3, std::vector<long long>(3));
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      scanf("%lld",&c[i][j]);
    }
  }
  solve(std::move(c));
  return 0;
}


Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int N;
	double sum = 0;
	double x[20];
	char u[20][20];

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%lf %s", &x[i], u[i]);

	}

	for (int i = 0; i < N; i++) {
		if (u[i][0] == 'J')sum += x[i];
		if (u[i][0] == 'B')sum +=(double) x[i] * 380000;
	}

	printf("%.7f", sum);

	return(0);
}

Measured memory_bytes: 256
n1 = n2 = 0
for _ in range(int(input())):
    a, b = input().split()
    if a == b:
        n1 += 1
        n2 += 1
        continue
    if sorted((a,b))[0] == b:
        n1 += 3
    else:
        n2 += 3

print(n1, n2)

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		cin >>a[i];
	int max1=0,cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]>=a[i+1]){
			cnt++;
			if(cnt>max1) 
				max1=cnt;
		} 
		else{	
			cnt=0;
		}	
	}
	cout<<max1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

struct CHT{
private:
  deque<pair<ll,ll>> fx;
  deque<int> x;
public:
  void add(ll A,ll B){
    while(1){
      if(fx.empty()){
        fx.push_back(make_pair(A,B));
        x.push_back(0);
        break;
      }
      ll a=fx.back().first;
      ll b=fx.back().second;
      ll c=x.back();
      if(a*c+b>=A*c+B){
        fx.pop_back();
        x.pop_back();
        continue;
      }
      if(a*1e6+b<=A*1e6+B)  break;
      int ng=c;
      int ok=1e6;
      while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(a*mid+b>=A*mid+B)  ok=mid;
        else  ng=mid;
      }
      fx.push_back(make_pair(A,B));
      x.push_back(ok);
      break;
    }
  }

  ll getmin(ll X){
    int ng=x.size();
    int ok=0;
    while(abs(ok-ng)>1){
      int mid=(ok+ng)/2;
      if(x.at(mid)<=X)  ok=mid;
      else  ng=mid;
    }
    ll a=fx.at(ok).first;
    ll b=fx.at(ok).second;
    return a*X+b;
  }
};

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  ll C;
  cin >> N >> C;
  vector<ll> h(N);
  for(int i=0;i<N;i++)  cin >> h.at(i);

  CHT cht;
  vector<ll> dp(N,1e18);
  dp.at(0)=0;
  cht.add(-2*h.at(0),dp.at(0)+h.at(0)*h.at(0));
  for(int i=1;i<N;i++){
    ll mi=cht.getmin(h.at(i));
    dp.at(i)=mi+h.at(i)*h.at(i)+C;
    cht.add(-2*h.at(i),dp.at(i)+h.at(i)*h.at(i));
  }
  cout << dp.at(N-1) << endl;

  return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

// #include "competitive_helper.cpp"

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int x, y;

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    cin >> x >> y;
    cout << 6 - x - y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(j, m) cin >> b[j];
  int cnt = 0;
  rep(i, n) {
    int sum = 0;
    rep(j, m) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    sum += c;
    if(sum > 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<int,int> pii;

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

const int INF = (int)1e9;

inline vector<pii> func(){
	int w, h, x, y;
	scanf("%d%d%d%d", &w, &h, &x, &y);
	
	vector<vector<int> > L(w + 2, vector<int>(h + 2, -1));
	vector<int> Ls;
	Ls.reserve(w * h + 2);
	Ls.push_back(0);
	Ls.push_back(INF);
	
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		scanf("%d", &L[j][i]);
		Ls.push_back(L[j][i]);
	}
	
	sort(Ls.begin(), Ls.end());
	Ls.erase(unique(Ls.begin(), Ls.end()), Ls.end());
	
	vector<pii> c(Ls.size());
	for(int i = 0; i < Ls.size(); ++i){
		c[i].second = Ls[i];
	}

	priority_queue<pii,vector<pii>,greater<pii> > pq;
	pq.push( pii(1, x << 16 | y) );
	L[x][y] = -1;

	while( !pq.empty() ){
		queue<int> q;
		q.push(pq.top().second);
		int u = pq.top().first;
		pq.pop();

		int k = lower_bound(Ls.begin(), Ls.end(), u) - Ls.begin();
		++c[k].first;

		while( !q.empty() ){
			for(int i = 0; i < 4; ++i){
				x = (q.front() >> 16) + dx[i];
				y = (q.front() & 0xffff) + dy[i];

				if( L[x][y] > 0 ){
					if( L[x][y] <= u ){
						L[x][y] = -1;
						++c[k].first;
						q.push(x << 16 | y);
					}
					else{
						pq.push( pii(L[x][y], x << 16 | y) );
						L[x][y] = -1;
					}
				}
			}
			q.pop();
		}
	}
	
	for(int i = 2; i < c.size(); ++i){
		c[i].first += c[i - 1].first;
	}
	c.back().first = INF;
	
	return c;
}

int main(){
	int R;
	while( scanf("%d", &R), R != 0 ){
		vector<pii> t1 = func();
		vector<pii> t2 = func();

		int ans = INF;
		for(int i = 0; i + 1 < t1.size(); ++i){
			int a = t1[i].second;
			pii p = pii(R - t1[i].first, -1);
			int b = lower_bound(t2.begin(), t2.end(), p)->second;
			ans = min(ans, a + b);
		}
		
		printf("%d\n", ans);
	}
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    long long v[N+1];
    for(int i = 1; i <= N; i++){
        cin >> v[i];
    }
    long long ans = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 0; j <= min(i, N); j++){
            for(int k = 0; k <= min(i-j, N-j); k++){
                int trash_cnt = min(j+k, i-j-k);
                long long tmp = 0;
                priority_queue<long long> pq;
                for(int m = 1; m <= j; m++){
                    tmp += v[m];
                    pq.push(-v[m]);
                }
                for(int m = 1; m <= k; m++){
                    tmp += v[N+1-m];
                    pq.push(-v[N+1-m]);
                }
                for(int m = 0; m < trash_cnt; m++){
                    if(pq.empty()) break;
                    long long w = pq.top();
                    pq.pop();
                    if(w < 0) break;
                    tmp += w;
                }
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    L = []
    for i in range(n):
        p,d1,d2  = map(int,input().split())
        L.append((p,d1+d2))

    L.sort(key = lambda x :-x[1])
    print(L[0][0],L[0][1])



Measured memory_bytes: 7300
#include <stdint.h>

#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, M, S;
  cin >> N >> M >> S;
  vector<vector<tuple<int, int64_t, int64_t>>> G(N);
  rep(i, M) {
    int u, v;
    int64_t a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    G[u].emplace_back(v, a, b);
    G[v].emplace_back(u, a, b);
  }
  vector<pair<int64_t, int64_t>> C(N);
  rep(i, N) {
    int64_t c, d;
    cin >> c >> d;
    C[i] = {c, d};
  }

  vector<vector<int64_t>> T(N, vector<int64_t>(50 * N, INT64_MAX));
  S = min(S, 50 * N - 1);
  T[0][S] = 0;

  priority_queue<tuple<int64_t, int64_t, int>,
                 vector<tuple<int64_t, int64_t, int>>,
                 greater<tuple<int64_t, int64_t, int>>>
      que;
  que.emplace(0, S, 0);
  while (!que.empty()) {
    int64_t time, money;
    int v;
    tie(time, money, v) = que.top();
    que.pop();
    // cout << "v=" << v << " time=" << time << " money=" << money << endl;
    if (T[v][money] != time) continue;

    int64_t money2 = money;
    int64_t time2 = time;
    while (true) {
      money2 += C[v].first;
      time2 += C[v].second;
      if (money2 >= 50 * N) break;
      if (T[v][money2] <= time2) continue;
      T[v][money2] = time2;
      que.emplace(time2, money2, v);
    }

    for (int i = 0; i < (int)G[v].size(); ++i) {
      int nv;
      int64_t nmoney, ntime;
      tie(nv, nmoney, ntime) = G[v][i];
      if (money < nmoney) continue;

      int64_t money3 = money - nmoney;
      int64_t time3 = time + ntime;
      if (T[nv][money3] <= time3) continue;
      T[nv][money3] = time3;
      que.emplace(time3, money3, nv);
    }
  }

  for (int t = 1; t < N; ++t) {
    int64_t answer = INT64_MAX;
    for (int i = 0; i < 50 * N; ++i) {
      answer = min(answer, T[t][i]);
    }
    cout << answer << endl;
  }
  return 0;
}


Measured memory_bytes: 53464
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<pair<int, int>> vec(M);
  REP(i, M) cin >> vec[i].first >> vec[i].second;

  sort(ALL(A));
  sort(ALL(vec), [](pair<int, int> const & l, pair<int, int> const & r){
      return l.second > r.second;
      });


  int i = 0;
  bool flag = true;
  REP(now, M){
    if(!flag) break;
    for(int j = 0; j < vec[now].first && i < N; j++){
      if(A[i] < vec[now].second){
        A[i++] = vec[now].second;
      }else flag = false;
    }
  }

  int ans = 0;
  REP(i, N) ans += A[i];

  cout << ans << "\n";


  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

int dfs(int cur, int tmp, vector<vector<int> > &G, int d, vector<bool> &used, int u, int v){

    used[cur] = true;
    int ret = 0;
    for(auto nxt : G[cur]){
        if(!used[nxt]){
            if(cur == u && nxt == v) continue;
            if(cur == v && nxt == u) continue;
            ret += dfs(nxt, tmp + 1, G, d, used, u, v);
        }
    }

    if(d < tmp) ret++;
    return ret;
}

signed main(){
    
    int n, k; cin >> n >> k;
    vector<vector<int> > G(n + 1);
    for(int i = 0; i < n - 1; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = INF;
    if(k % 2 == 0){
        for(int i = 0; i < n; i++){
            vector<bool> used(n, false);
            ans = min(ans, dfs(i, 0, G, k / 2, used, -1, -1));            
        }    
    }else{
        for(int i = 0; i < n; i++){
            for(auto j : G[i]){
                G[n].push_back(i);
                G[n].push_back(j);
                vector<bool> used(n, false);            
                ans = min(ans, dfs(n, 0, G, (k + 1) / 2, used, i, j));
                G[n].erase(G[n].begin(), G[n].end());
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640