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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

bool inc(char& c) {
  switch (c) {
    case '3':
      c = '5';
      return false;
    case '5':
      c = '7';
      return false;
    case '7':
      c = '3';
      return true;
  }
}

void inc(string& s) {
  bool carry = inc(s[s.size() - 1]);
  for (int i = s.size() - 2; i >= 0; --i) {
    if (!carry) break;
    carry = inc(s[i]);
  }
  if (carry) s = '3' + s;
}

bool contains(const string& s, char c) { return s.find(c) != string::npos; }

int main() {
  in(int, n);
  int ans = 0;
  string s = "3";
  while (stoll(s) <= n) {
    if (contains(s, '3') && contains(s, '5') && contains(s, '7')) {
      ++ans;
    }
    inc(s);
  }
  out(ans);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n;
  if(n==0)cout<<1<<endl;
  else if(n==1)cout<<2<<endl;
  else if(n==2)cout<<1<<endl;
  else cout<<0<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ll siz = 1e5 + 10;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 2e9;
const ll MAXX = 1e18;



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < sz(s); i++)
        if (s[i] != t[i])
            ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3704
# coding: utf-8
# Your code here!
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def search(S, key, n):
    i = 0
    S.append(key)
    while(S[i] != key):
        i += 1
    if(i == n):
        S.pop()
        return 0
    else:
        S.pop()
        return 1
        
        
count = 0
for key in T:
    count += search(S, key, n)
print(count)



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

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            max = a + b;
			if (max < a - b)
				max = a - b;
			if (max < a * b)
				max = a * b;
			
            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if (a == b) cout << "Draw" << "\n";
    else if ( a == 1 ) cout << "Alice" << "\n";
    else if ( b == 1 ) cout << "Bob" << "\n";
    else if (a > b) cout << "Alice" << "\n";
    else if (b > a) cout << "Bob" << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
  int i, cnt = 0;
  char word[5];
  int s[26];
  scanf("%s", word);
  for (i = 0; i < 26; i++)
    s[i] = 0;
  for (i = 0; i < strlen(word); i++) {
    s[word[i]-'A']++;
  }
  for (i = 0; i <= 25; i++) {
    if (s[i] == 2)
      cnt++;
  }
  if (cnt == 2)
    puts("Yes");
  else
    puts("No");
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
    
    int N;
    cin >> N;
    
    int A;
    int min=pow(10,9) ;
    
    for (int i=0 ; i<N ;i++){
        
        cin >> A;
        int P=0;
        while ( A%2==0 ){
            A = A/2 ;
            P++;
        }
        if (min>P){
            min = P;
        }
        
    }
    
    cout << min <<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int*,int);
void inputVector(vector<int>*,int);
template <typename T>
void output(T,int);
int gcd(int a,int b);

