akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define NIL -1
using namespace std;
const int maxn=30;
struct Node{
    int p,l,r;
    Node(int p=NIL){this->p=p;}
}T[maxn];
void Preorder(int cur){
    if(cur==NIL) return ;
    cout<<" "<<cur;
    Preorder(T[cur].l);
    Preorder(T[cur].r);
}
void Inorder(int cur){
    if(cur==NIL) return ;
    Inorder(T[cur].l);
    cout<<" "<<cur;
    Inorder(T[cur].r);
}
void Postorder(int cur){
    if(cur==NIL) return ;
    Postorder(T[cur].l);
    Postorder(T[cur].r);
    cout<<" "<<cur;
}
int main()
{
    int n,id,ll,rr;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>id>>ll>>rr;
        T[id].l=ll;
        T[id].r=rr;
        if(ll!=NIL) T[ll].p=id;
        if(rr!=NIL) T[rr].p=id;
    }
    int root;
    for(int i=0;i<n;i++) if(T[i].p==NIL) {root=i;break;}
    cout<<"Preorder\n";
    Preorder(root);
    cout<<"\nInorder\n";
    Inorder(root);
    cout<<"\nPostorder\n";
    Postorder(root);
    cout<<"\n";
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  int graph[n][n], graph_t[n][n];
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(i == j)
        graph[i][j] = 1;
      else
        graph[i][j] = 0;
    }
  }

  int a, b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = 1;
  }

  // for(int i=0; i<n; i++){                                                                                                                                                    
  //   for(int j=0; j<n; j++){                                                                                                                                                  
  //     cout << graph[i][j] << ' ';                                                                                                                                            
  //   }                                                                                                                                                                        
  //   cout << endl;                                                                                                                                                            
  // }                                                                                                                                                                          

  int ret = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(graph[i][j] == 1){
        graph[i][j] = 0;

        // copy graph                                                                                                                                                           
        for(int in=0; in<n; in++){
          for(int jn=0; jn<n; jn++){
            graph_t[in][jn] = graph[in][jn];
          }
        }

        for(int kn=0; kn<n; kn++){
          for(int in=0; in<n; in++){
            for(int jn=0; jn<n; jn++){
              if(kn != in && kn != jn && in != jn &&
                 graph_t[in][jn] == 0 &&
                 graph_t[in][kn] == 1 && graph_t[kn][jn] == 1)
                graph_t[in][jn] = 1;
            }
          }
        }

        bool flag = false;
        for(int in=0; in<n; in++){
          for(int jn=0; jn<n; jn++){
            if(graph_t[in][jn] == 0){
              flag = true;
              break;
            }
          }
          if(flag) break;
        }
        if(flag) ret++;

        graph[i][j] = 1;
      }
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, tmp = 0, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n + 1; i++)
  {
    char c = getchar();
    if (c == 'I')
      tmp++;
    else if (c == 'D')
      tmp--;
    ans = MAX(tmp, ans);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
while True:
    a , op , b = input().split()
    a = int(a)
    b = int(b)

    if op =="?":
        break

    if op == "+":
        print("%d" %(a+b))

    if op == "-":
        print("%d" %(a-b)) 

    if op == "/":
        print("%d" %(a/b))

    if op =="*":
        print("%d" %(a*b)) 




Measured memory_bytes: 5592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

const int INF = 100000000;

int main(){

	int n;
//	int dp[1000001];
	vector<int> dp(1000001,0);
	vector<int> dp2(1000001,0);
		vector<int> triNum;
		int sum = 1;
		int idx = 2;
		int allSum = 0;
		while(sum <= 1000000){
			allSum += sum;
			triNum.push_back(allSum);
			sum += idx;
			idx++;
		}
		fill(dp.begin(),dp.end(),INF);
		fill(dp2.begin(),dp2.end(),INF);
		dp[1] = 1;
		dp[2] = 2;
		dp[3] = 3;
		dp[0] = 0;

		dp2[1] = 1;
		dp2[2] = 2;
		dp2[3] = 3;
		dp2[0] = 0;


		for(int i = 4; i <= 1000001; i++){
			for(int j = 0; j < triNum.size(); j++){
				if(i - triNum[j] == 0){
					if(triNum[j] % 2)
						dp2[i] = 1;
					break;
				}
				else if(i - triNum[j] < 0){
					break;
				}
				if(triNum[j] % 2)
					dp2[i] = min(dp2[i],dp2[i-triNum[j]]+1);
			}

			for(int j = 0; j < triNum.size(); j++){
				if(i - triNum[j] == 0){
					dp[i] = 1;
					break;
				}
				else if(i - triNum[j] < 0){
					break;
				}
				dp[i] = min(dp[i],dp[i-triNum[j]]+1);
			}
		}

	while(cin >> n && n != 0){

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

	return 0;
}

Measured memory_bytes: 8740
a = [int(input()) for i in range(5)]

aMod = [0, 0, 0, 0, 0]
for i in range(0,5):
    aMod[i] = a[i] % 10
    if aMod[i] == 0:
        aMod[i] = 10
    a[i] = a[i] + (10 - aMod[i])

aModMin = min(aMod)
print(sum(a) + aModMin - 10)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  int K1 = 0;
  cin >> K1;
  
  vector<bool> isLoved(M, true);
  vector<int> foods(M, 0);
    
  for (int i = 0; i < M; i++) {
    if (i < K1) {
      cin >> foods.at(i);
    } else {
      foods.at(i) = 0;
    }
  }
    
  sort(foods.begin(), foods.end());
  reverse(foods.begin(), foods.end());
  
  for (int i = 0; i < N - 1; i++) {
    int K2;
    cin >> K2;
    
    vector<int> foods2(M, 0);
    
    for (int j = 0; j < M; j++) {
      if (j < K2) {
        cin >> foods2.at(j);
      } else {
        foods2.at(j) = 0;
      }
    }
    
    sort(foods2.begin(), foods2.end());
    reverse(foods2.begin(), foods2.end());
    
    for (int j = 0; j < K1; j++) {
      if (isLoved.at(j) == true) {
        bool isLoved2 = false;
        
        for (int k = 0; k < M; k++) {
          if (foods.at(j) == foods2.at(k)) {
            isLoved2 = true;
          }
        }
        
        if (!isLoved2) isLoved.at(j) = false;
      } 
    }
  }
  
  int answer = 0;
  
  for (int i = 0; i < K1; i++) {
    if (isLoved.at(i)) answer++;
  }
  
  cout << answer << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector< vector<int> > bulb(m);
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		for (int j = 0; j < x; j++) {
			int k;
			cin >> k;
			--k;
			bulb[i].push_back(k);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) 
		cin >> p[i];
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		vector<int> cnt(n);
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				for (int k = 0; k < m; k++) {
					for (int l : bulb[k]) {
						if (l == j)
							cnt[k]++;
					}
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < m and ok; j++)
			if (cnt[j] % 2 != p[j])
				ok = false;
		if (ok)
			ans++;
	}
	cout << ans << endl;		
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,i;
  double a,sum=0;
  
  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
      scanf("%lf",&a);
      sum+=1/a;
    }

  printf("%lf\n",1/sum);
  
  return 0;
  
}


