akhauriyash/Code-Regression huggingface dataset:
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (a, b, c): (isize, isize, isize);
    input!(a, b, c);
    if b - a == c - b {
        p("YES");
    } else {
        p("NO");
    }
}

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

using namespace std;

int main() {

    string S, T;
    cin >> S >> T;

    int length = S.length();

    int ans = 0;

    for(int i = 0; i < length; i++) {
        if(S[i] != T[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int c = 1; c < n; c++) {
  	int x = n - c;
    for (int i = 1; i * i <= x; i++) {
    	if (x % i == 0) {
        	if (x / i != i)
              ans++;
          	ans++;
        }
    }
  }
  
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
using namespace std;
int const maxn=300+5;
int temp,h,w,d,q,l,r;
struct xy{
    int x,y,w,vis;
}b[maxn*maxn];
int main(){
    scanf("%d%d%d",&h,&w,&d);
    for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++){
        scanf("%d",&temp);
        b[temp].x=i;
        b[temp].y=j;
    }
    for(int i=1;i<=d;i++)
    b[i].w=0;
    for(int i=1;i<=d;i++)
    for(int j=i+d;j<=w*h;j+=d)
    b[j].w=b[j-d].w+abs(b[j].x-b[j-d].x)+abs(b[j].y-b[j-d].y);
    scanf("%d",&q);
    while(q--){
        scanf("%d%d",&l,&r);
        if(l==r){
            printf("0\n");
            continue;
        }
        else printf("%d\n",b[r].w-b[l].w);
    }
}

Measured memory_bytes: 2432
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IMAX 2147483647
#define LMAX 9223372036854775807
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define PII pair<int,int>
#define PIII pair<int,PII>
#define VPII vector<PII>
#define VPIII vector<PIII>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define th se.se
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define rotateleft(vec,n) rotate(a.begin(),a.begin()+n,a.end())
#define rotateright(vec,n) rotate(a.rbegin(),a.rbegin()+n,a.rend())
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define countif(vec,condition_VAR) count_if(all(vec),[&](auto VAR){return condition_VAR;})
#define replaceif(vec,condition_VAR,n) replace_if(all(vec),[&](auto VAR){return condition_VAR;},n)
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_VAR) for_each(all(vec),[&](auto&VAR){VAR=calc_VAR;});
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return max(a,b);}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}
template<class C>int binarysearch(vector<C> vec,C n,char c){int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;while(right-left>1){int mid=left+(right-left)/2;bool OK=vec[mid]*getmin>=n*getmin;if(outleft==OK) left=mid;else right=mid;}return outleft?left:right;}


#define int int64_t
// #define double long double


// map
// segmenttree

