akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: i64,
    }

    let mut ans: usize = 0;
    for i in 1..N + 1 {
        if i * i > N {
            break;
        }
        for j in i..N + 1 {
            //let ab = i.saturating_mul(j);
            if i * j > N {
                break;
            }
            let ab = i * j;
            let c = N - ab;
            if c > 0 {
                if i == j {
                    ans += 1;
                } else {
                    ans += 2;
                }
            } else {
                break;
            }
        }
    }

    echo!(ans);
}


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

using namespace std;

int A, B;

bool judge ( string s )
{
  for ( int i = 0; i < A; ++i ) if ( s[i] < '0' || s[i] > '9' ) return false;
  if ( s[A] != '-' ) return false;
  for ( int i = A+1; i < A+B+1; ++i ) if ( s[i] < '0' || s[i] > '9' ) return false;

  return true;
}

int main()
{
  string s;

  cin >> A >> B;

  cin >> s;

  if ( judge(s) ) cout << "Yes\n";
  else cout << "No\n";
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin >> x;

    while (1) {
        int brojac = 0;
        for (int i=2; i<=sqrt(x); i++) {
            if (x%i==0)
                brojac++;
        }
        if (brojac==0) {
            cout << x << "\n";
            return 0;
        }
        x++;
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i).sort
cs = gets.split.map(&:to_i).sort

count = 0
bs.each do |b|
  a_count = as.bsearch_index { |x| x >= b } || as.size
  c_count = cs.size - (cs.bsearch_index { |x| x > b } || cs.size)
  count += a_count * c_count
end

p count

Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, y;
	while(cin >> x >> y){
		if(x==0 && y==0)
			break;
		if(x>y)
			swap(x, y);
		cout << x << " " << y << endl; 
	}
	return 0;
} 


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

using namespace std;

int main() {
	int n;

	cin >> n;

	vector <int> a(n);
	int x = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x = x ^ a[i];
	}

	for (int i = 0; i < n; i++) {
		cout << (x ^ a[i]) << " ";
	}

	cout << "\n";

	return 0;
}


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

const int MAXN = 100000;
int a[MAXN + 1], b[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false)
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;
    int n = (int)s.size();
    int m = (int)t.size();
    for(int i = 1; i <= n; i++) {
        a[i] = a[i - 1] + (s[i - 1] == 'A');
    }
    for(int i = 1; i <= m; i++) {
        b[i] = b[i - 1] + (t[i - 1] == 'A');
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int l1, r1;
        int l2, r2;
        scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
        int res1 = (a[r1] - a[l1 - 1]) * 2 + (r1 - l1 + 1) - (a[r1] - a[l1 - 1]);
        int res2 = (b[r2] - b[l2 - 1]) * 2 + (r2 - l2 + 1) - (b[r2] - b[l2 - 1]);
        //cout << res1 << " " << res2 << "\n";
        if(res1 % 3 == res2 % 3)
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}

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

typedef long long ll;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main()
{
  std::string s;
  std::cin >> s;

  ll lans = -1;
  ll rans = -1;
  ll N = (ll)s.size();
  for (ll i = 1LL; i < N; i++) {
    if (i == 1LL && s[i] == s[i-1]) {
      lans = 1;
      rans = 2;
      break;
    }
    if (i >= 2LL && (s[i] == s[i-2] || s[i] == s[i-1])) {
      lans = i-1;
      rans = i+1;
      break;
    }
  }

  print(lans, rans);
  return 0;
}


Measured memory_bytes: 512
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    arr = [ai - bi for ai, bi in zip(a, b)]
    arr.sort(reverse=True)
    tmp_1 = sum([-ai for ai in arr if ai < 0])
    tmp_2 = sum([ai for ai in arr if ai > 0])
    ans = 0
    for ai in arr:
        if ai < 0:
            ans += 1
    if tmp_2 < tmp_1:
        print(-1)
    else:
        for ai in arr:
            if ai > 0:
                if tmp_1 > 0:
                    tmp_1 -= ai
                    ans += 1

        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    puts("Cloudy");
  } else if (s == "Cloudy") {
    puts("Rainy");
  } else {
    puts("Sunny");
  }
  return 0;
}


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

