akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())
lst = [True]*(N*2)
for i in range(2,int(math.sqrt(N*2))+1):
  for j in range(i+i,N*2,i):
    lst[j] = False
for i in range(N,len(lst)):
  if lst[i]:
    print(i)
    break

Measured memory_bytes: 10268
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;

const long MOD = (long)1e9+7;

int main() {
    int n;
    long r=1;
    string s;
    cin >> n >> s;
    vector<int> counter(26,0);
    for(int i=0; i<n; i++){
        counter.at(s[i] - 'a')++;
    }

    for(int i=0; i<26; i++){
        r = (r * (counter[i] + 1)) % MOD;
    }

    printf("%ld\n", r-1);
}

Measured memory_bytes: 512
from collections import defaultdict
import itertools
N = int(input())
d = defaultdict(int)
for _ in range(N):
  s = input()
  if s[0] in 'MARCH':
    d[s[0]] += 1

ans = 0
if len(d.keys()) >= 3:
  for c in itertools.combinations(d.values(), 3):
    ans += c[0] * c[1] * c[2]

print(ans)

Measured memory_bytes: 3316
E=`seq \`dd\`|factor`.scan(/ \d+/).sort.chunk &:b;a,b,c,d,e=[1,3,13,23,73].map{|m|E.count{|_,x|x[m]}};p e+d*~-a+c*~-b+b*~-b*(a-2)/2

Measured memory_bytes: 2228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_1_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> li = new List<int>();
            for (int i = 0 ; i < n ; i++)
            {
                int[] line = ReadIntAr();
                switch (line[0])
                {
                    case 0: li.Add(line[1]);break;
                    case 1: Console.WriteLine(li[line[1]].ToString()); break;
                    case 2: li.RemoveAt(li.Count - 1); break;
                }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 21384
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		int N = Integer.parseInt(line);
		line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] H = new int[lines.length];

		for (int i = 0; i < lines.length; i++) {
			H[i] = Integer.parseInt(lines[i]);
		}

		boolean flag = true;

		for(int i=N-1; i>0; i--) {
			if(H[i]< H[i-1]) {
				if(H[i-1]-1 <= H[i]) {
					H[i-1]--;
				}else {
					flag = false;
					break;
				}
			}
		}

		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 46868
#include<bits/stdc++.h>
#define re register
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const LL inf=1e16;const int maxn=2005;
struct E{int v,nxt;}e[maxn<<1];char S[maxn];
int n,num,head[maxn],vis[maxn],s[maxn];LL ans,dp[maxn];
inline void add(int x,int y) {
	e[++num].v=y;e[num].nxt=head[x];head[x]=num;
	e[++num].v=x;e[num].nxt=head[y];head[y]=num;
}
LL dfs(int x,int fa) {
	s[x]=vis[x];
	LL mx=0,sum=0;int son=0;
	for(re int i=head[x];i;i=e[i].nxt) {
		if(e[i].v==fa) continue;
		LL t=dfs(e[i].v,x);
		s[x]+=s[e[i].v];
		if(t>mx) mx=t,son=e[i].v;
		sum+=t+s[e[i].v];
		//printf("%d %d %lld\n",x,e[i].v,t);
	}
	mx+=s[son];
	if(mx<=sum-mx) dp[x]=sum&1ll;
	else {
		if(dp[son]+s[son]<=sum-mx) dp[x]=sum&1ll;
		else dp[x]=dp[son]+s[son]+mx-sum; 
	}
	//printf("%d %lld %d\n",x,sum,s[x]);
	return sum;
}
int main() {
	n=read();scanf("%s",S+1);ans=inf;
	for(re int i=1;i<=n;i++)vis[i]=S[i]-'0';
	for(re int x,y,i=1;i<n;i++)add(read(),read());
	for(re int i=1;i<=n;i++) {
		LL tot=dfs(i,0);
		if(dp[i]) continue;
		ans=min(ans,tot>>1ll);
		//printf("%d %lld\n",i,tot);
	}
	if(ans==inf)puts("-1");else printf("%lld\n",ans);
	return 0;
}


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

