akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Numerics;
 
class Program
{
    static void Main()
    {
        const int divisor = 1000000007;
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ')
                                .Select(elem => int.Parse(elem))
                                .OrderByDescending(elem => elem)
                                .ToArray();
        bool flag = true;
        int num = n - 1;
        for (int i = 0; i < A.Length; i++)
        {
            if(A[i] != num) {flag = false; break;}
            if(i % 2 != 0) num -= 2;
        }
        var numOfPattern = flag ? BigInteger.ModPow(2, n / 2, divisor) : 0;
        Console.WriteLine(numOfPattern);
    }
}


Measured memory_bytes: 13272
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    int a,b;
    cin >> a >> b;
    if(a < b) cout << "a < b" << endl;
    else if(a > b)cout << "a > b" << endl;
    else if(a == b)cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=998244353;
const int maxn=500000;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
int n,m;
long long fir[maxn+5],inv[maxn+5];
long long C(int n,int m)
{
	if(n<m) return 0;
	return fir[n]*inv[m]%mod*inv[n-m]%mod;
}
void pre()
{
	fir[0]=1;
	for(int i=1;i<=maxn;i++) fir[i]=fir[i-1]*i%mod;
	inv[maxn]=ksm(fir[maxn],mod-2);
	for(int i=maxn-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
int main()
{
	pre();
	n=read(),m=read();
	long long ans=0;
	for(int i=0;i<=min(n,m);i++)
	{
		if(i&1) ans=(ans-C(n,i)*C(m,i)%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod*fir[i]%mod)%mod;
		else ans=(ans+C(n,i)*C(m,i)%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod*fir[i]%mod)%mod;
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 11556
#include <cassert>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
using namespace std;

const int M = 1000000007;

long long bruteforce(long long *A, long long *S, int N) {
    vector<long long> tmp[2];
    long long ans = 0;
    for (int i = 0; i < 1<<N; i++) {
        for (int j = 0; j < N; j++)
            if ((i >> j) & 1) tmp[0].push_back(S[j+1]);
            else tmp[1].push_back(S[j+1]);
        bool ok = true;
        for (int t = 0; ok && t < 2; t++)
            for (int j = 0; ok && j < int(tmp[t].size()) - 1; j++) {
                if (tmp[t][j+1] - tmp[t][j] < A[t]) { ok = false; break; }
            }
        if (ok) ans++;
        tmp[0].clear();
        tmp[1].clear();
    }
    return ans;
}

int main() {
    int N; cin >> N;
    long long A[2]; cin >> A[0] >> A[1];
    long long s[N+1];
    s[0] = -(1LL<<61);
    for (int i = 0; i < N; i++) cin >> s[i+1];

    long long dp[2][N+1], sum[2][N+1];
    dp[0][0] = dp[1][0] = 1;
    sum[0][0] = sum[1][0] = 1;
    int lb[2] = {};
    for (int i = 2; i <= N; i++) {
        for (int t = 0; t < 2; t++) {
            const int j = upper_bound(s, s+i-1, s[i] - A[t]) - s;
            if (lb[1-t] <= j) {
                dp[t][i-1] = sum[1-t][j-1];
                if (lb[1-t] > 0) dp[t][i-1] -= sum[1-t][lb[1-t]-1];
            } else
                dp[t][i-1] = 0;
            sum[t][i-1] = (sum[t][i-2] + dp[t][i-1]) % M;
        }
        for (int t = 0; t < 2; t++)
            if (s[i] - s[i-1] < A[t]) lb[t] = i-1;

        // cerr << i << " " << dp[0][i-1] << ' ' << dp[1][i-1] << ' ' << lb[0] << " " << lb[1] << endl;
    }

    long long ans = 0;
    for (int t = 0; t < 2; t++)
        ans += accumulate(dp[t] + lb[t], dp[t] + N, 0LL);
    cout << (ans % M + M) % M << endl;

    // long long ans2 = bruteforce(A, s, N);
    // if (ans != ans2) {
    //     cout << "wrong answer on:\n"
    //          << N << " " << A[0] << " " << A[1] << endl;
    //     for (int i = 1; i <= N; i++) cout << s[i] << " ";
    //     cout << endl;
    //     cout << "expect " << ans2 << ", got " << ans << endl;
    // }
}


Measured memory_bytes: 7064
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.string;

void main() {
    auto input = readln.split.to!(ulong[]);
    auto n = input[0];
    auto x = input[1];
    auto xi = readln.split.to!(ulong[]);
    xi ~= x;
    xi.sort();
    ulong[] d = [];
    foreach(i; 0..n)
        d ~= xi[i + 1] - xi[i];
    auto ans = d[0];
    foreach(i; 1..n)
        ans = gcd(ans, d[i]);
    ans.writeln;
}


Measured memory_bytes: 7348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e5+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


void solve(){
    int h1, h2 , m1 ,m2 , k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = (h2 - h1-1)*60 - k + m2 + 60-m1;
    cout << ans << endl;
}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

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

ll gcd( ll a , ll b ) { return ( b ?  gcd(b,a%b) : a ) ; }
ll lcd( ll a , ll b ) { return ( a/gcd(a,b)*b ) ; }
ll f(ll x, ll c , ll d ){
  ll ans = x ;
  ans -= x/c ;
  ans -= x/d ;
  ans += x/lcd(c,d) ;
  return ans ;
}

int main() {
  ll a , b ;
  ll c , d ;
  cin >> a >> b ; 
  cin >> c >> d ;
  //cout << lcd(c,d) << endl ;
  cout << f(b,c,d) - f(a-1,c,d) << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        double r = l / 3.0;

        cout << fixed << setprecision(10) << r * r * r << endl;

        return 0;
}


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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
    
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (((i < B) && (j < A)) || ((i >= B) && (j >= A))) {
        cout << 0;
      } else {
        cout << 1;
      }
    }
    cout << endl;
  }

}


Measured memory_bytes: 1280
n_book, n_algo, target = map(int,input().split())
cost_ls = [0] * n_book
up_ls = [0] * n_book
for i in range(n_book):
    ls = list(map(int, input().split()))
    cost_ls[i] = ls[0]
    up_ls[i] = ls[1:]

n_pattern = 2 ** n_book
min_cost = float('inf')
for pattern in range(n_pattern):
    cost = 0
    score_ls = [0] * n_algo
    can = True
    for ind_book in range(n_book):
        if (pattern >> ind_book) & 1:
            cost += cost_ls[ind_book]
            for ind_algo in range(n_algo):
                score_ls[ind_algo] += up_ls[ind_book][ind_algo]
    for ind_algo in range(n_algo):
        if score_ls[ind_algo] < target:
            can = False
    if can:
        min_cost = min(min_cost, cost)
if min_cost == float('inf'):
    print(-1)
else:
    print(min_cost)




Measured memory_bytes: 9236
#include <stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    printf(x+r>W||x-r<0||y+r>H||y-r<0?"No\n":"Yes\n");
    return 0;
}

