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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, M;
	cin >>N >>M;
	vector<vector<vector<int>>> A(N+1);
	for (int i=0; i<M; i++) {
		int L, R, D;
		cin >>L >>R >>D;
		A.at(L).push_back({R, D});
		A.at(R).push_back({L, -D});
	}
	vector<int> q;
	int ixq=0;
	vector<bool> Done(N+1, false);
	vector<bool> Fixed(N+1, false);
	vector<int> P(N+1, 0);
	for (int i=1; i<=N; i++) {
		if (Done.at(i))
			continue;
		Fixed.at(i)=true;
		// P.at(i)=0;
		q.push_back(i);
		while(ixq<q.size()) {
			int k=q.at(ixq);
			if (Done.at(k))
				continue;
			for (int j=0; j<A.at(k).size(); j++) {
				int R=A.at(k).at(j).at(0);
				int D=A.at(k).at(j).at(1)+P.at(k);
				if (Done.at(R))
					continue;
				if (Fixed.at(R)) {
					if (D==P.at(R))
						continue;
					else {
						cout <<"No" <<endl;
						return 0;
					}
				} else {
					P.at(R)=D;
					Fixed.at(R)=true;
				}
				if (!Done.at(R))
					q.push_back(R);
			}
			Done.at(k)=true;
			ixq++;
		}
	}
	cout <<"Yes" <<endl;
	return 0;
}



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

using namespace std;

void solve(int n, vector<int> div)
{
  if(n == 0){
    for(int i = 0; i < div.size(); i++){
      if(i) cout << " ";
      cout << div[i];
    }
    cout << endl;
    return;
  }
  for(int i = (div.size() > 0 ? min(n, div[div.size()-1]) : n); i > 0; i--){
    vector<int> temp = div;
    temp.push_back(i);
    solve(n - i, temp);
  }
  return;
}

int main()
{
  int n;
  while(cin >> n, n){
    vector<int> div;
    solve(n, div);
  }
  return 0;
}

Measured memory_bytes: 1224
def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

def solve(k):
    n = N
    while n % k == 0:
        n //= k
    return (n % k == 1)

N = int(input())

K = set(divisors(N) + divisors(N - 1)) - {1}
print(sum(solve(k) for k in K))

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

typedef long long ll;
int INF = INT_MAX/2;

#define E_MAX 100050

struct edge{
    int u, v, cost;
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

edge es[E_MAX];
int V,E;

class UnionFind {
private:
  int n;
  vector<int> a;
public:
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) {return a[x] < 0 ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    --n;
  }
  int size() {return n;}
  int size(int x) {return -a[find(x)];}
  void reset(){a.assign(n, -1);}
};

int main(){
    
    cin >> V >> E;
    int a[E], b[E];
    
    for(int i=0; i<E; i++) cin >> a[i] >> b[i];
    for(int i=0; i<E; i++){--a[i]; --b[i];}
    
    int ans = 0;
    for(int i=0; i<E; i++){
        UnionFind uf(V);
        for(int j=0; j<E; j++){
            if(i!=j) uf.unite(a[j],b[j]);
        }
        if(not uf.equal(a[i],b[i])) ans++;
        // cout << endl;
        uf.reset();
    }
    
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, A, B;
	int a = 0, b = 0;
	int ans = 0;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &A, &B);
		if (A > a) {
			a = A;
			b = B;
		}
	}
	ans = a + b;

	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

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

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

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (num[i] >= limit) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main { //クラス名はMain
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      	long n=sc.nextLong();
      	long o=0;
      	long x[]=new long[61];
      	for(int i=0;i<n;i++){
          	long a=sc.nextLong();
          	String bin = Long.toBinaryString(a);
          	int l=bin.length();
          	for(int j=0;j<l;j++){
              	if(bin.charAt(l-1-j)=='1')x[j]++;
            }            	
        }
      	long twoPow=1;
      	for(int i=0;i<=60;i++){
        	long p=(x[i]*(n-x[i]))%1000000007;	//xorの合計
          	o+=p*twoPow;
          	o=o%1000000007;
          	twoPow*=2;
          	twoPow=twoPow%1000000007;
        }
     	 System.out.println(o);
    }
}

Measured memory_bytes: 92780
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()

	P := make([]int, N)
	for i := 0; i < N; i++ {
		P[i] = sc.NextInt()
	}

	sort.Ints(P)
	mn := P[K-1] - P[0]
	for i := 0; i+K-1 < N; i++ {
		K := P[i+K-1] - P[i]
		if mn > K {
			mn = K
		}
	}
	fmt.Println(mn)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <utility>

#define ll long long
using namespace std;
typedef vector< pair<ll, ll> > pairs;

