akhauriyash/Code-Regression huggingface dataset:
import sys
N,M=map(int,input().split())
table=[set() for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    table[a].add(b)
for x in table[0]:
    if N-1 in table[x]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 78924
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"5 7 5
" => r"7",

r"1 1 7
" => r"7",

r"-100 100 100
" => r"-100"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
        c: i32,
    }

    if a == b {
        c.to_string()
    } else {
        if a == c {
            b.to_string()
        } else {
            a.to_string()
        }
    }
}


Measured memory_bytes: 4476
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

vvi edges;
vector<bool> visited;

void dfs(int x) {
  if (visited[x]) return;
  visited[x] = true;

  rep (i, edges[x].size()) {
    dfs(edges[x][i]);
  }
}

int main() {
  int n, m; cin >> n >> m;
  edges.resize(n);
  visited.assign(n, false);
  int ans = 0;
  rep(i, m) {
    int x, y, z; cin >> x >> y >> z;
    x--; y--;
    edges[x].pb(y);
    edges[y].pb(x);
  }
  rep(i, n) {
    if (!visited[i]) {
      dfs(i);
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>

int D[50];

int main(){
  int n, m, i;
  scanf("%d%d", &n, &m);
  for(i=0;i<m;i++){
    int x, y;
    scanf("%d%d",&x,&y);
    D[x-1]++;
    D[y-1]++;
  }
  for(i=0;i<n;i++) printf("%d\n", D[i]);
  return 0;
}


Measured memory_bytes: 128
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/fenwicktree>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int n,q; cin >> n >> q;
    ac::fenwick_tree<ll> ft(n);
    rip(i,n,0) {
        int a; cin >> a;
        ft.add(i, a);
    }
    rip(i,q,0) {
        int id, p,x; cin >> id  >>  p >> x;
        if(id) {
            printf("%lld\n", ft.sum(p, x));
        }
        else{
            ft.add(p ,x);
        }
    }
}

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

bool primeCheck(int n, int k) {
  if (k == 1) return true;
  return (n % k != 0) && primeCheck(n, k - 1);
}

int leastPrime(int n) {
  return primeCheck(n, sqrt(n))? n: leastPrime(n + 1);
}

int main() {
  int n; cin >> n;
  cout << leastPrime(n);
  return 0;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int n,a,b;
	cin>>n>>a>>b;
	if(a%n==0){
		cout<<"OK";
	}
	else if(a+(n-a%n)<=b){
		cout<<"OK";
	}
	else cout<<"NG";
}

Measured memory_bytes: 3512
#include<iostream>
#include<tuple>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int t,p,r,tid,pid,time;
  string mess;
  cin >>t >>p>>r;
  while(t!=0){
    //           ans time id
    vector<tuple<int,int,int> > teams;
    int wrong[t][p];
    for(int i=0;i<t;i++){
      for(int j=0;j<p;j++){
        wrong[i][j]=0;
      }
      teams.push_back(make_tuple(0,0,-(i+1)));
    }
    for(int i=0;i<r;i++){
      cin >> tid>>pid>>time>>mess;
      tid--;
      pid--;
      if(mess=="CORRECT"){
        get<0>(teams[tid]) += 1;
        get<1>(teams[tid]) += wrong[tid][pid]*1200+time;
      }else{
        wrong[tid][pid]++;
      }
    }
    for(int i=0;i<t;i++){
      get<1>(teams[i])*=-1;
    }
    sort(teams.begin(),teams.end(),greater<tuple<int,int,int> >());
    for(int i=0;i<t;i++){
      int id=-get<2>(teams[i]);
      cout << id<< " "<<(get<0>(teams[i]))<< " "<<-get<1>(teams[i])<<endl;
    }
    cin >>t >>p>>r;
  }
}



Measured memory_bytes: 3152
import sys
def input():
	return sys.stdin.readline().strip()

M, D = list(map(int, input().split()))

num = 0
for m in range(1, M + 1):
	for d in range(22, D + 1):
		d1 = d % 10
		d2 = (d - d1) // 10
		if d1 * d2 == m and d1 >= 2:
			num += 1

print(num)

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

int main() {
  int n, k, r, s, p;  cin>>n>>k>>r>>s>>p;
  string t;  cin>>t;
  int ans=0;
  rep(i, n) {
    if (i<k) {
      if (t[i]=='r') ans += p;
      else if (t[i]=='s') ans += r;
      else ans += s;
    }
    else {
      if (t[i]==t[i-k]) t[i]='z';
      else {
        if (t[i]=='r') ans += p;
        else if (t[i]=='s') ans += r;
        else ans += s;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for (int i = a; i <= b; i++) {
            String s = "" + i;
            if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) {
                ans++;    
            }    
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 34772
import copy

n = int(input())
A = list (map(str, input().split()))
B = copy.copy(A) 

def BubbleSort_dict(A, n):
    flag = 1    
    while flag:
        flag = 0
        for i in reversed(range(n-1)):
            if int(A[i][1]) > int(A[i+1][1]):
                a = A[i]
                A[i] = A[i+1]
                A[i+1] = a
                flag = 1
    return A
    
def SelectionSort_dict(A, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        if i != minj:
            a = A[i]
            A[i] = A[minj]
            A[minj] = a
    return A

A1 = BubbleSort_dict(A, n)
A2 = SelectionSort_dict(B, n)

print(' '.join(A1))
print("Stable")
print(' '.join(A2))
if A1 == A2:
    print("Stable")
else:
    print("Not stable")


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

int main()
{
  int N; cin >> N;
  int answer = 0;
  for (int c = 1; c <= N; c += 2){
    int num = 0;
    for(int x = 1; x <= c; x++){
      if (c%x == 0){
        ++num;
      }
    }
    if(num == 8){
      ++answer;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long



int main(){
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; ++i) {
		cin  >> v[i];
	}
	sort(v.begin() ,v.end());
	ll a = v[0];
	ll b = v[n-1];
	ll minn = 100000000000000000;
  for(int i = a; i <= b; ++i){
	   ll ans = 0;
	   for(int j = 0; j < n; ++j) {
		   ans += pow(abs(v[j] - i),2);
		 }
		 minn = min(minn,ans);
	}
	cout <<  minn;
  
}











Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    X, Y = map(int, input().split())
    if (Y - 2 * X) % 2 != 0:
        print("No")
        return
    kame = (Y - 2 * X) // 2
    if 0 <= kame <= X:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
N = int(input())

ans = 1
mac_c = 0
for i in range(2, N+1):
    c_count = 0
    temp_i = i
    while True:
        if temp_i % 2 != 0:
            break
        temp_i /= 2
        c_count += 1
    if mac_c <= c_count:
        mac_c = c_count
        ans = i

print(ans)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  rep(i, 0, 4) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      cout << b * 6000 << '\n';
    } else if (a == 2) {
      cout << b * 4000 << '\n';
    } else if (a == 3) {
      cout << b * 3000 << '\n';
    } else {
      cout << b * 2000 << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, c;
    scanf("%d %d", &n, &c);
    vector<vector<int>> a(c, vector<int>(200001));
    for (int i = 0, s, t, h; i < n; i++)
    {
        scanf("%d %d %d", &s, &t, &h);
        a[h - 1][s * 2 - 1]++;
        a[h - 1][t * 2 - 1]--;
    }
    for (int i = 0; i < c; i++)
    {
        for (int j = 1; j < 200001; j++)
        {
            if (a[i][j] > 0)
            {
                a[i][j - 1] += a[i][j];
                a[i][j] = 0;
            }
        }
        for (int j = 199999; j >= 0; j--)
        {
            if (a[i][j] < 0)
            {
                a[i][j + 1] += a[i][j];
                a[i][j] = 0;
            }
        }
    }
    for (int i = c - 1; i > 0; i--)
    {
        for (int j = 0; j < 200001; j++)
        {
            a[i - 1][j] += a[i][j];
        }
    }
    for (int i = 1; i < 200000; i++)
    {
        a[0][i] += a[0][i - 1];
    }
    printf("%d\n", *max_element(a[0].begin(), a[0].end() - 1));
}



Measured memory_bytes: 24576
#include<stdio.h>
#include<math.h>
bool flag[100000000];
void init(){
    flag[0]=true;
    for(int i=2;i<100000000;i++){
        for(int j=1;i*j<=100000000;j++){
            flag[i*j-1]=true;
        }
    }
}
bool is_prime_number(int n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0) return false;
    }
    return true;
}
int main(){
    int n,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        //if(!flag[x-1]) ans++;
        if(is_prime_number(x)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N = 26, D;
vi last (N, -1);
vi CS (N);
vector<vi> SAT;

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

	cin >> D;
	F0R(i, N) cin >> CS[i];
	SAT = vector<vi> (D, vi (N));
	F0R(i, D) F0R(j, N) cin >> SAT[i][j];

	int sat = 0;
	F0R(i, D) {
		int choice; cin >> choice; --choice;
		sat += SAT[i][choice];
		last[choice] = i;
		F0R(j, N) sat -= CS[j] * (i - last[j]);
		print(sat);
	}
	
}

Measured memory_bytes: 3716
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>

using namespace std;

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

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

	int z = gcd(x, y);
	cout << z << endl;

	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
using namespace std;
 
 
int main() {
    long n,k;
    cin >> n >>k;
    double p[n+10];
    double e[n+10];
    for (long i=0;i<n;i++){
        cin >> p[i];
        e[i]=(p[i]+1)/2;
      //cout <<e[i] << endl;
    }
    double ans=0;
    for (long i=0;i<k;i++){
        ans+=e[i];
    }
    //mは右端
    double ans1=ans;
    for(long m=k;m<n;m++){
        ans1-=e[m-k];
        ans1+=e[m];
        if(ans1>=ans) ans=ans1;
     //cout << ans1 << endl;
    }
    printf("%.12f\n",ans);
}
 



Measured memory_bytes: 3456
class GCD:
    def __init__(self):
        self.numlist = dict()
    def culc(self, K):
        ret = 0
        
        for i in range(1,K):
            for j in range(i + 1,K+1):
                ret += self.gcd_(i,j) * 6

        for i in range(1,K-1):
            for j in range(i+1, K):
                for k in range(j+1,K+1):
                    ret += self.gcd(i,j,k)*6

        for i in range(1, K+1):
            ret += i

        return ret

    def gcd(self, a,b,c):
        #l = (a,b,c)
        #if l in self.numlist:
        #    return self.numlist[l]
        #else:
        temp_ = self.gcd_(a,b)
        temp_ = self.gcd_(temp_, c)
        
        return temp_

    def gcd_(self,a,b):
        l = (min(a,b), max(a,b))
        if l in self.numlist:
            return self.numlist[l]
        else:
            mod = max(a,b) % min(a,b)
            if mod == 0:
                ret = min(a,b)
                self.numlist[l] = ret
                return ret
            else:
                ret = self.gcd_(min(a,b), mod)
                self.numlist[l] = ret
                return ret

K = int(input())
gcd = GCD()
ret = gcd.culc(K)
print(ret)

Measured memory_bytes: 10988
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())
A_ = list(set(A))

if sorted(A) == sorted(A_):
    print("YES")
else:
    print("NO")


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

using namespace std;

const int N = 55;
long long dp[N][N][N * N];

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

  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k < N * N; k++) {
        dp[i + 1][j][k] = dp[i][j][k];
        if (j > 0 && k >= a[i]) {
          dp[i + 1][j][k] += dp[i][j - 1][k - a[i]];
        }
      }
    }
  }

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * A];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 66560
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)

