akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF -1

void bfs();
void visit(int);
int dequeue();
void enqueue(int);
int d[101],color[101];
int Q[101],tail=0,head=0,kill,me[101][101];
int main(){
  int baby,i,j,yasuna,sonya;
  scanf("%d",&kill);
  for(i=1;i<=kill;i++)for(j=0;j<=kill;j++)me[i][j]=-1;

  for(i=0;i<kill;i++){
    scanf("%d%d",&yasuna,&sonya);
    for(j=0;j<sonya;j++){
      scanf("%d",&baby);
      me[yasuna][baby]=1;
    }
  }
  bfs();
  for(i=1;i<=kill;i++)printf("%d %d\n",i,d[i]);
}
void bfs(){
  int i,j,k,time=0,u;

  for(i=1;i<=kill;i++){
    color[i]=WHITE;
    d[i]=INF;
  }
  color[1]=GRAY;
  d[1]=0;
  enqueue(1);
  while(tail!=head){
    u=dequeue();
    for(i=1;i<=kill;i++){
      if(me[u][i]!=-1&&color[i]==WHITE){
	color[i]=GRAY;
	d[i]=d[u]+1;
	enqueue(i);
      }
    }
    color[u]=BLACK;
  }
}
void enqueue(int q){
  Q[head]=q;
  head=(head+1)%101;
}
int dequeue(){
  int i=tail;
  tail=(tail+1)%101;
  return Q[i];
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 1000000007;

ll frac[1000001];
ll fracinv[1000001];

ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

void init() {
  frac[0] = fracinv[0] = 1;
  REP(i,100000) {
    frac[i+1] = (i+1) * frac[i];
    frac[i+1] %= MOD;
    fracinv[i+1] = inv(frac[i+1], MOD);
  }
}

ll perm(ll n, ll k) {
  return (frac[n] * fracinv[n-k]) % MOD;
}

pair<ll, int> solve(const vector<vecint>& g, int k, int i, int p) {
  int children = 0;
  ll sum = 1;
  for (auto to : g[i]) {
    if (to == p) continue;
    ll chsum;
    int chch;
    tie(chsum, chch) = solve(g, k, to, i);
    sum *= chsum;
    sum %= MOD;
    sum *= perm(k-2, chch);
    sum %= MOD;
    ++children;
  }
  return make_pair(sum, children);
}

int main()
{
  init();
  int n,k;
  cin>>n>>k;
  vector<vecint> g(n);
  REP(i,n-1) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bool ok = true;
  REP(i,n) if (g[i].size() >= k) ok = false;
  if (!ok) {
    cout<<0<<endl;
  } else {
    auto res = solve(g, k, 0, -1);
    cout<<(((res.first*perm(k-1, res.second))%MOD)*k)%MOD<<endl;
  }
  return 0;
}


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

int bubbleSort(int A[], int N){
	int sw = 0;
	bool flag = 1;
	for(int i=0; flag; i++){
		flag = 0;
		for(int j = N-1; j >=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag =1;
				sw++;
			}
			
		}
		
		
	}
	
	return sw;
	
}

int main(){
	int A[100], N, sw;
	
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];
	
	sw = bubbleSort(A,N);
	for (int i =0; i<N; i++){
		if(i)cout << " ";
		cout << A[i];
		
	}
	
	cout << endl;
	cout << sw << endl;
	
	return 0;
}

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

int main(void){
	int h, w, i, j, k;
	char s[20][21];
	u_int d[400][400];
	memset(d, -1, sizeof(d));
	scanf("%d%d", &h, &w);
	for(i=0; i<h; i++){
		scanf("%s", s+i);
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]=='.'){
				d[i*w+j][i*w+j]=0;
			}
			if(i!=h-1 && s[i][j]=='.' && s[i+1][j]=='.'){
				d[i*w+j][(i+1)*w+j]=1;
				d[(i+1)*w+j][i*w+j]=1;
			}
			if(j!=w-1 && s[i][j]=='.' && s[i][j+1]=='.'){
				d[i*w+j][i*w+j+1]=1;
				d[i*w+j+1][i*w+j]=1;
			}
		}
	}
	int l=h*w;
	for(k=0; k<l; k++){
		for(i=0; i<l; i++){
			for(j=0; j<l; j++){
				if(d[i][k]!=UINT_MAX && d[k][j]!=UINT_MAX
						&& d[i][k]+d[k][j]<d[i][j]){
					d[i][j] = d[i][k]+d[k][j];
				}
			}
		}
	}
	int max=0;
	for(i=0; i<l; i++){
		for(j=0; j<l; j++){
			if(d[i][j]!=UINT_MAX && d[i][j]>max)
				max = d[i][j];
		}
	}
	printf("%d\n", max);
}


Measured memory_bytes: 768
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi

#j>iでj-aj=ai+iとなるi,jの組み合わせ
n.times do |j|
  cnt+=h[j-a[j]]
  h[a[j]+j]+=1
