akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  string s;
  cin >> n;
  cin >> s;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;
  } else {
    for(int i=0; i<n/2; i++){
      if(s[i]!=s[n/2+i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	ll n;
	cin>>n;
	P p[114514];
	for(int i=0;i<n;i++){
		cin>>p[i].first;
		p[i].second=i;
	}
	sort(p,p+n);
	ll ans=0;
	for(int i=0;i<n;i++)if(i%2!=p[i].second%2)ans++;
	ans/=2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		
		int num = Integer.valueOf(line);
		
		System.out.println(num * num * num);
	}

}

Measured memory_bytes: 24200
#include <bits/stdc++.h>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;

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

  vector<int> a_i(N);
  for (int i = 0; i < N; i++) {
    cin >> a_i.at(i);
  }
  std::sort(a_i.begin(),a_i.end(),std::greater<int>());
  int Alice=0;
  int Bob = 0;
  for(int i=0;i<a_i.size();i++){
  	  if(i%2==0){
  	  	Alice +=a_i[i];
  	  }else{
  	  	Bob+=a_i[i];
  	  }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
import math

d, g = map(int, input().split())

P = list()
C = list()

for _ in range(d):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

check = float('inf')
for i in range(2 ** d):
    ans = 0
    cnt = 0
    for j in range(d):
        # flagがたっていたら
        if (i >> j) & 1:
            ans += P[j] * (j + 1) * 100 + C[j]
            cnt += P[j]
            if ans >= g:
                check = min(check, cnt)
                break
        else:
            rest = j
    extra = P[rest] * (rest + 1) * 100
    if ans < g < (ans + extra):
        cnt += math.ceil(((g - ans) / ((rest + 1) * 100)))
        check = min(check, cnt)

print(check)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n;
	int s[100];
	bool f[100];
	bool flag=true;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		ans+=s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++)
	{
		if(s[i]%10==0)
		{
			f[i]=true;
		}else{
			f[i]=false;
			flag=false;
		}
	}
	if(flag==true)
	{
		ans=0;
	}else{
		for(int i=0;ans%10==0;i++)
		{
			if(f[i]==false)
			{
				ans -= s[i];
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main() {

	int n;
	cin >> n;

	int c[500] = { 0 };
	int s[500] = { 0 };
	int f[500] = { 0 };
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	int t;
	int f1;
	for (int i = 0; i < n-1; i++) {
		t = s[i];
		t += c[i];

		for (int j = i; j < n - 1; j++) {
			if (0 == f[j + 1]) break;

			f1 = s[j + 1];
			while (t > f1) {
				f1 += f[j + 1];
			}
			t += (f1 - t);

			t += c[j + 1];
		}

		cout << t << endl;
	}
	cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = []
M = 0
j = -1
for i in range(n):
    a = int(input())
    A.append(a)
    if a > M:
        M = a
        j = i
A.sort()
for i in range(n):
    if i == j:
        print(A[-2])
        continue
    print(M)

Measured memory_bytes: 12532
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
a = 0
if N <=3:
	a += 100000*(4-N)
if M <=3:
	a += 100000*(4-M)
if N==1 and M==1:
	a += 400000
print(a)

Measured memory_bytes: 4464
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    int64 pre = a[0];
    int64 ans = 0;
    for (int i=0; i<n; i++) {
        ans += max(0LL, pre - a[i]);
        pre = max(pre, a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4368
K, A, B = map(int, input().split())
now = 1

if A <= B - 3:
   if A - now + 2 <= K:

        K -= (A - now + 2)
        now = B

        if K % 2 == 0:
            now += (K//2) * B - (K//2) * A
        else:
            now += ((K-1) // 2) * B + 1 -(K//2) * A

   else:
       now += K
       #A, Bの動作に到達するまえにKが尽きてしまうので+= 1


else:
    now += K

    #そもそもA、Bの動作をやるだけ損なのでひたすら+=1

print(now)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
#define en "\n"
const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen("max.in","r",stdin);
   freopen("max.out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTmx = (int)1e9;
const ld EPS = (ld)1e-9;
const int N = 3e5 + 100;
int main()
{
    //file();
    boos();
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
    	cout << "Yes";
	}else {
		cout << "No";
	}
}

Measured memory_bytes: 256
n = int(input())
flower = list(map(int, input().split()))
water = 0
empty = [0] * len(flower)
left, right = 0, 0
flag = 0
while(flower != empty):
  for i in range(len(flower)):
    if (flower[i]):
      flower[i] -= 1
      if (flag == 0):
        water += 1
        flag = 1
    else:
      flag = 0
  if (flower[0]):
    water += 1
    flag = 1
print(water)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 ans = 0;
  for (i32 i = 0; i < m; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    ans += a > m ? 1 : 0;
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}



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

ll n, x;

ll solve(ll a, ll b){
    if (a > b) swap(a,b);
    ll ans = 0;
    ans = ((b / a - 1) * 2 + 1) * a;
    ll c = b % a;
    if (c == 0) return ans;
    return ans + a + solve(c, a);
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> x;
    cout << n + solve(x,n-x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, min, n;
  cin >> N;
  min = pow(2, 30);
  n = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    n = 0;
    while (A % 2 == 0) {
      n++;
      A /= 2;
    }
    if (min > n)
      min = n;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
n = input()
pt = px = py = 0
for _ in xrange(n):
    t, x, y = map(int, raw_input().split())
    if abs(x-px)+abs(y-py) > t-pt:
        print "No"
        break
    if (x+y-px-py) % 2 ^ (t-pt) % 2 :
        print "No"
        break
    pt = t
    px = x
    py = y
else:
    print "Yes"


Measured memory_bytes: 2568
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
  int a[2][N];
  for (int i=0;i<2;i++){
      for(int j=0;j<N;j++){
          scanf("%d",&a[i][j]);
      }
  }
  int max=0;
  int count=0;
  for(int index=0;index<N;index++){
      for(int i=0;i<=index;i++){
          count += a[0][i];
      }
      for(int i=index;i<N;i++){
          count+=a[1][i];
      }

  if(max<count){
      max =count;
  }
  count=0;
  }
  printf("%d",max);
}

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

int main()
{
  int n,m;cin>>n>>m;
  vector<vector<int>>s(m);
  for(int i=0;i<m;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int a;cin>>a;a--;
      s[i].push_back(a);
    }
  }
  vector<int>p(m);
  for(int i=0;i<m;i++)cin>>p[i];

  long long res=0;
  for(int bit=0;bit<(1<<n);bit++){
    bool ok=true;
    for(int i=0;i<m;i++){
      int con=0;
      for(auto v:s[i]){
        if(bit&(1<<v))con++;
      }
      if(con%2!=p[i])ok=false;
    }
    if(ok)res++;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main(){
    int n,s;
    cin >> n>> s;
    vector<int> hoge;
    REP(i,n){
        int a;
        cin >> a;
        hoge.push_back(a);
    }
    int length = n+1;
    int now_sum = 0;
    int left = 0;
    for(int i = 0;i < n;++i){
        now_sum += hoge[i];
        while(now_sum - hoge[left] >= s){
            now_sum -= hoge[left];
            left++;
        }
        if(now_sum >= s){
            length = min(length,i - left + 1);
        }
    }
    if(length == n+1){
        cout << 0 << endl;
    }else cout << length << endl;
    return 0;
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
#define N 200020
int a[N], n, k;
bool check(int x){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cnt += (a[i] / x);
        if(a[i] % x == 0) --cnt;
    }
    if(cnt <= k) return true;
    else return false;
}
int main(){
    cin>>n>>k;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int l = 1, r = 1000000000, ans = 0;
    while(l <= r){
        int mid = (l + r) >> 1;
        // cout<<mid<<endl;
        if(check(mid)){
            ans = mid; r = mid - 1;
        }
        else l = mid + 1;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int A, B, C, D, L, R;
    cin >> A >> B >> C >> D;

    L = A + B;
    R = C + D;

    if (L > R)
    {
        cout << "Left" << endl;
    }
    else if (L < R)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int a, b;
	cin >> a >> b;
	if(a + b == 15){ puts("+"); }
	else if(a * b == 15){ puts("*"); }
	else{ puts("x"); }
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

dp = [[0 for i in range(3)] for j in range(n)]

dp[0] = list(map(int, input().split()))

for i in range(1, n):
    a, b, c = map(int, input().split())
    dp[i][0] = max(a + dp[i - 1][1], a + dp[i - 1][2])
    dp[i][1] = max(b + dp[i - 1][0], b + dp[i - 1][2])
    dp[i][2] = max(c + dp[i - 1][0], c + dp[i - 1][1])
print(max(dp[-1]))


Measured memory_bytes: 62172
#include<stdio.h>

int main(void) {

	int i;
	int flag[31];
	int n;
	for(i=0; i<31; i++) {
		flag[i] = 0;
	}

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

	for(i=1; i<31; i++) {
		if(flag[i] == 0) {
			printf("%d\n",i);
		}
	}



	return 0;
}

Measured memory_bytes: 596
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

MAX = 2000
check = [False] * MAX


def recursive(ind, tmp_sum):
  global n
  if ind == n:
    check[tmp_sum] = True
    return

  recursive(ind+1, tmp_sum)
  if tmp_sum + A[ind] <= MAX:
    recursive(ind+1, tmp_sum + A[ind])

recursive(0,0)

for num in m:
  if check[num]:
    print('yes')
  else:
    print('no')


Measured memory_bytes: 5632
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;




int main(){
    ll n,h;
    ll mi=10000000000;
    cin>>n>>h;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    vector<ll> bb(n);
    sort(a.rbegin(),a.rend());
        sort(b.rbegin(),b.rend());
    ll ans=0;
    ll nokori=h;
    for(int i=0;i<n;i++){
        if(b[i]>a[0]){
            ans++;
            nokori-=b[i];
            if(nokori<=0){
                cout<<ans<<endl;
              
                return 0;
            }
        }
    }
    
    ans+=nokori/a[0];
    if(nokori%a[0]!=0)ans++;
    cout<<ans<<endl;
    
    
    
    
    

return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<vvvll> vvvvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
 
#define PI 3.141592653589793
#define MOD 1000000007
 
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int main()
{
	IOS;
	vll a(4);
	for(ll i=0;i<4;i++)
	{
		cin>>a[i];
	}
	ll n;
	cin>>n;
	vll v(4,0);
	ll st=8;
	ll min1=LLONG_MAX;
	ll ans=0;
	for(ll i=0;i<4;i++)
	{
		v[i]=a[i]*st;
		st/=2;
		min1=min(min1,v[i]);
	}
	ll st2=n/2;
	ans+=st2*min1;
	n-=st2*2;
	min1=LLONG_MAX;
	for(ll i=0;i<3;i++)
	{
		v[i]/=2;
		min1=min(min1,v[i]);
	}
	ans+=min1*n;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int sum = 0;
    int div = N;
    while (div > 0) {
        sum += div % 10;
        div = div/10;    
    }
    if (N % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    string s;
    int w;
    cin >> s >> w;
    for (int i = 0; i < s.size(); i += w) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
 
int main(){
    int n;
    double x1,x2,x3,y1,y2,y3,ox,oy,r;
    scanf("%d",&n);
 
    for(int i=0;i<n;i++){
        scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
        ox=((y2-y1)*((y3*y3-y1*y1)+(x3*x3-x1*x1))-(y3-y1)*((y2*y2-y1*y1)+(x2*x2-x1*x1)))/
                (2*((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)));
        if(y2 != y1){
            oy=(2*(x1-x2)*ox+(y2*y2-y1*y1)+(x2*x2-x1*x1))/(2*(y2-y1));
        }else{
            oy=(2*(x1-x3)*ox+(y3*y3-y1*y1)+(x3*x3-x1*x1))/(2*(y3-y1));
        }
 
        r = sqrt((ox-x1)*(ox-x1)+(oy-y1)*(oy-y1));
        printf("%.3lf %.3lf %.3lf\n",ox,oy,r);
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> dp(n+1, n);
  dp.at(0) = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 1; i+j <= n; j*=6) {
      dp[i + j] = min(dp[i+j], dp[i] + 1);
    }
    for (int j = 1; i+j <= n; j*=9) {
      dp[i + j] = min(dp[i+j], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
}

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

public class Main {

	void submit() {
		int n = nextInt() - 1;
		int a = nextInt();
		int b = nextInt();
		long c = nextInt();
		long d = nextInt();
		
		long diff = b - a;
		
		for (int pos = 0; pos <= n; pos++) {
			int neg = n - pos;
			
			
			long low = c * pos - d * neg;
			long high = d * pos - c * neg;
			
			if (low <= diff && diff <= high) {
				out.println("YES");
				return;
			}
		}
		
		out.println("NO");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21588
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=998244353
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b,c,d=map(int,input().split())
dp=[[0]*(d+1) for i in range(c+1)]
dp[a][b]=1
# for i in range(a+1,c+1):
#     dp[i][b]=dp[i-1][b]*b
# for j in range(b+1,d+1):
#     dp[a][j]=dp[a][j-1]*a
# print(dp)

for i in range(a,c+1):
    for j in range(b,d+1):
        if i==a and j==b:
            continue
        dp[i][j]=dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1)
        dp[i][j]%=mod
# print(dp)
print(dp[-1][-1])

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

long array_1[10],array_2[10];
long n;

int main() {
	cin>>n;
	long i;
	for(i=1;i<=n;++i)
		cin>>array_1[i];
	for(i=1;i<=n;++i)
		cin>>array_2[i];
	
	bool p_large=0,eqUal=1;
	for(i=1;i<=n;++i) {
		if(array_1[i]>array_2[i]) {eqUal=0;p_large=1;break;}
		if(array_2[i]>array_1[i]) {eqUal=0;break;}
	}
	if(eqUal) {cout<<"0"<<endl;return 0;}
	long ans;
	if(p_large) {
		ans=0;
		eqUal=1;
		for(i=1;i<=n;++i)
			if(array_1[i]!=array_2[i]) {
				eqUal=0;
				break;
			}
		while(!eqUal) {
			eqUal=1;
			++ans;
			next_permutation(array_2+1,array_2+n+1);
			for(i=1;i<=n;++i)
				if(array_1[i]!=array_2[i]) {
					eqUal=0;
					break;
				}
		}
	}
	else {
		ans=0;
		eqUal=1;
		for(i=1;i<=n;++i)
			if(array_1[i]!=array_2[i]) {
				eqUal=0;
				break;
			}
		while(!eqUal) {
			eqUal=1;
			++ans;
			next_permutation(array_1+1,array_1+n+1);
			for(i=1;i<=n;++i)
				if(array_1[i]!=array_2[i]) {
					eqUal=0;
					break;
				}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
   
 
   cin >> n;
  
   //cout << n << endl;
  
int sum = 0;
for(int i = 1;i<=n;i++){
  
  int ans = 0;
  
  if(i%2!=0){
    
    for(int j = 1;j<=n;j++){
      
      if(i%j==0){
        
        ans = ans + 1;
      }
      
    }
    
  }
  
  if(ans==8){
    
    sum = sum+1;
  }
     

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

Measured memory_bytes: 256
using System;

namespace Atcoder_0403
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int _syu = int.Parse(input[0]);
            int _count = int.Parse(input[1]);

            int[] _houses = new int[_count];

            var input2 = Console.ReadLine().Split(' ');
            for(int i = 0; i < _count; i++)
            {
                _houses[i] = int.Parse(input2[i]);
            }

            int _longest = _houses[0]-0;//最も長い区間　これを_syuから引けば答えが出る

            //最も長い区間を探す
            for (int i = 0; i < _count-1; i++)
            {
                int targetLength=_houses[i + 1] - _houses[i];
                if (targetLength > _longest)
                {
                    _longest = targetLength;
                }
            }
            //最後から最初への区間は計算が違う
            int lastLength = _syu - _houses[_count - 1] + _houses[0];
            if (lastLength > _longest)
            {
                _longest = lastLength;
            }
            Console.WriteLine(_syu - _longest);
        }
    }
}


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

int main(){
  char a[100][100],b[102][102];
  int h,w;
  cin >> h >>w;
  
  for(int i=0 ; i<h; i++){
    cin >> a[i];
  }
  for(int i=0; i<h+2;i++){
    for(int j=0;j<w+2;j++){
      b[i][j] ='#';
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      b[i+1][j+1] = a[i][j];
    }
  }
  for(int i=0; i<h+2;i++){
    for(int j=0;j<w+2;j++){
      cout << b[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
K = int(input())

done = set()
i = 0
x = 7
flag = True
while x % K != 0 :
  if not x in done :
    done.add(x)
  else :
    flag = False
    break
  x = (x % K) * 10 + 7
  i += 1
    
if flag :
  print(i + 1)
else :
  print(-1)

Measured memory_bytes: 156576
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int a;
  string s; 
  cin >> a >> s;
  if(a>=3200)
    cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
int k,n;
cin>>k>>n;
int a[n],b[n];
for(int i=0;i<n;i++){
  cin>>a[i];
}
for(int i=0;i<n-1;i++)
b[i]=a[i+1]-a[i];
b[n-1]=k-a[n-1]+a[0];
sort(b,b+n);
int sum=0;
for(int i=0;i<n-1;i++)
sum=sum+b[i];
cout<<sum;

  return 0;}




  


Measured memory_bytes: 1792
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 100000

int costs[MAXN];
vector<vector<int>>g(MAXN);

int dfs(int node){
  if(costs[node]>0)return costs[node];

  int cc = 0;
  for(auto c:g[node]){
    costs[node] = dfs(c)+1;
    cc = max(cc, costs[node]);
  }
  return costs[node] = cc;
}

int main(){
  int n,m;cin>>n>>m;
  vector<int>x(m),y(m);
  rep(i, m){
    cin>>x[i]>>y[i];
    x[i]--,y[i]--;
    g[x[i]].push_back(y[i]);
  }

//  rep(i, n)costs[i]=-1;

  int result = 0;
  rep(i, n)result = max(result, dfs(i));

  cout<<result<<endl;

//  rep(i, n)cout<<costs[i]<<' ';

  return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int cnt[30][100010] = {};

int main() {

    int n, C; cin >> n >> C;

    // いもす法
    for (int i = 0; i < n; ++i) {
        int s, t, c; cin >> s >> t >> c;
        --s;
        --c;

        cnt[c][s]++;
        cnt[c][t]--;
    }

    for (int i = 0; i < C; ++i) {
        for (int j = 1; j < 100010; ++j) {
            cnt[i][j] += cnt[i][j - 1]; // 復元
        }
    }

    for (int i = 0; i < C; ++i) {
        for (int j = 0; j < 100010; ++j) {
            if (cnt[i][j] == 2) { // 連続する部分は2になる
                cnt[i][j] = 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 100010; ++i) {
        int sum = 0;
        for (int j = 0; j < C; ++j) {
            if (cnt[j][i] == 1) sum++;
        }

        ans = max(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 15248
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main() {
  int e;
  while (1) {
	cin >> e;
	if (e == 0)return 0;
	int x, y, z;
	int m=INF;
	for (z = 0; z*z*z <= e; z++) {
	  for (y = 0; y*y <= e - z*z*z; y++) {
		x = e - z*z*z - y*y;
		if (x + y + z < m)m = x + y + z;
	  }
	}
	cout << m << endl;
  }
}

Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
	int i,j,n,x=-1000,y=1000000,z[100],a,b,c=0,d=2100000000;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&z[i]);
		if(x<z[i]){
			x=z[i];
		}
		if(y>z[i]){
			y=z[i];
		}
	}
	for(i=y;i<=x;i++){
		c=0;
		for(j=1;j<=n;j++){
			c+=(i-z[j])*(i-z[j]);
		}
		if(d>c){
			d=c;
		}
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

S = sorted(X)

med_left = S[N//2 - 1]
med_right = S[N//2]

for i in range(N):
  if X[i] <= med_left:
    print(med_right)
  else:
    print(med_left)

Measured memory_bytes: 93652
# coding: utf-8
# Your code here!

n=int(input())
x=input()

ones=x.count("1")

a=ones+1
b=ones-1

xda=0
xdb=0
for i in range(n):
    if x[-1-i]=="1":
        xda+=pow(2,i,a)
        xda%=a
        if b==0:
            continue
        xdb+=pow(2,i,b)
        xdb%=b

xds=[-1]*n

for i in range(n):
    if x[-1-i]=="0":
        xds[-1-i]=(xda+pow(2,i,a))%a
    else:
        if b==0:
            continue
        xds[-1-i]=(xdb-pow(2,i,b))%b

    
def popcount(x):
    return bin(x).count("1")
    
def solve(x):
    if x<0:
        return -1
    if x==0:
        return 0
    cnt=0
    while x>0:
        cnt+=1
        x=x%popcount(x)
    return cnt

for xd in xds:
    print(1+solve(xd))



Measured memory_bytes: 85724
#include<iostream>

int main(){

    size_t a, b;
    size_t cnt = 0, now = 1;

    std::cin >> a >> b;

    for(size_t i = 1; now < b; i++){
        now--;
        now += a;

        if(now >= b) cnt = i;
    }

    std::cout << cnt << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

int inside(point p, vector<point> ps){
  point a,b;
  a=b=p;

  b.x=1000000;

  int n=ps.size();
  ps.push_back(ps[0]);

  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<n;i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;
  
  for(int i=0;i<n;i++){
    if(is_point_on_line(ps[i],ps[i+1],p))return 0;
  }
  
  int cnt1=0;
  for(int i=0;i<n;i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;
  
  int cnt=0;
  for(int i=0;i<n;i++)
    if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
  
  return (cnt-cnt1)%2;
}

int main(void){
 
  point in[4],p;
  vector<point>ps;

  while(cin>>in[1].x>>in[1].y>>in[2].x>>in[2].y>>in[3].x>>in[3].y>>p.x>>p.y){

    ps.clear();

    for(int i=1;i<4;i++)
    ps.push_back(in[i]);

    if(inside(p,ps))cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(e,n,s) for(int i = e; i < n;i += s)
#define forr(e,n,s) for(int i = e; i >= n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed;
  cout<<setprecision(20);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go(); 

    // code here
    long long int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
    

}










Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int f(int n){
    if(n%2) return 3*n+1;
    else return n/2;
}
int main(){
    int s;
    cin >> s;
    vector<int> a(1000000);
    rep(i,1000000){
        a[s]++;
        if(a[s] == 2){
            cout << i+1 << endl;
            return 0;
        }
        s = f(s);
    }
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	vector<int> idx(n);
	for (int i = 0; i < n; i++)
	{
		idx[a[i]] = i;
	}
	ll ans = 0;
	set<int> st;

	for (int x = n - 1; x >= 0; x--)
	{
		int i = idx[x];
		ll c = 0;
		st.insert(i);
		vector<int> l(2, -1), r(2, n);
		
		auto it = st.find(i);

		// left
		for (int j = 0; j < 2; j++)
		{
			if (it == st.begin()) {
				break;
			}
			it--;
			l[j] = *it;
		}


		// right
		it = st.find(i);
		for (int j = 0; j < 2; j++)
		{
			it++;
			if (it == st.end()) {
				break;
			}
			r[j] = *it;
		}
		
		vector<int> ls(2);
		ls[0] = i - l[0];
		ls[1] = l[0] - l[1];

		vector<int> rs(2);
		rs[0] = r[0] - i;
		rs[1] = r[1] - r[0];

		c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];
		ans += c * (x + 1);
	}
	cout << ans << endl;






}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int a,b;
    cin >> a;
    cin >> b;
    int x=min(a,b);
    int y=max(a,b);
    if(x==1 && y==2)cout << 3;
    if(x==1 && y==3)cout << 2;
    if(x==2 && y==3)cout << 1;



    
}

/*
*/



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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool flag = false;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N-x; y++) {
      int z = N-x-y;
      int sum = 10000*x + 5000*y + 1000*z;
      if (sum == Y) {
        flag = true;
        cout << to_string(x) << " " << to_string(y) << " " << to_string(z) << endl;
        break;
      }
    }
    if (flag) break;
  }
  if (!flag) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char s[101];
    scanf("%s",s);
    int j,ans=0;
    
    j=strlen(s)-1;
    for(int i=0; i<j; i++){
        if(s[i]!=s[j])
            ans++;
        j--;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Objects;
import java.lang.StringBuilder;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    List<Character> enki = new ArrayList<Character>();
    List<Character> revEnki = new ArrayList<Character>();
    enki.add('A');
    enki.add('C');
    enki.add('G');
    enki.add('T');

    revEnki.add('T');
    revEnki.add('G');
    revEnki.add('C');
    revEnki.add('A');

    Character result = revEnki.get(enki.indexOf(b.charAt(0)));
    System.out.println(result);

  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(LL N, vector<LL> A){
    VI B(A);
    RSORT(B);
    LL f = B[0], s = B[1];
    REP(i, N) {
        if (A[i] == f) {
            cout << s << endl;
        } else {
            cout << f << endl;
        }
    }
}

int main(){
    LL N;
    scanf("%lld",&N);
    vector<LL> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 4720
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

N,K,Q = map(int,input().split())
win = [0 for _ in range(N)]
for i in range(Q):
    winner = int(input()) - 1
    win[winner] += 1
for i in range(N):
    if K - Q + win[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7172
#include <stdio.h>

int main(){
    
    int a,x;
    scanf("%d",&a);
    
    for(int i=1;i<=a;i++){
        x=i;
        if(x%3==0){
            printf(" %d",i);
        }else if(x%10==3){
            printf(" %d",i);
        }else{
            for(;x>0;){
                x=x/10;
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
            }
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2148
#!/usr/bin/env python3
import sys
INF = float("inf")


def main():
    N = int(input())
    A = [None]*N
    X = [None]*N
    Y = [None]*N
    for i in range(N):
        A[i] = int(input())
        x, y = [None]*A[i], [None]*A[i]
        for j in range(A[i]):
            x_, y_ = map(int, input().split())
            x[j] = x_
            y[j] = y_
        X[i] = x
        Y[i] = y

    m = 0
    for table in range(2**N):
        # tableの表のうち
        flag = True
        for i in range(N):
            # iビット目が真ならi番目の人の発言をチェック
            if table & (1 << i):
                for j in range(A[i]):
                    if not ((table >> (X[i][j]-1)) & 1) == Y[i][j]:
                        flag = False
                        break
            if flag == False:
                break
        if flag == True:
            # 矛盾はないのでカウントしてよい。
            tot = 0
            for i in range(N):
                tot += (table >> i) & 1
            m = max(tot, m)

    print(m)
    pass


if __name__ == '__main__':
    main()


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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll solve(int n, int k, vl a) {
	vl cnt(200001, INF);
	set<ll> se;
	for (int i = 0; i < n; i++) {
		se.insert(a[i]);

		if (cnt[a[i]] == INF) {
			cnt[a[i]] = 0;
		}
		cnt[a[i]]++;
	}

	if (se.size() <= k) {
		return 0;
	}

	sort(cnt.begin(), cnt.end());
	ll res = 0;

	for (int i = 0; i < se.size() - k; i++) {
		res += cnt[i];
	}

	return res;
}

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

	int n, k;
	cin >> n >> k;

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

	cout << solve(n, k, a) << endl;
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;
//=============================================================
//=============================================================

int N, M;
const int mmax = 1000000005;
const int nmax = 100005;

bool is_prime[mmax];
vector<int> P;
// void Eratosthenes(const int Num)
// {
//     for (int i = 0; i <= Num; i++)
//     {
//         is_prime[i] = true; // initialize
//     }
//     for (int i = 2; i <= Num; i++)
//     {
//         if (is_prime[i])
//         {
//             for (int j = 2 * i; j <= Num; j += i)
//             {
//                 is_prime[j] = false;
//             }
//             P.emplace_back(i);
//         }
//     }
// }

map<int, int> soinsubunkai(int x)
{
    // vector<int> res(p.size());
    // rep(i, p.size())
    // {
    //     while (m % p[i] == 0)
    //     {
    //         res[i]++;
    //         m /= p[i];
    //     }
    // }
    // return res;
    map<int, int> res;
    for (int i = 2; i * i <= x; i++)
    {
        while (x % i == 0)
        {
            x /= i;
            res[i]++;
        }
    }
    if (x != 1)
        res[x]++;
    return res;
}

const int MAX = 222222;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{ // O(N)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int ans = 1;
void solve()
{
    map<int,int> cx = soinsubunkai(M);

    for (auto x : cx)
    {
        int tmp = COM(x.second + N - 1, N - 1);
        ans = (ans * tmp) % MOD;
    }
}

signed main()
{
    COMinit();
    cin >> N >> M;
    //Eratosthenes(M);
    solve();

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

Measured memory_bytes: 6400