akhauriyash/Code-Regression huggingface dataset:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
li = []
if r - l > 2019:
    print(0)
else:
    for i in range(l, r+1):
        li.append(i % num)
    li.sort()
    n = len(li)
    m = 1000000000
    for i in range(n):
        for j in range(i+1, n):
            kazu = (li[i] * li[j]) % num
            if m > kazu:
                m = kazu
    print(m)




Measured memory_bytes: 3064
//https://atcoder.jp/contests/agc040/tasks/agc040_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
#if LOCAL&0
    std::ifstream in("./input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    string S; cin>>S;
    vector<ll> an(S.size()+1,0);
    vector<ll> bn(S.size()+1,0);
    for(ll i=0;i<S.size();++i){
        if(S.at(i)=='<'){
            an.at(i+1)=max(an.at(i)+1,an.at(i+1));
        } else {
            bn.at(i+1)=max(bn.at(i)+1,bn.at(i+1));
        }
    }
    for(ll i=S.size()-1;i>=0;--i){
        if(S.at(i)=='>'){
            an.at(i)=max(an.at(i),an.at(i+1)+1);
        } else{
            bn.at(i)=max(bn.at(i),bn.at(i+1)+1);
        }
    }
    ll ans=0;
    for(const auto& a:an){
        ans+=a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8732
r, g, b, n= [int(_) for _ in input().split()]
c = [r, g, b]
c.sort(reverse = True)
ans = 0
for i in range(n // c[0] + 1):
    for j in range((n-i*c[0]) // c[1] + 1):
        if (n-i*c[0]-j*c[1]) % c[2] == 0:
            ans += 1
print(ans)

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

}

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

#define M 750101/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch);

/* convert a string into an integer value */
long long getKey(char str[]);

int h1(int key);
int h2(int key);

int find(char str[]);
int insert(char str[]);


int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  
  return 0;
}
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}
int h2(int key){
  return (1+key%(M-1));
}

int find(char str[]){
  int i;
  long long h; 

  for(i=0;;i++){
    h=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(str,H[h])==0) return 1;
    if(H[h][0]=='\0') return 0;//H ni \0 ga arutoki 
  }
}
int insert(char str[]){
  int i;
  long long h;
  for(i=0;;i++){
    h=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(str,H[h])==0)return 1;
    if(H[h][0]=='\0'){
      strcpy(H[h],str);
      return 0;
    }
  }
}