int main(){
	//source
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	ll a_double,b_double,AandB;
	a_double=a*2;
	b_double=b*2;
	AandB=a+b;
	ll ans=0;
	if(c*2<a+b){
		int number=min(x,y);
		ans+=number*2*c;
		x-=number;
		y-=number;
	}else{
		int number=min(x,y);
		ans+=number*AandB;
		x-=number;
		y-=number;
	}

	if(x==0){
		ans+=min(y*b,y*c*2);
	}else{
		ans+=min(x*a,x*c*2);
	}

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

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int gcd(int a,int b){
	if(b>a){
		int temp=a;
		a=b;
		b=temp;
	}
	if(b==0){
		return a;
	}
	return (b,b%a);
}


Measured memory_bytes: 256
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    A, B = map(int, input().split())
    print(lcm(A, B))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
import sys
import math
import copy
from typing import Tuple, List
input = sys.stdin.readline

expressions = ["+", "-", "*"]
def calc_reverse_polish(formula: List) -> int:
    stack = []
    for icon in formula:
        if icon in expressions:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(str(eval(v1 + icon + v2)))
        else:
            stack.append(icon)
    return stack

if __name__ == "__main__":
    A = input().split()
    stack = calc_reverse_polish(A)
    print(stack[0])



Measured memory_bytes: 7220
# -*- coding: utf-8 -*-
X = int(raw_input())

ans = 10**8
lo, hi = 1, 10**10
while hi - lo >= 1:
    mi = (hi + lo)/2
    if X - mi <= (mi - 1)*mi/2:
        ans = min(ans, mi)
        hi = mi
    else:
        lo = mi + 1
print ans


Measured memory_bytes: 2568
#include <stdio.h>

int main(void){
	int a, b, c, i, n = 0;
	scanf("%d %d %d", &a, &b, &c);

	for(i = a; i <= b; i++){
		if(c % i == 0){
			n++;
		}
	}

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

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

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    rep(i, n) {
        rep(j, m) {
            cin >> a.at(i).at(j);
        }
    }
    rep(i, m) {
        cin >> b.at(i);
    }
    vector<int> ans(n);
    rep(i, n) {
        rep(j, m) {
            ans.at(i) += a.at(i).at(j) * b.at(j);
        }
    }
    rep(i, n) {
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 3176
#include<iostream>
using namespace std;
string str;
int n,m,goal,d;
int t[32][11];
int flg,flg2,ans,ans2;

int tt(int y,int x){
  if(y<=0||y>=d+1||x<=0||x>=n)return 0;
  return t[y][x];
}

void init(){
  for(int i=0;i<32;i++)
    for(int j=0;j<11;j++)t[i][j]=0;
}


bool compute(int y,int x){
  //cout<<y<<" "<<x<<endl;
  if(y==d+1&&x==goal){
    return true;
  }
  if(y==d+1)return false;

  if(tt(y,x)==1){
    return compute(y+1,x+1);
  }else if(tt(y,x-1)==1){
    return compute(y+1,x-1);
  }else{
    return compute(y+1,x);
  }
}


int main(){
  while(cin>>n&&n){
    cin>>m>>goal>>d;
    init();
    for(int i=1;i<=d;i++){
      cin>>str;
      for(int j=0;j<n-1;j++){
	t[i][j+1]=str[j]-'0';
      }   
    }

    flg=0;

    if(compute(1,m))cout<<"0"<<endl;
    else{
      for(int i=1;i<=d;i++){
	if(flg)break;
	for(int j=1;j<n;j++){

	  if(flg)break;
	  if(tt(i,j-1)==0&&tt(i,j)==0&&tt(i,j+1)==0){
	    t[i][j]=1;	    
	    if(compute(1,m)){
	      cout<<i<<" "<<j<<endl;
	      flg=1;
	    }
	    t[i][j]=0;
	  }

	}//j
      }//i
      if(flg==0)cout<<"1"<<endl;
    }
    
  }

  return 0;
}

Measured memory_bytes: 1204
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int N;  // 奇数
vector<long> A;
vector<long> X;
long sum;

void solve();

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    long a;
    cin >> a;
    A.push_back(a);
    sum += a;
    X.push_back(0);
  }
  solve();
}

void solve() {
  long sub = 0;
  for (int i = 1; i < N - 1; i += 2) {
    sub += A[i];
  }
  X[0] = sum - 2 * sub;
  cout << X[0] << " ";
  for (int i = 1; i < N; i++) {
    X[i] = (2 * A[i - 1]) - X[i - 1];
    cout << X[i] << " ";
  }
  cout << endl;
}


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

using namespace std;

int main()
{
    int n , i ;
    cin>>n;
    int a[n] , b[n] , c[n] , dp[n][3];

    for( i = 0 ; i < n ; i++)cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for( i = 1 ; i < n ;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> A(n);
	rep(i, n) cin >> A[i];

	int ans = 1000000001;

	for (int i = 0; i < n; ++i) {
		int a = 0;
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			a++;
		}
		ans = min(ans, a);
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int check(string &st,bool arr[]){
	for(int i=0;i<st.length();i++){
		if(arr[st[i]-'0']==true)return false;
	}
	return true;
}
int main() {
	int n,k;
	cin>>n>>k;
	bool arr[11]={};
	int x;
	for(int i=0;i<k;i++){
		cin>>x;
		arr[x]=true;
	}
	for(int i=n;i<100000;i++){
		string s=to_string(i);
		if(check(s,arr)==true){
			cout<<s;
			break;
		}
	}
}

Measured memory_bytes: 3688
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

dp = [0] * (N + 1)

for i in range(1, N + 1):
    tmp = float("inf")
    for j in A:
        if i - j >= 0:
            tmp = min(tmp, dp[i - j])
    dp[i] = tmp + 1

print(dp[N])





Measured memory_bytes: 7304
n=gets.to_i
n.times do
  ab,ac=[],[]
  balls=gets.split(/\s/).map(&:to_i)
  balls.each do |inb|
    if ab.size==0||ab.last<inb
      ab << inb
    else
      (ac.size>0&&ac.last>inb) ? break : ac << inb
    end
  end
  puts ((ab.size+ac.size)==10) ? 'YES' : 'NO'
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, d;
  in2(n, d);
  d = 2 * d + 1;
  out((n + d - 1) / d);
  memi;
}

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

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 400 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 232492
#include<stdio.h>
#include<math.h>
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	int a[100],b[100],c[100];
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=1;i<=n-1;i++)scanf("%d",&c[i]);
	for(int i=1;i<=n;i++)
	{
		sum+=b[a[i]];
		if(i>=2)
		{
			if(a[i]-a[i-1]==1)
			{
				sum+=c[a[i-1]];
			}
			
		}
	}
	printf("%d",sum);
	return 0;
} 