int main(){
    ll N,M,Q;
    int l, r, ql, qr;
    int X[505][505], C[505][505];
    int ans=0;
    cin >> N >> M >> Q;
    pairs sect(M);
    pairs qsec(Q);
    for(int i = 0; i < M; i++){
        cin >> l >> r;
        sect[i].first = l;
        sect[i].second = r;
        X[l][r]++;
    }
    for(int i = 0; i < Q; i++){
        cin >> l >> r;
        qsec[i].first = l;
        qsec[i].second = r;
    }

    //Lを固定した時の累積和を求めておく
    for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++){ 
            C[i][j] = C[i][j - 1] + X[i][j];
        }
	}
    for(int i = 0; i < Q; i++){
        ans = 0;
        ql = qsec[i].first;
        qr = qsec[i].second;
        for(int j = ql; j <= qr; j++){
            ans += C[j][qr] - C[j][ql-1];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 7680
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

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

  ll n, x;
  cin >> n >> x;
  ll ans = 0;

  ll pre, cur;
  cin >> pre;
  REP(i, n-1) {
    cin >> cur;
    ll diff = (pre + cur) - x;

    if(diff > 0) {
      ans += diff;
      cur -= min(cur, diff);
    }
    pre = cur;
  }

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


Measured memory_bytes: 256
def apply(as, x, y)
  as[y] += as[x]
  puts [x+1, y+1]*" "
end


n = gets.to_i
as = gets.split.map(&:to_i)

mx = as.max
mn = as.min

p 2*n
if mx >= mn.abs
  u = as.index(mx)
  0.upto(n-1) do |i|
    apply(as, u, i)
    apply(as, u, i)
    u = i
  end
else
  u = as.index(mn)
  (n-1).downto(0) do |i|
    apply(as, u, i)
    apply(as, u, i)
    u = i
  end
end

raise if as.sort != as


Measured memory_bytes: 3836
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=[a,b,c,d,e]
f.sort()
x=0
for i in range(5):
  if f[i]%10==0:
    x=x+f[i]
  if f[i]%10!=0:
    x=x+(f[i]//10)*10+10
g=a-(a//10)*10
h=b-(b//10)*10
i=c-(c//10)*10
j=d-(d//10)*10
k=e-(e//10)*10
l=[g,h,i,j,k]
l.sort()
y=0
z=0
for i in range(5):
  if l[i]!=0:
    y=y+1
    z=i
    break
if y==0:
  print(x)
else:
  print(x-(10-l[z]))

Measured memory_bytes: 9244
#include <stdio.h>

int main () {
	int num[3], k;
	scanf("%d %d %d %d", &num[0], &num[1], &num[2], &k);
	
	
	for (int i = 1; i <= k; i++){
		
		int max = (num[0] > num[1]) ? num[0] : num[1];
		max = (max > num[2]) ? max : num[2];
		
		for (int j = 0; j < 3; j++){
			if (num[j] == max){
				num[j] *= 2;
				break;
			}
		}
	
	}
	printf("%d\n", num[0] + num[1] + num[2]);
	
	return 0;
}

Measured memory_bytes: 128
B1 = 63533
B2 = 100007
DIV = 1<<32

def init(r)
  f = Array.new(r){ Array.new }
  r.times do |i|
    f[i] = gets.chomp.split("").map(&:ord)
  end
  f
end

def calc(f, r, c)
  f = f ? $f1 : $f2
  t1 = 1
  $c.times{ t1 = t1 * B1 % DIV }
  r.times do |i|
    e = 0
    $c.times do |j|
      e = e*B1 + f[i][j]
    end
    (0..c-$c).each do |j|
      $tmp[i][j] = e
      e = (e*B1 - t1*f[i][j] + f[i][j+$c] + DIV) % DIV if j < c - $c
    end
  end

  t2 = 1
  $r.times{ t2 = t2 * B2 % DIV }
  (0..c-$c).each do |j|
    e = 0
    $r.times{ |i| e = e*B2 + $tmp[i][j] }
    (0..r-$r).each do |i|
      $hash[i][j] = e
      e = (e*B2 - t2*$tmp[i][j] + $tmp[i+$r][j] + DIV) % DIV if i < r - $r
    end
  end
end

def check
  $h.times do |i|
    $w.times do |j|
      puts "#{i} #{j}" if $hash[i][j] % DIV == $key % DIV
    end
  end
end

$h, $w = gets.split.map(&:to_i)
$f1 = init($h)
$r, $c = gets.split.map(&:to_i)
$f2 = init($r)
if $h >= $r && $w >= $c
  $hash = Array.new($h){ Array.new($w, 0) }
  $tmp = Array.new($h){ Array.new($w, 0) }
  calc(nil,$r,$c)
  $key = $hash[0][0]
  calc(true,$h,$w)
  check
end

Measured memory_bytes: 61616
N,M=map(int,input().split())
import math
s = math.sqrt(M)
sq = math.floor(s)
l = []
for i in range(1,sq+1):
    if M%i == 0:
        l.append(i)
        l.append(M//i)
ans = 1
for r in l:
    n = M//r
    if n >= N:
        ans = max(ans,r)
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] t = new int[n];
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}

		long total = 0;
		long ttmp = 0;
		long atmp = 0;
		for (int i = 0; i < n; i++) {
			long tmp = t[i] + a[i];
			if (tmp >= total && ttmp <= t[i] && atmp <= a[i]) {
				total = tmp;
				ttmp = t[i];
				atmp = a[i];
			} else {
				BigInteger max = BigInteger.valueOf(total).add(BigInteger.valueOf(tmp)).subtract(BigInteger.ONE).divide(BigInteger.valueOf(tmp));
//				long max = (total + tmp - 1) / tmp;
				max = max.max(BigInteger.valueOf(ttmp).add(BigInteger.valueOf(t[i])).subtract(BigInteger.ONE).divide(BigInteger.valueOf(t[i])));
				max = max.max(BigInteger.valueOf(atmp).add(BigInteger.valueOf(a[i])).subtract(BigInteger.ONE).divide(BigInteger.valueOf(a[i])));
//				max = Math.max(max, (ttmp + t[i] - 1) / t[i]);
//				max = Math.max(max, (atmp + a[i] - 1) / a[i]);
				total = max.multiply(BigInteger.valueOf(tmp)).longValue();
//				total =  max * tmp;
				ttmp = BigInteger.valueOf(total).multiply(BigInteger.valueOf(t[i])).divide(BigInteger.valueOf(tmp)).longValue();
				atmp = BigInteger.valueOf(total).multiply(BigInteger.valueOf(a[i])).divide(BigInteger.valueOf(tmp)).longValue();
//				ttmp = total * t[i] / tmp;
//				atmp = total * a[i] / tmp;
			}
		}

		pr.println(total);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 16440
H, W = map(int, input().split())

if (H == 1 or W == 1):
    print(1)
    
elif (H * W) % 2 == 0:
    print(int((H * W) / 2))

else:
    masu = int((H * W) / 2) + 1
    print(masu)


Measured memory_bytes: 2940
def f(n, m, arrs=[], arr=[]):
    if len(arr) == n:
        arrs.append(arr)
    else:
        if len(arr) == 0:
            for i in range(1, m + 1):
                f(n, m, arrs, arr + [i])
        else:
            for i in range(arr[-1], m + 1):
                f(n, m, arrs, arr + [i])
    return arrs


n, m, q = map(int, input().split())
Q = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    Q.append((a, b, c, d))
#print(memo)
ans = 0
for ball in f(n, m):
    a = 0
    #print(ball)
    for q in Q:
        if ball[q[1] - 1] - ball[q[0] - 1] == q[2]:
            a += q[3]
    ans = max(ans, a)
print(ans)

Measured memory_bytes: 98500
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];

        ArrayList<PairInt> p = new ArrayList<>(N);
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            p.add(new PairInt(A[i], i));
        }

        Collections.sort(p, (p1, p2) -> {
            return -Long.compare(p1.x, p2.x);
        });
        int[] rank = new int[N];
        for (int i = 0; i < N; i++) {
            rank[i] = p.get(i).y;
        }

        long[][] dp = new long[N+1][N+1];
        for (int k = 1; k <= N; k++) {
            for (int x = 0; x <= k; x++) {
                int y = k - x;
                if (y > N) {
                    continue;
                }
                long px = A[rank[k-1]] * (N - y - rank[k-1]);
                long py = A[rank[k-1]] * (rank[k-1] - x + 1);
                if (x == 0) {
                    dp[x][y] = dp[x][y - 1] + px;
                } else if (y == 0) {
                    dp[x][y] = dp[x - 1][y] + py;
                } else {
                    dp[x][y] = Math.max(dp[x - 1][y] + py, dp[x][y - 1] + px);
                }
            }
        }

        long ans = 0;
        for(int x = 0 ; x <= N ; x++){
            ans = Math.max(ans, dp[x][N-x]);
        }

        System.out.println(ans);
    }
}

class PairInt {
    long x;
    int y;

    PairInt(long a, int b) {
        x = a;
        y = b;
    }
}

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

using namespace std;

int a[200001];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie();
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		a[i] -= i + 1;	
	}
	sort(a, a+n);
	long long ans = 0;
	for(int i=0;i<n;i++) {
		ans += abs(a[(n-1)/2] - a[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int A,B;
  cin>>A>>B;
  
  int ans=-1;
  rep(i,1251){
    int x=i*0.08;
    int y=i*0.1;
    
    if(x==A && y==B){
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e7;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> l(N + 1), r(N + 1);
    l[0] = 0;
    for(int i = 0; i < N; i++) {
        l[i + 1] = (i > 0 ? l[i] : 0) + (S[i] == '#');
    }
    r[N] = 0;
    for (int i = N - 1; i >= 0; i--) {
        r[i] = r[i + 1] + (S[i] == '#');
    }
    int ans = INF;
    for(int i = 0; i <= N; i++) {
        ans = min(ans, l[i] + N - i - r[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <iostream>
#include <queue>
#include <set>
#define ll long long
#define sf(a) scanf("%lld",&a)
#define pf(b) printf("%lld",b)
#define sp printf(" ")
#define nw printf("\n")
#define mp make_pair
#define pi pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define fast ios_base::sync_with_stdio(false)
using namespace std;
 
 
int main()
{
  ll x,k,d,ans;
  cin>>x>>k>>d;
  x=abs(x);
  //ll s=llround(((double)x)/((double)d));
  ll s=x/d;
  if(k<s) ans=x-(k*d);
  else
  {
   ll v0=x-(d*s);
   ll v1=v0-d;
   s=k-s;
   if(s%2) ans=v1;
   else ans=v0;
  }
  ans=abs(ans);
 // pf(ans);
  cout<<ans;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 3030;
const Int INF = 1e15;
Int n;
Int a[MAX];
Int dp[MAX][MAX],vi[MAX][MAX];
Int dfs(Int k,Int l,Int r){
  Int &res=dp[l][r];
  if(vi[l][r]) return res;
  vi[l][r]=1;
  if(l==r) return res=0;
  if(k==0){
    res=-INF;
    chmax(res,dfs(!k,l+1,r)+a[l]);
    chmax(res,dfs(!k,l,r-1)+a[r-1]);    
  }
  if(k==1){
    res=+INF;
    chmin(res,dfs(!k,l+1,r)-a[l]);
    chmin(res,dfs(!k,l,r-1)-a[r-1]);    
  }
  return res;
}

signed main(){
  cin>>n;
  for(Int i=0;i<n;i++) cin>>a[i];
  memset(vi,0,sizeof(vi));
  cout<<dfs(0,0,n)<<endl;  
  return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));
long long a,b;
cin>>a>>b;
long long ins;
//最大公約数から求めるやり方もありそう
if(a>b){
    ins=a;
    a=b;
    b=ins;
}
//いま、b>=a
long long g=1;
for(long long i=1;i<=a;i++){
    if(a%i==0 && b%i==0){
        g=max(g,i);
    }
}
cout<<(a/g)*(b/g)*g<<endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define HEIGHT 12
#define WIDTH 6

enum { YET, ALREADY };

int calcChain( void );
int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char, int );
void deleteGroup( void );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ HEIGHT ][ WIDTH ];
const int dx[ 4 ] = { -1, 0, 1, 0 };
const int dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ HEIGHT * WIDTH ];
int sp;

int main( void ) {
	int i, j, n;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( i = 0; i < HEIGHT; i++ ) {
			for ( j = 0; j < WIDTH; j++ ) {
				scanf( "%c", &field[ i ][ j ].color );
				field[ i ][ j ].state = YET;
			}

			scanf( "%*c" );
		}

		printf( "%d\n", calcChain() );
	}

	return 0;
}

int calcChain( void ) {
	int chain;

	for ( chain = 0; ; chain++ ) {
		if ( !deleteBlock() )
			break;

		fallBlock();
	}

	return chain;
}

int deleteBlock( void ) {
	int i, j, deleted;

	deleted = 0;
	for ( i = 0; i < HEIGHT; i++ )
		for ( j = 0; j < WIDTH; j++ )
			if ( field[ i ][ j ].color != '.' && field[ i ][ j ].color != 'O' && field[ i ][ j ].state == YET ) {
				sp = 0;
				if ( findGroup( i, j ) >= 4 ) {
					deleted = 1;
					deleteGroup();
				}
			}

	return deleted;
}

int findGroup( int i, int j ) {
	stack[ sp++ ] = i * WIDTH + j;
	field[ i ][ j ].state = ALREADY;

	findGroup_body( i, j - 1, field[ i ][ j ].color, 2 );
	findGroup_body( i - 1, j, field[ i ][ j ].color, 3 );

	return findGroup_body( i, j + 1, field[ i ][ j ].color, 0 ) + findGroup_body( i + 1, j, field[ i ][ j ].color, 1 ) + 1;
}

int findGroup_body( int i, int j, char color, int comeDir ) {
	int sum, d;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH || field[ i ][ j ].state == ALREADY || field[ i ][ j ].color != color && field[ i ][ j ].color != 'O' )
		return 0;

	stack[ sp++ ] = i * WIDTH + j;

	if ( field[ i ][ j ].color == 'O' )
		return 0;

	field[ i ][ j ].state = ALREADY;

	sum = 0;
	for ( d = 0; d < 4; d++ )
		if ( d != comeDir )
			sum += findGroup_body( i + dy[ d ], j + dx[ d ], color, d + 2 & 3 );
	
	return sum + 1;
}

void deleteGroup( void ) {
	while ( sp-- )
		field[ stack[ sp ] / WIDTH ][ stack[ sp ] % WIDTH ].color = '.';
}

void fallBlock( void ) {
	int i, j, cnt;

	for ( j = 0; j < WIDTH; j++ ) {
		cnt = 0;
		for ( i = HEIGHT - 1; i >= 0; i-- )
			if ( field[ i ][ j ].color == '.' )
				cnt++;
			else {
				field[ i + cnt ][ j ].color = field[ i ][ j ].color;
				field[ i + cnt ][ j ].state = YET;
			}

		for ( i = cnt - 1; i >= 0; i-- )
			field[ i ][ j ].color = '.';
	}
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A.at(i);
        H -= A.at(i);
    }

    cout << ((H <= 0) ? "Yes" : "No") << endl;
}

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


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll res = 0;
    map<string,ll> mp;
    for (int i = 1; i <= N; i++) {
        string fala = "";
        string lafa = ""; 
        string s = to_string(i);
        char fa = s.front();
        char la = s.back();
        fala += fa;
        fala += la;
        lafa += la;
        lafa += fa;
        res += mp[lafa]*2;
        mp[fala]++;
        if (fa == la) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
ll n,m;
int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		while(x--)
		{
			int p;
			cin>>p;
			a[p]++;
		}
	}
	ll ans=0;
	rep(i,1,n+1)if(a[i]==0)ans++;
	tell(ans);
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1000000007;
string s;
ll dp[4][100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  dp[0][0] = 1;
  for (int i = 0; i < s.size(); i++) {
    dp[0][i+1] = dp[0][i] * (s[i] == '?' ? 3 : 1);
    dp[0][i+1] %= MOD;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '?') {
        dp[i+1][j+1] += dp[i+1][j] * 3;
        dp[i+1][j+1] %= MOD;
      } else {
        dp[i+1][j+1] += dp[i+1][j];
        dp[i+1][j+1] %= MOD;
      }
      if (s[j] == '?' || s[j] == "ABC"[i]) {
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= MOD;
      }
    }
  }
  cout << dp[3][s.size()] << endl;

  return 0;
}

Measured memory_bytes: 3664
/*****************************************************************\
    |     IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL       |
    |                                                                 |
    |     Author     : Mahabub Rahman                                 |
    |     Email      : mahabubrahman618@gmail.com                     |
    |     University : Comilla University, Bangladesh		          |
    |                  Department of Computer Science & Engineering   |
    \*****************************************************************/


    /*...................................Data_Types............................................*/
    #include<bits/stdc++.h>

    using namespace std;
    #define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
    #define       ll                  long long int
    #define       ull                  unsigned long long int
    #define       veci                 vector<int>
    #define       vecc                 vector<char>
    #define       vecs                 vector<string>
    #define       vecl                 vector<long long int>
    #define       vecp                 vector<  pair<int,int> >
    #define       mapstrint            map< string , int >
    #define       mapstrstr            map< string , string >
    #define       mapint               map< int, int >
    #define       pb                   push_back
    #define       pob                  pop_back
    #define       mp                   make_pair
    ////============ CONSTANT ===============////
    #define mx9   1000000007
    #define mx7   10000007
    #define mx6   1000006
    #define mx5   200005
    #define inf   1<<30                                           //infinity value
    #define eps   1e-9
    #define pai   pair<int, int>
    #define pac   pair<char, int>

    #define mod   1000000007
    ////=====================================////

    long double PI = acosl(-1);
    bool compare_int(int a, int b) //This function is use for descending order.
    {
        return (a>b);
    }
    bool compare_string (string a, string b)
    {
        return a.size() < b.size();
    }
    bool compare_pair(const pair<int,int> &a,
                  const pair<int,int> &b)
    {
        if(a.second==b.second) return a.first>b.first;
        else return (a.second > b.second);
    }
    /*ll fact(ll n)
    {
        if(n==0 || n==1) return 1;
        else return n*fact(n-1);
    }*/

    ////======================================////
    /*bool check(int n)
    {
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }
        return true;
    }*/
    int32_t main()
    {
        FastIO;
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        int x = s.find('7');
        if(x!=-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (a == -1 && b == -1 && c == -1) {
				break;
			}
			if (a == -1 || b == -1) {
				System.out.println("F");
			} else if (a + b >= 80) {
				System.out.println("A");
			} else if (a + b >= 65) {
				System.out.println("B");
			} else if (a + b >= 50) {
				System.out.println("C");
			} else if (a + b >= 30) {
				if (c >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}

		}
	}
}


Measured memory_bytes: 26512
n = int(input())
a = input().split()
a = list(map(int,a))

total = sum(a)

x = 0
arr = []
if n == 2:
    arr.append(abs(a[0]-a[1]))
else:
    for i in range(n-1):
        x += a[i]
        y = total - x
        arr.append(abs(x - y))

print(min(arr))


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

int gcb(int a,int b){
    if(a%b == 0) return b;
    return gcb(b,a%b);
}

int main() {
    //input
    int n,m;
    std::cin >> n;
    std::cin >> m;

    int l = 0,r = n+1;
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        int b;
        cin >> b;
        l = max(l,a);
        r = min(r,b+1);
    }

    if(r-l>=0){
        cout << r-l;
    }else{
        cout << 0;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

s=input().strip()
t=input().strip()

L=len(s)

NLIST=[[float("inf")]*26 for i in range(2*L+1)]

s2=s*2

for i in range(2*L-1,-1,-1):
    for j in range(26):
        if j==ord(s2[i])-97:
            NLIST[i][j]=i
            continue
            
        NLIST[i][j]=NLIST[i+1][j]
        


NOW=-1
ANS=0
for al in t:
    x=NLIST[NOW+1][ord(al)-97]
    if x==float("inf"):
        print(-1)
        sys.exit()

    else:
        ANS+=(x-NOW)
        NOW=x%L

print(ANS)

    


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

template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

const int INF = 0xfffffff;

void warshall_floyd(vector<vector<int> >& d) {
	int v = d.size();
	for(int i = 0; i < v; ++i)
		for(int j = 0; j < v; ++j)
			for(int k = 0; k < v; ++k)
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	for(int n, m; cin >> n >> m, n | m;) {
		vector<vector<int> > riku(n, vector<int>(n, INF));
		vector<vector<int> > umi(n, vector<int>(n, INF));
		for(int i = 0; i < n; ++i)
			riku[i][i] = umi[i][i] = 0;

		for(int i = 0; i < m; ++i) {
			int x, y, t;
			char sl;
			cin >> x >> y >> t >> sl;
			--x;
			--y;
			
			if(sl == 'S')
				umi[x][y] = umi[y][x] = min(umi[y][x], t);
			else
				riku[x][y] = riku[y][x] = min(riku[y][x], t);
		}
		

		warshall_floyd(riku);
		warshall_floyd(umi);
		
		int r;
		cin >> r;
		
		vector<int> z(r);
		for(int i = 0; i < r; ++i) {
			cin >> z[i];
			--z[i];
		}

		vector<vector<int> > dp(r, vector<int>(n, INF));
		dp[0][z[0]] = 0;

		for(int i = 0; i < r - 1; ++i) {
			for(int j = 0; j < n; ++j) {
				chmin(dp[i + 1][j], dp[i][j] + riku[z[i]][z[i + 1]]);
				for(int k = 0; k < n; ++k) {
					chmin(dp[i + 1][k], dp[i][j] + riku[z[i]][j] + umi[j][k] + riku[k][z[i + 1]]);
				}
			}
		}

		cout << *min_element(dp[r - 1].begin(), dp[r - 1].end()) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2328
n = gets.to_i

if n <= 9
  puts n
else
  first = n
  d = 1
  sum = 0

  until first < 10
    sum += first % 10
    first /= 10
    d += 1
  end
  sum += first

  max = [first.to_s, "9" * (d - 1)].join.to_i
  puts n < max ? 9 * (d - 1) + (first - 1) : sum
end


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<tuple<string, int, int>> a;
	for(int i=1;i<=n;i++) {
		string s;
		int p;
		cin >> s >> p;
		p = -p;
		a.emplace_back(s, p, i);
	}
	sort(a.begin(), a.end());
	rep(i, n) {
		cout << get<2>(a[i]) << endl;
	}
	return 0;
}

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

signed main(){
    int N,M;
    cin>>N>>M;
    int ans=0;
    vector<vector<int>>vec(M);
    REP(i,M){
        int a;cin>>a;
        vec[i].resize(a);
        REP(j,a){
            cin>>vec[i][j];
            vec[i][j]--;
        }
    }
    vector<int>p(M);
    REP(i,M) cin>>p[i];
    for(int i=0;i<(1<<N);i++){
        bool ok = true;
        REP(j,M){
            int sum=0;
            for(int id : vec[j]){
                if((i >> id) & 1) sum++;
            }
            sum %=2;
            if(sum!=p[j]) ok=false;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N;
  int K;
  cin>>N>>K;
  int sum=0;
  int i=0;
  
  while (i<N) {
    int x;
    cin>>x;
    int A=K-x;
    int B=x-K;
    
    if(A<B && B<x) {
      sum += B*2;
    }
    
    else if (A<B) {
      sum += x*2;
    }
    
    if (B<A && A<x) {
      sum += A*2;
    }
    
    else if (B<A) {
      sum += x*2;
    }
    
    i++;
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
    string s;
    getline(cin, s);
    map<char, ll> x;
    for(char y : s){
        x[y]++;
    }
    if(x.size() == 2 && x[s.at(0)] == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> a(K);
  for (int i=0; i < K; i++) {
    cin >> d.at(i);
    a.at(i).resize(d.at(i));
    for (int j=0; j < d.at(i); j++) {
      cin >> a.at(i).at(j);
    }
  }
  set<int> set;
  for (int i=1; i < N+1; i++) {
    set.insert(i);
  }
  for (int i=0; i < K; i++) {
    for(int j=0; j < d.at(i); j++) {
      set.erase(a.at(i).at(j));
    }
  }
  cout << set.size() << endl;
}

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

int main()
{
	int n,PointA=0,PointB=0;
	short A,B,a=1;
	cin>>n;
	
	while(n!=0 || a==5){
		for(int i=0;i<n;i++){
			cin>>A>>B;
			if(A>B){
				PointA+=A+B;
			}
			else if(A<B){
				PointB+=A+B;
			}
			else if(A==B){
				PointA+=A;
				PointB+=B;
			}
		}
		cout<<PointA<<" "<<PointB<<endl;
		PointA=0,PointB=0;
	        a++;
		cin>>n;
	}
	
	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int a,b;
	cin>>a>>b;
	if(a*b%2==0) cout<<"Even"<<endl;
	else cout<<"Odd"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double x = Math.max(n - k + 1, 0) / (double)n;
		double y = 0.0;
		for (int i = 1; i <= Math.min(k - 1, n); i++) {
			y += getRate(i, k);
		}
		y /= n;
		System.out.println(x + y);
	}
	
	static double getRate(int w, int k) {
		double ans = 1;
		while (w < k) {
			w *= 2;
			ans *= 0.5;
		}
		return ans;
	}
}


Measured memory_bytes: 21716
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()
s = lc()

ok = True

for i, si in enumerate(s):
    if i == a:
        if si != "-":
            ok = False
    else:
        if si == "-":
            ok = False
            
if ok:
    print("Yes")
else:
    print("No")

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

int main(){
    long long int a, b, c;
    cin >> a >> b >> c;

    if(c <= a + b){
        cout << "No" << endl;
        return 0;
    }

    long long int left = 4 * a * b;
    long long int right = (c-a-b) * (c-a-b);
    if(left < right) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
/**********************************
	author:  mariogzsl
**********************************/

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,b,a) for(int i=b-1;i>=a;i--)
#define f first
#define s second
#define puts(x) cout<<x<<endl
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double v, ans=0, aux, add=INT_MIN;
	FOR(i,0,5){
		cin>>v;
		aux=v;
		v=10*ceil(v/10);
		add=max(add,v-aux);

		ans+=v;
	}
	cout<<int(ans-add)<<endl;
	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string s;
    cin >> s;
    deque<char> dq;
    for (auto c : s) {
        dq.pb(c);
    }
    bool rev = false;
    li q;
    cin >> q;
    rep(i, q) {
        li typ;
        cin >> typ;
        if (typ == 1) {
            rev = !rev;
        } else {
            li f;
            char c;
            cin >> f >> c;
            if (rev) {
                f = 3 - f;
            }
            if (f == 1) {
                dq.push_front(c);
            } else {
                dq.pb(c);
            }
        }
    }
    if (rev) {
        reverse(allof(dq));
    }
    for (auto c : dq) {
        cout << c;
    }
    cout << endl;

    return 0;
}

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

int main(){
    int hms;
    cin >> hms;
    int h = hms / 3600;
    int m = hms % 3600 / 60;
    int s = hms % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


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

int main(){

  ll N;
  ll h, n, w;
  ll H, M, W;
  int flag = 1;
  cin >> N;
  for(h = 1; h <= 3500; h++){
    for(n = 1; n <= 3500; n++){
      if((4*h*n-N*n-N*h) == 0 || (N*n*h) % (4*h*n-N*n-N*h) != 0) continue;
      w = (N*n*h) / (4*h*n - N*n - N*h);
      if(w < 0) continue;
      ll tmp = 4 * h * n * w;
      ll tmp1 = N * (n*w + h*w + n*h);
      if(tmp == tmp1){
        H = h;
        M = n;
        W = w;
        flag = 0;
        break;
      }
    }
    if(!flag) break;
  }
  printf("%lld %lld %lld\n", H, M, W);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc091/tasks/abc091_b

int main() {
    map<string, int> mp;
    int N; cin >> N;
    string s;
    REP(i, N) {
        cin >> s;
        mp[s]++;
    }

    int M; cin >> M;
    string t;
    REP(i, M) {
        cin >> t;
        mp[t]--;
    }

    int max = 0;
    for(map<string, int>::iterator it = mp.begin(), end = mp.end(); it != end; ++it) { // it->first, it->second
        if (it->second > max) {
            max = it->second;
        }
    }

    cout << max << "\n";

    return 0;
}


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

using namespace std;

int main(){
	bool flag=true;
	string s;
	cin>>s;

	for(int i=0;i<s.size()-1;i++){
		for(int j=i+1;j<s.size();j++){
			// cout<<s[j]<<" "<<s[i]<<endl;
			if(s[i]==s[j]){
				flag=false;
				break;
			}
		}
	}


	if(flag){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	cout << setprecision(10) << a * b * sin(c * M_PI / 180) / 2 << endl;
	cout << setprecision(10) << a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c * M_PI / 180)) << endl;
	cout << setprecision(10) << b * sin(c * M_PI / 180) << endl;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

class t_sort{
public:
	int n;
	vector<int> ans, deg;
	vector<vector<int> > G;
	void init(int N){
		n = N;
		deg.resize(n);G.resize(n);
	}
	void add_edge(int from, int to){	//DAG
		G[from].pb(to);deg[to]++;
	}
	void tsort(){
		stack<int> st;
		rep(i,n)if(deg[i] == 0)st.push(i);
		while(!st.empty()){
			int v = st.top();st.pop();ans.pb(v);
			rep(i,G[v].size())if(--deg[G[v][i]] == 0)st.push(G[v][i]);
			//for(auto u: G[v])if(--deg[u] == 0)st.push(u);
		}
	}
};

map<P, int> mp;
signed main(){
	int n,m;
	scanf("%lld%lld", &n, &m);
	t_sort t;
	t.init(n);
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);x--;y--;
		t.add_edge(x, y);
		mp[P(x, y)] = 1;
	}
	
	t.tsort();
	vector<int> ans = t.ans;
	rep(i,n)printf("%lld\n", ans[i]+1);
	int res = 1;
	rep(i,n-1){
		if(mp[P(ans[i], ans[i+1])] == 0)res = 0;
	}
	printf("%lld\n", res == 1 ? 0 : 1);
	return 0;
}







Measured memory_bytes: 11060
def main():
    h, w, a, b = map(int, input().split())
    mod = 10**9+7

    # comb init
    nmax = 2 * 10 ** 5 + 1  # change here
    fac = [0] * (nmax + 1)
    finv = [0] * (nmax + 1)
    inv = [0] * (nmax + 1)
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    p = (comb(b+(h-a-1), b) * comb((w-b-1)+(a-1), a-1)) % mod
    ans = p
    for x in range(b+1, w):
        p = (((p * (x + (h-a-1)))%mod) * ((inv[x] * inv[(w-x)+(a-1)])%mod) * (w-x)) % mod
        ans = (ans + p) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = 0;
	rep(i, n) {
		x -= a[i];
		if (x < 0) break;
		else ans++;
	}
	if (x > 0) ans--;
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for(int i=0; i<n; i++){
		string tmp;
		cin >> tmp;
		s[i] = tmp;
	}
	sort(s.begin(), s.end());
	for(int i=0; i<n; i++){
		cout << s[i];
	}
	return 0;
}



Measured memory_bytes: 256
def main():
    S = input()
    # S = "1" * 200000
    S = S[::-1]

    x = 1
    tot = 0
    cnt = [0] * 2019
    ans = 0

    for i in range(len(S)):
        # print("-----")
        # print(f"i: {i}")
        # print(f"tot: {tot}")
        # print(f"S[i]: {S[i]}")
        # print(f"x: {x}")
        # print(f"cnt: {cnt}")
        # print(f"cnt[tot]: {cnt[tot]}")
        # print(f"ans: {ans}")

        cnt[tot] += 1
        tot = (tot + (int(S[i]) * x)) % 2019
        ans += cnt[tot]
        x = (x * 10) % 2019
    
    # print("-----")
    # print(f"i: {i}")
    # print(f"tot: {tot}")
    # print(f"S[i]: {S[i]}")
    # print(f"x: {x}")
    # print(f"cnt: {cnt}")
    # print(f"cnt[tot]: {cnt[tot]}")
    # print(f"ans: {ans}")
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68488