akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    int size = s.size();
    string result = "Yes";
    REP(i, size){

        if (i%2 == 1) {
            if ((s[i] == 'L') or (s[i] == 'U') or (s[i] == 'D')) {
                continue;
            }
        } else if ((s[i] == 'R') or (s[i]=='U') or (s[i] == 'D')){
            continue;

        }
        result = "No";

    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  priority_queue<int> length;
  int x;

  rep(i,N) {
    cin >> x;
    length.push(x);
  }

  int sum = 0;
  rep(i,K) {
    sum += length.top();
    length.pop();
  }

  cout << sum << endl;
  return 0;
}


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

int main()
{
	double t,tmp,a,mx = 0x3f3f3f3f;
	int n;
	int ans = 0;
	cin>>n>>t>>a;
	for(int i = 1;i<=n;i++)
	{
		cin>>tmp;
	
		if( abs(a- (t- tmp* 0.006) )  <mx)
		{
			ans = i;
			mx = abs(a- (t- tmp *0.006) );
		}
	}
	cout<<ans;
	return 0;
}

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

namespace ConsoleApp19
{
    class Program
    {
        static void Main(string[] args)
        {

            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var p = line[0];
            var q = line[1];
            var r = line[2];

            var min = 0;
            min = p + q;
            min = (min > r + q) ? r + q : min;
            min = (min > p + r) ? p + r : min;
            min = (min > q + r) ? q + r : min;
            min = (min > r + p) ? r + p : min;
            min = (min > q + p) ? q + p : min;

            Console.WriteLine(min);
        }
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  REP(i, m) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    ++v.at(tmp1 - 1);
    ++v.at(tmp2 - 1);
  }
  
  REP(i, n)
    cout << v.at(i) << endl;
  
  return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int a, b, c;
	set<int> s;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);

	cout << s.size() << endl;


	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize
    };
    println!("{}", ["NO", "YES"][(2 * b == a + c) as usize]);
}


Measured memory_bytes: 2112
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		SSSPath sp = new SSSPath(n);

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for (int j = 0; j < k; j++)
				sp.addPath(u, scan.nextInt(), scan.nextInt());
		}
		sp.setPath(0);

		for (int i = 0; i < n; i++)
			System.out.println(i + " " + sp.getResult(i));

		scan.close();
		System.exit(0);
	}
}

class SSSPath {
	class Next {
		public Next(int to, int c) {
			pt = to;
			cost = c;
		}

		int pt;
		int cost;
	}

	class Point {
		List<Next> next = new ArrayList<Next>();
		int reach = -1;
		boolean fixed = false;
	}

	Point[] point;
	Bheap bheap;

	public SSSPath(int n) {
		point = new Point[n];
		for (int i = 0; i < n; i++)
			point[i] = new Point();

		bheap = new Bheap(n);
	}

	public int getResult(int i) {
		return point[i].reach;
	}

	public void setPath(int from) {
		point[from].reach = 0;
		bheap.add(from, 0);
		setP();
	}

	private void setP() {
		int p;
		while ((p = bheap.getTop()) != -1) {
			if (point[p].fixed)
				continue;
			point[p].fixed = true;
			for (int i = 0; i < point[p].next.size(); i++) {
				int np = point[p].next.get(i).pt;
				if (point[np].fixed)
					continue;
				int d = point[p].reach + point[p].next.get(i).cost;
				if (point[np].reach == -1 || point[np].reach > d) {
					point[np].reach = d;
					bheap.add(np, d);
				}
			}
		}
	}

	public void addPath(int from, int to, int c) {
		point[from].next.add(new Next(to, c));
	}

}

class Bheap {
	class Elem {
		int key;
		int pt;

		public Elem(int _pt, int _key) {
			key = _key;
			pt = _pt;
		}

		public void set(Elem e) {
			key = e.key;
			pt = e.pt;
		}
	}

	List<Elem> elem = new ArrayList<Elem>();

	public Bheap(int n) {
		elem.add(new Elem(-1, -1));
	}