Measured memory_bytes: 12048
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll gcd(ll a,ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

int main(){
	init();
	ll ans=0;
	ll N;cin>>N;
	for(int i=0;i<N;i++){
		ll a;cin>>a;
		ans=gcd(ans,a);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int kaijo(int n){
    int res=1;
    rep1(i,n){
        res*=i;
        res%=MOD;
    }
    return res;
}
int comb(int n,int k){
    int res=kaijo(n);
    res*=modinv(kaijo(k),MOD);
    res%=MOD;
    res*=modinv(kaijo(n-k),MOD);
    res%=MOD;
    return res;
}
signed main(){
    int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    int res=comb(r2+c2+2,r2+1);
    res-=comb(r1+c2+1,r1);
    res-=comb(r2+c1+1,c1);
    res+=comb(r1+c1,r1);
    res+=MOD;
    res%=MOD;
    cout<<res<<endl;
    //cout<<comb(10,5)+comb(9,4)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S,T;
bool sym(string U){
	for(int i=0;i<U.size();i++){
		int K=U.size()-1-i;
		if(U[i]=='i' && U[K]=='i'){
			goto E;
		}
		if(U[i]=='w' && U[K]=='w'){
			goto E;
		}
		if(U[i]=='(' && U[K]==')'){
			goto E;
		}
		if(U[i]==')' && U[K]=='('){
			goto E;
		}
		if(U[i]=='[' && U[K]==']'){
			goto E;
		}
		if(U[i]==']' && U[K]=='['){
			goto E;
		}
		if(U[i]=='{' && U[K]=='}'){
			goto E;
		}
		if(U[i]=='}' && U[K]=='{'){
			goto E;
		}
		return false;
		E:;
	}
	int cnt=0;
	char x[200];
	int size2=U.size();
	for(int i=0;i<size2;i++){
		x[i]=U[i];
	}
	for(int i=0;i<size2-2;i++){
		if(x[i]==105 && x[i+1]==119 && x[i+2]==105){
			cnt++;
		}
	}
	if(cnt==1){
		return true;
	}
	return false;
}
int main(){
	int res=0;
	cin>>S;
	for(int i=0;i<(1<<(S.size()));i++){
		T="";
		for(int j=0;j<S.size();j++){
			if((i/(1<<j))%2==0){
				T+=S[j];
			}
		}
		bool ok=sym(T);
		if(ok==true){
			res=max(res,(int)(T.size()));
		}
	}
	if(res<=2){
		res=0;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1192
n,x,m = gets.split.map(&:to_i)

used = Array.new(m,0)
as = Array.new(m,0)
cnt = 1
a = x
as[0] = a
used[a] = 1
again = 1
lpn = 0
while true
  a = a**2 % m
  if a == 0
    again = 0
    break
  end
  if used[a] == 0
    as[cnt] = a
    cnt += 1
    used[a] = 1
  else
    lpn = a
    break
  end
end

if again == 1
  beflp = 0
  aftlp = 0
  lpst = 0
  flag = 0
  for i in 0..(cnt-1)
    if as[i] == lpn
      flag = 1
      lpst = i
    end
    if flag == 0
      beflp += as[i]
    else
      aftlp += as[i]
    end
  end
  
  ans = beflp + aftlp*((n-lpst)/(cnt-lpst))
  for i in 0..(((n-lpst) % (cnt-lpst)) - 1)
    ans += as[i+lpst]
  end
  puts ans
else
  ans = 0
  for i in 0..(cnt-1)
    ans += as[i]
  end
  puts ans
end

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

int main(){
	int a = 100000, n;
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		a *= 1.05;
		if (a % 1000 != 0){
			a -= a % 1000;
			a += 1000;
		}
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

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

	if (k*500 >= x)
		cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3572
import java.util.ArrayList;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	
    	int a;
    	int b;
    	while (scan.hasNextInt()){
    		a = scan.nextInt();
    		b = scan.nextInt();
    		int[] result = doThem(a, b);
    		System.out.println(result[0] + " " + result[1]);
    	}
    }
    
    public static int[] doThem(int a, int b){
    	ArrayList<Integer> comfac = new ArrayList<Integer>();
		
		while (!isprime(a) || !isprime(b)){
			
			int fac;
			if (minfactor(a) == minfactor(b)){
				fac = minfactor(a);
				a = a / fac;
				b = b / fac;
				comfac.add(fac);
			}else if(minfactor(a) < minfactor(b)){
				fac = minfactor(b);
				if(a % fac == 0){
					a = a / fac;
					b = b / fac;
					comfac.add(fac);
				}else{
					fac = 5;
					if(a % fac == 0 && b % 5 == 0){
						a = a / fac;
						b = b / fac;
						comfac.add(fac);
					}else{
						break;
					}
				}
			}else if(minfactor(a) > minfactor(b)){
				fac = minfactor(a);
				if(b % fac == 0){
					a = a / fac;
					b = b / fac;
					comfac.add(fac);
				}else{
					fac = 5;
					if(a % fac == 0 && b % 5 == 0){
						a = a / fac;
						b = b / fac;
						comfac.add(fac);
					}else{
						break;
					}
				}
			}
		}
		
		if(a == b){
			a = a / a;
			b = b / a;
			comfac.add(a);
		}
		
		int[] result = new int[2];
		result[0] = 1; result[1] = 1;
		for(Integer value : comfac){
			result[0] = result[0] * value;
		}
		result[1] = result[0]*a*b;
		return result;
    }
    
    public static int minfactor(int n){
    	if (n % 2 == 0) return 2;
    	if (n % 3 == 0) return 3;
    	if (n % 5 == 0) return 5;
    	
    	int m = 7;
    	while (m*m <= n){
    		if (m*m == n){
    			return m;
    		}
    		m += 2;
    	}
    	
    	return n;
    }
    
    public static boolean isprime(int n){
    	if(minfactor(n) == n){
    		return true;
    	}else{
    		return false;
    	}
    }
}

Measured memory_bytes: 17228
program digit
	implicit none
    character(len=17) :: n
    character(len=17),parameter :: q = '99999999999999999'
    integer :: j
    integer :: i, ans
    
    read(*,*) n
    read(n(1:1),*) j !最高位の数字
    
    i = len_trim(n) !桁数

    if ( i==1 ) then
    	write(*,*) n
        stop
    end if
    
    if ( n(2:i) == q(2:i) ) then
    	ans = 9*(i-1) + j        
        write (*,*) ans
        stop
    end if
    
    ans = 9*(i-1) + j - 1
    write(*,*) ans
    stop
end program digit

Measured memory_bytes: 2860
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
 
struct Card {
    char suit;
    int value;
};
 
struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];
 
void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++)L[i] = A[left + i];
    for (i = 0; i < n2; i++)R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}
 
void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}
 
int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}
 