int main() {
 char c;
 cin >> c;
 if (c == 'a' || c=='e'|| c=='i'||c=='o'|| c=='u'){
   cout << "vowel" << endl;
 }
 else {cout << "consonant" << endl;} 
}
   

Measured memory_bytes: 256
n,k=map(int,input().split())
num=[0]*k
ans=0

def njo(arg,n):
  if n==0:
    return 1
  elif n%2==0:
    return njo((arg**2)%1000000007,n//2)
  else:
    return arg*njo((arg**2)%1000000007,n//2)

for i in range(k):
  test=k-i
  num[test-1]=njo(k//test,n)
  mul=test*2
  while mul<=k:
    num[test-1]-=num[mul-1]
    mul+=test

  ans+=num[test-1]*test
  
while ans<0:
  ans+=1000000007
print(str(ans%1000000007))

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //?§???????????????¢??????????????????
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

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

void ink(int y, int x)
{
    if (0 <= y && y < 10 && 0 <= x && x < 10) seet[y][x]++;
}

int main()
{
    int x, y, s, zero = 0, m = 0;

    while (scanf("%d,%d,%d", &x, &y, &s) != EOF){

        if (1 <= s){
            ink(y, x);
            REP(i, 4){
                ink(y + dy[i], x + dx[i]);
            }
        }
        if (2 <= s){
           ink(y - 1, x - 1);
           ink(y - 1, x + 1);
           ink(y + 1, x - 1);
           ink(y + 1, x + 1);
        }
        if (3 == s){
            REP(i, 4){
                ink(y + (dy[i] * 2), x + (dx[i] * 2));
            }
        }
    }

    REP(i, 10){
        REP(j, 10){
            if (seet[i][j] == 0){
                zero++;
            }
            m = max(m, seet[i][j]);
        }
    }

    CL(zero);
    CL(m);

    return (0);
}

Measured memory_bytes: 3216
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a=15,x;
	rep(i,5){
		cin>>x;a-=x;
	}
	cout<<a<<endl;
}


Measured memory_bytes: 3592
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))}
const main=()=>{
  let s=ts(),a,z
  a=s.indexOf('A')
  z=s.length-s.split('').reverse().join('').indexOf('Z')
  to(z-a)
}
main()

Measured memory_bytes: 11212
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n, m;
int k[20];
int s[20];
int p[20];

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

        cin >> n >> m;
        REP(i,m) {
                cin >> k[i];
                REP(j, k[i]) {
                        int tmp;
                        cin >> tmp;
                        tmp--;
                        s[i] |= (1 << tmp);
                }
        }
        REP(i,m)
                cin >> p[i];

        int r = 0;
        REP(i,1 << n) {
                int bad = 0;
                REP(j,m) {
                        int t = i&s[j];
                        int c = __builtin_popcount(t);
                        if (c%2 != p[j]) {
                                bad=1;
                                break;
                        }
                }
                if (!bad)
                        r++;
        }
        cout << r << endl;


        return 0;
}


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

int main() {
  long long x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red;
  vector<int> grn;
  while(a--){
    int p;
    cin >> p;
    red.push_back(p);
  }
  while(b--){
    int q;
    cin >> q;
    grn.push_back(q);
  }

  sort(red.begin(),red.end(),greater<int>());
  sort(grn.begin(),grn.end(),greater<int>());

  vector<int> vc;
  for(int i=0;i<x;i++){
    vc.push_back(red.at(i));
  }
  for(int i=0;i<y;i++){
    vc.push_back(grn.at(i));
  }
  while(c--){
    int r;
    cin >> r;
    vc.push_back(r);
  }

  sort(vc.begin(),vc.end(),greater<int>());
   
   long long ans=0;
  for(int i=0;i<x+y;i++){
    ans += vc.at(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int X = sc.nextInt();
		int Y = sc.nextInt();

		if(Y % 2 == 0)
		{
			int a = 2*X - (Y/2);
 
			if(Math.ceil(a) == Math.floor(a) && a >= 0 && (X-a) >= 0)
				out.println("Yes");
			else
				out.println("No");
		}
 
		else
		{
			out.println("No");
		}
		
		out.flush();
	}
}

Measured memory_bytes: 27100
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)


