akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
ll dp[100001],h[100001];
int k;

ll func(int x){
	if(dp[x]!=-1){
		return dp[x];
	}
	if(x==0){
		return 0;
	}
	dp[x]=func(x-1)+abs(h[x]-h[x-1]);
	for(int i=1;i<=k;i++){
		if(x>=i){
			dp[x]=min(dp[x],func(x-i)+abs(h[x]-h[x-i]));
		}
	}
	return dp[x];	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    MSET(dp,-1);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    cout<<func(n-1);

    
    

    return 0;
}




Measured memory_bytes: 6528
#include<stdio.h>

int main(void)
{
	int a,b,c,n=0;

	scanf("%d %d %d", &a,&b,&c);

	for (int x = a; x <= b; x++)
	{
		if (c%x==0)
		{
			n++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>

#define N 100000
#define Q 50000

int main(){
  int n,q;
  int s[N],t[Q];
  int cnt=0,i,left,right,mid;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&t[i]);

  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(s[mid]==t[i]){
	cnt++;
	break;
      }
      else if(t[i]<s[mid])right=mid;
      else left=mid+1;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    Vi a(n+1),b(n);
    rp(i,n+1) cin >> a.at(i);
    rp(i,n) cin >> b.at(i);
    ll sum=0;
    rp(i,n){
        if(b[i]>=a[i]){
            b[i]-=a[i];
            sum+=a[i];
        }else{
            sum+=b[i];
            b[i]=0;
        }
        if(a[i+1]>=b[i]){
            a[i+1]-=b[i];
            sum+=b[i];
        }else{
            sum+=a[i+1];
            a[i+1]=0;
        }
    }
    print(sum);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	if (a + b < 24) {
		cout << a+b << "\n";
	}
	else if (a + b >= 24) {
		cout << a + b - 24 << "\n";
	}
	std::cin >> e;
}

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

typedef signed long long ll;

int main() {
    string S, A, token;
    getline(cin, S);
    stringstream ss;
    ss << S;

    for(; getline(ss, token, ' ') ;) {
        A.push_back(token[0]);
    }

    cout << A << endl;

    return 0;
}

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

using namespace std;

const int   mod = 1e9 + 7;

int Pow(int a,int b)	{
	int ans = 1;

    while (b)	{
      	if(b & 1)	ans = 1ll * ans * a % mod;
      	a = 1ll * a * a % mod;	b >>= 1;
    }
  	return  ans;
}
void add(int &a,int b)	{
  	a += b;
  	if (a >= mod)
      	a -= mod;
}

int main()  {
	ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

  	int R;	cin >> R;
  	int C;	cin >> C;
  	int T;	cin >> T;

    int E = 1ll * __gcd(R,T) * __gcd(C,T) % (mod - 1);

    R /= __gcd(R,T);
    C /= __gcd(C,T);

    int ans = mod - 3;

  	add(ans,Pow(2,R));
  	add(ans,Pow(2,C));
  	add(ans,Pow(2,__gcd(R,C)));

   	cout << Pow(ans,E) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    // "Atcoder"は固定なので捨て
    scanner.next();

    // 二単語目の頭文字を取得
    char head = scanner.next().charAt(0);

    // "A" + head + "C" を出力
    System.out.println("A" + head + "C");
  }
}


Measured memory_bytes: 38676
#include<iostream>
#include<cstdio>
#include<vector>
#include<complex>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

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

typedef complex<double> P;

const double EPS = 1e-8;
inline double dot(P a, P b) {return real( conj(a)*b);}
inline double cross(P a, P b) {return imag( conj(a)*b);}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1;       // counter clockwise
  if (cross(b, c) < -EPS)   return -1;       // clockwise
  if (dot(b, c) < -EPS)     return +2;       // c--a--b on line
  if (norm(b) + EPS < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool IsIntersectSS(P a1, P a2, P b1, P b2) {
  return ccw(a1,a2,b1) * ccw (a1,a2,b2) <= 0 &&
    ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0;
}

enum { OUT, IN, ON };
int Contains(const vector<P>& Ps, P p) {
  bool in = false;
  int size = Ps.size();
  for (int i = 0; i < size; ++i) {
    P a = Ps[i] - p, b = Ps[(i+1)%size] - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

bool connect(const vector<P> &a, const vector<P> &b) {
  for(int i = 0; i < (int)a.size(); i++)
    for(int j = 0; j < (int)b.size(); j++)
      if( IsIntersectSS( a[i], a[(i + 1) % a.size()], b[j], b[(j + 1) % b.size()]) )
        return true;
  for(int i = 0; i < (int)a.size(); i++)
    if(Contains( b, a[i] ) ) return true;
  for(int i = 0; i < (int)b.size(); i++)
    if(Contains( a, b[i] ) ) return true;
  return false;
}

int table[128][128];
int visited[128];
void dfs(int p, int N) {
  if( visited[p] ) return;
  visited[p] = 1;
  REP(i, N) if( table[p][i] ) dfs(i, N);
}

void input(vector<P> &v) {
  v.clear();
  REP(k, 4) {
    int x, y; cin >> x >> y;
    v.push_back( P(x, y) );
  }
  reverse(v.begin(), v.end());
}

int solve(int N) {
  vector<P> v[N];
  REP(i, N) input(v[i]);

  REP(i, N) REP(j, N) table[i][j] = 0;

  REP(i, N) REP(j, i) {
    if( connect( v[i], v[j] ) )
      table[i][j] = table[j][i] = 1;
  }

  REP(i, N) visited[i] = 0;
  int cnt = 0;
  REP(i, N) {
    if( !visited[i] ) {
      cnt++;
      dfs(i, N);
    }
  }
  return cnt;
}

int main() {
  for(;;) {
    int N; cin >> N; if( N == 0 ) break;
    REP(i, N) {
      int M; cin >> M;
      int res = solve(M);
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 988
N,M = gets.split.map(&:to_i)
a,b = N.times.map { gets.split.map(&:to_i) }.transpose
c,d = M.times.map { gets.split.map(&:to_i) }.transpose

N.times do |i|
  min_m = 999999999999999
  min_idx = 0
  M.times do |j|
    m = (a[i]-c[j]).abs + (b[i]-d[j]).abs
    # 最小CPが複数あった場合に、番号が小さいものが優先される
    if m < min_m
      min_m = m
      min_idx = j+1
    end
  end
  p min_idx
end

Measured memory_bytes: 1788
<?php
fscanf(STDIN,"%d %d %d",$N,$H,$W);

$count=0;
for ($i=0;$i<$N;$i++){
 fscanf(STDIN,"%d %d",$A,$B);
 if ($H<=$A && $W<=$B) $count++;
}

echo $count."\n";

Measured memory_bytes: 3828
use std::cmp;
use std::collections::{BTreeMap, VecDeque};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let l: usize = sc.read();
    let n = sc.read();
    let x: Vec<usize> = sc.read_vec(n);
    let y: Vec<usize> = x.iter().map(|&x| l - x).rev().collect();
    let ans = cmp::max(solve(x, l), solve(y, l));
    println!("{}", ans);
}

fn solve(x: Vec<usize>, l: usize) -> usize {
    let n = x.len();
    let mut left = vec![0; n + 1];
    for i in 0..n {
        left[i + 1] = left[i] + (l - x[n - 1 - i]) * 2;
    }
    let mut right = vec![0; n + 1];
    for i in 0..n {
        right[i + 1] = right[i] + x[i] * 2;
    }

    let mut ans = 0;
    for i in 0..n {
        let rest = n - i;
        let left_count = rest / 2;
        let right_count = rest - left_count;
        let left_sum = left[left_count];
        let right_sum = right[n - left_count] - right[i];
        let last = if right_count > left_count {
            x[n - left_count - 1]
        } else {
            l - x[n - left_count]
        };
        let sum = left_sum + right_sum - last;
        ans = cmp::max(ans, sum);
    }
    ans
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
void abc042_a(){
    ll A,B,C; cin >> A >> B >> C;
    if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;}
    if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;}
    if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;}
    cout << "NO" << endl; return ;
}
// https://abc043.contest.atcoder.jp/tasks/abc043_a
void abc043_a(){
    ll N; cin >> N; cout << N*(N+1)/2 << endl;
}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
void abc046_a(){
    ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    abc046_a();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807
#define N 4
#define NN 16
#define LIMIT 100

struct Pazzle
{
    int f[NN], space, MD;
};

int MDT[NN][NN];
int limit;
int ans;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
Pazzle state;

int calcAllMD(Pazzle p)
{
    int ret = 0;
    for (int i = 0; i < NN; i++)
    {
        if (p.f[i] == NN)
            continue;
        ret += MDT[i][p.f[i] - 1];
    }
    return ret;
}

bool dfs(int depth, int prev)
{
    if (state.MD == 0)
    {
        ans = depth;
        return true;
    }

    if (state.MD + depth > limit)
        return false;

    int sx = state.space / N;
    int sy = state.space % N;

    Pazzle tmp;

    for (int i = 0; i < 4; i++)
    {
        int tx = sx + dx[i];
        int ty = sy + dy[i];

        if (tx < 0 || tx >= N || ty < 0 || ty >= N)
            continue;
        if (abs(prev - i) == 2)
            continue;

        tmp = state;
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(state.f[tx * N + ty], state.f[sx * N + sy]);
        state.space = tx * N + ty;
        state.MD = calcAllMD(state);
        if (dfs(depth + 1, i))
            return true;
        state = tmp;
    }

    return false;
}

void iterativeDeepening(Pazzle in)
{
    in.MD = calcAllMD(in);

    for (limit = in.MD; limit <= LIMIT; limit++)
    {
        state = in;
        if (dfs(0, -100))
        {
            cout << ans << endl;
            return;
        }
    }
}

signed main()
{
    for (int i = 0; i < NN; i++)
        for (int j = 0; j < NN; j++)
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

    Pazzle in;

    for (int i = 0; i < NN; i++)
    {
        cin >> in.f[i];
        if (in.f[i] == 0)
        {
            in.f[i] = NN;
            in.space = i;
        }
    }

    iterativeDeepening(in);
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int max=0;
    int sum=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        sum+=a;
        if(max<a){
            max=a;
        }
    }
    if(sum-max>max){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    char o[51], e[51], a[101];
    int olen, elen;

    scanf("%s", o);
    scanf("%s", e);

    olen = strlen(o);
    elen = strlen(e);
    for(int i = 0; i < olen; i++) a[i*2] = o[i];
    for(int i = 0; i < elen; i++) a[i*2+1] = e[i];
    
    a[olen + elen] = '\0';

    printf("%s\n", a);    

    return 0;
}

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

int main() {

  while (1) {

    string s;
    cin >> s;

    if (s == "-") {
      return 0;
    }

    int m;
    cin >> m;

    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;
      string s_ = s.substr(0, h);
      string b_ = s.substr(h, s.size() - h);
      s = b_ + s_;
    }

    cout << s << endl;

  }

  return 0;

}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

vector<vector<int>> f(const vector<vector<int>>& dist) {
    int n = dist.size() - 1;
    vector<vector<int>> res(n + 1, vector<int>(n + 1, 0x3f3f3f3f));
    for (int i = 1; i <= n; i++) {
        res[i][i] = 0;
        priority_queue<pair<int, int>> pq;
        pq.push(make_pair(0, i));
        while (pq.size() > 0) {
            auto p = pq.top();
            pq.pop();
            int d = -p.first, index = p.second;
            if (res[i][index] < d) continue;
            for (int j = 1; j <= n; j++) {
                if (res[i][j] > res[i][index] + dist[index][j] && dist[index][j] > 0) {
                    res[i][j]  = res[i][index] + dist[index][j];
                    pq.push(make_pair(-res[i][j], j));
                }
            }
        }
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> path;
    vector<vector<int>> dist(n + 1, vector<int>(n + 1, -1));
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        path.push_back({a, b, c});
        dist[a][b] = c;
        dist[b][a] = c;
    }
    int res = 0;
    auto min_dist = f(dist);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        a = path[i][0];
        b = path[i][1];
        c = path[i][2];
        int flag = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i == j) continue;
                if (min_dist[i][a] + c + min_dist[b][j] == min_dist[i][j]) {
                    flag = 1;
                    break;
                }
                if (min_dist[i][b] + c + min_dist[a][j] == min_dist[i][j]) {
                    flag = 1;
                    break;
                }
            }
        }
        res += 1- flag;
    }
    cout << res << endl;
}


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