signed main(){
  IOS;

  in(int,a,b);
  out((a-1)*(b-1));

  
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
#define foR for

// FHCまでにスタックオーバーフローの罠を解決する


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    ll n,d;
    cin>>n>>d;
    ll x,y;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        ll a = x*x+y*y;
        if(a <= d*d)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Airport Bus
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int ts[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", &ts[i]);
  sort(ts, ts + n);

  int bn = 0, bc = 0, ft = -1;
  for (int i = 0; i < n; i++) {
    int &ti = ts[i];

    if (ft > 0 && ft + k < ti) bn++, bc = 0, ft = -1;

    if (ft < 0) ft = ti;
    if (++bc >= c) bn++, bc = 0, ft = -1;
  }
  if (bc > 0) bn++;

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


Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll ans1=0,ans2=0;
ll h1[100001],h2[100001];
ll s[300000];
priority_queue<ll,vector<ll>,greater<ll>> sque;
priority_queue<ll> bque;
int main(void){
    cin>>n;
    for(int i=0;i<n*3;i++){
        cin>>s[i];
        if(0<=i&&i<n){
            sque.push(s[i]);
            ans1+=s[i];
        }
        if(2*n<=i&&i<3*n){
            bque.push(s[i]);
            ans2+=s[i];
        }
    }
    h1[0]=ans1,h2[n]=ans2;
    
    
    for(int i=2*n-1;i>=n;i--){
        if(bque.top()>s[i]){
            ans2+=s[i]-bque.top();
            bque.pop();
            bque.push(s[i]);
        }
        h2[i-n]=ans2;
    }
    
    
    
    
    for(int i=n;i<2*n;i++){
        if(sque.top()<s[i]){
            ans1+=s[i]-sque.top();
            sque.pop();
            sque.push(s[i]);
        }
        h1[i-n+1]=ans1;
    }
    
    ll ans=-(1LL<<60);
    for(int i=0;i<=n;i++){
        ans=max(ans,h1[i]-h2[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5876
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a%2&&b%2&&c%2){
    ll ans=a*b*c;
    ans=min(ans,a*b);
    ans=min(ans,c*b);
    ans=min(ans,a*c);
    cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }
}

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


int main(){
	string s;
	cin >> s;
	bool f1 = false,f2 = false,f3 = false;
	for(int i=0;i<s.size();++i){
		if(s[i] == 'a') f1 = true;
		if(s[i] == 'b') f2 = true;
		if(s[i] == 'c') f3 = true;
		
	}
	
	if(f1 && f2 && f3) cout << "Yes" <<endl;
	else cout << "No" << endl;
	
	return 0;
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int h, w; cin >> h >> w;
    string s[h+2] = {};
    for (int i = 0; i < w+2; i++)
    {
        s[0] += '.';
        s[h+1] += '.';
    }

    for (int i = 1; i <= h; i++)
    {
        string t;
        cin >> t;
        s[i] = '.' + t + '.';
    }

    int res[h+2][w+2] = {};
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if(s[i][j] == '#'){
                for (int k = i-1; k <= i+1; k++)
                {
                    for (int l = j-1; l <= j+1; l++)
                    {
                        res[k][l]++;
                    }
                }
            }
        }
    }

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if(s[i][j] == '#') cout << '#';
            else cout << res[i][j];
        }
        cout << endl;
    }

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 300050
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
int cal(int a){
    a*=(a-1);
    a/=2;
    return a;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    cout<< cal(n) + cal(m);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    cout<<(N+110)/111*111<<endl;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3

def main():
    n = int(input())
    v = list(map(int, input().split()))

    ct = []
    ct.append([0] * 101010)
    ct.append([0] * 101010)

    for i in range(n):
        ct[i % 2][v[i]] += 1

    m0 = max(ct[0])
    m1 = max(ct[1])
    i0 = ct[0].index(m0)
    i1 = ct[1].index(m1)

    r = 0
    if i0 != i1:
        r = n - m0 - m1
    else:
        ct[0][i0] = 0
        ct[1][i1] = 0
        m2 = max(ct[0])
        m3 = max(ct[1])
        r = n - m0 - max(m2, m3)


    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14268
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int h[10];
    for (int i = 0; i < 10; i++) {
        cin >> h[i];
    }

    sort(h, h + 10);
    cout << h[9] << endl << h[8] << endl << h[7] << endl;

    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <memory.h>
#include <string>
#include <fstream>
#include <queue>
#include <random>
#include <ctime>
#include <array>
#include <cassert>

using namespace std;
using Storage = std::vector<std::string>;

template<bool REV, bool END>
void GetStrings(
    int id,
    std::string &s1,
    std::string &s2,
    const std::string &s,
    Storage &storage) {
    if ((id == s.size() && END) || (!END && id == s.size() / 2)) {


        if (REV) {
            std::string new_string = s1 + s2;

            std::reverse(new_string.begin() + s1.size(), new_string.end());
            new_string += to_string(s2.size());
            storage.emplace_back(new_string);


        } else {
            std::string new_string = s2 + s1;

            std::reverse(new_string.begin(), new_string.begin() + s2.size());
            new_string += to_string(s1.size());
            storage.emplace_back(new_string);

        }
        return;
    }
    s1.push_back(s[id]);
    GetStrings<REV, END>(id + 1, s1, s2, s, storage);
    s1.pop_back();

    s2.push_back(s[id]);
    GetStrings<REV, END>(id + 1, s1, s2, s, storage);
    s2.pop_back();
}

using FinalStorage = std::vector<pair<std::string, int>>;

FinalStorage CompressStorage(Storage& st) {
    std::sort(st.begin(), st.end());
    FinalStorage fs{{st[0], 1}};
    for (int i = 1; i < st.size(); i++) {
        if (st[i - 1] == st[i]) {
            fs.back().second++;
        } else {
            fs.emplace_back(st[i], 1);
        }
    }
    return fs;
}

int main() {
    int n;
    std::string s;
    cin >> n >> s;
    std::string s1;
    std::string s2;
    Storage left;
    Storage right;

    GetStrings<true, false>(0, s1, s2, s, left);
    GetStrings<false, true>(n, s1, s2, s, right);
    auto left_f = CompressStorage(left);
    auto right_f = CompressStorage(right);

    int left_pointer = 0;
    int right_pointer = 0;
    int64_t ans = 0;
    while (left_pointer < left_f.size() && right_pointer < right_f.size()) {
        if (left_f[left_pointer].first == right_f[right_pointer].first) {
            ans += left_f[left_pointer].second * 1ll * right_f[right_pointer].second;
            left_pointer++;
            right_pointer++;
            continue;
        }
        if (left_f[left_pointer].first < right_f[right_pointer].first) {
            left_pointer++;
        } else {
            right_pointer++;
        }
    }
    std::cout << ans << std::endl;

}

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

  
int main() {
	int N;
  cin >> N;
  vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
  for(int i=0;i<N;i++){
   cin >> A[i]; 
  }
  for(int i=0;i<N;i++){
   cin >> B[i]; 
  }
  for(int i=0;i<N-1;i++){
   cin >> C[i]; 
  }
 int ans =0;
  for(int i=0;i<N;i++){
    ans += B[A[i]-1];
	if(A[i]+ 1 == A[i+1]) ans += C[A[i]-1];
  }
  cout << ans <<endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::cout << (n - 1) * n / 2 << std::endl;
  return 0;
}


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

int main() {
  vector<int> X(5);
  vector<int> Y(5);
  int tmp =0;
  int cnt =0;
  for(int i=0; i<5; ++i){
    cin >> X[i];
    Y[i] = X[i]%10;
    if(Y[i]==0){
      ++cnt;
      Y[i] = 9;
      tmp += X[i];
    }else tmp += (X[i]/10)*10 +10;
  }
  sort(Y.begin(), Y.end());
  tmp = tmp -10 + Y[0];
  if(cnt ==5) tmp = tmp +1;
  cout << tmp << endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

double dp[3000][3000] = {0};

int main(){
    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, n){
        cin >> p[i];
    }
    dp[0][0] = 1;
    REP(i, 1, n + 1){
        rep(j, n + 1){
            if(j >= 1){
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1.0 - p[i - 1]);
            }else{
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i - 1]);
            }
        }
    }
    double ans = 0;
    REP(j, n / 2 + 1, n + 1){
        ans += dp[n][j];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70528
#include <iostream>

using namespace std;
int main(void){

  int A, B;
  cin >> A >> B;
  
  int ans = A+B;
  int sub = A-B;
  
  if(sub > ans){
    ans = A-B;
    sub = A+B;
  }
  
  if(A*B > ans){
  ans = A*B;
  }
  
  cout << ans << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int x = sc.nextInt();
            int y = sc.nextInt();
			
			if ( x == 0 && y == 0)
				break;
			
			int small = 0;
			int large = 0;
			
			if ( x < y || x == y ) {
				small = x;
				large = y;
			} else if ( x > y ) {
				small = y;
				large = x;
			}
			
            System.out.println(String.format("%d %d", small, large));
        }

	}
}

