akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define mod 1000000007
#define pb push_back  
#define endl "\n"
#define fi first
#define se second 
#define ll long long
int power(int a,int b,int m=mod)
{
    if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
     
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

int32_t main()
{
   IOS
   
   string s,t;
   cin>>s>>t;
   
   ll n1 = s.length(),i,j,k,cnt=0,mn=INT_MAX,res=0;
   ll n2 = t.length();
   
   for(i=0;i<=n1-n2;i++)
   {
   	cnt=0;
   	k=0;
   	res=0;
   	 for(j=i;k<n2;j++)
   	 {
   	 	cnt++;
   	 	if(s[j]!=t[k])
   	 	{
   	 		res++;
   	 	}
   	 	k++;
   	 }
   	 mn = min(mn,res);
   }
   cout<<mn<<endl;
   
}

Measured memory_bytes: 3644
N,Q=gets.chomp.split(" ").map(&:to_i)

edges = {}
(N-1).times {
    a,b=gets.chomp.split(" ").map(&:to_i)
    a_edge = edges[a]
    if a_edge == nil
        edges[a] = [b]
    else
        a_edge.push(b)
    end
    
    b_edge = edges[b]
    if b_edge == nil
        edges[b] = [a]
    else
        b_edge.push(a)
    end
}

ops={}
(1..N).each{|n| ops[n] = 0 }
Q.times do
    p,x=gets.chomp.split(" ").map(&:to_i)
    ops[p] += x
end

memo = {}
def calc(p, c, edges, ops, memo)
    return [] if memo[p] != nil
    memo[p] = c + ops[p]
    nexts = edges[p]
    if nexts != nil
        nexts.map do |pnext|
            [pnext, memo[p]]
        end
    else
        []
    end
end

stack = [[1,0]]
while !stack.empty?
    s = stack.pop
    new_stack = calc(s[0], s[1], edges, ops, memo)
    stack.concat(new_stack)
end

(1..N).each do |n|
    print memo[n] 
    if n != N
        print " "
    end
end


Measured memory_bytes: 68676
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int N;
int ans[510][510];

void dfs(int l=0,int r=N,int level=1)
{
	if(r-l<2)return;

	int mid=(l+r)/2;
	for(int i=l;i<mid;i++)
	{
		for(int j=mid;j<r;j++)
		{
			ans[i][j]=level;
			ans[j][i]=level;
		}
	}

	dfs(l,mid,level+1);
	dfs(mid,r,level+1);
	return;
}


int main()
{
	cin >> N;

	dfs();
	
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			cout << ans[i][j];
			if(j==N-1)cout << endl;
			else cout << " ";
		}
	}
	return 0;
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define int long long


using namespace std;

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


    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for (int i = 0; i < n-1; ++i) {
        ans++;
        if(s[i]==s[i+1])
        {
            while (s[i]==s[i+1])
            {
                i++;
                if(i==n-1)
                    break;
            }
        }
    }
    
    if(n>1)
    {
        if(s[n-2]!=s[n-1])
            ans++;
    }
    else if(n==1)
        ans++;
    cout<<ans;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,num,arr[100001];
    cin>>num;
    for(int i=1;i<=num;i++)
    {
        cin>>n;
        arr[n]=i;
    }
    for(int u=1;u<=num;u++)
    {
        cout<<arr[u]<<" ";
    }
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  int q;
  cin >> q;
  vpii p(q);
  vector <vi> row(n + 1);
  vector <vi> col(m + 1);
  for (int i = 0; i < q; i++) {
    cin >> p[i].first >> p[i].second;
    row[p[i].first].pb(i);
    col[p[i].second].pb(i);
  }
  // row-col
  pii r(-1, -1);
  for (int i = 1; i <= n; i++) {
    if (not row[i].empty()) {
      pii state(sz(row[i]), i);
      r = max(r, state);
    }
  }
  vi taken(q, 0);
  for (int i: row[r.second]) {
    taken[i] = 1;
  }
  pii c(-1, -1);
  for (int i = 1; i <= m; i++) {
    if (not col[i].empty()) {
      int cc = 0;
      for (int j: col[i]) {
        if (not taken[j]) cc++;
      }
      pii state(cc, i);
      c = max(c, state);
    }
  }
  for (int i: col[c.second]) {
    taken[i] = 1;
  }
  int ans = accumulate(all(taken), 0);
  // col-row
  c = pii(-1, -1);
  for (int i = 1; i <= m; i++) {
    if (not col[i].empty()) {
      pii state(sz(col[i]), i);
      c = max(c, state);
    }
  }
  fill(all(taken), 0);
  for (int i: col[c.second]) {
    taken[i] = 1;
  }
  r = pii(-1, -1);
  for (int i = 1; i <= n; i++) {
    if (not row[i].empty()) {
      int cc = 0;
      for (int j: row[i]) {
        if (not taken[j]) cc++;
      }
      pii state(cc, i);
      r = max(r, state);
    }
  }
  for (int i: row[r.second]) {
    taken[i] = 1;
  }
  ans = max(ans, accumulate(all(taken), 0));
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 39576
#include <stdio.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	long long A, B, C, D;
	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
	
	long long G = gcd(C, D), L = (C / G) * D;
	long long c = B / C - (A - 1) / C, d = B / D - (A - 1) / D, l = B / L - (A - 1) / L;
	printf("%lld\n", (B - A + 1) - c - d + l);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