Measured memory_bytes: 128
#include<stdio.h>

void revers_array(int *array,int number);
void output(int *array,int number);

int main()
{

	int num;
	
	scanf("%d",&num);
	
	int a[num];
	int i,j,k;

	for(i=0;i<num;i++){
			scanf("%d",&a[i]);
	}
	revers_array(a,num);
	output(a,num);

	return 0;

}

void revers_array(int *array,int number){

		int i,j,k;
		int swp;
		int s[number];
		
		for(i=0;i<number;i++){
				s[i]=array[i];
		}

		j=number-1;

		for(i=0;i<number;i++){
				array[i] = s[j];
				j--;

		}
		
}

void output(int *array,int number){
		int i;
		for(i=0;i<number-1;i++){
				printf("%d ",array[i]);
		}
		printf("%d\n",array[i]);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll H, W, N, A, C[100][100];
pair<ll, ll> now_index = make_pair(0, 0);

def next_index(pair<ll, ll> P) {
    ll i = P.first, j = P.second;
    if(i & 1) {
        if(j == 0)
            i++;
        else
            j--;
    } else {
        if(j == W - 1)
            i++;
        else
            j++;
    }
    return make_pair(i, j);
}

signed main() {
    cin >> H >> W >> N;
    rep(i, N) {
        cin >> A;
        while(A--){
            ll x = now_index.first, y = now_index.second;
            C[x][y] = i + 1;
            now_index = next_index(now_index);
        }
    }
    rep(i, H) {
        rep(j, W) {
            if(j) cout << ' ' << C[i][j];
            else cout << C[i][j];
        }
        cout << endl;
    }
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

Measured memory_bytes: 384
from heapq import heappush, heappop

def main():
    x, y, z, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)

    # heappush(heap, (-(a[i]+b[j]+c[k]), i, j, k))
    heap = []
    heappush(heap, (-(a[0]+b[0]+c[0]), 0, 0, 0))
    s = set()
    for _ in range(k):
        value, i, j, k = heappop(heap)
        print(-value)
        if (i+1, j, k) not in s and i < x - 1:
            s.add((i+1, j, k))
            heappush(heap, (-(a[i+1]+b[j]+c[k]), i+1, j, k))
        if (i, j+1, k) not in s and j < y - 1:
            s.add((i, j+1, k))
            heappush(heap, (-(a[i]+b[j+1]+c[k]), i, j+1, k))
        if (i, j, k+1) not in s and k < z - 1:
            s.add((i, j, k+1))
            heappush(heap, (-(a[i]+b[j]+c[k+1]), i, j, k+1))

main()

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

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

    int n; cin >> n;
    map<string, int> m;

    ll ans = 0;
    while (n--) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        ans += m[s]++;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11264
#include <array>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    array<int, 3> sides;
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%d %d %d", &sides[0], &sides[1], &sides[2]);
        sort(sides.begin(), sides.end());
        printf(sides[2] * sides[2] == sides[0] * sides[0] + sides[1] * sides[1] ? "YES\n" : "NO\n");
    }

    return 0;
}

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