using namespace std;

int main() {

	int N;
	cin >> N;

	map<int, int> valueMap;
	rep(i, 100)
	{
		valueMap.insert(make_pair(i, 0));
	}

	int preVal = N;
	for (int i = 1;; ++i)
	{
		if (valueMap[preVal] == 0)
		{
			++valueMap[preVal];
		}
		else
		{
			cout << i;
			break;
		}

		if (preVal % 2 == 0)
		{
			preVal /= 2;
		}
		else
		{
			preVal = 3 * preVal + 1;
		}
	};
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n,count=0,count1=0,count2=0,count3=0;
cin>>n;
while(n--)
{string s;
cin>>s;
if(s=="AC")
count++;
else if(s=="WA")
count1++;
else if(s=="TLE")
count2++;
else
count3++;
}
cout<<"AC x "<<count<<"\n";
cout<<"WA x "<<count1<<"\n";
cout<<"TLE x "<<count2<<"\n";
cout<<"RE x "<<count3;
}

Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val A = Array(M) { sc.next().toInt() }

        val sum = A.sum()
        if (N >= sum) {
            pw.println(N - sum)
        } else {
            pw.println("-1")
        }
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

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

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

vector<edge> E;

const int MAX_V = limit;

int par[MAX_V];

void init(int n) {
    rep(i, n) par[i] = i;
}

int root(int x) {
    if (par[x] == x) {
        return x;
    } else {
        par[x] = root(par[x]);
        return par[x];
    }
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
}

ll kruskal(int n) {
    sort(E.begin(), E.end(), comp);
    init(n);
    ll res = 0;
    for (auto e : E) {
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    pll px[n], py[n];
    ll x[n], y[n];

    rep(i, n) {
        ll xi, yi;
        cin >> xi >> yi;
        px[i] = MP(xi, i);
        py[i] = MP(yi, i);
        x[i] = xi;
        y[i] = yi;
    }

    sort(px, px + n);
    sort(py, py + n);

    rep(i, n - 1) {
        ll dist_x = min(abs(x[px[i + 1].second] - x[px[i].second]),
                abs(y[px[i + 1].second] - y[px[i].second]));
        E.push_back({px[i].second, px[i + 1].second, dist_x});
        ll dist_y = min(abs(x[py[i + 1].second] - x[py[i].second]),
                abs(y[py[i + 1].second] - y[py[i].second]));
        E.push_back({py[i].second, py[i + 1].second, dist_y});
    }

    cout << kruskal(n) << endl;

    return 0;
}

Measured memory_bytes: 12912
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string qw;
    cin >> qw;
    int t=0;
    for (int i=0; i<qw.size(); ++i)
    {
        if (qw[i]=='R')
            t+=1;
    }
    if (t==1)
        cout << 1 << endl;
    else if (t==0)
        cout << 0 << endl;
    else if (t==3)
        cout << 3 << endl;
    else if (qw[1]=='R')
        cout << 2 << endl;
    else
        cout << 1 << endl;
}


Measured memory_bytes: 3620
n,m = map(int,input().split())
ai = [input() for i in range(n)]
bi = [input() for i in range(m)]

flag = False

if n == m:
    for i in range(n):
        for j in range(n):
            if ai[i][j] != bi[i][j]:
                print('No')
                exit()
    print('Yes')
    exit()

for i in range(n-m):
    if flag == True:
        break
    for j in range(n-m):
        if flag == True:
            break
        for k in range(m):
            flag = True
            for l in range(m):
                if bi[k][l] != ai[i+k][j+l]:
                    flag = False
                    break
            if flag == False:
                break

if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
    return 0;
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int l = 0, ans = 0;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            l++;
        } else {
            ans = max(ans, l);
            l = 0;
        }
    }
    cout << max(ans, l) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll a,b;
  cin>>a>>b;
  a+b>=10?cout<<"error"<<endl:cout<<a+b<<endl;

  return 0;
}