int main(){
    int n;
    cin >> n;
    int a, db = 0, sq = 0;
    bool flg = false;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a % 4 == 0){
            sq++;
        }
        else if(a % 2 == 0){
            db++;
        }
    }

    if(db == 0){
        if(n <= sq*2+1){
            flg = true;
        }
    }
    else{
        if(n-db <= sq*2){
            flg = true;
        }
    }
    
    if(flg){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
ll f(ll l,ll r)
{
    ll mn=2019;
    for(int i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){
            //cout<<"for ("<<i<<","<<j<<") : "<<(i*j%2019)<<endl;
            mn = min(mn,1LL*(i%2019*j%2019)%2019);
        }
    }
    return mn;
}
int ok[2025];
int main ()
{
    int l,r;
    cin >> l >> r;
    for(int i=0;i<2019;i++){
            for(int j=i;j<=r;j+=2019){
                if(j>=l&&j<=r){
                    ok[i]=1;
                    //cout<<i
                    break;
                }
            }
    }
    //for(int i=0;i<2019;i++)if(ok[i])cout<<i<<endl;
    //cout<<"ans = "<<f(l,r)<<endl;
    ll mn=1e9;
    for(int i=0;i<2019;i++){
        for(int j=i+1;j<2019;j++){
            if(ok[i]&&ok[j]){
               mn = min(mn,(ll)(i*j)%2019);
                //return 0;
            }
        }
    }
    cout<<mn<<endl;
    return 0;
}
/*
1 2020
*/


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