Measured memory_bytes: 33248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REPF(i, a, n) for (int i = a; i < (n); i++)
#define REP(i, n) REPF(i, 0, n)
#define FORE(x, s) for (auto& x : s)
#define ALL(x) begin(x),end(x)
using pii = pair<int, int>;
template<class T> bool chmin(T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 1001001001001001001LL;

int ans = INF;
pii ans_edge;
void update(int x, int a, int b) {
    if (ans > x) {
        ans = x;
        ans_edge = {min(a, b), max(a, b)};
    } else if (ans == x) {
        chmin(ans_edge, {min(a, b), max(a, b)});
    }
}
int total;
vector<vector<pii>> g;
vector<bool> used_v;
map<pii, bool> used_e;
vector<int> ord, lowlink, W;
int k = 0;
int dfs(int v) {
    used_v[v] = true;
    ord[v] = lowlink[v] = k++;
    for (auto& e : g[v]) {
        int w = e.first;
        int c = e.second;
        if (!used_v[w]) {
            used_e[{v, w}] = true;
            W[v] += dfs(w) + c;
            lowlink[v] = min(lowlink[v], lowlink[w]);  // lowlink[w]は計算済み
        } else if (!used_e[{w, v}]) {
            // v --> w は後退辺
            W[w] += c;
            lowlink[v] = min(lowlink[v], ord[w]);  // 後退辺を辿った先のordで更新(1度までしか後退辺を辿ることはできない)
        }
    }
    return W[v];
}

signed main() {
    ans_edge = {INF, INF};

    int N, M;
    cin >> N >> M;
    g = vector<vector<pii>>(N);
    used_v = vector<bool>(N, false);
    ord = lowlink = W = vector<int>(N, 0);

    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
        total += c;
    }
    dfs(0);

    vector<bool> vis(N, false);
    function<void(int)> dfs2 = [&](int v) {
        vis[v] = true;
        FORE(e, g[v]) {
            int w = e.first;
            int c = e.second;

            if (ord[v] < lowlink[w]) {
                int A = W[w];
                int B = total - A - c;
                update(abs(A - B), v, w);
            } else {
                update(total - c, v, w);
            }

            if (vis[w]) continue;
            dfs2(w);
        }
    };
    dfs2(0);

    cout << ans_edge.first + 1 << " " << ans_edge.second + 1 << endl;
    return 0;
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define N 500001
#define M 500001
using namespace std;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int inf = 1000000001;

piii pos[N]; int x[N], y[N];

vector<int> g[N]; int nc;
void adde(int u, int v) {
    //cout << u << "->" << v << endl;
    g[u].push_back(v);
}


int id1[1<<16], id2[1<<16];
void build(int p, int lb, int rb) {
    id1[p] = ++nc; g[nc].clear();
    id2[p] = ++nc; g[nc].clear();
    if (lb + 1 == rb) {
        adde(id1[p], pos[lb].second.second);
        adde(pos[lb].second.first, id2[p]);
    }
    else {
        int mid = (lb + rb) >> 1;
        build(p << 1, lb, mid);
        build(p << 1 | 1, mid, rb);
        adde(id1[p], id1[p << 1]);
        adde(id1[p], id1[p << 1 | 1]);
        adde(id2[p << 1], id2[p]);
        adde(id2[p << 1 | 1], id2[p]);
    }
}

int opp(int x) { return x & 1 ? x + 1 : x - 1; }

void adde(int l, int r, int x, int p, int lb, int rb) {
    if (l >= r) return;
    if (l <= lb && rb <= r) {
        adde(x, id1[p]);
        adde(id2[p], opp(x));
    }
    else {
        int mid = (lb + rb) >> 1;
        if (l < mid) adde(l, r, x, p << 1, lb, mid);
        if (r > mid) adde(l, r, x, p << 1 | 1, mid, rb);
    }
}

int dfn[M], low[M], bel[M], dfc, scc;
bool inst[M]; int scs[M], *sct = scs;
void scc_clr(int n) { scc = 0; fill(dfn + 1, dfn + n + 1, 0); }
int dfs_scc(int u) {
    *sct++ = u; inst[u] = 1;
    dfn[u] = low[u] = ++dfc;
    for (int v : g[u]) {
        if (!dfn[v]) low[u] = min(low[u], dfs_scc(v));
        else if (inst[v]) low[u] = min(low[u], low[v]);
    }
    if (dfn[u] == low[u])
        for (++scc; *sct != u; --sct)
            bel[sct[-1]] = scc, inst[sct[-1]] = 0;
    return low[u];
}

bool check(int d, int n) {
    int m = 2 * n;
    nc = m;
    for (int i = 1; i <= m; ++i)
        g[i].clear();
    build(1, 1, m + 1);
    //cout << string(79, '-') << endl;
    for (int i = 1; i <= m; ++i) {
        int lx = pos[i].first - d, rx = pos[i].first + d;
        int l = upper_bound(pos + 1, pos + m + 1, piii(lx, pii(inf,inf))) - pos;
        int r = lower_bound(pos + 1, pos + m + 1, piii(rx, pii(0,0))) - pos;
        int x = pos[i].second.first;
        adde(l, i, x, 1, 1, m + 1);
        adde(i + 1, r, x, 1, 1, m + 1);
    }
    //cout << string(79, '=') << endl;
    scc_clr(nc);
    for (int i = 1; i <= nc; ++i)
        if (!dfn[i]) dfs_scc(i);

    for (int i = 1; i <= m; ++i) {
        if (i & 1) {
            if (bel[i] == bel[i + 1])
                return false;
        }
    }
    return true;
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0);
//#ifndef ONLINE_JUDGE
//    ifstream cin("1.in");
//#endif // ONLINE_JUDGE

    int n; cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        pos[i * 2 - 1] = { x[i], pii(i * 2 - 1, i * 2) };
        pos[i * 2] = { y[i], pii(i * 2, i * 2 - 1) };
    }

    sort(pos + 1, pos + 2 * n + 1);

    int l = 1, r = inf;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (!check(mid, n)) r = mid - 1;
        else l = mid + 1;
    }

    cout << r << endl;

	return 0;
}

