akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	cin >> N;
	vl R(N), A(N), B(N);
	for (i = 0; i < N; i++) {
		ll p;
		cin >> p;
		R[p - 1] = i;
	}
	A[0] = 1; B[0] = 1000000000;
	for (i = 0; i < N-1; i++) {
		if (R[i] < R[i + 1]) {
			B[i + 1] = B[i] - 1;
			A[i + 1] = A[i] + R[i + 1] - R[i] + 1;
		}
		else {
			B[i + 1] = B[i] + R[i + 1] - R[i] - 1;
			A[i + 1] = A[i] + 1;
		}
	}
	for (i = 0; i < N; i++) co3(A[i]);
	cout << endl;
	for (i = 0; i < N; i++) co3(B[i]);
	cout << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  int n;cin>>n;
  vector<int> d(n);int sum=0;
  for(int i=0;i<n;i++){
  	cin>>d[i];sum+=d[i];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
  	ans += d[i]*(sum-d[i]);
  }
  ans /= 2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/***********************
  Author : rohitroy
************************/

#include "bits/stdc++.h"
using namespace std;

#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	
	int n;
	cin>>n;
	if(n%2==1)
		cout<<(n-1)/2;
	else
		cout<<n/2-1;
	cout<<"\n";	
	
return 0;
}

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