int main() {
    int x,y;
    string op;
    for(int i = 0; i < 100000; i++){
        cin >> x >> op >> y;
        if(op == "+")cout << x + y << endl;
        if(op == "-")cout << x - y << endl;
        if(op == "*")cout << x * y << endl;
        if(op == "/")cout << x / y << endl;
        if(op == "?")break;
        
    }
}


Measured memory_bytes: 3148
from collections import defaultdict
from collections import deque

N, K=map(int, input().split())
A=list(map(int, input().split()))
for i in range(N):
    A[i]-=1
s=[0 for _ in range(N+1)]
for i in range(N):
    s[i+1]=(s[i]+A[i])%K
d=defaultdict(int)
ans=0
q=deque()
for j in range(N+1):
    ans+=d[s[j]]
    d[s[j]]+=1
    q.append(s[j])
    if len(q)==K:
        d[q[0]]-=1
        q.popleft()
print(ans)

Measured memory_bytes: 113140
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

void brute(lint  n, lint k, vector< lint > & a) {
  lint z = 0;
  for (lint i=0; i<k; ++i) {
    vector< lint > an(n, 0);
    for (lint j=0; j<n; ++j) {
      for (lint p=max(z, j-a[j]); p <=min(n-1, j+a[j]); ++p) {
	an[p]++;
      }
    }
    lint cur = 0;
    for (lint j=0; j<n; ++j) {
      if (an[j]==n) cur++;
      a[j] = an[j];
    }
    if (cur == n) break;
  }
  for (lint i=0; i<n; ++i) cout << a[i] << " ";
  cout << endl;
}