Measured memory_bytes: 128
package main

import "fmt"

func main() {

  var n int
  fmt.Scan(&n)
  mp := map[int]struct{}{}

  for i := 0; i < n; i++ {
    var a int
    fmt.Scan(&a)

    if _, ok := mp[a]; ok {
      delete(mp, a)
    } else {
      mp[a] = struct{}{}
    }
  }

  fmt.Println(len(mp))
}


Measured memory_bytes: 6496
import Control.Applicative
import Data.Maybe

main = solve <$> getLine <*> getLine >>= putStrLn . fromMaybe "UNRESTORABLE"

solve :: String -> String -> Maybe String
solve s t = maybeMinimum . map f . filter (check t . second) $ [ split i (i + length t) s | i <- [0..length s - length t] ]
  where
    f :: (String, String, String) -> String
    f (a, b, c) = replace '?' 'a' a ++ t ++ replace '?' 'a' c
    
    replace :: Eq a => a -> a -> [a] -> [a]
    replace u v = map (\x -> if x == u then v else x)

second :: (a, a, a) -> a
second (_, y, _) = y

maybeMinimum :: Ord a => [a] -> Maybe a
maybeMinimum [] = Nothing
maybeMinimum a = Just . minimum $ a

check :: String -> String -> Bool
check t = all (\(x, y) -> y == '?' || x == y) . zip t

split :: Int -> Int -> [a] -> ([a], [a], [a])
split l r s = let (m, c) = splitAt r s
                  (a, b) = splitAt l m
              in (a, b, c)

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

int main() {
  string s;
  cin>>s;
  int result=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i] != s[s.size()-1-i]){
        result++;
    }
  }
  cout << result;
}

Measured memory_bytes: 504
a,b=map(int,input().split())
d=b-a+1
length=1
while(2**length<=b):
    length=length+1
a_bin=format(a,'0%db' % length)
a_bin=a_bin[::-1]
answer=0
for i in range(0,length):
    a_number=int(a_bin[i])
    if a_number==0:
        index_a=a%(2**i)
    else:
        index_a=a%(2**i)+2**i
    rest=d%(2**(i+1))
    index_b=(index_a+rest-1)%(2**(i+1))
    if i==0:
        if a_number==0:
            if d%4==0 or d%4==1:
                count=0
            else:
                count=1
        else:
            if d%4==1 or d%4==2:
                count=1
            else:
                count=0
    else:
        if 0<=index_a<2**i:
            count_a=0
        else:
            if (index_a-2**i)%2==0:
                count_a=0
            else:
                count_a=1
        if 0<=index_b<2**i:
            count_b=0
        else:
            if (index_b-2**i)%2==0:
                count_b=1
            else:
                count_b=0
        count=(count_a+count_b)%2
    answer=answer+count*(2**i)
if d==1:
    print(a)
else:
    print(answer)
    
    
    




Measured memory_bytes: 3064
n, a = gets.to_s.split.map{|t|t.to_i}
x    = gets.to_s.split.map{|t|t.to_i - a}.sort.reverse

h = Hash.new(0)
h[0] = 1
# p x
n.times do |i|
  
  t = x[i]
  
  n = h.dup
  h.keys.each do |k|
    n[k+t] += h[k]
  end
  h = n.dup
  