int main() { 
  int n;cin>>n;
  int a[100000];
  int all = 0;
  a[0] = 0;  
  repd(i,1,n+1){
    cin>>a[i];
    all += abs(a[i]-a[i-1]);
  }
  a[n+1] = 0;
  all += abs(a[n]);
  repd(i,1,n+1){
    cout << all-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl;
  }
}


Measured memory_bytes: 1664
#include <stdio.h>

#define N 100000

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	static int aa[N + 1], bb[N];
	int n, i, x;
	long long ans;

	scanf("%d", &n);
	for (i = 0; i < n + 1; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &bb[i]);
	ans = 0;
	for (i = 0; i < n; i++) {
		x = min(aa[i], bb[i]);
		ans += x;
		aa[i] -= x;
		bb[i] -= x;
		x = min(aa[i + 1], bb[i]);
		ans += x;
		aa[i + 1] -= x;
		bb[i] -= x;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 896
r,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(r)]
s=[]
n=0
for i in range(r-1):
    for  j in range(c):
        if l[i][j]%2==1:
            l[i][j]-=1
            l[i+1][j]+=1
            s.append([i+1,j+1,i+2,j+1])
            n+=1
for i in range(c-1):
    if l[r-1][i]%2==1:
        l[r-1][i]-=1
        l[r-1][i+1]+=1
        s.append([r,i+1,r,i+2])
        n+=1