end

puts cnt

Measured memory_bytes: 38632
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] pc = new int[N + 1];
        long[] P = new long[M];
        long[][] Y = new long[M][3];
        Arrays.fill(pc, 0);
        for (int i = 0; i < M; i++) {
            P[i] = sc.nextLong();
            Y[i][0] = sc.nextLong();
            Y[i][1] = i;
            Y[i][2] = P[i];
        }
        Arrays.sort(Y, (a, b) -> Long.compare(a[0], b[0]));
        for (int i = 0; i < M; i++) {
            pc[(int) Y[i][2]]++;
            Y[i][0] = pc[(int) Y[i][2]];
        }
        Arrays.sort(Y, (a, b) -> Long.compare(a[1], b[1]));
        for (int i = 0; i < M; i++) {
            if (String.valueOf(P[i]).length() == 2) {
                System.out.print("0000");
            } else if (String.valueOf(P[i]).length() == 3) {
                System.out.print("000");
            } else if (String.valueOf(P[i]).length() == 4) {
                System.out.print("00");
            } else if (String.valueOf(P[i]).length() == 5) {
                System.out.print("0");
            } else if (String.valueOf(P[i]).length() == 1) {
                System.out.print("00000");
            }
            System.out.println(P[i] * 1000000 + Y[i][0]);
        }
    }
}


Measured memory_bytes: 109192
#include<iostream>
using namespace std;
char a,b;
int main(){
    cin>>a>>b;
    if(a=='A'&&b=='A')cout<<"="<<endl;
    if(a=='A'&&b=='B')cout<<"<"<<endl;
    if(a=='A'&&b=='C')cout<<"<"<<endl;
    if(a=='A'&&b=='D')cout<<"<"<<endl;
    if(a=='A'&&b=='E')cout<<"<"<<endl;
    if(a=='A'&&b=='F')cout<<"<"<<endl;
    if(a=='B'&&b=='A')cout<<">"<<endl;
    if(a=='B'&&b=='B')cout<<"="<<endl;
    if(a=='B'&&b=='C')cout<<"<"<<endl;
    if(a=='B'&&b=='D')cout<<"<"<<endl;
    if(a=='B'&&b=='E')cout<<"<"<<endl;
    if(a=='B'&&b=='F')cout<<"<"<<endl;
    if(a=='C'&&b=='A')cout<<">"<<endl;
    if(a=='C'&&b=='B')cout<<">"<<endl;
    if(a=='C'&&b=='C')cout<<"="<<endl;
    if(a=='C'&&b=='D')cout<<"<"<<endl;
    if(a=='C'&&b=='E')cout<<"<"<<endl;
    if(a=='C'&&b=='F')cout<<"<"<<endl;
    if(a=='D'&&b=='A')cout<<">"<<endl;
    if(a=='D'&&b=='B')cout<<">"<<endl;
    if(a=='D'&&b=='C')cout<<">"<<endl;
    if(a=='D'&&b=='D')cout<<"="<<endl;
    if(a=='D'&&b=='E')cout<<"<"<<endl;
    if(a=='D'&&b=='F')cout<<"<"<<endl;
    if(a=='E'&&b=='A')cout<<">"<<endl;
    if(a=='E'&&b=='B')cout<<">"<<endl;
    if(a=='E'&&b=='C')cout<<">"<<endl;
    if(a=='E'&&b=='D')cout<<">"<<endl;
    if(a=='E'&&b=='E')cout<<"="<<endl;
    if(a=='E'&&b=='F')cout<<"<"<<endl;
    if(a=='F'&&b=='A')cout<<">"<<endl;
    if(a=='F'&&b=='B')cout<<">"<<endl;
    if(a=='F'&&b=='C')cout<<">"<<endl;
    if(a=='F'&&b=='D')cout<<">"<<endl;
    if(a=='F'&&b=='E')cout<<">"<<endl;
    if(a=='F'&&b=='F')cout<<"="<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  Created by Vijay Bhati on 19/02/20.
//  Copyright © 2019 Vijay Bhati. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <map>
#include <sstream>
#include <set>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <memory>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define P pair<ll, ll>
#define ff first
#define ss second
#define F first
#define S second
#define MOD 1000000007
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)

using namespace std;

ll max(ll a, ll b) {
    return a > b ? a : b;
}

ll min(ll a, ll b) {
    return a > b ? b : a;
}

ll __gcd(ll a, ll b) {
    if (a == 0) {
        return b;
    }
    return __gcd(b%a, a);
}

ll find_power(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans = (ans * a) % 1000000007;
        }
        b = b >> 1;
        a = (a * a) % 1000000007;
    }
    return ans;
}