void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}
 
int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
 
    scanf("%d", &n);
 
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
 
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);
 
    for (i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit)stable = 0;
    }
 
    if (stable == 1)printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
 
    return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>
#include <functional>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

bool isPrime(ll n)
{
    if(n == 1)
    {
        return false;
    }
    for(ll i = 2; i*i <= n; i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

int main(void)
{
    
    int h,w,k,t,res;
    char tmp;
    vector<int> board, row, col;
    
    cin >> h >> w >> k;
    
    int ttl = 0;
    
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> tmp;
            if(tmp == '.')
            {
                board.push_back(0);
            }
            else
            {
                board.push_back(1);
                ttl++;
            }
        }
    }
    
    res = 0;
    
    for(int i = 0; i < (int)pow(2, h)-1; i++)
    {
        for(int j = 0; j < (int)pow(2, w)-1; j++)
        {
            t = 0;
            for(int a = 0; a < h; a++)
            {
                for(int b = 0; b < w; b++)
                {
                    if(i & (1 << a) || j & (1 << b))
                    {
                        
                    }
                    else
                    {
                        t += board[w*a+b];
                    }
                }
            }
            if(t == k)
            {
                res++;
            }
        }
    }
    
    cout << res;
    
    
    return 0;
}

Measured memory_bytes: 4096
// ConsoleApplication3.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main() {
    int N, M;
    cin >> N;
    cin >> M;
    if (N == M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int ac[110], bc[110];

int main() {
	string a, b;
	bool flag =false;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		ac[i] = a[i] - 'a';
	}
	for (int i = 0; i < b.size(); i++) {
		bc[i] = b[i] - 'a';
	}
	sort(ac, ac+a.size());
	sort(bc, bc+b.size());
	reverse(bc, bc + b.size());

	int rage = (a.size() < b.size()) ? a.size() : b.size();
	for (int i = 0; i < rage; i++) {
		if (ac[i] < bc[i]) {
			flag = true;
			break;
		}
	}
	if (ac[rage - 1] == bc[rage - 1]&&!flag) {
		if (a.size() < b.size())flag = true;
	}

	cout << ((flag) ? "Yes" : "No") << endl;

	return 0;
}

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

int main(){
     int n,k;
     cin >> n >> k;
     int cnt =0;
     vector<int> x(n,0);
     rep(i,k){
       int d;
       cin >>d;
       
       vector<int> a(d);
       rep(i,d) cin >> a[i];
       rep(i,d){
         if(x[a[i]-1]==0) {x[a[i]-1]++;
       }
       }
     }
     rep(i,n){
       if(x[i]==0) cnt++;
     }
     cout << cnt<<endl;
 }

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); 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; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( K < 10 )
    {
        cout << K << endl;
        return 0;
    }

    priority_queue<ll, vector<ll>,greater<ll> > q;
    REP(i, 1, 10) q.push(i);

    rep(i,K-1)
    {
        ll tmp = q.top();
        q.pop();
        int tmp_size = to_string(tmp).size();
        
        q.push(tmp*10+tmp%10);
        if( tmp%10 != 9 )  q.push(tmp*10+tmp%10+1);
        if( tmp%10 != 0 ) q.push(tmp*10+tmp%10-1);
    }
    cout << q.top() << endl;
}


Measured memory_bytes: 2420
#include<stdio.h>