using namespace std;
int main(){

  int n, k, a[100], ans=0;
  cin >> n >> k;

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

  for(int i=0; i<n; i++){
    if(a[i]<=(k-a[i])){
      ans+=a[i]*2;
    } else {
      ans+=(k-a[i])*2;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
'use strict';

function Main(input) {
  const tmp = input.split('\n');
  const A = tmp[0].split('').reverse();
  const B = tmp[1].split('').reverse();
  const C = tmp[2].split('').reverse();

  let winner;
  let turn = 1;
  let next = A.pop();
  while (turn) {
    switch (next) {
      case 'a':
        next = A.pop();
        if (next == undefined) {
          winner = 'A';
          turn = 0;
        }
        break;
      case 'b':
        next = B.pop();
        if (next == undefined) {
          winner = 'B';
          turn = 0;
        }
        break;
      case 'c':
        next = C.pop();
        if (next == undefined) {
          winner = 'C';
          turn = 0;
        }
        break;
    }
  }
  console.log(winner);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  while (1) {
    int n; cin >> n;
    if (n == 0) break;

    int t = 0;
    rep(i, 9) {
      int k;
      cin >> k;
      t += k;
    }
    cout << n - t << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), m = ni();
        int l = 1, r = n;
        while(m-->0){
            l = Math.max(l, ni());
            r = Math.min(r, ni());
        }
        pn(Math.max(0, r-l+1));
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)998244353, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)2e5+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 43264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
using namespace std;
int arr[11][1001];
bool arr2[11];
int ans;
int h,w,k;
int culc(int hc){
	int cur=0;
	int ind=1;
	int d=hc;
	//cout<<d<<endl;
	while(d>0){
		if(d&1){arr2[ind]=true;}
		ind++;
		d=d>>1;
	}
	ind=0;
	for(int i=1;i<=h-1;i++)if(arr2[i]){ind++;}
	//cout<<ind<<endl;
	arr2[h]=true;
	arr2[0]=true;

	while(cur<w){
		bool st=true;
		for(int inc=1;inc+cur<=w;inc++){
			
			for(int i=0;i<h&&st;i++){
				if(arr2[i])
					for(int j=i+1;j<=h&&st;j++){
						if(arr2[j]){
							if(arr[j][cur+inc]+arr[i][cur]-arr[i][cur+inc]-arr[j][cur]>k){
								st=false;							
							}
							break;
						}
					}			
			}
			if(st&&inc+cur==w){
					//cout<<cur<<" "<<inc<<" "<<hc<<endl;
					return ind;
			}
			if(!st){
				if(inc==1){return h*w;}
				ind++;
				cur=cur+inc-1;
				st=true;
				//cout<<cur<<" "<<cur-inc+2<<endl;
				break;
			}	
		}
	}
	return ind;
}
				
int main(){
	
	cin>>h>>w>>k;
	ans=h*w;
	
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++){
			if(s[j]=='1')arr[i+1][j+1]=1;
			else arr[i+1][j+1]=0;
		}
	}
	for(int i=0;i<=h;i++)arr[i][0]=0;
	for(int j=0;j<=w;j++)arr[0][j]=0;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)arr[i][j]=arr[i][j]+arr[i][j-1];
	for(int i=2;i<=h;i++)for(int j=1;j<=w;j++)arr[i][j]=arr[i][j]+arr[i-1][j];
	for(int i=0;i<(1<<(h-1));i++){
		for(int j=0;j<=h;j++)arr2[j]=false;
		//cout<<'a'<<i<<endl;
		ans=min(ans,culc(i));
	}
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,max=0,a[10],sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    max=a[0];
    for(i=1;i<n;i++){
        if(max<a[i])
            max=a[i];
    }
    for(i=0;i<n;i++){
            sum=sum+a[i];
    }
    if(sum-max>max)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 1636
N = int(input())
l = len(str(N))
if l == 1:
  print(N)
elif l % 2 == 0:
  n = l//2
  print(int((100**n-1)/11))
elif l % 2 == 1:
  n = l//2
  print(int((100**n-1)/11 + N+1 - 10**(l-1)))