	public int getTop() {
		if (elem.size() <= 1)
			return -1;
		int rpt = elem.get(1).pt;

		elem.get(1).set(elem.get(elem.size() - 1));
		elem.remove(elem.size() - 1);

		this.down(1);
		return rpt;
	}

	private void down(int c) {
		int min = c;
		if (c * 2 < elem.size() && elem.get(c * 2).key < elem.get(min).key)
			min = c * 2;
		if (c * 2 + 1 < elem.size() && elem.get(c * 2 + 1).key < elem.get(min).key)
			min = c * 2 + 1;
		if (min == c)
			return;
		this.swap(min, c);
		this.down(min);
	}

	private void swap(int c1, int c2) {
		Elem temp = new Elem(-1, -1);
		temp.set(elem.get(c1));
		elem.get(c1).set(elem.get(c2));
		elem.get(c2).set(temp);
	}

	public void add(int ptr, int cost) {
		elem.add(new Elem(ptr, cost));
		this.up(elem.size() - 1);
	}

	private void up(int c) {
		if (c < 2 || elem.get(c).key >= elem.get(c / 2).key)
			return;

		swap(c, c / 2);
		this.up(c / 2);
	}

}

Measured memory_bytes: 277252
#include <iostream>
#include <vector>
#include <numeric>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> t_arr(n);
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        std::cin >> tmp;
        t_arr[i] = tmp;
    }

    int m;
    std::cin >> m;
    std::vector<int> p_arr(m);
    std::vector<int> x_arr(m);
    for (int i = 0; i < m; ++i)
    {
        int p, x;
        std::cin >> p >> x;
        p_arr[i] = --p;
        x_arr[i] = x;
    }

    const int64_t sum = std::accumulate(t_arr.begin(), t_arr.end(), static_cast<int64_t>(0));
    for (int i = 0; i < m; ++i)
    {
        const int p = p_arr[i];
        std::cout << sum - (t_arr[p] - x_arr[i]);
        if (i != m - 1)
        {
            std::cout << std::endl;
        }
    }

    return 0;
}


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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main()
{
    int n;
    cin >> n;
    vector<ll> dp(n + 1);
    dp[1] = 1;
    for (int i = 2; i < n + 1; i++)
    {
        dp[i] = dp[i - 1];
        int head = 1;
        int tail;
        tail = i % 10;
        int counter = 0;
        while (head != 0)
        {
            counter++;
            head = i / (int)pow(10, counter);
        }
        counter--; //桁数
        head = i / (int)pow(10, counter);
        //cout << head << " " << tail << endl;
        ll add = 0;
        if (tail == 0)
        {
            continue;
        }

        if (head > tail)
        {
            rep(j, counter)
            {
                add += 2 * (ll)pow(10, j);
            }
        }
        else if (head < tail)
        {
            if (counter == 1)
            {
                continue;
            }

            rep(j, counter - 1)
            {
                add += 2 * (ll)pow(10, j);
            }
        }
        else
        {
            if (counter == 0)
            {
                add++;
            }
            else if (counter == 1)
            {
                add += 3; //22とか33
            }
            else if (counter > 1)
            {
                add += 2; //1桁
                int temp;
                temp = i;
                temp -= head * (ll)pow(10, counter);
                temp -= tail;
                rep(j, counter - 1)
                {
                    add += 2 * (ll)pow(10, j);
                }
                add += (temp / 10) * 2;
                add++; //自分
            }
        }

        dp[i] += add;
    }
    /*rep(i, n)
    {
        cout << dp[i] << endl;
    }*/
    //cout << dp[n - 1] << endl;
    cout << dp[n] << endl;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int N, K, Q;
    std::cin >> N >> K >> Q;

    std::vector<int> A(N, 0);
    REP(i, Q) {
        int a;
        std::cin >> a;
        A[a - 1]++;
    }

    REP(i, N) {
        std::cout << ((K - (Q - A[i]) > 0) ? "Yes" : "No" ) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353

n, k = map(int, input().split())
dp = [0] * n
dp[0] = 1
dp[1] = -1
delta = []
for _ in range(k):
    l, r = map(int, input().split())
    delta.append((l, 1))
    delta.append((r+1, -1))

total = 0
for i in range(n):
    total += dp[i]
    total %= MOD
    for p, d in delta:
        if i + p >= n:
            continue
        dp[i + p] += total * d
        dp[i + p] %= MOD
print(total % MOD)

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a > b) printf("%c > %c\n", 'a', 'b');
    else if (a < b) printf("%c < %c\n", 'a', 'b');
    else printf("%c == %c\n", 'a', 'b');
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>

int main(void) {

  int a, b ,c , d;
  std::cin >> a >> b >> c >> d;
  int d_ac = c > a ? c - a: a - c;
  int d_ab = b > a? b - a:a - b;
  int d_bc = c > b? c - b: b - c;
  
  if(d_ac <= d) { std::cout << "Yes"; return 0;}
  if (d_ab <= d && d_bc<= d) { std::cout << "Yes"; return 0;}
  std::cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,t,x;
bool cmp(pair < double , int > tmp1,pair < double , int > tmp2)
{
    return tmp1.first<tmp2.first;
}
void solve()
{
    vector < pair < double , int > > a(n);
    int i;
    for (i=0;i<n;i++)
    {
        cin>>a[i].first;
        a[i].second=i+1;
    }
    for (i=0;i<n;i++)
        a[i].first=t-a[i].first*.006;
    for (i=0;i<n;i++)
        a[i].first=fabs(a[i].first-1.0*x);
    sort(a.begin(),a.end(),cmp);
    cout<<a[0].second<<endl;
}
int main()
{
    while(cin>>n>>t>>x)
        solve();
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    int ans = 0;
    for(int i=1;i*i<=n;i++){
        ans = i*i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a;
    double b;
    char c[11][13]={{"light fly"},{"fly"},{"bantam"},{"feather"},{"light"},{"light welter"},{"welter"},{"light middle"},{"middle"},{"light heavy"},{"heavy"}};
    while(scanf("%lf",&b)!=EOF){
        if(b<=48.00)a=0;
        else if(b<=51.00)a=1;
        else if(b<=54.00)a=2;
        else if(b<=57.00)a=3;
        else if(b<=60.00)a=4;
        else if(b<=64.00)a=5;
        else if(b<=69.00)a=6;
        else if(b<=75.00)a=7;
        else if(b<=81.00)a=8;
        else if(b<=91.00)a=9;
        else a=10;
        printf("%s\n",c[a]);
    }
    return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <string.h>
int main() {
	char o[51], e[51];
	scanf("%s%s", o, e);
	for (int i = 0; i < strlen(o) * 2; i++) {
		if (i % 2 == 0) {
			printf("%c", o[i / 2]);
		} else {
			if (i == strlen(o) * 2 - 1 && strlen(o) - strlen(e) == 1) break;
			printf("%c", e[(i - 1) / 2]);
		}
	}
	printf("\n");
	return 0;
}

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

int main() {
  int N;
  int count = 0;
  cin >> N;

  for(int i = 0;i < N;++i){
    int x,y;
    cin >> x;
    cin >> y;
    if(x == y){
      count++;
      if(count >= 3){
        break;
      }
    }
    else{
      count = 0;
    }
  }
  if(count >= 3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;    
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b;
    cin >> a >> b;
    bool x[3];
    REP(i,3) x[i]=true;
    x[a-1]=false;x[b-1]=false;
    REP(i,3){
        if(x[i]) cout << i+1;
    }
    return 0;
}

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

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

    int d[10] = {0};
    for (int i = 0; i < k; ++i) {
        int t;
        cin >> t;
        d[t] += 1;
    }

    while (true) {
        int i = n;
        bool flg = true;
        while (i > 0) {
            if (d[i % 10] == 1) flg = false;
            i /= 10;
        }
        if (flg == true) {
            break;
        } else {
            n++;
        }
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int x = 1;
    for(int i=0; i<N; i++){
        int a = x + K;
        int b = 2*x;
        x = min(a, b);
    }
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/input.txt", "r", stdin);
    freopen("/Users/ishan/Desktop/fuzzy-chainsaw-algo/output.txt", "w", stdout);
#endif
}

int main(){
    c_p_c();
    int n; cin>>n;
    int k; cin>>k;
    vector<int> arr(n);
    for(int i = 0; i < n; i++) cin>>arr[i];

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j <= i + k; j++){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
            
        }
    }
    cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> X;
  rep(i,0,100000){
    A=(double)i*1.08;
    B=(double)i*1.1;
    if(A-i==N&&B-i==X){
      Out(i);
      flag=1;
      break;
    }
  }
  if(!flag)Out(-1);
}

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

int main(){
    int x, y;
    cin >> x >> y;
    if(x<y){
        int tmp=x;
        x=y;
        y=tmp;
    }
    int z=x%y;
    while(z!=0){
        x=y;
        y=z;
        z=x%y;
    }
    cout << y << endl;
    return 0;
}



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

using namespace std;

int main()
{
    int n, a, b, fcnt = 0, scnt = 0, tcnt = 0;
    scanf("%d %d %d", &n, &a, &b);

    for (int i = 0; i < n; i++)
    {
        int p;
        scanf("%d", &p);
        p <= a ? fcnt++ : (p <= b ? scnt++ : tcnt++);
    }

    printf("%d\n", min(fcnt, min(scnt, tcnt)));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// // #define input(X) getline(cin,X)
static const ll  INF = 1e9+7;
static const ll INFL = 1e18+7;
ll n,m,l, p;
string s,t;
ll d[200010],e[200010],dp[1001][1001];
char field[202][202];

int main(){
	while(cin >> n >> m, n){
		int ans = 0;
		rep(i,0,m)
			rep(j,0,n)
				cin >> dp[i][j];
		
		rep(i,0,n){
			int total = 0;
			rep(j,0,m)total += dp[j][i];
			ans = max(ans, total);
		}
		print(ans);
	}
	return 0;
}



Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void slove() {
	ll n; cin >> n;
	int a = n % 10;
	if (a == 2 || a==4|| a==5|| a==7|| a==9) {cout << "hon"; return;}
	if (a==0|| a==1|| a==6|| a==8){cout << "pon"; return;}
	if (a==3) cout << "bon";
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	slove();

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){

    int n;
    cin>>n;
    while(n--){
        int least=30,most=30,now=30;
        string str;
        char ans[60];
        cin>>str;
        ans[30]=str[0];
        for(int i=3;i<str.size();i+=3){
            if(str[i-1]=='>'){
                now++;
                if(most<now)most++;
            }
            else{
                now--;
                if(least>now)least--;
            }
            ans[now] = str[i];
            if(most-least==25)break;
        }
        for(int i=least;i<=most;i++)cout<<ans[i];
        cout<<endl;

    }

    return 0;
}

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

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

    if (a > b) {
        int t;
        t = a;
        a = b;
        b = t;
    }
    if (b > c) {
        int t;
        t = b;
        b = c;
        c = t;
    }
    if (a > b) {
        int t;
        t = a;
        a = b;
        b = t;
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    return 0;
}


Measured memory_bytes: 3052
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
 
d = abs(b - a)
u = v - w
 
if d == 0:
  print("YES")
elif u <= 0:
  print("NO")
elif d <= t * u:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9188
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

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

	int x, y = 0;
	x = a[0];
	REP(i, 1, N)y += a[i];
	int ans = abs(x - y);
	REP(i, 1, N - 1) {
		ans = min(ans, abs(x - y));
		x += a[i];
		y -= a[i];
	}
	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
//Atlanta       83 71  8  0 1 6 1
//Atlanta       83 71  8  0 1 6 1
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  /*int[] n1=int_arr();
	        		  int n=n1[0],k=n1[1];;
	        		  int[] arr=int_arr();*/
	        		  String s=read(),t=read();
	        		  if(s.equals(t.substring(0,s.length()))){out.write("Yes");}
	        		 else{out.write("No");}
	        		  
	        	
                      out.flush();
	        		 
	}
}
	       
	          



	
  





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






int main(){
  

  int n;
  cin>>n;
  
  vector<int> tdata(n+1),xdata(n+1),ydata(n+1);
  
  tdata.at(0)=0;
  xdata.at(0)=0;
  ydata.at(0)=0;
  
  
  for (int i=1;i<=n;i++){
    int t,x,y;
    cin>>t>>x>>y;
    tdata.at(i)=t;
    xdata.at(i)=x;
    ydata.at(i)=y;
  }
  
  string answer="Yes";
  
  for (int i=1;i<=n;i++){
    
    int tmpt=tdata.at(i)-tdata.at(i-1);
    int tmpx=xdata.at(i)-xdata.at(i-1);
    int tmpy=ydata.at(i)-ydata.at(i-1);
    
    
    
    if ( (tmpt-tmpx-tmpy)%2==1 or abs(tmpx)+abs(tmpy)>tmpt   ){
      answer="No";
    }
  }
  
  cout<<answer<<endl;
  
  
      
  

      
  
    

  
  
    
  
  
  
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL pow5(LL x){
    return x*x*x*x*x;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL X; cin >> X;
    map<LL,int> mp;
    REP(i,100000000){
        LL tmp = pow5(i);
        if(mp.find(tmp-X) != mp.end()){
            cout << i << " " << mp[tmp-X] << endl;
            return 0;
        }else{
            mp[tmp] = i;
            mp[tmp*-1] = -i;
        }

    }
    

}

Measured memory_bytes: 3672
x = int(input())
dp = [None] * 1000001
for i in range(100):
    dp[i] = False
dp[100] = True
dp[101] = True
dp[102] = True
dp[103] = True
dp[104] = True
dp[105] = True


for i in range(106, x+1):
    if dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]:
        dp[i] = True
    else:
        dp[i] = False

print(1) if dp[x] else print(0)

Measured memory_bytes: 10868
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
string itos(int a){
	string s="";
	while(a){
		s=(char)(a%10+'0')+s;
		a/=10;
	}
	return s;
}
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vector<bool>ha(n,true);
		vector<string>in(m);
		rep(i,m)cin>>in[i];
		int co=0;
		int no=n;
		loop(i,1,m+1){
			if(no==1)break;
			//??£?§£???????¨?
			string s=itos(i);
			if(i%15==0)s="FizzBuzz";
			else if(i%5==0)s="Buzz";
			else if(i%3==0)s="Fizz";
			//??°????¨???????
			while(ha[co]==false){co++;if(co==n)co=0;}
			//????¨?????????£?§£????????±???
			string a=in[i-1];
			if(a!=s){no--;ha[co]=false;}
			co++;
			if(co==n)co=0;
		}
		vi out;
		rep(i,n)if(ha[i])out.pb(i+1);
		rep(i,out.size()-1)cout<<out[i]<<" ";
		cout<<out[out.size()-1]<<endl;
	}
}

