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

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

  vector<pair<int, int> > ab(M);  
  int ans = 0;
  for ( int i = 0; i < M; i++ ) {
    cin >> ab[i].first >> ab[i].second;
  }

  sort(ab.begin(), ab.end());

  int r = 0;
  for ( int i = 0; i < M; i++ ) {    
    int a = ab[i].first, b = ab[i].second;
    if ( a < r ) {
      r = min(b, r);      
    } else {
      r = b;
      ans++;
    }
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll n;
  cin>>n;
  ll a[n];
  ll i;
  for(i=0;i<n;i++)
  cin>>a[i];
  ll bal=1000;ll stock=0;
  for(i=1;i<n;i++)
  {
  	if(a[i]>a[i-1])
	  {
	  	stock=bal/a[i-1];
	  	bal=bal % a[i-1];
	  	bal+=stock*a[i];
	  	//cout<<"Stock  "<<stock<<endl;
	  	//cout<<"Balance  "<<bal<<endl;
	  }
  }
   cout<<bal<<endl;
  
return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,x[5];
    cin >>n;
    ll neck=1e16;
    ll npoint=0;
    for(int i=0;i<5;i++){
        cin >>x[i];
        if(x[i]<neck){
            neck=x[i];
            npoint=i;
        }
    }
    ans=npoint+(n/neck+((n%neck>0)?(1):(0)))-1+(5-npoint);


    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

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

using namespace std;

typedef long long ll;

ll solve(ll h, ll w) {
  ll result = 1000000000000LL;
  for (ll i = 1; i < w; i++) {
    ll s1 = i * h;

    ll w2 = w - i;
    ll s21 = (w2 / 2) * h;
    ll s22 = ((w2 + 1) / 2) * h;

    ll s31 = (h / 2) * w2;
    ll s32 = ((h + 1) / 2) * w2;

    vector<ll> v1 = {s1, s21, s22}, v2 = {s1, s31, s32};
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    result = min(result, min(v1[2] - v1[0], v2[2] - v2[0]));
  }
  return result;
}

int main() {
  ll h, w;
  cin >> h >> w;
  cout << min(solve(h, w), solve(w, h)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    string S;
    cin >> S;
    vector<string> check = {"dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"};
    int idx = 0;
    while (idx < S.length()) {
        bool ng = true;
        for (int i = 0; i < check.size(); i++) {
            int len = check[i].length();
            if (idx + len > S.length()) continue;
            auto base = S.substr(idx, len);
            if (base == check[i]) {
                ng = false;
                idx += len;
                break;
            }
        }
        if (ng) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,char> cc;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<cc,ll> ct;
	for (int i=1; i<=n; i++) {
		string cur=to_string(i);
		ct[{cur.front(),cur.back()}]++;
	}
	ll ret=0;
	for (char ch1='1'; ch1<='9'; ch1++) {
		for (char ch2='1'; ch2<='9'; ch2++) {
			ret+=ct[make_pair(ch1,ch2)]*ct[make_pair(ch2,ch1)];
		}
	}
	cout<<ret<<endl;
	return 0;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	int N, M, K; cin >> N >> M >> K;
	bool flag = false;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (M * i + N * j - 2 * i * j == K) flag = true;
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
tmp = int("0"+str(N)[1:-1])
NR = int(str(N)[-1])
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = (R*10**j) +L
        maxi = ((R+1)*10**j) +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        
        if L <= NR:
            ans += tmp+1
        else:
            ans += tmp
        break
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
 
int main(void){
    double x1,x2,y2,y1;
 
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
 
    printf("%lf\n",sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    return 0;
}


Measured memory_bytes: 1992
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
					/*多倍長整数/cpp_intで宣言
					#include <boost/multiprecision/cpp_int.hpp>
					using namespace boost::multiprecision;
					*/

					//#pragma GCC target ("avx2")
					//#pragma GCC optimization ("O3")
					//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int h, a;
	scanf("%d%d", &h, &a);
	printf("%d\n", (a + h - 1) / a);

	Please AC;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
 
 
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        uint[] A = new uint[100001];//1にするところ注意
        string[] In = Console.ReadLine().Split(' ');
        //long sum = 0;
        ulong sum = 0;
        for (int i = 0; i < n; i++)
        {
            A[int.Parse(In[i])]++;
            sum += uint.Parse(In[i]);
            //sum += int.Parse(In[i]);
        }
        int q = int.Parse(Console.ReadLine());
        var que = new Queue<ulong>();
        //var que = new Queue<long>();
        for (int i = 0; i < q; i++)
        {
            string[] In2 = Console.ReadLine().Split(' ');
            uint b = uint.Parse(In2[0]);
            uint c = uint.Parse(In2[1]);
            //int temp_num = A[b];
            uint temp_num = A[b];
            sum -= temp_num * b;
            sum += temp_num * c;
            A[b] = 0;
            A[c] += temp_num;
            que.Enqueue(sum);
        }
        while (!(que.Count == 0))
        {
            Console.WriteLine(que.Dequeue());
        }
    }
}

Measured memory_bytes: 50496
def main():
    n = int(input())
    alp = 'abcdefghijklmnopqrstuvwxyz'
    answer = ''

    while n >= 1:
        n -= 1
        answer += alp[n % 26]
        n //= 26

    real_answer = ''
    for i in range(1, len(answer) + 1):
        real_answer += answer[-i]

    print(real_answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll X;
    ll money = 100;
    cin >> X;
    int year = 0;
    while(true) {
        money = money + money / 100;
        year++;
        if (money >= X) {
            cout << year << endl;
            exit(0);
        }
    }
}

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

int main() {
  int num;
  cin >> num;
  int result;
  for (int i = 0;i < num;i++) {
    int pre, rear;
    cin >> pre >> rear;
    result += rear - pre + 1;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (s == u) a--;
	else b--;
	cout << a << " " << b;
	return(0);
}

Measured memory_bytes: 256
using System;

namespace A_The_Number_of_Even_Pairss
{
    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            //n個から2個取り出す組み合わせnCn-1
            int ns = n * (n-1) / 2;
            //m個から2個取り出す組み合わせnCn-1
            int ms = m * (m - 1) / 2;
            Console.WriteLine(ns + ms);
        }
    }
}


Measured memory_bytes: 13140
from itertools import combinations_with_replacement
animal_count, leg_count = map(int, input().split(' '))

# 0番地が鶴、1番地を亀とする
animals = [2, 4]

#print(animal_count, leg_count)

found = False
for case in combinations_with_replacement(animals, animal_count):
  #print(case)
  if(sum(case) == leg_count):
    found = True
    break

if(found):
  print('Yes')
else:
  print('No')


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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> map(h+2);
	rep(i, h) cin >> map.at(i+1);
	rep(i, h){
		map.at(i+1) = '.' + map.at(i+1) + '.';
	}
	rep(i, w+2){
		map.at(0) += '.';
		map.at(h+1) += '.';
	}
	int f = 0;
	rep(i, h){
		rep(j, w){
			int y = i+1;
			int x = j+1;
			if(map.at(y).at(x) == '#'){
				if(map.at(y-1).at(x) == '.' && map.at(y+1).at(x) == '.' && map.at(y).at(x-1) == '.' && map.at(y).at(x+1) == '.'){
					f = 1;
					break;
				}
			}
		}
		if(f == 1) break;
	}
	if(f == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int MAXN=1e5+50;
int main()
{
    //freopen("in.txt","r",stdin);
   int ans=1^2^3;
   int a,b;
   scanf("%d%d",&a,&b);
   ans=ans^a^b;
   printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
A = list(map(int,input().split()))

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
temp = list(dic.values())
ans = 0
temp.sort()
for i in range(len(temp)-k):
    ans += temp[i]
    
print(ans)

Measured memory_bytes: 32184
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int W, N; scanf(" %d %d", &W, &N);
	vector<int> arr(W+1);
	rep(i,W+1) arr[i] = i;
	rep(i,N) {
		int a, b; scanf(" %d,%d", &a, &b);
		swap(arr[a], arr[b]);
	}
	rep(i,W) printf("%d\n", arr[i+1]);
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        int tmp = 0;
        int next = 0;

        // 一人目
        next = sc.nextInt();
        tmp = next;

        for (int i = 1; i < n; i++) {
            next = sc.nextInt();
            int diff = 0;
            if (next < tmp) {
                diff = tmp - next;
                sum += diff;
            }
            tmp = next + diff;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 58196
h,w = map(int,input().split())
mat = []
for i in range(h):
  g = list(input())
  if g.count(".") != w:
    mat.append(g)


for i in range(w-1, -1, -1):
  count = 0
  for j in range(len(mat)):
    if mat[j][i] == ".":
      count += 1
  if count == len(mat):
    for j in range(len(mat)):
      mat[j].pop(i)

for h in range(len(mat)):
  print("".join(mat[h]))
    


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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, x;
    vector <pair<ll,ll>> cu; //understanding
    cin>>n>>m>>x;
    vector <vector <ll>> ca(n, vector <ll> (m+1,0));
    vector <ll> cost;
    forl(i,0,n) {
        cin>>ca[i][0];
        //cost[i] = ca[i][0];
        forl(j,1,m+1) {
            cin>>ca[i][j];
        }
    }
    for(ll i=1; i<(1<<n); i++) {
        ll cst = 0;
        vector <ll> un(m,0);
        ll in=0;
        for(ll j=1; j<=(1<<(n-1));) {
            if(j&i) {
                cst += ca[in][0];
                forl(p,1,m+1) {
                    un[p-1] += ca[in][p];
                }
            }
            in++;
            j = (1<<in);
        }
        srt(un);
        auto lb = lower_bound(un.begin(), un.end(), x);
        if(lb==un.begin()) cost.pb(cst);
    }
    if(cost.empty()) cout<<-1<<"\n";
    else cout<<*min_element(cost.begin(),cost.end())<<"\n";
}

Measured memory_bytes: 3716
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int n, *x, *y, *t;
	x = new int[100000];
	y = new int[100000];
	t = new int[100000];
	int px = 0, py = 0,pt=0;
	bool check = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> x[i] >> y[i];
		if (check) {
			if (abs(x[i] - px) + abs(y[i] - py) == t[i]-pt) {
				px = x[i];
				py = y[i];
				pt = t[i];
			}
			else if (abs(x[i] - px) + abs(y[i] - py) < t[i]-pt && ((t[i]-pt) - (abs(x[i] - px) + abs(y[i] - py))) % 2 == 0) {
				px = x[i];
				py = y[i];
				pt = t[i];
			}
			else
				check = false;
		}
	}
	if (check)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	delete[]x;
	delete[]y;
	delete[]t;
	return 0;
}


Measured memory_bytes: 1408
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    N = int(input())
    S = [input() for _ in range(N)]
    countA = 0
    countB = 0
    countBA = 0
    countAB = 0
    for s in S:
        countAB += s.count('AB')
        #print(s, s.count('AB'))
        if s[0] == 'B':
            if  s[-1] == 'A':
                countBA += 1
            else:
                countB += 1
        elif s[-1] == 'A':
            countA += 1

    #print(countA, countB, countBA, countAB)
    if countBA > 1:
        countAB += countBA - 1
        countBA = 0

        if countA > 0:
            countAB += 1
            countA -= 1
        if countB>0:
            countAB += 1
            countB -= 1

    plus = min(countA, countB)

    countAB += plus
    countA -= plus
    countB -= plus

    plus = min(countBA, countA)
    countAB += plus
    countBA -= plus
    countA -= plus

    plus = min(countBA, countB)
    countAB += plus

    print(countAB)






if __name__ == "__main__":
    run()

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

int main(){
    int n;
    int m;
    scanf("%d %d",&n,&m);
    int sum = 0;
    int a;
    for(int i = 0;i < m;i++){
        scanf("%d",&a);
        sum += a;
    }
    a = n - sum;
    if(a >= 0){
        printf("%d\n",a);
    }else{
        printf("-1\n");
    }
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int K;
	scan(K);
	if(K%2) prin(K/2*(K/2+1));
	else prin((K/2)*(K/2));

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=0
if(n==3):
  ans+=1
if(n==2):
  ans+=2
if(n==1):
  ans+=3
if(m==3):
  ans+=1
if(m==2):
  ans+=2
if(m==1):
  ans+=3
  
if(n==1 and m==1):
  ans+=4
  
print(ans*100000)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
int array[100];
cin >> n;
for(int i = 0; i < n; i++) {
    cin >> array[i];
}
sort(array, array+n, greater<int>());
int Alice = 0;
int Bob = 0;
for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
        Alice += array[i];
    } else {
        Bob += array[i];
    }
}
    cout << Alice - Bob << endl;
}

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