int main(){
  int a,b,k;
  int div_a[100]={},div_b[100]={};
  scanf("%d %d %d",&a,&b,&k);
  
  int s=0;
  for(int i=1;i<=a;i++){
    if(a%i==0){
      div_a[s]=i;
      s++;
    }
  }
  int t=0;
  for(int j=1;j<=b;j++){
    if(b%j==0){
      div_b[t]=j;
      t++;
    }
  }
  int count=0;
  for(int i=s-1;i>=0;i--){
    for(int j=t-1;j>=0;j--){
      if(div_a[i]==div_b[j]){
        count++;
        if(count==k){
          printf("%d",div_a[i]);
          return 0;
        }
        break;
      }
    }
  }
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }

#define MAX_V (ll)1e5+1

struct edge {
    ll to;
    ll cost;
};

// <最短距離, 頂点の番号>
#define P pair<ll, ll>

ll V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V+1, INF_LL);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main()
{
    cin >> V;

    vector<ll> a(V-1);
    vector<ll> b(V-1);
    vector<ll> c(V-1);

    rep(i,V-1)
    {
        cin >> a[i] >> b[i] >> c[i];
        edge e = {b[i], c[i]};
        G[a[i]].push_back(e);
        e = {a[i], c[i]};
        G[b[i]].push_back(e);
    }

    ll Q,K;
    cin >> Q >> K;

    vector<ll> x(Q);
    vector<ll> y(Q);
    rep(i,Q) cin >> x[i] >> y[i];
    
    dijkstra(K);

    rep(i,Q)
    {
        cout << d[x[i]] + d[y[i]] << endl;
    }

    /*
    rep(i,6)cout << d[i] << " ";
    cout << endl;
    */
}


Measured memory_bytes: 15088
n = int(input())
h = [int(i) for i in input().split()] 
bef = 0
count = 0
max_count = 0
for x in h:
  if x <= bef:
    count += 1
  else:
    count = 0
  
  max_count = max(max_count, count)
  bef = x
  
print(max_count)

Measured memory_bytes: 14252
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

def scc(g):
    n=len(g)
    cmp=[0]*n
    ord=[-1]*n
    fin=[False]*n
    low=[0]*n
    visited=[]
    num=0
    k=0
    for x in range(n):
        if ord[x]!=-1:
            continue
        st=[~x, x]
        while st:
            v=st.pop()
            if v>=0:
                if ord[v]!=-1:
                    continue
                ord[v]=num
                low[v]=num
                num+=1
                visited.append(v)
                for w in g[v]:
                    if ord[w]==-1:
                        st.append(~w)
                        st.append(w)
            else:
                v=~v
                if fin[v]:
                    continue
                fin[v]=True
                for w in g[v]:
                    if ord[w]<ord[v]:
                        if ord[w]<low[v]:
                            low[v]=ord[w]
                    elif ord[w]<n:
                        if low[w]<low[v]:
                            low[v]=low[w]
                if ord[v]==low[v]:
                    while True:
                        w=visited.pop()
                        cmp[w]=k
                        ord[w]=n
                        if w==v:
                            break
                    k+=1
    cmp=[k-1-x for x in cmp]
    return (k, cmp)
n, m=map(int, readline().split())
g=[[] for _ in range(n)]
ab=map(int, read().split())
for a, b in zip(ab, ab):
    g[a].append(b)
k, cmp=scc(g)
print(k)
vs=[[] for _ in range(k)]
ans=[]
for i, x in enumerate(cmp):
    vs[x].append(i)
for v in vs:
    ans.append(f"{len(v)} "+" ".join(map(str, v)))
