akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main() {
    long long n;
    cin >> n;
    
    long long a[200010];
    long long ans[200010]={0};
    
    for(long long i=2;i<=n;i++){
        cin >> a[i];
    }
    for(long long i=2;i<=n;i++){
        ans[a[i]]++;
    }
    
    for(long long i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6752
def aux(f)
  x=0.0
  y=0.0
  dir=0.0
  while f.length > 0
    d,t=f.shift()
    break if d==0 and t==0
    x += d.to_f * Math.sin(dir*Math::PI/180.0)
    y += d.to_f * Math.cos(dir*Math::PI/180.0)
    dir += t.to_f
  end
  [x.to_i,y.to_i]

end

def main
  f=[]
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    l = $_.strip.chomp.split(/,/)
    f.push(l)
  end
  puts aux(f)
end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6924
#include <stdio.h>
int main(void){

int a,b,c;

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

    if(a <= b && b <= c) {
        printf("%d %d %d\n", a, b, c);
    }
    
    else if(b <= a && a <= c) {
        printf("%d %d %d\n", b, a, c);
    }
    
    else if(a <= c && c <= b) {
        printf("%d %d %d\n", a, c, b);
    }
    
    else if(b <= c && c <= a) {
        printf("%d %d %d\n", b, c, a);
    }
    
    else if(c <= a && a <= b) {
        printf("%d %d %d\n", c, a, b);
    }
    
    else if(c <= b && b <= a) {
        printf("%d %d %d\n", c, b, a);
    }
    
    return 0;    
    
}


Measured memory_bytes: 2064
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <string>
#include <iostream>

int calc(int a, std::string op, int b) {
    int res;
    if (op == "+") {
        res = a + b;
    } else if (op == "-") {
        res = a - b;
    } else if (op == "/") {
        res = a / b;
    } else if (op == "*") {
        res = a * b;
    } else {
        throw std::runtime_error("");
    }
    return res;
}

int main() {
    int a, b;
    std::string op;
    while (true) {
        std::cin >> a >> op >> b;
        if (op == "?") {
            break;
        }
        std::cout << calc(a, op, b) << std::endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3144
// 問題: ヒストグラムに含まれる長方形の面積の最大値を求める
// 解法: dpl_3_bのサブセット
//       http://algorithms.blog55.fc2.com/blog-entry-132.html

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

ll largest_square(const ll N, const vector<ll>& in_histo) {
    // 番兵として、右端に0を入れる
    auto histo = in_histo;
    histo.pb(0);

    ll ans = 0;
    // <ヒストグラムの高さ, index>
    stack<pair<ll, ll>> s;
    REP(n, N+1) {
        auto height = histo[n];
        if (s.empty()) s.push(mp(height, n));
        else if (s.top().first < height) s.push(mp(height, n));
        else if (s.top().first > height) {
            ll last_idx = n;
            while(!s.empty() && s.top().first > height) {
                auto area = (n - s.top().second) * s.top().first;
                ans = max(area, ans);
                last_idx = s.top().second;
                s.pop();
            }
            s.push(mp(height, last_idx));
        }
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> histo(N);
    REP(n, N) cin >> histo[n];
    cout << largest_square(N, histo) << endl;

    return 0;
}



Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; 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 VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a;
	cin>>a;
	if(a<=999){
		cout<<"ABC"<<endl;
	}
	else{
		cout<<"ABD"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N, L;
    vector<string> S;
    cin >> N >> L;
    for (int i = 0; i < N; i++) {
        string t;
        cin >> t;
        S.push_back(t);
    }
    sort(S.begin(), S.end());
    string ans = "";
    for (int i = 0; i < N; i++) {
        ans += S[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int X;
	cin >> X;
	int ans = 0;
	for (int i = 2; i * i <= X; i++) {
		int power = i * i;
		while (power <= X) {
			ans = max(ans, power);
			power *= i;
		}
	}
	if (ans == 0) ans = 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String[] list = new String[N];
        output(0);
        list[0] = scan.next();
        if (is_finished(list[0])) {
            return;
        }
        output(N-1);
        list[N-1] = scan.next();
        if (is_finished(list[N-1])) {
            return;
        }
        int left = 0;
        int right = N - 1;
        while (left < right) {
            int mid = (left + right) / 2;
            output(mid);
            list[mid] = scan.next();
            if (is_finished(list[mid])) {
                break;
            }
            if (list[mid].equals(list[right]) &&  (right - mid) % 2 == 1) {
                left = mid;
                continue;
            }
            if (!list[mid].equals(list[right]) &&  (right - mid) % 2 == 0) {
                left = mid;
                continue;
            }
            if (list[mid].equals(list[left]) &&  (mid - left) % 2 == 1) {
                right = mid;
                continue;
            }
            if (!list[mid].equals(list[left]) &&  (mid - left) % 2 == 0) {
                right = mid;
                continue;
            }
            break;
        }
    }
    private void output(int x) {
        System.out.println(x);
        System.out.flush();
    }
    private boolean is_finished(String x) {
        return "Vacant".equals(x);
    }
}


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

bool parse(string s, int &i){
  if(s[i] == 'm'){
    i++;
    parse(s, i);
    if(s[i] == 'e'){
      i++;
      parse(s, i);
      if(s[i] == 'w'){
        i++;
        if(i == s.length())return true;
      }
    }
  }
  return false;
}


int main(int argc, char *argv[]){
  int i = 0;
  string s;
  cin >> s;
  if(parse(s, i)){
    std::cout << "Cat" << std::endl;
  }else{
    std::cout << "Rabbit" << std::endl;
  }
  return 0;
}

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

using namespace std;

int main(void)
{
    int a[5];
    int mod[5];
    double b;
    int sum =0;
    for(int i = 0;i < 5; i++){
        cin >> a[i];
        mod[i] = a[i] % 10;
    }
    
    int dmin = 10;
    int idx = 0;
    for(int i = 0; i < 5;i++){
        if(dmin > mod[i] && mod[i] > 0){
            dmin = mod[i];
            idx = i;
        }
    }
    for(int i = 0; i < 5; i++){
        b = ceil((double)a[i] / 10.0);
        if(i!=idx) sum += (int)b * 10;
    }
    cout << sum + a[idx] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<string> c(h); REP(i, h) cin >> c[i];
  REP(i, h) cout << c[i] << '\n' << c[i] << '\n';
  return 0;
}


Measured memory_bytes: 256
int main(void)
{
	int w,h;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(w == 0&&h == 0)break;
		int i,j;
		
		for(i = 0;i < h;i++){
			if(i == 0||i == h-1){
				for(j = 0;j < w;j++){
					printf("#");
				}
			}else{
				printf("#");
				for(j = 1;j < w-1;j++){
					printf(".");
				}
				printf("#");
			}
			printf("\n");
		}
		
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
s = input()
n = len(s)
count = 0

def rec(int_num, num, count):
    if count >= n - 1:
        if int_num == 7:
            print('{}={}'.format(num, int_num))
            exit()
        else:
            return
    else:
        rec(int_num + int(s[count + 1]), num + '+' + s[count + 1], count + 1)
        rec(int_num - int(s[count + 1]), num + '-' + s[count + 1], count + 1)

rec(int(s[0]),s[0],count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
// #define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

//部分木の数え上げ

ll mod,n;
vector<vector<int>> g;
vector<ll> dp,par,ans;



ll dfs(int pre,int now){
    ll ret=1;
    for(auto to:g[now])if(to!=pre){
        par[to]=now;
        ret=ret*(1+dfs(now,to))%mod;
    }
    return dp[now]=ret;
}

void fill_dp(int now){
    // cout<<now<<" : "<<dp[now]<<endl;
    int m=(int)g[now].size();
    vector<ll> l(m),r(m);
    l[0]=dp[g[now][0]]+1;
    r[m-1]=dp[g[now][m-1]]+1;
    for(int i=1;i<m;i++) l[i]=l[i-1]*(dp[g[now][i]]+1)%mod;
    for(int i=m-2;i>=0;i--) r[i]=r[i+1]*(dp[g[now][i]]+1)%mod;
    ans[now]=1;
    for(auto to:g[now]) ans[now]=ans[now]*(dp[to]+1)%mod;
    rep(i,m)if(par[now]!=g[now][i]){
        dp[now]=1;
        if(i>0) dp[now]=dp[now]*l[i-1]%mod;
        if(i<m-1) dp[now]=dp[now]*r[i+1]%mod;
        fill_dp(g[now][i]);
    }
}

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

    cin>>n>>mod;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    g.resize(n);
    dp.resize(n,0);
    par.resize(n,-1);
    ans.resize(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(-1,0);

    ans[0]=dp[0];

    fill_dp(0);    

    // debug(par);
    // debug(dp);debug(ans);

    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi H(N);
	REP(i,N) cin >> H[i];
	vl dp(N, numeric_limits<ll>::max());
	dp[0] = 0;
	FOR(i,1,N) {
		dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i]);
		if (i > 1) {
			dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i]);
		}
	}
	cout << dp[N - 1] << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1408
def main():
    N, A = int(input()), list(map(int, input().split()))

    ans = 0
    for idx in range(1, N):
        if A[idx] < A[idx - 1]:
            diff = A[idx - 1] - A[idx]
            ans += diff 
            A[idx] = A[idx - 1]

    print('{}'.format(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 32244
import itertools
import math


num_point, dimension = map(int, input().split(' '))
points = {index: tuple(map(int, input().split(' '))) for index in range(0, num_point)}

trials = list(itertools.combinations(range(0, num_point), 2))

distances = [sum([(p1 - p2)**2 for p1, p2 in zip(points[trial[0]], points[trial[1]])]) for trial in trials]

ints = [distance for distance in distances if math.sqrt(distance) == int(math.sqrt(distance))]

print(len(ints))


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int a[101]={};
    REP(i,n) cin>>a[i];
    int cnt=0;

    //選択ソート
    REP(i,n){
        int mn=i;
        FOR(j,i,n){
            if(a[j]<a[mn]) mn=j;
        }

        if(i!=mn){
            swap(a[i], a[mn]);
            cnt++;
        }
    }

    REP(i,n){
        cout<<a[i];
        if(i==n-1) cout<<endl;
        else cout<<" ";
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 100000001

int main(){
  int n;
  cin>>n;
  vector<int> t(n),v(n);
  rep(i,n) cin>>t[i];
  rep(i,n) cin>>v[i];

  vector<int> dp(105, -INF);
  dp[0] = 0;
  rep(i,n){
    rep(j,t[i]){
      vector<int> nxt(105, -INF);
      rep(k,v[i]){
        if(k>0) nxt[k] = max(nxt[k], dp[k-1] + 4*k-2);
        nxt[k] = max(nxt[k], dp[k] + 4*k+1);
        nxt[k] = max(nxt[k], dp[k+1] + 4*k+2);
      }
      nxt[v[i]] = max(dp[v[i]] + 4*v[i], dp[v[i]-1] + 4*v[i]-2);
      swap(dp, nxt);
    }
  }

  printf("%.4f\n", dp[0]/4.0);

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

const long double PI = acos(-1);

int main() {
    long double R;
    cin >> R;
    cout << fixed << setprecision(10) << 2.0 * PI * R << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define MAX 123123
int arr[MAX],N;

bool bit_sum(int i,int A,int B){
  string s = to_string(i);
  int ssum = 0;
  for(char x:s){
    ssum += x - '0';
  }
  return A<=ssum&&ssum<=B;
}

int main(){
  int A,B;
  cin >> N >> A >> B;
  long long int sum=0;
  for(int i=1;i<=N;i++){
    if(bit_sum(i,A,B))sum+=i;
  }
  cout << sum << endl;
  return 0;
}



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

int main() {
  char S[100];
  int N;
  cin >> N;
  for(int i=0;i<N;i++)
    cin >> S[i];
    int a=0;
    int b=0;
  for(int i=0;i<N;i++){
      if(S[i]=='I'){
        a++;
      }
      else if(S[i]=='D'){
        a--;
      }
    if(b < a){
      b = a;
    }
    
     
    }
  cout << b << endl;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,K;
vector<int> A;

int gcd(int x,int y)
{
	return y ? gcd(y,x % y) : x;
}

int main()
{
	scanf("%d%d",&N,&K);
	A.assign(N,0);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}
	sort(A.begin(),A.end());

	if(N == 1 || A.front() == A.back()){
		puts(A [0] == K ? "POSSIBLE" : "IMPOSSIBLE");
		return 0;
	}

	int g = A [1] - A [0];
	FOR(i,2,N){
		g = gcd(A [i] - A [i - 1],g);
	}

	bool ans = A.front() <= K && K <= A.back() && (K - A.front()) % g == 0;
	puts(ans ? "POSSIBLE" : "IMPOSSIBLE");

	return 0;
}


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

typedef long long ll;
typedef long double ld;




int main(){

    	ll n;
    	cin >> n;
    	ll arr[n][3];
    	ll i,j;
    	for(i=0;i<n;i++){
            for(j=0;j<3;j++)
                cin >> arr[i][j];
    	}
    	ll sum=0;
    	ll dp1[n],dp2[n],dp3[n];
    	dp1[0]=arr[0][0];
    	dp2[0]=arr[0][1];
    	dp3[0]=arr[0][2];
    	for(i=1;i<n;i++){
            dp1[i] = arr[i][0]+max(dp2[i-1],dp3[i-1]);
            dp2[i] = arr[i][1]+max(dp1[i-1],dp3[i-1]);
            dp3[i] = arr[i][2]+max(dp2[i-1],dp1[i-1]);

    	}
        cout << max(dp3[n-1],max(dp1[n-1],dp2[n-1]));


}


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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
    int n;
    cin >> n;
    int L[n];
    rep(i,n) cin >> L[i];
    ll ans = 0;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            for(int k=j+1;k<n;k++) {
                if(L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
                if(L[i]+L[j] > L[k] && L[i]+L[k] > L[j] && L[j]+L[k] > L[i]) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 
 
int main()
{
  ll n,m,g,a,b,h;
  string s,t,p,q;
  h=0;
  cin >> n >> m >> s >> t;
  g=gcd(n,m);
  a=n/g;
  b=m/g;
  rep(i,g)if(s[a*i]!=t[b*i])h=1;
  if(h==0)printf("%lld",n*m/g);
  else printf("-1");
}

Measured memory_bytes: 512
using System;

class Program {
    private static int Main() {
        do {
            var input = Console.ReadLine();
            var values = input.Split( ' ' );

            var a = int.Parse( values[ 0 ] );
            var op = char.Parse( values[ 1 ] );
            var b = int.Parse( values[ 2 ] );

            if( op == '?' ) { break; }

            int answer = 0;
            switch( op ) {
                case '+':
                    answer = a + b;
                    break;

                case '-':
                    answer = a - b;
                    break;

                case '*':
                    answer = a * b;
                    break;

                case '/':
                    answer = a / b;
                    break;

                default:
                    throw new Exception( "Invalid op: " + op );
            }

            var output = string.Format( "{0}", answer );
            Console.WriteLine( output );
        } while( true );

        return 0;
    }
}

Measured memory_bytes: 5628
#include<stdio.h>

int main(void)
{
        int N;
        int L;
        int wa = 0;
        int a;
        int i;

        scanf("%d%d", &N, &L);
        if(L < 0 && L + N - 1 >= 0){
                a = L;
                for(i = 0; i < N ; i++){
                        wa += a;
                        a++;
                }
                printf("%d\n", wa);
        }
        else if(L < 0 && L + N -1 < 0){
                a = L;
                for(i = 0; i < N -1; i++){
                        wa += a;
                        a++;
                        }
                        printf("%d\n", wa);
        }
        else{
                for(i = 0; i < N-1; i++){
                        wa += L + 1;
                        L++;
                }
                printf("%d\n", wa);
        }


        return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int a[MAXN], b[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &a[i]);
	}
	REP(i, 0,n) {
		scanf("%d", &b[i]);
		a[i] -= b[i];
	}
	sort(a, a + n);
	ll sum = 0ll;
	int cnt = 0;
	REP(i, 0, n){
		if (a[i] < 0) {
			sum -= a[i];
			cnt++;
		}
	}
	for(int i = n - 1; i >= 0; i--) {
		if (sum > 0 && a[i] > 0) {
			sum -= a[i];
			cnt++;
		}
	}
	if (sum > 0) {
		cnt = -1;
	}
	printf("%d\n", cnt);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1024
(let ((n (read))
    (s (make-array '(26 50) :initial-element 0)))
    (dotimes (i n)
        (let ((str (read-line)))
            (loop for j below (length str) do
                (incf (aref s (- (char-code (char str j)) 97) i))
            )
        )
    )
    (loop for i below 26 do
        (let ((num 0))
            (loop for j below n do
                (progn
                    (if (= (aref s i j) 0)
                        (progn
                            (setq num 0)
                            (return)
                        )
                    )
                    (if (= j 0)
                        (setq num (aref s i j))
                        (if (> num (aref s i j))
                            (setq num (aref s i j))
                        )
                    )
                )
            )
            (loop for k below num do
                (format t "~A" (code-char (+ i 97)))
            )
        )
    )
    (format t "~%")
)

Measured memory_bytes: 24412
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL dp[5300][5300];
LL t[5300];
LL t2[5300];

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	LL x,y;
	LL s[10]={0};
	cin>>n;
	cin>>x>>y;
	if(x<y)swap(x,y);

	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(i=0;i<x;i++){
		dp[i+1][0]=dp[i][0];
		a=0;
		for(j=0;j<x;j++){
			dp[i+1][j+1]=dp[i][j];
			if(j>=y)a+=dp[i][j];
		}
		a%=MAX;
		dp[i+1][0]+=a;
		if(dp[i+1][0]>=MAX)dp[i+1][0]%=MAX;
	}
	for(i=0;i<=x;i++){
		t[i]=dp[i][0];
	}

	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(i=0;i<=n;i++){
		if(i+1<x){
			dp[i+1][0]+=t[i+1];
			dp[i+1][0]%=MAX;
		}
		for(j=0;j<y;j++){
			dp[i+1][j+1]=dp[i][j];
			if(j)t2[i]+=dp[i][j];
		}
		t2[i]%=MAX;
		a=0;
		for(j=0;j<x-1;j++){
			if(i-j<0)break;
			a+=t2[i-j]*t[j];
			if(a>=MAX)a%=MAX;
		}
		dp[i+1][0]+=a;
		dp[i+1][0]%=MAX;
	}
	for(i=1;i<y;i++){
		s[2]+=dp[n][i];
	}
	for(j=1;j<x;j++){
		if(n-j<0)break;
		s[2]+=t2[n-j]*t[j];
		if(s[2]>=MAX)s[2]%=MAX;
	}
	s[2]%=MAX;
	s[0]=pow_mod(2,n)-s[2];
	if(s[0]<0)s[0]+=MAX;
	cout<<s[0]%MAX<<endl;
}

Measured memory_bytes: 223164
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;



public class Main {
    public static void main(String[] args) throws IOException {
       try{
           Scanner sc=new Scanner(System.in);
           String s=sc.nextLine();
           if((s.charAt(2)==s.charAt(3)) && (s.charAt(4)==s.charAt(5)))
           System.out.println("Yes");
           else
           System.out.println("No");
       }
       catch(Exception e)
       {
           return;
       }
    }
}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> COUNT(100001, 0);
	long long SUM = 0;
	for (int i = 0; i < N; i++) cin >> A[i], COUNT[A[i]]++, SUM += A[i];
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long B, C;
		cin >> B >> C;
		SUM += (C - B) * COUNT[B];
		COUNT[C] += COUNT[B];
		COUNT[B] = 0;
		cout << SUM << endl;
	}
}

Measured memory_bytes: 4752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415a926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

#define itn int

int main() {
    itn n;
    cin >> n;
    int a[n];
    int min = INF;
    int s=0;
    rep(i, n) cin >> a[i];
    repk(i,1,101) {
        rep(j,n) 
            s += pow((i - a[j]), 2);
        chmin(min, s);
        s = 0;
    }
    cout << min << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	vector<int> sum;
	int a, b;

	while(cin >> a >> b){
		sum.push_back(a+b);
	}

	for(int x : sum){
		int d = 1;
		x /= 10;
		while(x > 0){
			x /= 10;
			d++;
		}
		cout << d << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    string b;
    cin >> a >> b;
    string ABC = "ABC";
    int count = 0;
    for(int i = 0;i<a-2;i++){
        string ans = b.substr(i,3);
        if(ans == ABC)
            count++;

    }
    cout << count << endl;
}

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

using namespace std;

typedef long long ll;

ll a, b, c, k;

int main() {
	cin >> a >> b >> c >> k; // 7 4 2 3

	while (b <= a) b *= 2, k--;
	while (c <= b && k > -2) c *= 2, k--;

	if (k < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

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

long long N, A, B, C, D, dp[1009][1009], nr[1009][1009], inv[1009], mod = 1000000007;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

void init() {
	for (int i = 0; i <= 1000; i++) {
		for (int j = 0; j <= 1000; j++) {
			if (i == 0 || j == 0) nr[i][j] = 1;
			else nr[i][j] = (nr[i - 1][j] + nr[i][j - 1]) % mod;
		}
	}
	for (int i = 1; i <= 1000; i++) inv[i] = modpow(i, mod - 2, mod);
}

long long ncr(long long n, long long r) {
	if (n < r || r < 0) return 0;
	return nr[n - r][r];
}

int main() {
	init();
	cin >> N >> A >> B >> C >> D;
	dp[A][0] = 1;
	for (int i = A; i <= B; i++) {
		for (int j = 0; j <= N; j++) {
			if (dp[i][j] == 0) continue;
			dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= mod;

			int sum = j; long long V = 1;
			for (int k = 1; k <= D; k++) {
				sum += i; if (sum > N) break;
				V *= ncr(sum, sum - i); V %= mod;
				V *= inv[k]; V %= mod;
				if (C <= k) {
					dp[i + 1][sum] += dp[i][j] * V;
					dp[i + 1][sum] %= mod;
				}
			}
		}
	}
	cout << dp[B + 1][N] << endl;
	return 0;
}

Measured memory_bytes: 16128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAXN 200010
int n, a[MAXN], d[MAXN][20];
long long res = 0;
int main(){
    scanf("%d", &n);
    for(int i = 1;i <= n;i++)scanf("%d", &a[i]);
    for(int i = 1;i <= n;i++){
        for(int j = 0;j < 20;j++){
            d[i][j] = d[i - 1][j] + ((a[i] >> j) & 1);
        }
    }
    for(int i = 1;i <= n;i++){
        int l = i, r = n, ans = i;
        while(l <= r){
            int mid = (l + r) >> 1;
            int ok = true;
            for(int j = 0;j < 20;j++){
                if(d[mid][j] - d[i - 1][j] > 1){
                    ok = false;
                    break;
                }
            }
            if(ok)ans = mid, l = mid + 1;
            else r = mid - 1;
        }
        res += ans - i + 1;
    }
    printf("%lld\n", res);
    return 0;
}

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

int main(void)
{
    int number1, number2;
    cin >> number1 >> number2;

    if (number1 == number2) {
        cout << "a == b" << endl;
    } else if (number1 < number2) {
        cout << "a < b"<< endl;
    } else {
        cout << "a > b" << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int n, uf_par[112345], uf_rnk[112345];

void uf_init(int size)
{
    REP(i, size)
    {
        uf_par[i] = i;
        uf_rnk[i] = 0;
    }
}

int uf_find(int x)
{
    if (uf_par[x] == x)
        return x;
    else
        return uf_par[x] = uf_find(uf_par[x]);
}

void uf_unite(int x, int y)
{
    x = uf_find(x);
    y = uf_find(y);
    if (x == y)
        return;

    if (uf_rnk[x] < uf_rnk[y])
    {
        uf_par[x] = y;
    }
    else
    {
        uf_par[y] = x;
        if (uf_rnk[x] == uf_rnk[y])
            uf_rnk[x]++;
    }
}

bool uf_same(int x, int y)
{
    return uf_find(x) == uf_find(y);
}

int main()
{
    int n;
    vector<P> x, y;
    map<P, bool> mp;

    cin >> n;

    uf_init(n);

    int num = n;

    REP(i, n)
    {
        int a, b;
        cin >> a >> b;
        if (mp[make_pair(a, b)])
        {
            num--;
            continue;
        }

        mp[make_pair(a, b)] = true;

        x.push_back(make_pair(a, i));
        y.push_back(make_pair(b, i));
    }

    SORT(x);
    SORT(y);

    vector<pair<int, P>> v;

    for (int i = 0; i < x.size() - 1; i++)
    {
        v.push_back(make_pair(x[i + 1].first - x[i].first, make_pair(x[i].second, x[i + 1].second)));
    }

    for (int i = 0; i < y.size() - 1; i++)
    {
        v.push_back(make_pair(y[i + 1].first - y[i].first, make_pair(y[i].second, y[i + 1].second)));
    }

    SORT(v);

    ll res = 0;
    int cnt = 0;

    int i = 0;

    while (cnt < num - 1)
    {
        if (uf_same(v[i].second.first, v[i].second.second))
        {
            i++;
            continue;
        }

        res += v[i].first;

        uf_unite(v[i].second.first, v[i].second.second);

        cnt++;

        i++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 14180
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

const ld pi = acos(-1.0L);

using Data = int;
const Data INF = 1000000000;

vector<Data> lis(const vector<Data>& a) {
  const int n = a.size();
  if (n == 0) return vector<Data>(0);
  vector<Data> A(n, INF);
  vector<int> id(n);
  for (int i = 0; i < n; i++) {
    id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i]));
    A[id[i]] = a[i];
  }
  int m = *max_element(id.begin(), id.end());
  vector<Data> res(m + 1);
  for (int i = n - 1; i >= 0; i--)
    if (id[i] == m) res[m--] = a[i];
  return res;
}

void solve(vector<ll> x, vector<ll> y, ll N, vector<ll> X, vector<ll> Y) {
  int l = min(x[0], x[1]);
  int r = max(x[0], x[1]);
  int t = min(y[0], y[1]);
  int b = max(y[0], y[1]);
  vector<pair<int,int>> point;
  REP(i,N) {
    if (l <= X[i] && X[i] <= r && t <= Y[i] && Y[i] <= b) {
      point.emplace_back(abs(X[i] - x[0]), abs(Y[i] - y[0]));
    }
  }
  sort(ALL(point));
  vector<int> ys;
  for (auto p: point) ys.push_back(p.second);
  auto v = lis(ys);
  ld res = ((r - l) + (b - t)) * 100.00L;
  if (v.empty()) { cout << res << endl; }
  else{
    int n = v.size();
    chmin(n, r - l);
    chmin(n, b - t);
    res += (5 * pi - 20) * n;
    if (r - l < int(v.size()) || b - t < int(v.size())) {
      res += 10 * pi - 20;
    }
    cout << res << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(15) << fixed;
  cout.imbue(loc);
	vector<ll> x(2-1+1);
	ll N;
	vector<ll> y(2-1+1);
	for (int i = 0 ; i <= 2-1 ; i++) {
	  scanf("%lld", &x[i]);
	  scanf("%lld", &y[i]);
	}
	scanf("%lld", &N);
	vector<ll> Y(N-1+1);
	vector<ll> X(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &X[i]);
	  scanf("%lld", &Y[i]);
	}
	solve(x, y, N, X, Y);
	return 0;
}


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

signed main(void)
{
	string s;
	cin >> s;
	long long n, m, sum;
	bool flag;
	n = m = 0;
	sum = 0;
	flag = false;
	rep(i, s.size())
	{
		if (s[i] == '<')
		{
			if (flag)
			{
				if (m > n)
				{
					sum += m * (m + 1) / 2;
					sum += n * (n - 1) / 2;
				}
				else
				{
					sum += m * (m - 1) / 2;
					sum += n * (n + 1) / 2;
				}
				n = 0;
				m = 0; 
				flag = false;
			}
			m++;
		}
		else if (s[i] == '>')
		{
			flag = true;
			n++;
		}
	}
	if (m > n)
	{
		sum += m * (m + 1) / 2;
		sum += n * (n - 1) / 2;
	}
	else
	{
		sum += m * (m - 1) / 2;
		sum += n * (n + 1) / 2;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 900
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <utility>
#include <queue>
#include <stack>

#include <vector>
using namespace std;
#define INF 1000000001;
#define int long long

int V, E;

const int MAX_V = 50;

int dist[MAX_V];          //訪問回数
vector<int> G[MAX_V];     //グラフの隣接リスト

void bfs(int s) {
  queue<int> que;
  que.push(s);
  dist[s] = 0;

  while (que.size()) {
    int u = que.front();
    que.pop();
    // cerr << u << endl;
    for (int i = 0; i < G[u].size(); i++) {
      if (dist[G[u][i]] > dist[u] + 1) {  //もし未訪問なら
        dist[G[u][i]] = dist[u] + 1;
        // cerr << u << "<->" << G[u][i] << ":" << dist[G[u][i]] << endl;
        que.push(G[u][i]);
      }
    }
  }
}

signed main() {
  cin >> V >> E;  // == V,E
  int ans = 0;
  vector<pair<int, int> >lines(E);  

  for (int i = 0; i < E; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    lines[i].first = a;
    lines[i].second = b;
  }

  for (int X = 0; X < E; X++) {
    for (int i = 0; i < X; i++) {
      G[lines[i].first].push_back(lines[i].second);
      G[lines[i].second].push_back(lines[i].first);
    }
    for (int i = X+1; i < E; i++) {
      G[lines[i].first].push_back(lines[i].second);
      G[lines[i].second].push_back(lines[i].first);
    }

    for (int i = 0; i < V; i++) {
      dist[i] = 99999999;
    }
    bfs(0);

    for (int i = 0; i < V; i++) {
      if (dist[i] == 99999999) {
        ans++;
        break;
      }
    }
    for (int i = 0; i < V; i++) {
      G[i].clear();
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
 
using namespace std;
 
int main(){
	string s;
	string result = "";
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'B'){
			if(!result.empty()){
				result.pop_back();
			}
		}else{
			result += s[i];
		}
	}
	cout << result << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;




int main(){
    int a[3010],b[3010];
    int ct = 0;
    
    while(true){
        cin >> a[ct] >> b[ct];
        if(a[ct] == 0 && b[ct] == 0) break;
        ct++;
    }
    
    ct = 0;
    while(a[ct] != 0 || b[ct] != 0){
        if(a[ct]>b[ct])cout << b[ct] <<" " << a[ct] << endl;
        else cout << a[ct] << " " << b[ct] << endl;
        ct++;
    }
}









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

int main() {
	int N;
	cin >> N;
	vector<int>vec(N);
	rep(i, N) {
		cin >> vec[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = (vec[i] - 1) + ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}


int main()
{
	fast;

	int n;
	cin>>n;
	int a[n+1];
	FOR(i,1,n)cin>>a[i];
	int ans = 0;
	FOR(i,1,n-1){
		if(a[i]==a[i+1]){
			a[i+1] = -1;
			ans++;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N=gets.to_i
a=[]
b=[]
a=gets.split(" ").map{|i| i.to_i}

allcon=a.group_by{|i| i}.values.map{|i| i.length*(i.length-1)/2}.reduce{|i,j| i+j}
agroup=a.group_by{|j| j}
b=a.map{|i| (agroup[i].length-1)}

b.each do |i|
  puts allcon-i
end



Measured memory_bytes: 60072
#include<bits/stdc++.h>
#define re register
#define int long long
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
using namespace std;
int n,m,a[100002],b,k,ans,l[100002],r[100002],la;
signed main(){
	n=read()+1;
	for(re int i=1;i<=n;++i)a[i]=read();
	if(n==1&&a[1]==1)return puts("1"),0;
	else if(a[1]>=1)return puts("-1"),0;
	l[n]=r[n]=a[n];
	for(re int i=n-1;i;--i){
		l[i]=(l[i+1]+1)>>1;r[i]=r[i+1];
		l[i]+=a[i];r[i]+=a[i];
	}la=1;
	for(re int i=1;i<=n;++i){
		if(la<l[i])return puts("-1"),0;
		la=min(la,r[i]);
		ans+=la;la-=a[i];
		la<<=1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5996
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

if n % 1000 == 0:
	print(0)
else:
	print(1000 - (n % 1000))
print()


Measured memory_bytes: 65136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e5;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)
        cin >> a[i];
    vector<bool> dp(K + 5);
    for(int i = 1; i <= K; ++i)
        for(int j = 0; j < N; ++j)
            if(i >= a[j])
                dp[i] = dp[i] | !dp[i - a[j]];
    cout << (dp[K] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 256