Measured memory_bytes: 1648
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
	for j in range(B+1):
		for k in range(C+1):
			if(i * 500 + j * 100 + k * 50 == X) :
				ans += 1;
		
print(ans)

Measured memory_bytes: 9104
#include"bits/stdc++.h"
using namespace std;

int main() {
	int n;
	long long k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto& e : a) {
		cin >> e;
	}

	long long cnt = 0;
	for (int i = 0;i < n;i++) {
		int under_num = 0;
		int under_num_back = 0;
		for (int j = 0;j < n;j++) {
			if (a[i] > a[j]) {
				under_num++;
				if (i < j) {
					under_num_back++;
				}
			}
		}
		cnt += (under_num_back * k)%1000000007 + (under_num * ((k * (k - 1)/2)%1000000007))%1000000007;
		cnt %= 1000000007;

	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(a, Math.max(b, c));
		System.out.println(a + b + c - max);
	}
}


Measured memory_bytes: 21716
def cal(a,b,c,d):
    list = []
    list.append(a*c)
    list.append(b*c)
    list.append(a*d)
    list.append(b*d)
    new_list = sorted(list, reverse=True)
    print(new_list[0])

a,b,c,d = map(int, input().split())
cal(a,b,c,d)

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

int main(){
 int n,a[100010];
 cin>>n;
 for(int i=0;i<n;i++){
   cin>>a[i];
   a[i]--;
 }
 int ans=0;
 for(int i=0;i<n;i++) if(a[a[i]]==i){ ans++; a[i]=-1;}
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  long long a, b, r, x, tmp;

  scanf("%lld", &a);
  scanf("%lld", &b);

  x = a * b;

  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  printf("%lld\n", x / b);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>


int main(void) {
	int xa=0, xb, ya=0,yb;
	int i;
	int w, h, n;
	int x[100],y[100],a[100];
	scanf("%d%d%d", &w,&h,&n);
	xb = w; yb = h;
	for (i = 0; i < n; i++) {
		scanf("%d%d%d", &x[i], &y[i], &a[i]);
		switch (a[i]) {
		case 1:if (x[i] > xa)xa = x[i]; break;
		case 2:if (x[i] < xb)xb = x[i]; break;
		case 3:if (y[i] > ya)ya = y[i]; break;
		case 4:if (y[i] < yb)yb = y[i]; break;
		}
	}
	if (xa < xb&&ya < yb)printf("%d\n", (xb - xa)*(yb - ya));
	else printf("%d", 0);

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll k;
    cin >> k;

    ll cur = 0;
    for (int i = 0; i <= k * 10; i++) {
        cur *= 10;
        cur += 7;
        cur %= k;

        if (cur == 0) {
            cout << i + 1;
            return 0;
        }
    }

    cout << "-1";

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
      cout << "Yes";
    }else if(S.at(1) == S.at(2) && S.at(2) == S.at(3)){
      cout << "Yes";
    }else{
    cout << "No";
  }
  return 0;
}

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