Measured memory_bytes: 584
#include <iostream>

using namespace std;

int main()
{
	int h = 0, w = 0;
	while(true)
	{
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		for(int y = 0; y < h; y++)
		{
			for(int x = 0; x < w; x++)
			{
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#define rep(i,n) for (long long i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> k(N);
    vector<vector<int> > s(M);
    rep(i,M){
        cin>>k[i];
        rep(j,k[i]){
            int x;
            cin>>x;
            s[i].push_back(x);
        }
    }
    vector<int> p(M);
    rep(i,M) cin>>p[i];
    int ans=0;
    rep(i,1<<N){
        vector<int> v;
        rep(j,N){
            if ((i>>j)&1) v.push_back(j);
        }
        bool f=true;
        rep(kk,M){
            int fl=0;
            rep(l,k[kk]){
                rep(m,v.size()){
                    if (s[kk][l]==v[m]+1) fl+=1;
                }
            }
            if (fl%2!=p[kk]) f=false;
        }
        if (f) ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $count_list = [];
  for($i=1; $i<=$n; $i++){
    $count = 0;
    $q = $i;
    while($q > 0 && $q%2 == 0){
      $p = $q/2;
      $count++;
      $q = $p;
    }
    $count_list[$i] = $count;
  }
  arsort($count_list);
  echo key($count_list)."\n";
  
  

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

int main() {
  ll a; double b;
  cin >> a >> b;
  ll ans;
  ll ib = b * 100 + 0.5;
  a *= ib;
  a /= 100;

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


Measured memory_bytes: 3744
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let mut ps: Vec<i64> = sc.vec(n);
    ps.sort();
    put!(ps[0..k].iter().sum::<i64>());
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2248
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        int N = in.nextInt();
        BigInteger a = new BigInteger("2");
        BigInteger b = BigInteger.ONE;
        BigInteger temp;
        if (N == 1) {
            System.out.println(1);
        } else {
            for (int i = 2; i <= N; i++) {
                temp = b;
                b = a.add(b);
                a = temp;
            }
            System.out.println(b.toString());
        }
   }


    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}

Measured memory_bytes: 22996
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int N;
  std::cin >> N;

  std::vector<std::string> S(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> S[i];
  }

  std::map<std::string, int> mp;
  for (auto &v : S) {
    mp[v] += 1;
  }
  // mp["abc"] = 123;
  // mp["xyz"] = 321;

  int max_count = 0;
  for (auto kv : mp) {
    if (max_count < kv.second) {
      max_count = kv.second;
    }
  }
    // std::cout << kv.first << ": " << kv.second << std::endl;

  std::vector<std::string> res;
  for (auto kv : mp) {
    if (kv.second == max_count) {
      res.push_back(kv.first);
    }
  }

  // std::cout << res << std::endl;

  std::sort(res.begin(), res.end());
  for (auto &v : res) {
    std::cout << v << std::endl;
  }

  return 0;
}


Measured memory_bytes: 28404
#include<stdio.h>
int main()
{
	int a,b,c,i,x,y;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		for(i=a;i>0;i--){
			if(a%i==0&&b%i==0){
				x=i;
				break ;
			}
		}
	}
	else {
		for(i=b;i>0;i--){
			if(b%i==0&&a%i==0){
				x=i;
				break ;
			}
		}
	}
	y=(a*b)/(x*x);
	printf("%d\n",y*c);
	return 0;
}


Measured memory_bytes: 2756
/*
      author : nishi5451
      created: 11.08.2020 21:09:47
*/

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


int main(){
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7)
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<pair<ll,ll>> q;
    rep(i,n) {
        ll a;
        cin >> a;
        q.emplace(a,1);
    }
    rep(i,m) {
        ll b, c;
        cin >> b >> c;
        q.emplace(c,b);
    }
    ll ans = 0;
    rep(i,n) {
        auto p = q.top();
        q.pop();
        ans += p.first;
        if (p.second > 1) {
            q.emplace(p.first, p.second-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7408
#include<bits/stdc++.h>
using namespace std;int N,M,L,R,C,A,i,j;string S;char Q[4];main(){scanf("%d",&N);scanf("%d",&M);cin>>S;vector<vector<int> >F(N+1,vector<int>()),D(N+1,vector<int>());for(i=0;i<M;i++){scanf("%s",Q);if(Q[0]=='L'&&Q[1]=='+'){L++;}if(Q[0]=='L'&&Q[1]=='-'){L--;}if(Q[0]=='R'&&Q[1]=='+'){R++;}if(Q[0]=='R'&&Q[1]=='-'){R--;}F[R-L+1].push_back(L);C=max(C,R-L+1);}for(i=1;i<=N;i++){sort(F[i].begin(),F[i].end());if(F[i].size()){D[i].push_back(F[i][0]);}for(j=1;j<F[i].size();j++){if(F[i][j-1]!=F[i][j]){D[i].push_back(F[i][j]);}}}for(i=1;i<=C;i++){set<string> s;for(j=0;j<D[i].size();j++){s.insert(S.substr(D[i][j], i));}A+=s.size();}printf("%d\n",A);}

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

using namespace std;

#define MOD 1000000007

int main() {
	int n, k; cin >> n >> k;
	vector<vector<long long> > dp(n + 1, vector<long long>(k + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		long long sum = 0;
		for (int j = 0; j <= k; ++j) {
			sum += dp[i][j];
			if (j > a) sum -= dp[i][j - a - 1];
			dp[i + 1][j] = sum % MOD;
		}
	}
	cout << dp[n][k] << endl;

	return 0;
}

Measured memory_bytes: 80256
#include<iostream>
using namespace std;
int n,t,s,f,sum;
int main(){
  while(cin>>t&&t){
    cin>>n;
    sum=0;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      sum+=(f-s);
    }
    if(sum>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-sum<<endl;
    }
  }
  return 0;
}


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

int main() {
	
	int x;
	cin >> x;
	
	switch(x){
		case 3:
		case 5:
		case 7:
			puts("YES");
			break;
		default:
			puts("NO");
			break;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

int main()
{
  int n;
  cin >> n;
  cout << (1000000 - n) % 1000 << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t N, T;
    cin >> N >> T;
    int64_t ans = 0, l = 0;
    cin >> l;
    for(int i = 1; i < N; i++) {
        int64_t t;
        cin >> t;
        ans += min(T, t - l);
        l = t;
    }
    ans += T;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
Score = []

while True:
    A,B = 0,0
    n = int(input())
    if n == 0:
        break
    else:
        for i in range(n):
            a,b = list(map(int,input().split()))
            if a > b:
                A += a+b
            elif a < b:
                B += a+b
            elif a == b:
                A += a
                B += b
        Score.append([A,B])

for i in range(len(Score)):
    print(str(Score[i][0]) + " " + str(Score[i][1]))

Measured memory_bytes: 7676
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  int G[n][n] = {};
  rep(i, m){
    int a, b; cin >> a >> b;
    a--; b--;
    G[a][b]++;
    G[b][a]++;
  }
  vi v;
  rep(i, n) v.pb(i);
  int ans = 0;
  do {
    for (int i = 1; i < n; i++) {
      if(G[v[i-1]][v[i]] == 0) break;
      if(i == n-1) ans++;
    }
  } while(next_permutation(v.begin()+1, v.end()));

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=naive")
//#pragma GCC diagnostic ignored "-W"
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
char in[10005];
int main(){
        int n,m;
        while(~getII(n,m)){
                int ans=max({n+m,n-m,n*m});
                printf("%d\n",ans);
        }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;
typedef pair<int, lli> pil;
vector<pil> adj[100001];
lli dist[100001];
int N, Q, K;

void dfs(int here, int parent)
{
	for (int i = 0; i < adj[here].size(); i++) {
		int next = adj[here][i].first;
		if (next == parent)
			continue;
		dist[next] = dist[here] + adj[here][i].second;
		dfs(next, here);
	}
}

int main()
{
	int a, b;
	lli c;
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d %lld", &a, &b, &c);
		adj[a].push_back(make_pair(b, c));
		adj[b].push_back(make_pair(a, c));
	}
	scanf("%d %d", &Q, &K);
	dfs(K, -1);
	while (Q--) {
		scanf("%d %d", &a, &b);
		printf("%lld\n", dist[a] + dist[b]);
	}
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int dijkstra(const VT<VPII> &graph, int s, int t) {
    VT<bool> used(graph.size(), false);
    VI cost(graph.size(), INF);
    cost[s] = 0;
    priority_queue<PII, VPII, greater<PII>> pq;
    pq.push(MP(0, s));
    while (!pq.empty()) {
        int nowpoint, nowcost;
        tie(nowcost, nowpoint) = pq.top(); pq.pop();
        if (used[nowpoint]) continue;
        used[nowpoint] = true;
        FORE(e, graph[nowpoint]) {
            int next, ncost;
            tie(next, ncost) = e;
            ncost += nowcost;
            if (cost[next] <= ncost) continue;
            cost[next] = ncost;
            pq.push(MP(ncost, next));
        }
    }
    return cost[t];
}

int main(void) {
    int N, M;
    scanf("%d%d", &N, &M);
    VT<VPII> graph(N);
    VT<tuple<int, int, int>> abc(M);
    REP(i, M) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a--;b--;
        graph[a].EB(MP(b, c));
        graph[b].EB(MP(a, c));
        abc[i] = make_tuple(a, b, c);
    }
    int ans = 0;
    FORE(e, abc) {
        int a, b, c;
        tie(a, b, c) = e;
        ans += (dijkstra(graph, a, b) != c);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=2e5+10;

    int fa[N],v[N];vc<int> son[N];
    ll T;vc<pr> S[N],tmp;
    void solve(int x)
    {
        S[x].clear();if(!sz(son[x])) {S[x].PB({0,0});return;}
        int lc=son[x][0],rc=son[x][1];if(sz(S[lc])>sz(S[rc])) swap(lc,rc);tmp.clear();
        for(int i=0,j=-1,k=0;i<sz(S[lc]);i++)
        {
            pr now=S[lc][i];
            while(j+1<sz(S[rc]) and S[rc][j+1].FR<=T-v[lc]-v[rc]-now.SE) j++;
            if(j>=0) tmp.PB({now.FR+v[lc],S[rc][j].SE+v[rc]});
            while(k<sz(S[rc]) and S[rc][k].SE>T-v[lc]-v[rc]-now.FR) k++;
            if(k<sz(S[rc])) tmp.PB({S[rc][k].FR+v[rc],now.SE+v[lc]});
        }
        sort(all(tmp));if(sz(tmp))S[x].PB(tmp[0]);fo(t,1,sz(tmp)-1) if(S[x].back().SE>=tmp[t].SE) S[x].PB(tmp[t]);
    }
    void main()
    {
        int n=qread();fo(i,2,n) fa[i]=qread(),v[i]=qread(),son[fa[i]].PB(i);
        ll fl=0,fr=bin(50),ans=-1;
        while(fl<=fr)
        {
            T=(fl+fr)/2;fd(x,n,1) solve(x);
            if(sz(S[1])) ans=T,fr=T-1; else fl=T+1;
        }write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 37492
#include <stdio.h>

int main(){

  int a[101][101];
  int n,k,u,i,j,m;

  scanf("%d",&n);
  for(i=1;i<=n;i++)for(j=1;j<=n;j++) a[i][j]=0;

  for(i=1;i<=n;i++){
    scanf("%d",&m);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&u);
      a[m][u]=1;
      // printf("(%d,%d)\n",m,u);
    }
  }


  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)printf(" ");
      printf("%d",a[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

using namespace std;
int a, b, cnt = 0;
int main() {
	cin >> a >> b;
	for (int i = 0; i < b; i++) {
		cin >> cnt;
		a -= cnt;
	}
	if (a > 0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
C=[None];S=[None];F=[None]
for i in range(1,N):
    Ci,Si,Fi=map(int,input().split())
    C.append(Ci);S.append(Si);F.append(Fi)

for i in range(1,N):
    t=S[i]
    for j in range(i,N-1):
        t=max((t+C[j]+F[j+1]-1)//F[j+1]*F[j+1],S[j+1])
    t=t+C[N-1]
    print(t)
print(0)

Measured memory_bytes: 41708
n,y = map(int,input().split())

for i in range(0,n+1):
    for j in range(0,n+1-i):
        k = max(0,n-i-j)
        if 10000*i + 5000*j + 1000*k == y:
            print(i,j,k)
            exit(0)

print(-1,-1,-1)

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

int main() {
  int n,count=0;
  cin >> n;
  vector<int> v(n);
  r(i,n){
    cin >> v[i];
    if(v[i]==count+1)count++;
  }
  if(count)cout<<n-count<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << '?';
    REP(i,n){
        cout << " " << i+1;
    }
    cout << endl;
    string s;
    cin >> s;
    int l=0,r=n;
    int f;
    if(s=="Red"){
        f = 0;
    }else if(s=="Blue"){
        f = 1;
    }else{
        return 0;
    }
    vector<string> rb(2);
    rb[0] = "Red";
    rb[1] = "Blue";
    vint ans(2*n);
    //phase 1
    while(r-l>1){
        int mid = (r+l)/2;
        cout << '?';
        REP(i,n){
            cout << " " << mid+1+i;
        }
        cout << endl;
        string t;
        cin >> t;
        if(t==rb[f]){
            l = mid;
        }else if(t==rb[1-f]){
            r = mid;
        }else{
            return 0;
        }
    }
    ans[l]=f;
    ans[l+n]=1-f;
    //phase 2;
    for(int i=0;i<l;i++){
        cout << '?';
        cout << " " << i+1;
        for(int j=l+1;j<l+n;++j){
            cout << " " << j+1;
        }
        cout << endl;
        string t;
        cin >> t;
        if(t==rb[0]){
            ans[i]=0;
        }else if(t==rb[1]){
            ans[i]=1;
        }else{
            return 0;
        }
    }
    for(int i=l+n+1;i<2*n;i++){
        cout << '?';
        cout << " " << i+1;
        for(int j=l+1;j<l+n;++j){
            cout << " " << j+1;
        }
        cout << endl;
        string t;
        cin >> t;
        if(t==rb[0]){
            ans[i]=0;
        }else if(t==rb[1]){
            ans[i]=1;
        }else{
            return 0;
        }
    }
    for(int i=l+1;i<l+n;i++){
        cout << '?';
        cout << " " << i+1;
        for(int j=0;j<l;++j){
            cout << " " << j+1;
        }
        for(int j=l+n+1;j<2*n;++j){
            cout << " " << j+1;
        }
        cout << endl;
        string t;
        cin >> t;
        if(t==rb[0]){
            ans[i]=0;
        }else if(t==rb[1]){
            ans[i]=1;
        }else{
            return 0;
        }
    }
    cout << "! ";
    REP(i,2*n){
        if(ans[i]==0){
            cout << "R";
        }else{
            cout << "B";
        }
    }
    cout << endl;
    return 0;
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    for (int itiman = 0; itiman <= N; itiman++){
        for (int gosen = 0; gosen <= N - itiman; gosen++){
            if ((Y - 10000*itiman - 5000*gosen) == (N - itiman - gosen)*1000){
              cout << itiman << ' ' << gosen << ' ' << N - itiman - gosen << endl;
              return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x = in();
    if(x >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
cnt = [0, 0, 0]
for p in P:
    if p <= A:
        cnt[0] += 1
    elif p <= B:
        cnt[1] += 1
    else:
        cnt[2] += 1
print(min(cnt))

Measured memory_bytes: 9192
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
t, x, y = 0, 0, 0
for i in range(N):
    T, X, Y = TXY[i]
    z = (T - t) - ((X - x) + (Y - y))
    if z >= 0 and z % 2 == 0:
        t, x, y = T, X, Y
    else:
        print('No')
        exit()
print('Yes')


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

int main() {
  string S;
  cin >> S;

  int max = 0, num = 0;
  for (char c : S) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
      num++;
    }
    else {
      num = 0;
    }
    if (num > max) {
      max = num;
    }
  }

  cout << max << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n,m; cin >> n >> m;
  
  map<int,vector<string>> mp;

  for(int i=1;i<=m;i++){
    int pi; cin >> pi;
    string s; cin >> s;
    mp[pi].pb(s);
  }

  int ac = 0 , wa = 0;

  for(auto& p : mp){
    vector<string>& vec = p.second;
    bool flag = false;
    int cnt = 0;
    for(int i=0;i<vec.size();i++){
      if(vec[i]=="AC"){
        flag = true;
        break;
      }else{
        cnt++;
      }
    }
    if(flag){
      ac++;
      wa+=cnt;
    }
  }
  cout << ac << " " << wa << '\n';
  

  return 0;
}

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

int map[7][7][7]={},n,m;
int X[13]={-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0/*,0, 0,0,0, 1, 1, 1, 1,1,1, 1,1,1*/};
int Y[13]={-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0/*,0, 1,1,1,-1,-1,-1, 0,0,0, 1,1,1*/};
int Z[13]={-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1/*,1,-1,0,1,-1, 0, 1,-1,0,1,-1,0,1*/};

int put(int a,int b,int z)
{
  int c;
  for(int i=0;i<n;i++){
    if(map[a][b][i]==0){
      map[a][b][i]=z;
      c=i;
      break;
    }
  }
  int aa,bb,cc;
  for(int i=0;i<13;i++){
    int count=1;
    for(int j=1;j<=m;j++){
      aa=a+j*X[i],bb=b+j*Y[i],cc=c+j*Z[i];
      if(aa<0 || bb<0 || cc<0 || aa>=n || bb>=n || cc>=n)break;
      if(map[aa][bb][cc]!=z)break;
      count++;
    }
    for(int j=1;j<=m;j++){
      aa=a+(-1)*j*X[i],bb=b+(-1)*j*Y[i],cc=c+(-1)*j*Z[i];
      if(aa<0 || bb<0 || cc<0 || aa>=n || bb>=n || cc>=n)break;
      if(map[aa][bb][cc]!=z)break;
      count++;
    }
    if(count>=m)return z;
  }
  return 0;
}
int main()
{
  int p[1000][2],P;

  while(1){
    cin>>n>>m>>P;
    if(n+m+P==0)break;
    for(int i=0;i<P;i++){
      cin>>p[i][0]>>p[i][1];
      p[i][0]--;
      p[i][1]--;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++)map[i][j][k]=0;
      }
    }
    for(int i=0;i<P;i++){
      int a=put(p[i][0],p[i][1],(i%2)+1);
      if(a==1){
	cout<<"Black "<<i+1<<endl;
	break;
      }
      if(a==2){
	cout<<"White "<<i+1<<endl;
	break;
      }
      if(i==P-1){
	cout<<"Draw"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>

using namespace std;
const int N = 5e2 + 10;
const int C = 33;
#define int long long

int32_t main() {
	int a, b;
	cin >> a >> b;
	int c = b - a;
	int d = (c * (c - 1)) / 2;
	cout << d - a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a;
	rep(i, n - 3 + 1) a.push_back(stoi(s.substr(i, 3)));

	int ans = INF;
	for (auto i : a) chmin(ans, abs(i - 753));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#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 int
#define pb              push_back
#define mp              make_pair
#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 zrobits(x)      __builtin_ctzll(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 w(x)            int x; cin>>x; while(x--)
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;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isPrime(int n)
{
	for (int i = 2; i <= sqrt(n) + 1; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}
int32_t main()
{
	Raghav();
	int n;
	cin >> n;
	int a[n];
	map<int, int>m;
	for (int i = 1; i < n; i++)
	{
		cin >> a[i];
		m[a[i]]++;
	}
	//cout << m[2];
	for (int i = 1; i <= n; i++)
	{
		cout << m[i] << "\n";
	}



	return 0;
}

Measured memory_bytes: 17708
n = int(input())

ans = 0
digit = len(str(n))

# print(digit)

if digit == 6:
  ans = 90909
elif digit == 5:
  ans = (n - 10000) + 1 + 909
elif digit == 4:
  ans = 909
elif digit == 3:
  ans = (n - 100) + 1 + 9
elif digit == 2:
  ans = 9
elif digit == 1:
  ans = n


print(ans)

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

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

using namespace std;

int main() {
  int r, g, b, n;
  std::cin >> r >> g >> b >> n;

  int num = 0;
  rep(i, n / r + 1) {
    rep(j, n / g + 1) {
      int t = r * i + g * j;
      if ((n - t) % b == 0 && t <= n) {
        num++;
      }
    }
  }
  std::cout << num << std::endl;
}


Measured memory_bytes: 3616
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <stack>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main(){
    int n, m; cin >> n >> m;
    vector<unordered_set<int>> vec(n);
    vector<int> in(n, 0);
    for(int i=0; i<n-1+m; i++){
        int a, b; cin >> a >> b; a--; b--;
        vec[a].insert(b);
        in[b]++;
    }
    vector<int> parent(n, -1);
    stack<int> st;
    for(int i=0; i<n; i++){
        if(in[i] == 0){st.push(i);}
    }
    while(!st.empty()){
        int i = st.top(); st.pop();
        for(auto& v:vec[i]){
            parent[v] = i;
            in[v]--;
            if(in[v] == 0){st.push(v);}
        }
    }
    for(auto& v:parent){
        cout << v + 1 << endl;
    }
    return 0;
}

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

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

    int min_sum = 1000000000;

    vector<int> Xs(N);
    for (int i = 0; i < N; i++)
    {
        cin >> Xs[i];
    }

    for (int i = 1; i <= 100; i++)
    {
        int sum = 0;
        for (int j = 0; j < N; j++)
        {
            sum += pow((Xs[j] - i), 2);
        }
        if (sum < min_sum)
        {
            min_sum = sum;
        }
    }

    cout << min_sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(nullptr)
#define INF (1LL<<62)-1
#define F first
#define S second
#define pb push_back

vector<ll> b(100005,-1),a(100005);
ll f(ll i, ll n)
{
    if(b[i]!=-1) return b[i];
    if(i>=n-1) return 0;

    if(i+2<n) b[i] = min(abs(a[i]-a[i+1]) + f(i+1,n) , abs(a[i]-a[i+2]) + f(i+2,n));
    else b[i] = abs(a[i]-a[i+1]) + f(i+1,n);
    return b[i];
}

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

    cout<<f(0,n);
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int MAX = 100005;
int n;
int a[MAX];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> a[i];
    ll curmin = 1e18;
    int cnt;
    bool yes = false;
    for(int i=0;i<n;++i)
    {
        if(a[i]<0)
        cnt++;
        if(a[i]==0)
        {
            yes = true;
            break;
        }
    }
    ll ans = 0;
     for(int i=0;i<n;++i)
        {
            ans+=abs(a[i]);
        }
    if(cnt%2==0 || yes)
    {
        cout << ans ;
        return 0;
    }

    for(int i=0;i<n;++i)
    {
        curmin = min(curmin,(long long)(abs(a[i])));
    }

    cout << ans-2*curmin;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int n, k;
    cin>>n>>k;
    int i;
    int ans = 1;
    for(i=0; i<n; i++){
        if(ans*2<ans+k){
            ans = ans*2;
        }
        else{
            ans = ans + k;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	int time = 0;
	int num = 0;
	while (true) {
		num += x;
		time += t;
		if (n <= num) break;
	}
	cout << time << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	int n;
	int a[5], b[5];
	int i, j;
	int hit, blow;
	
	while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		hit = 0, blow = 0;
		for (i = 0; i < 4; i++){
			scanf("%d", &n);
			for (j = 0; j < 4; j++){
				if (n == a[j]){
					if (i == j)hit++;
					else blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
	
}

Measured memory_bytes: 592
// 171

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    ll n, count=0;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    vector<ll> v(a.back()+1, 0);
    for(ll n: a){
        if(v.at(n) != 0){
            v.at(n) = 2;
            continue;
        }
        for(ll j=1; n*j<a.back()+1; j++){
            v.at(n*j)++;
        }
    }
    for(ll buf: a){
        if(v.at(buf) == 1) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 12556
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf17-relay-open/submissions/8927584
#include <bits/stdc++.h>
using namespace std;

string rep(string s, int k){
    string t = "";
    for(int i = 0; i < k; i++) t += s;
    return t;
}

int main(){
    int L;
    char s[202020], t[202020];
    scanf("%d %s %s", &L, s, t);
    string S(s), T(t);
    int ns = S.size(), nt = T.size();
    string ans = "}";
    for(int i = 0; i * ns <= L; i++){
        if((L - i * ns) % nt == 0){
            int j = (L - i * ns) / nt;
            ans = min(ans, rep(S, i) + rep(T, j));
            ans = min(ans, rep(T, j) + rep(S, i));
            break;
        }
    }
    for(int i = L / ns; i >= 0; i--){
        if((L - i * ns) % nt == 0) {
            int j = (L - i * ns) / nt;
            ans = min(ans, rep(s, i) + rep(t, j));
            ans = min(ans, rep(t, j) + rep(s, i));
            break;
        }
    }
    printf("%s\n", ans.c_str());
    return 0;
}

Measured memory_bytes: 1852