akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
vectors = [list(map(int, input().split())) for i in range(N)]

sumamry = [0] * 30
for vec in vectors:
    ans = vec[1:]
    for a in ans:
        sumamry[a-1] += 1

ret = 0
for s in sumamry:
    if s == N:
        ret += 1

print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> s;
	vector<ll> a(s.size() + 1);
	ll cnt = 0;
	ll l = 0; ll r = 0;
	ll M, m;
	rep(i, s.size()-1) {
		if (s[i] == '>' && s[i+1] == '<') {
			r++;
			M = max(r, l);
			m = min(r, l);
			cnt += M * (M + 1) / 2 + m * (m - 1) / 2;
			l = 0; r = 0;
			continue;
		}
		if (s[i] == '<') l++;
		else r++;
	}
	if (s[s.size() - 1] == '<') {
		l++;
	}
	else {
		r++;
	}
	M = max(r, l);
	m = min(r, l);
	cnt += M * (M + 1) / 2 + m * (m - 1) / 2;
	cout << cnt << endl;
}

Measured memory_bytes: 4740
import java.util.Scanner;
import java.lang.String;
 
public class Main {
  
  public static void main (String[] arg) {
    Scanner sc = new Scanner(System.in);
    rockpaper(sc);
    sc.close();
  }
  
  private static void rockpaper(Scanner sc) {
    String tcdSequence = sc.next();
    int tcdLength = tcdSequence.length();
    char[] acdSequence = new char[tcdLength];
    for (int i = 0; i < acdSequence.length; i++) {
      if (i % 2 == 0) {
        acdSequence[i] = 'g';
      } else {
        acdSequence[i] = 'p';
      }
    }
    
    int acdScore = 0;
    for (int k = 0; k < tcdSequence.length(); k++) {
      if ((tcdSequence.charAt(k) == 'g') && (acdSequence[k] == 'p')) {
        acdScore++;
      } else if ((tcdSequence.charAt(k) == 'p') && (acdSequence[k] == 'g')) {
        acdScore--;
      }
    }
    
    System.out.println(acdScore);
  }
}

