akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
const ll inf = 1LL << 50;


ll a[100010];

// {1 1 4 2 3 5}
// min {1,1,2,3,5} みたいに管理

void add(auto &deq, ll x) {
	while (!deq.empty() and deq.back() < x) deq.pop_back();
	deq.push_back(x);
}

void del(auto &deq, ll x) {
	if (!deq.empty() and deq.front() == x) deq.pop_front();
}

ll getval(auto &deq) {
	return (deq.empty()) ? -inf : deq.front();
}

ll dp[100010], dp2[100010];


int main(void) {
	ll n, m, k;
	cin >> n >> m >> k;

	rep(i, n) cin >> a[i];
	rep(i, n) dp[i] = a[i];

	rep(i, 2, k + 1) {
		deque<ll> deq;
		rep(j, n) {
			dp2[j] = 1LL * i * a[j] + getval(deq);
			add(deq, dp[j]);
			if (j - m >= 0) del(deq, dp[j - m]);
		}
		rep(j, n) dp[j] = dp2[j];
	}

	ll ans = 0LL;
	rep(j, n) chmax(ans, dp[j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int a[n],b[m];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<m;i++) cin >> b[i];
    sort(a,a+n);
    sort(b,b+m);
    for(int i=x+1;i<=y;i++){
        if(a[n-1]<i&&i<=b[0]){
            puts("No War");
            return 0;
        }
    }
    puts("War");
    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
const long long INF = 1e18;
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll,ll> P;

struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i = 0; i < V; i++){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    for(int i = 0; i < V; i++){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

int main(){
  int H,W;
  graph g(10);
  cin >> H >> W;
  for(int i = 0;i <= 9; i++){
    for(int j = 0; j <= 9; j++){
      int cost;
      cin >> cost;
      g.add_edge(j,i,cost);
    }
  }
  g.dijkstra(1);
  
  long long ans = 0;
  for(int i = 0; i < H ; i++){
    for(int j = 0; j < W; j++){
      int num;
      cin >> num;
      if(num == -1) continue;
      ans += g.d[num];
      //cout << g.d[num] << ' ';
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  [k, x] <- map (read::String -> Int) . words <$> getLine
  let left = max (-1000000) (x - k + 1)
      right = min 1000000 (x + k - 1)
  putStrLn . foldl1 (\acc i -> acc ++ " " ++ i) $ map show [left..right]
  
  

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,l,r) for(int i=l;i<r;i++)
using ll = long long;
const int inf=2e9+10;
const ll MOD=1e9+7;
const ll INF=9e18+10;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int main(){
        int n;cin>>n;
        int cnt=0;
        rep(i,n){
                int x,y;cin>>x>>y;
                if(x==y)cnt++;
                else cnt=0;
                if(cnt==3){
                        cout<<"Yes\n";
                        return 0;
                }
        }
        cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int r;
  cin >> r;
  string ans;
  if(r<1200) ans = "ABC";
  else if(r<2800) ans = "ARC";
  else ans = "AGC";
  cout << ans << endl;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, m;

int main() {
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<int> a(n - 1);
  vector<int> b(n - 1);
  range(i, 0, n - 1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    a[i] = u; b[i] = v;
    g[u].push_back(i);
    g[v].push_back(i);
  }
  vector<int> par(n);
  function<void(int, int)> dfs = [&] (int v, int p) {
    par[v] = p;
    int pp = (~p ? a[p] + b[p] - v : -1);
    for(int id : g[v]) {
      int u = a[id] + b[id] - v;
      if(u != pp) dfs(u, id);
    }
  };
  dfs(0, -1);
  vector<int> x(m), y(m);
  vector<set<int>> to(n);
  vector<vector<int>> path(m);
  range(i, 0, m) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    x[i] = u; y[i] = v;
    vector<int> su, sv;
    while(~par[u]) {
      su.push_back(par[u]);
      int p = a[par[u]] + b[par[u]] - u;
      if(u > p) su.back() = ~su.back();
      u = p;
    }
    while(~par[v]) {
      sv.push_back(par[v]);
      int p = a[par[v]] + b[par[v]] - v;
      if(v > p) sv.back() = ~sv.back();
      v = p;
    }
    while(!su.empty() && !sv.empty() && su.back() == sv.back()) {
      su.pop_back(); sv.pop_back();
    }
    for(int id : su) {
      path[i].push_back(id);
    }
    for(int id : sv) {
      path[i].push_back(~id);
    }
    for(int id : path[i]) {
      if(id >= 0) to[id].insert(i);
      else to[~id].insert(~i);
    }
  }
  int res = 0;
  range(i, 0, n - 1) {
    res += min(2, (int) to[i].size());
  }
  cout << res << endl;
  vector<int> cur(n - 1);
  vector<bool> rev(m);
  range(i, 0, n - 1) if(to[i].size() == 1) cur[i] = 3;
  while(true) {
    int id = -1;
    range(i, 0, n - 1) {
      if(cur[i] == 3 || to[i].empty()) continue;
      if(id == -1 || to[i].size() < to[id].size()) id = i;
    }
    if(id == -1) break;
    int c = *to[id].begin();
    if(cur[id] == 1) c = ~c;
    int s = max(c, ~c);
    rev[s] = c < 0;
    for(int id : path[s]) {
      if((id < 0) ^ (c < 0)) cur[max(id, ~id)] |= 2;
      else cur[max(id, ~id)] |= 1;
      id = max(id, ~id);
      to[id].erase(s);
      to[id].erase(~s);
    }
  }
  range(i, 0, m) if(rev[i]) swap(x[i], y[i]);
  range(i, 0, m) {
    cout << x[i] + 1 << " " << y[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 63232
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int check(string &s, vector<char> &t, vector<char> &d, int k) {
	int q = t.size();
	int n = s.size();
	REP(i, q) {
		if (t[i] == s[k]) {
			if (d[i] == 'L')k--;
			else k++;
			if (k == -1)return -1;
			if (k == n)return 1;
		}
	}
	return 0;
}

int main() {
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<char> t(q), d(q);
	REP(i, q) {
		char tmp[2];
		scanf("%s", tmp);
		t[i] = tmp[0];
		scanf("%s", tmp);
		d[i] = tmp[0];
	}
	//left
	int r = n, l = -1;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		if (check(s, t, d, mid) == -1)l = mid;
		else r = mid;
	}
	int x = (check(s, t, d, r) == -1) ? r : l;
	
	r = n, l = 0;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		if (check(s, t, d, mid) == 1)r = mid;
		else l = mid;
	}
	int y = (check(s, t, d, l) == 1) ? l : r;
	cout << y - x - 1 << endl;
}

Measured memory_bytes: 900
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::BinaryHeap;
use std::collections::VecDeque;

fn main() {
    let x: usize = read();
    let y: usize = read();
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let mut p: Vec<i64> = read_n(a);
    let mut q: Vec<i64> = read_n(b);
    let mut r: Vec<i64> = read_n(c);

    p.sort();
    p.reverse();
    q.sort();
    q.reverse();
    r.sort();
    r.reverse();

    let (xv, _) = p.split_at(x);
    let (yv, _) = q.split_at(y);
    let mut bh: BinaryHeap<i64> = BinaryHeap::new();
    for i in xv {
        bh.push(-*i);
    }

    for i in yv {
        bh.push(-*i)
    }

    for i in r {
        if bh.len() != 0 {
            let current = bh.pop().unwrap();
            bh.push(min(current, -i));
        }
    }
    let mut cnt = 0;

    while !bh.is_empty() {
        cnt -= bh.pop().unwrap();
    }
    println!("{}", cnt);
}


Measured memory_bytes: 39036
program atcoder_abc115c_sort
    implicit none
    integer(8) :: n,k,i,ans=10000000000_8
    integer(8),allocatable,dimension(:) :: a
    read*,n,k
    allocate( a(n) )
    read(*,*)(a(i),i=1,n)
    call sort(a)
    do i=1,n-k+1
        ans = min(ans,a(i+k-1)-a(i))
    enddo
    write(*,'(I0)')ans
!----------------------functions--------------------------
contains
recursive subroutine mergesort(a, p, r, b)
  integer(8) a(:), b(:)
  integer(8) p, r
  integer(8) q
  if (p < r) then
    q = (p+r)/2
    call mergesort(a, p, q, b)
    call mergesort(a, q+1, r, b)
    call merge(a, p, q, r, b)
  end if
end subroutine mergesort
subroutine merge(a, p, q, r, b)
    integer(8) a(:), b(:)
    integer(8) p, r, q, i, j, k
    integer(8) t
    k = p;   i = p;   j = q+1
    do
      if (.not. (k <= r)) exit
      if (j > r) then
        t = a(i);   i = i+1
      else if (i > q) then
        t = a(j);   j = j+1
      else if (a(i) <= a(j)) then
        t = a(i);   i = i+1
      else
        t = a(j);   j = j+1
      end if
      b(k) = t;   k = k+1
    end do
    do i = p, r
      a(i) = b(i)  
    end do
end subroutine merge
subroutine sort(a)
    integer(8) a(:), b(size(a)),n
    n = size(a)
    call mergesort(a,1_8,n,b)
end subroutine sort
end program atcoder_abc115c_sort

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.exec();
    }
    
    private void exec() {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] params = input.split(" ");
        int fiveCount = 0;
        int sevenCount = 0;
        for (String param : params) {
            if (param.equals("5")) {
                fiveCount++;
            } else if (param.equals("7")) {
                sevenCount++;
            }
        }
        if (fiveCount == 2 && sevenCount == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        
    }
}

Measured memory_bytes: 21204
#!/usr/bin/env python3
import sys


def solve(N: int, W: "List[int]"):
    ret = float('inf')
    for i in range(1, N + 1):
        ret = min(ret, abs(sum(W[i:]) - sum(W[:i])))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, W)

if __name__ == '__main__':
    main()


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    vector<vector<int>> vvec(H,vector<int> (W,0));
    for(int j = 0; j < A; ++j){
        vvec.at(0).at(j) = 1;        
    }
    
    for(int i = 1; i <= B; ++i){
        for(int j = A; j < W; ++j){
            vvec.at(i).at(j) = 1;      
        }  
    }
    for(int i = B+1; i < H; ++i){
        for(int j = 0; j < A ; ++j){
            vvec.at(i).at(j) = 1;      
        }  
    }

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){

                cout << vvec.at(i).at(j);

        }
        if(i != H -1){
            cout << endl;
        }
    }

}