print("\n".join(ans))

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  char A[H][W];
  int cnt[30] = {};
  rep(i, H) rep(j, W) {
    cin >> A[i][j];
    cnt[A[i][j]-'a']++;
  }
  using P = pair<int, char>;
  priority_queue<P> que;
  rep(i, 30) if(cnt[i] > 0) que.emplace(cnt[i], i+'a');
  if(H > 1 && W > 1) {
    int hoge = 0;
    while(!que.empty() && hoge < (H/2)*(W/2)) {
      P p = que.top(); que.pop();
      if(p.first >= 4) {
	hoge++;
	if(p.first > 4) que.emplace(p.first-4, p.second);
      } else {
	que.push(p);
	break;
      }
    }
    if(hoge != (H/2)*(W/2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(H%2 == 1 && W > 1) {
    int hoge = 0;
    while(!que.empty() && hoge < W/2) {
      P p = que.top(); que.pop();
      if(p.first >= 2) {
	hoge++;
	if(p.first > 2) que.emplace(p.first-2, p.second);
      } else {
	que.push(p);
	break;
      }
    }
    if(hoge != W/2) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(W%2 == 1 && H > 1) {
    int hoge = 0;
    while(!que.empty() && hoge < H/2) {
      P p = que.top(); que.pop();
      if(p.first >= 2) {
	hoge++;
	if(p.first > 2) que.emplace(p.first-2, p.second);
      } else {
	que.push(p);
	break;
      }
    }
    if(hoge != H/2) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(H%2 == 1 && W%2 == 1) {
    assert(!que.empty());
    P p = que.top(); que.pop();
    if(p.first > 1) que.emplace(p.first-1, p.second);
  }
  cout << (que.empty() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b||b==c||a==c) 
	{
		if(a!=b||b!=c||a!=c)
		{
			cout<<"Yes";
			return 0;
		}
		else
		{
			cout<<"No";
			return 0;
		}
	}
	else
	{
		cout<<"No";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if (a<=8 && b<=8)
	{
		cout<<"Yay!"<<endl;
		return 0;
	}
	if(a>8 || b>8)
	{
		cout<<":("<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll N = 110, V = 1100 * N, mod = 1e9 + 7; 
ll a[N], b[N], dp[N][V], ans;
int main(){
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++){
        cin >> b[i] >> a[i];
    }
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= V; j++)
            dp[i][j] = mod;
    dp[0][0] = 0; 
    for(int i = 1; i <= n; i++){
        for(ll j = 0; j < V; j++){
            dp[i][j] = dp[i - 1][j]; 
            if(j >= a[i]){
                dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i]] + b[i]);
            }
            if(dp[i][j] <= w)ans = max(ans, j);
        } 
    }
    cout << ans << endl;
}  

Measured memory_bytes: 96512
from operator import itemgetter

n = int(input())
a = []
res = ('Yes')
for i in range(n):
    a.append(list(map(int,input().split())))

a.sort(key=itemgetter(1))
suma = 0
for i in range(0,n):
    suma += a[i][0]
    if suma > a[i][1]:
        res = ('No')
        break


print(res)

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

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i=0; i<N; i++) {
            L[i] = sc.nextInt();
        }

        System.out.println(solve3(N, L));
    }

    /**
     * 愚直な実装でこれだとTLE
     * @param N
     * @param L
     * @return
     */
    private static int solve(int N, int[] L) {
        int count = 0;

        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                for (int k=j+1; k<N; k++) {
                    if (L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]) {
                        count++;
                    }
                }
            }
        }

        return count;
    }

    /**
     * 三角形を構成する2辺を事前に選んだとき，残りの1辺を三角形の成立条件と累積和により求める．
     *
     * @param N
     * @param L
     * @return
     */
    private static long solve2(int N, int[] L) {
        long count = 0;

        // i以上の辺の数を求める
        int[] numGreaterOrEqualToL = new int[1000 + 2];
        Arrays.sort(L);
        int idx = 0;
        for (int i=1000; i>=0; i--) {
            numGreaterOrEqualToL[i] = numGreaterOrEqualToL[i+1];
            while (idx < N && i == L[N - idx - 1]) {
                numGreaterOrEqualToL[i]++;
                idx++;

                // System.err.println("OL[" + i + "] = " + numGreaterOrEqualToL[i]);
            }
        }

        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                // 三角形の成立条件 c < a + b, c > a - b, c > b - a
                int kMax = Math.min(1000+1, L[i]+L[j]);
                int kMin = Math.abs(L[i]-L[j]);

                count += numGreaterOrEqualToL[kMin+1] - numGreaterOrEqualToL[kMax];
                if (kMin < L[i] && L[i] < kMax) count--;
                if (kMin < L[j] && L[j] < kMax) count--;

                // System.err.println("i=" + L[i] + ", j=" + L[j] + " = " + count);
            }
        }

        // 同じ三角形を3回選んでいるので1/3が求める数
        return count/3;
    }

    /**
     * 2分探索で求める
     * @param N
     * @param L
     * @return
     */
    private static long solve3(int N, int[] L) {
        long count = 0;

        Arrays.sort(L);
        for (int i=0; i<N; i++) {
            for (int j=i+1; j<N; j++) {
                int l = L[i] + L[j];
                int lb = lowerBound(L, l);

                count += lb - j - 1;
            }
        }

        return count;
    }

    /**
     * l <= L_i を満たす最小の i を返す
     * @param L
     * @param l
     * @return
     */
    private static int lowerBound(int[] L, int l) {
        int lb = -1;
        int ub = L.length;

        while (ub - lb > 1) {
            int mid = (ub+lb)/2;
            if (l <= L[mid]) {
                ub = mid;
            } else {
                lb = mid;
            }
        }

        return ub;
    }
}