Measured memory_bytes: 25616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == S[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < S.size() - 2; i++) {
		if (S[i] == S[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *NodePointer;

NodePointer r,NIL;

NodePointer find(NodePointer x,int k)
{
  while(x != NIL && k != x->key)
    {
      if(k < x->key)
	{
      
	  x = x->l;
	}
      else
	{
	  x = x->r;
	}
    }
  return x;
}

void insert(int k)
{
  NodePointer y = NIL;
  NodePointer x = r;

  NodePointer z = (NodePointer)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->l;
	}
      else
	{
	  x = x->r;
	}
    }
  z->p = y;

  if(y == NIL)
    {
      r = z;
    }else if(z->key < y->key)
    {
      y->l = z;
    }
  else
    {
      y->r = z;
    }
}

void inorder(NodePointer u)
{
  if(u == NIL)
    {
      return;
    }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(NodePointer u)
{
  if(u == NIL)
    {
      return;
    }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print()
{
  inorder(r);
  puts("");
  preorder(r);
  puts("");
}

int main()
{
  int n,i,j,z,x;
  char s[10];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",s);
      if(s[0] == 'f')
	{
	  scanf("%d",&x);
	  NodePointer t = find(r,x);
	  if(t == NIL)printf("no\n");
	  else printf("yes\n");

	}
      else if(s[0] == 'i')
	{
      
	  scanf("%d",&z);
	  insert(z);
	}
      else
	{
	  print();
	}
    }

  return 0;
}



Measured memory_bytes: 20464
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int ans = min(b, d) - max(a, c);
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int h, w, k;
string s[10];
int cnt[11][1001];

int solve(int s) {
    vector<int> sp = {0};
    for (int i = 0; i < h-1; i++) if ((s>>i)&1) sp.push_back(i+1);
    sp.push_back(h);
    int ans = 0;
    for (int j = 0, p = 0; j < w; ) {
        bool ok = true;
        for (int i = 1; i < sp.size(); i++)
            if (cnt[sp[i]][j+1] + cnt[sp[i-1]][p] - cnt[sp[i]][p] - cnt[sp[i-1]][j+1] > k) {
                ok = false; break;
            }
        if (!ok) {
            if (p == j) return 1<<30;
            p = j;
            j++; 
            ans++;
        } else {
            j++;
        }
    }
    return ans + sp.size() - 2;
}

int main() {
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cnt[i+1][j+1] = (s[i][j] - '0') + cnt[i][j+1] + cnt[i+1][j] - cnt[i][j];
    int ans = 1<<30;
    for (int s = 0; s < 1<<(h-1); s++) ans = min(ans, solve(s));
    cout << ans << endl;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(d:usize g:i64){d;list:(i64,i64)});
    let mut v = list
        .into_iter()
        .enumerate()
        .map(|(a, (b, c))| ((a as i64) + 1, b, c))
        .collect::<Vec<_>>();
    v.reverse();
    f(g, &v, 0, 0, 0).to_string()
}

fn f(g: i64, list: &Vec<(i64, i64, i64)>, sum: i64, i: usize, count: i64) -> i64 {
    if sum >= g {
        count
    } else if i == list.len() {
        <i64>::max_value()
    } else {
        std::cmp::min(f(g, list, sum, i + 1, count), {
            let (a, b, c) = list[i];
            if a * b * 100 + sum >= g {
                let x = div2(g - sum, a * 100);
                f(g, list, sum + x * a * 100, i + 1, count + x)
            } else {
                f(g, list, sum + a * b * 100 + c, i + 1, count + b)
            }
        })
    }
}

fn div2(a: i64, b: i64) -> i64 {
    (a + (b - 1)) / b
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 700\n3 500\n5 800" => "3",
    test2: "2 2000\n3 500\n5 800" => "7",
    test3: "2 400\n3 500\n5 800" => "2",
    test4: "5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000" => "66",
}


Measured memory_bytes: 4352
SA = list(input())
SA.append('end')
SB = list(input())
SB.append('end')
SC = list(input())
SC.append('end')
count = 0

while(len(SA)*len(SB)*len(SC) != 0):
  if(count == 0):
    tmp = SA.pop(0)
    count += 1
  else:
    if(tmp == 'a'):
      tmp = SA.pop(0)
    elif(tmp == 'b'):
      tmp = SB.pop(0)
    elif(tmp == 'c'):
      tmp = SC.pop(0)
  
if(len(SA) == 0):
  print('A')
elif(len(SB) == 0):
  print('B')
elif(len(SC) == 0):
  print('C')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int ans = 0;
  int cou = 0;
  string T = "ATGC";
  for(int i=0;i<S.size();i++){
    bool isATGC = false;
    for(int j=0;j<4;j++){
      if(S[i] == T[j]){
        cou++;
        isATGC = true;
      }
    }
    if(!isATGC || i == S.size() - 1){
      ans = max(ans, cou);
      cou = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val a = Array.fill(5)(Scanner.nextInt)
  val fractionMinIndex = a.zipWithIndex.minBy(ai=>{
    if (ai._1%10 == 0){
      10
    } else {
      ai._1%10
    }
  })._2
  val result = a.zipWithIndex.map(ai=>{
    if (ai._2 != fractionMinIndex) {
      (scala.math.ceil(ai._1/10.0)*10).toInt
    } else {
      ai._1
    }
  }).sum

  println(result)
}

Measured memory_bytes: 25548
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	long long ans;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) ans = 0;
	else {
		ans = min(a*b, b*c);
		ans = min(ans, a*c);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto ip = readln.split.to!(int[]), N=ip[0], M=ip[1];
	int L = 0;
	int R = N;
  
	foreach(i; 0..M){
		auto LR = readln.split.to!(int[]);
		L = max(L, LR[0]);
		R = min(R, LR[1]);
	}
  
  	if(L<=R) writeln(R-L+1);
  	else writeln(0);
}

Measured memory_bytes: 1276
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i,a,b;
        String c="";
        for(i=0; ;i++){
            a=sc.nextInt();
            c=sc.next();
            b=sc.nextInt();
            if(c.equals("+")){
                System.out.println(a+b);
            }else if(c.equals("-")){
                System.out.println(a-b);
            }else if(c.equals("*")){
                System.out.println(a*b);
            }else if(c.equals("/")){
                System.out.println(a/b);
            }else if(c.equals("?")){
                break;
            }        
        }
    }
}