void brute_lr(lint  n, lint k, vector< lint > & a) {
  lint z = 0;
  vector< lint > an(a);
  for (lint i=0; i<k; ++i) {
    vector< lint > l(n, 0), r(n+1, 0);
    for (lint j=0; j<n; ++j) {
      lint li = max(z, j-an[j]);
      lint ri = min(n, j+an[j]+1);
      l[li]++;
      r[ri]++;
    }
    lint c = 0;
    lint cur = 0;
    for (lint j=0; j<n; ++j) {
      c += l[j]-r[j];
      an[j] = c;
      if (c == n) cur++;
    }
    if (cur == n) break;
  }
  for (lint i=0; i<n; ++i) cout << an[i] << " ";
  cout << endl;
}

void plr(vector< lint > & l, vector< lint > & r) {
  lint cur = 0;
  /*
  for (lint i=0; i<l.size(); ++i) {
    cout << l[i] << " " << r[i] << endl;
  }
  */
  for (lint i=0; i<l.size(); ++i) {
    cur += l[i]-r[i];
    cout << cur << " ";
  }
  cout << endl;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint n, k, z=0;
  cin >> n >> k;
  vector< lint > a(n);
  for (lint i=0; i<n; ++i) cin >> a[i];
  brute_lr(n, k, a);
  return 0;
}


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,r,l, i,s=0;
  cin >> N;
  
  for(i=0; i<N; i++){
  	cin >> l >> r;
    s += r-l+1;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n+1], s[n+1], minn=99999999;
	s[0]=0;
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
		s[i]=s[i-1]+a[i];
	}
	for (int i=1; i<=n; i++)
		minn=min(abs(s[n]-s[i-1]-s[i-1]),minn);
	cout << minn << endl;
	return 0;
}

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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
    ll a[3][3], b[3][3], n, i, j, k;
    string ans = "No";
    fo(i,3)fo(j,3){cin>>a[i][j];b[i][j]=0;}
    cin>>n;
    fo(i,n) {
        ll p;cin>>p;
        fo(j,3)fo(k,3)if(a[j][k]==p)b[j][k]=1;
    }
    fo(i,3) {
        ll f = 1;
        fo(j,3)if(b[i][j]==0)f=0;
        if(f==1)ans="Yes";
    }
    fo(i,3) {
        ll f = 1;
        fo(j,3)if(b[j][i]==0)f=0;
        if(f==1)ans="Yes";
    }
    if(b[0][0]==1 and b[1][1]==1 and b[2][2]==1)ans="Yes";
    if(b[0][2]==1 and b[1][1]==1 and b[2][0]==1)ans="Yes";
    cout<<ans;
}

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