N, C = list(map(int, input().split()))
E = []
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    E.append((s, c, +1))
    E.append((t, c, -1))

E = sorted(E, key=lambda x:-x[2])
E = sorted(E, key=lambda x:x[0])

n = 0
nmax = 0
ie = 0
X = [0]*31
while ie<len(E):
    t = E[ie][0]
    while ie<len(E) and E[ie][0]==t and E[ie][2]==1:
        c = E[ie][1]
        if X[c]==0: n+=1
        X[c] +=1
        ie+=1

    nmax = max(nmax, n)
        
    while ie<len(E) and E[ie][0]==t and E[ie][2]==-1:
        c = E[ie][1]
        X[c] -= 1
        if X[c]==0: n-=1
        ie+=1

print(nmax)

Measured memory_bytes: 29868
fun pow5(x:Long) = x*x*x*x*x

fun main(args: Array<String>) {
    val x = readLine()!!.toLong()
    val l = -1000L..1000L
    val t = l.map{ a -> l.map{ b -> Triple(a, b, pow5(a) - pow5(b)) } }.flatten().find { it.third == x }!!
    println("${t.first} ${t.second}")
}

Measured memory_bytes: 552172
N = gets.to_i
WHITE = 0
BLACK = 1

G = Hash.new { |h, k| h[k] = [] }

(N - 1).times do
  a, b = gets.split.map(&:to_i)

  G[a] << b
  G[b] << a
end

if N <= 3
  puts [*1..N].join(' ')
  exit
end

COLOR = Hash.new

def bfs
  visited = Hash.new(false)
  queue = []
  queue << [1, WHITE]

  until queue.empty?
    v, color = queue.shift
    COLOR[v] = color

    visited[v] = true
    G[v].each do |u|
      next if visited[u]

      if color == WHITE
        queue << [u, BLACK]
      else
        queue << [u, WHITE]
      end
    end
  end
end

bfs
nums = Hash.new { |h, k| h[k] = [] }

1.upto(N) do |n|
  nums[n % 3] << n
end

black_cnt = COLOR.values.count(BLACK)
white_cnt = COLOR.values.count(WHITE)
ans = Array.new(N + 1)

if black_cnt <= N / 3
  1.upto(N) do |n|
    if COLOR[n] == BLACK
      ans[n] = nums[0].pop
    else
      if nums[1].empty?
        ans[n] = nums[2].pop
      else
        ans[n] = nums[1].pop
      end
    end

    ans[n] = nums[0].pop if ans[n].nil?
  end
elsif white_cnt <= N / 3
  1.upto(N) do |n|
    if COLOR[n] == WHITE
      ans[n] = nums[0].pop
    else
      if nums[1].empty?
        ans[n] = nums[2].pop
      else
        ans[n] = nums[1].pop
      end
    end

    ans[n] = nums[0].pop if ans[n].nil?
  end
else
  1.upto(N) do |n|
    if COLOR[n] == WHITE
      ans[n] = nums[1].pop if nums[1].size > 0
    else
      ans[n] = nums[2].pop if nums[2].size > 0
    end

    ans[n] = nums[0].pop if ans[n].nil?
  end
end

puts ans[1..-1].join(' ')


Measured memory_bytes: 71592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = sc.nextInt();
        if (x < t) {
            System.out.println(0);
        } else {
            System.out.println(x - t);
        }
    }
}