namespace testtesttest
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();
            var k = Int32.Parse(Console.ReadLine());
            var dict = new Dictionary<char,int>();
            dict.Add('z',1);
            dict.Add('y',2);
            dict.Add('x',3);
            dict.Add('w',4);
            dict.Add('v',5);
            dict.Add('u',6);
            dict.Add('t',7);
            dict.Add('s',8);
            dict.Add('r',9);
            dict.Add('q',10);
            dict.Add('p',11);
            dict.Add('o',12);
            dict.Add('n',13);
            dict.Add('m',14);
            dict.Add('l',15);
            dict.Add('k',16);
            dict.Add('j',17);
            dict.Add('i',18);
            dict.Add('h',19);
            dict.Add('g',20);
            dict.Add('f',21);
            dict.Add('e',22);
            dict.Add('d',23);
            dict.Add('c',24);
            dict.Add('b',25);
            dict.Add('a',0);
            
            for (int i = 0; i < s.Length; i++)
            {
                if(k==0)break;
                var c = s[i];
                var lim = dict[c];
                if (k >= lim)
                {
                    k -= lim;
                    s[i] = 'a';
                }
            }
            if (k != 0)
            {
                var last = s[s.Length - 1];
                var n = (26 - dict[last])%26;
                var target = (n + k)%26;
                var index = (26 - target)%26;
                var targetC = dict.First(pair => pair.Value == index).Key;
                s[s.Length - 1] = targetC;
            }
            Console.WriteLine(new string(s));
            Console.Read();
        }
    }
}