Measured memory_bytes: 3640
n,m=map(int,input().split())
a=map(int,input().split())

from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
l=1

max2=0
min2=1000

for i in a:
    factor=(i^(i-1)).bit_length()
    max2=max(max2,factor)
    min2=min(min2,factor)
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

if l>m or min2!=max2:
    print(0)
else:
    ans=1 if l<=m else 0
    m-=l
    print(ans+max(0,m//(2*l)))

Measured memory_bytes: 12608
import java.util.Scanner;
import java.util.Arrays;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] count = new int [101];
		int [] countc = new int [101];
		int max;
		int j = 0;
		int x;
 		
		Scanner cin = new Scanner(System.in);
		while (cin.hasNext()) {
    	 	x = cin.nextInt();
    	 	count[x]++;
		}
    	 	
    	 	for (j = 0; j < 101; j++) {
    	 		countc[j] = count[j];
    	 	}
 			
 			Arrays.sort(countc);
 			
 			max = countc[100];
 			
	 		for (j = 0; j < 101; j++) {
    	 		if (count[j] == max) {
    	 			System.out.println(j);
    	 		}
    	 	}
	}
}

Measured memory_bytes: 26164
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split();
            int N, M;
            Int32.TryParse(a[0], out N);
            Int32.TryParse(a[1], out M);
            string a2 = (N == M) ? "Yes" : "No";
            Console.WriteLine(a2);
        }
    }
}


Measured memory_bytes: 11092
using System;

namespace abc131_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var code = Console.ReadLine();

            var badStatus = false;
            for (int i = 1; i < code.Length; i++)
            {
                if (code[i] == code[i - 1])
                {
                    badStatus = true;
                    break;
                }
            }

            var answer = badStatus ? "Bad" : "Good";
            Console.WriteLine($"{answer}");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n;
    double m;
    cin >> n >> m;
    int z [n];
    int total = 0;
    double x = 1 / (4*m);
    for(int i = 0;i < n;++i){
        cin >> z[i];
        total += z[i];
    }
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(z[i] >= total*x){
            cnt++;
        }
    }
    if(cnt >= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int L, M, N;
	int i, money[12], sum;
	
	while (1){
		
		scanf("%d", &L);
		
		if (L == 0){
			break;
		}
			
	
		for (i = 0; i < 12; i++){
			
			scanf("%d %d", &M, &N);
			money[i] = M - N;
			
		}
		sum = 0;
		for (i = 0; i < 12; i++){
			sum += money[i];
			if (sum >= L){
				printf("%d\n", i + 1);
				L = -1;
				break;
			}
		}
		if (L != -1){
			printf("NA\n");
		}
	}
	return (0);
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

bool all_diff(char a, char b, char c)
{
    return a != b && b !=c && a != c;
}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ret = 0;
    ll cnt[3] = {}; // RGB
    for(int i=0;i<s.length();++i)
    {
        if(s[i] == 'R'){
            cnt[0]++;
        } else if(s[i] == 'G')
        {
            cnt[1]++;
        }else{
            cnt[2]++;
        }
    }
    ret = cnt[0] * cnt[1] * cnt[2];
    for(int i=1;(i*2)<s.length();++i)
    {
        for(int j=0;j + i*2 < s.length();++j)
        {
            if(all_diff(s[j], s[j+i], s[j+2 * i]))
            {
                ret--;
            }
        }
    }
    cout << ret << endl;
}

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