using namespace std;
int main()
{
    int n,r;
    while(cin>>n>>r){
        
        if(n==0&&r==0)break;
        stack<int> st1;
        for(int i=0; i<n; i++){
            st1.push(i+1);
        }
        
        for(int rop=0; rop<r; rop++){
            int p,c;
            cin>>p>>c;
            stack<int> st2,st3;
            for(int i=0; i<p-1; i++){
                st2.push(st1.top());
                st1.pop();
            }
            
            for(int i=0; i<c; i++){
                st3.push(st1.top());
                st1.pop();
            }
            
            while (!st2.empty()) {
                st1.push(st2.top());
                st2.pop();
            }
            
            while (!st3.empty()) {
                st1.push(st3.top());
                st3.pop();
            }
        }
        
        cout<<st1.top()<<endl;
    }
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int main()
{
	int n, x, i, j, k, count;

	while (true)
	{
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		for (i = 1; i <= n; i++)
		{
			for (j = i + 1; j <= n; j++)
			{
				for (k = j + 1; k <= n; k++) 
				{
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    ll res = 0;
    for (int i=1; i<N; ++i) {
        if (A[i-1] > A[i]) {
            res += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  long long x;
  cin>>x;
  long long m=100;
  long long cnt=0;
  while(m<x){
    cnt++;
    long long y=m*0.01;
    m+=y;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int h,w,n,t,i,j,k,e,a[10010],ans[110][110];
  cin >> h >> w >> n;
  for (i=0;i<n;i++) cin >> a[i];
  t=i=j=0;
  e=1;
  while (t<n){
    k=0;
    while (k<a[t]){
      ans[i][j]=t+1;
      if ((e==-1 && j==0) || (e==1 && j==w-1)){
        i++;
        e*=-1;
      }else{
        j+=e;
      }
      k++;
    }
    t++;
  }
  for (i=0;i<h;i++){
    for (j=0;j<w;j++) cout << ans[i][j] << ' ';
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	
	int a,b[10000],i,count;
	count=0;
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%d",&b[i]);
		for(b[i];b[i]>0;b[i]=b[i]/2){
			if(b[i]%2==0){
				count=count+1;
			} else {
				b[i]=0;
			}
		}
	}

	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char convert(char a) {
  if (a >= 'D') a-=3;
  else a = 'X'+a-'A';
  return a;
}
int main() {
  string a;
  cin >> a;
  REP(i,a.length()) {
    cout << convert(a[i]);
  }
  cout << endl;
}

Measured memory_bytes: 0
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define inf pow(10, 9)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int N, K;
  ci(N, K);
  map<int, int> A;
  rep(i, N){
    A[i + 1] = 0;
  }
  rep(i, K){
    int d;
    ci(d);
    rep(j, d){
      int a;
      ci(a);
      A[a] ++;
    }
  }
  int c = 0;
  each(i, A){
    if(i.sc == 0){
      c++;
    }
  }
  co(c);
}

Measured memory_bytes: 3640
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

ll dp1[MAX_N];
ll dp2[MAX_N];
ll a[MAX_N];
ll c[MAX_N];
int n,w;

int main()
{
    cin >> n >> w;
    for(int i = 1;i<=n;++i)
        cin >> a[i] >> c[i];
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=w;++j)
        {
            if (j>=a[i])
                dp2[j] = max(dp2[j],dp1[j-a[i]]+c[i]);
        }
        memcpy(dp1,dp2,sizeof dp1);
    }
    cout << dp1[w];
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7
s = sum(A)
AA = []
for a in A[:-1]:
    s = (s - a) % m
    AA.append(s)
ans = 0
for i in range(N-1):
    ans += (A[i] * AA[i]) % m
ans %= m
print(ans)

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

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> h(n);
	rep(i,n){
		cin >> h[i];
	}
	
	ll r = 1000000000; //必ず条件を満たす
	ll l = 0; //必ず条件を満たさない
	
	while(r-l>1){
		ll t = (r+l)/2; //t回以内で魔物を全滅させることができるか判定する。
		vector<ll> temp(n);
		ll count = 0;
		rep(i,n){
			temp[i] = h[i] - t*b;
			if(temp[i] > 0){
				count += (temp[i]+a-b-1)/(a-b); //切り上げに注意
			}
		}
		if(count <= t){
			r = t;
		}else{
			l = t;
		}
	}
	
	cout << r << endl;
	
    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(){

    long N=0;
    long H[100000]={};
    int out=0;


    scanf("%ld",&N);

    for(int i=0;i<N;i++){
        scanf("%ld",&H[i]);
    }

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

    }

    if(out==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    a += b;
    REP(i, n){
        if (s[i] == 'a' && a>0) {
            a--;
            COUT("Yes");
        }else if (s[i] == 'b' && a>0 && b>0){
            a--;
            b--;
            COUT("Yes");
        }else{
            COUT("No");
        }
    }
}


Measured memory_bytes: 3688
import sys
sys.stdin.readline()
ss = list(map(int,sys.stdin.readline().split()))
sys.stdin.readline()
tt = list(map(int,sys.stdin.readline().split()))

cnt = 0
for t in tt:
    beg = 0
    end = len(ss)-1
    while beg<=end:
        ctr = (beg+end)//2
        if t==ss[ctr]:
            cnt += 1
            break
        elif t<ss[ctr]:
            end=ctr-1
        else: # t>s[ctr]                                                        
            beg=ctr+1
print(cnt)


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

using namespace std;


const int N = 1e5 + 5;
const int INF = 2e9;

int h[N];
int mem[N];
int n;

int dp(int i){

    if(i > n-1)  return INF;
    if(i == n-1) return 0;

    if(mem[i] != -1) return mem[i];

    int ans = INF;
    for(int j = 1 ; j <= 2 ; j ++){

            ans = min(ans , abs(h[i] - h[i + j]) + dp(i + j));

    }

    return mem[i] = ans;
}

main(){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &h[i]);
    }

    memset(mem , -1 , sizeof mem);
    printf("%d\n" , dp(0));

    return 0;
}


Measured memory_bytes: 4096