Measured memory_bytes: 4056
a, b, c, x, y = map(int, input().split())

ans = 0

if a + b >= c * 2:
    ans += min(x, y) * c * 2
    x, y = x - min(x, y), y - min(x, y)
    if [a, b][y > x] >= c * 2:
        ans += max(x, y) * c * 2
    else:
        ans += [a, b][y > x] * max(x, y)
else:
    ans += a * x + b * y

print(ans)


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "a == b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
while True:
    count = 0
    n,x = map(int, input().split())
    if n==0 and x==0:
        break;
    for i in range(1, n+1):
        for j in range(1, n+1):
            if i >=j:
              continue
            tmp = x - (i + j)
            if tmp > j and tmp <=n:
                count = count + 1
    print(count)


Measured memory_bytes: 5592
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		boolean not[] = new boolean[100000];
		not[0] = true;
		not[1] = true;
		for (int i = 2; i * i < 100000; i++)
		{
			if (not[i]) continue;
			for (int x = (i << 1); x < 100000; x += i)
			{
				if (not[x]) continue;
				not[x] = true;
			}
		}
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			int n = sc.nextInt(),
				p = 0;
			for (int i = 2; i < n; i++)
			{
				if (!not[i] && !not[n - (i - 1)])
					p++;
			}
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int a,b;
  vi c(3,0);
  cin >> a >> b;
  a--;b--;

  c.at(a) = 1;
  c.at(b) = 1;

  rep(i,3) if(c.at(i) == 0) cout << i + 1 << endl;  

  return 0;
}


Measured memory_bytes: 3652
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n;
map<string, LL> mm;

int main()
{
	FIO;
	cin >> n;
	rep(i,1,n) {
		string s;
		cin >> s;
		mm[s]++;
	}
	cout << "AC x " << mm["AC"] << endl;
	cout << "WA x " << mm["WA"] << endl;
	cout << "TLE x " << mm["TLE"] << endl;
	cout << "RE x " << mm["RE"] << endl;
}

Measured memory_bytes: 3664
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
S=get_nsp
T=get_nsp
N.times do|i|
    if S[i..]==T[0..N-1-i]
        puts N+i
        exit
    end
end
puts N*2

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

const int mod = 1e9 + 7;

int dp[1001][1001];
int main(){
    int h,w;
    cin>>h>>w;
    char arr[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>arr[i][j];
        }
    }

    int flag=0;

    for(int j=1; j<w; j++){
        if(arr[0][j] == '#'){
            flag=1;
        }
        if(flag){
            dp[0][j] = 0;
        }
        else{
            dp[0][j]=1;
        }
    }

    flag=0;

    for(int i=1; i<h; i++){
        if(arr[i][0] == '#'){
            flag=1;
        }
        if(flag){
            dp[i][0] = 0;
        }
        else{
            dp[i][0] = 1;
        }
    }

    for(int i=1; i<h; i++){
        for(int j=1; j<w; j++){
            if(arr[i][j] == '#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] = dp[i][j]%mod;
            }
        }
    }

    cout<<dp[h-1][w-1]%mod<<endl;


}


Measured memory_bytes: 5120
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD=10 ** 9 + 7

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