int main() {
#ifdef DEBUG
    freopen("in.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    int t;
    cin >> t;
    string s;
    cin >> s;
    if (s.size() > t) {
        for (int i = 0; i < t; ++i) {
            cout << s[i];
        }
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }



    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;

int main(){

    int a,b,k;
    cin >> a >> b >> k;

    set<int> ans;

    rep(i,k){
        if(a + i <= b) ans.insert(a + i);
    }

    rep(i,k){
        if(b- i >= a) ans.insert(b - i);
    }

    for(auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << (*itr) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
** 范围搜索
*/

# include <cstdio>
# include <algorithm>
# include <vector>
using namespace std;

class Node {
    public:
      int location;
      int p, l, r;
      Node() {}
};

class Point {
    public:
      int id, x, y;
      Point() {}
      Point(int id, int x, int y) : id(id), x(x), y(y) {}
      bool operator<(const Point &p) const {
          return id < p.id;
        }

        void print() {
            printf("%d\n", id);
        }
};

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

int N;
Point P[MAX];
Node T[MAX];
int np;

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

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

    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth + 1);
    T[t].r = makeKDTree(mid+1, r, depth + 1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;

    if ( sx <= x && x <= tx && sy <= y && y <= ty ) {
        ans.push_back(P[T[v].location]);
    }

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

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

    np = 0;

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

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

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 15940
import java.util.Scanner;

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

	int a = scan.nextInt();
	int b = scan.nextInt();
	int k = scan.nextInt();

	int divide = 1;
	for(int i = 100; i >= 1; i--){
	    if(a % i == 0 && b % i == 0){
		k--;
	    }
	    if(k == 0){
		divide = i;
		break;
	    }
	}

	System.out.println(divide);
    }
}


Measured memory_bytes: 22868
#include<stdio.h>

int main()
{
	int v1,v2;
	int dist[10];
	int dist0to10;
	int i,station;
	double intersect,tmp;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",dist,dist+1,dist+2,dist+3,dist+4,dist+5,dist+6,dist+7,dist+8,dist+9,&v1,&v2)!=EOF)
	{
		dist0to10=0;
		tmp=0;
		for(i=0;i<10;i++)
		{
			dist0to10+=dist[i];
		}

		intersect=(double)(v1*dist0to10)/(v1+v2);
		

		for(i=0;i<10;i++)
		{
			tmp+=(double)dist[i];
			if(tmp>=intersect)
			{
				station=i+1;
				break;
			}
		}
		printf("%d\n",station);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int max_size = 1000000;

vector<long long> fac(max_size+1), ifac(max_size+1);

long long pow_mod(long long x, long long n){
    long long ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

long long comb(long long a, long long b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    long long tmp = ifac[a-b] * ifac[b] % mod;
    return tmp * fac[a] % mod;
}
int main(){
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i < max_size; i++){
        fac[i+1] = fac[i]*(i+1) % mod;
        ifac[i+1] = ifac[i]*pow_mod(i+1,mod-2) % mod;
    }

    long long x,y;
    cin >> x >> y;
    if((-2*x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    else if((-x+2*y) < 0 || (-y+2*x) < 0){
        cout << 0 << endl;
        return 0;
    }
    long long a = (-x+2*y)/3;
    long long b = (-y+2*x)/3;
    cout << comb(a+b,a) << endl;
    return 0;
}


Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		ArrayList<Integer> HeightMountain = new ArrayList<>();
		int height = 0;

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String line = null;
		try {
			while((line = input.readLine()) != null) {
				height = Integer.valueOf(line);
				HeightMountain.add(height);
			}
		} catch (NumberFormatException e) {
			System.out.println(line + "は整数でない");
		} catch (IOException e) {
			System.out.println("入出力例外");
		}

		Collections.sort(HeightMountain, Collections.reverseOrder());

		for(int i = 0; i < 3; i++) {
			System.out.println(HeightMountain.get(i));
		}
	}
}



Measured memory_bytes: 24476
#include <stdio.h>

int main(void) {
	char buffer[2000];
	int i;
	scanf("%s",buffer);
	for(i=0;buffer[i];i++) {
		buffer[i]-=3;
		if(buffer[i]<'A')buffer[i]+=26;
	}
	puts(buffer);
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string str;
	cin >> str;
	int sm = 0;
	for(auto el: str) sm += el - '0';
	if(sm % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
}



Measured memory_bytes: 3784
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,i = 1,f = 1;
	scanf("%d",&a);
	if(a==1)
{	printf("1");
	return 0;}
	while(f*2<=a)
		f*=2;
	printf("%d",f);
	return 0;
}


Measured memory_bytes: 128
#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 rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    int n; cin >> n;
    vint a(n), b(n);
    rep(i, n) cin >> a[i];
    long long sum = 0;
    rep(i, n) {
        sum += a[i] / 2;
        b[i] = a[i] % 2;
    }
    bool f = false;
    rep(i, n) {
        if(f) {
            if(a[i] == 0) {
                f = false;
            } else {
                if(b[i] == 1) {
                    f = false;
                    sum++;
                }
            }
        } else {
            if(b[i] == 1) f = true;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define mod		1000000007
#define inf     1000000000000000000
#define MX1		100005
#define MX2		10000004
#define pi		acos(-1)
#define pb      push_back
#define vlli    vector<lli>
#define plli    vector<pair<lli,lli> >
#define mp      make_pair
#define all(v)  v.begin(),v.end()
#define test    int t;cin>>t;
lli gcd(lli a, lli b){return b?gcd(b,a%b):a;}
lli power(lli a,lli b){lli ans=1;while(b){if(b&1){ans=(ans*a)%mod;}a=(a*a)%mod;b>>=1;}return ans;}
int main()
{
	opt;
	lli r,g,b;
cin>>r>>g>>b;
lli ans;
ans=(r*100)+(g*10)+b;
if(ans%4==0)
cout<<"YES\n";
else
cout<<"NO\n";

	return 0;
}


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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,k,c;
        cin>>n>>k>>c;
        string s;
        cin>>s;
        vector<int>a,b;
        for(int i=0;i<n;i++){
            if(s[i]=='o'){
                a.push_back(i);
                i+=c;
            }
        }
        for(int i=n-1;i>=0;i--){
            if(s[i]=='o'){
                b.push_back(i);
                i-=c;
            }
        }
//        cout<<"\n";
//        for(int i=0;i<k;i++)
//            cout<<a[i]<<" ";
//        cout<<"\n";
//        for(int i=0;i<k;i++)
//            cout<<b[i]<<" ";
        for(int i=0;i<k;i++){
            if(a[i]==b[k-i-1])
                cout<<a[i]+1<<"\n";
        }
        return 0;
    }


Measured memory_bytes: 3468
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  float t, x; cin >> t >> x;
  cout << t / x << endl;
}


Measured memory_bytes: 888
// https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pair<int, int>> v;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    double sum = 0;
    REP(i, N) FOR(j, i + 1, N) {
        sum += hypot(v[j].first - v[i].first, v[j].second - v[i].second);
    }
    printf("%.10f\n", 2 * sum / N);

    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    ll n, h, w;
    cin >> n >> h >> w;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        ll a, b;
        cin >> a >> b;

        if(a >= h and b >= w){
            cnt++;
        }
    }

    ppp(cnt);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bisc[2];

long long perm(int a){
    int pangkat = 1;
    if (a == 1) return 1;
    for(int i=1; i<a; i++){
        pangkat*=2;
    }
    return perm(a-1) + pangkat;
}

int main(){
    int N, P;
    cin >> N >> P;
    for(int i=1; i<=N; i++){
        int biscuits;
        cin >> biscuits;
        bisc[biscuits % 2]++;
    }
    long long ans = 1;
    for(int i=1; i<=bisc[0] ; i++) ans*=2;
    ans--;
    if(bisc[1] > 1){
        ans +=  ans*(perm(bisc[1] - 1)) + perm(bisc[1] - 1) ;
    }
    ans++;
    if (P == 0){
        cout << ans << endl;
    } else{
        long long pangkat = 1;
        for(int i=1; i<=N; i++){
            pangkat*=2;
        }
        cout << pangkat - ans << endl;
    }
}

Measured memory_bytes: 256
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

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

    vector<vector<int>> cells;

    times_do(2, [&](){
        cells.push_back(reads<int>(n));
    });

    int count = accumulate(begin(cells[1]), end(cells[1]), cells[0][0]);
    int count_max = count;

    for(size_t i = 1; i < n; ++i)
    {
        count = count + cells[0][i] - cells[1][i-1];
        count_max = max(count_max, count);
    }

    cout << count_max << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, *s;  cin >> n;
    s = new int[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];

    int **dp = new int *[n+1];
    for (int i = 0; i < n+1; i++) {
        dp[i] = new int[10001];
        for (int j = 0; j < 10001; j++)
            dp[i][j] = 0;
    }

    dp[0][0] = 1;


    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10000; j++) {
            if (s[i] <= j && dp[i][j-s[i]])
                dp[i+1][j] = 1;
            if (dp[i][j])
                dp[i+1][j] = 1;
            if (!j)
                dp[i+1][j] = 1;
        }
    }

    int i = 10000;
    for (; i > 0; i--) {
        if (dp[n][i] && i % 10)
            break;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

const int mod = 1000000007;

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

//const int dx[8] = {};
//const int dy[8] = {};

using namespace std;

template <class myType>
void p(vector<myType>& v)
{
    for(myType i: v) cout<<i<<" ";
    cout<<endl;
}

template <class myType>
void pv(vector<vector<myType>>& vv)
{
    for(auto& v: vv)
        p(v);
}

template <class myType>
void GetInputV(vector<myType>& v, int n)
{
    v.resize(n);
    for(myType& i: v) cin>>i;
}

template <class myType>
void GetInputVV(vector<vector<myType>>& vv, int m, int n)
{
    vv.resize(m);
    for(vector<myType>& v: vv) GetInputV(v, n);
}

int main()
{

    int n;
    cin>>n;
    vector<int> v;

    GetInputV(v, n);

    int negCnt = 0;
    long long res = 0;
    int mn = abs(v[0]);

    for(int i: v)
    {
        if(i <= 0) negCnt++;
        res += abs(i);
        mn = min(mn, abs(i));
    }

    if((negCnt%2) != 0)
    {
        res -= 2*mn;
    }

    cout<<res<<endl;
    

    return 0;
}

Measured memory_bytes: 640
N, M = list(map(int, input().split(" ")))
A = {int(input()) for _ in range(M)}

memo = [0] * (N + 1)
memo[0] = 0 if 0 in A else 1
memo[1] = 0 if 1 in A else 1

for i in range(2, N + 1):
    if i in A:
        continue
    memo[i] = memo[i - 2] + memo[i - 1]

print(memo[N] % 1000000007)

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i], --a[i];
    int b = 0;
    int cnt = 0;
    while (b != 1)
    {
        b = a[b];
        ++cnt;
        if (cnt > N)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;

const int maxN = 1 << 11;

char in[2][maxN];

long long f(long long n, long long p)
{
	long long res = 0;
	for (long long q=p; q<=n; q*=p)
		res += n/q;
	return res;
}

int main()
{
	long long n;
	scanf ("%lld", &n);
	if (n % 2 == 1ll)
	{
		printf("0\n");
		return 0;
	}
	
	n /= 2;
	long long a = f(n, 2) + n, b = f(n, 5);
	printf("%lld", min(a, b));
	
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[100005], y[100005], z[100005];
ll k;

vector<ll> G[500005];

void solve(){
    cin >> n;
    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            if(i * i *  i * i * i - j * j * j * j * j == n){
                pe(i);p(j);
                return;
            }
        }
    }
    assert(false);
    return;
}

int main(){

    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















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

int main() {
    int n;
    cin >> n;
    
    for (int i = n; i > 0; i--)
    {
        if ((int)sqrt(i) * (int)sqrt(i) == i) {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

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

/*-------------------Define Start-------------------*/
typedef bool BL;    					// 布尔类型
typedef char SB;    					// 有符号1字节,8位
typedef unsigned char UB;    			// 无符号1字节,8位
typedef short SW;    					// 有符号短整型,16位
typedef unsigned short UW;    			// 无符号短整型,16位
typedef long SDW;    					// 有符号整型,32位
typedef unsigned long UDW;   			// 无符号整型,32位
typedef long long SLL;    				// 有符号长整型,64位
typedef unsigned long long ULL;			// 无符号长整型,64位
typedef char CH;    					// 单个字符
typedef float R32;    					// 单精度浮点数
typedef double R64;    					// 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;				//常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;				//用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;	//用来表示无限大

// 重载<<操作符，用来打印vector 
template < typename T >
ostream& operator<< (ostream& out, vector< T > vec) {
	foreach(i, vec) {
		if(i != vec.begin()) {
			out << " ";
		}
		out << *i;
	}
    return out;
}
/*-------------------Define End-------------------*/

const UDW maxN = 5e3 + 7;
SDW k, q;
SLL d[maxN], dm[maxN];
SLL n, x, m;
SLL eqcnt;	// 记录 a[i] % m == a[i+1] % m 的个数 
SLL gtcnt;	// 记录 a[i] % m > a[i+1] % m 的个数 
SLL ltcnt;	// 记录 a[i] % m < a[i+1] % m 的个数 
SLL firstA; // a[0]
SLL lastA;	// a[n-1]
SLL ans;

void input(){
	eqcnt = gtcnt = ltcnt = ans = 0;
	cin >> n >> x >> m;
}

void solve(){
	firstA = lastA = x;
	
	Rep(i, k) {
		dm[i] = d[i] % m;
		lastA += ((n - 1) / k) * dm[i]; 
		if(i < (n - 1) % k) {
			lastA += dm[i];
		}
		gtcnt += lastA / m;
		lastA %= m;
	}
	
	Rep(i, k) {
		if(dm[i] == 0) {
			eqcnt += (n - 1) / k;
			if(i < (n - 1) % k) {
				++eqcnt;
			}
		}
	}
	
	gtcnt -= firstA / m;
	ltcnt = n - 1 - eqcnt - gtcnt;
	
	ans = ltcnt;
}

void output(){
	cout << ans << endl;
}

int main() {
	cin >> k >> q;
	Rep(i, k) {
		cin >> d[i];
	}
	while(q--) {
		input();
		solve();
		output();
	}
	return 0;
}


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

int main() {

	int a,b,c,ans;
	cin>>a>>b>>c;
	
  if(a==b&&b==c){ans=1;}
  else if(a==b||b==c||a==c){ans=2;}
  else{ans=3;}
    
	cout<<ans<<endl;
}


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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        sort(v.begin(), v.end());
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i % M) ans += v[N - i];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3056
$<.map{|s|
    puts [*(s.split(/\+|=/).all?{|b|b.chomp.size==1||b.chars[0]!='X'}? 0 : 1)..9].find{|x|eval(s.gsub("=","==").gsub("X",x.to_s))}||"NA"
}



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

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

int n,m;
int t[201][2];
int dp[201];

int solve(int idx){
	if(dp[idx] != -1) return dp[idx];

	int res = 0;

	rep(i,n){
		if(t[idx][0] > t[i][0] && t[idx][1] > t[i][1]){
			res = max(res,solve(i));
		}
	}

	return (dp[idx] = res + 1);
}

int main(void){
	t[200][0] = t[200][1] = 1001;

	while(cin>>n && n){
		rep(i,n) cin>>t[i][0]>>t[i][1];
		cin>>m;
		REP(i,n,n+m) cin>>t[i][0]>>t[i][1];
		n += m;

		memset(dp,-1,sizeof(dp));
		cout<<solve(200)-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
# coding=utf-8


def main():
    n = input()
    s = ''
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            s += ' ' + str(i)
            continue
        while x:
            if x % 10 == 3:
                s += ' ' + str(i)
                break
            x /= 10
    print s
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 4528
#include <iostream>
typedef long long int ll;
using namespace std;
ll a,b,i,j,x,y,n,m;
ll arr[1000];
int main()
{
    cin >> a >> n >> m;
    x = a-n;
    y = a-m;
    if (x<0)
        x*=-1;
    if (y<0)
        y*=-1;

    if (x>y)
        cout << "B\n";
    else
        cout << "A\n";



    return 0;
}


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

using namespace std;
using ll =long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;

const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

constexpr ll MOD = 998244353ll;

template<long long mod = 1000000007>
struct modint{
    long long a;

    modint() : a(0){}
    modint(long long t){
        a = t % mod;
        if(a < 0) a += mod;
    }

    operator long long() const{ return a; }

    bool operator==(const modint &x) const{ return a == x.a; }
    bool operator!=(const modint &x) const{ return a != x.a; }

    modint operator-() const{ return modint(a ? (mod - a) : 0); }
    modint operator~() const{ return pow(mod - 2); }

    modint operator+(const modint &x) const{ return modint(*this) += x; }
    modint operator-(const modint &x) const{ return modint(*this) -= x; }
    modint operator*(const modint &x) const{ return modint(*this) *= x; }
    modint operator/(const modint &x) const{ return modint(*this) /= x; }

    modint &operator+=(const modint &x){
        a += x.a;
        if(a >= mod) a -= mod;
        return *this;
    }
    modint &operator-=(const modint &x){
        a -= x.a;
        if(a < 0) a += mod;
        return *this;
    }
    modint &operator*=(const modint &x){
        a = a * x.a % mod;
        return *this;
    }
    modint &operator/=(const modint &x){
        a = a * (~x).a % mod;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }
    friend istream &operator>>(istream &is,modint &x){
        long long t;
        is >> t;
        x = modint(t);
        return is;
    }

    modint pow(long long x) const{
        modint ret = 1, tmp = a;
        for(;x;tmp *= tmp,x >>= 1){
            if(x & 1) ret *= tmp;
        }
        return ret;
    }
};


// modint<MOD> binom(ll n, ll k) {
//     modint<MOD> res = 1;
//     FOR(i, 0, k) {
//         res *= n - i;
//         res /= i+1;
//     }
//     return res;
// }

int main(){ cin.sync_with_stdio(0);
    ll N, M, K; cin >> N >> M >> K;

    vector<modint<MOD>> fac(N+5), facInv(N+5);
    fac[0] = 1;
    FOR(i, 1, N+5) fac[i] = fac[i-1] * modint<MOD>(i);
    facInv[N+4] = ~fac[N+4];
    FORD(i, 1, N+5) facInv[i-1] = facInv[i] * modint<MOD>(i);

    auto binom = [&](ll n, ll k) {
        if (k < 0 || n < k) return modint<MOD>(0);
        return fac[n] * facInv[k] * facInv[n-k];
    };

    modint<MOD> ans = 0;

    FOR(i, 0, K+1) {
        ans += binom(N-1, i) * modint<MOD>(M) * modint<MOD>(M-1).pow(N-i-1);
    }
    cout << ans << endl;
} //cin.tie(0) bei schnellem Wechseln



Measured memory_bytes: 6424
n,k= map(int,input().split())
tree = []
for i in range(n):
    tree.append(int(input()))
tree.sort()
ans = int(1e10)
for i in range(n-k+1):
    a = tree[i+k-1] - tree[i]
    ans = min(ans, a)
print(ans)


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

#define ll long long
#define ull unsigned long long

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
	int H, W, M;
	cin >> H >> W >> M;

	vector <int> h(M);
	vector <int> w(M);
	map<int, int> hmap;
	map<int, int> wmap;
	map<pair<int,int>, int> existmap;
	for (int ii = 0; ii < M; ++ii){
		cin >> h[ii] >> w[ii];
		h[ii]--; w[ii]--;
		hmap[h[ii]]++;
		wmap[w[ii]]++;
		existmap[make_pair(h[ii], w[ii])] = 1;
	}

	//行，列の最大値を取得
	int hmax = 0;
	int wmax = 0;
	for(auto itr = hmap.begin(); itr != hmap.end(); ++itr) {
		hmax = max(hmax, itr->second);
	}
	for(auto itr = wmap.begin(); itr != wmap.end(); ++itr) {
		wmax = max(wmax, itr->second);
	}

	//最大値を持つ行，列を取得
	vector <int> hlist;
	for(auto itr = hmap.begin(); itr != hmap.end(); ++itr) {
		if (hmax == itr->second){
			hlist.push_back(itr->first);
		}
	}
	vector <int> wlist;
	for(auto itr = wmap.begin(); itr != wmap.end(); ++itr) {
		if (wmax == itr->second){
			wlist.push_back(itr->first);
		}
	}

	bool ok = false;
	for (int ii = 0; ii < hlist.size(); ++ii){
		for (int jj = 0; jj < wlist.size(); ++jj){
			pair<int, int> key = make_pair(hlist[ii], wlist[jj]);
			if (existmap[key] == 0){
				ok = true;
				break;
			}
		}
	}

	int ans = hmax + wmax;
	if (!ok){
		ans--;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 73600
n, m = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
sum = a.inject(:+)
c = []

a.each.with_index(1) do |s, i|
  c << i if s >= sum / (4 * m).to_f
end

if c.count >= m
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K:
        if k==1 or sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Measured memory_bytes: 169224
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void cook()
{
    // start with your recipe
    long long n, k, powof2 = 1099511627776, cnt, ans = 0;
    int i, j;
    cin>>n>>k;
    vector<long long> a(n), b(n);
    for(i=0;i<n;++i)
    {
        cin>>a[i];
        b[i] = a[i];
    }
    for(i=0;i<41;++i)
    {
        // cnt is count of numbers in array with ith bit set
        cnt = 0;
        for(j=0;j<n;++j)
        {
            if(a[j] >= powof2)
            {
                ++cnt;
                a[j] -= powof2;
            }
        }
        // if there are more zeros, set a bit
        // but check whether it doesn't exceed given k
        if(cnt*2 < n && ans+powof2 <= k)
            ans += powof2;
        powof2 /= 2LL;
    }
    //cout<<ans<<" ";
    long long sum = 0;
    for(i=0;i<n;++i)    sum += (ans^b[i]);
    cout<<sum<<"\n";
}

start_cooking
{
    main_ingredient_added
    //int t;
    //cin>>t;
    //while(t--)
        cook();
    food_is_ready
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    int num[n];
    for (int ii = 0; ii < n; ++ii)
    {
        std::cin >> num[ii];
    }

    bool is = true;
    int count = 0;
    while (is)
    {
        for (int ii = 0; ii < n; ++ii)
        {
            if ((num[ii] % 2) != 0)
            {
                is = false;
                break;
            }
            else
            {
                num[ii] /= 2;
            }
        }
        if (is)
        {
            ++count;
        }
    }

    std::cout << count;
}

Measured memory_bytes: 256
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0002
 */
#include <iostream>
#include <sstream>

using namespace	std;

int
main()
{
	string line;
	while (getline(cin, line)) {
		int a, b;
		istringstream iss(line);
		ostringstream oss;
		iss >> a >> b;
		oss << a + b;
		cout << oss.str().length() << endl;
	}
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N;
    cin >> N;
    vl A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    ll ans = 0;
    reverse(all(A));reverse(all(B));
    
    rep(i,N){
        ll a = (A[i]+ans+B[i]-1)/B[i];
        ans += a*B[i]-A[i]-ans;
    }
    
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 1792
#include <set>          
#include <map>           
#include <list>
#include <ctime>
#include <deque>         
#include <bitset>        
#include <vector>
#include <list>
#include <stack>
#include <random>		 
#include <string>       
#include <numeric>      //  needed for  accumulate
#include <utility>      // needed for std:: move
#include <iterator> 
#include <iostream>   
#include <algorithm> 
#include <functional>    
#include <cmath>         
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair                     
#define srt(x) sort(x.begin(),x.end())         
#define mod static_cast<long long> (1e9+7)     
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define pi 3.14159265358979323846
#define testing 0
using namespace std;
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		in >> x;
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		in << x << " ";
	return in;
}
long long fast(long long a, long long b, long long mid)
{
	if (b == 0)
		return 1;
	a %= mid;
	long long ans = 1;
	while (b)
	{
		if (b & 1)
		{
			ans = (ans*a) % mid;
		}
		a *= a;
		a %= mid;
		b >>= 1;
	}
	return ans;
}
class solve
{
	long long n,m;
public:
	solve()
	{
		cin >> n >> m;
		if(n%3==0 || m%3==0 || (n+m)%3==0)
		{
			cout <<"Possible\n";
		}
		else
			cout <<"Impossible\n";
	}
};
 
int32_t main()
{
	int t = 1, i = 1;
//	scanf("%d", &t);
	while (t--)
	{
		new solve;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b;char op;
    while(cin >> a >> op >> b){
        int res = 0;
        if(op== '?')break;
        if(op == '+') res+=a+b;
        else if(op == '-')res+=a-b;
        else if(op == '*')res+=a*b;
        else res = a/b;
        cout << res << endl;
    }
}





Measured memory_bytes: 3016
#include<iostream>
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++)
                if(i*500+j*100+k*50==x)
                    ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(b>=c){
    cout<<"delicious"<<'\n';
  }
  else if(b<c && c-b<a+1){
    cout<<"safe"<<'\n';
  }
  else if(b<c && c-b>=a+1){
    cout<<"dangerous"<<'\n';
  }
  return 0;
}


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

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<vector<Edge>> g;

  Dijkstra(int n) : g(n) {}

  void addEdge(int u, int v, T w) { g[u].push_back({v, w}); }
  vector<vector<T>> build(int s) {
    struct State {
      int to;
      int t;
      bool operator<(const State& other) const {
        return (to != other.to) ? to < other.to : t < other.to;
      };
    };
    using Node = pair<T, State>;
    vector<vector<T>> dist(g.size(), vector<T>(3, -1));
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s][0] = 0, {s, 0}});
    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      for (auto&& v : g[u.to]) {
        int nt = (u.t + 1) % 3;
        if (dist[u.to][u.t] < d) continue;
        if (dist[v.to][nt] < 0 || dist[v.to][nt] > dist[u.to][u.t] + v.cost) {
          dist[v.to][nt] = dist[u.to][u.t] + v.cost;
          pq.push({dist[v.to][nt], {v.to, nt}});
        }
      }
    }
    return dist;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  Dijkstra<int> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v, u--, v--;
    g.addEdge(u, v, 1);
  }

  int s, t;
  cin >> s >> t, s--, t--;
  auto d = g.build(s);
  int ans = d[t][0];
  cout << ((ans < 0) ? -1 : ans / 3) << endl;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> B(N-1);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> B[i];
    }
    ll ans = B[0] + B[N-2];
    for ( int i = 1; i < N-1; i++ ) {
        ans += min(B[i-1],B[i]);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

double dp[40000 + 1][200 + 1];

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

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

  int tt = 0;
  rep (i, 40001) rep (j, 201) dp[i][j] = -1;
  dp[0][0] = 0;

  rep (i, n) rep (j, t[i] * 2) {
    rep (k, v[i] * 2 + 1) if (dp[tt][k] != -1) {
      dp[tt + 1][k] = max(dp[tt + 1][k], dp[tt][k] + (k / 2.0 + k / 2.0) / 4);
      if (k + 1 <= v[i] * 2) {
        dp[tt + 1][k + 1] = max(dp[tt + 1][k + 1], dp[tt][k] + (k / 2.0 + (k + 1) / 2.0) / 4);
      }
      if (k - 1 >= 0) {
        dp[tt + 1][k - 1] = max(dp[tt + 1][k - 1], dp[tt][k] + (k / 2.0 + (k - 1) / 2.0) / 4);
      }
    }
    tt++;
  }

  printf("%.10f\n", dp[tt][0]);
}


Measured memory_bytes: 63104
n = gets.to_i
as = gets.split.map(&:to_i)
MAX = 2 * 10**5

cs = Array.new(MAX + 1, 0)
as.each do |a|
  cs[a] += 1
end

sum = cs.inject(0) do |r, v|
  r + v * (v - 1) / 2
end

as.each do |a|
  c = cs[a]
  diff = (c - 1) # c * (c - 1) / 2 - (c - 1) * (c - 2) / 2

  puts sum - diff
end


Measured memory_bytes: 23940
n, m, x, y = map(int, input().split())
xl = list(map(int, input().split()))
yl = list(map(int, input().split()))
xl.sort()
yl.sort()
if xl[-1] >= yl[0]:
  print('War')
  quit()
for i in range(xl[-1]+1, yl[0]+1):
  if i>x and i<=y:
    print('No War')
    quit()
print('War')

Measured memory_bytes: 3064
#include <stdio.h>

int swap(int *a, int *b)
{
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}
  
int main()
{
  int x, y;

  scanf("%d %d", &x, &y);
  if (x < y) swap(&x, &y);

  while (1) {
    x %= y;
    if (!x) break;
    swap(&x, &y);
  }

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

  return 0;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	set<int> a;
	rep(snip_i, m){
		int in;
		cin >> in;
		a.insert(in);
	}
	vector<ll> dp(n+1, 0);
	dp.at(0) = 1;
	rep2(i, 1, n+1){
		if(a.count(i) == 1) continue;
		dp.at(i) = dp.at(i-1);
		if(i > 1) dp.at(i) = (dp.at(i) + dp.at(i-2)) % 1000000007;
	}
	cout << dp.at(n) << endl;
	return 0;
}

Measured memory_bytes: 5760
k = list('keyence')
s = list(input())
while len(k) > 0:
    if k[0] == s[0]:
        k.pop(0)
        s.pop(0)
    else:
        break
while len(k) > 0:
    if k[-1] == s[-1]:
        k.pop()
        s.pop()
    else:
        break
if len(k) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064