akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,x;
  cin >> N >> x;

  vector<int> a(N);
  for(int i = 0;i < N;i++) {
    cin >> a.at(i);
  } 

  sort(a.begin(),a.end());

  int ans = 0;
  for(int i = 0;i < N;i++) {
    x -= a.at(i);
    if(x < 0) break;
    if(i == N-1) if(x != 0) break;
    ans++;
  }

  cout << ans << endl;
}


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

#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair

const int N = int( 2e5 ) + 10;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<class T> T gcd(T a,T b){while(b){T r=a%b;a=b;b=r;}return a;}
template<class T> T lcm(T a,T b){return (a*b)/gcd(a,b);}
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}


const int INF = 1e8;
int n, m, r;
int rr[8];
int adj[201][201];
int dis[201][201];
int from, to, d;
int ans;
void __answer()
{
    ans = INF;
    for(int i = 0; i < 201; i++) {
        fill(adj[i], adj[i] + 201, 0);
        fill(dis[i], dis[i] + 201, INF);
    }
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++) {
        cin >> rr[i];
    }
    for(int i = 0; i < m; i++) {
        cin >> from >> to >> d;
        dis[from][to] = min(dis[from][to], d);
        dis[to][from] = min(dis[to][from], d);
    }
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    sort(rr, rr + r);
    do {
        int path = 0;
        for(int i = 0; i + 1 < r; i++) {
            path += dis[rr[i]][rr[i + 1]];
        }
        ans = min(ans, path);
    } while(next_permutation(rr, rr + r));
    cout << ans;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(11) << fixed;
    #ifdef LOCAL
        freopen("TEST.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


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

int main(){
    int N;
    vector<int> V(N),C(N);

    cin >> N;

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

    int profit,sum=0;

    for (int i=0; i<N; i++){
        profit = V[i]-C[i];
        if (profit > 0){
            sum += profit;
        }
    }

    cout << sum << endl;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int X, Y, A, B, C;
int p[110000], q[110000], r[110000];
signed main() {
    cin >> X >> Y >> A >> B >> C;
    rep(i, A) { cin >> p[i]; }
    rep(i, B) { cin >> q[i]; }
    rep(i, C) { cin >> r[i]; }
    sort(p, p + A), reverse(p, p + A);
    sort(q, q + B), reverse(q, q + B);
    sort(r, r + C), reverse(r, r + C);
    int ans = 0;
    vint v;
    rep(i, X) { v.push_back(p[i]), ans += p[i]; }
    rep(i, Y) { v.push_back(q[i]), ans += q[i]; }
    sort(all(v));
    rep(i, min((int) v.size(), C)) {
        if (v[i] < r[i]) { ans += r[i] - v[i]; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4724
S = gets.chomp.to_s## to_sメソッドが数値→文字

ans = 0
## S.times や S.chars みたいなのは先頭を大文字
S.chars do |i| ## chars は文字列内の文字を１文字ずつ取り出しながら処理
  if i == "+"
    ans += 1
  else
    ans += - 1
  end 
end 

puts ans



Measured memory_bytes: 1788
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        qs: [(usize1, usize1); q],
    }

    let mut acs = vec![0; s.len()];

    for i in 1..s.len() {
        if s[i - 1] == 'A' && s[i] == 'C' {
            acs[i] = 1;
        }
    }

    for i in 1..s.len() {
        acs[i] += acs[i - 1];
    }

    for (l, r) in qs {
        let ans = acs[r] - acs[l];
        println!("{}", ans);
    }
}


Measured memory_bytes: 6908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

int n;
int A[100100];

int main() {
	cin >> n;
	rep(i, n)cin >> A[i];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj)cnt++;
		swap(A[i], A[minj]);
	}
	rep(i, n) {
		if (i == 0)cout << A[i];
		else cout << " " << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}

Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x=scanner.nextInt();
		for(int i=1;x!=0;i++) {
			System.out.println("Case "+i+": "+x);
			x=scanner.nextInt();
		}

	}
}



Measured memory_bytes: 42136
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> happiness(N,vector<int>(3));
  
  for(int i = 0; i < N; i++){
    cin >> happiness.at(i).at(0);
    cin >> happiness.at(i).at(1);
    cin >> happiness.at(i).at(2);
  }
  
  vector<vector<int>> DP(N+1,vector<int>(3));

  int plus = 0;
  int a = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(j != k){
          if(i == 0){
            a = 0 + happiness.at(i).at(j);
          }
          else{
            a = DP.at(i-1).at(k) + happiness.at(i).at(j);
          }
          plus = max(plus, a);
        }
      }
      DP.at(i).at(j) = plus;
      plus = 0;
    }
  }
 
  int biggest = 0;
  
  for(int i = 0; i < 3; i++){
    biggest = max(biggest ,DP.at(N-1).at(i));
  }