class BinomialCoefficient(object):

    def __init__(self, N=510000, MOD=10**9+7):
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]
        self.MOD = MOD
        for i in range(2, N + 1):
            self.fac.append((self.fac[-1] * i) % MOD)
            self.inv.append((-self.inv[MOD % i] * (MOD // i)) % MOD)
            self.finv.append((self.finv[-1] * self.inv[-1]) % MOD)

    def comb(self, n, r):
        if r < 0 or n < r or r < 0:
            return 0
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.MOD



n, k = MI()

if k >= n:
    print(combination(2 * n - 1, n, MOD))
    exit(0)

coef = BinomialCoefficient(n + 1, MOD)
ans = 1
for l in range(1, k + 1):
    ans += coef.comb(n, l) * coef.comb(n - 1, l)
    ans %= MOD
print(ans % MOD)


Measured memory_bytes: 80880
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll n,i,j,ans=0;
    cin>>n;
    if(n%2!=0)
        ans+=(n/2);
    else
        ans+=(n/2)-1;
    for(i=1;i<=n/2;i++)
    {
        if(n%i==0)
            ans+=((n/i)-1);
        else
            ans+=(n/i);
    }
    cout<<ans<<endl;
    #ifndef ONLINE_JUDGE
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}

Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long[] t = new long[n];
            for (int i = 0; i < n; i++) {
                t[i] = Long.parseLong(in.next());
            }
            if (n == 1) {
                out.println(t[0]);
                return;
            }
            long ans = t[0] / gcd(t[0], t[1]) * t[1];
            for (int i = 2; i < n; i++) {
                ans = ans / gcd(ans, t[i]) * t[i];
            }

            // 出力
            out.println(ans);

        }

        public static long gcd(long num1, long num2) {
            if (num2 == 0) return num1;
            else return gcd(num2, num1 % num2);
        }

    }
}



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

using namespace std;



int main()
{

    int frsta =0 , lstz = 0;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0 ; i < n ; ++i) if( s[i] == 'A' ) {
        frsta =i;
        break;
    }

    for(int i = 0 ; i < n ; ++i) if(s[i] == 'Z') lstz = i;


    cout << lstz - frsta +1 ;


    return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	vector<int> ans(3);
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		cin >> ans[i];
		if (ans[i] == 5) cnt++;
	}	
	if (cnt == 2) cout << "YES" << "\n";
	else cout << "NO" << "\n";
	return 0;
}


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

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

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

using namespace std;


long long mod_mult(int a, int n, int m) {
	a %= m;
	if (a < 0) a += m;
	long long ans = 0;
	while (n >= 1) {
		if (n % 2 == 1) ans = (a + ans) % m;
		a = a * 2 % m;
		n >>= 1;
	}
	return ans;
}
long long mod_pow(int a,int n,int m ){
	long long b = 1;
	while (n >= 1) {
		if (n % 2 == 1) b = mod_mult(a, b, m);
		a = mod_mult(a, a, m);
		n >>= 1;
	}
	return b;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> v(n);
	REP(i, n) {
		cin >> v[i];
	}
	sort(ALL(v));

	int flag = 1;
	REP(i, n) {
		if (n % 2 == 0) {
			if (i % 2 == 0 && v[i] !=  i + 1) flag = 0;
			else if (i % 2 == 1 && v[i] != i) flag = 0;
		}
		else  {
			if (i % 2 == 0 && v[i] != i) flag = 0;
			else if (i % 2 == 1 && v[i] != i + 1) flag = 0;
		}
	}
	if (flag) cout << mod_pow(2, n / 2,MOD) << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = int(input())
    b = list(map(int,input().split()))
    res = 0
    for i in range(m):
        for j in range(n):
            if b[i]==a[j]:
                res+=1
                break
    print (res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 6552
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000, mod = 1_000_000_007;



    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    long[] toLongArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        long[] ary = new long[n];
        for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);
        return ary;
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }


    long pow(long a, int pow)
    {
        long res = 1;
        while(pow > 0)
        {
            if(pow % 2 != 0) {
                res *= a;
                res %= mod;
            }
            a = a * a;
            a %= mod;
            pow /= 2;
        }

        return res;
    }

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");
        char[] gg = in.readLine().toCharArray();}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        
        new Main().c();        
        out.flush();
    }

    void c() throws Exception
    {
        int[] ary = toIntArray();
        int k = ary[0], n = ary[1];
        ary = toIntArray();
        int[] dist = new int[n];
        for(int i = 0; i < n - 1; i++)
        {
            dist[i] = ary[i + 1] - ary[i];
        }
        dist[n - 1] = ary[0] + k - ary[n - 1];
        
        int mini = k;
        
        for(int d : dist)
        {
            mini = Math.min(mini, k - d);
        }

        out.println(mini);
    }

    void b() throws Exception
    {
        int x = readInt();
        long hp = (x / 500) * 1000;
        x %= 500;
        hp += (x / 5) * 5;
        out.println(hp);
    }

    void a() throws Exception
    {
        char[] chs = in.readLine().toCharArray();
        if(chs[2] == chs[3] && chs[4] == chs[5]) 
        {
            out.println("Yes");
        }
        else out.println("No");
    }
}

