akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

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

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */
    private static void getAns(MyScanner sc){
        int n = sc.ni(), l = sc.ni();
        String[] ar = new String[n];
        for(int i = 0; i < n; i++) ar[i] = sc.nn();
        Arrays.sort(ar);

        Arrays.stream(ar).forEach(k -> out.print(k));
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 26580
N = int(input())
H = list(map(int, input().split()))

sep = []
for i in range(1, N - 1):
    if H[i] < H[i-1] and H[i] < H[i+1]:
        sep.append(i)

stack = []
prev = -1
a = 0
for i, h in enumerate(H):
    if h == 0 and prev != 0:
        if H[a:i] != []:
            stack.append(H[a:i])
        a = i
    elif h != 0 and prev == 0:
        a = i
    prev = h
if H[a:] != []:
    stack.append(H[a:])

count = 0
while stack:
    lst = stack.pop()
    if min(lst) == 0:
        continue
    m = min(lst)
    count += m
    lst = [l-m for l in lst]
    a = 0
    prev = -1
    for i, h in enumerate(lst):
        if h == 0 and prev != 0:
            if lst[a:i] != []:
                stack.append(lst[a:i])
            a = i
        elif h != 0 and prev == 0:
            a = i
        prev = h
    if lst[a:] != []:
        stack.append(lst[a:])

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=1;i<=3;i++)
	{
		if((i*a*b)%2!=0){
			cout <<"Yes";
			return 0;
		}
	}
	cout <<"No";
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = LI()
    a.sort()
    print(a[0]*a[1]//2)  
    return

#B
def B():
    d = defaultdict(int)
    s = II()
    def f(n):
        if n % 2:
            return 3 * n + 1
        return n // 2
    i = 1
    while not d[s]:
        d[s] = 1
        s = f(s)
        i += 1
    print(i)
    return

#C
def C():
    n = II()
    h = LI()
    ans = h[0]
    for i in range(n - 1):
        ans += max(0, h[i + 1] - h[i])
    print(ans)
    return

# D
# 解説AC
# 大きいものからとっていった際にその種類数をn
# としてi<=nの種類数においてこれを超えるものは無い
# それより大きいものについて種類数が減らずかつとったものの中で
# 一番小さいものを除き、種類数が増える一番大きいものをとってこれば
# i+1番目の種類下でもっとも大きい数になる 
def D():
    n, k = LI()
    ma = []
    for _ in range(n):
        t, di = LI()
        ma.append((di, t))
    ma.sort()
    ma = deque(ma)
    s = defaultdict(int)
    t = 0
    ans = 0
    q = []
    for _ in range(k):
        di,ti = ma.pop()
        ans += di
        heappush(q, (di, ti))
        if not s[ti]:
            t += 1
        s[ti] += 1
    ans += t ** 2
    ans = [ans]
    while ma and q:
        di, ti = ma.pop()
        while s[ti] and ma:
            di, ti = ma.pop()
        if not ma and s[ti]:
            break
        d1, t1 = heappop(q)
        while s[t1] == 1 and q:
            d1, t1 = heappop(q)
        if not q and s[t1] == 1:
            break
        s[t1] -= 1
        tmp = ans[-1]
        tmp = tmp - d1 + di - t ** 2
        t += 1
        tmp += t ** 2
        ans.append(tmp)
        heappush(q, (di, ti))
        s[ti] += 1
    print(max(ans))


    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 77148
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <unordered_set>

using namespace std;
#define INF 99999
#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define fi first
#define se second
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
using namespace std;

void _main(){
    int n;
    cin >> n;
    vint a(n);
    REP(i, n) cin >> a[i];

    pint s;
    priority_queue <int> maxpq;
    unordered_set<int> us;

    REP(i, n){
        if(us.find(a[i]) != us.end()){
            us.erase(a[i]);
            maxpq.push(a[i]);
        } else if(a[i] >= s.se){
            us.emplace(a[i]);
        }
    }

    if(maxpq.size() >= 2) {
        int s1 = maxpq.top();
        maxpq.pop();
        int s2 = maxpq.top();
        cout << long(s1) * long(s2);
    } else {
        cout << 0;
    }
}

int main() {
    _main();

    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	int type = 0;
	cin>>a>>b;
	if(a == b)
		cout<<"EQUAL"<<endl;
	else if(a.size() > b.size())
		cout<<"GREATER"<<endl;
	else if(a.size() < b.size())
		cout<<"LESS"<<endl;
	else
	{
		for(int i =0;i<a.size();i++)
		{
			if(a[i] > b[i])
			{
				type = 1;
				break;
			}
			else if(b[i] > a[i])
			{
				type = 2;
				break;
			}
			else
				continue;
		}
		if(type == 1)
			cout<<"GREATER"<<endl;
		else
			cout<<"LESS"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
void dfs(vll &cu,vvll &ta,ll now,ll s){
  for(ll o:ta[now]){
    if(o==s) continue;
    cu[o]+=cu[now];
    dfs(cu,ta,o,now);
  }
  return ;
}
int main(){
  ll n,q;
  cin>>n>>q;
  vvll ta(n+1,vll(0));
  rep(i,n-1){
    ll a,c;
  cin>>a>>c;
  ta[a].pb(c);
  ta[c].pb(a);
  }
  vll cu(n+1);
  rep(i,q){
    ll a,b;
    cin>>a>>b;
    cu[a]+=b;
  }
  dfs(cu,ta,1,-1);
  for(int i=1;i<=n;i++){
    cout<<cu[i]<<" ";
  }
}


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

const int INF = 1 << 30;

using Edge = std::pair<int, int>;
using Graph = std::vector<std::vector<Edge>>;
Graph G;

std::vector<bool> visited;
std::vector<int> X;

void dfs(const int v, bool &res) {
  visited[v] = true;

  for (auto e : G[v]) {
    int nv = e.first;
    int d = e.second;
    if (visited[nv]) {
      if (X[nv] != X[v] + d)
        res = false;
      continue;
    }

    X[nv] = X[v] + d;
    dfs(nv, res);
  }
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M), R(M), D(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    --L[i], --R[i];
  }

  G.resize(N);
  for (int i = 0; i < M; ++i) {
    G[L[i]].push_back(std::make_pair(R[i], D[i]));
    G[R[i]].push_back(std::make_pair(L[i], -D[i]));
  }

  visited.assign(N, false);
  X.assign(N, INF);

  bool res = true;
  for (int v = 0; v < N; ++v) {
    if (visited[v])
      continue;
    dfs(v, res);
  }

  if (res)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


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

int main()
{
  string s; cin >> s;
  int n = s.length();
  int ans = 0;
  rep(i, n/2) {
    if (s[i]!=s[n-i-1]) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int max = 0;
    int min = 0;
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (i == 0) {
        max = a;
        min = a;
      }
      if (a > max) max = a;
      if (a < min) min = a;
    }

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

Measured memory_bytes: 23892
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp{
  char name[100]; //??????
  int t; //?????????????????????
}P;

void enqueue(P);
P dequeue(void);
void initialize(void);
int isEmpty(void);
int isFull(void);

P Q[LEN+1];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q; //q:???????????????
  P u;
  scanf("%d %d", &n, &q);

  initialize();

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n+1;

  while(1){
    if(isEmpty()) break;

    u=dequeue();

    if(u.t > q ){
      elaps +=q;
      u.t -= q;
      enqueue(u); 
    }
    else {
      elaps +=u.t;
      printf("%s %d\n",u.name,elaps);
    }

  }

  return 0;
}


void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  return head == tail;
}

int isFull(void){
  return head == (tail + 1) % LEN;
}

void enqueue(P x){ /* ?????\??????????°????????´? x ????????????????????? */
  if(isFull()) fprintf(stderr,"overflow\n");
  Q[tail] = x;
  if (tail + 1 == LEN) tail = 0;
  else tail++;
}

P dequeue(void){ /* ?????\??????????????????????´????????????????????????? */
  P x;
  if(isEmpty()) fprintf(stderr,"underflow\n");
  x = Q[head];
  if (head + 1 == LEN) head = 0;
  else head++;
  return x;
}

Measured memory_bytes: 10752
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, A;
	std::cin >> N >> A;
	if ((N%500) <= A) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int a[3],cnt=0; 
    cin>>a[0]>>a[1]>>a[2]; 
    while (1){
        if (a[1]==a[0] and a[1]==a[2]) break;
        cnt++;
        sort(a,a+3);
        int d=a[2]-a[0];
        if (d>=2) a[0]+=2;
        else {
            if (a[2]==a[1]) cnt++;
            break;
        }
    }
    cout << cnt << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612
a, b, x = map(float, input().split())

import math

box_volume = float(a**2*b)
if x >= 0.5*box_volume:
    sita = math.degrees(math.atan(2*(box_volume-x)/a**3))
else:
    sita = 90 - math.degrees(math.atan(2*x/(a*b**2)))
    
print(sita)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=INT_MAX;
const double PI=3.1415926;
int main()
{
    map<ll,ll> m;
    ll n,a;
    cin>>n;
    rep(i,n-1)
    {
        cin>>a;
        m[a]++;
    }
    rep1(i,n) cout<<m[i]<<"\n";
}


Measured memory_bytes: 16052
N, P = gets.split(/ /).collect{|n| n.to_i}

if N == 1
	puts P
else
	
	MAX = 10 ** 6
	
	p_table = [true] * (MAX + 1)
	
	(2..10**6).each{|n|
		next unless p_table[n]
		x = n + n
		while x < MAX
			p_table[x] = false
			x += n
		end
	#	print "#{n} "
	}
	p_list = []
	
	(2..10**6).each{|n|
		if p_table[n]
			p_list << n
		end
	}
	
	i = 0
	p_count = p_list.length
	
	f_table = {}
	
	num = P
	while i < p_count && num > 1
		f = p_list[i]
		if f <= num
			while true
				if num % f == 0
					num = num / f
					if count = f_table[f]
						f_table[f] = count + 1
					else
						f_table[f] = 1
					end
				else
					break
				end
			end
		end
		
		i += 1
	end
	
	answer = 1
	f_table.each{|f, count|
		if count >= N
			answer *= (f ** (count / N))
		end
	}
	
	puts answer
end


Measured memory_bytes: 10364
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int q;
  cin >> q;
  for (int i=0; i<q; ++i) {
    ul a, b;
    cin >> a >> b;
    if (a==b) {
      cout << (a-1)*2 << endl;
      continue;
    }
    //if (a>b) swap(a, b);
    ul m1 = (ul)(sqrt(a*b-1));
    ul m2 = (m1*(m1+1) < a*b ? m1+1 : m1);
    ul ans = 0;
    ul m1b = m1, m2b = m2;
    while (true) {
      if (m1b==0 || m2b==0) break;
      if (m1b==a) {
        m1b--;
        continue;
      }
      if (m2b==b) {
        m2b++;
        continue;
      }
      if (m1b*m2b >= a*b) {
        m1b--;
        continue;
      }
      if (m1b * (m2b+1) < a*b) {
        ans += m1b;
        if (m1b >= a) ans--;
        //cout << m1b << " " << m2b << " +" << endl;
        break;
      }
      ans++;
      //cout << m1b << " " << m2b << " 1" << endl;
      m1b--; m2b++;
    }
    m1b = m2, m2b = m1;
    if (m1b==m2b) {
      m1b++;
      m2b--;
    }
    while (true) {
      if (m1b==0 || m2b==0) break;
      if (m1b==a) {
        m1b++;
        continue;
      }
      if (m2b==b) {
        m2b--;
        continue;
      }
      if (m1b*m2b >= a*b) {
        m2b--;
        continue;
      }
      if ((m1b+1) * m2b < a*b) {
        ans += m2b;
        if (m2b >= b) ans--;
        //cout << m1b << " " << m2b << " +r" << endl;
        break;
      }
      ans++;
      //cout << m1b << " " << m2b << " 1r" << endl;
      m1b++; m2b--;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = True
for i in range(N):
    ans = ans + AB[i][0]
    if ans > AB[i][1]:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38032
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    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" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define mod 1000000007

int main(void){
  int N;
  scanf("%d",&N);
  char S[2][52];
  scanf("%s",S[0]);
  scanf("%s",S[1]);

  int data[N];
  long long ans = 1;

  for(int i = 0;i < N;i++){
    if(S[0][i] == S[1][i]){
      data[i] = 1;
    }else{
      data[i] = 2;
    }
  }

  for(int i = 0;i < N;i++){
    if(i == 0){
      if(data[i] == 2){
        ans *= 6;
        i++;
      }else{
        ans *= 3;
      }
      continue;
    }

    if(data[i] == 1){
      if(data[i-1] == 1){
        ans *= 2;
        ans %= mod;
      }
    }else{
      if(data[i-1] == 1){
        ans *= 2;
      }else{
        ans *= 3;
      }
      ans %= mod;
      i++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n%2 == 0:
    a_l = a[0::2]
    a_r = a[1::2]
    flag = True
    key = 1
    for i,j in zip(a_l,a_r):
        if i!=key or j!=key:
            flag = False
            break
        key += 2
    if flag:
        print(2**(n//2)%(10**9+7))
    else:
        print(0)
else:
    a_l = a[1::2]   #0を一つとばす
    a_r = a[2::2]
    flag = True
    key = 2
    for i,j in zip(a_l,a_r):
        if i!=key or j!=key:
            flag = False
            break
        key += 2
    if flag:
        print(2**(n//2)%(10**9+7))
    else:
        print(0)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int a[110];
  cin >> N;
  for (int i=0; i<N; i++)
    cin >> a[i];
  sort(a, a+N);
  cout << a[N-1] - a[0] << endl;
}



Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector<int> vec(n);

    for(auto& v : vec)
        v = 0;

    for(int i = 0; i < k; ++i)
    {
        int num;
        cin >> num;
        for(int j = 0; j < num; ++j)
        {
            int mem;
            cin >> mem;
            vec[mem - 1]++;
        }
    }

    int ans = 0;
    for(auto& v : vec)
    {
        if(v == 0)
            ++ans;
    }

    cout << ans << "\n";

    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<LL> x;

struct E {
    LL to;
    LL w;
};

vector<vector<E>> g;

string ans = "Yes";

void dfs(LL i, LL now) {
    if(x[i] != LLONG_MAX){
        if(now != x[i]){
            ans = "No";
        }
        return;
    }else{
        x[i] = now;
        for(auto next : g[i]){
            dfs(next.to, now+next.w);
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    LL n, m;cin >> n >> m;
    x.resize(n, LLONG_MAX);
    g.resize(n);
    inc(i, 0, m){
        LL l, r, d;cin >> l >> r >> d;
        l--;r--;
        g[l].pb({r, d});
        g[r].pb({l, -d});
    }
    inc(i, 0, n){
        if(x[i] != LLONG_MAX) continue;
        dfs(i, 0);
    }

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


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  while(true)
  {
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)
    {
      break;
    }
    int T[n];
    int H[m];
    int sumT = 0;
    int sumH =0;
    for(int i = 0 ; i < n ;i++)
    {
      cin >> T[i];
      sumT += T[i];
    }
    for(int i = 0; i<m;i++)
    {
      cin >> H[i];
      sumH += H[i];
    }
    int ansT = -1;
    int ansH = -1;
    int sumTH = 1e9;
    for(int i = 0;i<n;i++)
    {
      for(int j = 0;j<m;j++)
      {
        if(sumT - T[i] + H[j] == sumH - H[j] + T[i])
        {
          if(chmin(sumTH,T[i]+H[j]))
          {
            ansT = T[i];
            ansH = H[j];
          }
        }
      }
    }
    if(ansT == -1 && ansH == -1){
      cout << -1 << endl;
    }else
    {
      cout << ansT << " " << ansH << endl;
    }
    
    
  }
  
}



Measured memory_bytes: 3132
def main():
    n = int(input())
    words = []
    for i in range(n):
        words.append(input())
    if len(words) != len(set(words)):
        print('No')
        return
    for w1, w2 in zip(words, words[1:]):
        if w1[-1] != w2[0]:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    ll c,d;
    cin>>c>>d;
    string e;
    cin>>e;
    if(a==e)
        cout<<c-1<<" "<<d;
    else
        cout<<c<<" "<<d-1;
}


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

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

   int n1 = n / 10;
   int n2 = n % 10;

   if ((n1 != 0 && n1 % 9 == 0) || (n2 != 0 && n2 % 9 == 0)) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
array = []
array << gets.chomp.to_i
array << gets.chomp.to_i
array << gets.chomp.to_i
array << gets.chomp.to_i
array << gets.chomp.to_i
k = gets.chomp.to_i

combinations = array.combination(2).to_a
combinations.each do |c|
    if c[0] > c[1] then
        dist = c[0] - c[1]
    else
        dist = c[1] - c[0]
    end
    if dist > k then
        puts ":("
        exit()
    end
end
puts "Yay!"

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

dp = [[0] * 10 for _ in range(11)]
for i in range(10):
    dp[0][i] = 1
for i in range(1, 11):
    for j in range(0, 10):
        dp[i][j] += dp[i-1][j]
        if j-1 >= 0:
            dp[i][j] += dp[i-1][j-1]
        if j+1 < 10:
            dp[i][j] += dp[i-1][j+1]
    
k = int(input())
ans = ""
ret = 0
lv = 0
for i in range(11):
    if k > sum(dp[i][1:]):
        k -= sum(dp[i][1:])
    else:
        lv = i
        break

lft = 1; rgt = 10 
for l in range(lv, -1, -1):
    for i in range(lft, rgt):
        item = dp[l][i]
        if k > item:
            k -= item
        else:
            lft = max(i - 1, 0)
            rgt = i + 2
            ans += str(i)
            break
print(ans)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    vector<int> k(M);
    for (int i = 0; i < M; i++) {
        cin >> k.at(i);
        for (int j = 0; j < k.at(i); j++) {
            int temp;
            cin >> temp;
            s.at(i).push_back(temp);
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }
    
    int count = 0;
    for (int mask = 0; mask < (1 << N); mask++){
        int flag = 1;

        for (int i = 0; i < M; i++) {
            int temp = 0;

            for (int j = 0; j < k.at(i); j++) {
                if((mask >> (s.at(i).at(j)-1))&1) {
                    temp = !temp;
                }
            }

            if (p.at(i) != temp) {
                flag = 0;
                break;
            }
        }

        if (flag) {
            count++;
        }
    }

    cout << count << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, k, u, v;
string s, t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	vll a(n);
	for(ll i =0;i<n;i++) cin>>a[i];

	ll cou = 1,maxi = a[0];
	for(ll i=1;i<n;i++) {
		if(maxi <= a[i]) {
			cou++;
			maxi = a[i];
		}
	}
	cout<<cou;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3656
# coding: utf-8
N = int(input())
line = input().split()
A = int(line[0])
B = int(line[1])
line = input().split()
q_num = [0, 0, 0]
for i in line:
  i = int(i)
  if i <= A:
    q_num[0] += 1
  elif i > B:
    q_num[2] += 1
  else:
    q_num[1] += 1
print(min(q_num))

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<time.h>
#include<vector>
#include<cstdlib>
#include<cstdio>


using namespace std;
int a[110000];
int a1 = 0, a2 = 0;
map<int, int>b1,b2;
int temp1,temp2;
int main()
{
	int max1 = 0, max2 = 0;
	int max11 = 0, max22 = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			b1[a[i]]++;
			if (b1[a[i]] > max1)
			{
				if (temp1 != a[i])max11 = max1;
				max1 = b1[a[i]];
				temp1 = a[i];
			}
			else
			{
				if (b1[a[i]] > max11)
				{
					max11 = b1[a[i]];
				}
			}
		}
		else
		{
			b2[a[i]]++;
			if (b2[a[i]] > max2)
			{
				if (temp2 != a[i])max22 = max2;
				max2 = b2[a[i]];
				temp2 = a[i];
			}
			else
			{
				if (b2[a[i]] > max22)
				{
					max22 = b2[a[i]];
				}
			}
		}
	}
	if (temp1 != temp2)
	{
		printf("%d", n - max1 - max2);
	}
	else
	{
		if (n % 2 == 0)
		{
			printf("%d", min(n - max1 - max22, n - max2 - max11));
		}
	}
}

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

vector<int> eratos(int n){
    vector<int> primeVec;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = false; isPrime[1] = false;
    for(int p = 2; p*p <= n; p++){
        if(isPrime[p]) for(int i = p*2; i <= n; i += p) isPrime[i] = false;
    }
    for(int p = 2; p <= n; p++) if(isPrime[p]) primeVec.push_back(p);
    return primeVec;
}

int main(){
    int q;
    cin >> q;
    vector<int> sosuu = eratos(100000);
    vector<bool> niteru(100000+1);
    for(int x : sosuu){
        niteru[x] = true;
    }
    for(int i = 100000; i >= 0; i--){
        if(niteru[i] == true) niteru[i] = niteru[(i+1)/2];
    }

    vector<int> vec;
    for(int i = 0; i <= 100000; i++){
        if(niteru[i] == true) vec.push_back(i);
    }

    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        int ans = upper_bound(vec.begin(), vec.end(), r) - lower_bound(vec.begin(), vec.end(), l);
        cout << ans << endl;
    }
}


Measured memory_bytes: 768
#include <stdio.h>
 
int main(){
   int a,b,c,d;
    
   scanf("%d %d %d %d",&a,&b,&c,&d);
   if (a==1 || b==1 || c==1 || d==1)
   if (a==9 || b==9 || c==9 || d==9)
   if (a==7 || b==7 || c==7 || d==7)
   if (a==4 || b==4 || c==4 || d==4) {
      puts("YES");
     return 0;
   }
   puts("NO");
   return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[110][100010];

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	memset(dp,sizeof(dp),0);
	For(i,0,n) dp[i][0]=1;
	For(i,1,n) For(j,1,k){
		dp[i][j]=dp[i][j-1]+dp[i-1][j];
		if(j>v[i-1]) dp[i][j]-=dp[i-1][j-v[i-1]-1];
		dp[i][j]=(dp[i][j]%MOD+MOD)%MOD;
	}
	cout<<dp[n][k]<<"\n";
	return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

static void B_FiveDishes();

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

static void B_FiveDishes()
{
	int dishTime[5] = { 0 };
	int serveTime[5] = { 0 };
	int diffTime[5] = { 0 };
	int total = 0;

	for (int p = 0; p < 5; p++) {
		scanf(" %d", &dishTime[p]);

		serveTime[p] = (dishTime[p] / 10) * 10;
		if ((diffTime[p] = dishTime[p] % 10)) {
			serveTime[p] += 10;
		}

	}

	int diffMaxIdx = 0;
	int tmp = 10;
	
	for (int p = 0; p < 5; p++) {
		if ((tmp > diffTime[p]) && (diffTime[p] != 0)) {
			tmp = diffTime[p];
			diffMaxIdx = p;
		}
	}
	int i;
	for (i = 0; i < 5; i++) {
		if (i != diffMaxIdx) {
			total += serveTime[i];
		}
	}
	total += dishTime[diffMaxIdx];

	printf("%d\n", total);
	fflush(stdout);

	return;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = A[0]
    y = sum(A[1:])
    ans = abs(x - y)
    for i in range(1, N - 1):
        x += A[i]
        y -= A[i]
        ans = min(ans, abs(x - y))
    print(ans)


main()


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;

int dp[100000][3];

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

    for(int i = 0; i < 3; i++) dp[0][i] = a[0][i];
    for(int i = 1; i < n; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);

    int ans = 0;
    for(int i = 0; i < 3; i++) ans = max(ans, dp[n-1][i]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
#define MOD 1000000007
 
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 

int main(){
    LL a,b,n;
    cin >>a>>b>>n;
    LL x;
    if(b-1>n){
        x=n;
    }
    else{
        x=b-1;
    }
    LL w=a*x/b;
    LL y=x/b;
    LL ans=w-a*y;
    cout <<ans<<endl;
}

Measured memory_bytes: 3588
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
A = sorted(I())
B = sorted(I())
C = sorted(I())

ans = 0
for i in range(n):
    left = bl(A, B[i])
    right = n - br(C, B[i])
    ans += left * right
print(ans)



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

using namespace std;
#define int long long
#define inf 999999999999999999
#define N 666666
#define mod 998244353
#define M 998244353
int arr[N],fac[N+1000090]= {1};
vector<int> v; 
map<int,int> vis;
int qpow(int a,int b){
        int ans=1;
        int k=a;
        while(b){
        if(b&1)ans=ans*k%M;
        k=k*k%M;
        b>>=1;
    }
    return ans;
}
int C(int n,int m){
    if(m>n)return 0;
    return fac[n]*qpow(fac[m],M-2)%M*qpow(fac[n-m],M-2)%M;
}
int f[N];
signed main(){
	for(int i=1;i<=666666;i++)fac[i]=fac[i-1]*i%M;
	int n,m,k;
	cin>>n>>m>>k;	
	f[0]=1;
	int ans=0;
	for(int i=1;i<=n+10;i++) f[i]=(f[i-1]%mod*(m-1)%mod)%mod;
	for(int i=0;i<=k;i++){
		ans=(ans+(m*C(n-1,i)%mod*f[n-i-1]%mod)%mod+mod)%mod;
	}
	cout<<ans;
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n;
   cin >> n;
   vec<int> v(n);
   map<ll, int> mp;
   rep (i, n) {
      cin >> v[i];
      mp[v[i]]++;
   }

   int ans = 0;
   for (auto x : mp) {
      if (x.first <= x.second) {
         ans += x.second - x.first;
      } else {
         ans += x.second;
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Aug  9 21:00:42 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    Int n;
    std::cin >> n;
    auto t = make_vec<Int>(18 + 1, 18 + 1, 0);
    Int ans = 0;
    REP(i, n) {
        double a;
        std::cin >> a;
        Int x = a * 1000000000 + 0.5;
        Int p = -1, q = -1;
        dump(i, x);
        REP(j, 19) {
            if (j == 18 || x % 2) {
                p = j;
                break;
            }
            x /= 2;
        }
        REP(j, 19) {
            if (j == 18 || x % 5) {
                q = j;
                break;
            }
            x /= 5;
        }
        REP(i2, 19) {
            REP(j2, 19) {
                if (p + i2 >= 18 && q + j2 >= 18) ans += t[i2][j2];
            }
        }
        t[p][q]++;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int h[2], m[2], s[2], i;
	int t[3], t2;
	
	for (i = 0; i < 3; i++){
		scanf("%d %d %d %d %d %d", &h[0], &m[0], &s[0], &h[1], &m[1], &s[1]);
		t[i] = (h[1] - h[0]) * 3600 + (m[1] - m[0]) * 60 + (s[1] - s[0]);
	}
	for (i = 0; i < 3; i++){
		printf("%d %d %d\n", t[i] / 3600, t[i] % 3600 / 60, t[i] % 60);
	}
	return (0);
}
			

	

Measured memory_bytes: 1028
cells = [list(map(int, input().split())) for i in range(3)]

for i in range(2):
    for j in range(2):
        if cells[i][j+1] - cells[i][j] == cells[i+1][j+1] - cells[i+1][j]:
            pass
        else:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;

int gcd(int a,int b)
{
  if(a>b)swap(a,b);
  if(a==0){return b;}
  else return gcd(b%a,a);
}
map<ll,ll>prime_factor(int m)
{
  map<ll,ll>res;
  ll sqrm=sqrt(m)+1;
  for(int i=2;i<sqrm+1;i++)
  {
    while(m%i==0){res[i]++;m/=i;}
    if(m==1)break;
  }
  if(m>1)res[m]++;
  return res;
}

struct sieve{
  int p=0;
  vector<bool> furui;
  sieve(int n){
    furui.resize(n,1);
    furui[0]=0;
    furui[1]=0;
    for(int i=2;i<n;i++)if(furui[i])for(int j=i*2;j<n;j+=i)furui[j]=0;
  }
  bool isprime(int m){return furui[m];}
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int a;
  cin>>n;
  cin>>a;
  vector<ll>b(n+1);
  b[n]=a;
  a=abs(a);
  rep(i,n){cin>>b[n-1-i];}
  rep(i,n+1)
  {
    if(b[i]!=0)
    {
      if(a==0)
      {
        a=abs(b[i]);
      }
      else a=gcd(a,abs(b[i]));
    }
  }
  auto ma=prime_factor(a);
  auto ma2=prime_factor(abs(b[0]));
  if(b[0]==0)
  {
    sieve si(n+10);
    rep(p,n+2)
    {
      if(!si.isprime(p))continue;
      ll tb=0;
      bool f=1;
      rep(i,p-1)
      {
        for(int j=i;j<=n;j+=p-1)tb+=b[j];
        if(tb%p!=0){f=0;break;}
      }
      if(f)
      {
        cout<<p<<"\n";
      }
    }
  }
  else 
  {
    for(auto tp:ma2)
    {
      int p=tp.first;
      if(p-1>n)continue;
      ll tb=0;
      bool f=1;
      rep(i,p-1)
      {
        for(int j=i;j<=n;j+=p-1)tb+=b[j];
        if(tb%p!=0){f=0;break;}
      }
      if(f)
      {
        cout<<p<<"\n";
      }
    }
  } 
  for(auto tp:ma)
  {
    if(tp.first<n+2)continue;
    cout<<tp.first<<"\n";
  }


  return 0;

}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace ABC136A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var A = input[0];
            var B = input[1];
            var C = input[2];

            Console.WriteLine(Math.Max(C - (A - B), 0));
        }
    }
}

Measured memory_bytes: 11348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var first = int.Parse(str);
            Console.WriteLine((first - 2) * 180);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,C,K; cin>>N>>C>>K;
    vint t(N);
    REP(i,N) cin>>t[i];
    sort(ALL(t));

    int ans=0;
    for(int i=0,j=i;i<N;i=j)
    {
        while(j<N and j-i+1<=C and t[j]<=t[i]+K) j++;
        ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
  int N,X;
  cin >> N >> X;
 
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  
   int count =1;
   vector<int> D(N+1);
  D.at(0)=0;
   for (int j=1;j<N+1;j++){
     D.at(j)=D.at(j-1)+L.at(j-1);
     if(D.at(j)<=X){
       count++;
     }
   }
   cout << count << endl;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(c <= a + b + 1) cout << b + c << endl;
    else cout << a + b + 1 + b << endl;
    return 0;
}

Measured memory_bytes: 256
L,R = map(int, input().split())
if R-L >= 2019:
  print(0)
else:
  list = []
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      list.append(i*j%2019)
  list = sorted(list)
  print(list[0])

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

/*
   AtCoder contest
   coder : yoichidon
 */

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.printf("%d %d", Math.min(A,B), Math.max(0, A+B-N));
    }
}


Measured memory_bytes: 21588
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, H, count = 0;
	long long a[100000], b[100000], max = 0;
	scanf("%d%d", &N, &H);
	for (int i = 0; i < N; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
		if (a[i] > max) {
			max = a[i];
		}
	}
	sort(b, b + N, greater<int>());
	int j = 0;
	while (H > 0) {
		if (max >= b[j]) {
			H -= max;
		}
		else {
			H -= b[j];
			j++;
		}
		count++;
	}
	printf("%d", count);
	return 0;
}

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

using namespace std;

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

Measured memory_bytes: 256