Measured memory_bytes: 26280
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int top,s[1000];


int pop()
{
  top--;
  return s[top+1];
}

int push(int a)
{
  s[++top]=a;
}

int main()
{
  int b,a;
  top=0;
  char c[3];
  while(cin>>c){
    if(c[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(c[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(c[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(c));
    }
  }
  cout<<pop()<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n], b[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i <= (n-3); i++) {
    bool b1 = (a[i]==b[i]);
    bool b2 = (a[i+1]==b[i+1]);
    bool b3 = (a[i+2]==b[i+2]);
    if(b1&&b2&&b3) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3644
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
uf1 = UnionFind(N)
frs = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    uf1.union(a-1, b-1)
    frs[a-1] += 1
    frs[b-1] += 1
ans = []
for i in range(N):
    ans.append(uf1.size(i) - frs[i] - 1)
for _ in range(K):
    c, d = map(int, input().split())
    if uf1.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)


Measured memory_bytes: 14124
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include<math.h>
//#include "Ants.h"
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
/************************************************************************************/
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
/**************/
int h[int(1e5)] = { 10,30,40,20 };
ll dp[int(1e5)];
int main()
{
	int n=4;
	int K;
	cin >> n>>K;
	for (int i = 0; i < n; i++)cin >> h[i];
	for (int i = 0; i < n; i++)dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < K; j++) {
			
			int jump = i+j + 1;
			if (jump >= n)continue;
			dp[jump] = min(dp[jump],dp[i] + abs(h[jump] - h[i]));
		}
	}
	cout << dp[n-1] << endl;

}

Measured memory_bytes: 1408
#include<stdio.h>
#define N 100000
#define NIL -1
void depth(int,int);
void print(int);

typedef struct{
    int parent;
    int left;
    int right;
} Node;
Node node_all[N];
int n;
int depth_node[N];

int main(){
    int i,j,n_num,degree,data,n_child,flag;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        node_all[i].parent = node_all[i].left = node_all[i].right = NIL;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&n_num,&degree);
        for(j=0;j<degree;j++){
            scanf("%d",&data);
            if(j==0){
                node_all[n_num].left = data;
            }
            else{
                node_all[n_child].right = data;
            }
            n_child = data;
            node_all[data].parent = n_num;
        }
    }
    for(i=0;i<n;i++){
        if(node_all[i].parent == NIL) flag = i;
    }
    depth(flag,0);
    for(i=0;i<n;i++){
        print(i);
    }
    return 0;
}

void depth(int first,int count){
    depth_node[first] = count;
    if(node_all[first].right != NIL){
        depth(node_all[first].right,count);
    }
    if(node_all[first].left != NIL){
        depth(node_all[first].left,count+1);
    }
}

void print(int k){
    int i,data;
    printf("node %d: ",k);
    printf("parent = %d, ",node_all[k].parent);
    printf("depth = %d, ",depth_node[k]);
    if(node_all[k].parent == NIL){
        printf("root, ");
    }
    else if(node_all[k].left == NIL){
        printf("leaf, ");
    }
    else printf("internal node, ");

    printf("[");
    for(i=0,data=node_all[k].left;data!=NIL;i++){
        printf("%d",data);
        data=node_all[data].right;
        if(data!=NIL){
            printf(", ");
        }
    }
    printf("]\n");
}