/*
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      cout << DP.at(i).at(j) << " ";
    }
    cout << endl;
  }
*/
  
  cout << biggest << endl;
}

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

#define F first
#define S second
#define int long long int

signed main(){
    
    int n;
    cin>> n;
    
    priority_queue<int> pq;
    
    for(int i = 0; i < n; i++){
        int tmp;
        cin>> tmp;
        pq.push(-tmp);
    }
    
    while(pq.size() > 1){
        int tmp = -pq.top();
        pq.pop();
        cerr<<tmp;
        vector<int> v;
        while(!pq.empty()){
            if(-pq.top()%tmp){
                v.push_back(-pq.top()%tmp);
//                pq.pop();
            }
            pq.pop();
        }
        for(auto u : v)
            pq.push(-u);
        pq.push(-tmp);
    }
    
    cout<< -pq.top();
    
    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int N;
    cin >> N;
    const int MAX = 3500;

    for (int x = 1; x <= MAX; x++) {
        for (int y = 1; y <= MAX; y++) {
            double z1 = ((double)N * x * y);
            double z2 = (4.0 * x * y - (double)N * y - (double)N * x);
            double z = -1;

            if (z2 == 0) {
                continue;
            }
            // zが正の整数ならそれが正解
            // まず、zが正である場合
            z = z1 / z2;
            int aiu;
            if (z > 0) {
                // zが整数である
                aiu = (int)z;
                if (z - aiu == 0) {
                    cout << x << " " << y << " " << aiu << endl;
                    return 0;
                }
            }

            /*
            if (z > 0 && z < 1) {
                continue;
            }
            if ( z < 0) {
                continue;
            }
            if (z1 % z2 == 0.0) {
                z = z1 / z2;
            } else {
                continue;
            }

            string s = to_string(z);
            DEBUG(s);

            cout << x << " " << y << " " << (int)z << endl;
            return 0;
    */
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

    int n;
    cin >> n;
    cout << n * n * n;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    long pcnt;
    foreach (e; s)
        pcnt += e == 'p' ? 1 : 0;
    writeln(s.length / 2 - pcnt);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll ans,d,x,y,n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        ll dist=x*x+y*y;
        if(dist<=d*d)
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define ll long long 
#define inf 1000000007 
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
	int n,d,x;
	cin>>n>>d>>x;
	int ans=x;
	for(int i=0;i<n;i++) {
		int a;
		cin>>a;
		int N=d-1;
		ans+=N/a;
	}
	cout<<ans+n<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    if(n <= 111)cout << 111 << endl;
    else if(n <= 222) cout << 222 << endl;
    else if(n <= 333) cout << 333 << endl;
    else if(n <= 444) cout << 444 << endl;
    else if(n <= 555)cout << 555 << endl;
    else if(n <= 666)cout << 666 << endl;
    else if(n <= 777)cout << 777<<endl;
    else if(n <= 888)cout << 888 << endl;
    else cout << 999 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,arr[100],m,a,b;
    int sum=0;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>arr[i];
    }
    cin>>m;
    while(m--)
    {
        sum=0;
        cin>>a>>b;
        for(int i=0; i<n; ++i)
        {
            if(i==a-1)
                sum+=b;
            else 
            sum+=arr[i];
        }
        cout<<sum<<endl;
    }


    
}


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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	int a = 0, w = 0, t = 0, r = 0;
	while(n--){
		string s;
		cin >> s;	
		if(s == "AC")
			a++;
		else if(s == "WA")
			w++;
		else if(s == "TLE")
			t++;
		else if(s == "RE")
			r++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, w, t, r);
    return 0;
}



Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int d[2001][2001]={};
int main(){
  int n,k,ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int x,y;
    char c;
    cin>>x>>y>>c;
    if(c=='W') y+=k;
    x%=2*k,x++;
    y%=2*k,y++;
    d[x][y]++;
    if(x<=k&&y<=k) d[x+k][y+k]++;
    else if(x>k&&y>k) d[x-k][y-k]++;
    else if(x<=k&&y>k) d[x+k][y-k]++;
    else d[x-k][y+k]++;
  }

  for(int i=1;i<=2*k;i++){
    for(int j=1;j<=2*k;j++){
      d[i][j]+=d[i-1][j]+d[i][j-1]-d[i-1][j-1];
    }
  }

  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      int tmp;
      tmp=d[i+k][j+k]-d[i][j+k]-d[i+k][j]+d[i][j];
      if(ans<tmp) ans=tmp;
      if(ans<n-tmp) ans=n-tmp;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 15872