Measured memory_bytes: 21844
import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
import random
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, T = read_values()
    P = sorted([tuple(read_values()) for _ in range(N)], key=lambda p: (p[0], -p[1]))

    dp = [[0] * (T + 2) for _ in range(N + 1)]

    for i, (a, b) in enumerate(P):
        for t in range(T + 1):
            if t < T:
                s = min(T, t + a)
                dp[i + 1][s] = max(dp[i + 1][s], dp[i][t] + b)
            dp[i + 1][t] = max(dp[i + 1][t], dp[i][t])
    print(max(dp[N]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 154824
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(dead_code)]
fn in_digit(mut x: u32, a: u32, b: u32) -> bool {
    let mut sum = 0;
    while x > 0 {
        sum += x % 10;
        x /= 10;
    }
    a <= sum && sum <= b
}

fn main() {
    input! {
        n: u32,
        a: [u32; n],
    }
    let mut v: Vec<u32> = a;
    v.sort();
    v.reverse();
    let mut bob: u32 = 0;
    let mut alice: u32 = 0;
    for (i, &item) in v.iter().enumerate() {
        if i % 2 == 0 {
            alice += item;
        } else {
            bob += item;
        }
    }
    println!(
        "{}",
        alice - bob
    )
}


Measured memory_bytes: 4352
import java.util.*;
class Main {
  public static void main(String[]agrs) {
    Scanner scanner = new Scanner(System.in);
    int h = scanner.nextInt();
    int a = scanner.nextInt();
    int aN = 0;
    
    if(h<a){
      System.out.println(1);
    }else{
      for(int i=h; i>0; i -=a){
        aN ++;
      }
      System.out.println(aN);
    }
  }
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	class Pair
	{
		public int Count {get; set;}
		public long Value {get; set;}
	}
	public static void Main(string[] args)
	{
		var ps = Input().ToInt();
		int n = ps[0];
		int m = ps[1];
		var p = Input();
		var a = new long[n];
		
		for(int i = 0; i < n; i++)
		{
			a[i] = p[i].ToLong();
		}
		Array.Sort(a);
			
		var cs = new Pair[m];
		for(int i = 0; i < m; i++)
		{
			p = Input();
			var b = p[0].ToInt();
			var c = p[1].ToLong();
			cs[i] = new Pair(){ Count = b, Value = c};
		}
		Array.Sort(cs, (s, t) => (int)(t.Value - s.Value));
		long[] replaces = new long[n];
		var index = 0;
		for(int i = 0; i < n; i++)
		{
			replaces[i] = cs[index].Value;
			cs[index].Count--;
			if(cs[index].Count<=0)
				index++;
			if(index >= cs.Length)
				break;
		}
		for(int i = 0; i < n; i++)
		{
			a[i] = Math.Max(a[i], replaces[i]);
		}
		
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			wa += a[i];
		}
		Console.WriteLine(wa);
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< int > A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    long long ans = 0;
    for (int i = 0; i < M; i++) {
        ans += A[i];
        if (ans > (long long)N) {
            printf("-1\n");
            return 0;
        }
    }
    printf("%ld\n", (long long)N - ans);
    return 0;
}


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

int main() {
  string s;
  string t;
  cin >> s >> t;
  if( s.at(0) ==  t.at(2) && s.at(1) == t.at(1) && s.at(2)==t.at(0)){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] As = Console.ReadLine().Split(' ');
            double d = 0;
            int sum = 0;
            for (var i = 0; i < N; i++)
            {
                int A = int.Parse(As[i]);
                d += 1.0/A;
            }
            double ans = 1.0/d;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
# include <bits/stdc++.h>
# define LL long long
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100, lg = 19;
LL n, k, a[N];
inline LL solve(LL m){
	LL cur_ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] < 0){
			int ll = 1, rr = i - 1, ans = i;
			while(ll <= rr){
				int mm = (ll + rr) >> 1;
				if(a[mm] * a[i] < m){
					rr = mm - 1;
					ans = mm;
				}else{
					ll = mm + 1;
				}
			}
			cur_ans += i - ans;
		}
		if(a[i] >= 0){
			int ll = 1, rr = i - 1, ans = 0;
			while(ll <= rr){
				int mm = (ll + rr) >> 1;
				if(a[mm] * a[i] < m){
					ll = mm + 1;
					ans = mm;
				}else{
					rr = mm - 1;
				}
			}
			cur_ans += ans;
		}
	}
	return cur_ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	LL l = -1e18, r = 1e18, res = 0;
	while(l <= r){
		LL m = (l + r) / 2, cur_ans = solve(m);
		if(cur_ans < k){
			l = m + 1;
			res = m;
		}else{
			r = m - 1;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
grid = [list(int(s) for s in input().split()) for _ in range(3)]

flg = False
if (grid[1][0] - grid[0][0] == grid[1][1] - grid[0][1] == grid[1][2] - grid[0][2])\
        and (grid[2][0] - grid[0][0] == grid[2][1] - grid[0][1] == grid[2][2] - grid[0][2]):
    flg = True

print("Yes" if flg == True else "No")


Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

immutable long MOD = 10^^9+7;
alias ModLong = ModNum!(long, MOD);
void main() {
    int H, W, A, B;
    readf("%d %d %d %d\n", &H, &W, &A, &B);

    ModLong[] fact = new ModLong[H+W+1];
    ModLong[] _fact = new ModLong[H+W+1];
    foreach(i, ref e; fact) {
        e = i==0 ? ModLong(1) : ModLong(i) * fact[i-1];
    }
    foreach(i; _fact.length.iota.retro) {
        _fact[i] = i==H+W ? ModLong(1)/fact[i] : ModLong(i+1) * _fact[i+1];
    }
    iota(B, W).map!(i =>
        fact[H-A-1+i]*_fact[i]*_fact[H-A-1] * fact[W+A-2-i]*_fact[A-1]*_fact[W-1-i]
    ).sum.writeln;
}

struct ModNum(T, T mod) if (__traits(isIntegral, T)) {
    T value;
    typeof(this) opBinary(string op)(typeof(this) that) if (op=="+" || op=="-" || op=="*") {
        mixin("return typeof(this)((this.value"~op~"that.value+mod)%mod);");
    }
    typeof(this) opBinary(string op)(typeof(this) that) if (op == "/") {
        return this*getReciprocal(that);
    }
    typeof(this) opBinary(string op)(typeof(this) that) if (op == "^^") {
        return typeof(this)(modPow(this.value, that.value));
    }
    typeof(this) opBinary(string op, S)(S that) if (op == "^^" && __traits(isIntegral, S)) {
        return typeof(this)(modPow(this.value, that));
    }
    typeof(this) getReciprocal(typeof(this) x) in {
        assert(isPrime(mod));
    } body {
        return typeof(this)(modPow(x.value, mod-2));
    }
    T modPow(T base, T power)  {
        T result = 1;
        for (; power > 0; power >>= 1) {
            if (power & 1) {
                result = (result * base) % mod;
            }
            base = base^^2 % mod;
        }
        return result;
    }
    string toString() {
        import std.conv;
        return this.value.to!string;
    }
    invariant() {
        assert(this.value>=0);
        assert(this.value<mod);
    }
    bool isPrime(T n) {
        if (n<2) {
            return false;
        } else if (n==2) {
            return true;
        } else if (n%2==0) {
            return false;
        } else {
            for(T i=3; i*i<=n; i+=2) {
                if (n%i==0) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 3452
using System;
class Volumen0
{
    static void Main()
    {
        int[] height = new int[10];
        for (int i = 0; i < 10; i++)
        {
            height[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(height);
        Array.Reverse(height);
        for (int i = 0; i < 3; i++)
            Console.WriteLine(height[i]);
    }
}
     


Measured memory_bytes: 15948
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m < v {
			m = v
		}
	}
	return m
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Together
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	flag := make(map[int]int, N)
	for i := 0; i < N; i++ {
		a[i] = nextInt()
		flag[a[i]]++
	}

	var maxNum int
	for i := 0; i < 100000; i++ {
		maxNum = max(maxNum, flag[i]+flag[i+1]+flag[i+2])
	}

	fmt.Println(maxNum)
}


Measured memory_bytes: 5660
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n,d,a;
   cin>>n>>d>>a;
   
   pair<ll,ll> arr[n];
   rep(n)
        cin>>arr[i].ff>>arr[i].ss;
   sort(arr,arr+n);
   
   multiset<pair<ll,ll>> ms;
   ll sum = 0;
   ll ans = 0;
   rep(n)
   {
       while(ms.size()>0 && ms.begin()->ff<arr[i].ff)
       {
           sum-=ms.begin()->ss;
           ms.erase(ms.begin());
       }
       
       if(arr[i].ss<=sum*a)
            continue;
       
       ll rem = (arr[i].ss-sum*a + a-1)/a;  
       ms.insert(mp(arr[i].ff+2*d,rem));
       sum+=rem;
       ans+=rem;
   }
   
   cout<<ans;
   
           
   
   return 0;        
}  
   

Measured memory_bytes: 9600
n = int( input() )
p_list = list( map( int, input().split() ) )
c = 0
for i in range(0,n - 2):
    b = p_list[i+1]
    c_list = [ p_list[i],p_list[i+1],p_list[i+2] ]
    c_list.sort()
    if b == c_list[1]:
        c += 1
print(c)    

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

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

int main() {
  int n; ll w;
  cin >> n >> w;
  vector<ll> weight(110,0);
  vector<ll> value(110,0);
  rep(i,0,n) cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(110, vector<ll>(100100,0));
  
  rep(i,0,n) rep(sum_w,0,w+1) {
    if (sum_w - weight[i] >= 0) {
      chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
    }
    chmax(dp[i+1][sum_w], dp[i][sum_w]);
  }
  cout << dp[n][w] << endl; 
  return 0;
}


Measured memory_bytes: 90364
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    wi, vi = map(int, input().split())
    w.append(wi)
    v.append(vi)

v_sum = sum(v) + 1
inf = float('inf')
dp = [inf] * v_sum
dp[0] = 0

for i in range(N):
    for j in reversed(range(v_sum)):
        if j + v[i] < v_sum and dp[j] != inf:
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i])

for i in reversed(range(v_sum)):
    if dp[i] <= W:
        print(i)
        break

Measured memory_bytes: 53844
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll >
#define vi          vector<ll int>
#define vii         vector<pii>
#define mi          map<ll int,ll int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007 
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        2000005

using namespace std;


void solve()
{
	ll n;
	cin>>n;
	ll a=400,b=599;
	ll k=8;
	for(a=400,b=599;b<=1999;a=a+200,b=b+200)
	{
		if(n>=a&&n<=b)
		{
			cout<<k<<endl;
			return;
		}
		k--;
	}
	
}
int main()
    {
      
        ll t;
        t=1;
        
    
    //cin>>t;
        while(t--)
        solve();
    }

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

int main(void) {
    int d, t, s;
    cin >> d >> t >> s;
    
    if (t * s >= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    
    
	public static void main (String[] args) throws java.lang.Exception
	{
			Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			
			int a[] = new int[n];
			for(int i=0;i<n;i++) {
				int c = s.nextInt()-1;
				a[c]=i+1;
			}
			for(int i:a) {
				System.out.print(i+" ");
			}
			System.out.println();
			
	}
}


Measured memory_bytes: 60452
/*
AizuOnline A2104
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int t;
int n,k;
int x[100000];
int kukan[100000];
//
int compare(const void *x , const void *y)
{
  return(*(int *)y - *(int *)x);
}
print_kukan()
{
  int i;
  for(i=0;i<n;i++)
    printf("%d ",kukan[i]);
  printf("\n");
}

main()
{
  int i,res;

  scanf("%d",&t);
  while(t--)
    {
      scanf("%d %d",&n,&k);
	{
	  for(i=0;i<n;i++)
	    {
	      scanf("%d",&(x[i]));
	      if(i)
		kukan[i-1]=x[i]-x[i-1];
	    }

	  if(n==1 || k >= n)
	    {
	      printf("0\n");
	      continue;
	    }

	  //print_kukan();
	  qsort(kukan,n-1,sizeof(int),compare);
	  //print_kukan();
	  res = x[n-1]-x[0];
	  for(i=0;i<k-1;i++)
	    res -= kukan[i];
	  
	  printf("%d\n",res);
	}
    }
return(0);
}

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

using namespace std;

string A(string& S) {
	if (S.length() & 1)
		return "No";
	for (int i = 0; i < S.length(); i += 2)
		if (S[i] != 'h' || S[i + 1] != 'i')
			return "No";
	return "Yes";
}

int main() {
	string S;
	cin >> S;
	cout << A(S);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
X.sort()
avg = sum(X) / N
avg_int = sum(X)// N

if avg-avg_int <= 0.5:
    m = avg_int
else:
    m = avg_int + 1

cnt = 0
for i in X:
    cnt += (i-m)**2

print(cnt)

Measured memory_bytes: 3064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll D[100010];
    rep(i,0,N) cin >> D[i];
    if(D[0] != 0){
        print(0);
        return 0;
    }
    sort(D, D+N);
    map<ll,ll> mp;
    rep(i,0,N) mp[D[i]]++;
    if(mp[0] != 1){
        print(0);
        return 0;
    }
    rep(i,0,N-1){
        if(D[i+1] - D[i] >= 2){
            print(0);
            return 0;
        }
    }
    ll ans = 1;
    for(auto &e: mp){
        if(e.first == 0) continue;
        ll num = mp[e.first-1];
        ans *= power(num, e.second) % MOD;
        ans %= MOD;

    }
    print(ans);

    
    

}

Measured memory_bytes: 7296
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    
    long long sum = 0;
    
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    
    cout << sum;

    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
int main() {
  	int N, K, h, answer = 0;
 	scanf("%d %d", &N, &K);
  
  	for (int i = 0; i < N; ++i) {
    	scanf("%d", &h);
      	if (h >= K) answer++;
    }
  	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
p = list(map(int, input().split()))

for i in range(len(p)):
    p[i] = (p[i] + 1) / 2

sum = 0
S = [0]

for i in p:
    sum += i
    S.append(sum)

# print(S)

max = 0

for i in range(len(p) - K + 1):
    s = S[i + K] - S[i]
    # print(s)
    if max < s:
        max = s

print(max)


Measured memory_bytes: 25060
W,H,N = map(int, input().split())
start = [0,0]
end = [W,H]

for _ in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        start[0] = max(x, start[0])
    elif a == 2:
        end[0] = min(x, end[0])
    elif a == 3:
        start[1] = max(y, start[1])
    else:
        end[1] = min(y, end[1])

print(max(0, end[0]-start[0])*max(0, end[1]-start[1]))

Measured memory_bytes: 3064
// AOJ 2369
#include<iostream>
using namespace std;

string code;
char tok;
bool flag;

char car(string s) {
  return (s.empty() ? '.':s[0]);
}

string cdr(string s) {
  return (s.empty() ? "":s.substr(1));
}

void advance() {
  tok = car(code);
  code = cdr(code);
}

void eat(char c) {
  if (tok == c) {
    advance();
  } else {
    flag = true;
  }
}

void Cat() {
  if (tok == 'm') {
    eat('m');
    Cat();
    eat('e');
    Cat();
    eat('w');
  } else {
  }
}

void Eof() {
  eat('.');
}

void Z() {
  Cat(); Eof();
}

int main() {
  cin >> code;
  code.push_back('.');
  advance();
  
  Z();

  cout << (flag ? "Rabbit":"Cat") << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    REP(i, H) cin >> s[i];

    vector<vector<int>> a(H, vector<int>(W, 0));
    int piece_num = 0;
    vector<int> empty_lines;
    REP(i, H) {
        int nberrys = count(all(s[i]), '#');
        PRINT(nberrys);
        if (nberrys == 0) {
            empty_lines.pb(i);
            continue;
        }
        piece_num++;
        REP(j, W) {
            a[i][j] = piece_num;
            if (s[i][j] == '#') {
                nberrys--;
                if (nberrys) {
                    piece_num++;
                }
            } else {
            }
        }
    }


    while (empty_lines.size()) {
        REP(p, empty_lines.size()) {
            int i = empty_lines[p];
            if (i - 1 >= 0 && find(all(empty_lines), i - 1) == empty_lines.end()) {
                REP(j, W) {
                    a[i][j] = a[i - 1][j];
                }
                empty_lines.erase(empty_lines.begin() + p);
                break;
            }
            if (i + 1 < H && find(all(empty_lines), i + 1) == empty_lines.end()) {
                REP(j, W) {
                    a[i][j] = a[i + 1][j];
                }
                empty_lines.erase(empty_lines.begin() + p);
                break;
            }
        }
    }





    REP(i, H) {
        REP(j, W) {
            cout << a[i][j] << (j == W - 1 ? '\n' : ' ');
        }
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int n;
int a[maxn],b[maxn];
vector<long long> vec[60][60];
void csh(){
	int id;
	for(int i=0;i<=50;i++){
		vec[i][i].push_back(0);
		for(int j=0;j<i;j++){
			for(int k=1;k<=i;k++){
				id=i%k;
				for(vector<long long>::iterator it=vec[id][j].begin();it!=vec[id][j].end();it++)
					vec[i][j].push_back(*it|(1LL<<k));
			}
		}
	}
}
struct node{
	int p;
	long long v;
}stk[maxn];
int top;
bool vis[maxn];
bool check(int p){
	for(int i=1;i<=n;i++)
		vis[i]=0;
	for(int i=1;i<=top;i++){
		if(!(stk[i].v&(1LL<<p)))
			vis[stk[i].p]=1;
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
			return 0;
	return 1;
}
void solve(int p){
	int cnt=0;
	for(int i=1;i<=top;i++)
		if(!(stk[i].v&(1LL<<p)))
			stk[++cnt]=stk[i];
	top=cnt;
}
int main(){
//	freopen("C.in","r",stdin);
	csh();
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++){
		if(vec[a[i]][b[i]].empty()){
			puts("-1");
			return 0;
		}
		for(vector<long long>::iterator it=vec[a[i]][b[i]].begin();it!=vec[a[i]][b[i]].end();it++)
			stk[++top]=(node){i,*it};
	}
	long long ans=0;
	for(int i=50;i>=1;i--){
		if(check(i))
			solve(i);
		else
			ans|=1LL<<i;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

vi adjList[200000];
int depth[200000],m = 0;
int doDFS(int u,int p,int d) {
    int i;
    depth[u] = d;
    if (d > depth[m]) m = u;
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS(v,u,d+1);
    }
    return 0;
}
int main() {
    int i;
    int N,u,v;
    scanf("%d",&N);
    for (i = 0; i < N-1; i++) {
        scanf("%d %d",&u,&v);
        u--,v--;
        adjList[u].pb(v);
        adjList[v].pb(u);
    }

    doDFS(0,-1,0);
    doDFS(m,-1,0);
    int x = depth[m]+1;
    if ((x % 3) == 2) printf("Second\n");
    else printf("First\n");

    return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    vector<int> L;
    unordered_map<int, int> um;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        L.push_back(t);
        for (int j = 0; j < 3; ++j) {
            if (um.count(t+j-1) == 0) {
                um.emplace(t+j-1, 1);
            } else {
                um[t+j-1] += 1;
            }
        }
    }
    int ans = 0;
    for (auto& i : um) {
        ans = i.second > ans ? i.second : ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

pii a[2009];
ll dp[2009][2009];

ll ans(int i, int st, int en)
{
	if(st>en) return 0;
	if(dp[st][en]!=-1) return dp[st][en];
	ll ans1=ans(i+1,st,en-1)+1LL * a[i].fi * (en-a[i].se);
	ll ans2=ans(i+1,st+1,en)+1LL * a[i].fi * (a[i].se-st);
	return dp[st][en]=max(ans1,ans2);
}

void solve()
{
	int n;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		cin>>a[i].fi;
		a[i].se=i;
	}
	memset(dp,-1,sizeof(dp));
	sort(a+1,a+1+n,[](pii x, pii y){return x.fi>y.fi;});
	cout<<ans(1,1,n);
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 35280
//**************************
//*** author  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n,m;
vi g[125252];
int indeg[125252];
int len[125252],bef[125252];

int main()
{
	cin>>n>>m;
	rept(i,0,m)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		g[x].pb(y);
		indeg[y]++;
	}
	fill(bef,bef+n,-1);
	stack<int> s;
	rept(i,0,n)
	{
		if (indeg[i]==0) s.push(i);
	}
	while (s.size())
	{
		int p=s.top();
		s.pop();
		for (int to:g[p])
		{
			if (len[p]+1>len[to])
			{
				len[to]=len[p]+1;
				bef[to]=p;
			}
			indeg[to]--;
			if (indeg[to]==0) s.push(to);
		}
	}
	printf("%d\n",*max_element(len,len+n));
	return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll f(ll b, ll n)
{
	if (n < b)
		return n;
	return f(b, n / b) + (n % b);
}

int main()
{
	ll n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	for (ll b = 2; b <= (ll)sqrt((double)n); ++b) {
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
	for (ll p = (ll)sqrt((double)n); p > 0; --p) {
		ll b = (n - s) / p + 1;
		if (b < 2)
			continue;
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

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

	if (x <= 111)
		cout << "111" << endl;
	else if (x <= 222)
		cout << "222" << endl;
	else if (x <= 333)
		cout << "333" << endl;
	else if (x <= 444)
		cout << "444" << endl;
	else if (x <= 555)
		cout << "555" << endl;
	else if (x <= 666)
		cout << "666" << endl;
	else if (x <= 777)
		cout << "777" << endl;
	else if (x <= 888)
		cout << "888" << endl;
	else if (x <= 999)
		cout << "999" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int array_gcd(int a[],int size){
	int x=a[0];
	for(int i=1;i<size;i++)x=gcd(x,a[i]);
	return x;
}
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  cout<<array_gcd(a,n);
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];

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

    sc.close();

    long[][] dp = new long[N+1][W+1];

    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= W; j++) {
        if (j < w[i]) {
          dp[i + 1][j] = dp[i][j];
        } else {
          dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
      }
    }

    System.out.println(dp[N][W]);

  }

}


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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int n,x,t;
    cin >> n >> x >> t;
    
    cout << ceiv(n,x) * t << endl;
}

Measured memory_bytes: 3592
object Main extends App {
  import scala.io.StdIn.readLine
  val Array(a, b, c) = readLine().split(' ').map(_.toInt)
  val Array(k) = readLine().split(' ').map(_.toInt)

  val values = (0 until k).foldLeft((a,b,c)) { case ((a,b,c), _ ) =>
    val maximumIdx = Seq(a,b,c).zipWithIndex.maxBy(_._1)._2
    maximumIdx match {
      case 0 =>
        (a * 2, b, c)
      case 1 =>
        (a, b * 2, c)
      case 2 =>
        (a, b, c * 2)
    }
  }

  println(Seq(values._1, values._2, values._3).sum)
}

Measured memory_bytes: 54900
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> P, pd;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        P.push_back(p);
    }

    pd.push_back(P[0]);
    for (int i = 1; i < N; i++) {
        pd.push_back(min(pd[i - 1], P[i]));
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= pd[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int> v(n),dp(n);
    for(int i=0;i<n;++i)  cin>>v[i];
    dp[0]=0;
    for(int i=1;i<n;++i)
    {
        dp[i]=abs(v[i]-v[i-1])+dp[i-1];
        for(int j=2;j<=min(k,i);++j)
            dp[i]=min(dp[i],(int)abs(v[i]-v[i-j])+dp[i-j]);
    }
    printf("%d",dp[n-1]);
    return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

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

int main()
{
    int n; cin>>n;
    const int mod = 1e9+7;
    ll a[n];
    for0(i,n) cin>>a[i];
    ll psum[n];
    partial_sum(a,a+n,psum);
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans = (ans + (a[i]*((psum[n-1]-psum[i])%mod))%mod)%mod;
    }
    
    cout<<ans;
}

Measured memory_bytes: 6760
N, W = [int(i) for i in input().split()]
noValue = [[W+1 for j in range(100001)] for i in range(N)] # 重さ[番号][価値]
w,v = [int(i) for i in input().split()]
maxValue = v
noValue[0][v] = w

for i in range(1,N) :	
	noValue[i][0] = 0
	w, v = [int(i) for i in input().split()] # w, v = w_i, v_i
	for j in range(1,min(maxValue+v+1, 100001)) : # 現在の価値の最大+今の入力の価値 or 価値の最大値 の小さいほう
		if j < v  :
			noValue[i][j] = noValue[i-1][j]
		else :
			if noValue[i-1][j - v] == W + 1 :
				if j == v :
					noValue[i][j] = w
					maxValue = max(maxValue, j)
				else :
					noValue[i][j] = noValue[i-1][j]
			elif noValue[i-1][j-v] + w > W :
				noValue[i][j] = noValue[i-1][j]
			else :
				noValue[i][j] = min(noValue[i-1][j - v] + w, noValue[i-1][j])
				maxValue = max(maxValue, j)
print(maxValue)

Measured memory_bytes: 171248
#include <stdio.h>
#define bit(n,m)(((n)>>(m))&1)

char s[9][9];
int main(){
	int h,w,k;
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;i++)scanf(" %s",s[i]);
	
	int ans=0;
	for(int hh=0;hh<1<<h;hh++)for(int ww=0;ww<1<<w;ww++){
		int cnt=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(s[i][j]=='#'&&!bit(hh,i)&&!bit(ww,j))cnt++;
		if(cnt==k)ans++;
	}
	printf("%d",ans);
}

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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cur_min = 1e9;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (p <= cur_min) {
            cur_min = p;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = list(input())

Sa = int(S[0]+S[1])
Sb = int(S[2]+S[3])

if 0<Sa<13:
    if 0<Sb<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0<Sb<13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define ten5 100005

int num[ten5];
vector<int> vint[ten5];
set<int> sint[ten5];
//map<ll,ll> mp;

void dfs(int n,int fix)
{
    int x,i;
    for(i=0;i<vint[n].size();i++)
    {
        if(vint[n][i]<0) continue;
        x=vint[n][i];
        if(sint[fix].find(x)!=sint[fix].end()) continue;
        sint[fix].insert(x);
        num[x]=fix;
        dfs(x,fix);
    }
    return;
}

int main(void)
{
    int n,m,k;
    int a1,a2,i,j,sum,a=0,temp;
    cin>>n>>m>>k;
    for(i=0;i<m;i++)
    {
        cin>>a1>>a2;
        vint[a1].pb(a2);
        vint[a2].pb(a1);
    }
    for(i=0;i<k;i++)
    {
        cin>>a1>>a2;
        vint[a1].pb(-a2);
        vint[a2].pb(-a1);
    }
    for(i=1;i<=n;i++)
    {
        if(num[i]!=0) continue;
        sint[i].insert(i);num[i]=i;
        dfs(i,i);
    }
    for(i=1;i<=n;i++)
    {
        a=1;
        sum=sint[num[i]].size();
        for(j=0;j<vint[i].size();j++)
        {
            temp=vint[i][j];
            if(temp>0)
            {

                a++;
                continue;
            }
            temp=-temp;
            if(sint[num[i]].find(temp)!=sint[num[i]].end())
            {
                a++;
            }
        }
        cout<<sum-a<<" ";
    }
    return 0;
}


Measured memory_bytes: 18688
program example
    implicit none

    integer(8) N,M,B
    integer(8),allocatable :: A(:)

    read(*,*) N,M

    allocate(A(M))

    read(*,*) A

    B=N-sum(A)

    if(B>=0) then
        write(*,*) B
    else
        write(*,*) "-1"
    end if

end program example


Measured memory_bytes: 2836