Measured memory_bytes: 6444
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(){
		
		long Inf = (long) 1e18;
		long[][] WF = new long[N][];
		for(int i=0;i<N;i++){
			WF[i] = new long[N];
			for(int j=0;j<N;j++){
				WF[i][j] = i == j ? 0 : Inf;
			}
		}
		for(int i=0;i<M;i++){
			WF[A[i]][B[i]] = WF[B[i]][A[i]] = C[i];
		}
		
		for(int k=0;k<N;k++){
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					WF[i][j] = Math.Min(WF[i][j],WF[i][k] + WF[k][j]);
				}
			}
		}
		
		long[][] dp = new long[R][];
		for(int i=0;i<R;i++){
			dp[i] = new long[1<<R];
			for(int j=0;j<(1<<R);j++) dp[i][j] = Inf;
		}
		
		for(int i=0;i<R;i++){
			dp[i][1<<i] = 0;
		}
		
		
		for(int i=0;i<(1<<R);i++){
			for(int j=0;j<R;j++){
				if(dp[j][i] == Inf) continue;
				for(int k=0;k<R;k++){
					dp[k][i | (1<<k)] = Math.Min(dp[k][i | (1<<k)],dp[j][i] + WF[RR[j]][RR[k]]);
				}
			}
		}
		
		long min = Inf;
		for(int i=0;i<R;i++){
			min = Math.Min(min,dp[i][(1<<R)-1]);
		}
		Console.WriteLine(min);
		
	}
	int N,M,R;
	int[] RR;
	int[] A,B;
	long[] C;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1]; R = d[2];
		RR = ria();for(int i=0;i<R;i++) RR[i]--;
		A = new int[M];
		B = new int[M];
		C = new long[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1; C[i] = d[2];
		}
	}

	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: 17420