Measured memory_bytes: 3060
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    if A[i]==B[i]==C[i]:
        continue
    elif A[i]==B[i] or B[i]==C[i] or C[i]==A[i]:
        ans += 1
    else:
        ans += 2

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
class Cube {
public:
	int f[6];
	Cube() {}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
};
bool eq(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++)
		if (c1.f[i] != c2.f[i])return false;
	return true;
}
bool equal(Cube c1, Cube c2) {
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			if (eq(c1, c2))return true;
			c1.roll_z();
		}
		if (i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return false;
}
int main() {
	Cube c1,c2;
	for (int i = 0; i < 6; i++)cin >> c1.f[i];
	for (int i = 0; i < 6; i++)cin >> c2.f[i];
	if (equal(c1, c2))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long cnt[N] = {};
int main() {
    int n, q, x;
    long long sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        sum += x;
        cnt[x]++;
    }
    cin >> q;
    int a, b;
    while (q--) {
        cin >> a >> b;
        sum -= a * cnt[a];
        sum += b * cnt[a];
        cnt[b] += cnt[a];
        cnt[a] = 0;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 4292
#include<iostream>
#include<array>
#include<algorithm>
#include<utility>

constexpr const char* const str = "SHCD";

size_t f(char c){
    if(c == 'S'){
        return 0;
    }else if(c == 'H'){
        return 1;
    }else if(c == 'C'){
        return 2;
    }else{
        return 3;
    }
}

int main(){

    size_t n;
    std::cin >> n;

    std::array<std::array<bool, 13>, 4> mat = {};

    for(size_t i = 0; i < n; i++){
        char c;
        size_t x;
        std::cin >> c >> x;
        mat[f(c)][x - 1] = true;
    }

    for(size_t i = 0; i < mat.size(); i++){
        for(size_t j = 0; j < mat[i].size(); j++){
            if(!mat[i][j]){
                std::cout << str[i] << ' ' << j + 1 << std::endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 0;
		int min = 1000;
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(max < a ) max = a;
			if(min > a ) min = a;
		}

		System.out.println(max - min);
	}
}


Measured memory_bytes: 21972
A, B, C, D = map(int, input().split())
U = B - A + 1

MofD = 0
MofCD = 0

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)


def sten(st, en, x):
    if x == 1:
        return en - st + 1
    st = st // x if st % x == 0 else st // x + 1
    en = en // x
    st *= x
    en *= x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
if C != D:
    MofD = sten(A, B, D)
    MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)


Measured memory_bytes: 3064
#include<stdio.h>

void swap(int *a, int *b);
int main (){
	int list[5];
	int i,j,k;
	int sorted=0;
	for(i=0;i<5;i++){
		scanf("%d",&list[i]);
	}
	for(i=0;i<5;i++){
		for(j=0;j<4-sorted;j++){
			if(list[j]<list[j+1]){
				swap(&list[j],&list[j+1]);
			}
		}
		sorted++;
	}
	for(i=0;i<4;i++){
		printf("%d ",list[i]);
	}
	printf("%d\n",list[4]);
	return 0;
}


void swap(int *a, int *b){
	int buf = *a;
	*a = *b;
	*b = buf;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int res=0;
    for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) for(int k=j+1;k<n;k++) if(a[i]<a[j]&&a[j]<a[k]&&a[i]+a[j]>a[k]) res++;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3664
N, C = map(int, input().split())
time = 10**5+1
channel_list = [[0 for _ in range(time)]for _ in range(C)]
count_list = [0 for _ in range(time)]
for i in range(N):
    s, t, c = map(int, input().split())
    channel_list[c-1][s-1] += 1
    channel_list[c-1][t] -= 1

for i in range(C):
    for t in range(1, time):
        channel_list[i][t] += channel_list[i][t-1]
        if channel_list[i][t] >= 1:
            count_list[t] += 1

print(max(count_list))


Measured memory_bytes: 27444
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int N, x;
	cin >> N >> x;

	vector<int> a(N);
	rep(i, N) cin >> a[i];
	sort(ALL(a));

	int tmp = x;
	int ans = 0;
	rep(i, N-1) {
		tmp -= a[i];
		if (tmp >= 0) {
			ans++;
		}
		else{
			break;
		}
	}
	
	if (tmp == a[N - 1]) {
		cout << ans + 1 << endl;
	}
	else {
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ipair():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def spair():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    else:
        return -1

###########


n,k = ipair()
d = map(int,raw_input().split(" "))

while 1:
    flag = 1
    for a in list(str(n)):
        if index(d,int(a))!=-1:
            flag = 0
    if flag:
        print n
        break
    n += 1

Measured memory_bytes: 2944
let n = Scanf.scanf " %d" (+) 0
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let i, ans = ref 0, ref 0
let _ = while !i < n do if ps.(!i) = !i + 1 then (if !i + 1 < n && ps.(!i + 1) = !i + 2 then incr i; incr ans); incr i done; Printf.printf "%d\n" !ans

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define MAX_N 300005
#define MOD 1000000007

//どこかでmake()することを忘れずに
ll inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll comb(int a,int b)
{
	if(a<b){
		return 0;
	}
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

int main(){
    make();
    ll h,w,n;
    cin >> h >> w >> n;
    vector<ll> r(n+2),c(n+2);
    vector<pair<ll,ll> > p(n+2);
    p[0] = {1,1};
    p[n+1] = {h,w};
    r[0] = 1;
    c[0] = 1;
    r[n+1] = h;
    c[n+1] = h;
    rep(i,n){
        cin >> r[i+1] >> c[i+1];
        p[i+1] = {r[i+1],c[i+1]};
    }
    sort(p.begin(),p.end());
    n +=2;
    rep(i,n){
        r[i] = p[i].first;
        c[i] = p[i].second;
    }
    vector<vector<pair<ll,ll> > > g(n);
    rep(i,n-1){
        rep(j,n){
            if(i!=j){
                if(r[i]<=r[j]&&c[i]<=c[j]){
                    g[i].push_back(MP(j,comb(r[j]-r[i]+c[j]-c[i],r[j]-r[i])));
                }
            }
        }
    }
    vector<pair<ll,ll> > v(n+2);
    v[0] = {0,1};
    rep(i,n){
        for(auto x:g[i]){
            ll k = x.first;
            ll s = x.second;
            v[k].first += (s*v[i].second)%MOD;
            v[k].first %= MOD;
            v[k].second += (s*v[i].first)%MOD;
            v[k].second %= MOD;
        }
    }
    // rep(i,n){
    //     cerr << v[i].first << " " << v[i].second << endl;
    // }
    cout << (v[n-1].first-v[n-1].second+(ll)MOD)%MOD << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	int N;
	string S;

	cin >> N;
	cin >> S;

	int sum = 0;
	for (int i = 0; S[i+2]; ++i) {
		if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
			++sum;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    ll n, K, x, y;
    vector<pair<ll, ll> > d;
    vector<ll> vx, vy;
    cin >> n >> K;
    rep(i, n){
        cin >> x >> y;
        d.pb(mp(x, y));
        vx.pb(x);
        vy.pb(y);
    }
    sort(all(vx));
    sort(all(vy));
    ll ans = LINF;
    rep(i, n){
        rep(j, n){
            rep(k, n){
                rep(l, n){
                    int cnt = 0;
                    rep(p, n){
                        if(vx[i] <= d[p].first && d[p].first <= vx[k] && vy[j] <= d[p].second && d[p].second <= vy[l]){
                            cnt++;
                        }
                    }
                    if(K <= cnt)ans = min(ans, abs(vx[i] - vx[k]) * abs(vy[j] - vy[l]));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.util.stream.*;
import java.io.*;

class Graph {
  public ArrayList<Integer>[] adjacency;

  Graph(int n){
    adjacency = new ArrayList[n];
    for(int i = 0; i < n; i++){
      adjacency[i] = new ArrayList<Integer>();
    }
  }

  public void add_edge(int from, int to, boolean is_directed){
    adjacency[from].add(to);
    if(!is_directed){
      adjacency[to].add(from);
    }        
  }
}

public class Main {

  static int n, m, ans;
  static int[] h;

  static Graph g;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    m = Integer.parseInt(in[1]);

    in = br.readLine().split(" ");
    h = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    g = new Graph(n);

    for(int i = 0; i < m; i++){
      in = br.readLine().split(" ");
      g.add_edge(Integer.parseInt(in[0]) - 1, Integer.parseInt(in[1]) - 1, false);
    }
    
    br.close();

    ans = 0;

    for(int i = 0; i < n; i++){
      boolean good = true;
      for(int nex : g.adjacency[i]){
        if(h[i] <= h[nex]) good = false;
      }

      if(good) ans++;
    }

    PrintWriter out = new PrintWriter(System.out);
    out.println(ans);
    out.flush();

  }
}

Measured memory_bytes: 70236
H, W, K = [int(i) for i in input().split()]
C = []
for i in range(H):
    temp = list(input())
    C.append(temp)

    answer = 0
for row in range(2 ** H):
    for column in range(2 ** W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (row >> i) % 2 == 1:
                    continue
                if (column >> j) % 2 == 1:
                    continue
                if C[i][j] == "#":
                    black += 1
        if black == K:
            answer += 1

print(answer)

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

int main(){
  int N,ans=0;
  cin >> N;
  vector<string>blue(N);
  
  for(int i=0; i<N ; i++){
    cin >> blue.at(i);
    }
  
  int M;
  cin >> M;
  vector<string>red(M);
  
  for(int i=0; i<M ; i++){
    cin >> red.at(i);
    }
  
  
  for(int i=0; i<N ;i++){
    int sum2=0;  //合計は初期化
    
    for(int j=0; j<N ;j++){   //青のカードで青のカードと文字列が一致しているものはあるか？
      
      if( blue.at(i) == blue.at(j) ){  //青のカード同じなら+1
          sum2++;}
    }
      
      for(int k=0; k<M ; k++ ){               //赤のカードで青のカードを文字列が一致しているものはあるか？
        
        if( blue.at(i) == red.at(k) ){  //赤のカード同じならば-1
          sum2--;}
      
    }
    
    if( ans <= sum2 ){
      ans = sum2; }    //最大の値を答えにする、最大の値を上書き？
    
  }
  
  cout << ans << endl;
}

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





int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  ll n,k;
	cin>>n>>k;
	if(k*2-1<=n){
		cout<<"YES";
		return 0;
	}cout<<"NO";
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

int main()
{
	int a, b;

	cin >> a >> b;

	cout << max(a - b * 2, 0) << endl;
	

	return 0;

}

Measured memory_bytes: 256
N, W = map(int, input().split())
w = [0]*N
v = [0]*N

for i in range(N):
    w[i], v[i] = map(int, input().split())
    
#dp[3][5] 3個目までの荷物で5容量のときの最大value
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1, N+1):
    for j in range(W+1):
        if j-w[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])

Measured memory_bytes: 120428
N, Y = map(int,input().split())
c = Y//1000
for x in range(N+1):
    if (c-N-9*x) % 4 == 0:
        y = (c-N-9*x)//4
        if 0<=y<=N-x:
            print(x,y,N-x-y)
            exit(0)
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);

    int M =(n-1)*(n-2)/2;
    if(k>M) {
        printf("-1\n"); return 0;
    }

    vector<pair<int,int> > z;
    int i,j;
    int cnt=M;
    for(i=1; i<n; i++) {
        z.push_back(make_pair(0,i));
    }

    if(cnt>k) {
        for(i=1; i<n; i++) {
            for(j=i+1; j<n; j++) {
                z.push_back(make_pair(i,j));
                cnt--;
                if(cnt==k) break;
            }
            if(cnt==k) break;
        }
    }
    printf("%d\n", (int)z.size());
    for(i=0; i<(int)z.size(); i++) {
        printf("%d %d\n", z[i].first+1, z[i].second+1);
    }

    return 0;
}


Measured memory_bytes: 384
import math
import functools

def main():
    n = int(input())
    ans = solve(n)
    print(ans)

def solve(n):
    if n == 1:
        return 0
    cnt = [[i] * (i + 1) for i in range(20)]
    cnt = [i for inner in cnt for i in inner]
    factor = prime_factorization(n)
    ans = 0
    for p, e in factor:
        ans += cnt[e]
    return ans

def prime_factorization(n):
    nn = n
    lim = math.floor(n ** (1 / 2))
    primelist = prime_list(lim)
    ans = []
    for p in primelist:
        if n % p == 0:
            e = 0
            while n % p == 0:
                e += 1
                n /= p
            ans.append((p, e))
    if ans == []:
        ans.append((n, 1))
    tmp = functools.reduce(lambda x, y: x * y, [p ** e for p, e in ans])
    if tmp != nn:
        ans.append([int(nn / tmp), 1])
    return ans

def prime_list(n):
    if n < 2:
        return []
    tmp = [True for i in range(n + 1)]
    tmp[:2] = [False, False]
    for i in range(n + 1):
        if tmp[i]:
            for j in range(2 * i, n + 1, i):
                tmp[j] = False
    ans = [num for num, flag in enumerate(tmp) if flag]
    return ans

def test():
    n = int(input())
    ans = prime_factorization(n)
    print(*ans, sep = '\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 20660
program sample
    implicit none
    character(200000)::s,t
    integer(8) :: i,j,m,n,a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) s
    n=len_trim(s)
    if (mod(n,2)==0)then
        m=n/2
    else
        m=(n+1)/2
    end if
    a=0
    b=0
    do i=1,n
        if (s(i:i) .eq. 'W')then
            b=b+a
        else
            a=a+1
        end if
    end do


    write(*,*) b
  
    stop
end program sample
  



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

using namespace std;

#define CK(n, a, b) (a <= n && n < b)

int main() {
  int N;
  
  while(cin >> N && N) {
    vector<string> G(N);
    for(int i=0; i<N; i++) {
      cin >> G[i];
    }
    
    int grid[N][N];
    for(int i=0; i<N; i++) {
      for(int j=0; j<N; j++) {
	grid[i][j] = G[i][j] - '0';
      }
    }
    
    int ans = 0;
    
    // right
    for(int i=0; i<N; i++) {
      int cnt = 0;
      for(int j=0; j<N; j++) {
	if(!grid[i][j]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }
    
    // down
    for(int j=0; j<N; j++) {
      int cnt = 0;
      for(int i=0; i<N; i++) {
	if(!grid[i][j]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }
    
    // right down
    for(int i=0; i<N; i++) {
      int sx = i, sy = 0;
      int cnt = 0;
      for(int k=0; k<N; k++) {
	if(!CK(sy+k, 0, N) || !CK(sx+k, 0, N)) break;
	if(!grid[sy+k][sx+k]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }
    for(int i=0; i<N; i++) {
      int sx = 0, sy = i;
      int cnt = 0;
      for(int k=0; k<N; k++) {
	if(!CK(sy+k, 0, N) || !CK(sx+k, 0, N)) break;
	if(!grid[sy+k][sx+k]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }


    // left down
    for(int i=0; i<N; i++) {
      int sx = N-1, sy = i;
      int cnt = 0;
      for(int k=0; k<N; k++) {
	if(!CK(sy+k, 0, N) || !CK(sx-k, 0, N)) break;
	if(!grid[sy+k][sx-k]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }
    for(int i=0; i<N; i++) {
      int sx = i, sy = 0;
      int cnt = 0;
      for(int k=0; k<N; k++) {
	if(!CK(sy+k, 0, N) || !CK(sx-k, 0, N)) break;
	if(!grid[sy+k][sx-k]) cnt = 0;
	else cnt ++;
	ans = max(ans, cnt);
      }
    }
      
    cout << ans << endl;
  }
  
  return 0;
}

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

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var D = RL2IE().ToList();
            var A = D[0];
            var B = D[1];
            var C = D[2];
            var K = c2i(RL());

            for (int i = 0; i < K; i++)
            {
                if (A >= B) B *= 2;
                else if (B >= C) C *= 2;
                else break;
            }
            var ret = A < B && B < C;
            Console.WriteLine(bool2ret(ret));

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

template<class T> inline bool chmax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

char s[3100];
char t[3100];
char ans[3100];
long dp[3100][3100];

int main(){
	scanf("%s%s", s, t);
	int n = strlen(s);
	int m = strlen(t);
	dp[0][0] = 0;
	for(int i=0; i < n; i++) {
		for(int j=0; j < m; j++) {
			if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
			chmax(dp[i+1][j+1], dp[i+1][j]);
			chmax(dp[i+1][j+1], dp[i][j+1]);
		}
	}

	int idx = dp[n][m] - 1;
	while(n > 0 && m > 0) {
		if(dp[n][m] == dp[n-1][m]) n--;
		else if(dp[n][m] == dp[n][m-1]) m--;
		else {ans[idx--] = s[n-1]; n--; m--;}
	}
	printf("%s\n", ans);
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	ll ans=0;
	n/=2;
	for(ll i=5; i<=n; i*=5) ans+=n/i;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

bool solve(vector<int> &va) {
  map<int, int> cnts;
  for (auto &a : va) {
    cnts[a]++;
  }

  if (va.size() % 3 != 0) {
    return cnts[0] == va.size();
  }

  bool ans;
  switch (cnts.size()) {
    case 1: {
      ans = cnts[0] == va.size();
      break;
    }
    case 2: {
      ans = cnts[0] == va.size() / 3;
      break;
    }
    case 3: {
      int xor_all = accumulate(cnts.begin(), cnts.end(), 0,
                               [](int a, auto b) { return a ^ b.first; });
      ans = xor_all == 0 && all_of(cnts.begin(), cnts.end(), [&](auto p) {
              return p.second == va.size() / 3;
            });
      break;
    }
    default: {
      ans = false;
      break;
    }
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  cout << (solve(va) ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN 64

int n, m;
int q;
int a[MAXN][4];
int ret = 0;

set<pair<pair<int, int>, vector<int> > > s;

int bitcnt(int mask) {
	int ret = 0;
	while (mask) {
		mask &= mask - 1;
		ret++;
	}
	return ret;
}

int check(vector<int> cur) {
	reverse(cur.begin(), cur.end());
/*	for (int i = 0; i < cur.size(); i++) {
		cout << cur[i] << " ";
	}
	cout << endl;
*/	int curbest = 0;
	for (int i = 0; i < q; i++) {
		if (max(a[i][0], a[i][1]) > cur.size()) {
			continue;
		}
		if (cur[a[i][1] - 1] - cur[a[i][0] - 1] == a[i][2]) {
			curbest += a[i][3];
		}
	}
	return curbest;
}

void gen(int n, int m, vector<int> & v) {
	pair<pair<int, int>, vector<int> > p = make_pair(make_pair(n, m), v);
	if (s.count(p)) {
		return;
	}
	s.insert(p);
	if (m == 0) {
		return;
	}
	if (n == 0) {
		ret = max(ret, check(v));
		return;
	}
	v.push_back(m);
	gen(n - 1, m, v);
	v.pop_back();
	gen(n, m - 1, v);
}

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

	ret = 0;
	vector<int> v;
	gen(n, m, v);
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 49364
# coding: utf-8
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
all = p + q + r
all.sort(reverse=True)
print(sum(all[:x+y]))

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

using namespace std;

int main()
{

    int x;
    cin >> x;

    vector<bool> vs(x + 1, false);

    vs[0] = true;

    for (int i = 0; i <= x; i++)
    {
        if ((100 <= i && vs[i - 100]) || (101 <= i && vs[i - 101]) || (102 <= i && vs[i - 102])
            || (103 <= i && vs[i - 103]) || (104 <= i && vs[i - 104]) || (105 <= i && vs[i - 105]))
        {
            vs[i] = true;
        }
    }
    cout << vs[x] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll t;
    {
        ll i,j,k,l,m,n;
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
            cin>>k;
            n-=k;
        }
        if(n>=0)
            cout<<n<<endl;
        else
            cout<<-1<<endl;



    }

}



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

int main() {
  const int MOD = 1000000007;
  int N, M; cin >> N >> M;
  vector<long long> dp(N+5, 0);
  for (int i = 0; i < M; i++) {
    int a; cin >> a;
    dp.at(a) = -1;
  }
  dp.at(0) = 1;
  for (int i = 0; i < N; i++) {
    if (dp.at(i) == -1) continue;
    if (dp.at(i+1) != -1) {
      dp.at(i+1) += dp.at(i);
      dp.at(i+1) %= MOD;
    }
    if (dp.at(i+2) != -1) {
      dp.at(i+2) += dp.at(i);
      dp.at(i+2) %= MOD;
    }
  }
  cout << max(0LL, dp.at(N)) << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll H, N;
ll A[10010], B[10010];
ll dp[1010][10010];

int main()
{
  scanf( "%lld%lld", &H, &N );
  rep( i, N )
    scanf( "%lld%lld", A+i, B+i );

  rep( i, N+1 ) rep( j, H+1 )
    dp[i][j] = INF;

  dp[0][0] = 0;

  rep( i, N ) rep( j, H+1 )
  {
    dp[i+1][j] = std::min( dp[i+1][j], dp[i][j] );

    ll nj = std::min( H, j+A[i] );
    dp[i+1][nj] = std::min( dp[i+1][nj], dp[i+1][j]+B[i] );
  }

  printf( "%lld\n", dp[N][H] );

  return 0;
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int x, y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}




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

int main(){
	int S,h,m,s;
	cin>>S;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(h*3600+60*m);
	cout<<h<<':'<<m<<':'<<s<<endl;
	return 0;
	}
	

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

using namespace std;

vector<int> G[100010];
vector<int> va, vb;
bool used[100010];

void dfs(int u, vector<int> &a) {
  a.push_back(u);
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (used[v]) continue;
    used[v] = true;
    dfs(v, a);
    return;
  }
}

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

  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  used[a] = used[b] = true;

  dfs(a, va);
  dfs(b, vb);
  reverse(va.begin(), va.end());

  cout << va.size() + vb.size() << endl;
  for (int i = 0; i < va.size(); i++) {
    cout << va[i] << " ";
  }
  for (int i = 0; i < vb.size(); i++) {
    cout << vb[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int H,W,A,B;
int f[1010][1010];
int main(){
  cin >> H >> W >> A >> B;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int x = (i<B)?1:0;
      int y = (j<A)?1:0;
      if((x^y)==1)f[i][j] = 1;
      cout << f[i][j];
    }
    cout << endl;
  }
	return 0;
}


Measured memory_bytes: 5120
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        Integer[] r = new Integer[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(sc.next());
            r[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i < n; i++) {
            result += r[i] - l[i] + 1;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int m[20],n,q,A[20];
int ans(int x,int y){
  if(x==0)return 0;
  if(y>=n)return 1;
 
  if(ans(x,y+1)==0 || ans(x-A[y],y+1)==0)return 0;
  else return 1;
}
 
int main(){ 
  cin>>n; 
  for(int i=0;i<n;i++)cin>>A[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m[i];

    if(ans(m[i],0)==0)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int X = sc.nextInt();
		int Y = sc.nextInt();
	
		int ans =X+Y/2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 27024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,read().split())

x = np.arange(1,N+1,dtype=np.int64)
need = np.zeros(N,dtype=np.int32)

for _ in range(20):
    target = (x <= K-1)
    x[target] <<= 1
    need[target] += 1

counter = np.bincount(need,minlength=20)
power = np.full(20,1/2,dtype=np.float64); power[0] = 1; np.cumprod(power,out=power)

answer = (counter * power).sum() / N
print(answer)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll t;
string num;
ll  ans;
int dp[1010101];
void dfs(int current,int amari, int cnt){
  if(current == num.size() && cnt == 0){
    dp[amari]++;
    return;
  }

  // 区切る場合
  int mm = cnt*10 + (num[current]-'0');
  if(amari - mm >= 0) dfs(current+1, amari-mm, 0);
  else return;

  // 区切らない場合
  if(current+1 < num.size()) dfs(current+1, amari, mm);

}

VI ansDFS(int current, int amari, int cnt, VI v){
  VI notAns;
  if(current == num.size()){
    if(ans == amari && cnt == -1) {
      return v;
    }
    else return notAns;
  }
  cnt = max(0,cnt);
  VI ansV0;
  VI ansV1;

  int mm = cnt*10 + (num[current]-'0');
  if(amari - mm < 0) return notAns;

  // 区切らない場合
  if(not(current > 0 && num[current] == '0' && num[current-1] == '0')) ansV0 = ansDFS(current+1, amari, mm, v);

  // 区切る場合
  v.push_back(mm);
  // cout << mm << endl;
  ansV1 = ansDFS(current+1, amari-mm, -1,v);

  if(ansV0.size() > 0) return ansV0;
  else return ansV1;
}


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

  while(true){
    cin >> t >> num;
    if(t == 0 && num == "0") break;


    rep(j,1010101) dp[j] = 0;
    dfs(0,t,0);
    bool flag = false;

    rep(i,t+1){
      if(dp[i] == 1){
        ans = i;

        VI v;
        VI ansV = ansDFS(0, t ,0, v);
        ans = t - ans;
        cout << ans << " ";
        // cout << "Vsize is " << ansV.size() << endl;
        rep(j,ansV.size()){
          if(ansV.size() == j+1) cout << ansV[j] << endl;
          else cout << ansV[j] << " ";
        }

        flag = true;
        break;
      }else if(dp[i] > 1){
        cout << "rejected" << endl;
        flag = true;
        break;
      }
    }
    if(flag == false){
      cout << "error" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 7072
#include <stdio.h>

int main(void)
{
	int hen1, hen2, taikaku;
	int tyouhoukei, hishigata; 
	
	tyouhoukei = 0;
	hishigata = 0;
	
	while(scanf("%d, %d, %d" , &hen1, &hen2, &taikaku) != EOF){
		
		if ((hen1 * hen1) + (hen2 * hen2) == (taikaku * taikaku)){
			tyouhoukei++;
		}
		
		else if (hen1 == hen2){
			hishigata++;
		}
	}
	
	printf("%d\n" , tyouhoukei);
	printf("%d\n" , hishigata);
	
	return (0);
}

Measured memory_bytes: 596