Measured memory_bytes: 5120
import numpy as np

n = int(input())
a = list(map(int,input().split()))

a = np.array(a)

b = 1000

k = 0
for k in range(len(a)-1):
    temp = a[k]
    if a[k+1] == temp:
        a[k+1] = b
        b += 1


print(b - 1000)

Measured memory_bytes: 21908
#include<bits/stdc++.h>
using namespace std;
vector<char> con;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='0')
		{
			con.push_back('0');
			continue;
		}
	    if(a[i]=='1')
	    {
	    	con.push_back('1');
	    	continue;
	    }
	    if(con.size()!=0&&a[i]=='B')
	        con.pop_back();
	}
	for(int i=0;i<con.size();i++)
	    cout<<con[i];
	cout<<endl;
	return 0;
}

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

using namespace std;

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

int main(){
  int s; cin >> s;
  bool ym=false;
  bool my=false;

  int front=s/100;
  int back=s%100;
  if(1<=front && front<=12){
    my=true;
  }
  if(1<=back && back<=12){
    ym=true;
  }

  if(ym && my){
    puts("AMBIGUOUS");
  }else if(ym){
    puts("YYMM");
  }else if(my){
    puts("MMYY");
  }else{
    puts("NA");
  }
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

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

int main(){
int S,h,m,s;

0 <= S <= 86400;

cin >> S;

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


cout << h << ":" << m << ":" << s << endl;

return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ull unsigned long long
#define ll long long
const int maxn=100000;
using namespace std;
priority_queue<int,vector<int>,greater<int>>q;

int main()
{

  int a,b;
  cin>>a>>b;
  cout<<(a*3+b)/2<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		
		int[] t = new int[n];
		
		int sum = 	0;
		
		for(int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			sum+=t[i];
		}
		
		int m = sc.nextInt();
		
		int[] p = new int[m];
		int[] x = new int[m];
		
		for(int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			x[i] = sc.nextInt();
			
			out.println(sum - t[p[i] - 1] + x[i]);
		}
		
		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
	}

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

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21460
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define ABSS(a, b) (a > b ? a - b : b - a)

int compare_f(const void *a, const void *b) {
	return (int)(*(uint32_t *)b) - (int)(*(uint32_t *)a);
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	char s[101];

	scanf("%s", s);

	printf("%c%zu%c\n", s[0], strlen(s) - 2, s[strlen(s) - 1]);

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void){
  int a,b,c,d,e,swap;
scanf("%d %d",&a,&b);
c = a+b;
d = a-b;
e = a*b;
if (c > d)
{
  swap = c;
  c = d;
  d = swap;
}
if(d > e){
  swap = d;
  d = e;
  e = swap;
}
  if (c > e){
    swap = c;
    c = e;
    e = swap;
}
printf ("%d ",e);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#define mx 100002
vector<ll> v;
ll dp[mx];

ll n,k;
ll fn(ll pos){
    if(pos>=n-1)    return 0;

    ll p = 1e9;
    if(dp[pos]!=-1) return dp[pos];

    for(ll i = 1;i<=k; i++){
        if(pos+i>=n)    continue;
        ll h = abs(v[pos+i]-v[pos]);
        p = min(p,h+fn(pos+i));
    }
    return dp[pos] = p;
}

int main(){
ll t,tc = 0;

scanf("%lld%lld",&n,&k);
memset(dp,-1,sizeof dp);
v = vector<ll> (n);

for(ll i = 0; i<n; i++)    scanf("%lld",&v[i]);

ll ans = fn(0);
printf("%lld\n",ans);

return 0;
}


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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  if (A+B>C+D){
    cout << "Left" << endl;
  }
  else if (A+B==C+D) {
    cout << "Balanced" <<endl;
  }
  else {
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k,c; cin >> n >> k >> c;
  string s; cin >> s;
  vector<int> mxl(n+2);
  vector<int> mxr(n+2);
  rep(i,n){
    if(s[i]=='o'){
      if(i+1-(c+1)>=1) mxl[i+1]=mxl[i+1-(c+1)]+1;
      else mxl[i+1]=1;
    }
    else{
      mxl[i+1]=mxl[i];
    }
  }
  rrep(i,n){
    if(s[i]=='o'){
      if(i+1+c+1<=n) mxr[i+1]=mxr[i+1+c+1]+1;
      else mxr[i+1]=1;
    }
    else{
      mxr[i+1]=mxr[i+2];
    }
  }
  vector<int> ans(0);
  rep(i,n){
    if(mxl[i+1]>mxl[i]&&mxr[i+1]>mxr[i+2]) ans.push_back(i+1);
  }
  if(mxl[n]!=k){
    cout << endl;
    return 0;
  }
  rep(i,ans.size()){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 6020
#include <bits/stdc++.h>
#define MP make_first
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 105, MAX = 100005;

int n;
int b[N], c[N];
bool vis[N];
int ans[N];


int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> b[i];
    int now = n;
    for(int T = n; T >= 1; T--) {
        int mx = -1;
        for(int i = now; i; i--) {
            if(b[i] == i) {
                mx = i; break;
            }
        }
        ans[T] = mx;
        if(mx > T || mx == -1) {
            cout << -1; return 0;
        }
        for(int i = mx; i < now; i++) b[i] = b[i + 1];
        --now;
    }

    for(int i = 1; i <= n; i++) cout << ans[i] << '\n';
    return 0;
}
/*
5
1 1 3 1 1

5
1 1 1 3 4
*/


Measured memory_bytes: 256
import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = [cnt]
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res.append(cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()


Measured memory_bytes: 15524
H,W,K = map(int,input().split())
c = [[0] * W for i in range(H)]
p = 0
ans = 0
for i in range(H):
    a = str(input())
    for j in range(W):
        if a[j] == ".":
            c[i][j] = 0
        else:
            c[i][j] = 1
            p += 1
aa = [0]*(H + W)
for i in range(2**(H + W)):
    pp = p
    for j in range(H + W):
        aa[j] = i%2
        i = i//2
    for k in range(H):
        for l in range(W):
            if c[k][l] == 1:
                if aa[k] == 1 or aa[H + l] == 1:
                    pp -= 1
    if pp == K:
        ans += 1
print(ans)

Measured memory_bytes: 9240
fun main() {
    val n = nextInt()
    var m = n
    var s = 0
    while (m > 0) {
        s += m % 10
        m /= 10
    }
    println(if (n % s == 0) "Yes" else "No")
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 34552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const ll mod = 1e9 + 7;








int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    map<ll,ll>map_a,map_b;
    ll cnt = 0;
    rep(i,n){
        cin >> a[i];
        cnt++;
        if(i >= 1){
            if(a[i-1] != a[i]){
                map_a[a[i-1]] = cnt-1;
                cnt = 1;
            }
        }
    }
    map_a[a[n-1]] = cnt;
    cnt = 0;
    rep(i,n){
        cin >> b[i];
        cnt++;
        if(i >= 1){
            if(b[i-1] != b[i]){
                map_b[b[i-1]] = cnt-1;
                cnt = 1;
            }
        }
    }
    map_b[b[n-1]] = cnt;
    
    reverse(b.begin(),b.end());
    ll num = 0,sta,res;
    rep(i,n){
        if(a[i] == b[i]){
            num++;
            if(num == 1)sta = i;
            res = a[i];
        }
    }
    if(num == 0){
        cout << "Yes" << endl;
        rep(i,n){
            cout << b[i] << " ";
        }
        cout << "\n";
        return 0;
    }
    if(n-(map_a[res] + map_b[res]-num) >= num){
        cout << "Yes" << endl;
        bool flag = false;
        ll k;
        rep(i,num){
            if(a[i] == res || b[i] == res){
                if(!flag){
                    flag = true;
                    k = i;
                }
            }
            ll j;
            if(flag)j = n-i+k-1;
            else j = i;
            swap(b[j],b[sta+i]);
        }
        rep(i,n)cout << b[i] << " ";
        cout << "\n";
    }else{
        cout << "No" << endl;
        
    }
    

    return 0;
}


Measured memory_bytes: 31248
import sys
N=int(input())
a=[[] for i in range(N)]
for i in range(N):
    a[i]=input()
    
for i in range(N):
    if i>0:
        if a[i-1][len(a[i-1])-1]!=a[i][0]:
            print("No")
            sys.exit()

for i in range(N):
    for j in range(1,N-i-1):
        if a[i] == a[N-j]:
                print("No")
                sys.exit()

print("Yes")

Measured memory_bytes: 3064
while True:
    nums = list(map(int, input().split()))
    
    if nums[0] == nums[1] == 0:
        break;
    if nums[0] > nums[1]:
        temp = nums[0]
        nums[0] = nums[1]
        nums[1] = temp
        
    print(nums[0], nums[1])




Measured memory_bytes: 5612
import math


def isPrime(n):
	if n == 2:
		return True

	if n < 2 or n % 2 == 0:
		return False

	i = 3
	while i <= math.sqrt(n):
		if n % i == 0:
			return False
		i = i + 2

	return True


num = int(input())
numbers = [int(input()) for i in range(num)]

count = 0
for i in range(num):
    if isPrime(numbers[i]) == True:
        count += 1
print(count)

Measured memory_bytes: 8176
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

struct sushi{
	ll t,d;
	bool operator<(const sushi& rhs) const{
		return d > rhs.d;
	}
};

int main(){
	ll n,k;
	cin >> n >> k;
	vector <sushi> arr(n);
	vector <ll> type(n+1,0);
	for (int z=0;z<n;z++){
		cin >> arr[z].t >> arr[z].d;
		type[arr[z].t]++;
	}
	ll tt = 0;
	for (int z=0;z<n;z++){
		if (type[arr[z].t] > 0) tt++;
	}
	sort(arr.begin(),arr.end());
	vector <bool> used(n,false);
	vector <ll> num(n+1,0);
	ll temp = 0;
	ll c = 0;
	ll current = k;
	for (int z=0;z<k;z++){
		temp += arr[z].d;
		num[arr[z].t]++;
		if (num[arr[z].t] == 1){
			c++;
		}
		used[z] = true;
	}
	ll ans = temp+c*c;
	bool ok = true;
		for (int i = current-1 ; i>-1; i--){
			if (current == n) break;
			if (num[arr[i].t] <= 1) continue;
			if (!used[i]) continue;
			temp -= arr[i].d;
			num[arr[i].t]--;
			used[i] = false;
			for (;current<n;current++){
				if (num[arr[current].t] == 0){
					temp += arr[current].d;
					c++;
					num[arr[current].t]++;
					used[current] = true;
					break;
				}
			}
			ans = max(ans,temp+c*c);
			if (c == tt) break;
		}
	
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 3328
s = gets.chomp.split(" ").map(&:to_s)
s = s[0]

if s =~ /^A[a-z]([Ca-z]+)[a-z]$/ then
  if  $1.chars.sort.join =~ /^C[a-z]*$/ then
    print "AC"
  else
    print "WA"
  end
else
  print "WA"
end


Measured memory_bytes: 1788
n,k=map(int,input().split())
d=[]
t=(n-1)*(n-2)//2
if t<k:
    print(-1)
    exit()
for i in range(2,n+1):
    d.append((1,i))
t-=k
for i in range(2,n):
    if t==0: break
    for j in range(i+1,n+1):
        d.append((i,j))
        t-=1
        if t==0: break
print(len(d))
for i in d:
    print(i[0],i[1])


Measured memory_bytes: 43120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    List<Integer> ls = new ArrayList<>();
    for (int i = 0; i < m; i++) {
      ls.add(sc.nextInt());
    }
    sc.close();
    List<Integer> prev = new ArrayList<>();
    List<Integer> next = new ArrayList<>();
    for (int i = 0; i < m; i++) {
      if (ls.get(i) > x) {
        next.add(ls.get(i));
      } else {
        prev.add(ls.get(i));
      }
    }
    if (next.size() >= prev.size()) {
      System.out.println(prev.size());
    } else {
      System.out.println(next.size());
    }
  }
}


Measured memory_bytes: 35632
#include <stdio.h>

int main(){
  int i,n,m,s[3]={-1,-1,-1},f=0,a,b;
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<m;i++){
 	scanf("%d %d",&a,&b);
    if((s[n-a]==-1)|(s[n-a]==b)){
      s[n-a]=b;
    }else{
      f=-1;
      break;
    }
  }
  if(f!=-1){
    if(n<3){
      if(s[2]>0){
        f==-1;
      }
      s[2]=0;
    }
    if(n==1){
      if(s[1]>0){
        f=-1;
      }
      s[1]=0;
    }
    if(s[2]==0){
      if(n==3){
      	f=-1;
      }else{
    	if(n==2){
          if(s[1]==0){
          	f=-1;
          }else if(s[1]==-1){
            s[1]=1;
          }
        }
      }
    }else if(s[2]==-1){
      if(n==3){
        s[2]=1;
      }
    }
  }
  for(i=0;i<3;i++){
	if(s[i]==-1){
      s[i]=0;
    }
  }
  if(f!=-1){
    f=s[2]*100+s[1]*10+s[0];
  }
  printf("%d",f);
  return(0);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,buc[30],num;
char read[110];
void sub1()
{
	for(int i = 1;i <= 26;i++)
	{
		num += buc[i] / 2;
		buc[i] %= 2;
	}
	if(n / 2 > num)
	{
		printf("No\n");
		return;
	}
	printf("Yes\n");
}
void sub2()
{
	for(int i = 1;i <= 26;i++)
	{
		num += buc[i] / 2;
		buc[i] %= 2;
	}
	if(m / 2 > num)
	{
		printf("No\n");
		return;
	}
	printf("Yes\n");
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++)
	{
		scanf("%s",read + 1);
		for(int j = 1;j <= m;j++)
			buc[read[j] - 'a' + 1]++;
	}
	if(m == 1 && n >= 1){sub1();return 0;}
	if(n == 1 && m > 1){sub2();return 0;}
	for(int i = 1;i <= 26;i++)
	{
		num += buc[i] / 4;
		buc[i] %= 4;
	}
	if((n / 2) * (m / 2) > num)
	{
		printf("No\n");
		return 0;
	}
	if(n % 2 == 1 || m % 2 == 1)
	{
		int cnt = 0;
		for(int i = 1;i <= 26;i++)if(buc[i] % 2)cnt++;
		if(cnt > 1)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>

using namespace std;

int main(){
    int N,f=1;
    cin>>N;
    int t[100005],x[100005],y[100005],zz;
    for(int i=0;i<N;i++){
        cin>>t[i]>>x[i]>>y[i];
        if(i==0){
            zz=x[i]+y[i];
            if(zz>t[i]){
                f=0;
            }
            else if(zz==t[i]){

            }
            else{
                zz=t[i]-zz;
                if(zz%2==0){

                }
                else{
                    f=0;
                }
            }

        }
        else{
            zz=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            if(zz>(t[i]-t[i-1])){
                f=0;
            }
            else if(zz==(t[i]-t[i-1])){

            }
            else{
                zz=(t[i]-t[i-1])-zz;
                if(zz%2==0){

                }
                else{
                    f=0;
                }
            }
        }
    }
    if(f){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 1408
import math
def q3():
    A, B, H, M = [int(i) for i in input().split(" ")]

    def get_pos(l, deg):
        x = l * math.cos(math.radians(deg))
        y = l * math.sin(math.radians(deg))
        return [x, y]

    def get_distance(pos1, pos2):
        return math.sqrt(
            math.pow(pos1[0] - pos2[0], 2) +
            math.pow(pos1[1] - pos2[1], 2)
        )

    pos_h = get_pos(A, 90 - ((H + M / 60) / 12) * 360)
    pos_m = get_pos(B, 90 - (M / 60) * 360)

    d = get_distance(pos_h, pos_m)
    print(d)

q3()


Measured memory_bytes: 9588
N_nin, K_ko = map(int, input().split())

index = [1 for i in range(N_nin)]

for i in range(K_ko):
    d = int(input())
    
    if (d != 1):
        A = list(map(int, input().split()))
        for a in A:
            temp = a - 1
            index[temp] = 0
    else:
        A = int(input()) - 1
        
        index[A] = 0
        

ans = sum(index)
print(ans)

Measured memory_bytes: 9116
S = input()

hoge = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

hoge2 = list(S)

differlen = len((set(hoge) ^ set(hoge2)))

differ2 = set(hoge) ^ set(hoge2)
differ3 = sorted(differ2)




if differlen == 0:
    print("None")
else:
    print(differ3[0])

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

#define INF 1e+9
#define MAX_N 40000
/*
ll dp[MAX_N];
ll n;
vector<ll> a;

int solve() {
    fill(dp, dp+n, INF);
    for (int i=0; i<n; ++i) {
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    return lower_bound(dp, dp+n, INF) - dp ;
}
vector <ll>h;
int main(){
  cin>>n;
  a.resize(n);
  ll tmp=0;
  rep(i,0,n){cin>>tmp;h.push_back(tmp);}
  irep(i,n-1,0)a.push_back(h[n-1-i]);
  ll k=solve();
  cout<<k;

}
*/





int main(){
  bool p=false;
  ll a,b;
  cin>>a>>b;
  ll ans=1,x=a;
  if(!p)while(x<b) {x+=a-1;ans++;}
  if(b==1)cout<<"0";
  else cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main( ){

  int x,x1,y,z,i,j,s=0,z1;

  scanf("%d%d",&x,&y);


  if(x<y){

    x1=x;
    x=y;
    y=x1;

  }

  z=x%y;

  while(z != 0){
    
    x=y;
    y=z;
    z=x%y;

  }
    
  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
   
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
   
   
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"
 

Measured memory_bytes: 6452
from copy import deepcopy

def main():
    n = int(input())
    p = list(map(int,input().split()))
    org = deepcopy(p)
    p.sort()

    count = 0

    for i in range(n):
        if p[i] != org[i]:
            count += 1

    if count <= 2:
        print("YES")
    else: 
        print("NO")


if __name__ == "__main__":
    main()



Measured memory_bytes: 38384
#include <stdio.h>

int main()
{
  int i, j, k, l, n, r;
  int m[101][101], p[101];

  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &p[i - 1] ,&p[i]);
  }

  for (i = 1; i <= n; i++) {
    m[i][i] = 0;
  }
  for (l = 2; l <= n; l++) {
    for (i = 1; i <= n - l + 1; i++) {
      j = i + l - 1;
      m[i][j] = 100000;
      for (k = i; k < j; k++) {
        r = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
        if (m[i][j] > r) {
          m[i][j] = r;
        }
      }
    }
  }

  printf("%d\n", m[i - 1][j]);

  return 0;
}

Measured memory_bytes: 636
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]
for i in range(N-1):
  L.append(gcd(L[i],A[i]))
  R.append(gcd(R[i],A[-i-1]))

max_gcd = 0
for i in range(N):
  max_gcd = max(max_gcd, gcd(L[i],R[-i-1]))

print(max_gcd)

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
  //  freopen("input.txt", "r", stdin);
    SPEED
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n);
    FOR(_, 0, k) {
        int d;
        cin >> d;
        FOR(i, 0, d) {
            int x;
            cin >> x;
            cnt[x - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += cnt[i] == 0;
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3648
def main():
    s = input()

    l = 0
    r = len(s) - 1

    ret = 0
    while l < r:
        lc, rc = s[l], s[r]

        if lc == rc:
            l += 1
            r -= 1
            continue

        if lc == 'x':
            ret += 1
            l += 1
            continue

        if rc == 'x':
            ret += 1
            r -= 1
            continue

        print(-1)
        return

    print(ret)


if __name__ == '__main__':
    main()


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  for(int i = 0; i < m; i++) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

//処理
  vector<int> dp(n+1);
  const int mod = 1000000007;
  dp[0] = 1;
  if(broken[1] == 0) { dp[1] = 1; }
  for(int i = 2; i < n+1; i++) {
    if(!broken[i]) {
      dp[i] = (dp[i-1] + dp[i-2]) % mod;
    }
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int f[200005],l[25],p[25],q[200005];
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>l[i]>>p[i];
	}
	f[1]=q[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			f[i]+=((q[max(i-l[j],0ll)]-q[max(i-p[j]-1,0ll)])%mod+mod)%mod;
			f[i]%=mod;
		}
		q[i]=q[i-1]+f[i];
		q[i]%=mod;
	}
	cout<<f[n]<<endl;;
	return 0;
}

Measured memory_bytes: 6720
using System;
using System.Collections.Generic;
using System.Linq;

public static class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var X = vals[1];
        var T = vals[2];

        var answer = N / X;
        if (N % X != 0)
        {
            answer++;
        }
        answer *= T;

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 28288
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long C = sc.nextLong();
		long K = sc.nextLong();
		long[] T = new long[N];
		for (int i = 0; i < N; ++i) {
			T[i] = sc.nextLong();
		}
		Arrays.sort(T);

		int ans = 0;
		for (int i = 0; i < N; ++i) {
			long departTime = T[i];
			long cnt = 1;
			while (i + 1 < N && cnt < C && departTime + K >= T[i + 1]) {
				++i;
				++cnt;
			}
			++ans;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 60216