#include<bits/stdc++.h>
#define ll long long
#define MOD = 1e9+7
#define rep(i,n) for(int i=0;i<(n);++i)
const double PI=3.14159265358979323846; 
const int INF = 1001001001;
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  rep(i,x+1){
    if(y%2==0){
      if(2*i + (x-i) == y/2){
        cout << "Yes" << endl; 
        return 0;
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CraneAndTurtle | diff CraneAndTurtle.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CraneAndTurtle.cpp && ./a.out

/*

 6/14/2020

 5:02-

 */

int x,y;

void solve() {
  REPE(a,x) {
    int b=x-a;
    if(2*a+4*b==y) {
      cout<<"Yes"<<endl;
      return;
    }
  }
  cout<<"No"<<endl;
}

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

  cin>>x>>y;
  solve();

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    map<int,int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        ++mp[a];
    }

    int ans = 0;
    for(int i=2;i<=1e5+1;++i){
        int tmp =0;
        tmp += mp[i] + mp[i-1] + mp[i-2];
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8244
#include <iostream> 
#include <sstream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <bitset> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
using namespace std;

int main(){
	long long N,a[200005];
	cin>>N;
	for(int i=1;i<=N;i++) {cin>>a[i];a[i]=a[i]+a[i-1];}
	sort(a+1,a+N);
	int i=1,j=N-1;
	for(;j-i>1;){
		int m=(i+j)/2;
		if(a[N]-2*a[m]>0) i=m;
		else j=m;
	}
	long long x=abs(a[N]-2*a[i]),y=abs(a[N]-2*a[j]);
	if(x<=y) cout<<x<<endl;
	else cout<<y<<endl;
return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
double x,y;
double a,b;
int main()
{
	cin>>x>>y;
	cin>>a>>b;
	if((a==x/2)&&(b==y/2))
     cout<<x*y/2<<" "<<1;  
	else
	{
		{
         cout<<x*y/2<<" "<<0;
	    }
	    
	}
}

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

int32_t main()
{

    int n; cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

string s, t;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>s>>t;
    int n = s.length(), ans = 0;
    for(int i=0; i<n; i++)
        if(s[i]!=t[i]) ans++;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
#define ll long long
using namespace std;

int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cout<<"ACL";
    cout<<endl;
}

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


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int max = 0;
    rep(i,N - 1) {
        int count = 0;
        vector<int> A(26,0);
        vector<int> B(26,0);
        string a = S.substr(0,i + 1);
        string b = S.substr(i + 1);
        rep(j,a.size()) {
            A[a[j] - 'a']++;
        }
        rep(k,b.size()) {
            B[b[k] - 'a']++;
        }
        rep(l,26) {
            if (A[l] > 0 && B[l] > 0) {
                count++;
            }
        }
        if (count > max) {
            max = count;
        }
    }
    cout << max << endl;
}



Measured memory_bytes: 3628
/******************************************************************************
 
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
 
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define ee endl
#define re return 
//Author Rahul Sannigrahi
 
int countdigit(int n)
{
    return floor(log10(n)+1);
}
 
int power(int x,int y)
{
    int res=1;
    
    while(y>0)
    {
       if(y&1)
       res=res*x;
       
       y=y>>1;
       x*=x;
    }
    re res;
}    
    
bool isprime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<n; i=i+6) 
        if ((n%i==0)|| n%(i+2)==0) 
           return false; 
  
    return true; 
} 
 
 
int solve()
{
 int x1,x2,x3,x4,x5;
 cin>>x1>>x2>>x3>>x4>>x5;
 if(x1==0)
 cout<<1<<ee;
 else
 if(x2==0)
 cout<<2<<ee;
 else
 if(x3==0)
 cout<<3<<ee;
 else
 if(x4==0)
 cout<<4<<ee;
 else
 if(x5==0)
 cout<<5<<ee;
 return 0;
}
 
int32_t main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0;
}
 


Measured memory_bytes: 3596
N = int(input())
A = list(map(int,input().split()))

ans = [0]*N
for i in range(N-1,-1,-1):
    a = 0
    for j in range(2,N//(i+1)+1):
        a += ans[j*(i+1)-1]
    if a%2!=A[i]:
        ans[i] = 1

print(sum(ans))
ans = [str(i+1) for i in range(N) if ans[i]==1]

print(' '.join(ans))

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

using namespace std ;

int main(){
	
	int n , m ;
	
	cin>>n ;		
	cin>>m ;		
	
	
	float comb_n , comb_m ;
	
	comb_n= (float)n * (((float)n/2) -0.5 ) ;
	comb_m = (float)m * (((float)m/2) -0.5 )  ;
	

	int ans = (int)comb_n + (int)comb_m ;
	cout<<ans ;
	
	return 0 ;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};
 int main(){
   ll n , m ; cin>> n>>m ;
   vector<P> A(m) ;
   rep(i,m){
     ll a , b; cin>>a>>b ;
     a-- ; b-- ;
     A[i].fi= a ;A[i].se= b ;
   }
   ll ans=0 ;
   rep(i,m){
    UnionFind uf(n) ;
    rep(j,m){
    if(j==i) continue ;
     uf.unite(A[j].fi,A[j].se) ;
    }
   bool ok= 1 ;
   rep(i,n-1){
     rep2(j,i+1,n-1){
       if(!uf.same(i,j)) ok= 0;
     }
   }

  if(!ok) ans++ ;
   }
   
   cout<<ans<<endl ;
   return 0;
  }

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool shop_sort(const pair<int, int> &a, const pair<int, int> &b){
  return a.first < b.first;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector <pair <int, int>> shop(N);
  for (int i = 0; i < N; i++) {
    cin >> shop[i].first >> shop[i].second;
  }
  sort(shop.begin(), shop.end());
  
  long long ans = 0;
  int energy = M;
  for (int i = 0; i < N; i++) {
    if (energy >= shop[i].second) {
      ans += (long long)shop[i].second * shop[i].first;
      energy -= shop[i].second;
    } else {
      ans += energy * (long long)shop[i].first;
      energy -= energy;
    }
    if (energy <= 0) break;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int k,a,b;
  cin>>k>>a>>b;
  
  bool ans=false;
  
  for (int i = a; i <=b; i++) { 
   int x=i;
    if(x%k==0)ans=true;
  }
  
  if(ans)cout<<"OK"<<endl;
  else{cout<<"NG"<<endl;}
}

Measured memory_bytes: 3596
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int H,W;
  int h,w;
  
  scanf("%d %d", &H, &W);
  scanf("%d %d", &h, &w);

  printf("%d", (H-h)*(W-w));

  return 0;
}


Measured memory_bytes: 1708