#include <vector>
#define debug(x) print(x, #x)
#define debug_1d(arr, len) print(arr, len, #arr)
#define debug_2d(arr, row, col) print((decltype(&arr[0][0]))arr, row, col, sizeof(*arr)/sizeof(**arr), #arr)
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a1,a2,a3,x,...) x
#define deb(...) CHOOSE((__VA_ARGS__,debug_2d,debug_1d,debug,~))(__VA_ARGS__)
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	return os << '(' << p.first << ',' << p.second << ')';
}
template<typename T> void print(T x, string tag="") {
	if (tag.empty()) cout << x << endl;
	else cout << tag << ": " << x << endl;
}
template<typename T> void print(T *ar, int len, string tag="") {
	if (!tag.empty()) cout << tag << ": ";
	for (int i = 0; i < len; ++i) cout << ar[i] << ' ';
		cout << endl;
}
template<typename T> void print(T *ar, int row, int col, int C, string tag="") {
	if (!tag.empty()) cout << tag << ": " << endl;
	for (int i = 0; i < row; ++i) {
		for (int j = 0; j < col; ++j) {
			cout << ar[i*C + j] << ' ';
		}
		cout << endl;
	}
}
template<typename T> void print(vector<T> v, string tag="") {
	if (!tag.empty()) cout << tag << ": ";
	for (T e : v) cout << e << ' ';
	cout << endl;
}
template<typename T> void print(vector<vector<T>> v, string tag="") {
	if (!tag.empty()) cout << tag << ": " << endl;
	for (auto ev : v) {
		for (auto e : ev) cout << e << ' ';
		cout << endl;
	}
}