int main(){
  char b;
  cin >> b;
  
  if(b == 'A'){
      cout << 'T' << endl;
  }else if(b == 'C'){
      cout << 'G' << endl;
  }else if(b == 'G'){
      cout << 'C' << endl;
  }else if(b == 'T'){
      cout << 'A' << endl;
  }
  return 0;
}

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

int main() {
	int a, b, c; cin >> a >> b >> c;
	if(a==b){
	    if(b==c) cout << 1 << endl;
	    else cout << 2 << endl;
	}
	else if(a==c || b==c) cout << 2 << endl;
	else cout << 3 << endl;
	return 0;
}


Measured memory_bytes: 256
nm=input().split()
N=int(nm[0]);M=int(nm[1])
dict={}
for i in range(N):
    list=input().split()
    del list[0]
    dict[i]=[int(l) for l in list]
st={}
for j in range(N):
    if j==0:
        st=set(dict[j])
    else:
        st=st&set(dict[j])
print(str(len(st)))
    


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


int main(){
  bool is_prime[N];
  for(int i=0;i<N;i++)
    is_prime[i] = false;

  for(int i=3;i<N;i+=2) is_prime[i] = true;
  is_prime[2] = true;
  for(int i=3;i<=1000;i+=2){
    if(is_prime[i]){
      for(int j=2*i;j<N;j+=i) is_prime[j] = false;
    }
  }

  int n,x;
  while(cin >> n >> x){
    if(n==0&&x==0) break;
    int v;
    bool dp[x+1];
    for(int i=0;i<=x;i++)
      dp[i] = false;

    for(int i=0;i<n;i++){
      cin >> v;
      dp[v] = true;
      for(int j=0;j<=x-v;j++){
        if(dp[j]) dp[j+v] = true;
      }
    }
    for(int i=x;i>=0;i--){
      if(i==0) cout << "NA" << endl;
      if(dp[i]&&is_prime[i]){
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4996
N,M=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
S=[]
if N>=M:
	print(0)
	exit()
for i in range(M-1):
	S.append(abs(L[i+1]-L[i]))
S=sorted(S)
#print(S)
print(sum(S[0:M-N]))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    else {
        int a, b; cin >> a >> b;
        cout << a+b << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7744
N = int(input())
P = [int(input()) for _ in range(N)]
P.sort()
s = sum(P)
a = sum(P)
if a % 10 == 0:
    for i in range(N):
        if P[i] % 10 != 0:
            a = P[i]
            break
else:
    a = 0
print(s - a)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 23 22:02:16 2018
ABC050B
@author: maezawa
"""

n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for _ in range(m):
    pi, xi = list(map(int, input().split()))
    p.append(pi)
    x.append(xi)
    
standard = sum(t)
for i in range(m):
    stime = standard - (t[p[i]-1]-x[i])
    print(stime)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 1500
 
vector<int> G[MAX];
set<int> st;
bool visited[MAX];
 
void solve(int v){
    if(st.count(v)) return;
    if(visited[v]) return;
    visited[v] = true;
    if(G[v].size() == 0){
	st.insert(v);
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	solve(G[v][i]);
    }
}
 
int main(){
    int N;
    while(cin >> N, N){
	for(int i = 0 ; i < MAX ; i++){
	    G[i].clear();
	    visited[i] = false;
	}
	int idx = 0;
	string s;
	map<string,int> mp;
	for(int i = 0 ; i < N ; i++){
	    cin >> s;
	    int p = s.find(":");
	    string s1,s2;
	    s1 = s.substr(0,p);
	    s2 = s.substr(p+1); s2.resize(s2.size()-1);
	    if(mp.find(s1) == mp.end()){
		mp[s1] = idx++;
	    }
	    stringstream ss(s2);
	    while(getline(ss,s2,',')){
		if(mp.find(s2) == mp.end()){
		    mp[s2] = idx++;
		}
		G[mp[s1]].push_back(mp[s2]);
	    }
	}
	st.clear();
	solve(0);
	cout << st.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3336
// Confessions of a Dangerous Mind

/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

long long a[4][4];
bool u[M];

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

/*
	"With self-discipline most anything is possible."
*/
	
	for(long long i = 1; i <= 3; i++){
		for(long long j = 1; j <= 3; j++){
			cin >> a[i][j];
			u[a[i][j]] = true;
		}
	} 	
	
	long long n; cin >> n;
	for(long long i = 0; i < n; i++){
		long long x; cin >> x;
		u[x] = false;
	}	
	
	if(!u[a[1][1]] && !u[a[1][2]] && !u[a[1][3]]) cout << "Yes";
	else if(!u[a[2][1]] && !u[a[2][2]] && !u[a[2][3]]) cout << "Yes";
	else if(!u[a[3][1]] && !u[a[3][2]] && !u[a[3][3]]) cout << "Yes";
	else if(!u[a[1][1]] && !u[a[2][1]] && !u[a[3][1]]) cout << "Yes";
	else if(!u[a[1][2]] && !u[a[2][2]] && !u[a[3][2]]) cout << "Yes";
	else if(!u[a[1][3]] && !u[a[2][3]] && !u[a[3][3]]) cout << "Yes";
	else if(!u[a[1][1]] && !u[a[2][2]] && !u[a[3][3]]) cout << "Yes";
	else if(!u[a[3][1]] && !u[a[2][2]] && !u[a[1][3]]) cout << "Yes";
	else cout << "No";
	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/


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

int main() {
  int n, x, min;
  cin >> n;

  for (int i = 0; i < n; i++) {
      int cnt = 0;
      cin >> x;

      while (x % 2 == 0) {
          x /= 2;
          cnt++;
      }

      if (i == 0) min = cnt;
      else if (cnt < min) min = cnt;
  }

  cout << min << endl;
}

Measured memory_bytes: 256
using System;

class AOJ
{
	public static void Main()
	{
		var input = Console.ReadLine().Trim().Split(' ');
		int W = int.Parse(input[0]);
		int H = int.Parse(input[1]);
		int x = int.Parse(input[2]);
		int y = int.Parse(input[3]);
		int r = int.Parse(input[4]);

		if(x < 0 || x >= W){ Console.WriteLine("No"); }
		else if(y < 0 || y >= H){ Console.WriteLine("No"); }
		else
		{
			if(x + r > W){ Console.WriteLine("No"); }
			else if(y + r > H){ Console.WriteLine("No"); }
			else{ Console.WriteLine("Yes"); }
		}
	}
}

Measured memory_bytes: 19640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

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

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

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {

	ll N;
	cin >> N;

	ll dp[MAX];

	dp[0] = 0;

	repn(i, N) {
		dp[i] = dp[i - 1] + 1;

		for (ll j = 1; j <= i; j *= 6) {
			dp[i] = min(dp[i - j] + 1, dp[i]);
		}

		for (ll j = 1; j <= i; j *= 9) {
			dp[i] = min(dp[i - j] + 1, dp[i]);
		}
	}

	cout << dp[N];
	


	system("PAUSE");
}

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

int main(){
  int a;
  cin>>a;
  vector<long long>c(a),ans(a);
  for(int i=0;i<a;i++){
    cin>>c[i];
  }
  if(a%2==1){
    for(int i=0;i<a;i++){
      if(i%2==1){
        ans[(a+i)/2]=c[i];
      }
      else{
        ans[(a-i-1)/2]=c[i];
      }
    }
  }
  else{
        for(int i=0;i<a;i++){
      if(i%2==0){
        ans[(a+i)/2]=c[i];
      }
      else{
        ans[(a-i-1)/2]=c[i];
      }
    }
  }
      for(int i=0;i<a;i++){
cout<<ans[i];
        if(i!=a-1){
          cout<<" ";
        }
        else{
          cout<<endl;
        }
    }
  }

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char dp[1001][1001]; ll dpt[1001][1001];

ll solve(ll s,ll e,ll n,ll m)
{
    if(s==n || e==m)
        return 0;
    if(s==n-1 && e==m-1)
        return 1;
    if(dpt[s][e]!=-1)
        return dpt[s][e];
    if(dp[s][e]=='#')
        return 0;
    ll a=0;
    a=(solve(s+1,e,n,m)%1000000007+solve(s,e+1,n,m)%1000000007)%1000000007;
    dpt[s][e]=a;
    return a;
}

int main()
{
    ll n,m,i,j,k;
    cin>>n>>m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>dp[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            dpt[i][j]=-1;
        }
    }
    ll s=solve(0,0,n,m);
    cout<<s<<endl;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000000+7;

int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  
  bool NG=false;
  
  if(N%2==0){
    for(int i=0;i<N;i++){
      if(A.at(i)/2*2+1!=i/2*2+1)
        NG=true;
    }
  }
  else{
    for(int i=0;i<N;i++){
      if(ceil((double)i/2)*2!=ceil((double)A.at(i)/2)*2)
        NG=true;
      //cout<<ceil((double)i/2)*2<<endl;
    }
  }
  
  vector<ll>pow2(100001);
  pow2.at(0)=1;
  for(int i=1;i<100001;i++)
    pow2.at(i)=pow2.at(i-1)*2%mod;
  
  if(NG)
    cout<<0;
  else{
    cout<<pow2.at(N/2*2/2);
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>

#define P 1000000007

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

int n;
int main() {
    cin >> n; 
    vi vc; vc.resize(2*n);

    for (int i = 0; i < 2*n; ++i) cin >> vc[i];

    sort(vc.begin(), vc.end());

    int ans = 0;
    int temp = INT_MAX;
    for (int i = 0; i < 2*n; ++i) {
        if (i % 2) {
            ans += min(temp, vc[i]);
            
        } else {
            temp = vc[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC134
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] b = new int[N + 1];
            for (int i = N; 0 < i; i--)
            {
                int count = 0;
                int j = 1;
                while (i * j <= N)
                {
                    count += b[i * j];
                    j++;
                }

                if (count % 2 != a[i - 1]) { b[i] = 1; }
                else { b[i] = 0; }
            }

            List<int> list = new List<int>();
            int index = 0;
            foreach (var item in b)
            {
                if (item == 1) { list.Add(index); }
                index++;
            }

            Console.WriteLine(list.Count());
            foreach (var item in list)
            {
                Console.Write(item);
                Console.Write(' ');
            }
            if (list.Count != 0) Console.WriteLine();
        }
    }
}

Measured memory_bytes: 32216
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (A < B) {
    cout << "Bob" << endl;
  } else if (A > B) {
    cout << "Alice" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b = inpl()
res = -1
for i in range(10**6):
    if int(i*0.08) == a and int(i*0.1) == b:
        res = i
        break
print(res)

Measured memory_bytes: 65896
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;

#define lld long long

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int w,h; cin >> h >> w;
    int a,b; cin >> a >> b;
    cout << w*h-a*w-b*h+a*b << endl; return 0;
}

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


using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end) \
    for (ll index = beg; index < N; ++index)

#define DEBUG(x) \
    std::cout << #x << " : " << x << "\n"


static const ll MAX_N = (int)1e5;

int main() {

    ll N;
    array<ll, MAX_N> A;

    cin >> N;
    
    FOR_RANGE(i, 0, N) {
        cin >> A[i];
    }

    // 累積GCD
    array<ll, MAX_N> gcdFromLeft, gcdByRight;
    gcdFromLeft.front() = A.front();
    gcdByRight[N - 1] = A[N - 1];

    FOR_RANGE(i, 1, N) {
        gcdFromLeft[i] = calcGCD(gcdFromLeft[i - 1], A[i]);
        //DEBUG(gcdFromLeft[i]);
        gcdByRight[N-i - 1] = calcGCD(A[N-1 - i], gcdByRight[N - i]);
        //DEBUG(gcdByRight[i]);
    }

    ll maxGCD = 1;
    FOR_RANGE(skip, 0, N) {
        ll gcd;
        if (skip == 0)
            gcd = gcdByRight[1];
        else if (skip == N - 1)
            gcd = gcdFromLeft[N - 2];
        else
            gcd = calcGCD(gcdFromLeft[skip - 1], gcdByRight[skip + 1]);

        maxGCD = max(maxGCD, gcd);
    }

    cout << maxGCD;

    return 0;
}



Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))

    # O(n^2 * 2^n)
    state_to_score = [0] * (1 << n)
    for U in range(1 << n):
        for i in range(n):
            if (U >> i) & 1 == 0:
                continue
            for j in range(i):
                if (U >> j) & 1:
                    state_to_score[U] += A[i][j]

    # dp[i][U] : i まで見て U <= {1, ..., n} を grouping したときの max
    # msb(U) = i ならば dp[i][U] = dp[i + 1][U] = ... = dp[n - 1][U] なので dp は使いまわせる
    # dp[i + 1][U | 1 << (i + 1)] = max((V + {i + 1} の score) + dp[i][W]) for all V + W = U
    dp = [-INF] * (1 << n)
    dp[0] = 0
    for i in range(n): # 既に U = 0, ..., 2^i - 1 までは確定している
        for U in range(1 << i): # O(2^i) これから 2^i, ..., 2^(i + 1) - 1 を確定させる
            V = U
            while V: # これだと V = 0, W = U の場合が処理されない
                W = U ^ V
                dp[U | 1 << i] = max(dp[U | 1 << i], state_to_score[V | 1 << i] + dp[W])
                V = (V - 1) & U
            # 別処理
            dp[U | 1 << i] = max(dp[U | 1 << i], state_to_score[1 << i] + dp[U])


    # 計算量は sum_{0 <= i < n} sum_{0 <= U < 2^i} 2 ^ popcount(U)
    # = sum_{0 <= i < n} sum_{0 <= k <= i} iCk * 2^k = (3^n - 1) / 2
    print(dp[-1])
resolve()

Measured memory_bytes: 45148
a[101];
int main(){
	int n,t,x,i;
	scanf("%d",&n);
	for(i=0;i<3;i++)for(scanf("%d",&t);t--;a[x]|=(1<<i))scanf("%d",&x);
	for(x=i=0;++i<=n;)x+=(a[i]&5)==4||(a[i]&6)==6;
	printf("%d\n",x);
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c || a == c && a != b || b == c && b != a) {
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> lst_a(n, 0);
  rep(i, n) cin >> lst_a[i];

  bool flag = true;
  int sortd_idx = 0;
  int count_swap = 0;
  while (flag) {
    flag = false;
    rep(i, n - 1) {
      int idx = n - i - 1;
      if (lst_a[idx] < lst_a[idx - 1]) {
        int tmp = lst_a[idx - 1];
        lst_a[idx - 1] = lst_a[idx];
        lst_a[idx] = tmp;
        flag = true;
        count_swap++;
      }
    }
  }
  rep(i, n - 1) cout << lst_a[i] << " ";
  cout << lst_a[n - 1] << endl;
  cout << count_swap << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 924844033
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int dp[2019][2019];
int ans[4019];
int ne[4019];
int used[4019];
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
int dfs(int x, int y){
	if( x < 0 || y < 0 || (x+1)/2 < y )return 0;
	if( dp[x][y] > 0 ) return dp[x][y];
	if( y == 0 ){
		dp[x][y] = 1;
		return 1;
	}
	if( y == 1 ){
		dp[x][y] = x;
		return x;
	}
	dp[x][y] += dfs( x-2, y-1 ) + dfs( x-1, y );
	dp[x][y] %= inf;
	return dp[x][y];
}
signed main(){
	int n,k;
	cin>>n>>k;
	setkaijo(4019);
	vector<int> v;
	ans[0] = 1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dfs(i,j);
		}
	}
	for(int i=1;i<=n;i++){
		if( used[i] == 0 ){
			int len = ( n - i ) / k;
			int cur = i;
			for(int j=0;j<=len;j++){
				used[cur] = 1;
				if( cur <= n ) cur += k+n ;
				else cur -= n-k;
			}
			v.pb(len);
		}
		if( used[n+i] == 0 ){
			int len = ( n - i ) / k;
			int cur = n+i;
			for(int j=0; j<=len;j++){
				used[cur] = 1;
				if( cur <= n ) cur += k+n ;
				else cur -= n-k;
			}
			v.pb(len);
		}
	}
	for(int i=0;i<v.size();i++){
		//cout<<v[i]<<endl;
		for(int j=0;j<=(v[i]+1)/2;j++){
			for(int p=0;p<=n;p++){
				ne[j+p] += ans[p] * dp[v[i]][j];
				ne[j+p] %= inf;
			}
		}
		for(int j=0;j<=n;j++){
			ans[j] = ne[j];
		}
		for(int j=0;j<=n+(v[i]+1)/2;j++){
			ne[j]=0;
		}
	}	
	int kot = 0, hik = 0;
	for(int i=1;i<=n;i++){
		if( i% 2 == 1 ){
			hik += ans[i] * ka[n-i];
			hik %= inf;
		}
		else{
			hik += (inf - ans[i]) * ka[n-i];
			hik %= inf;
		}
	}
	kot = ka[n] + inf - hik;
	kot %= inf;
	cout<<kot<<endl;
	return 0;
}

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


int main()
{
  int x, y, z;

  cin >> x >> y >> z;
  x -= 2*z;
  
  int i=0, cnt=0;
  while ( 1 ) {
    if ( i%2 == 0 ) {
      x -= y;
      if ( x < 0 ) break;
      cnt++;
    } else {
      x -= z;
      if (x < 0 ) break;
    }
    i++;
  }
  cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

typedef long long ll;

double dist[8][8];
struct point
{
    int x;
    int y;
};

point points[8];

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

int factrial(int a)
{
    if(a == 1) return 1;
    else
    {
        return a * factrial(a - 1);
    }
}

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

    for(int i = 0; i < n; i++)
    {
        cin >> points[i].x;
        cin >> points[i].y;
    }

    double sum = 0;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            sum += d(points[i], points[j]);
        }
    }

    sum *= 2 * factrial(n - 1);

    vector<int> a(n);
    for(int i = 0; i < n; i++) a.at(i) = i;
    int k = 0;

    do{
        k++;
    }while(next_permutation(a.begin(), a.end()));

    printf("%.10f\n", sum / k);
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define nrep(i,a,b) for(ll i=a;i>=b;i--)

using namespace std;
int main()
{
	fast;
	string s;
	cin>>s;
	if(s[0]=='S')
	{
		cout<<"Cloudy\n";
	}
	else if(s[0]=='C')
	{
		cout<<"Rainy\n";
	}
	else
	{
		cout<<"Sunny\n";
	}
}

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

const long long mod = 1e9 + 7;

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

  vector<long long> C(N);
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
  sort(C.begin(), C.end());

  long long coef = 1; // coef = 2 ^ (2N - 2)
  for(int i = 0; i < N - 1; i++){
    coef *= 4;
    coef %= mod;
  }

  long long ans = 0;
  for(int i = 0; i < N; i++){
    ans += coef * C[i] % mod * (N - i + 1) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    if(s[1]==s[2]){
        if(s[0]==s[1]||s[2]==s[3])puts("Yes");
        else puts("No");
    }
    else puts("No");
    return 0;
}


Measured memory_bytes: 3632
import math
import copy
from collections import Counter
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

a=(input())
b=input()


def func():
    if b.count("R")>len(b)/2:
        return "Yes"
    return "No"
 
print(func())


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int thou = N/500;
    N -= 500*thou;
    int fiv = N/5;
    cout << thou*1000 + fiv*5 << endl;
    return 0;
}

Measured memory_bytes: 256