akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int K = input.nextInt();
		int[] test = new int[N];
		for (int i = 0; i < N; i++) {
			test[i] = input.nextInt();
		}
		System.out.println(JUMP(test, K));
	}
	public static int JUMP(int[] test, int K) {
		int[] dp = new int[test.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0]=0; //dp[i] represents cheapest cost up to ith stone
		dp[1]=Math.abs(test[1]-test[0]);
		for (int i = 2; i < test.length; i++) {
			for (int j = 1; j <= Math.min(i, K); j++) {
				dp[i]=Math.min(dp[i-j]+Math.abs(test[i]-test[i-j]), dp[i]);
			}
		}
		return dp[test.length-1];
	}
}

Measured memory_bytes: 53016
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> vec[m+10];
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        if(m-a>=0) vec[m-a].pb(b);
    }
    priority_queue<ll> que;
    ll ans=0;
    for(ll i=m-1;i>=0;i--){//i日め解禁
        for(ll b : vec[i]) que.push(b);
        if(!que.empty()){
            ans+=que.top();
            que.pop();
        }
    }
    kaku(ans);
}



Measured memory_bytes: 5632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)



















const ll table_size = 200005;
ll fact[table_size], finv[table_size], inv[table_size];

// 前処理
void make_table(ll mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll comb(ll n, ll r, ll mod){
    if(n < r || n < 0 || r < 0) return 0;
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}



int main(){
    make_table(MOD);
    
    ll n, m, k;
    cin >> n >> m >> k;
    
    ll a = comb(n * m - 2, k - 2, MOD);
    
    ll ans = 0;
    for(ll d = 1; d < n; d++){
        ans += ((((((d * (n - d) % MOD) * m) % MOD) * m) % MOD) * a) % MOD;
        ans %= MOD;
    }
    for(ll d = 1; d < m; d++){
        ans += ((((((d * (m - d) % MOD) * n) % MOD) * n) % MOD) * a) % MOD;
        ans %= MOD;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>

using namespace std;

const long long int MOD=1e9+7;

long long int calc_ans(long long int n, long long int m) {
    long long int tmp_ans=1;
    for(int i=1; i<=n; i++) {
        tmp_ans *= i;
        tmp_ans %= MOD;
    }
    for(int i=1; i<=m; i++) {
        tmp_ans *= i;
        tmp_ans %= MOD;
    }
    
    return tmp_ans;
}

int main() {
    long long int N, M;
    cin >> N >> M;
    
    long long int ans;
    if(N==M) {
        ans = calc_ans(N, M);
        ans *= 2;
        ans %= MOD;
    } else if (abs(N-M)==1) {
        ans = calc_ans(N, M);
    } else {
        ans = 0;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main ( ) {
 int a ,b ;
  cin>>a>>b;
  if(b*2 >= a ){
	cout<<0<<endl;
    return 0 ;
  }
  else {
    cout<<a-(b*2)<<endl;
    return 0 ;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int answer = 0;
        while(a != b + 1) {
            double d = a;
            int check = c / a;
            double check2 = c / d;
            if(check == check2){
                answer++;
            }
            a++;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 26284
#include <cstdio>
#include <cstring>
#define Max(_A, _B) (_A > _B ? _A : _B)
const int Mod = 1e9 + 7;
int N, M, K, f[2010][2010], s[2010][2010];
int main()
{
	scanf("%d %d %d", &N, &M, &K);
	for(int i = 1; i < K; ++i) f[i][K - i - 1] = 1;
	for(int i = 0; i <= N; ++i)
		for(int j = 0; j < M; ++j)
		{	
			if(j >= K - 1) (f[i][j] += s[i][j - K + 1]) %= Mod;
			else if(i + j - K + 1 >= 0) (f[i][j] += s[i + j - K + 1][0]) %= Mod;
			if(i >= K) (f[i][j] -= s[i - K][j + 1]) %= Mod;
			s[i][j] = (f[i][j] + (i ? s[i - 1][j + 1] : 0)) % Mod;
		}
	f[0][0] = 0;
	int Ans = 0;
	for(int i = N % (K - 1); i <= N; i += K - 1)
		for(int j = (M - 1) % (K - 1); j < M; j += K - 1)
			(Ans += f[i][j]) %= Mod;
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N, R;
    cin >> N >> R;

    cout << R + 100 * max(10-N, (ll)0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
  int n,ans=1e9,idx;
  cin>>n;
  int a[n],sum=0;
  r(i,n){
    cin>>a[i],a[i]*=n;
    sum+=a[i];
  }
  sum/=n;
  r(i,n){
    double x=abs(a[i]-sum);
    if(ans>x){
      ans=x;
      idx=i;
    }
  }
  cout<<idx<<endl;
}

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

#define inRange(x,a,b) (a <= x && x <= b)

struct Node{
    int location, p, l, r;
    Node() {}
};

struct Point{
    int id, x, y;
    Point() {}
    Point(int id, int x, int y) : id(id), x(x), y(y) {}
    bool operator<(const Point other) const{
        return id < other.id;
    }
    void print(){
        printf("%d\n", id);
    }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;
vector<Point> ans;

bool lessX(Point p1, Point p2)  {return p1.x < p2.x;}
bool lessY(Point p1, Point p2)  {return p1.y < p2.y;}

int makeKDTree(int l, int r, int depth){
    if(!(l < r))    return NIL;
    int mid = (l + r) / 2;
    int t = np++;
    if(depth % 2 == 0){
        sort(P+l, P+r, lessX);
    }else{
        sort(P+l, P+r, lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(mid+1, r, depth+1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth){
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;
    if(inRange(x, sx, tx) && inRange(y, sy, ty)){
        ans.push_back(P[T[v].location]);
    }

    if(depth % 2 == 0){
        if(T[v].l != NIL && sx <= x)
            find(T[v].l, sx, tx, sy, ty, depth+1);
        if(T[v].r != NIL && x <= tx)
            find(T[v].r, sx, tx, sy, ty, depth+1);
    }else{
        if(T[v].l != NIL && sy <= y)
            find(T[v].l, sx, tx, sy, ty, depth+1);
        if(T[v].r != NIL && y <= ty)
            find(T[v].r, sx, tx, sy, ty, depth+1);
    }
}

int main(){
    scanf("%d", &N);
    int x, y;
    for(int i = 0; i < N; i++){
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }

    np = 0;
    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0);
        sort(ans.begin(), ans.end());
        for(int j = 0; j < ans.size(); j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 16472
#include<stdio.h>

int main()
{
  int a,b,i,j,k=0;
  
  scanf("%d %d",&a,&b);
  
  for(i=a;i<=b;i++){
    int s = i/10000;
    int d = i % 10000;
    int s2 = d / 1000;
    int d2 = d % 1000;
    int s3 = d2 / 100;
    int d3 = d2 % 100;
    int s4 = d3 / 10;
    int d4 = d3 % 10;
    if(s == d4 && s2 == s4)
      k++;
  }
  
  printf("%d\n",k);
  return 0;
}

Measured memory_bytes: 128
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)


Measured memory_bytes: 32512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,maxi=0, mini=1000;
    cin>>n;
    while(n--)
    {
        int num;
        cin>>num;

        if(num>maxi)
            maxi=num;
        if(num<mini)
            mini=num;
    }
    cout<<maxi-mini<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var V = Console.ReadLine().Split(' ').Select(double.Parse).OrderBy(s => s);
            Console.WriteLine(V.Aggregate((a, b) => (a + b) / 2.0));
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#define EXIST 1
#define EMPTY 0
#define SIZE 21
int main() {
  int N, M, i, j, x, y, amount, flag;
  int map[SIZE][SIZE];
  char way;

  for (;;) {
    for (i = 0; i < SIZE; i++)
      for (j = 0; j < SIZE; j++)
        map[i][j] = EMPTY;

    scanf("%d", &N);
    if (!N) return 0;

    for (i = 0; i < N; i++) {
      scanf("%d %d", &x, &y);
      map[SIZE - y - 1][x] = EXIST;
    }

    scanf("%d", &M);
    for (i = 0, x = 10, y = 10; i < M; i++) {
      scanf(" %c %d", &way, &amount);
      for (j = 0; j < amount; j++) {
        if (way == 'N') y++;
        if (way == 'S') y--; 
        if (way == 'E') x++;
        if (way == 'W') x--;
        map[SIZE - y - 1][x] = EMPTY;
      }
    }

    for (i = 0, flag = 0; i < SIZE; i++) 
      for (j = 0; j < SIZE; j++)
        if (map[i][j] == EXIST) flag = 1;
    
    if (flag)
      printf("No\n");
    else
      printf("Yes\n");
  }

  return -1;
}

Measured memory_bytes: 0
#include <stdio.h>                                    
#include <stdlib.h>     
#include <errno.h>
            
#define MAX_PROC_NAME_SIZE 16
                            
struct proc {        
  char name[MAX_PROC_NAME_SIZE];
  int time;
};
                                                                                
struct proc_list {
  struct proc *ps;
  int head;
  int tail;                  
  int size;
  int quantum;        
};
                                      
static void                        
read_procs(FILE *f, struct proc_list *pl, int size) {
  int ret, i;
                                         
  for (i = 0; i < size; ++i) {     
    ret = fscanf(f, "%s", pl->ps[i].name);
    if (errno != 0) perror("fscanf");
    if (ret == EOF) break;
                        
    ret = fscanf(f, "%d", &pl->ps[i].time);
    if (errno != 0) perror("fscanf");                           
    if (ret == EOF) break;   
  }
}                                     
                          
static void
enqueue(struct proc_list *pl, struct proc p) {
  pl->tail++;  
  if (pl->tail == pl->size) pl->tail = 0;
  pl->ps[pl->tail] = p;
}                                          

static struct proc
dequeue(struct proc_list *pl) {
  struct proc p;

  p = pl->ps[pl->head++];
  if (pl->head == pl->size) pl->head = 0;
  return p;
}

static void
do_process(FILE *f, struct proc_list *pl) {
  int elapsed;
  struct proc p;

  elapsed = 0;
  while (pl->head != pl->tail) {
    p = dequeue(pl);

    if (p.time <= pl->quantum) {
      fprintf(f, "%s %d\n", p.name, elapsed + p.time);
      elapsed += p.time;
      p.time = 0;
    } else {
      elapsed += pl->quantum;
      p.time -= pl->quantum;
      enqueue(pl, p);
    }
  }

  fprintf(f, "%s %d\n", pl->ps[pl->head].name, elapsed + pl->ps[pl->head].time);
}

int
main(int argc, char **argv) {
  int ret;
  struct proc_list pl;

  ret = fscanf(stdin, "%d", &pl.size);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  ret = fscanf(stdin, "%d", &pl.quantum);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  pl.head = 0;
  pl.tail = pl.size - 1;
  pl.size++;
  pl.ps = (struct proc *) malloc(sizeof(struct proc) * pl.size);
  if (pl.ps == NULL) exit(1);

  read_procs(stdin, &pl, pl.size - 1);
  do_process(stdout, &pl);

  free(pl.ps);
  pl.ps = NULL;
  exit(0);
}


Measured memory_bytes: 2244
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	count := 0
	for i := 0; i < n; i++ {
		if list[i] >= k {
			count++
		}
	}
	fmt.Println(count)
}


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

using namespace std;

int h, w, n;

bool isIn(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

void fall(vector<string> & field){
    for(int i=h-1; 1 <= i; i--){
        for(int j=0; j < w; j++){
            int p = i;
            while(p < h && field[p][j] == '.' && field[p-1][j] != '.'){swap(field[p][j], field[p-1][j]); p++;}
        }
    }
}

bool run(vector<string> field){
    fall(field);
    while(true){
        bool erase = false;
        bool f[h][w];
        for(int i=0; i< h; i++)for(int j=0; j< w; j++) f[i][j] = false;

        for(int i=0; i < h; i++){
            for(int j=0; j < w; j++){
                if(field[i][j] == '.') continue;
                int count = 1;
                while(isIn(i, j+count) && field[i][j] == field[i][j+count]) count++;
                if(n <= count){for(int k=0; k < count; k++) f[i][j+k] = true; erase = true;}
                count = 1;
                while(isIn(i+count, j) && field[i][j] == field[i+count][j]) count++;
                if(n <= count){for(int k=0; k < count; k++) f[i+k][j] = true; erase = true;}
            }
        }
        if(!erase) break;

        for(int i=0; i < h; i++)for(int j=0; j < w; j++)if(f[i][j]) field[i][j] = '.';
        fall(field);
    }
    for(int i=0; i < h; i++)for(int j=0; j < w; j++) if(field[i][j] != '.') return false;
    return true;
}

int main(){
    cin >> h >> w >> n;
    vector<string> field(h);
    for(int i=0; i < h; i++) cin >> field[i];
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            if(isIn(i, j+1)){
                swap(field[i][j], field[i][j+1]);
                if(run(field)){cout << "YES" << endl; return 0;}
                swap(field[i][j], field[i][j+1]);
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    cout << a[n / 2] - a[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int c[9];
	REP(i, 9)scanf("%d", &c[i]);
	Yes(c[4] == c[1] + c[3] - c[0] && c[5] == c[2] + c[3] - c[0] && c[7] == c[1] + c[6] - c[0] && c[8] == c[2] + c[6] - c[0]);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<bitset>
#define MAXN 410
int x[100010], y[100010], n, m, ans;
std::bitset<MAXN> z[MAXN];
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1;i <= m;i++)scanf("%d%d", &x[i], &y[i]);
    for(int i = 1;i <= n;i++){
        z[i].set(i);
        for(int j = m;j;j--){
            if(z[i][x[j]] && z[i][y[j]]){
                z[i].set(0);
                break;
            }else if(z[i][x[j]])z[i].set(y[j]);
            else if(z[i][y[j]])z[i].set(x[j]);
        }
    }
    for(int i = 1;i <= n;i++){
        for(int j = i + 1;j <= n;j++){
            if(!z[i][0] && !z[j][0] && (z[i] & z[j]).none())ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
import math
N,P = map(int,input().split())
if N == 1:
    print(P)
    exit()
ans = 1
for i in range(2,math.floor(pow(P,1/2)) + 1):
    if P % i == 0:
        count = 1
        P = P // i
        while P % i == 0:
            count += 1
            P = P // i
        ans *= pow(i,count // N)
print(ans)

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

int main(){

string s;
  cin >> s;
bool c=true;
for(int i=97;i<=122;i++){
        c=true;
for(int j=0;s[j]!='\0';j++){
        if(char(i)==s[j]){
        c=false;
        continue;
        }
}
        if(c==true){
            cout<<char(i);
            break;
        }
}
if(c==false)
        cout<<"None";
 return 0;
}

Measured memory_bytes: 3760
D,d=$<.map &:split
x=[0,4,5,1]
y=[0,2,5,3]
f=->a,b{a.map{|i|d[i]}.rotate(b).map.with_index{|v,i|d[a[i]]=v}}
(1..24).map{|i|f[[1,2,4,3],1]
if d==D
puts:Yes
exit
end
f[i%8<4?x:y,1] if i%4==0}
puts:No

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

static const int MAX = 1e+3;
const int INF = 1e+8;
int a[MAX], b[MAX];

int main(){
    int h, n;
    cin >> h >> n;
    for(int i = 0; i < n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    for(int j = 0; j < h; j++){
        for(int i = 0; i < n; i++){
            int damage = min(h, j + a[i]);
            dp[damage] = min(dp[damage], dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 256
n,y = gets.split.map(&:to_i)

ans = [n,0,0]
sum = n * 1000
if y >= n * 1000 && y <= n * 10000
  while  sum != y && ans[0] >= 0 && ans[2] >= 0 && ans[2] <= n
    if (y - sum) >= 9000
      ans[0] -= 1
      ans[2] += 1
    elsif sum < y
      ans[0] -= 1
      ans[1] += 1
    elsif sum > y
      ans[2] -= 1
      ans[1] += 1
    end
    sum = ans[0] * 1000 + ans[1] * 5000 + ans[2] * 10000
    #p sum
  end
else
  ans[0] = -1
end
if ans[0] < 0 || ans[0] > n || ans[2] < 0 || ans[2] > n
  puts "-1 -1 -1"
else
  print "#{ans[2]} #{ans[1]} #{ans[0]}"
end


Measured memory_bytes: 3836
use proconio::{input, marker::Usize1};

static mut N: usize = 0;
static mut M: u64 = 0;
static mut QS: Vec<(usize, usize, u64, u64)> = Vec::new();
static mut SQ: Vec<u64> = Vec::new();

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    unsafe {
        N = n;
        M = m;
        QS = qs;
        let ans = dfs();
        println!("{}", ans)
    }
}

unsafe fn dfs() -> u64 {
    let mut res = 0;
    if SQ.len() == N {
        for &(a, b, c, d) in &QS {
            if SQ[b] - SQ[a] == c {
                res += d
            }
        }
    } else {
        let last = *SQ.last().unwrap_or(&1);
        for x in last..=M {
            SQ.push(x);
            res = res.max(dfs());
            SQ.pop();
        }
    }
    res
}


Measured memory_bytes: 2192
#include <stdio.h>
#include <math.h>

struct point {
        double x;
        double y;
};

static void
koch(int num, struct point p1, struct point p2)
{
        struct point s, t;
        struct point u;
        double theta = M_PI * 60.0 / 180.0;

        if (num == 0)
                return;

        s.x = ((p1.x * 2.0) + p2.x) / 3.0;
        s.y = ((p1.y * 2.0) + p2.y) / 3.0;
        t.x = (p1.x + (p2.x * 2.0)) / 3.0;
        t.y = (p1.y + (p2.y * 2.0)) / 3.0;

        u.x = (t.x - s.x) * cos(theta) - (t.y - s.y) * sin(theta) + s.x;
        u.y = (t.x - s.x) * sin(theta) + (t.y - s.y) * cos(theta) + s.y;

        num--;

        koch(num, p1, s);
        printf("%.8f %.8f\n", s.x, s.y);

        koch(num, s, u);
        printf("%.8f %.8f\n", u.x, u.y);

        koch(num, u, t);
        printf("%.8f %.8f\n", t.x, t.y);

        koch(num, t, p2);
}

int
main(void)
{
        struct point p1, p2;
        int num;

        scanf("%d", &num);

        p1.x = 0.0;
        p1.y = 0.0;
        p2.x = 100.0;
        p2.y = 0.0;

        printf("%.8f %.8f\n", p1.x, p1.y);
        koch(num, p1, p2);
        printf("%.8f %.8f\n", p2.x, p2.y);

        return 0;
}



Measured memory_bytes: 2088
#include <iostream>

using namespace std;

int gcd(int x,int y)
{
    int r;
    while(r = x%y)
    {
        x = y;
        y = r;
        r = x%y;
    }
    return y;
}

int main()
{
    int i,j,k,t,n;
    long long sum=0;
    cin >> n;
    for(i = 1;i <= n;i++)
        for(j = 1;j <= n;j++)
            for(k = 1;k <= n;k++)
            {
                t = gcd(i,k);
                sum += gcd(j,t);
            }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > G(n);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  
  vector<int> mx(n,0);
  function<void(int, int, int)> dfs1=
    [&](int v,int p,int d){
      chmax(mx[v],d);
      for(int u:G[v]){
        if(u==p) continue;
        dfs1(u,v,max(v,mx[v]));
      }      
    };
  dfs1(0,-1,0);
  
  vector<map<int, int> > dp(n);
  function<int(int, int, int)> dfs4=
    [&](int v,int p,int d){
      if(dp[v].count(d)) return dp[v][d];
      int &res=dp[v][d];
      res=v<d;
      for(int u:G[v]){
        if(u==p||u>d) continue;
        res+=dfs4(u,v,d);
      }
      return res;
    };
  
  vector<int> ans(n,0);
  function<void(int, int)> dfs2=
    [&](int v,int p){      
      for(int u:G[v]){
        if(u==p) continue;
        dfs2(u,v);
      }
      if(p<0) return;
      ans[v]=1+dfs4(v,p,mx[v]);
      if(v<mx[v]) ans[v]-=1+(v<mx[p]?dfs4(v,p,mx[p]):0);
    };
  dfs2(0,-1);
  
  function<void(int, int)> dfs3=
    [&](int v,int p){
      for(int u:G[v]){
        if(u==p) continue;
        ans[u]+=ans[v];
        dfs3(u,v);
      }
    };
  dfs3(0,-1);

  for(int i=1;i<n;i++){
    if(i>1) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int MX_N = 2005;
const int MX_M = 2005;
const int MX_Q = 2e5+5;

int N, M, Q, G[MX_N][MX_M], H[MX_N][MX_M], V[MX_N][MX_M];

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

    cin >> N >> M >> Q;
    FOR(i,1,N){
        string S; cin >> S;
        S = '^' + S;
        FOR(j,1,M){
            G[i][j] = S[j]-'0';
            if (G[i][j]) {
                V[i][j] = (i > 0 && G[i-1][j]);
                H[i][j] = (j > 0 && G[i][j-1]);
            }
        }
    }
    FOR(i,1,N) FOR(j,1,M) {
        G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1];
        V[i][j] += V[i-1][j] + V[i][j-1] - V[i-1][j-1];
        H[i][j] += H[i-1][j] + H[i][j-1] - H[i-1][j-1];
    }

    FOR(i,0,Q-1){
        int X1, Y1, X2, Y2;
        cin >> X1 >> Y1 >> X2 >> Y2;
        
        int v = G[X2][Y2] - G[X1-1][Y2] - G[X2][Y1-1] + G[X1-1][Y1-1];
        int e = V[X2][Y2] - V[X1][Y2] - V[X2][Y1-1] + V[X1][Y1-1]
            + H[X2][Y2] - H[X1-1][Y2] - H[X2][Y1] + H[X1-1][Y1];

        cout << v-e << '\n';
    }
}



Measured memory_bytes: 48896
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		int color[] = new int[9];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			if(a[i] < 400) {
				color[0]++;
			} else if(a[i] < 800) {
				color[1]++;
			} else if(a[i] < 1200) {
				color[2]++;
			} else if(a[i] < 1600) {
				color[3]++;
			} else if(a[i] < 2000) {
				color[4]++;
			} else if(a[i] < 2400) {
				color[5]++;
			} else if(a[i] < 2800) {
				color[6]++;
			} else if(a[i] < 3200){
				color[7]++;
			} else {
				color[8]++;
			}
		}
		
		int sum = 0;
		for(int i = 0; i < 8; i++) {
			if(color[i] > 0) {
				sum++;
			}
		}
		
		int min = sum;
		int max = sum + color[8];
		
		if(sum == 0) {
			min = 1;
			max = color[8];
		}
		
		System.out.println(min + " " + max);
	}
}


Measured memory_bytes: 23380
H, W, A, B = map(int, input().split())
ans = [["0" for _ in range(W)] for _ in range(H)]

for i in range(H):
  if i + 1 <= B:
    ans[i][A:] = ["1"] * (W-A)
  else:
    ans[i][:A] = ["1"] * A

for j in ans:
  print("".join(j))

Measured memory_bytes: 12788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	if(d == 0)
		printf("%.10f\n", ((n-d) * (m-1)) * 1.0 / (n*n));
	else
		printf("%.10f\n", ((n-d) * 2 * (m-1)) * 1.0 / (n*n));
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M), C(M);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  
  bool flag = false;
  for(int i = 0; i <= N - M; i++){
    for(int j = 0; j <= N - M;j ++){
      for(int k = 0; k < M; k++){
        C.at(k) = A.at(i + k).substr(j,M);
      }
      if(C == B){
        flag = true;
        goto OUT;
      }
    }
  }
  OUT:
  if(flag) cout << "Yes" <<endl;
  if(!flag) cout << "No" <<endl;
}
    

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

void dfs(int water, int sugar, int &a, int &b, int &c, int &d, int &e, int &f, vector<vector<bool>> &memo)
{
    // cout << water << " " << sugar << endl;
    if (100 * water + sugar <= f)
    {
        if (water * e >= sugar)
        {
            if (!memo[water][sugar])
            {
                memo[water][sugar] = true;
            }

            if (!memo[water][sugar + c])
            {
                dfs(water, sugar + c, a, b, c, d, e, f, memo);
            }

            if (!memo[water][sugar + d])
            {
                dfs(water, sugar + d, a, b, c, d, e, f, memo);
            }

            if (!memo[water + a][sugar])
            {
                dfs(water + a, sugar, a, b, c, d, e, f, memo);
            }

            if (!memo[water + b][sugar])
            {
                dfs(water + b, sugar, a, b, c, d, e, f, memo);
            }
        }
        else
        {
            if (!memo[water + a][sugar])
            {
                dfs(water + a, sugar, a, b, c, d, e, f, memo);
            }

            if (!memo[water + b][sugar])
            {
                dfs(water + b, sugar, a, b, c, d, e, f, memo);
            }
        }
    }
}

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    vector<vector<bool>> memo(F + 1, vector<bool>(F + 1, false));
    dfs(0, 0, A, B, C, D, E, F, memo);

    double best = 0;
    int ans_whole = 0;
    int ans_sugar = 0;
    for (int i = 0; i * 100 <= F; i++)
    {
        for (int j = 0; i * 100 + j <= F; j++)
        {
            if (memo[i][j])
            {
                if (best <= (double)j / ((double)i * 100 + j))
                {
                    best = (double)j / ((double)i * 100 + j);
                    ans_whole = i * 100 + j;
                    ans_sugar = j;
                }
            }
        }
    }
    cout << ans_whole << " " << ans_sugar << endl;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int h, m, s, S;
	scanf("%d", &S);

	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 60;

	printf("%d:%d:%d\n", h, m, s);


	return  0;
}


Measured memory_bytes: 2108
from itertools import product
import numpy as np

N, M = map(int,input().split())

lst = [list(map(int, input().split())) for _ in range(M)]
p_lst = np.array(list(map(int, input().split())))

ans = 0
mat = [[0]*N for _ in range(M)]

for j, lst2 in enumerate(lst):
    for i in lst2[1:]:
        mat[j][i-1] = 1

mat_np = np.array(mat)

for a in product([0, 1], repeat=N):
    l = np.array(a)
    b = np.dot(mat_np, l)%2
    if np.sum(b==p_lst)==M:ans += 1

print(ans)


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

int main() {
  
  int64_t X, K, D;
  cin >> X >> K >> D;
  
  int64_t close = abs(X / D); 
  
  if (close >= K){
    cout << abs(X - D * K * (abs(X)/X)) << endl;
  }
  else{
    
    if ((K-close)%2 == 0) {
      cout << abs(X - D * close * (abs(X)/X)) << endl;
    }
    else {
      cout << abs(X - D * close * (abs(X)/X) - (abs(X)/X) * D) << endl;
    }
  }

  
return 0;
}

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

int mul(int x){
    int res = 1;

    while(x){

        if(x % 10 > 1){
            res *= (x%10);
            x /= 10;
        }
        else break;
    }

    return res;
}

int main()
{
    int m,d;
    cin >> m >> d;
    int c = 0;
    for(int i = 2; i <= m; i++){
        for(int j = 22; j <= d; j++) {
            if(i == mul(j)){
                if(mul(j) > 1)c++;
                //cout << i << " " << j << endl;
            }
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
C = dict()
i, cp, hist, ans = 0, 0, [0]*N, 0
for _ in range(N):
    c = int(input())
    if c != cp:
        if c in C.keys():
            temp = hist[C[c]] + 1
            hist[i] = hist[i-1] + temp
            ans += temp
        else:
            hist[i] += hist[i-1]
        C[c], cp = i, c
        i += 1
print((ans+1) % (10**9+7))

Measured memory_bytes: 761200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(char*)a-*(char*)b;
}
int main(void){
    char a[4];
    scanf("%s",a);
    qsort(a,3,sizeof(char),asc);
    if(strcmp(a,"abc")==0) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=2*100000+1;

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

int main(){
    ll n,ans,g,tmp1,tmp2;
    cin>>n;
    ll t[n];
    for(ll i=0;i<n;i++){
        cin>>t[i];
    }

    for(ll i=0;i<n-1;i++){
        g=gcd(t[i],t[i+1]);
        if(t[i]<=t[i+1]){
            tmp1=t[i];
            tmp2=t[i+1];
        }
        if(t[i]>t[i+1]){
            tmp2=t[i];
            tmp1=t[i+1];
        }
        t[i+1]=(tmp2/g)*tmp1;
    }
    cout<<t[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()

a = int(s[0:2])
b = int(s[2:4])

if 1 <= a <= 12 and  1 <= b <= 12:
	print("AMBIGUOUS")
elif 1 <= a <= 12 and  not (1 <= b <= 12):
	print("MMYY")
elif not(1 <= a <= 12) and  1 <= b <= 12:
	print("YYMM")
else:
	print("NA")



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		int a = Integer.parseInt(s.next());
		int b = Integer.parseInt(s.next());
		
		System.out.printf("%d %d %.5f",a/b,a%b,(double)a/(double)b );
	}

}

Measured memory_bytes: 26424
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
    //dp[i] denotes the minimum cost to reach ith stone
    // 0 < i < n - 1 are the stones
    //We are asked to dind the cost to reach last stone i.e dp[n - 1]
    //Initially there is infinite cost to reach ith stones
    vector<int> dp(n, INT_MAX);
  
    //To reach first stone there is no cost. SO dp[0] = 0
    dp[0] = 0;
   //To reach second stone the frog can jump from 0th stone costing dp[1] = abs(h[1] - h[0])
    dp[1] = abs(h[1] - h[0]);
    
    //For every other stones 2 <= i < n, the frog can jump from the (i - 1), (i - 2)...(i - k)th stones 
    for(int i = 2; i < n; i++){
      for(int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++){
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
      }
    }
    //Print minm cost to reach (n - 1)th stone
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    c=input()
    L=["a","i","u","e","o"]
    f=0
    for i in range(5):
        if c==L[i]:
            f=1
            
    if f==1:
        print("vowel")
    else:
        print("consonant")

main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long K, std::vector<long long> A)
{
    reverse(A.begin(), A.end());
    ll low = 2, high = 2;
    for (int i = 0; i < K; i++)
    {
        if (high % A[i] != 0 && low % A[i] != 0)
        {
            if ((high / A[i]) - (low / A[i]) == 0)
            {
                cout << -1 << endl;
                return;
            }
        }

        low = ceil(low, A[i]) * A[i];
        high = (high / A[i]) * A[i] + A[i] - 1;
    }
    cout << low << " " << high << endl;
}

int main()
{
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(K);
    for (int i = 0; i < K; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(K, std::move(A));
    return 0;
}


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


int main()
{
   int k;cin>>k;
   string s; cin>>s;
   int len = s.size();
   if(len>k)
     {for(int i= 0;i<k;i++)
        cout<<s[i];
       cout<<"..."<<endl;

     }
     else{
        cout<<s<<endl;
       }

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[300000];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0, cur = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] != cur) {
      ans++;
    } else {
      cur++;
    }
  }
  printf("%d\n", ans == n ? -1 : ans);
}

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

int main(){
  string S;
  int A = 0;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S[i]=='2'){
      A++;
    }
  }
  cout << A << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<float.h>
int main(){
  int n,x,a,b,c;
  scanf("%d",&n);
  x=n/1.08;
  a=x*1.08;
  b=(x+1)*1.08;
  c=(x-1)*1.08;
  if(n==a){
    printf("%d",x);
  }
  else if(n==b){
    printf("%d",x+1);
  }
  else if(n==c){
    printf("%d",x-1);
  }
  else{
    printf(":(");
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{   
    int n;
    cin >> n;
    vector<int> L(n);
    int sum = 0;
    rep(i, n) {
        cin >> L[i];
        sum += L[i];
    }

    sort(L.rbegin(), L.rend());

    if(sum - 2*L[0] > 0) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 200005;

int n;
int a[N];

int main() {
    int p;
    while (~in(n)) {
        FOR (i, 1, n) in(a[i]);
        p = 0;
        FOR (i, 1, n) {
            if (a[i] != p + 1) continue;
            p++;
        }
        printf("%d\n", p == 0 ? -1 : n - p);
    }
    return 0;
}


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

const int maxn = 200001;
const int dem = 2;  
const double INF = (1e200);
struct Point{
    double x[dem];
}p[maxn];

int n;
double minx[1<<dem], maxx[1<<dem];

double solve() {
    int tmp = 1<<dem;

    for(int i=0; i<tmp; i++) {
        minx[i] = INF;
        maxx[i] = -INF;
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<tmp; j++) {
            int t = j;
            double s = 0;
            for(int k=0; k<dem; k++) {
                if(t & 1) s += p[i].x[k];
                else s -= p[i].x[k];
                t >>= 1;
            }
            if(maxx[j] < s) maxx[j] = s;
            if(minx[j] > s) minx[j] = s;
        }
    }

    double ans = -INF;
    for(int i=0; i<tmp; i++) {
        if(maxx[i] - minx[i] > ans)
            ans = maxx[i] - minx[i];
    }

    return ans;
}

int main(){
    cin >> n;
    rep(i, n) {
        rep(j, dem) cin >> p[i].x[j];
    }
    double ans = solve();
    cout << (int)ans << endl;
    return 0;
}


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

int main(){

  string str,str2,str3;
  int n,count,t,ans = 0,mis;

  cin >> str >> n;

  for(int i=0;i<n;i++){
    cin >> str2;
    mis = 0;
    str3 = str2 + str2;

    for(int j=0;j<str3.size()-str.size();j++){
      count = 0;
      t = j;
      for(int s=0;s<str.size();s++){
      	if(str[s] == str3[t]){
	  t++;
	  count++;
	}
      }
      if(count == str.size() && mis == 0){
	ans++;
	mis = 1;
      }
    }
  }

  cout << ans << endl;

}

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

int main() {
    int a,b;
    cin>>a>>b;
    if(a - 2*b <= 0){
        cout<<"0\n";
    }else{
        cout<<a - 2*b<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256