while True:
    a, op, b = input().split()  # 3変数ともに文字列として読み込む
    a = int(a)  # a を整数に変換
    b = int(b)  # b を整数に変換
    if op == '?':
        break
    elif op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))



Measured memory_bytes: 5596
t1, t2 = map(int,input().split())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())

def ispos(x):
    return x==abs(x)

first = (a1-b1)*t1
second = (a2-b2)*t2
net = first+second
if net == 0:
    print("infinity")
elif ispos(first) == ispos(net):
    print(0)
else:
    res = 1
    first = -abs(first)
    second = abs(second)
    net = first+second
    res += 2*int(abs(first)/net)
    if first%net == 0:
        res -= 1
    print(res)


Measured memory_bytes: 38636
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	int n;cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0) 
		{
			sum+=i;
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

    ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
    ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1e16;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll>h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll M = INF;
    rep(i,n-k+1){
        M=min(M,h[i+k-1]-h[i]);
    }
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}


ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll dp[101010][20];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.rbegin(), b.rend());
	rep(i, n) {
		if (a[i] == b[0])cout << b[1] << endl;
		else cout << b[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 6408
n,a,b = map(int,input().split())
ans = 0
for c in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if c*10000 + i*1000 + j*100 + k*10 + l <= n and c + i + j + k + l >= a and c + i + j + k + l <= b:
                        ans = ans + c*10000 + i*1000 + j*100 + k*10 + l
print(ans)

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

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

class Sol{
	public void Solve(){
		
		int[] two = new int[N];
		for(int i=0;i<N;i++){
			while(A[i] > 0 && A[i] % 2 == 0){
				two[i]++;
				A[i] /= 2;
			}
		}
		Console.WriteLine(two.Sum());
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

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


Measured memory_bytes: 12000
# coding: utf-8
# Your code here!

n,m = map(int,input().split())

par = [i for i in range(n+1)]
rank = [0 for i in range(n+1)]

def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def unite(x,y):
    rx=find(x)
    ry=find(y)
    
    if rx==ry:
        return
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx
        
    if rank[rx]==rank[ry]:
        rank[rx]+=1

def some(x,y):
    return find(x)==find(y)

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)

for i in range(1,n+1):
    find(i)
    
ans=len(set(par))-1

print(ans)


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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B==C){
        cout<<"No"<<endl;
    }else if(A==B||B==C||A==C){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!{ h: usize, w: usize, k: usize, s: [Chars; h], };
    let mut ans = 0;
    for is in 0 .. (1 << h) {
        for js in 0 .. (1 << w) {
            let mut c = 0;
            for i in 0 .. h {
                for j in 0 .. w {
                    if (is >> i & 1 != 0) && (js >> j & 1 != 0) {
                        if s[i][j] == '#' {
                            c += 1;
                        }
                    }
                }
            }
            if c == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2180
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
if N%2 == 0:
    print(N//2-1)
else:
    print(N//2)


Measured memory_bytes: 4452
#pragma GCC optimize("O3", "unroll-loops")

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

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

// kの階乗を計算する.(sgnを0以外に設定すると逆元を返す)
ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

// aCbを計算する.
ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}


signed main() {
	int x, y; cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
	}
	else {
		int t = (x + y) / 3;
		cout << comb(x + y - 2 * t, x - t) << endl;
	}
	return 0;
}

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

typedef long long ll;

ll md = 1000000007;

int main(int, char**) 
{
	ll k, x;
	cin >> k >> x;

	// cerr << k << ", " << x << endl;
	ll a, b;
	a = x - k + 1;
	b = x + k - 1;
	// cerr << a << ", " << b << endl;

	if (a < -1000000) {
		cerr << "here" << endl;
		a = -1000000;
	}
	if (b > 1000000)
		b = 1000000;
	// cerr << a << ", " << b << endl;

	cout << a;
	for (ll i = a + 1; i <= b; i++)
		cout << " " << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    string S;
    ll A,B,C,D,tmp,tmp2;
    ll N,Q;
    ll cnt = 0;
    ll ans = 100000000;
    cin >> N >> Q;
    cin >> S;
    vector<ll> l(Q), r(Q), T(S.size()); 
    for(int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }
    bool Af = false, Bf = false;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A'){
            Af = true;
        }else if(S[i] == 'C'){
            if(Af){
                cnt++;
                Af = false;
            }
        }else{
            Af = false;
        }
        T[i] = cnt;
    }
    for(int i = 0; i < Q; i++){
        cout << T[r[i]-1] - T[l[i]-1] << endl;
    }
}

Measured memory_bytes: 3392
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[100010];
VI g[100010];

int dfs(int v, int p) {
  if(g[v].size() == 0) return 0;

  VI vec;
  for(int i: g[v]) if(i != p) {
    vec.PB(dfs(i, v));
  }
  sort(ALL(vec));
  reverse(ALL(vec));
  int ret = 0;
  REP(i, vec.size()) {
    chmax(ret, vec[i]+i+1);
  }

  return ret;
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n-1) {
    cin >> a[i];
    g[a[i]-1].PB(i+1);
  }

  cout << dfs(0, -1) << endl;

  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
int nex[maxn],a[maxn],b[maxn];
int ste[maxn];
ll n,k;
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>nex[i];
    int now=1,last=0,ans=1;ste[1]=1;
    for(;k;k--){
        last=now;now=nex[now];
        if(ste[now]) {
            k--;
            k%=(ste[last]-ste[now]+1);
            // cout<<now<<' '<<last<<' '<<ste[last]<<' '<<ste[now]<<endl;
            break;
        }
        ste[now]=ste[last]+1;
    }
    for(;k;k--){now=nex[now];}
    cout<<now<<endl;
    return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(a==b&&b==c&&a%2==0){
    cout<<-1<<endl;
    return 0;
  }
  int cnt = 0;
  while (1) {
    if ((a % 2 | b % 2 | c % 2 )== 1) break;
    ll A = a, B = b, C = c;
    a = (B + C) / 2;
    b = (A + C) / 2;
    c = (A + B) / 2;
    cnt++;
    //cout << a << b << c << endl;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
        #define REP(i,n) for(int i=0;i<n;i++)
        #define LOOP(i,x,n) for(int i=x;i<n;i++)
        #define ALL(v) (v).begin(),(v).end()
        #define PB push_back
        #define MP make_pair
        #define FIR first
        #define UB upper_bound
        #define LB lower_bound
        #define int long long
        using namespace std;
        const int MOD=1000000007;
        const int INF=1000000009;
         
        signed main(){
          double r,g;
          cin>>r>>g;
          cout<<2*g-r<<endl;
          return 0;
        }

Measured memory_bytes: 256
s = list(input())
b = s[:(len(s) - 1) // 2]
e = s[:(len(s) - 1) // 2:-1]
e_b = s[(len(s) + 3) // 2 - 1:]
e_e = s[:(len(s) + 3) // 2 - 2:-1]
print("Yes") if b == e and e_b == e_e else print("No")

Measured memory_bytes: 8892
#include<stdio.h>
int main(){
  int a, b, c, x, y, an, bn, cn, nkr, sum, t1, t2, t3;
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
  if(x<y){
    t1=a*x+b*y;
    t2=c*x*2+b*(y-x);
    t3=c*y*2;
  }else{
    t1=a*x+b*y;
    t2=c*y*2+a*(x-y);
    t3=c*x*2;
  }
  if(t3<t1 && t3<t2){
    printf("%d\n", t3);
  }else{
    if(t1<t2){
      printf("%d\n", t1);
    }else{
      printf("%d\n", t2);
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(I,x,n) for(int I=x;I<n;I++)
using namespace std;
int m[12][12];
int main()
{
    int n,d,ans=0;
    cin>>n>>d;
    rep(i,0,n)
    {
        rep(j,0,d)
        {
            cin>>m[i][j];
        }
    }
    rep(i,0,n-1)
    {
        rep(j,i+1,n)
        {
            int res=0;
            rep(k,0,d)
                res+=(m[i][k]-m[j][k])*(m[i][k]-m[j][k]);
        int r=(int)sqrt(res);
        if(r*r==res)
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
s=gets.split.map!(&:to_i)
ans=0
pen=0
for i in 0..n-1
  if s[i]%2==0
    if s[i]%3==0 || s[i]%5==0
      ans=1
    else
      pen=1
    end
  end
end
if ans==1 && pen==0 || ans==0 && pen==0
  puts "APPROVED"
else
  puts "DENIED"
end


Measured memory_bytes: 14316
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){//こっちを信じる
  ll n;
  cin >>n;
  ll h[n+1];
  ll dp[n+1];
  for(ll i=1;i<n+1;i++) cin >>h[i];
  for(ll i=0;i<n+1;i++) dp[i]=1e9+7;
  dp[1]=0;//足場1動かなくていいので0
  dp[2]=abs(h[2]-h[1]);
  for(ll i=3;i<n+1;i++){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout << dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int D, N;
	scanf("%d %d", &D, &N);
	
	int i, ans = 1;
	for (i = 0; i < D; i++) ans *= 100;
	if (N == 100) ans *= 101;
	else ans *= N;
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

int main(){
	int n ;
	cin >> n ;
	int a[n] , cnt[2] = {0 , 0};
  	for(int i = 0 ; i < n ; ++i){
    	cin >> a[i];
      	cnt[a[i] % 2]++;
    }
  	cnt[0] += cnt[1]/2;	
  	cnt[1] %= 2; 
  	cout << (!cnt[1] ? "YES" : "NO") << '\n' ;
}

Measured memory_bytes: 3992
#define M 26
P[M],A[M],B[M];
int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
	for(k=0;k<M;k++)A[k]=B[k]=0,P[k]=k;
	for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
	for(k=0;k<M;k++){if(A[k]-B[k]||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
}exit(0);}

Measured memory_bytes: 588
//
// Created by Daiki Kuyoshi on 2020/05/03.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    int N, K;
    cin >> N >> K;
    int d;
    vi sunuke (N);
    int a;
    for(int i=0; i<K; i++){
        cin >> d;
        for(int j=0; j<d; j++){
            cin >> a;
            sunuke.at(a-1) += 1;
        }
    }

    int c = 0;

    for(int i=0; i<N; i++){
        if(sunuke.at(i) == 0){
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3188
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

bool isp(int n) {
	for (int i = 2; i <= sqrt(n); ++i) {
		if (n%i == 0) { return 0; }
	}
	return 1;
}

long long n, k[100005], ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; if (isp(k[i])) { ++ans; } }
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  string S;

  CIN(S);

  int len = S.length();
  int num = 0;
  int minDiff = INT_MAX;
  int diff = 0;

  for (int l = 0; l < len; l++) {
    int r = l + 2;
    if (r < len) {
      num = (S[l] - '0') * 100 + (S[l + 1] - '0') * 10 + (S[l + 2] - '0');
      diff = abs(num - 753);
      if (diff < minDiff) {
        minDiff = diff;
      }
    }
  }

  COUT(minDiff);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextLong();
		for (int i=0;i<N-1;i++) {
			long t = sc.nextLong();
			T = T/Main.gcd(T, t)*t;
		}
		System.out.println(T);
	}

	public static long gcd (long a,long b) {
		if (a<b) {
			return gcd(b,a);
		}
		if (b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
}


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

using namespace std;

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

    if (y % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    if (x * 2 <= y && y <= x * 4) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    String t = "keyence";

    String q[] = {"k"     , "ke"   , "key" , "keye", "keyen", "keyenc" };
    String w[] = {"eyence", "yence", "ence", "nce" , "ce"   , "e" };

    signed call_of_Cthulhu( signed datum ) {

        String a;
        read a;
        int n = a.size();
        String r = a;
        reverse(alles(r));

        if ( a.find(t) == 0 ) {
            echo "YES" fin;
            return 0;
        }
        reverse(alles(t));
        if ( r.find(t) == 0 ) {
            echo "YES" fin;
            return 0;
        }

        for ( int i = 0; i < 6; i++ ) {
            reverse(alles(w[i]));
            if ( a.find(q[i]) == 0 && r.find(w[i]) == 0 ) {
                echo "YES" fin;
                return 0;
            }
        }
        echo "NO" fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
ll A[100010];

signed main(){
    cin >> N;
    REP(i, N) cin >> A[i];
    multiset<ll> mst;
    REP(i, N){
        auto l = mst.lower_bound(A[i]);
        if(l != mst.begin()){
            l--;
            mst.erase(l);
        }
        mst.insert(A[i]);
    }
    PRINT(mst.size());
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

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

    vector<int> dp(n+10);
    dp[1]=abs(h[0]-h[1]);
    dp[2]=abs(h[0]-h[2]);
    for(int i=3; i<n; i++){
        dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));
    }
    cout << dp[n-1] << endl;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	string ans;
	bool flag = false;
	int n = s.size(), m = t.size();
	for(int i = n - m ; i >= 0 ; --i){
		ans = s;
		for(int j = 0 ; j < n ; ++j){
			if(ans[j] == '?'){
				ans[j] = 'a';
			}
		}
		for(int j = i ; j < i + m ; ++j){
			ans[j] = t[j - i];
		}
		bool ok = true;
		for(int j = 0 ; j < n ; ++j){
			if(s[j] != '?' && s[j] != ans[j]){
				ok = false;
				break;
			}
		}
		if(ok){
			flag = true;
			break;
		}
	}
	if(flag){
		cout << ans << endl;
	}else{
		cout << "UNRESTORABLE" << endl;
	}
}

Measured memory_bytes: 256