Measured memory_bytes: 52788
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    string s;
    cin >> s;
    ll bcnt = 0, cnt = 0;
    rep(i, s.length()){
        if(s[i] == 'B') bcnt++;
        else if(s[i] =='W') cnt += bcnt;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    int i=0;
    int N;
    cin >> N;
    int P[N];
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    int ans=0;
    /*
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if(P[i]>P[j]){
                ans--;
                break;
            }
        }
        ans++;
    }
    */
   // should count max update Number
   //自分が一番小さかったらOK
   int min=P[0];
   ans++;
   for(int i=1;i<N;i++){
       if(min>P[i]){
           min=P[i];
           ans++;
       }
       
   }
    cout<<ans<<endl;

    return 0;
}

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

int main(void)
{
    int h1,m1,h2,m2,k,t;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    if(m1>m2){
        t=(h2-h1-1)*60+60-m1+m2;
    }else{
        t=(h2-h1)*60+m2-m1;
    }

    cout << t-k << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

#define T0(T) T
#define T1(T) vector<T0(T)>
#define T2(T) vector<T1(T)>
#define T3(T) vector<T2(T)>
#define V0(v, T,    ...) v
#define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__))
#define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__))

const int M = 161 * 159 + 1;
const int Z = M / 2;

int main() {
	int h, w;
	cin >> h >> w;
	auto a = V2(0, int, h, w);
	inc(i, h) {
	inc(j, w) {
		cin >> a[i][j];
	}
	}
	inc(i, h) {
	inc(j, w) {
		int b; cin >> b;
		a[i][j] -= b;
		a[i][j] = abs(a[i][j]);
	}
	}
	
	auto dp = V2(0, bitset<M>, h + 1, w + 1);
	dp[0][0][Z] = 1;
	inc(i, h) {
	inc(j, w) {
		dp[i][j] = (dp[i][j] << a[i][j]) | (dp[i][j] >> a[i][j]);
		dp[i + 1][j] |= dp[i][j];
		dp[i][j + 1] |= dp[i][j];
	}
	}
	
	incID(k, Z, M) { if(dp[h - 1][w - 1][k]) { cout << k - Z << endl; return 0; } }
	
	UR;
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >>b;
  if(a > b)
  {
    cout << 2*a-1;
  }
  else if(b > a)
  {
  	cout << 2*b-1;
  }
  else
  {
    cout << a + b; 
  }
    
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e18 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ERedScarf {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> ans(N, 0);
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> num(32, 0);
    rep(i, N) {
      rep(j, 31) {
        if ((a[i] >> j) & 1) {
          num[j]++;
        }
      }
    }
    rep(i, N) {
      rep(j, 31) {
        if ((a[i] >> j) & 1) {
          if (not(num[j] % 2)) {
            ans[i] += bpm(2, j);
          }
        } else {
          if (num[j] % 2)
            ans[i] += bpm(2, j);
        }
      }
    }
    FOR(i, ans) {
      cout << i << " ";
    }
    cout << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ERedScarf solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 6264
struct tbl_t{int c,l;unsigned char b;}tbl[]={{'A',6,0x25},{'B',8,0x9a},{'C',4,0x05},{'D',4,0x01},{'E',3,0x06},{'F',5,0x09},{'G',8,0x9b},{'H',6,0x10},{'I',4,0x07},{'J',8,0x98},{'K',4,0x06},{'L',5,0x04},{'M',8,0x99},{'N',8,0x9e},{'O',5,0x05},{'P',3,0x07},{'Q',8,0x9f},{'R',4,0x08},{'S',5,0x06},{'T',5,0x07},{'U',8,0x9c},{'V',8,0x9d},{'W',6,0x02},{'X',8,0x92},{'Y',8,0x93},{'Z',8,0x90},{' ',3,0x05},{'.',6,0x11},{',',6,0x03},{'-',8,0x91},{'\'',6,0x00},{'?',6,0x01},};c,b,l,i,r,f;main(){for(;c=getchar(),c+1;){for(i=0;i<32;i++){r=l-tbl[i].l;if(r>=0&&b>>r==tbl[i].b){putchar(tbl[i].c);b&=(1<<r)-1;l-=tbl[i].l;i=-1;}}if(c=='\n'){putchar(c);b=l=0;}else{for(i=0;i<32;i++)if(tbl[i].c==c){b=b<<5|i;l+=5;}}}exit(0);}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			double weight = Double.parseDouble(sc.nextLine());
			
			String c = "";
			if (weight > 91.0) c = "heavy";
			else if (weight > 81.0) c = "light heavy";
			else if (weight > 75.0) c = "middle";
			else if (weight > 69.0) c = "light middle";
			else if (weight > 64.0) c = "welter";
			else if (weight > 60.0) c = "light welter";
			else if (weight > 57.0) c = "light";
			else if (weight > 54.0) c = "feather";
			else if (weight > 51.0) c = "bantam";
			else if (weight > 48.0) c = "fly";
			else c = "light fly";
			
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 26100
H,W=map(int, input().split())
M=[list(input()) for _ in range(H)]

used=[[False for _ in range(W)] for __ in range(H)]
def dfs(sx,sy):
    global used
    if used[sy][sx]: return (0,0)
    black=white=0
    stack=[(sx,sy)]
    used[sy][sx]=True
    while stack:
        x,y=stack.pop()
        if M[y][x]=='#':
            black+=1
        else:
            white+=1
        for dx,dy in [(1,0),(-1,0),(0,1),(0,-1)]:
            nx,ny=x+dx,y+dy
            if 0<=nx<W and 0<=ny<H and not used[ny][nx]:
                if M[y][x]!=M[ny][nx]:
                    stack.append((nx,ny))
                    used[ny][nx]=True
    return (black,white)

ans=0
for y in range(H):
    for x in range(W):
        black,white=dfs(x,y)
        ans+=black*white
print(ans)


Measured memory_bytes: 55388
#include <stdio.h>

int main(){
	int n, i;
	long debt = 100000;
	
	scanf("%d",&n);

	for(i = 0; i < n; i++){
		debt *= 1.05;
		if(debt % 1000 != 0){
			debt -= (debt % 1000);
			debt += 1000;
		}

	}

	printf("%ld\n",debt);

	return 0;
}

Measured memory_bytes: 588
import java.util.Scanner;

public class Main {
  private static int input_num, x;
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    input_num = stdIn.nextInt();
    for (int i = 1;i <= input_num; i++) {
      x = i;
      if (x % 3 == 0) {
        System.out.print(" "+ x);
        continue;
      }
      while (x > 0) {
        if (x % 10 == 3) {
          System.out.print(" "+ i);
          break;
        }
        x /= 10;
      }
    }
    System.out.println("");
  }
}

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

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

    int homeworkDaysSum = 0;
    for (int i = 0; i < m; ++i)
    {
        int input;
        cin >> input;

        homeworkDaysSum += input;

        if (homeworkDaysSum > n)
        {
            break;
        }
    }

    cout << (homeworkDaysSum > n ? -1 : n - homeworkDaysSum) << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<queue>
#define SF scanf
#define PF printf
#define MAXN 500010
using namespace std;
int p[MAXN],q[MAXN];
set<int> pre,bac;
vector<int> a[MAXN];
priority_queue<int> que;
int n,k,pri[MAXN];
int vis[MAXN];
int main(){
	SF("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		SF("%d",&p[i]);
		q[p[i]]=i;
	}
	for(int i=1;i<=k;i++)
		bac.insert(p[i]);
	set<int>::iterator b,g;
	for(int i=1;i<=n;i++){
		b=bac.upper_bound(p[i]);
		g=pre.upper_bound(p[i]);
		if(b!=bac.end()){
			//PF("{%d %d}\n",q[*b],i);
			a[q[*b]].push_back(i);
			vis[i]++;
		}
		if(g!=pre.end()){
			//PF("[%d %d]\n",q[*g],i);
			a[q[*g]].push_back(i);
			vis[i]++;
		}
		pre.insert(p[i]);
		if(i-k+1>0)
			pre.erase(p[i-k+1]);
		if(i+k<=n)
			bac.insert(p[i+k]);
		bac.erase(p[i]);
	}
	for(int i=1;i<=n;i++)
		if(vis[i]==0)
			que.push(i);
	int tot=0;
	while(!que.empty()){
		int x=que.top();
		que.pop();
		pri[++tot]=x;
		//PF("[%d]",x);
		for(int i=0;i<a[x].size();i++){
			vis[a[x][i]]--;
			if(vis[a[x][i]]==0)
				que.push(a[x][i]);
		}
	}
	for(int i=1;i<=n;i++)
		q[pri[i]]=n-i+1;
	for(int i=1;i<=n;i++)
		PF("%d\n",q[i]);
}

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

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j)); // .emplace(i,j)
    };
    update(si,sj,0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir,4) {
        int ni = i+di[dir], nj = j+dj[dir];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)