Measured memory_bytes: 37768
from sys import stdin
from collections import deque

# not AC
# def get_result(data):
#     S, Q = data[0][0], int(data[1][0])
#     for i in range(Q):
#         if data[i+2][0] == '1':
#             S = S[::-1]
#         else:
#             F, C = data[i+2][1], data[i+2][2]
#             if F == '1':
#                 S = C + S
#             else:
#                 S = S + C
#     return S


def get_result(data):
    S, Q = data[0][0], int(data[1][0])
    # 文字列と反転状況を別で判断する
    ans = deque(S)
    cnt = 0
    for i in range(Q):
        if data[i+2][0] == '1':
            cnt += 1
        else:
            F, C = data[i+2][1], data[i+2][2]
            if F == '1':
                if cnt % 2 == 0:
                    ans.appendleft(C)
                else:
                    ans.append(C)
            else:
                if cnt % 2 == 0:
                    ans.append(C)
                else:
                    ans.appendleft(C)

    if cnt % 2 == 1:
        ans = ''.join(reversed(ans))
    else:
        ans = ''.join(ans)

    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(str, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 57324
# 参考: https://drken1215.hatenablog.com/entry/2020/03/08/020200
# 注: (mod p(素数)上で) aとpが互いに素のとき、aの逆元とpが互いに素になることは容易に証明できる（aの逆元 = a^(p-2)なので）

from collections import Counter
n, p = map(int, input().split())
s = input()

if p == 2 or p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
    print(ans)
    exit()

num = 0
a = [0] * (n+1)
for i in reversed(range(n)):
    j = n-1 - i
    num += int(s[i]) * pow(10, j, p) % p
    num %= p
    a[j+1] = num

ctr = Counter(a)
ans = 0
for v in ctr.values():
    ans += v * (v-1) // 2

print(ans)




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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, a, b, labor=0;
  cin >> n;
  map<ll, ll> m;
  forll(i, 0, n){
	cin >> a >> b;
	m[b] += a;
  }
  for(auto i=m.begin(); i!=m.end(); i++){
	labor += i->second;
	if (labor > i->first){
	  cout << "No" << endl;
	  return 0;
	}
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 12800
#include<iostream>
#include <algorithm>
using namespace std;
int H, W, ans, cnt;
int a[10][10000];
int main() {
	while (cin >> H >> W&&H&&W) {
		for (int i = 0; i<H; i++)
			for (int j = 0; j<W; j++)
				cin >> a[i][j];
		ans = 0;
		for (int S = 0; S<(1 << H); S++) {
			int cnt = 0;
			for (int j = 0; j<W; j++) {
				int c = 0;
				for (int i = 0; i<H; i++) {
					if ((S >> i) & 1)c += 1 - a[i][j];
					else c += a[i][j];
				}
				cnt += max(c, H - c);
			}
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
}


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

ll mod = 2019;

int main(){
  ll l, r;  cin >> l >> r;
  r = min(r, l+2019*2);
  ll ans = 2018;
  for(ll i = l; i <= r; i++)
    for(ll j = i+1; j <= r; j++){
    ans = min(ans, i*j%mod);
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    int n,k,i;
    cin >> n >> k;
    vector<int> h(n);
    for(i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    int ans = 1e9;
    for(int i=0; i<=h.size()-k; i++){
        ans = min(h[i+k-1]-h[i],ans);

    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3744
s = input()
bitlst = []
for i in range(2**3):
    res = []
    for j in range(3):
        if i>>j &1:
            res.append("+")
        else:
            res.append("-")
    bitlst.append(res)

for i in bitlst:
    ans = int(s[0])
    for j in range(3):
        if i[j] == "+":
            ans +=  int(s[j+1])
        else:
            ans -= int(s[j+1])

    if ans == 7:
        print(s[0]+i[0]+s[1]+i[1]+s[2]+i[2]+s[3]+"=7")
        exit()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	map<string, int> cnt;

	w(t)
	{
		string s; cin >> s;
		cnt[s]++;
	}

	cout << "AC x " << cnt["AC"] << '\n';
	cout << "WA x " << cnt["WA"] << '\n';
	cout << "TLE x " << cnt["TLE"] << '\n';
	cout << "RE x " << cnt["RE"] << '\n';
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> H(N);
    map<int,int> O;
    for (int i=0;i<N;i++) {
        cin >> H[i];
        O[i+1]=H[i];
    }
    int A,B;
    for (int i=0;i<M;i++) {
        cin >> A >> B;
        if(H[A-1] > H[B-1]) {
            if (O.count(B)) {
                O.erase(B);
            }
        }
        else if (H[A-1] < H[B-1]) {
            if (O.count(A)) {
                O.erase(A);
            }
        }
        else {
            if (O.count(B)) {
                O.erase(B);
            }
            if (O.count(A)) {
                O.erase(A);
            }
        }
    }
    cout << O.size() << endl;
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define endl '\n'
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define ff first
#define ss second
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;



string solve() {
	int x, y;
	cin >> x >> y;
	if (y & 1) return "No";
	int b = y / 2 - x;
	int a = 2 * x - y / 2;
	if (a >= 0 and b >= 0) return "Yes";
	else return "No";
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
bool graph[50][50];
int N,M;
bool visited[50];

void dfs(int n) {
  visited[n] = true;
  rep(i,N) {
    if(graph[n][i] == false) continue;
    if(visited[i] == true) continue;
    dfs(i);
  }
}

int main() {
  
  cin >> N >> M;
  int a[M],b[M];
  rep(i,M) {
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }
  int ans = 0;

  rep(i,M) {
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;
    rep2(j,N) {
      visited[j] = false;
    }
    dfs(0);

    bool bridge = false;
    rep2(j,N) {
      if(visited[j] == false) bridge = true;
    }
    if(bridge) ans++;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    for (auto& el : h) {
        cin >> el;
    }
    ll l = 0, r = 0;
    for (auto el : h) {
        r += (el + b - 1) / b;
    }
    while (l < r) {
        auto m = l + (r - l) / 2;
        auto bb = m * b;
        ll cnt = 0;
        for (auto el : h) {
            cnt += (max(0ll, el - bb) + a - b - 1) / (a - b);
        }
        if (cnt <= m) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    cout << l << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()] 
#a = [int(input()) for _ in range(n)]

a = sorted(a, reverse = True)
for i in range(n - 1):
    if a[i] == a[i + 1]:
        ans1 = a[i]
        tmp1 = i + 1
        break
    if i == n - 2:
        ans1 = 0
if ans1 == 0:
    print(0)
    exit()
for i in range(tmp1+1, n-1):
    if a[i] == a[i + 1]:
        ans2 = a[i]
        break
    if i == n - 2:
        ans2 = 0
print(ans1 * ans2)


Measured memory_bytes: 14224
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU

main = putStrLn . unlines . map (unwords.map show) .  solve . map read . words =<< getContents

solve (h:w:n:xs) = zs where
    ys = concat $ zipWith replicate xs [1..]
    zs = f ys 0
    f [] _ = []
    f ss i = vv : f ww (i+1) where
        (uu, ww) = splitAt w ss
        vv = if mod i 2 == 0 then uu else reverse uu

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n, i; cin >> n >>i;
    cout << n-i+1 << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
H=list(map(int,input().split()))

dp=[float('inf') for _ in range(n)]
dp[0]=0
for i in range(n):
  for j in range(1,k+1):
    if i+j<len(dp):
      dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
print(dp[-1])

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

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {
	
	int n;
	cin >> n;
	vector<int>y;
	long long int s = 0;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		s += x;
		y.push_back(x);
	}
	int r;
	cin >> r;
	while (r--) {
		int a, b;
		cin >> a >> b;
		cout << s - y[a - 1] + b << endl;
	}
	

	return 0;

}




Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }
const long long INF = 1LL << 60;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];

    rep(i,n-1){
        t[i+1] = lcm(t[i],t[i+1]);
    }
    cout << t[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector> 
using namespace std;
typedef long long LL;
const LL N = 998244353;

LL d1[1000005],d2[1000005],f[1000005],g[1000005];
LL mu[1000005],npr[1000005];

LL kpw(LL x,LL y){
	LL ans = 1,tmp = x;
	while(y){
		if(y & 1) ans = (ans * tmp) % N;
		tmp = (tmp * tmp) % N; y >>= 1;
	} return ans;
}

void sieve(){
	for(LL i = 1;i <= 1000000;i ++) mu[i] = 1;
	for(LL i = 2;i <= 1000000;i ++){
		if(npr[i]) continue;
		mu[i] = -1;
		for(LL j = i + i;j <= 1000000;j += i){
			if((j / i) % i == 0) mu[j] = 0;
			mu[j] *= -1; npr[j] = 1;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	LL n,w,ans = 0;
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> w;
		for(LL j = 1;j * j <= w;j ++){
			if(!(w % j)){
				d1[j] += w; d1[j] %= N; d2[j] += w * w % N; d2[j] %= N;
				if(j * j != w){ d1[w / j] += w; d1[w / j] %= N; d2[w / j] += w * w % N; d2[w / j] %= N; }
			}
		}
	}
	for(LL i = 1;i <= 1000000;i ++) f[i] = ((d1[i] * d1[i] - d2[i]) % N + N) % N;
	sieve();
	for(LL i = 1;i <= 1000000;i ++){
		g[i] = 0;
		for(LL j = i;j <= 1000000;j += i){
			g[i] += mu[j / i] * f[j];
			g[i] = (g[i] % N + N) % N;
		}
		ans += g[i] * kpw(i,N - 2) % N; ans %= N;
	}
	ans = (ans * kpw(2LL,N - 2)) % N;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 50056
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
  int N,a=0,b=0;
  scanf("%d",&N);
  
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(int i=0; i<N; i++){
      if(A[i]%2==0){
        a++;
      }
  }
  
  for(int i=0;i<N;i++){
    if(A[i]%2==0){
      if(A[i]%6==0 || A[i]%10==0){
        b++;
      }
    }
  }
  if(a==b){
    printf("APPROVED\n");
  }
  else{
    printf("DENIED\n");
  }
  return 0;
}
      

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int count=0,l,*S;
 
void insertionSort(int A[], int n, int m){
int i,v,j;
  for(i=m;i<n;i++){
    v=A[i];
    j=i-m;
    while(j>=0&&A[j]>v){
      A[j+m]=A[j];
      j-=m;
      count++;
    }
    A[j+m]=v;
  }
}
 
void Sort(int A[],int n){
  int i=0,a;
 
  S=(int *)malloc(n * sizeof(int));
 
  for(a=1; ; ){
    if(a>n) break;
    S[i]=a;
    i++;
    a=3*a+1;
  }
  l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,S[i]);
  }
}
 
 
 
int main(){
  int i,A[N],n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
 
  Sort(A,n);
 
  printf("%d\n",l);
 
  for(i=l-1;i>=0;i--){
    printf("%d",S[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  for(i=0;i<n;i++)printf("%d\n",A[i]);
 
  free(S);
  return 0;
}



Measured memory_bytes: 5644
n, x = map(int, input().split())

ms = []
for i in range(n):
    exec("ms.append(int({}))".format(input()))

donuts = len(ms)
remaining_flour = x - sum(ms) 
while remaining_flour >= min(ms):
    remaining_flour -= min(ms)
    donuts += 1

print(donuts)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n, x;
	int i;
	int count = 0;
	int* L;
	int  L2;

	scanf("%d", &n);
	scanf("%d", &x);
	
	L = (int*)malloc(sizeof(int) * n);

	L2= 0;

	for(i = 0; i < n; i++){
		scanf("%d",&L[i]);
	}

	for(i = 0; i < n; i++){
		L2 += L[i];
		if(L2 <= x){
			count++;
		}
	}	
	
	printf("%d", count+1);
	
	free(L);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
  	cout << "Yes\n";
  }else {
  	cout << "No\n";
  }
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

i64 gcd(i64 a, i64 b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<i64> A(N);
    rep(i,0,N){
        cin >> A[i];
    }
    
    i64 ans=A[0];
    rep(i,1,N){
        ans=gcd(ans,A[i]);
    }
    
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);
    vi a(n), b(n), c(n);
    vector<vector<int>> prizes(n, vector<int>(3, -1));
    f(i, 0, n){
        f(j, 0, 3){
            s(prizes[i][j]);
        }
    }
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            int idx1 = (j + 1)%3;
            int idx2 = (j + 2)%3;
            dp[i + 1][j] = max(dp[i][idx1] + prizes[i][idx1], dp[i][idx2] + prizes[i][idx2]);
        }
    }

    int maxx = *max_element(dp[n].begin(), dp[n].end());
    p(maxx);
    return;
}

class CVacation {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CVacation solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 16404
S=input()
d=dict()

for s in S:
    d[s]=d.get(s,0)+1

boolean=True
if len(d.values())==2:
    for i in d.values():
        if i!=2:
            boolean=False
            break
        else:
            continue
else:
    boolean=False

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

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=2050;
//ここまでテンプレ
int main() {
	int N;
	cin>>N;
	int mini=INF;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		int cou=0;
		while(a%2==0){
			a/=2;
			cou++;
		}
		mini=min(mini,cou);
	}
	cout<<mini<<endl;
    return 0;
}

Measured memory_bytes: 256