int main() {
#ifdef __APPLE__
    const clock_t begin_time = clock();
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    
    ll n;
    cin >> n;
    ll h[n][3];
    ll dp[n][3];
    
    for (int i = 0; i < n; i++) {
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }
    
    memset(dp, 0, sizeof(dp));
    
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];
    
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    dp[i][k] = max(dp[i][k], dp[i-1][j] + h[i][k]);
                }
            }
        }
    }
    
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    
#ifdef __APPLE__
    cout << endl;
    cout << "Time : ";
    cout << float( clock () - begin_time ) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


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

N = int(input())
if N==1:
    print(0)
else:
    
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
    
        if temp!=1:
            arr.append([temp, 1])
    
        if arr==[]:
            arr.append([n, 1])
    
        return arr
        
    def num(n):
        if n==1:
            return 1
        cnt=0
        for i in range(50):
            cnt += i
            if n<=cnt-1:
                return i-1
    
    ans = 0

    for i in factorization(N):
        ans += num(i[1])
    print(ans)


Measured memory_bytes: 9480
#include <stdio.h>
#include <math.h>

int main(void) {
	int n;
	double xa,ya,ra,xb,yb,rb;
	double dist;
	int res;

	scanf("%d",&n);
	while (n--) {
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		dist = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));
		if (ra + rb < dist) {
			// overlap
			res = 0;
		} else if (dist + ra < rb) {
			// A in B
			res = -2;
		} else if (dist + rb < ra) {
			// B in A
			res = 2;
		} else {
			// intersect
			res = 1;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int i,n,m,a[1000],sum=0,cnt=0;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum += a[i];
    }

    for(i=0;i<n;i++){
        if(a[i]*4*m>=sum){
            cnt++;
        }
    }
    if(cnt>=m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1668
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string O, E;
	cin >> O >> E;
	REP(i, O.size()) {
		cout << O[i];
		if (i < E.size())cout << E[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        int Q = Integer.parseInt(s.next());
        StringBuilder sb = new StringBuilder(S);
        StringBuilder sbF = new StringBuilder();
        StringBuilder sbB = new StringBuilder();
        boolean reversed = false;
        for (int i = 0; i < Q; i++) {
            // 反転
            if (s.nextInt() == 1) {
                reversed = !reversed;
                continue;
            }
            // 文字追加
            int F = s.nextInt();
            String C = s.next();
            // 先頭に追加
            if (F == 1) {
                if (reversed) {
                    // 反転されている場合は末尾追加
                    sbB.append(C);
                    continue;
                }
                sbF.append(C);
                continue;
            }
            if (reversed) {
                // 反転されている場合は先頭追加
                sbF.append(C);
                continue;
            }
            // 末尾に追加
            sbB.append(C);
        }

        if (reversed) {
            System.out.print(sbB.reverse());
            System.out.print(sb.reverse());
            System.out.println(sbF);
        } else {
            System.out.print(sbF.reverse());
            System.out.print(sb);
            System.out.println(sbB);
        }
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int ret=0;
	char cur='0';
	cin>>S;
	FORR(c,S) if(c!=cur) cur=c, ret++;
	
	cout<<ret-1<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
C - Synthetic Kadomatsu
https://atcoder.jp/contests/abc119/tasks/abc119_c

"""
import sys
from itertools import product, groupby


def solve(N, A, B, C, L):
    ans = float('inf')
    for p in product('abc_', repeat=N):
        if not all([ch in p for ch in 'abc']):
            continue
        cost = 0
        t = sorted([(usage, l) for usage, l in zip(p, L)], key=lambda x:x[0])
        for k, g in groupby(t, key=lambda x: x[0]):
            if k not in 'abc':
                continue
            g = list(g)
            cost += 10 * (len(g) - 1)
            l = sum(i[1] for i in g)
            if k == 'a':
                cost += abs(A - l)
            elif k == 'b':
                cost += abs(B - l)
            elif k == 'c':
                cost += abs(C - l)
        ans = min(ans, cost)
    return ans


def main(args):
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]
    ans = solve(N, A, B, C, L)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL W, H;
	cin >> H >> W;

	LL ret = W * (H / 2) + (W + 1) / 2 * (H % 2);
	if(W == 1 || H == 1) ret = 1;
	cout << ret << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//
//-----CODE------//


void solve(void)
{
  string str;
  cin>>str;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == ',')cout<<" ";
    else cout<<str[i];
  }
  
  cout<<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(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
def main():
    h, w, m = map(int, input().split())
    hp = [0]*h
    wp = [0]*w
    hw = set()
    for _ in range(m):
        h1, w1 = map(int, input().split())
        hp[h1-1] += 1
        wp[w1-1] += 1
        hw.add((h1, w1))

    h_max = max(hp)
    w_max = max(wp)

    hh = [i+1 for i, v in enumerate(hp) if v == h_max]
    ww = [i+1 for i, v in enumerate(wp) if v == w_max]
    ans = h_max + w_max

    for hb in hh:
        for wb in ww:
            if (hb, wb) not in hw:
                print(ans)
                exit()
    print(ans-1)


if __name__ == '__main__':
    main()

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

using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);

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

    int ans = INF_32;

    for (int bit = 0; bit < (1 << n); bit++) {
        vector<int> algo(m, 0);
        int cost = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                cost += c.at(i);
                for (int j = 0; j < m; j++) {
                    algo[j] += a[i][j];
                }
            }
        }

        bool flag = true;
        for (int j = 0; j < m; j++) {
            if (algo[j] < x) {
                flag = false;
            }
        }

        if (flag) {
            ans = min(ans, cost);
        }
    }

    if (ans == INF_32) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int head[200005],t1,t2;
struct edge{
    int v,nxt;
}e[400005];
ll n,ans[200005],f[200005],g[200005],tot,md,pre[200005],suf[200005],ed[200005];
void addedge(int fr,int to){
    e[++tot].nxt=head[fr];
    e[tot].v=to;
    head[fr]=tot;
}
void dfs1(int root,int fa)
{
    f[root]++;int tot=0;
    for(int i=head[root];i;i=e[i].nxt)
    {
        if(e[i].v==fa) continue;
        dfs1(e[i].v,root);
        f[root]=f[root]*f[e[i].v]%md;
    }
    for(int i=head[root];i;i=e[i].nxt) if(e[i].v!=fa) ed[++tot]=e[i].v;
    f[root]++;f[root]%=md;pre[0]=suf[tot+1]=1;
    for(int i=1;i<=tot;i++) pre[i]=pre[i-1]*f[ed[i]]%md;
    for(int i=tot;i;i--) suf[i]=suf[i+1]*f[ed[i]]%md;
    for(int i=1;i<=tot;i++) g[ed[i]]=pre[i-1]*suf[i+1]%md;
}
void dfs2(int root,int fa){
    if(root==1) ans[root]=1;
    else ans[root]=(g[root]*ans[fa]+1)%md;
    for(int i=head[root];i;i=e[i].nxt) if(e[i].v!=fa) dfs2(e[i].v,root);
}
int main()
{
    scanf("%lld%lld",&n,&md);
    for(int i=1;i<n;i++) scanf("%d%d",&t1,&t2),addedge(t1,t2),addedge(t2,t1);
    dfs1(1,1);dfs2(1,1);
    for(int i=1;i<=n;i++) printf("%lld\n",ans[i]*(md+f[i]-1)%md);
    return 0;
}

Measured memory_bytes: 15232
#配列アクセスを減らした
#入力変更
#出力変更
#tupleで済むところをlistから変更
#変数名以外2907313と同一に見える
import heapq
v, e, r = map(int, input().split( ))
E = [[] for _ in range(v)]
inf = 10**10
for _ in range(e):
    s,t,d = map(int, input().split( ))
    E[s].append((t,d))
D = [inf for _ in range(v)]
#Prev = [-1 for _ in range(v)]
D[r] = 0
Q = []
heapq.heappush(Q, (0,r))
#print(E)
#popからheappopに変更
while Q:
    d,q = heapq.heappop(Q) #qは[距離、頂点番号]：キューの優先度の都合で番号が後
    #print(q)
    for n,c in E[q]:#nは[辺の終点、辺の長さ]
        if D[n]>d+c:
            D[n] = d+c
            #Prev[n] = q
            heapq.heappush(Q, (d+c,n))

for d in D:
    if d<inf:
        print(d)
    else:
        print("INF")




Measured memory_bytes: 90296
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
tmp=[]
for i in range(x):
    tmp.append(p[i])

for j in range(y):
    tmp.append(q[j])

for k in range(len(r)):
    tmp.append(r[k])

tmp.sort(reverse=True)
ans=0
for i in range(x+y):
    ans+=tmp[i]

print(ans)

Measured memory_bytes: 23328
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        if(a+b>a-b&&a+b>a*b)
        {
               printf("%d\n",a+b);
        }
        else if(a-b>a+b&&a-b>a*b)
             printf("%d\n",a-b);
        else if(a*b>a+b&&a*b>a-b)
            printf("%d\n",a*b);
        else
            printf("%d\n",a);
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int n,x=0;
    int mx=0;
    char s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=='D')x-=1;
        else if(s=='I')x+=1;
        mx=max(mx,x);
    }
    cout<<mx<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main (){
  int A,B,C,D;
  cin>>A>>B;
  C=2*B;
  D=A-C;
  if(A<=C){
    cout<<"0"<<endl;
  }else{
    cout<<D<<endl;
  }
  return 0;
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    cin >> n;
    string s[n];
    rep(i, n){
        cin >> s[i];
    }

    int cnt = 0;
    for(int b = 0; b < n; ++b){
        bool ok = true;
        for(int i = 0; i < n; ++i){
            if(!ok) break;
            for(int j = 0; j < n; ++j){
                int I = (i+b)%n, J = (j+b)%n;
                if(i == J) continue;
                if(s[i][J] != s[j][I]){
                    ok = ok && false;
                    break;
                }
            }
        }
        if(ok) ++cnt;
    }
    ppp(n*cnt);
    return 0;
}


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

int main(){
  int N,T,S=0;cin>>N;T=N;
  while(T!=0){
    S+=T%10;
    T/=10;
  }
  if(N%S==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define dbl double
#define pi acos(-1)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pb push_back

ll ara[1000005];

map<ll,ll>vis;
map<ll,ll>vis1;
map<ll,ll>pos;
map<ll,ll>high;
map<ll,ll>low;
map<string,ll>mp;
vector<ll>vec;
vector<ll>v;
stack<ll>q;
string str1[100];
string str2[100];
priority_queue<ll>pq;
ll dp[1000005],t;
ll mn=1000000;
ll call(ll id)
{
    if(id==t )return 0;
    if(dp[id]!=-1)
        return dp[id];
    ll p=call(id+1)+abs(ara[id+1]-ara[id]);
    ll q=100000000;
    if(id+2!=t+1)
        q=call(id+2)+abs(ara[id+2]-ara[id]);
    dp[id]=min(p,q);
    return dp[id];

}
int main()
{

    // ll t;
    memset(dp,-1,sizeof(dp));
    sc1(t);
    for(ll i=1; i<=t; i++)
    {
        sc1(ara[i]);
    }
    cout<<call(1)<<endl;
    return 0;
}


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

using namespace std;

#define PACKAGE_NUM_MIN     (1)         
#define PACKAGE_NUM_MAX     (100000)    
#define PACKAGE_WEIGHT_MIN  (1)         
#define PACKAGE_WEIGHT_MAX  (10000)     
#define TRUCK_NUM_MIN       (1)         
#define TRUCK_NUM_MAX       (100000)    
#define FAIL                (-1)
#define SUCCESS             (0)

unsigned int CanPkgIntoTruck(unsigned int ulExp, vector<unsigned int> &ulvecPkg, unsigned int ulTruck);
unsigned int SelectMinLoad(vector<unsigned int> &ulvecPkg, unsigned int ulTruck, unsigned int ulTotal);


/*
最初の行に荷物の数nとトラックの数kが空白区切りで与えられる。
続くn行にn個の整数wiがそれぞれ１行に与えられる。
すべての荷物を積むために各トラックの必要な最大積載量の最小値を１行に出力してください。
return 正常値0のみ。
*/
int main(void)
{
    unsigned int ulTruck;
    unsigned int ulPkgNum;
    unsigned int ulTotal = 0;
    vector<unsigned int> ulvecPackage;
    
    // vectorの最大サイズを確保
    ulvecPackage.reserve(PACKAGE_NUM_MAX);
    
    // 荷物の数、トラックの数を取得
    cin >> ulPkgNum;
    if((ulPkgNum < PACKAGE_NUM_MIN) || (ulPkgNum > PACKAGE_NUM_MAX))
    {
        return FAIL;
    }
    cin >> ulTruck;
    if((ulTruck < TRUCK_NUM_MIN) || (ulTruck > TRUCK_NUM_MAX))
    {
        return FAIL;
    }
    
    // 各荷物の重さを取得（総重量も計算）
    ulvecPackage.resize(ulPkgNum);
    for(unsigned int i = 0; i < ulPkgNum; i++)
    {
        cin >> ulvecPackage[i];
        if((ulvecPackage[i] < PACKAGE_WEIGHT_MIN) || (ulvecPackage[i] > PACKAGE_WEIGHT_MAX))
        {
            return FAIL;
        }
        ulTotal += ulvecPackage[i];
    }
    
    // 最大積載量の最少値を求める
    cout << SelectMinLoad(ulvecPackage, ulTruck, ulTotal) << endl;
    
    return SUCCESS;
}

/*
期待値に対して、トラックに全部の荷物がつめられるかを判定する
ulExp       [in]最大積載量の期待値
ulvecPkg    [in]各荷物の大きさ
ulTruck     [in]トラックの数
return  最大積載量が制約を満たす1, 満たさない0
*/
unsigned int CanPkgIntoTruck(unsigned int ulExp, vector<unsigned int> &ulvecPkg, unsigned int ulTruck)
{
    unsigned int ulIdx   = 0;   // 荷物を積んでいるトラックの番号
    unsigned int ulTotal = 0;   // 各トラックに積む荷物の重さの合計値
    unsigned int i = 0;

    while((i < ulvecPkg.size()) && (ulIdx < ulTruck)) 
    {
        // 荷物の重さの合計が期待値を超えるか判定する
        ulTotal += ulvecPkg[i];
        if(ulTotal <= ulExp)
        {
            i++;
        }
        else
        {
            ulTotal = 0;
            ulIdx++;
        }

    }
    
    if(ulIdx < ulTruck)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
/*
すべての荷物を積むために必要な最大積載量の最小値を二部探索により求める
ulvecPkg    [in]各荷物の大きさ
ulTruck     [in]トラックの数  
ulTotal     [in]荷物の合計値
return      制約を満たす最大積載量の最少値
*/
unsigned int SelectMinLoad(vector<unsigned int> &ulvecPkg, unsigned int ulTruck, unsigned int ulTotal)
{
    unsigned int ulLeft     = PACKAGE_WEIGHT_MIN - 1;
    unsigned int ulRight    = ulTotal + 1;
    
    // 二部探索を実行する
    while(ulRight - ulLeft > 1)
    {
        //　中間値を期待値として、荷物が載るかを判定する
        unsigned int  ulMid = ulLeft + ((ulRight - ulLeft) / 2);
        if (CanPkgIntoTruck(ulMid, ulvecPkg, ulTruck))
        {
            ulRight = ulMid;
        }
        else
        {
            ulLeft  = ulMid;
        }
    }
    
    // 条件を満たす値の最少値を返す
    return ulRight;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())                 //昇順
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>()) //降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N, M, X;
  cin >> N >> M >> X;

  vec A(M);

  ll ansL = 0;
  ll ansR = 0;
  REP(i, M) {
    cin >> A[i];
    if (A[i] > X)
      ansR++;
    else
      ansL++;
  }

  cout << min(ansL, ansR) << endl;

  return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    s=input()
    if n%2!=0 or n==0:
        print('No')
    else:
        s1 = s[0:n//2]
        s2 = s[n//2:n]
        if s1==s2:
            print('Yes')
        else:
            print('No')
resolve()

Measured memory_bytes: 2940
import java.util.*;
import java.math.BigDecimal;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),k=sc.nextInt();
    int[] a=new int[n];
    boolean[] f=new boolean[n-k];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      if(i>=k){
        if(a[i]>a[i-k]){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }
    }
  }
}


Measured memory_bytes: 60752
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

vector<vector<bool>> a;
int n,m;
vector<vector<vector<int>>> dp;

int fdp(int r,int c,int t)
{
	if(r>=n || c>=m)
		return INF;
	if(dp[r][c][t]!=-1)
		return dp[r][c][t];
	int &ans=dp[r][c][t];
	
	if(r==n-1 && c==m-1 && a[r][c]==t)
		return (ans=0);
	
	ans=0;
	if(a[r][c]!=t)
	{
		ans=fdp(r,c,1-t)+(t==0);
	}
	else
	{
		ans=min(fdp(r+1,c,t),fdp(r,c+1,t));
	}
	return ans;
}

signed main()
{
	fio
	cin>>n>>m;
	a.resize(n,vector<bool>(m));
	fo(i,n)
	{
		string s;
		cin>>s;
		fo(j,m)
		{
			if(s[j]=='#')
				a[i][j]=1;
		}
	}
	
	// fo(i,n)
	// 	cerr<<a[i]<<'\n';
	// cerr<<'\n';
	
	dp.resize(n,vector<vector<int>>(m,vector<int>(2,-1)));
	cout<<fdp(0,0,0)<<'\n';
	
	// fo(i,n)
	// {
	// 	fo(j,m)
	// 	{
	// 		cout<<i<<','<<j<<" : "<<dp[i][j][0]<<','<<dp[i][j][1]<<'\n';
	// 	}
	// }
	
	printclock;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef pair<int, int> pr;
typedef priority_queue<int> p_int_max;
typedef priority_queue<int, vector<int>, greater<int>> p_int_min;

string s, t;
int a, b;
string u;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> s >> t >> a >> b >> u;
  	if(u == t) cout << a  << " " << b-1 << "\n";
  else cout << a-1 << " " << b << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	cin>>n;
	vector<pair<ld,ld> > vec(n);
	for(auto& it :vec)
		cin>>it.fi>>it.se;
	v p(n);
	for (int i = 0; i < n; ++i)
		p[i]=i;
	ld ans=0.0;
	ld comp=0.0;
	do{
		ld sum=0.0;
		for (int i = 1; i < n; ++i)
		{
			int idx=p[i];
			sum+=sqrt((vec[p[i-1]].fi-vec[idx].fi)*(vec[p[i-1]].fi-vec[idx].fi)+(vec[p[i-1]].se-vec[idx].se)*(vec[p[i-1]].se-vec[idx].se));
		}
		//debug(sum);
		comp+=1.0;
		ans+=sum;
	}while(next_permutation(all(p)));
	//debug(ans);
	//debug(comp);
	//comp+=1.0;
	cout<<fixed<<setprecision(10)<<ans/comp;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1<<28;

int N, M, P;
vector<int> D;
void input() {
    cin >> N >> M >> P;
    D.clear();
    D.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> D[i];
    }
    D.push_back(P);
    M++;
    sort(D.begin(), D.end());
}

int Dist(int x, int y) {
    if (x > y) {
        y += N;
    }
    return y - x;
}

void solve() {
    int Ans = INF;
    for (int pi = 0; pi < M; pi++) {
        int qi;
        if (pi == M - 1) {
            qi = 0;
        } else {
            qi = pi + 1;
        }
        int p = D[pi], q = D[qi];
        Ans = min(Ans, N - Dist(p, q) + 
                min( min(Dist(P, p), Dist(p, P)),
                     min(Dist(P, q), Dist(q, P)) ));
    }
    cout << Ans * 100 << endl;
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 1296
#include <cstdio>
#define f(i,n)for(int i=0;i<n;i++)
#define s (scanf("%d",&e),e)
int main(){int a=0,w,n,m,b,e,d[99];f(i,99)d[i]=0;n=s;m=s;if(n==0)return 0;f(i,m){w=b=0;f(j,n){s;if(e)f(k,3){e=d[j+k];if(e&&e-w){if(w){f(l,n+2)d[l]=d[l]==e?w:d[l];a--;}else w=e;}if(w==0)a++,w=i*n+j+1;}else w=0;d[j]=b;b=w;}d[n]=b;}printf("%d\n",a);main();}

Measured memory_bytes: 1032
#include <stdio.h>
int main(void)
{
  int A,B;
  scanf("%d",&A);
  scanf("%d",&B);
  if((A==1&&B==2)||(A==2&&B==1)) printf("3\n");
  else if((A==1&&B==3)||(A==3&&B==1)) printf("2\n");
  else if((A==2&&B==3)||(A==3&&B==2)) printf("1\n");
  
  return 0;  
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmax(x, a)  do { x = max(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

ll N, ans;

int main(void) {
  cin >> N;
  for (ll i = 1; i <= N; i++) {
    ll a;
    cin >> a;
    if ((i % 2) && (a % 2))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
N,M = map(int,input().split())
oks = [True]*(N+1)
for i in range(M):
   a = int(input())
   oks[a] = False
dp = [0]*(N+1)
dp[0] = 1
mod = 1000000007
for now in range(N):
    for next in range(now+1,min(N,now+2)+1): #1段または2段すすむ。際集団を超えないように
        if oks[next]: #階段が壊れていなければ
            dp[next] += dp[now]
            dp[next] %= mod
print(dp[N])


Measured memory_bytes: 76452
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
struct position{
  int x;
  int y;
};

int main(){
  int64_t h,w,d;
  cin >> h >> w >> d;
  vector<position> apos(h*w);
  rep(i,h){
    rep(j,w){
      int hoge;
      cin >> hoge;
      apos.at(hoge-1).y = i;
      apos.at(hoge-1).x = j;
    }
  }
  vector<int64_t> prep(h*w);
  rep(i,d){
    int j = i;
    while(true){
      j += d;
      if(j < h*w){
        prep.at(j) = prep.at(j-d)+abs(apos.at(j).x-apos.at(j-d).x)
          +abs(apos.at(j).y-apos.at(j-d).y);
      }else{
        break;
      }
    }
  }
  /*rep(i,h*w){
    cout << prep.at(i) << ",";
  }
  cout << endl;*/
    
  int q;
  cin >> q;
  vector<int64_t> l(q),r(q);
  rep(i,q){
    cin >> l.at(i) >> r.at(i);
  }
  int64_t cost = 0;
  rep(i,q){
    cout << prep.at(r.at(i)-1) - prep.at(l.at(i)-1) << endl;
  }

      
      
  
}

Measured memory_bytes: 4096
n = int(input())
a = list(map(int,input().split()))
a = [0] + a + [0]
a0 = a[0]
b = []
for i in range(1,n+2):
    b.append(abs(a0-a[i]))
    a0 = a[i]
s = sum(b)
for i in range(n):
    print(s+abs(a[i]-a[i+2])-(b[i]+b[i+1]))

Measured memory_bytes: 14176
#include<stdio.h>
#include<math.h>

int main(){
  int a,b,h,m;
  double theta,c;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  
  theta=2*M_PI*((double)h/12.0 + ((double)m/60.0)/12.0 - (double)m/60.0);
  
  
  c=(double)(a*a + b*b)-(double)(2*a*b)*cos(theta);
  printf("%.15f\n",sqrt(c));
  
  return 0;
}
  
  

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

#define int long long

struct Combination
{
  int mod;
  vector<int> mfact;
  vector<int> rfact;

  /*
    constructor : O(sz+log(mod))    
   */
  Combination(int sz, int mod) : mfact(sz+1), rfact(sz+1), mod(mod) {
    mfact[0] = 1;
    for ( int i = 1; i < (int)mfact.size(); i++ ) {
      mfact[i] = mfact[i-1]*i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      rfact[i] = rfact[i+1]*(i+1) % mod;
    }
  }

  int fact(int k) const {
    return (mfact[k]);
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int inv(int x) const {
    return (pow(x, mod - 2));
  }

  /*
    permutation
   */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return (mfact[n]*rfact[n-r] % mod);
  }

  /*
    combination
   */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return (mfact[n]*rfact[r]%mod * rfact[n-r] % mod);    
  }  

  /*
    combination with repetition
   */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
   */
  int S(int n, int r) const {
    int ret;
    for ( int i = 1; i <= r; i++ ) {
      
    }
  }

  /*
    bell number
   */
  int B(int n, int r) const {

  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  int MOD = 1e9+7;  
  Combination c(2000, MOD);
  cout << c.C(n+k-1, n) << endl;  
  
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<long long> lucas(90);
    lucas[0] = 2;
    lucas[1] = 1;
    for (int i = 2; i <= n; i++) {
        lucas[i] = lucas[i-1] + lucas[i-2];
    }
    cout << lucas[n] << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll=long long;
ll MOD=1e9+7;

ll mod_pow(ll a,ll n){
    ll ret=1;
    while(n>0){
        if(n & 1){
            ret=ret*a%MOD;
        }
        a=a*a%MOD;
        n>>=1;
    }
    return ret;
}
ll mod_inv(ll x){
    return mod_pow(x,MOD-2);
}
int main(){
    ll n,k;
    cin>>n>>k;
    ll sum=1;
    ll M=1;
    ll N=1;
    ll N_1=1;
    ll C;
    ll H;
    //i=0は1通り
    //重複組み合わせ
    //(n-m)Hm=(n-1)Cm
    ll max=min(k,n);
    for(ll i=1;i<=max;i++){
        M=M*i%MOD;
        N=N*(n-i+1)%MOD;
        ll mM=mod_inv(M);
        C=N*mM%MOD;
        N_1=N_1*(n-i)%MOD;
        H=N_1*mM%MOD;
        sum+=C*H%MOD;
        sum%=MOD;
    }
    cout<<sum<<endl;
    return 0;
}

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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	UnionFind uf(N);
	for (int n = 0; n < Q; ++n) {
		int t, u, v;
		scanf("%d %d %d", &t, &u, &v);
		if (0 == t) {
			uf.merge(u, v);
		}
		else {
			if (uf.issame(u,v)) {
				printf("1\n");
			}
			else {
				printf("0\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4060
N,K = map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

ans=-float("inf")

for start in range(N):
    cur=P[start]
    scores=[C[cur]]
    for _ in range(K):
        if cur==start:
            break
        cur = P[cur]
        scores.append(C[cur]+scores[-1])


    
    #no_loop_sum= max(scores[:K])
    #remain_hops=K-scores.index(no_loop_sum)-1
    #if scores[-1]>0:
    #    loops=remain_hops//len(scores)
    #else:
    #    loops=0
    #ans=max(ans,no_loop_sum+scores[-1]*loops)

    
    for goal in range(len(scores)):
        no_loop_sum=scores[goal]
        remain_hops=K-goal-1
        #remain_hops=K-1

        if scores[-1]>0:
            loops=remain_hops//len(scores)
        else:
            loops=0
        ans=max(ans,no_loop_sum+scores[-1]*loops)
print(ans)


Measured memory_bytes: 78132
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n; // number of entries
  cin >> n;

  vector<int> swap_vec;

  for (int i = 0; i < n; i++) {
    int entry;
    cin >> entry;
    swap_vec.push_back(entry);
  }
  
  //bubble sort
  int n_swaps = 0;
  for (int i = 0; i < n; i++) {
    for (int j = n-1; j > i; j--) {
      if (swap_vec[j] < swap_vec[j-1]) {
	swap(swap_vec[j], swap_vec[j-1]);
	++n_swaps;
      }
    }
  }
  
  //print vector
  for (int i = 0; i < n; i++) {
    cout << swap_vec[i];
    if (i < n - 1) cout << " ";
  }
  cout << endl;

  cout << n_swaps << endl;
}
	

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n,m=0;
  cin>>a>>b>>n;
  if(n<b){
    m=(a*n)/b;
  }
  else {
    m=(a*(b-1))/b;
  }
  cout<<m<<endl;
}

Measured memory_bytes: 3616
# coding:utf-8


INF = float('inf')


def inpl(): return list(map(int, input().split()))


N, X = inpl()
A = inpl()
B = [0]
for a in A:
    B.append(B[-1] + a)

ans = INF
for k in range(1, N + 1):
    tmp = 5 * B[N] + (N + k) * X
    cur = N - 2 * k
    while cur > 0:
        tmp += 2 * B[cur]
        cur -= k
    ans = min(ans, tmp)
print(ans)


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

int main(){
    int n;
    long long sum = 0;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3600