int a,b,c;

int main() {
  cin >>a>>b>>c;
  int s;
  if (a==b) s=c;
  if (a==c) s=b;
  if (b==c) s=a;
  cout << s << endl;
}


Measured memory_bytes: 256
n = int(input())
b = []
r = []
for i in range(n):
    r.append(list(map(int, input().split())))
for i in range(n):
    b.append(list(map(int, input().split())))
    
r = sorted(r)
b = sorted(b)

b_f = [-1] * n
r_f = [-1] * n

pair = []
count = 0
for i in range(n):
    if b_f[i] == -1:
        tmp = []
        for j in range(n):
            if b[i][0] > r[j][0] and b[i][1] > r[j][1] and r_f[j] == -1:
                tmp.append(j)
            
        if len(tmp) != 0:     
            pair_j = max(tmp, key=lambda j: r[j][1])
            count += 1
            b_f[i] = 1
            r_f[pair_j] = 1
print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
N,M = map(int, input().split())

food = [0] * M

for i in range(0,N):
    Ks =  list(map(int, input().split()))
    K = Ks[0]
    for j in range(1,K+1):
        food[Ks[j]-1] += 1

cnt=0
for i in range(0,M):
    if food[i] == N:
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
/**
*	created: 01.09.2020 14:13:56
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
template<typename T> T pow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

// UnionFind
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    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);
        par[x] += par[y]; par[y] = x;
        return true;
    }
    bool issame(int x, int y) {return root(x) == root(y);}
    int size(int x) {return -par[root(x)];}
};

signed main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    vector<int> a(m), b(m);
    int c;
    rep(i,m) {
        cin >> a[i] >> b[i] >> c;
        a[i]--; b[i]--;
        uf.merge(a[i],b[i]);
    }
    set<int> v;
    rep(i,n) v.insert(uf.root(i));
    cout << v.size() << endl;
    return 0;
}

Measured memory_bytes: 10196
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll n;cin>>n;
  if(n%2==0){
    cout<<n<<endl;
  }
  else{cout<<2*n<<endl;}
}

Measured memory_bytes: 256