int main() {
	long long n, m, x;
	cin >> n >> x >> m;
	int a = 1, t = 1;
	struct P {
		bool b;
		int idx;
	};
	vector<P> v(m);
	v[x] = {true, 0};
	for (long long i = 1, y = x; i <= m+3; i++) {
		y = y * y % m;
		if (v[y].b == true) {
			a = v[y].idx;
			t = i;
			break;
		} else v[y].b = true, v[y].idx = i;
	}
	long long s = 0;
	for (long long i = 0, y = x; i < m+3; i++) {
		if (i >= a && i < t) s += y;
		y = y * y % m;
	}
	long long ans = 0;
	for (int i = 0; i < a && i < n; i++) {
		ans += x;
		x = x * x % m;
		n--;
	}
	ans += s * (n / (t-a));
	for (long long i = (n/(t-a))*(t-a); i < n; i++) {
		ans = (ans + x);
		x = x*x % m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3548
import collections
n = int(input())
a = [int(i) for i in input().split()]
dic = collections.defaultdict(int)

for i in range(n):
  dic[a[i]] += 1
ans = 0
ls = list(dic.keys())
ls.sort()
ans_ls = []

for i in range(len(ls)-1,-1,-1):
  if dic[ls[i]] >= 2:
    ans_ls.append(ls[i])
  if dic[ls[i]] >= 4:
    ans_ls.append(ls[i])
if len(ans_ls) < 2:
  print(0)
else:
  print(ans_ls[0] * ans_ls[1])

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

using namespace std;

const long long int INF = 1LL<<60;

int main() {
  string s, t;
  cin >> s;
  cin >> t;

  vector<vector<int>> dp(s.length()+1, vector<int>(t.length()+1, 0));
  for(int i=0; i<s.length(); i++) {
    for(int j=0; j<t.length(); j++) {
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  string res = "";

  int i = s.length(), j=t.length();
  while(i > 0 && j > 0) {
    if(dp[i][j] == dp[i-1][j]){
      i--;
    } else if(dp[i][j] == dp[i][j-1]) {
      j--;
    } else {
      res = s[i-1] + res;
      i--;
      j--;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    string s,t;
    cin >> s >> t;
    
    priority_queue<string,vector<string>,greater<string>> sq;
    priority_queue<string> tq;
    
    rep(i,(int)s.size())
        sq.push(s.substr(i,1));
    rep(i,(int)t.size())
        tq.push(t.substr(i,1));

    string sd = "";
    string td = "";

    rep(i,(int)s.size())
    {
        sd += sq.top();
        sq.pop();
    }
    rep(i,(int)t.size())
    {
        td += tq.top();
        tq.pop();
    }

    cout << (sd<td ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 1000000
#define offset 50000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
const ll MOD=1e9+7;
ll pot(ll base,ll exp)
{
    base%=MOD;
    ll res=1;
    while(exp>0)
    {
        if (exp&1)
            res*=base,res%=MOD;
        base*=base;base%=MOD;
        exp/=2;
    }
    return res;
}
ll F[tam],Finv[tam];
ll C(ll n,ll m)
{
    if (n<0|| m<0|| m>n)
        return 0;
    ll aux=F[n];
    aux*=Finv[m];aux%=MOD;
    aux*=Finv[n-m];aux%=MOD;
    return aux;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    F[0]=Finv[0]=1;
    forr(i,1,tam)
    {
        F[i]=F[i-1]*i,F[i]%=MOD;
        Finv[i]=Finv[i-1]*pot(i,MOD-2),Finv[i]%=MOD;
    }
    //cout<<C(5,3)<<endl;
    int n,m,k;
    cin>>n>>m>>k;
    int s=m+k;
    int iz,der;
    iz=der=k;
    ll val=C(s,k);//aca
    ll answer=val*C(n-1+s,s),totpar;answer%=MOD;
    //cout<<val<<" "<<answer<<endl;
    //cout<<endl;
    for(int i=s-1;i>=0;i--)
    {
        iz--;
        val+=C(i,iz);
        val+=C(i,der);val%=MOD;
        val*=pot(2,MOD-2);val%=MOD;
        //val
        totpar=C(n-1+i,i)*val;totpar%=MOD;
        totpar*=pot(3,s-i);totpar%=MOD;
        //cout<<val<<" "<<totpar<<endl;
        answer+=totpar;
        answer%=MOD;
    }
    cout<<answer<<endl;

}   


Measured memory_bytes: 15872
def main():
  H, W, D = map(int, input().split())
  num = [[] for _  in range(H*W)]
  for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
      num[temp[j]-1] = [i, j]
  #num = np.array(num)
  num_sum = [0]*(H*W)
  for i in range(D, H*W):
    num_sum[i] = num_sum[i-D] + (abs(num[i][0]-num[i-D][0])+ abs(num[i][1]-num[i-D][1]))
  Q = int(input())
  for i in range(Q):
    L, R = map(int, input().split())
    print(num_sum[R-1]-num_sum[L-1])
if __name__ == "__main__":
  main()

Measured memory_bytes: 17076
#include <stdio.h>
#define change(type, x, y) do{int temp; temp = x; x = y; y = temp;}while(0);
#define NUMBER 10
#define DATANUMBER 3

void bubble_sort(int vc[], int num) {
    int i, j;
    
    for(i = 0; i < num; i++) {
        for(j = i + 1; j < num; j++) {
            if(vc[i] < vc[j])
                change(int, vc[i], vc[j]);
        }
    }
    
}

int main(void) {
    int mountain[NUMBER];
    int i;
    
    for(i = 0; i < NUMBER; i++) {
        scanf("%d", &mountain[i]);
    }
    
    bubble_sort(mountain, NUMBER);
    
    for(i = 0; i < DATANUMBER; i++) {
        printf("%d\n", mountain[i]);
    }
    
    return(0);
}

Measured memory_bytes: 600
N=int(input())
import math
ans=(N+1)*N//2

ans-=(N//3)*(N//3*3+min(3,N//3*3))//2
ans-=(N//5)*(N//5*5+min(5,N//5*5))//2
ans+=(N//15)*(N//15*15+min(15,N//15*15))//2
print(ans)


Measured memory_bytes: 61976
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],q[2];main(n,m,p,I,x,y,z,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,I=0,sizeof(M)),c=1;I++<p;c*=-1){
		for(scanf("%d%d",&x,&y),z=1;;z++)if(!M[x][y][z]){M[x][y][z]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(q[j]=2*j-1;;q[j]+=2*j-1)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I++<p;)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N, A, B;

signed main(){
    cin >> N >> A >> B;
    if(abs(A-B)%2 == 0){
        cout << abs(A-B)/2 << endl;
    }
    else{
        ll ans = A + abs(1-(B-A))/2;
        A = N+1-A;
        B = N+1-B;
        swap(A, B);
        ans = min(ans, A + abs(1-(B-A))/2);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e17 + 42;
const ll N = (ll)1e6 + 2;
 
ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod ;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res % mod ;
}
 
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
//    //ans[a] += ans[b];
//    //return true;
// }
//
//ll sev[275];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 275 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 275 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        ll n  , a , b;
        cin >> n >> a >> b;
        ll t1 = max(a , b);
        a = min(a , b);
        b = t1;
        if((b - a) & 1)
        {
            t1 = b - a;
            ll ans = min({a - 1 , n - b });
            ans ++;
            ans += (t1 - 1)/2;
            print(ans);
        }
        else
        {
            print((b - a)/2);
        }
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


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

int n,p,t,dp[50][3],P,T,a;

int main(){
	while(cin>>n,n){
		rep(i,50)rep(j,3)dp[i][j]=INF;
		dp[0][0]=0;P=0;T=0;a=INF;
		rep(i,n){
			cin>>p>>t;
			rep(j,3)if(dp[i][j]!=INF&&(j+2)*P+p<=t-T)dp[i+1][0]=min(dp[i+1][0],dp[i][j]+P+p);
			for(int j=1;j<3;j++)if(dp[i][j-1]!=INF&&(j+1)*abs(P-p)<=t-T)dp[i+1][j]=min(dp[i+1][j],dp[i][j-1]+abs(P-p));
			P=p;T=t;
		}
		rep(i,3)a=min(a,dp[n][i]);
		if(a!=INF) cout<<"OK "<<a+P<<endl;
		else{
			rep(i,n+1)if(dp[i][0]==INF&&dp[i][1]==INF&&dp[i][2]==INF){a=i;break;}
			cout<<"NG "<<a<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include <stdio.h>

typedef unsigned int ui;

int seatsOcu(ui a, ui b) {
    if (a > b) {
        return (a - b) + 1;
    }else if (b > a) {
        return (b - a) + 1;
    }else{
        return 1;
    }
}

int main() {
    ui total, n, a, b ;

    scanf("%u", &n);

    for (size_t i = 0; i < n; ++i) {
        scanf("%u %u", &a, &b);
        total += seatsOcu(a, b);
    }

    printf("%u\n", total);
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] l = new int[n * 2];

		for (int i = 0; i < l.length; i++) {
			l[i] = sc.nextInt();
		}

		Arrays.sort(l);

		int sum = 0;
		for (int i = 0; i < l.length; i += 2) {
			sum += Math.min(l[i], l[i + 1]);
		}

		System.out.println(sum);

		sc.close();
	}

}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int64_t	modpow(int64_t a, int64_t n, const int64_t mod)
{
	int64_t	result = 1;
	while (n) {
		if (n & 1) result = result * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return result;
}

int64_t	modinv(int64_t a, const int64_t mod)
{
	int64_t	b = mod;
	int64_t	u = 1, v = 0;
	while (b > 0) {
		int64_t	q = a / b;
		a -= q * b; swap(a, b);
		u -= q * v; swap(u, v);
	}
	if (u < 0)
		u += mod;
	return u;
}

int64_t modinvpow(int64_t a, int64_t n, const int64_t mod)
{
    return modinv(modpow(a, n, mod), mod);
}

int dfs(const Graph &graph, vector<int> &num_child, int u, int par)
{
    int num_child_u = 0;
    for (int v : graph.at(u)) {
        if (v == par) continue;
        num_child_u += dfs(graph, num_child, v, u) + 1;
    }
    num_child.at(u) = num_child_u;
    return num_child_u;
}

int64_t dfs2(int N, const Graph &graph, const vector<int> &num_child,
            int u, int par, const int64_t mod)
{
    int64_t ev = 0;
    int64_t prob;
    for (int v : graph.at(u)) {
        if (v == par) continue;
        ev = (ev + dfs2(N, graph, num_child, v, u, mod));
        int nc = num_child.at(v);
        int64_t p1 = modinvpow(2, nc + 1, mod);
        int64_t p2 = modinvpow(2, N - nc - 1, mod);
        prob = (1 - p1) * (1 - p2) % mod;
        ev = (ev + prob) % mod;
    }
    return ev;
}

int	main()
{
    const static int64_t mod = static_cast<int64_t>(1e+9) + 7;
    int N;
    cin >> N;
    Graph graph(N);
    int A, B;
    for (int i = 0; i < N - 1; ++i) {
        cin >> A >> B;
        --A; --B;
        graph.at(A).push_back(B);
        graph.at(B).push_back(A);
    }
    vector<int> num_child(N, -1);
    dfs(graph, num_child, 0, -1);
    int64_t ev = - N * modinv(2, mod); // ev: expected value
    ev = (ev + dfs2(N, graph, num_child, 0, -1, mod)) % mod;
    ev = (ev + 1 - modinvpow(2, N, mod)) % mod;
    ev = (ev < 0) ? (ev + mod) : ev;
    cout << ev << endl;
}


Measured memory_bytes: 28312
#include<iostream>

using namespace std;

int main(){
	int n, x, count = 0;

	for (int i = 1; i = 1;){
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0){
			break;
		}
		for (int i1 = 1; i1 < n +1; i1++){
			for (int i2 = 1; i2 < n+1; i2++){
				if (i1 != i2){
					for (int i3 = 1; i3 < n+1; i3++){
						if (i2 != i3 && i1 != i3){
							if (i1 + i2 + i3 == x){
								
								count++;
							}
						}
					}

				}
			}
		}
		cout << count / 6 << endl;

	}

}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll> >;

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n; cin >> n;
    if(n == 1) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output1.txt","w", stdout);
    #endif
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans;
    ans=max(a*c,max(a*d,max(b*c,b*d)));
    cout<<ans;
    #ifndef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}       

Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
from sys import stdin

N, M, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
lx = [int(x) for x in stdin.readline().rstrip().split()]
ly = [int(x) for x in stdin.readline().rstrip().split()]

lx.append(X)
ly.append(Y)

if max(lx) >= min(ly):
    print("War")
else:
    print("No War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n;

void input(){
    cin >> n;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    string ans = "";
    while(n != 0){
        int r = n%2;
        if (r < 0) r+=2;
        n = (n - r) / (-2);
        ans += (char)('0' + r);
    }
    reverse(ans.begin(), ans.end());
    if (ans == "" ) ans = "0";
    cout << ans << endl;
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		bool[] NA = new bool[N];
		for(int i=0;i<N;i++){
			if(S[i] == '#') NA[i] = true;
			if(i + 1 < N && S[i + 1] == '#') NA[i] = true;
			if(i - 1 >= 0 && S[i - 1] == '#') NA[i] = true;
		}
		
		bool chk = false;
		for(int i=A;i<C;i++){
			if(i + 1 < N && S[i + 1] == '.') continue;
			if(i + 2 < N && S[i + 2] == '.') continue;
			chk = true;
			break;
		}
		if(chk){
			Console.WriteLine("No");
			return;
		}
		
		chk = false;
		for(int i=B;i<D;i++){
			if(i + 1 < N && S[i + 1] == '.') continue;
			if(i + 2 < N && S[i + 2] == '.') continue;
			chk = true;
			break;
		}
		if(chk){
			Console.WriteLine("No");
			return;
		}		
		
		if(C <= B || D <= A){
			Console.WriteLine("Yes");
			return;
		}
		
		if(D > C){
			Console.WriteLine("Yes");
			return;
		}
		
		chk = false;
		for(int i=B;i<=D;i++){
			if(NA[i] == false) chk = true;
		}
		Console.WriteLine(chk ? "Yes" : "No");
		
		
	}
	int N,A,B,C,D;
	String S;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1] - 1; B = d[2] - 1; C = d[3] - 1; D = d[4] - 1;
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read();
	vector<pi> lr(n);
	REP(i,n){
		int h=read(),p=read();
		lr[i]=pi(h+p,h);
	}
	sort(ALL(lr));
	priority_queue<int,vector<int>,greater<int>> pq;
	int x=inf,mn=0;
	const auto UpdateX=[&](int w){
		while(!pq.empty()){
			int v=pq.top();
			int y=x-v;
			if(y>=w){
				pq.pop();
				x=y;
				mn++;
			}else
				break;
		}
		if(!pq.empty()){
			int v=pq.top();
			pq.pop();
			pq.push(w-(x-v));
		}
		x=w;
	};
	for(int i=n-1;i>=0;i--){
		int l=lr[i].second,r=lr[i].first;
		UpdateX(r);
		pq.push(r-l);
	}
	UpdateX(0);
	print(mn);
}


Measured memory_bytes: 384