Measured memory_bytes: 256
N = int(input())
height = list(map(int, input().split()))

dp = [0]
cost_initial = abs(height[1] -height[0])
dp.append(cost_initial)

#print(dp)
#for h in height:

for i in range(len(height)-2):
    a1 = dp[i+1] + abs(height[i+2] - height[i+1])
    a2 = dp[i] + abs(height[i+2] - height[i])
    dp.append(min(a1, a2))

print(dp[-1])

Measured memory_bytes: 55280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //int test = Integer.parseInt(scan.next());
        //int ok = Integer.parseInt(scan.next());
        //int c = Integer.parseInt(scan.next());
//        int cnt = 0;
//        while(h>0) {
//            h = h-a;
//            cnt++;
//        }
//        if(test == ok) {
//            System.out.println("Yes");
//        } else {
//            System.out.println("No");
//        }
        String C = scan.next();
        System.out.println((char)(C.charAt(0)+1));
    }
}


Measured memory_bytes: 21716
N, M = gets.split.map(&:to_i)
SC = M.times.map do
  s, c = gets.split.map(&:to_i)
  [s - 1, c]
end

table = {}
SC.each do |s, c|
  if table[s] && table[s] != c
    puts '-1'
    exit 0
  end
  table[s] = c
end

if table[0] == 0 && N > 1
  puts '-1'
  exit 0
end

ans = []
N.times do |i|
  if table[i]
    ans.push(table[i])
  else
    if i == 0
      if N > 1
        ans.push(1)
      else
        ans.push(0)
      end
    else
      ans.push(0)
    end
  end
end
puts ans.join('')

Measured memory_bytes: 1788
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(a-b)<=d && abs(b-c)<=d)||(abs(a-c)<=d))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A, B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
S=input()
if S=="ARC":
    print("ABC")
else:
    print("ARC")


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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(auto x : mp) {
        ans += (ll) x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11284
N,K = map(int,input().split())

if N >= K:
    a = N//K
    N -= K*a

b = min(N,K)
for i in range(100000):
    if b > max(N,K)-min(N,K):
        b = max(N,K)-min(N,K)
    else:
        break

print(b)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int ans=n*800-(n/15)*200;
  cout<<ans<<endl;
}

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

int main()
{
  int n,m,x;
  cin >> n >> m >> x;
  
  int a[m];
  rep(i,m) cin >> a[i];
  
  int right = 0;
  for(int i = x; i <= n; i++){
    for(int j = 0; j < m; j++){
      if(i == a[j]){
      right++;
      }
    }
  }
  
  int left = 0;
  for(int i = x; i >= 0; i--){
    for(int j = 0; j < m; j++){
      if(i == a[j]){
        left++;
      }
    }
  }
  
  cout << min(right,left) << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
//g++ -std==c++14
//setprecision(10)
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        if(i % 2 == 0)
            cout << s[i];
    cout << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}
 
int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))

t=['W']*n

for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        t[b-1]='L'
    if h[a-1]<=h[b-1]:
        t[a-1]='L'
print(t.count('W'))

Measured memory_bytes: 19920
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int n;
int k;
int h[100000];
int dp[100001];

int main(){
  scanf("%d%d", &n, &k);
  for(int i = 0; i < n; i++)
    scanf("%d", h+i);

  dp[1] = std::abs(h[1] - h[0]);
  for(int i = 1; i < n; i++){
    dp[i] = dp[i-1] + std::abs(h[i] - h[i-1]);
    for(int j = 2; j <= std::min(k, i); j++){
      dp[i] = std::min(dp[i], dp[i-j] + std::abs(h[i] - h[i-j]));
    }
  }

  printf("%d\n", dp[n-1]);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--) 
 