end
# p h
puts h[0] - 1

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vp xl(N);
  rep(i,N) {
    int x,l;
    cin >> x >> l;
    xl[i] = P(x+l,x);
  }
  sort(rng(xl));
  int ans = 0;
  int lim = -INF;
  rep(i,N) {
    int l = xl[i].first - xl[i].second;
    int x = xl[i].first - l;
    int a = x-l;
    if(a >= lim) {
      ans++;
      lim = l+x;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a, b, c; cin >>a >>b >>c;
  bool ans = false;
  if (a+b==c || b+c==a || c+a==b) ans = true;
  
  if (ans) cout <<"Yes";
  else     cout <<"No";
  cout <<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: [usize; n],
    };
    let mut ret = 1;
    let mut highest = h[0];
    for i in 1..n {
        if highest <= h[i] {
            highest = h[i];
            ret += 1;
        }
    }

    println!("{}", ret);

}



Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
  int price[4];
  for (int i=0 ; i<4 ; i++) {
    scanf("%d", &price[i]);
  }
  printf("%d\n", min(price[0], price[1]) + min(price[2], price[3]));
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)

	// not coprime
	gcd := A[0]
	for i := 1; i < N; i++ {
		gcd = GCD(gcd, A[i])
	}
	if gcd != 1 {
		fmt.Println("not coprime")
		return
	}

	m := make(map[int]int)
	for i := 0; i < N; i++ {
		factors := Factorization(A[i])
		for _, factor := range factors {
			v := factor[0]
			if m[v] > 0 {
				fmt.Println("setwise coprime")
				return
			}
			m[v] = 1
		}
	}
	fmt.Println("pairwise coprime")
}

func Factorization(n int) [][]int {
	res := [][]int{}
	for i := 2; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		cnt := 0
		for n%i == 0 {
			n /= i
			cnt++
		}
		res = append(res, []int{i, cnt})
	}
	if n != 1 {
		res = append(res, []int{n, 1})
	}
	return res
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(){
    int x , a, b ;
    cin >> x >> a >> b ;
    cout << x - ( a + (x-a)/b * b ) << endl ;
}

Measured memory_bytes: 3620
import java.io.*;
 
class Main {
	
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int[] A = new int[n];
            int i, j;
            
            for( i=0; i<n; i++ ) {
            	A[i] = Integer.parseInt( nums[i] );
            }
            
            int cnt = 0;
			cnt = selectionSort( A );
			
            StringBuilder output = new StringBuilder( 200+1 );
            for( i=0; i<n; i++ ) {
            	output.append( A[i]  );
            	output.append( " "  );
            }
            output.deleteCharAt( output.lastIndexOf( " " ) );

            System.out.println( output );
            System.out.println( cnt );
			 
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }        
    }
    
    static int selectionSort( int[] A ) 
    {
    	int tmp;
    	int i, j, mini, cnt;
    	int n = A.length;
    	
    	cnt = 0;
   		for( i=0; i<n; i++ ) {
   			mini = i;
   			for( j=i; j<n; j++ ) {
   				if( A[j] < A[ mini ] ) {
   					mini = j;
   				}
   			}
   			if( mini != i ) {
		   		tmp = A[ mini ];
				A[ mini ] = A[ i ];
				A[ i ] = tmp;
				cnt++;
			}
   		}
   		return cnt;
    }
}

Measured memory_bytes: 17056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

string s[8];

int main(void){
  int h, w;
  cin >> h >> w;
  int c = 0;
  REP(i, 0, h) {
    cin >> s[i];
    REP(j, 0, w) {
      c += s[i][j] == '#';
    }
  }
  cout << (c == h + w - 1 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		
		int N = scan.nextInt();
		int res = N;
		
		for(int i = 0; i <= N; i++) {
			int cc = 0;
			int t = i;
			while(t > 0) {
				cc += t % 6;
				t /= 6;
			}
			
			t = N - i;
			while(t > 0) {
				cc += t % 9;
				t /= 9;
			}
			
			if(res > cc) res = cc;
		}
		
		System.out.println(res);
	}
}


Measured memory_bytes: 23892
from itertools import accumulate

N = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))

# 各区間の制限速度条件のみを満たす最大速度のグラフを求める
accTs = list(accumulate(ts))
sumT = accTs[-1]
vMaxs = [[] for i in range(N + 2)]
for i, (v, l, r) in enumerate(zip(vs + [0, 0], [0] + accTs[:-1] + [0, sumT], accTs + [0, sumT])):

    vms = [v + l - t / 2 for t in range(0, l * 2)] + \
          [v] * ((r - l) * 2 + 1) + \
          [v + t / 2 - r for t in range(r * 2 + 1, sumT * 2 + 1)]

    vMaxs[i] = vms

# 最小値がその時刻における列車の速度になる
vMaxs = list(map(min, *vMaxs))

print(sum(vMaxs) / 2)


Measured memory_bytes: 135664
let num_degit n =  1 + int_of_float ( log10 (float_of_int n)) in
let n = read_int () in
let a = ref max_int in
  for i=1 to int_of_float (sqrt (float_of_int n)) do
    if (n mod i) = 0 then 
        a := min !a (max i (n / i))
  done;
  print_int (num_degit !a)


Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := []byte(getString())

	q := make([]byte, 0)
	for _, v := range s {
		n := len(q)
		if n == 0 {
			q = append(q, v)
		} else if q[n-1] != v {
			q = q[:n-1]
		} else {
			q = append(q, v)
		}
		// out(q)
	}
	out(len(s) - len(q))
}