print(n)
for i in range(len(s)):
    for j in range(4):
        if j!=3:
            print(s[i][j],end=' ')
        else:
            print(s[i][j])

Measured memory_bytes: 30228
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;

vector<vector<int>> dist = {{1,0}, {-1,0}, {0,1}, {0,-1}};

template<typename T>
void vdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        if(i==size-1){
            cout << da[i] << endl;
        }
        else{
            cout << da[i] << ' ';
        }
    }
}
template<typename T>
void vvdeb(vector<T> &da){
    int size=da.size();
    for(int i=0;i<size;i++){
        vdeb(da[i]);
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> da(h);
    rip(i,h,0){
        cin >> da[i];
    }
    vector<vector<int>> li(h,vector<int>(w,-1));
    queue<pair<P, int>> q;
    q.push(mp(mp(0,0),1));
    while(!q.empty()){
        auto now = q.front();
        q.pop();
        int x = now.first.first,y = now.first.second;
        if(li[x][y] > 0 || da[x][y] == '#'){
            continue;
        }
        li[x][y] = now.second;
        rip(i,4,0){
            if(0 <= x + dist[i][0] && x + dist[i][0] < h && 0 <= y + dist[i][1] && y + dist[i][1] < w){
                q.push(mp(mp(x + dist[i][0], y + dist[i][1]),now.second + 1));
            }
        }
    }
    int ans = h * w;
    rip(i, h, 0){
        rip(j, w, 0){
            if(da[i][j] == '#'){
                ans--;
            }
        }
    }
    //vvdeb(li);
    ans -= li[h-1][w-1];
    if(li[h-1][w-1]==-1){
        ans = -1;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n,string s)
{
    KAKA
    ll r = count(s.begin(),s.end(),'R');
    ll cnt = 0;
    pragi(0,r)
    {
        if(s[i] == 'W') cnt++;
    }
    cout<<cnt<<"\n";
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    string s;
    cin>>s;
    Compute(n,s);
}

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

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
		rotate(t.begin(), t.begin() + 1, t.end());
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = map(int,input().split())
color = [0,0,0,0,0,0,0,0,0]
for _a in a:
    if _a < 400:
        color[0] += 1
    elif _a < 800:
        color[1] += 1
    elif _a < 1200:
        color[2] += 1
    elif _a < 1600:
        color[3] += 1
    elif _a < 2000:
        color[4] += 1
    elif _a < 2400:
        color[5] += 1
    elif _a < 2800:
        color[6] += 1
    elif _a < 3200:
        color[7] += 1
    else:
        color[8] += 1
category = 0
for i in range(8):
    if color[i] != 0:
        category += 1
if category == 0:
    print(1,color[8])
else:
    print(category,category + color[8])

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }
    
    bool can = true;
    for(int i = 0; i < S.size();) {
        bool can2 = false;
        for(int j = 0; j < 4; j++) {
            string d = divide[j];
            if(S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if(!can2) {
            can = false;
            break;
        }
    }
    if(can) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3728
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str, ch, st;
	int a, b;
	while (cin >> str >> ch)
	{
		cin >> a >> b;
		cin >> st;
		if (st == str)
		{
			a--;
		}
		else if (st == ch)
		{
			b--;
    	}
		cout << a << " " << b << endl;
	}
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

struct E {
    int to, d, e;
    E(int to, int d, int e) : to(to), d(d), e(e) {}
};

struct S {
    int a, h, m;
    S(int a, int h, int m) : a(a), h(h), m(m) {}
    bool operator>(const S& s) const {
        return a > s.a;
    }
};

int n, m, l;
int inf = 1<<29;

int main() {
    while (cin >> n >> m >> l, n or m or l) {
        vector<vector<E>> g(n);
        rep(i, m) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--;
            b--;
            g[a].emplace_back(b, d, e);
            g[b].emplace_back(a, d, e);
        }
        vector<vector<int>> dist(n, vector<int>(l+1, inf));
        dist[0][l] = 0;
        priority_queue<S, vector<S>, greater<S>> que;
        que.push(S(0, 0, l));
        while (que.size()) {
            S s = que.top(); que.pop();
            int d = s.a, v = s.h, m = s.m;
            if (dist[v][m] < d) continue;
            for (auto tmp : g[v]) {
                int u = tmp.to;
                int ud = tmp.d;
                if (m - ud >= 0) {
                    if (dist[u][m-ud] > d) {
                        dist[u][m-ud] = d;
                        que.push(S(dist[u][m-ud], u, m-ud));
                    }
                }
                if (dist[u][m] > d + tmp.e) {
                    dist[u][m] = d + tmp.e;
                    que.push(S(dist[u][m], u, m));
                }
            }
        }
        int ans = inf;
        rep(i, l+1) ans = min(ans, dist[n-1][i]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3500
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "YES";
const string NO = "NO";

void solve(ll a, ll b, ll c) {
  bool pred = (a+c) == 2*b;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll c;
  cin >> c;
  solve(a, b, c);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int sum[1000];
    int j = 0;
    
    while(1){
        string number;
        cin >> number;

        if(number[0] == '0'){
            break;
        }

        for ( int i = 0; i < number.size(); i++ ){ // 文字列の長さだけ繰り返す
            sum[j] += (number[i] - '0'); // char型配列と同じように扱う
        }
        j++;
    }
    
    for(int i = 0; i < j; i++){
        cout << sum[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;
typedef complex<ld>     cld;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define kill(x)         return cout << x << endl, 0;
#define Mp              make_pair
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 1e5 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7,
         LOG  = 32;
//const ld PI   = M_PI;

ll n, w, a[110], v[110], dp[110][MAXN];

int main()
{
    fastio;
    //ld_io;

    cin >> n >> w;
    for (ll i = 1; i <= n; i++)
        cin >> a[i] >> v[i];

    for (ll i = 1; i < MAXN; i++)
        dp[0][i] = INF;

    for (ll i = 1; i <= n; i++) {
        for (ll j = 0; j < MAXN; j++) {
            if (j >= v[i])
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + a[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    for (ll i = MAXN-1; i >= 0; i--)
        if (dp[n][i] <= w)
            kill(i);

    return 0;
}



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


int main(){
    ll k = 1000000007;
    int n; cin >> n;
    vector<int> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
    }
    ll ans = 1;
    int a = 0, b = 0, c = 0;
    for(int i = 0; i < n; i++){
        int f = 0;
        if(lis[i] == a){
            f++;
        }
        if(lis[i] == b){
            f++;
        }
        if(lis[i] == c){
            f++;
        }

        if(lis[i] == a){
            a++;
        }else if(lis[i] == b){
            b++;
        }else if(lis[i] == c){
            c++;
        }
        ans = (ans * f) % k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, x;
  cin >> n >> x;
  ll size[n + 1], full[n + 1];
  size[0] = 1, full[0] = 1;

  REP(i, n){
    size[i + 1] = 2 * size[i] + 3;
    full[i + 1] = 2 * full[i] + 1;
  }

  ll ans = 0;

  while(x > 0 && n > 0){
    if(x >= (size[n] + 1) / 2){
      x -= (size[n] + 1) / 2;
      ans += full[n - 1] + 1;
    }
    else x--;
    n--;
    if(n == 0 && x > 0) ans++;
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  bool j = true;
  
  for (int i = 0; i < k; i++) {
    if(a>=b){
      b = 2*b;
      continue;
    }else if(b>=c){
      c = 2*c;
    }
  }	
  
  if(a<b && b<c){
    j=true;
  }else{
    j=false;
  }
  
  if(j==true){
    cout << "Yes" << endl;
  }else if(j==false){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X = int(readline())
    print(360//math.gcd(360,X))


if __name__ == '__main__':
    main()


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

m = [(e + 1) / 2 for e in p]

t = sum(m[0:K])
result = t
for i in range(N - K):
    t -= m[i]
    t += m[i + K]
    if t > result:
        result = t
print(result)

Measured memory_bytes: 25060
# AOJ 0576
# JOI 2011/2012 yo-t1
l = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
j = a/c
j += 1 if a%c>0
m = b/d
m += 1 if b%d>0
puts l - [j, m].max

Measured memory_bytes: 6088
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main()
{
    int n,k;
    long long h[200200];
    
    cin>>n>>k;
    REP(i,n)cin>>h[i];

    sort(h,h+n);

    long long ans=0;
    REP(i,n-k)ans+=h[i];

    cout<<ans<<endl;
}


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

int main(void) {
  long x;
  cin >> x;
  // 1/2 n(n+1)
  // 1/2 (n-1)n < x <= 1/2 n(n+1)となるnが答え
  rep(i,100000) {
    if((i-1)*i/2 < x && x <= i*(i+1)/2) {
      cout << i << endl; break;
    }
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  string s;
  cin>>s;
  vector<int> a(26);
  rep(i,s.size())a[s[i]-'a']++;
  rep(i,26){
    if(a[i]==0){
      cout<<(char)(i+'a')<<endl;
      return 0;
  }
  }
  cout<<"None"<<endl;
}

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


double p[301][301][301];
double ev[301][301][301];
void solve()
{
    int n;
    cin >> n;
    vector<int> cnt(4);
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        cnt[temp]++;
    }

    p[cnt[1]][cnt[2]][cnt[3]] = 1;

    for (int c = n; c >= 0; --c) {
        for (int b = n; b >= 0; --b) {
            for (int a = n; a >= 0; --a) {
                dbg(a, b, c, p[a][b][c]);
                if (a+b+c>n) {
                    continue;
                }
                if (a==0 && b==0 && c==0) {
                    continue;
                }
                double prob;
                //we pick 0
                prob = (a+b+c)/(double)n;
                ev[a][b][c] += 1/prob * p[a][b][c];
                //p[a][b][c] += p[a][b][c] * prob;
                //we pick 1
                if (a>0) {
                    prob = (double)a/(a+b+c);
                    p[a-1][b][c] += p[a][b][c] * prob;
                    ev[a-1][b][c] += ev[a][b][c] * prob;
                }
                //we pick 2
                if (b>0) {
                    prob = (double)b/(a+b+c);
                    p[a+1][b-1][c] += p[a][b][c] * prob;
                    ev[a+1][b-1][c] += ev[a][b][c] * prob;
                }
                //
                //we pick 3
                if (c>0) {
                    prob = (double)c/(a+b+c);
                    p[a][b+1][c-1] += p[a][b][c] * prob;
                    ev[a][b+1][c-1] += ev[a][b][c] * prob;
                }
            }
        }
    }
    cout << setprecision(10) << ev[0][0][0] << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 426240
//04
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(char n[80001];cin>>n,n[0]!='0';){
    static int r[80001][11];
    int a=0;
    fill(r[0],r[80001],0);
    for(int i=0;n[i];i++){
      int d=n[i]-'0';
      for(int j=0;j<11;j++){
	r[i+1][(j*10+d)%11]+=r[i][j];
      }
      a+=r[i+1][0];
      if(d){
	r[i+1][d]++;
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 4652
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;

	cout << S[0] << S[1] << S[2] << endl;

	return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

int main(int argc, char const *argv[])
{
  int N, A;

  cin >> N >> A;
  cout << (N*N-A) << endl;
  
  return 0;
}


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










const long int INF = 1e9+5;

int main()
{
    int n;
    cin >> n;
    vector <int> dp(3,0);

    for (int i=0; i<n; i++)
    {
        vector <int> ndp(3,0);
        vector <int> c(3);
        for (int i=0; i<3; i++)
            cin >> c[i];
        for (int i=0; i<3; i++)
            for (int j=0; j<3; j++)
            if (i!=j)
        {
            ndp[j] = max(ndp[j],dp[i]+c[j]);
        }
        dp=ndp;
        //cout << dp[0] << " " << dp[1] << " "<<dp[2] << "\n";
    }

int mx=0;
for (int i=0; i<3; i++) mx = max(mx,dp[i]);
cout << mx;
}

/*
10
10 3
1 2 3 4 5 6 7 8 9 10
3 3 4
*/



Measured memory_bytes: 3612
a,b,c,d = map(int, input().split())
takahashi = a // d 
aoki = c // b

if a % d != 0:
    takahashi += 1
if c % b != 0:
    aoki += 1
    
if takahashi < aoki:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(){
    ll n;
    ll a,b;
    cin >> n >> a >> b;
    ll cnt =0;
    ll cnt2 =0;
    ll cnt3 =0;
    for(ll i=0;i<n;i++){
        ll x;
        cin >> x;
        if(x<=a){
            cnt++;
        }else if(x>=a+1&&x<=b){
            cnt2++;
        }else if(x>=b+1){
            cnt3++;
        }
    }
    ll minn = min(cnt,cnt2);
    minn = min(minn,cnt3);
    cout << minn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;

  FOR(i, 1, 3501) {
    FOR(j, 1, 3501) {
      ll frac = i * j * n;
      ll denomi = 4 * i * j - n * i - n * j;
      if (denomi <= 0) continue;
      if (frac % denomi == 0) {
        cout << i << " " << j << " " << frac / denomi << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <cassert>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long lolong;

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 200005, mod = 998244353;
char s[maxn];
int X[maxn];
int to[maxn];
lolong p2[maxn];
lolong a[maxn];

lolong power(lolong x, int k) {
	if(k < 0) k += mod - 1;
	lolong res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

int main() {
	int n = input();
	scanf("%s", s + 1);

	p2[0] = 1;
	for(int i = 1; i <= n; i ++)
		p2[i] = (p2[i - 1] << 1) % mod;

	int p = 0;
	for(int x = 1; x * x <= n; x ++)
		if(!(n % x)) {
			if((n / x) & 1)
				X[++ p] = x;
			if(x & 1 and x * x != n)
				X[++ p] = n / x;
		}

	std::sort(X + 1, X + p + 1);

	for(int k = 1; k <= p; k ++) {
		int x = X[k];
		int &t = to[x];
		t = x;
		while(t < n and s[t + 1] != s[t + 1 - x])
			t ++;
		debug("%d -> %d\n", x, t);
	}

	for(int k = p; k; k --) {
		int x = X[k];
		a[x] = x << 1;
		for(int l = k + 1; l <= p; l ++) {
			int y = X[l];
			if(!(y % x))
				/* a[x] += mod - (y << 1); */
				a[x] += mod - a[y];
		}
		a[x] %= mod;
		debug("%d : %lld\n", x, a[x]);
	}

	lolong ans = 0;

	for(int i = 1; i <= n; i ++)
		if(s[i] == '1') {
			/* ans += p2[n - i] * (n << 1) % mod; */
			for(int k = 1; k <= p; k ++) {
				int x = X[k];
				if(i <= x) {
					for(int l = 1; l <= p; l ++)
						if(!(X[l] % x))
							assert(i <= X[l] or to[X[l]] == i - 1);
					debug(">%d %d %lld\n", i, x, p2[x - i]);
					ans += a[x] * p2[x - i] % mod;
					/* ans += (mod - (n << 1) + (x << 1)) * p2[x - i] % mod; */
				}
				else if(to[x] == i - 1) {
					for(int l = 1; l <= p; l ++)
						if(!(X[l] % x))
							assert(to[X[l]] == i - 1 or i <= X[l]);
					debug(">>%d %d\n", i, x);
					ans += a[x];
				}
			}
			ans %= mod;
			debug("%lld\n", ans);
		}

	for(int k = 1; k <= p; k ++)
		if(to[X[k]] == n)
			ans += a[X[k]];
	ans %= mod;

	/* int x = n; */
	/* for(int k = 1; k <= p; k ++) */
	/* 	if(to[X[k]] == n) */
	/* 		x = std::min(x, X[k]); */
	/* (ans += x << 1) %= mod; */

	printf("%lld\n", ans);
}


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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N = 1e5 + 5;
const int M = 1e9 + 7;

void solve()
{
	string s1,s2;
	cin>>s1>>s2;
	int n1=s1.size();
	int n2=s2.size();
	int ans=inf;
	for(int i=0;i<n1-n2+1;i++)
	{
		int cnt=0;
		for(int j=0;j<n2;j++)
		{
			if(s2[j]!=s1[i+j])
				cnt++;
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

signed main()
{
	FAST

#ifndef ONLINE_JUDGE
	freopen("input_sublime.txt", "r", stdin);
	freopen("output_sublime.txt", "w", stdout);
#endif

	int t = 1;
	// cin>>t;
	for (int tc = 1; tc <= t; tc++)
	{
		// cout<<"Case #"<<tc<<": ";
		solve();
	}

#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
}


Measured memory_bytes: 3644
s = input()
odd = []
even = []
for i in range(len(s)):
    if i % 2 == 0:
        odd.append(s[i])
    else:
        even.append(s[i])
if 'L' in odd:
    print("No")
    exit()
elif 'R' in even:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
n, x = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
d = []
d.append(0)
for i in range(n):
    d.append(d[i] + l[i])

for i in range(len(d)):
    if d[i] <= x:
        ans += 1

print(ans)

Measured memory_bytes: 3064
n = gets.to_i
a = []
n.times do
    input = gets.to_i
    a << input
end

button = 1
count = 0
result = false
a.length.times do
    count += 1
    button = a[button - 1]
    if button == 2
        result = true
        break
    end
end

puts result ? count : -1

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

int main() {
	// your code goes here
	int h;
	int a;
	cin >> h >> a;
	if(h%a!=0){
		cout << h / a + 1 << endl;
	}
	else{
		cout << h / a << endl;
	}
	return 0;
}

Measured memory_bytes: 256