signed main(){
    fast;
    int n, w;
    cin >> n >> w;
    if(w>=n)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 11
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

char S[MAX_N];

void solve()
{
  int ans = INT_MAX;
  int n = strlen(S);
  for (int i = 0; i <= n - 3; i++) {
    int a = 0;
    int k = 0;
    while (k < 3) {
      a += (S[i + k] - '0') * (int)pow(10, 2 - k);
      k++;
    }
    ans = min(ans, abs(753 - a));
  }
  cout << ans << endl;
}

int main(void)
{
  cin >> S;
  solve();
  return 0;
}


Measured memory_bytes: 256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  return ~~((a,b)=>Math.max(a+a-1,a+b,b+b-1))(intShift(),intShift());
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5 3
`);

Measured memory_bytes: 22076
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
// const int INF = +100100100;
// typedef pair<int,int> P;

// int dp(int i, int j, string x, string y, char D[MAX][MAX]){
//     if(x[i-1]==y[j-1])return D[i-1][j-1]+1;
//     else{
//         return max(D[i-1][j],D[i][j-1]);
//     }
// }

int lcs(string x, string y){
    int D[x.size()+1][y.size()+1];
    rep(i,x.size()+1)D[i][0]=0;
    rep(i,y.size()+1)D[0][i]=0;
    rrep(i,x.length()){
        rrep(j,y.length()){
            if(x[i-1]==y[j-1])D[i][j]= D[i-1][j-1]+1;
            else{
                D[i][j]= max(D[i-1][j],D[i][j-1]);
            }
        }
    }
    int ans = D[x.length()][y.length()];
    return ans;
}

int main(){
    int n;cin>>n;
    rep(i,n){
        string x,y;
        cin >> x >> y;
        printf("%d\n",lcs(x,y));
    }
    return 0;
}


Measured memory_bytes: 7140
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<(n); i++)

int main(){

    int N,X,T,n=0,ans=0;
    cin>>N>>X>>T;

    while(1){
        ans+=T;
        n+=X;
        if(n>=N) break;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  I(N);
  vl A(N);
  vl B(N);
  REP(i, N) {
    I(A[i]);
    I(B[i]);
  }
  sort(ALL(A));
  sort(ALL(B));
  if (N % 2 == 1) {
    ll a = A[N/2];
    ll b = B[N/2];
    if (b >= a) {
      P(b - a + 1);
    } 
  } else {
    ll a = A[N/2-1] + A[N/2];
    ll b = B[N/2-1] + B[N/2];
    if (b >= a) {
      P(b - a + 1);
    }
  }

}


Measured memory_bytes: 6428
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long D, G;
	cin >> D >> G;
	vector<long long>P(D), C(D);
	for (long long i = 0; i < D; i++) {
		cin >> P.at(i) >> C.at(i);
	}
	long long ans = 1e9;
	for (long long i = 0; i < (1 << D); i++) {
		long long num = 0, sum = 0, mx = -1;
		vector<bool>A(D, false);
		for (long long j = 0; j < D; j++) {
			if (i & (1 << j)) {
				num += (100 * j + 100) * P.at(j) + C.at(j);
				sum += P.at(j);
			}
			else {
				mx = j;
			}
		}
		if (num < G) {
			int score = 100 * (mx + 1);
			int prob = (G - num) / score;
			if ((G - num) % score != 0) prob++;
			if (prob > P.at(mx)) continue;
			sum += prob;
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# 高橋くんと見えざる手
n, t = map(int, input().split())
a = list(map(int, input().split()))

max_value = [[0, n] for i in range(n + 1)]

# max_value[i]=後ろからi番目までの値で最も大きい値
for i in range(1, n + 1):
    num = a[-i]
    if max_value[i - 1][0] < num:
        max_value[i][0] = num
        max_value[i][1] = n + 1 - i
    else:
        max_value[i] = max_value[i - 1]


min_value = [10**10 for i in range(n + 1)]
# min_value[i]=初めからi番目までの値で最も小さい値
for _ in range(n):
    x = a[_]
    min_value[_ + 1] = min(min_value[_], x)

max_dif = 0
for i in range(1, n + 1):
    if max_value[i][0] > min_value[n - i]:
        max_dif = max(max_dif, max_value[i][0] - min_value[n - i])


disk = []
for i in range(1, n + 1):
    base = a[i - 1]
    if base + max_dif == max_value[n - i][0]:
        disk.append((i, max_value[n - i][1]))

######


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


uni = UnionFind(n)
for some in disk:
    a, b = some[0], some[1]
    uni.union(a, b)
for i in range(n + 1):
    uni.find(i)

# UnionFind

group = {i: [] for i in range(n + 1)}

for i in range(n + 1):
    group[uni.par[i]].append(i)
ans = 0
for i in range(n + 1):
    L = len(group[i])
    ans += L * (L - 1) // 2
print(ans)


Measured memory_bytes: 45068
A,B,K=map(int,input().split())


def D(n):
    S=set()
    for i in range(1,n+1):

        if n / i ==  n // i:

            S.add(i)
    return S


A=D(A)
B=D(B)

A&=B
A=list(A)
A.sort(reverse=True)

print(A[K-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n ;
    cin >> n ;
    int count = 0 ;
    int arr[101] = {0};
    for ( int i = 1 ; i <= n ; i++)
    {
        cin >> arr[i] ;
    }
    for ( int i = 1 ; i <= n ; i++)
    {
        if (i%2==1 and arr[i]%2==1)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3532
import java.util.Scanner;

public class Main {
    public static void main(String... args){
        Scanner scanner = new Scanner(System.in);
        String[] a = scanner.nextLine().split("");
        String[] b = scanner.nextLine().split("");
        String[] c = scanner.nextLine().split("");
        System.out.println(a[0] + b[1] + c[2]);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;



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

int N;
cin >> N;
map<int, int> mp;
rep(i,N) {
    cin >> mp[i];
    mp[i]--;
}
int cnt = 0;
int v = 0;
while(true) {
    v = mp[v];
    cnt++;
    if(v == 1) break;
    if(cnt == 2*N) {
        cout << -1 << endl;
        return 0;
    }
}
cout << cnt << endl;
return 0;
}

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

namespace ABC093_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var D = aaa[0];
            var X = aaa[1];
            var ans = 0;

            for(var i=0;i<N;i++)
            {
                var num = int.Parse(Console.ReadLine());
                var sss = 0;
                var j = 0;

                while (sss <= D)
                {
                    sss = num * j + 1;
                    if (sss <= D)
                        ans++;
                    j++;
                }
            }

            Console.WriteLine(ans + X);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans=0;
	cin >> a >> b;
	for(int i=a;i <= b;i++)
		if(i/10000 == i%10 && i/1000%10 == i%100/10)
			ans++; 
	cout << ans;
	return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    double arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        arr[i] = (arr[i]+1)/2;
    }
    double pref[n];
    for(int i=0; i<n; i++)
    {
        pref[i] = arr[i];
        if(i)
            pref[i] += pref[i-1];
    }
    double mx = pref[k-1];
    for(int i=0; i<n-k; i++)
    {
        mx = max(mx, pref[i+k] - pref[i]);
    }
    cout << setprecision(15) << mx;
    return 0;
}



Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int H, R;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> R;

    if (H < -R) cout << -1 << endl;
    else if (H == -R) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 3212
import collections
N = int(input())
ans = 0


def prime_decomposition(n):
    i = 2
    ret = collections.defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret[i] += 1
        i += 1
    if n > 1:
        ret[n] = 1
    return ret


factors_dict = prime_decomposition(N)
factors_values = list(factors_dict.values())
factors_keys = list(factors_dict.keys())
factors = []
import itertools
for K in itertools.product(*[range(_ + 1) for _ in factors_values]):
    f = 1
    for i in range(len(factors_keys)):
        f *= factors_keys[i]**K[i]
    factors += [f]
ans = 0
for f in factors:
    if N < f * (f - 1):
        ans += f - 1
print(ans)


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int a,b,c;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);


cin>>a>>b>>c;

if(a+b==c){
	cout<<"Yes"<<endl;
	return 0;
}
if(b+c==a){
	cout<<"Yes"<<endl;
	return 0;
}
if(a+c==b){
	cout<<"Yes"<<endl;
	return 0;
}
cout<<"No"<<endl;

}



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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int r;
  cin >> r;
  cout << r*r;

  return 0;
}






// Coded by Z..

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,n2=1,q,a[100010],b[100010],c[100010],d[100010],x[100010],y[100010],u[100010],v[100010],
depth[100010],par[100010],num[100010],st[100010],ed[100010],top[100010],heavy[100010],len=0,
ans[100010];
vector <int> g[100010],edg[100010],que[100010];

int dfs(int pos,int no,int d)
{
	depth[pos]=d;
	par[pos]=no;
	st[pos]=len++;
	int mx=0,tmp,ret=1;
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		tmp=dfs(g[pos][i],pos,d+1);
		ret+=tmp;
		if(tmp>mx)
		{
			mx=tmp;
			heavy[pos]=i;
		}
	}
	ed[pos]=len-1;
	return ret;
}

void dfs2(int pos,int no,int tp)
{
	top[pos]=tp;
	num[pos]=len++;
	if(heavy[pos]==-1) return;
	dfs2(g[pos][heavy[pos]],pos,tp);
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no||i==heavy[pos]) continue;
		dfs2(g[pos][i],pos,g[pos][i]);
	}
}

struct SegTree
{
	int dat[400010];
	
	void upd(int k,int val)
	{
		dat[k]+=val;
		while(k>0)
		{
			k=(k-1)/2;
			dat[k]+=val;
		}
	}
	
	int query(int k,int lb,int ub,int tlb,int tub)
	{
		if(ub<tlb||tub<lb) return 0;
		if(tlb<=lb&&ub<=tub) return dat[k];
		return query(k*2+1,lb,(lb+ub)/2,tlb,tub)+query(k*2+2,(lb+ub)/2+1,ub,tlb,tub);
	}
}sum,cnt;

int add(int xx,int yy)
{
	//cout<<xx<<' '<<yy<<endl;
	if(depth[xx]<depth[yy]) swap(xx,yy);
	if(top[xx]==top[yy]) return sum.query(0,0,n2-1,num[yy]+1,num[xx]);
	if(st[top[xx]]<=st[yy]&&ed[yy]<=ed[top[xx]])
	return sum.query(0,0,n2-1,num[top[yy]],num[yy])+add(xx,par[top[yy]]);
	return sum.query(0,0,n2-1,num[top[xx]],num[xx])+add(par[top[xx]],yy);
}

int add2(int xx,int yy)
{
	if(depth[xx]<depth[yy]) swap(xx,yy);
	if(top[xx]==top[yy]) return cnt.query(0,0,n2-1,num[yy]+1,num[xx]);
	if(st[top[xx]]<=st[yy]&&ed[yy]<=ed[top[xx]])
	return cnt.query(0,0,n2-1,num[top[yy]],num[yy])+add2(xx,par[top[yy]]);
	return cnt.query(0,0,n2-1,num[top[xx]],num[xx])+add2(par[top[xx]],yy);
}

int main()
{
	cin>>n>>q;
	rep(i,n-1)
	{
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
		edg[c[i]].pb(i);
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	rep(i,q)
	{
		scanf("%d%d%d%d",&x[i],&y[i],&u[i],&v[i]);
		que[x[i]].pb(i);
	}
	rep(i,100005) heavy[i]=-1;
	dfs(1,0,0);
	len=0;
	dfs2(1,0,1);
	//repn(i,n) cout<<top[i]<<endl;
	while(n2<n) n2*=2;
	rep(i,n-1)
	{
		if(depth[a[i]]<depth[b[i]]) swap(a[i],b[i]);
		sum.upd(num[a[i]]+n2-1,d[i]);
	}
	rep(i,q) ans[i]=add(u[i],v[i]);
	rep(i,400005) sum.dat[i]=0;
	repn(i,n-1)
	{
		//cout<<i<<endl;
		rep(j,edg[i].size())
		{
			sum.upd(num[a[edg[i][j]]]+n2-1,d[edg[i][j]]);
			cnt.upd(num[a[edg[i][j]]]+n2-1,1);
		}
		rep(j,que[i].size())
		ans[que[i][j]]+=add2(u[que[i][j]],v[que[i][j]])*y[que[i][j]]-add(u[que[i][j]],v[que[i][j]]);
		rep(j,edg[i].size())
		{
			sum.upd(num[a[edg[i][j]]]+n2-1,-d[edg[i][j]]);
			cnt.upd(num[a[edg[i][j]]]+n2-1,-1);
		}
	}
	rep(i,q) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30336
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<chrono>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K;
ll A[100010],B,C,D,X,Y;
ll ans=0;
string S,T,U;
ll F[100010];
bool ok=true;
ll Q;
map<ll,ll> G;
ll Z[]={1,2,3,6,7,8,9,0};

int main(){
    cin>>N;
    REP(i,N){
        cin>>A[i];
        ans+=A[i];
        G[A[i]]++;
    }
    cin>>Q;
    REP(i,Q){
        ll a,b;
        cin>>a>>b;
        ans+=(b-a)*G[a];
        G[b]+=G[a];
        G[a]=0;
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
using namespace std;
using point = complex<double>;
double f(point A, point B, point C)
{
    double a = abs(B - C), b = abs(C - A), c = abs(A - B);
    point I = (a*A + b*B + c*C) / (a+b+c);
    double S = abs(imag(conj(B - A) * (C - A))) / 2;
    double r = 2 * S / (a + b + c);
    double ok = 0.0, ng = 1.0;
    for (int i = 0; i < 100; i++) {
        double mid = (ok + ng) / 2;
        point p = A + (I - A) * mid, q = B + (I - B) * mid;
        if (abs(p - q) > 2 * r * mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return r * ok;
}
point input() { double real, imag; cin >> real >> imag; return point(real, imag); }
int main()
{
    point p1 = input(), p2 = input(), p3 = input();
    cout << fixed << setprecision(12);
    cout << max({ f(p1, p2, p3), f(p2, p3, p1), f(p3, p1, p2) }) << '\n';
    return 0;
}


Measured memory_bytes: 256