Measured memory_bytes: 26424
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define F first
#define S second
#define forcin(n, a) for(int i = 0; i < n; ++i) {cin >> a[i];}
#define forcout(n, a) for(int i = 0; i < n; ++i) {cout << a[i] << " ";}
#define PI acos(-1)
#define forup(st, fin) for(int i = st; i < fin; ++i)
#define fordown(st, fin) for(int i = st; i >= fin; --i)
#define reverse_all(v) reverse(v.begin(), v.end())
#define sort_all(v) sort(v.begin(), v.end())
#define sort_allr(v) sort(v.rbegin(), v.rend())
#define mmin(a, b, c) min(min(a, b), c)
#define mmax(a, b, c) max(max(a, b), c)

///#define cin in
///#define cout out
///#define int long long

const ll MAXL = 1e18;
const int N = 10005000;
const int MAXN = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        if (i && v[i] == v[i - 1]) {
            v[i] = -1;
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

/*
 5
 1 2 3 2 4
 */

Measured memory_bytes: 892
num = input().split(' ')
num_data = [int(num[i]) for i in range(2)]
data = input().split(' ')
data_m = [int(data[i]) for i in range(num_data[1])]
data_m.append(num_data[0] + data_m[0])
key = data_m[0]
locate = 0
for i in range(num_data[1]):
    if(key < data_m[i + 1] - data_m[i]):
        key = data_m[i + 1] - data_m[i]
        locate = i + 1
print(num_data[0] - key)


Measured memory_bytes: 24564
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
class P
{
    static void Main()
    {
        int[] ipts = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = ipts[0], m = ipts[1];
        int[] check = new int[m];
        for (int i = 0; i < n; i++)
        {
            ipts = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int k = ipts[0];
            for (int j = 1; j <= k; j++)
            {
                int a = ipts[j] - 1;
                check[a]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++)
            ans += check[i] == n ? 1 : 0;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <string.h>

#define testin freopen("1.txt","r",stdin);
#define testout freopen("out.txt","w",stdout);
#define ll long long

using namespace std;

const int maxn=(int)1e5+10;

char c[maxn];


int main(){
    cin>>c;
    int n=strlen(c),cnt1=1,cnt2=1,now=0;
    while(now<n){
        if(c[now]=='R'){
            cnt1=1;
            while(c[now+1]=='R'){
                cnt1++;
                now++;
            }
        }else{
            cnt2=1;
            while(c[now+1]=='L'){
                cnt2++;
                now++;
                if(now==n-1) break;
            }
            for(int i=0;i<cnt1-1;i++) cout<<0<<" ";
            int sum=cnt1+cnt2,t1,t2;
            if(sum%2==0){
                cout<<sum/2<<" "<<sum/2<<" ";
            }else{
                if(cnt1%2){
                    t2=sum/2;
                    t1=sum-t2;
                }else{
                    t1=sum/2;
                    t2=sum-t1;
                }
                cout<<t1<<" "<<t2<<" ";
            }
            for(int i=0;i<cnt2-1;i++) cout<<0<<" ";
        }
        now++;
    }
    cout<<endl;
    return 0;
}


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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

int n, k;

int main(){
    scanf("%d %d", &n, &k);

    if(k == 1){
        puts("0");
    } else {
        printf("%d\n", n - k);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(abs(x-a)<abs(x-b)){cout<<"A"<<endl;return 0;}
    else{cout<<"B"<<endl;return 0;}
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [str(input()) for i in range(n)]

ss = [''.join(sorted(i)) for i in s]
ans = 0
key_dict = {}

for i in ss:
    if i in key_dict:
        key_dict[i] += 1
    else:
        key_dict[i] = 1

a = key_dict.values()
al = [i * (i-1) / 2 if i > 1 else 0 for i in a]

ans = int(sum(al))
print(ans)

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

int main() {
  string s;
  cin>>s;
  for(char i='a';i<='z';i++){
    bool flag=true;
    for (int j=0;j<s.size();j++){
      if(s[j]==i) {flag=false; break;}
    }
    if(flag) {cout<<i<<endl; return 0;}
  }
  cout<<"None"<<endl;
}
    

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int d(int a,int b){ return abs(a-b);}

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int sum = d(0,v[0]) + d(0,v[n-1]);
    rep(i,v.size()-1){
        sum += d(v[i+1],v[i]);
    }
    
    cout<<sum-d(0,v[0])-d(v[0],v[1])+d(0,v[1])<<endl;
    
    for(int i=1;i<n-1;i++){
        cout<<sum - d(v[i-1],v[i]) - d(v[i],v[i+1]) + d(v[i-1],v[i+1])<<endl;
    }

    cout<<sum-d(v[n-2],v[n-1])-d(v[n-1],0)+d(0,v[n-2])<<endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int abs(int x){
  return max(-x,x);
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  int t[100001];
  int x[100001];
  int y[100001];
  string ans="Yes";
  for(int i=1;i<=N;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  if(N==1){
    int xdif=x[1];
    int ydif=y[1];
    int dif=xdif+ydif;
    int tdif=t[1];
    int b=tdif%2;
    if(dif>tdif || (dif%2)!=b){
      ans="No";
    }
  }
  for(int i=2;i<=N;i++){
    int xdif=abs(x[i]-x[i-1]);
    int ydif=abs(y[i]-y[i-1]);
    int dif=xdif+ydif;
    int tdif=t[i]-t[i-1];
    int b=tdif%2;
    if(dif>tdif || (dif%2)!=b){
      ans="No";
    }
  }
  P(ans);
  return 0;
}


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

int main(){
  ll a,b,c,k,i;
  cin >> a >> b >> c >> k;
  for(i=1;i<=k;i++){
    if(a>=b){
      b=b*2;
    }
    else{
      c=c*2;
    }
  }
  if((a<b)&&(b<c)){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
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;
}
ll n,c;
ll h[220000];
ll dp[220000];
ll calc(l_l f,ll x){
    return f.fi*x+f.se;
}
struct ConvexHullTrick{
    vector<l_l> f;
    vector<ll> p;
    ConvexHullTrick(){};
    void add_line(ll a,ll b){
        l_l new_f=l_l(a,b);
        if(f.empty()){
            f.pb(new_f);
            return;
        }
        if(calc(new_f,(ll)INF)>=calc(f.back(),(ll)INF))return;
        if(calc(new_f,-(ll)INF)<=calc(f.front(),-(ll)INF)){
            f.clear();
            p.clear();
            f.pb(new_f);
            return;
        }
        while(!p.empty()){
            ll lastl=p.back()+1;
            if(calc(new_f,lastl)<=calc(f.back(),lastl)){
                f.pop_back();
                p.pop_back();
            }
            else break;
        }
        ll l;
        if(p.empty())l=-INF;
        else l=p.back()+1;
        ll r=INF;
        while(r-l>1){
            ll mid=(r+l)/2;
            if(calc(new_f,mid)<=calc(f.back(),mid))r=mid;
            else l=mid;
        }
        f.pb(new_f);
        p.pb(l);
    }
    ll get_min(ll x){
        ll ind=lower_bound(p.begin(),p.end(),x)-p.begin();
        return calc(f[ind],x);
    }
};
int main(){
    cin>>n>>c;
    rep(i,n)cin>>h[i];
    ConvexHullTrick ch;
    dp[0]=0;
    ch.add_line(-2*h[0],dp[0]+h[0]*h[0]);
    for(int i=1;i<n;i++){
        dp[i]=ch.get_min(h[i])+h[i]*h[i]+c;
        ch.add_line(-2*h[i],dp[i]+h[i]*h[i]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 13080
N = int(input())
a = list(map(int,input().split()))

data = []
for i in range(N-1):
  if a[i+1]-a[i] == 0:
    continue
  else:
    data.append(a[i+1]-a[i])
#print(data)

if len(data) <= 1:
  print(1)
else:
  ans = 0
  left = 0
  i = 0
  while left < len(data)-1:
    if data[left]*data[left+1] < 0: # 極値
      ans += 1
      left += 1
      i = left
    left += 1
  else:
    if i == len(data):
      pass
    else:
      ans += 1
    print(ans)

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

int main()
{
	int a, b;
	cin >> a >> b;
	
	for (int i = 1; i <= 1000; ++i)
	{
		if (floor(i * 0.08) == a and floor(i * 0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  string s; cin >> s;
  bool nine_flag = true;
  Loop1(i, s.length() - 1) {
    if (s[i] != '9') nine_flag = false;
  }
  int ans = 0;
  if (nine_flag) {
    Loop(i, s.length()) {
      ans += s[i] - '0';
    }
  }
  else {
    if (s.length() == 1) {
      ans = s[0] - '0';
    }
    else {
      s[0]--;
      Loop1(i, s.length() - 1) {
        s[i] = '9';
      }
      Loop(i, s.length()) {
        ans += s[i] - '0';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h;
vector<int> vv;
vector<int> vvb;

int dp[1000000]={};
int dpb[1000000]={};
void pir_cal(){
	for(int i=1;i<1000000;i++){
		dp[i]=1000000;
		dpb[i]=1000000;
	}
	for(int i=1;i<200;i++){
		ll j=(ll)i*(i+1)*(i+2)/6;
		if(j>=1000000){
			break;
		}
		vv.push_back(j);
		dp[j]=1;
		if(j%2==1){
			vvb.push_back(j);
			dpb[j]=1;
		}
	}
	/*for(int i=0;i<vv.size();i++)
		cout<<vv[i]<<endl;*/
}

void cal_dp(){
	
	for(int i=1;i<1000000;i++){
		
		for(int j=0;j<vv.size()&&vv[j]<i;j++){
			dp[i]=min(dp[i],dp[i-vv[j]]+1);
			
		}
		for(int j=0;j<vvb.size()&&vvb[j]<i;j++){
			dpb[i]=min(dpb[i],dpb[i-vvb[j]]+1);
			
		}
		
	}
}
		
int main(){
	pir_cal();
	cal_dp();
	while(1){
		cin>>h;
		if(h==0)break;
		printf("%d %d\n",dp[h],dpb[h]);
	}
	return 0;
}


Measured memory_bytes: 10856
#include <iostream>

using namespace std;

int digits(int n)
{
	if (n == 0) {
		return 0;
	}
	return 1 + digits(n / 10);
}

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

	int ans = 0;

	for (int i = 1; i <= N; ++i) {
		if (digits(i) % 2 != 0) {
			++ans;
		}
	}
	cout << ans << endl;
}


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

void p_day()
{
    int M,D;
    cin>>M>>D;
    
    int day = 0;
    
    for(int i=1; i<=M; i++)
    {
        for(int j=10; j<=D; j++)
        {
            int d1 = j%10, d10 = j/10;
            if(d1>=2 && d10>=2 && d1*d10==i)
            {
                day++;
            }
        }
    }
    
    cout<<day<<endl;
}
int main()
{
    p_day();
    return 0;
}

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

using namespace std;
using ll = long long;

void solve(){
	int a,b,k;
	cin >> a >> b >> k;
	set<int> da,db;
	for(int i=1;i*i<=a;++i){
		if(a%i==0){
			da.insert(-i);
			da.insert(-a/i);
		}
	}
	for(int i=1;i*i<=b;++i){
		if(b%i==0){
			db.insert(-i);
			db.insert(-b/i);
		}
	}
	for(auto &st:db){
		if(da.count(st)){
			--k;
		}
		if(k==0){
			cout << -st << '\n';
			break;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
  	ll n;
  	cin >> n;
  	ll X = 0;
  	for (int i = 1; i <= n; i ++) {
  		cin >> a[i];
		  X ^= a[i];	
	  }
	for (int i = 1; i <= n; i ++) {
		a[i] ^= X;
		cout << a[i] << ' ';
	}
}

Measured memory_bytes: 5176
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1;rrp(i,n-r+1,n+1){ans*=i;ans%=mod;}return ans/=fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
double ans=0;
////////////////////////////////////////////////////////////
int main(){
 char s[200000];
 sc(s);
 ll len=strlen(s);
 deque<char>deque(s,s+len);
 ll sm=0,q,t,r;char c;
 sc(t);
 rep(i,0,t){
  sc(q);
  if(q==1)sm++;
  if(q==2){
   sc(r);sc(c);
   if(r==1){
    if(sm%2==1)deque.push_back(c);
    else deque.push_front(c);
   }
   if(r==2){
    if(sm%2==0)deque.push_back(c);
    else deque.push_front(c);
   }
  }
 }
 if(sm%2==1)reverse(all(deque));
 for(auto itr=deque.begin();itr!=deque.end();++itr){
  if(*itr==NULL)break;
  cout<<*itr;
 }
 pnn;

return 0;}


Measured memory_bytes: 4060
#include<stdio.h>

int main()
{
	int i, j, k, n, m, l;
	long t;
	 
	scanf("%d %d %d",&n,&m,&l);
	
	int a[n][m],b[m][l];
	
	//行列A入力
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	//行列B入力
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
		t = 0;
			for(k=0;k<m;k++){
			t += a[i][k]*b[k][j];
			}
		printf("%ld",t);
		if(j<l-1) printf(" ");
		else putchar('\n');
		
		}
	}
	
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2 * acos (0.0)
int main()
{
    ll a,b,c,d,e,f,g,h,ct;
    string s1,s2,s3,s4;
    ll n,k,t,x,y,x1,x2,y1,y2,m;
    cin>>t;
    m=0;
    for(ll i=1;i<=t;i++)
    {
        for(ll j=1;j<=t;j++)
        {
            for(ll k=1;k<=t;k++)
            {
                d=__gcd(__gcd(i,j),k);
                m+=d;
            }
        }
    }


     cout<<m<<endl;
}








Measured memory_bytes: 3632
/**
 * @author sakt_coder
 * created on 2020-09-19 17:34
 */
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		String s=nextLine();
		if(s.charAt(s.length()-1)=='s')
		{
			out.print(s);
			out.println("es");
		}
		else
		{
			out.print(s);
			out.println("s");
		}
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 32832
import heapq

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

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

li = [(-(a[0]+b[0]+c[0]),0,0,0)]

heapq.heapify(li)

for i in range(k):
    ans = heapq.heappop(li)
    print(-ans[0])
    if x > ans[1]+1 and (-(a[ans[1]+1]+b[ans[2]]+c[ans[3]]),ans[1]+1,ans[2],ans[3]) not in li: 
        heapq.heappush(li,(-(a[ans[1]+1]+b[ans[2]]+c[ans[3]]),ans[1]+1,ans[2],ans[3]))
    if y > ans[2]+1 and (-(a[ans[1]]+b[ans[2]+1]+c[ans[3]]),ans[1],ans[2]+1,ans[3]) not in li:
        heapq.heappush(li,(-(a[ans[1]]+b[ans[2]+1]+c[ans[3]]),ans[1],ans[2]+1,ans[3]))
    if z > ans[3]+1 and (-(a[ans[1]]+b[ans[2]]+c[ans[3]+1]),ans[1],ans[2],ans[3]+1) not in li:
        heapq.heappush(li,(-(a[ans[1]]+b[ans[2]]+c[ans[3]+1]),ans[1],ans[2],ans[3]+1))

Measured memory_bytes: 3828
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn dfs(
   v: usize,
   t: usize,
   used: &mut Vec<bool>,
   nodes: &mut Vec<usize>,
   to: &Vec<Vec<usize>>,
) -> bool {
   used[v] = true;
   for &u in &to[v] {
      if u == t || !used[u] && dfs(u, t, used, nodes, to) {
         nodes.push(v);
         return true;
      }
   }
   false
}

fn main() {
   input! {
      n: usize,
      m: usize,
      ab: [(Usize1, Usize1); m]
   }

   let mut edge = vec![vec![false; n]; n];
   let mut to = vec![vec![]; n];
   for (a, b) in ab {
      to[a].push(b);
      edge[a][b] = true;
   }
   for i in 0..n {
      let mut nodes = vec![];
      let mut used = vec![false; n];
      if !dfs(i, i, &mut used, &mut nodes, &to) {
         continue;
      }
      nodes.reverse();
      loop {
         let n = nodes.len();
         let mut update = None;
         'outer: for i in 0..n {
            for j in 0..n {
               if i == j || j == (i + 1) % n {
                  continue;
               }
               if edge[nodes[i]][nodes[j]] {
                  update = Some((i, j));
                  break 'outer;
               }
            }
         }
         if let Some((i, j)) = update {
            let mut new = vec![];
            if i < j {
               for k in 0..n {
                  if i < k && k < j {
                     continue;
                  }
                  new.push(nodes[k]);
               }
            } else {
               for k in 0..n {
                  if k < i || j < k {
                     continue;
                  }
                  new.push(nodes[k]);
               }
            }
            nodes = new;
         } else {
            break;
         }
      }
      println!("{}", nodes.len());
      for a in nodes {
         println!("{}", a + 1);
      }
      return;
   }
   println!("-1");
}



Measured memory_bytes: 3360
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c,d;
	LL p,q;
	LL t1,t2;
	cin>>t1>>t2;
	cin>>a>>b>>c>>d;
	p=a-c,q=b-d;
	if((p>0 && q>0) || (p<0 && q<0)){
		cout<<0<<endl;
		return 0;
	}
	p*=t1,q*=t2;
	if(p>q)p=-p,q=-q;
	if(p+q<0){
		cout<<0<<endl;
		return 0;
	}
	if(p+q==0){
		cout<<"infinity"<<endl;
		return 0;
	}
	a=q/(p+q)*2-1;
	if(q%(p+q)==0)a--;
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <algorithm>
#define ll  long long int
//#define mod 1000000007
using namespace std;
int main() 
{
	int n,i,ans=0,j;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<=999;i++)
	{
		string k=to_string(i);
		if(i<100)
			k="0"+k;
		if(i<10)
			k="0"+k;
		int ind=0;
		for(j=0;j<n;j++)
		{
			if(s[j]==k[ind])
				ind++;
			if(ind==3){
				//cout<<"n is "<<k<<endl;
				ans++;
				break;
				}
				
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int vis[50];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int k;
		cin>>k;
		for(int j=0;j<k;j++)
		{
			int temp;
			cin>>temp;
			vis[temp]++;
		}
	 } 
	 int ans=0;
	 for(int i=1;i<=m;i++)
	 	if(vis[i]==n)	
	 		ans++;
	cout<<ans<<endl; 
	return 0;
}

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using pll = pair < ll , ll >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vl  = vector < ll >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
vii v;

bool cmp(ii a , ii b){
    if(a.second == b.second)return a.first < b.first;
    return a.second > b.second;
}

set < int > days;

void solve(){
    scanf("%d %d" , &n , &m);

    for(int i = 1 ; i <= n ; i ++){
        int a , b;
        scanf("%d %d" , &a , &b);

        v.push_back({a , b});
    }

    sort(v.begin() , v.end() , cmp);

    for(int i = 0 ; i <= m ; i ++){
        days.insert(i);
    }

    int ans = 0;
    for(ii V : v){
        int a = V.first;
        int b = V.second;

        if(a > m)continue;
        auto it = days.lower_bound(a);
        if(it == days.end())continue;

        ans += b;
        days.erase(it);
    }

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

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}





Measured memory_bytes: 5748
import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.append(X)
    x = sorted(x)

    m = []
    for i in range(N):
        m.append(x[i + 1] - x[i])
    print(gcd_list(m))


main()


Measured memory_bytes: 16276
#include<cstdio>
int n,m,mo,jie[100001],ans,f[100001],a[100001],pre[100011];
int mi(int x,int y)
{
	int s=1;
	while(y!=0)
	{
		if(y%2==0)s=(1ll*s*x)%mo;
		x=(1ll*x*x)%mo;
		y=y/2;
	}
	return(s);
}
int main()
{
	scanf("%d",&n);
	mo=1000000007;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	ans=0;
	for(int i=1;i<=n;i++)ans=(ans+a[i])%mo;
	jie[0]=1;
	for(int i=1;i<=n;i++)jie[i]=(1ll*jie[i-1]*i)%mo;
	pre[n+1]=1;
	for(int i=n;i>=1;i--)pre[i]=(1ll*pre[i+1]*i)%mo;
	f[n-1]=0;
	ans=(1ll*ans*jie[n])%mo;
	for(int i=n-2;i>=0;i--)f[i]=(f[i+1]+1ll*pre[n-1-i+2]*jie[n-1-i])%mo;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+1ll*f[i-1]*a[i])%mo;
		ans=(ans+1ll*f[n-i]*a[i])%mo;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
    int D;
    cin >> D;
    map<int , string> eve;
 
    eve[25] = "Christmas";
    eve[24] = "Christmas Eve";
    eve[23] = "Christmas Eve Eve";
    eve[22] = "Christmas Eve Eve Eve";
 
    cout << eve[D] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int num[N * 2], n, del[N * 2];
inline bool check(int mid) {
	for (int i = 1;i < n * 2 - 1;i++) del[i] = (num[i] >= mid) == (num[i + 1] >= mid);
	for (int i = 1;i < n;i++) {
		if (del[n + i - 1]) return num[n + i - 1] >= mid;
		if (del[n - i]) return num[n - i] >= mid;
	}
	return num[1] >= mid;
}
int main() {
	scanf("%d", &n);
	for (int i = 1;i < n * 2;i++) scanf("%d", &num[i]);
	int l = 1, r = 2 * n - 1, mid, ans = -1;
	while (l <= r) 
		if (check(mid = (l + r) >> 1)) ans = mid, l = mid + 1;
		else r = mid - 1;
	printf("%d\n", ans);
}

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

using namespace std;
#define         MAX         2*10000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)
#define         inf         10000000




int main(){

    //input;
    //output;

    int k,a,b;
    cin>>k>>a>>b;

    int l = a/k;
    int r = b/k;

    if(l*k>=a && l*k<=b){
        cout<<"OK"<<endl;
        return 0;
    }

    if(r*k>=a && r*k<=b){
        cout<<"OK"<<endl;
        return 0;
    }

    cout<<"NG"<<endl;

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	long long int a;
	cin >> n;
	vector<long long int> arr;
	bool zeroFound = false;
	for(int i = 0; i < n; i++) {
		cin >> a;
		if(a == 0) {
			zeroFound = true;
		}
		arr.push_back(a);
	}
	if(zeroFound){
		cout << 0 << endl;
		return 0;
	}
	else {
		long long int product = 1;
		for(int i = 0; i < n; i++) {
			if(arr[i] <= 1000000000000000000/product) {
				product *= arr[i];
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		cout << product << endl;
	}
	return 0;
}

Measured memory_bytes: 4232
N = int(input())
condos = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(N):
    b, f, r, v = map(int, input().split())
    condos[b-1][f-1][r-1] += v

for k in range(4):
    for j in range(3):
        for i in range(10):
            print(" {}".format(condos[k][j][i]), end="")
        print()
    if k < 3:
        print("####################")


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (abs(a-c)<=d ||(abs(a-b)<=d&&abs(b-c)<=d))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll x;
	cin >> x;

	ll res = -inf;
	for (ll i = 0; i <= 100; i++)
	{
		for (ll j = 2; j <= 100; j++)
		{
			ll s = (ll)pow(i, j);
			if (s <= x)
			{
				res = max(res, s);
			}
		}
	}

	println(res);
}

Measured memory_bytes: 640
while 1:
	try:
		h=[input() for i in [1]*5]
		if (1 in h and 2 in h and 3) in h or max(h.count(1),h.count(2),h.count(3))==5:
			for i in h:print 3
		elif 1 in h:
			if 2 in h:
				for i in h:print 1 if i==1 else 2
			else:
				for i in h:print 1 if i==3 else 2
		elif 2 in h:
			for i in h:print 1 if i==2 else 2
	except:
		break

Measured memory_bytes: 4224
S = list(input())
N = len(S)
M = (N - 1) // 2
X = S[:M]
L = (N + 3) // 2
Z = S[L-1:]
if S == list(reversed(S)) and X == list(reversed(X)) and Z == list(reversed(Z)):
    print('Yes')
else:
    print('No')

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

int main(){
  string s;
  int n;
  
  cin >> n >> s;
  
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < n; j++){
      if(s[i] == 'Z'){
        s[i] = 'A';
      }
      else{
        s[i] += 1;
      }
    }
  }
  
  cout << s << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n;
  cin >> n;
  long long int mod = 1e9+7;
  long long int a[1050] = {};
  for(int i=2; i<=n; i++){
    int num = i;
    for(int j=2; j<=1000; j++){
      while(num%j==0){
        a[j]++;
        num /= j;
      }
    }
  }
  long long int ans = 1;
  for (int i = 2; i <= n; i++){
    ans *= a[i] + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	typedef pair<int, pint> E;
	priority_queue<E> q;
	int N = in();
	rep(y,N)rep(x,N) {
		int A = in();
		if (A && y < x) q.push(mp(-A, mp(y, x)));
	}
	
	int dist[310][310];
	rep(i,310)rep(k,310)dist[i][k] = INF;
	rep(i,310)dist[i][i] = 0;
	ll ans = 0;
	while (! q.empty()) {
		E e = q.top();
		q.pop();
		int c = -e.first;
		int u = e.second.first;
		int v = e.second.second;
		
		int sp = INF;
		rep(i,N) sp = min(sp, dist[u][i] + dist[i][v]);
		if (sp < c) goto NG;
		dist[u][v] = dist[v][u] = c;
		if (sp == c) continue;
		ans += c;
	}
	
	cout << ans << endl;
	return 0;
	
	NG:;
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1272