Measured memory_bytes: 1664
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jan 28 21:03:05 2018
//
package main

import (
	"fmt"
)

func main() {
	var A, B, C, X int
	fmt.Scan(&A, &B, &C, &X)

	count := 0
	for i := 0; i <= A; i++ {
		for j := 0; j <= B; j++ {
			for k := 0; k <= C; k++ {
				if i*500+j*100+k*50 == X {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,ans1,ans2;
  cin >> N >> M;
  ans1=0;
  ans2=0;
  vector<int> p(M);
  vector<string> S(M);
  vector<int> ac(N);
  vector<int> wa(N);
  for (int i = 0;i<M;i++) {
    cin >> p.at(i) >> S.at(i);
    if (ac.at(p.at(i)-1)==0){
      if (S.at(i)=="AC") {
        ans1++;
        ans2 =ans2+wa.at(p.at(i)-1);
        ac.at(p.at(i)-1)++;
      } else {
        wa.at(p.at(i)-1)++;
      };
    };
  };
  cout << ans1 <<" "<< ans2 << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];

  int ans = 0;
  REP(i, 29) {
    vector<int> mod_A(N), mod_B(N);
    REP(j, N) {
      mod_A[j] = A[j] & ((1 << (i + 1)) - 1);
    }
    REP(j, N) {
      mod_B[j] = B[j] & ((1 << (i + 1)) - 1);
    }
    sort(ALL(mod_B));

    int cnt = 0;
    for (int a : mod_A) {
      cnt += (lower_bound(ALL(mod_B), (1 << (i + 1)) - a) - mod_B.begin()) - (lower_bound(ALL(mod_B), (1 << i) - a) - mod_B.begin());
      cnt += (lower_bound(ALL(mod_B), (1 << (i + 2)) - a) - mod_B.begin()) - (lower_bound(ALL(mod_B), 3 * (1 << i) - a) - mod_B.begin());
    }
    if (cnt & 1) ans |= (1 << i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    ll arr[n];
    bool flag=1;
    rep(i,0,n){
        cin>>arr[i];
        if(arr[i]==0)flag=0;
    }
    ll tmp=1;
    if(flag==0)cout<<"0\n";
    else {
        rep(i,0,n){
          tmp*=arr[i];
          if(tmp>1000000000000000000LL||tmp<=0)flag=0;
        }
        if(tmp>(1000000000000000000LL))flag=0;
        if(flag==0||tmp<0)cout<<"-1\n";
        else cout<<tmp;
    }
 
return 0;
}

Measured memory_bytes: 4424
class UFTree:
    def __init__(self, N):
        self.nodes = [Node(i) for i in range(N)]
        self.N = N

    def find_max_child_num(self):
        result = 0
        for i in range(self.N):
            result = max(result, self.nodes[i].child_num)
        return result

class Node:
    def __init__(self, ID):
        self.ID = ID
        self.parent = None
        self.child_num = 0
        self.rank = 1

    def get_root(self):
        if self.parent is None:
            return self
        
        return self.parent.get_root()

    def concat(self, another):
        sr = self.get_root()
        ar = another.get_root()

        # is in a same tree.
        if sr.ID == ar.ID:
            return

        if sr.rank > ar.rank:
            parent, child = sr, ar
        else:
            parent, child = ar, sr

        parent.child_num += child.child_num + 1
        parent.rank = max(parent.rank, child.rank + 1)
        child.parent = parent

N, M = map(int, input().split())
tree = UFTree(N)

AB = []
for i in range(M):
    l = list(map(int, input().split()))
    AB.append(l)

for i in range(M):
    a, b = AB[i][0], AB[i][1]
    a -= 1;
    b -= 1;

    tree.nodes[a].concat(tree.nodes[b])

print(tree.find_max_child_num() + 1)


Measured memory_bytes: 85100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;
#define N 300050
#define M 2400050
int head[N],to[M],nxt[M],n,m,cnt,val[M],tot,vis[N],dis[N],S,T;
int Q[N],l,r;
priority_queue<pair<int,int> >q;
struct A {
	int x,y,z,id;
	bool operator < (const A &u) const {return z<u.z;}
}e[N];
vector<A>G[N];
inline void add(int u,int v,int w) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt; val[cnt]=w;
}
char buf[100000],*p1,*p2;
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int rd() {
	int x=0; char s=nc();
	while(s<'0') s=nc();
	while(s>='0') x=(((x<<2)+x)<<1)+s-'0',s=nc();
	return x;
}
void dfs(int x,int d) {
	dis[x]=d;vis[x]=1; Q[r++]=x;
	int i;
	for(i=head[x];i;i=nxt[i]) if(val[i]==0) {
		if(!vis[to[i]]) {
			dfs(to[i],d);
		}
	}
}
int main() {
	n=rd(),m=rd();
	int i,j;
	for(i=1;i<=m;i++) {
		e[i].x=rd(),e[i].y=rd(),e[i].z=rd(); e[i].id=i;
		G[e[i].x].push_back(e[i]);
		G[e[i].y].push_back(e[i]);
	}
	tot=m; S=n+m+1,T=n+m+2;
	for(i=1;i<=n;i++) {
		sort(G[i].begin(),G[i].end());
		int lim=G[i].size();
		tot++;
		for(j=0;j<lim;j++) {
			add(G[i][j].id,tot,0);
			add(tot,G[i][j].id,1);
		}
		int k=0,l;
		for(j=0;j<lim;j=k) {
			for(;k<lim&&G[i][j].z==G[i][k].z;k++) ;
			for(l=j+1;l<k;l++) {
				add(G[i][l].id,G[i][l-1].id,0);
				add(G[i][l-1].id,G[i][l].id,0);
			}
		}
		for(j=0;j<lim;j++) {
			if(i==1) add(S,G[i][j].id,0);
			if(i==n) add(G[i][j].id,T,0);
		}
	}
	Q[r++]=S; vis[S]=1; dis[S]=1;
	while(l<r) {
		int x=Q[l++];
		for(i=head[x];i;i=nxt[i]) {
			if(val[i]==0&&!vis[to[i]]) {
				dfs(to[i],dis[x]);
			}
		}
		for(i=head[x];i;i=nxt[i]) if(val[i]==1) {
			if(!vis[to[i]]) {
				dis[to[i]]=dis[x]+val[i]; Q[r++]=to[i]; vis[to[i]]=1;
			}
		}
	}
	if(!dis[T]) puts("-1");
	else printf("%d\n",dis[T]);
}













Measured memory_bytes: 53876
def comb(n,r):
    if n-r < r:
        r=n-r
    p=1
    q=1
    for i in range(r):
        p *=n-i #=n(n-1)・・(n-r+1)
        p %= mod
        q *=i+1 #=1・2・・r =r!
        q %=mod
    return p*pow(q,mod-2,mod)

# 初期入力
N,a,b = (int(x) for x in input().split())
mod =10**9 +7
#
all_n =pow(2,N,mod) -1

#嫌いな数の組み合わせ
dislike_a =comb(N,a)
dislike_b =comb(N,b)

ans = (all_n -dislike_a -dislike_b)%mod
print(ans)

Measured memory_bytes: 3064
from bisect import bisect_left

if __name__ == "__main__":
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()
	# print(L)
	sum = 0
	for a in range(N - 2):
		for b in range(a + 1, N - 1):
			key = L[a] + L[b]
			i = bisect_left(L, key)
			# print(a, b, i, i - b)
			sum += i - b - 1
	print(sum)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int n,m;
vi s[10];
int p[10];

int ans=0;

void dfs(int idx, bitset<10> bit)
{
    if (idx==n){
        int cnt=0;
        rep(i,m){
            int pop=0;
            for(auto e:s[i]){
                if (bit[e]) pop++;
            }
            if (pop%2==p[i]) cnt++;
        }
        if (cnt==m) ans++;
        return;
    }
    dfs(idx+1,bit);
    bit[idx] = true;
    dfs(idx+1,bit);
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        int k; cin>>k;
        rep(j,k){
            int _s; cin>>_s;
            s[i].pb(_s-1);
        }
    }
    rep(i,m) cin>>p[i];
    dfs(0, bitset<10>());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int M;
vector<bool> vis;
vector<i64> dist;

struct edge{
  int to;
  i64 cost;
};

vector<vector<edge>> edges;

bool dfs(int v){
  vis[v] = true;
  for(auto & e : edges[v]){
    if(vis[e.to]){
      if(dist[e.to] != dist[v] + e.cost) return false;
    }
    else{
      dist[e.to] = dist[v] + e.cost;
      if(!dfs(e.to)) return false;
    }
  }
  return true;
}

int main(){
  cin >> N >> M;
  dist.resize(N);
  vis.resize(N,false);
  edges.resize(N);

  rep(i,0,M - 1){
    int l,r,d;
    cin >> l >> r >> d;
    l--;
    r--;
    edges[l].push_back({r,d});
    edges[r].push_back({l,-d});
  }

  rep(i,0,N - 1){
    if(!vis[i]){
      dist[i] = 0;
      if(!dfs(i)){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 16512
let () =
  let rec read l p =
    try let n = read_int () in
        if n != 0 then read (n::l) p
        else read (List.tl l) ((List.hd l)::p)
    with End_of_file ->
      List.rev p |> List.iter (fun x -> print_int x |> print_newline)
  in read [] []
;;

Measured memory_bytes: 2136
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second

const int MAXN = 110;

int n;
int a[11];

int main()
{
	
	scanf("%d", &n);
	int sum = 0;
	int tmp = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int x;
		scanf("%d", &x);
		sum += 1;
		if (x < 3200)
			a[x/400] ++;
		else
			tmp ++;
	}
	int x = 0;
	for (int i = 0; i <= 7; ++ i)
	{
		if (a[i] > 0) ++ x;
	}
	
	printf("%d %d\n", max(x, 1), x+tmp);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
const long long inf = 1e18;
long long t[maxn], s[maxn], a, b, q;
long long f(long long x){
	int us2 = upper_bound(s, s + a, x) - s;
	int us1;
	if(us2 == 0) 
		us1 = us2;
	else
		us1 = us2 - 1;
	int ut2 = upper_bound(t, t + b, x) - t;
	int ut1;
	if(ut2 == 0)
		ut1 = 0;
	else
		ut1 = ut2 - 1;
//	cout << "\n" << us1 << " " << ut1 << "\n";
//	cout << us2 << " " << ut2 <<"\n";
	long long m1;
	if((s[us1] < x && t[ut1] > x) || (s[us1] > x && t[ut1] < x)){
		m1 = (abs(x - s[us1]) + abs(x - t[ut1])) + min(abs(x - s[us1]) , abs(x - t[ut1]));
	//	cout << (abs(x - s[us1]) + abs(x - t[ut1])) + min(abs(x - s[us1]) , abs(x - t[ut1])) << " *\n";
	}
	else{
		m1 = max(abs(x - s[us1]), abs(x - t[ut1]));
	//	cout << max(abs(x - s[us1]), abs(x - t[ut1])) << " **\n";
	}
	if((s[us2] < x && t[ut2] > x) || (s[us2] > x && t[ut2] < x)){
		m1 = min(m1, (abs(s[us2] - x)+ abs(t[ut2] - x)) + min(abs(s[us2] - x), abs(t[ut2] - x)));
	//	cout << (abs(s[us2] - x)+ abs(t[ut2] - x)) + min(abs(s[us2] - x), abs(t[ut2] - x)) << " ***\n";
	}
	else{
		m1 = min(m1, max(abs(s[us2] - x), abs(t[ut2] - x)));
	//	cout << max(abs(s[us2] - x), abs(t[ut2] - x))<< " ****\n";
	}
	if((s[us2] < x && t[ut1] > x) || (s[us2] > x && t[ut1] < x)){
		m1 = min(m1, abs(s[us2] - x)  + abs(t[ut1] - x) + min(abs(s[us2] - x)  , abs(t[ut1] - x)));
	//	cout << abs(s[us2] - x)  + abs(t[ut1] - x) + min(abs(s[us2] - x)  , abs(t[ut1] - x)) << " *****/n";
	}
	else{
		m1 = min(m1, max(abs(s[us2] - x)  , abs(t[ut1] - x)));
	//	cout << max(abs(s[us2] - x)  , abs(t[ut1] - x)) << " ******\n";
		
	}
	//cout << abs(s[us2] - x)  + abs(t[ut1] - x) + min(abs(s[us2] - x)  , abs(t[ut1] - x)) << " *****\n";
	if((s[us1] < x && t[ut2] > x) || (s[us1] > x && t[ut2] < x)){
		m1 = min(m1, (abs(t[ut2] - x) + abs(s[us1] - x) + min(abs(t[ut2] - x) , abs(s[us1] - x))));
	//	cout << abs(t[ut2] - x) + abs(s[us1] - x) + min(abs(t[ut2] - x) , abs(s[us1] - x)) << " *******\n";
	}
	else{
		m1 = min(m1, max(abs(t[ut2] - x) , abs(s[us1] - x)));
		//cout << abs(t[ut2] - x) + abs(s[us1] - x) + min(abs(t[ut2] - x) , abs(s[us1] - x)) << " ******\n";
	//	cout << max(abs(t[ut2] - x) , abs(s[us1] - x)) << " ********\n";
	}
	return m1;
}
int main(){
	cin >> a >> b >> q;
	for(int i = 0; i < a; i++)
		cin >> s[i];
	for(int i = 0; i < b; i++)
		cin >> t[i];
	s[a] = inf;
	t[b] = inf;
	while(q--){
		long long x;
		cin >> x;
		cout << f(x) << "\n";
	}
	
}

Measured memory_bytes: 2816
#include <stdio.h>

int main(){
  int a=0;
  int count=0;
  scanf("%d", &a);
  if(a>=500){
    count+=(1000*(a/500));
    a-=(a/500)*500;
  }
  count+=(5*(a/5));
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#pragma GCC optimize "trapv"
int main()
{
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
string s;
cin>>s;
ll ans=0;
for(ll i =0;i<s.size();i++)
{
	ans+=(s[i]+9-'0')%9;
	ans%=9;
}    
if(ans==0)
	cout<<"Yes\n";
else
	cout<<"No\n";


}

Measured memory_bytes: 3752
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    int n, x = 0, mx = 0;
    char c;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        cin>>c;
        if(c == 'I') x++;
        else if(c == 'D') x--;
        if(mx < x)  mx = x;
    }
    printf("%d\n", mx);
    return 0;
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='s')COUT(s+"es");
    else COUT(s+"s");
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n,m;
  cin>>n>>m;
  vector<bool>v(m,1);
  rep(i,n){
    int k;
    cin>>k;
    vector<bool>c(m,1);
    rep(j,k){
      int x;
      cin>>x;
      x--;
      c[x]=false;
    }
    rep(j,m){
      if(c[j])v[j]=false;
    }
  }
  int sum=0;
  rep(i,m){
    sum+=v[i];
  }
  cout<<sum;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	string s;
	cin >> s;
	cout << "2018";
	for (int i = 4;i < s.length();++i) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int nDigits( int );

int main( void ) {
	int i, a, b;

	while ( scanf( "%d %d", &a, &b ) == 2 )
		printf( "%d\n", nDigits( a + b ) );

	return 0;
}

int nDigits( int x ) {
	int d = 1;

	while ( ( x /= 10 ) > 0 )
		d++;

	return d;
}

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

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var array = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var L = array[0];
            var R = array[1];

            var minimum = long.MaxValue;
            for (long i = L; i < R; i++)
            {
                for (long j = i + 1; j <= R; j++)
                {
                    System.Diagnostics.Debug.WriteLine(i.ToString() + " : " + j.ToString());
                    minimum = Math.Min(minimum, (i * j) % 2019);
                    if (minimum == 0) break;
                }
                if (minimum == 0) break;
            }
            Console.WriteLine(minimum);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b;
  cin>>a>>b;
  vector<int> sunuke(a);
  
  for(int i=0;i<b;i++){int d=0;cin>>d;
                  for(int j=0;j<d;j++){
                  int A=0;
                    cin>>A;
                    sunuke.at(A-1)++;
                  }}
int k=0;
  for(int i=0;i<a;i++){if(sunuke.at(i)==0){k++;}}
cout<<k<<endl;
}

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


int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if (s==u) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int t = 1;
		//int t = Integer.parseInt(reader.readLine());
		for(int i1 = 0;i1<t;i1++){
			int p = Integer.parseInt(reader.readLine());
			int[] list = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			Arrays.sort(list);
			int ans = 0;
			for(int i = 0;i<list.length;i++){
				for(int j = i+1;j<list.length;j++){
					for(int k = j+1;k<list.length;k++){
						//System.out.println((list[i]!=list[j] && list[j]!=list[k] && list[i]!=list[k])+" "+list[i]+" "+list[j]+" "+list[k]);
						if(list[i]!=list[j] && list[j]!=list[k] && list[i]!=list[k] && list[i]+list[j] >list[k] ) ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 35028
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    vector<string>v;
    for(ll i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        v.push_back(s);
        //cout<<s<<endl;
    }
    sort(v.begin(),v.end());
    ll sum=0,cnt=1;
    for(ll i=1;i<n;i++)
    {
        if(v[i]==v[i-1])
            cnt++;
        else
        {
            sum+=((cnt-1)*cnt)/2;
            cnt=1;
        }
    }
    sum+=((cnt-1)*cnt)/2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
int main(){
	FASTIO
	double d,t,s;
	cin>>d>>t>>s;
	double time = d/s;
	if(time<=t)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3700