akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  bool ans = false;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7') ans = true;
  cout << (ans ? "Yes" : "No") << endl;
}

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

int	main(void)
{
	char str[11];
	scanf("%s",str);

	if(strcmp(str, "hi") == 0 || strcmp(str,"hihi") ==0||strcmp(str,"hihihi")==0||strcmp(str,"hihihihi")==0||strcmp(str,"hihihihihi")==0)
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    vector<double> D(n); rep(i, n) cin >> D[i];
    int m; cin >> m;
    vector<ll> T(m); rep(i, m) cin >> T[i];

    sort(all(D));
    bool ok = true;
    rep(i, m){
        auto iter = lower_bound(all(D), T[i]);
        if(iter == D.end()) {ok = false; break;}
        int index = distance(D.begin(), iter);
        if(D[index] != T[i]){ok = false; break;}
        D[index] -= 0.1;
    }
    if(ok) cout << "YES" << ln;
    else cout << "NO" << ln;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[100000],k1,i,j,k;
	long long sum=0,ans=1;
	memset(a,0,sizeof(a));
	cin>>k1;
	sum += k1;
	a[k1]++;
	for(i=0;i<n-1;i++)
	{
		cin>>k;
		sum += k;
		a[k]++;
	}
	//for(i=0;i<n;i++)	cout<<a[i]<<" ";
	if(k1!=0 || a[0]!=1)
	{
		cout<<0;
	}
	else
	{
		long long int sum1=0;
		for(i=1;i<n;i++)
		{
			if(a[i] == 0)
				break;
			else
				sum1 += a[i]*i;
		}
		if(sum != sum1)
		{
			cout<<0;
		}
		else
		{
			if(sum == 0)
			{
				cout<<0;
			}
			else
			{
				for(i=0;i<n-1 && a[i]!=0;i++)
				{
					for(j=0;j<a[i+1];j++)
					{
						ans = ans%998244353 * a[i]%998244353 ;
						ans %= 998244353;
					}
				}
				cout<<ans;
			}
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B,C;
  cin>>A>>B>>C;
  if(C>=A&&C<=B){
    ce("Yes")
  }else{
    ce("No")
  }
}

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

int main() 
{
	int n, m[101][101], p[101];
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> p[i - 1] >> p[i];

	for (int i = 1; i <= n; i++) 
		m[i][i] = 0;
		
	for (int j = 2; j <= n; j++) 
	{
		for (int i = 1; i <= n - j + 1; i++) 
		{
			int k = i + j - 1;
			m[i][k] = INT_MAX;
			for (int l = i; l <= k - 1; l++)
				m[i][k] = min(m[i][k], m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k]);
		}
	}

	cout << m[1][n] << endl;

	return 0;
}

Measured memory_bytes: 3136
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int h=sc.nextInt();		//モンスターHP
		int n=sc.nextInt();		//n種類の必殺技
		
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			h=h-a;
		}
			if(h<=0) {
				 System.out.println("Yes");
			}else {
				 System.out.println("No");
			}
			sc.close();
		}

	}

Measured memory_bytes: 48308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll a;
	long double b;
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  string s; cin >> s;
  string t; cin >> t;
  int ma = 0;
  for(int i=0;i<n;++i) {
    int cnt = 0;
    for(int j=i;j<n;++j) {
      if(s[j] == t[j-i]) cnt++;
      else break;
    }
    ma = max(ma, cnt);
  }
  cout << 2 * n - ma << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	
	int N; cin >> N;
	ll ans = 0;
	int last;
	for (int i = 1; i <= N; i++) {
		int a; cin >> a;
		if (i == 1) last = a;
		else {
			if (last > a) ans += last - a;
			else last = a;
		}
	}
	cout << ans;

}


Measured memory_bytes: 3616
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll K,N,cnt=0,res;
  P p[100001];
  cin >> N >> K;
  REP(i,N)
    cin >> p[i].first >> p[i].second;
  sort(p,p+N);
  REP(i,N){
    cnt += p[i].second;
    if(K <= cnt){
      cout << p[i].first << endl;
      return 0;
    }
  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i, j, N, v;
  int *A;

  scanf("%d",&N);
  A = (int *)malloc(sizeof(int) * N);
 
  for( i = 0 ; i < N ; i++ ){
    scanf("%d",&A[i]);
  }
    printf("%d",A[0]);
    for( j = 1 ; j < N ; j++ ){
      printf(" %d",A[j]);
    }
    printf("\n");

  /*   sort   */
  for( i = 1 ; i < N ; i++ ){
    v = A[i];
    j = i - 1;
    while( ( j >= 0 ) && (A[j] > v) ){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    printf("%d",A[0]);
    for( j = 1 ; j < N ; j++ ){
      printf(" %d",A[j]);
    }
    printf("\n");
  }

  
  return 0;
}



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

using Graph = vector<vector<int>>;

int main(){
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    queue<int> que;
    int ans = -1;
    for (int v = 0; v < N; ++v) {
        if (dist[v] != -1) continue;
        int cnt = 1;
        dist[v] = 0;
        que.push(v);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (auto nv : G[v]) {
                if (dist[nv] == -1) {
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                    cnt++;
                }
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 15512
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <iterator>
using namespace std;

string GetSubstringKth(string s, size_t K){
    set<string> candidate;
    size_t itr = 0;
    while(s.size()!=itr){
        candidate.insert(s.substr(itr, min(s.size()-itr,(size_t)5)));
        itr++;
    }
    vector<string> candidateV(candidate.begin(), candidate.end());
    set<string> candidate2;
    for(size_t i=0;i<min((size_t)5,candidateV.size());i++){
        for(size_t j=0;j<candidateV.at(i).size();j++){
            candidate2.insert(candidateV.at(i).substr(0,j+1));
        }
    }
    vector<string> candidateV2(candidate2.begin(), candidate2.end());
    return candidateV2[K-1];
}

int main()
{
    string s;
    size_t K;
    cin >> s;
    cin >> K;
    auto sub = GetSubstringKth(s, K);
    cout<<sub<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

typedef tuple<int,int,int> T;
typedef pair<int,int> P;
vector<T> Edges;
map<P,int> Stations;//(station,company)->sta_id
vector<P> E[500000];//to,fee
bool isupdated[500000];
int dist[500000];
#define mygc(c) (c)=getchar_unlocked()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}


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

    int N,M;
    //cin>>N>>M;
    reader(&N); reader(&M);
    for(int i=0;i<N;i++) Stations[P(i,0)]=0;
    for(int i=0;i<M;i++){
        int p,q,c;
        //cin>>p>>q>>c;
        reader(&p); reader(&q); reader(&c);
        Edges.emplace_back(p,q,c);
        Stations[P(p,c)]=0;
        Stations[P(q,c)]=0;
    }
    int c=0;
    for(auto &p:Stations) p.second=c++;
    fill(dist,dist+c,100000000);
    for(auto &s:Stations){
        auto p = s.first;
        int station=p.first, company=p.second, sta_id=s.second;
        if(company==0) continue;
        E[Stations[P(station,0)]].emplace_back(sta_id,1);
        E[sta_id].emplace_back(Stations[P(station,0)],0);
    }
    for(auto &e:Edges){
        int p=get<0>(e), q=get<1>(e), c=get<2>(e);
        int sp = Stations[P(p,c)], sq = Stations[P(q,c)];
        E[sp].emplace_back(sq,0);
        E[sq].emplace_back(sp,0);
    }

    deque<P> que;//cost,sta_id
    que.emplace_back(0,Stations[P(1,0)]);
    dist[Stations[P(1,0)]]=0;
    int dest=Stations[P(N,0)];
    while(!que.empty()){
        P p = que.front(); que.pop_front();
        int cost=p.first, sta_id=p.second;
        if(sta_id==dest){
            cout<<cost<<endl;
            return 0;
        }
        if(isupdated[sta_id]) continue;
        isupdated[sta_id]=true;

        for(auto &e:E[sta_id]){
            int to=e.first, fee=e.second;
            if(cost+fee<dist[to]){
                dist[to]=cost+fee;
                if(fee){
                    que.emplace_back(cost+fee,to);
                }else{
                    que.emplace_front(cost+fee,to);
                }
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 59184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll N, A, B, C;
vi l;

int main()
{
    cin >> N >> A >> B >> C;
    l = vi(N);
    REP(i, N)
    {
        cin >> l[i];
    }

    ll ans = INF;
    REP(p, 1LL << (2 * N))
    {
        vi x = vi(4);
        vi mp = vi(4);
        REP(i, N)
        {
            ll j = (p >> 2 * i) & 3;
            x[j] += l[i];
            mp[j] += 10;
        }
        if (x[1] > 0 and x[2] > 0 and x[3] > 0)
        {
            ans = min(ans, abs(x[1] - A) + mp[1] - 10 + abs(x[2] - B) + mp[2] - 10 + abs(x[3] - C) + mp[3] - 10);
        }
    }

    OUT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
char s[1000000];
int a[1000000], b[1000000];

int main(){
    scanf("%d", &N);
    REP(i, N) scanf("%s", &s[i]);

    a[0] = 0;
    b[N+1] = 0;

    REP(i, N){
        if(s[i] == 'W'){
            a[i+1] = a[i] + 1;
        } else if (s[i] == 'E'){
            a[i+1] = a[i];
        }
    }

    REP(i, N){
        if(s[N-1-i] == 'E'){
            b[N-i] = b[N-i+1] + 1;
        } else if (s[N-1-i] == 'W'){
            b[N-i] = b[N-i+1];
        }
    }

    int ans = INF;

    REP(i, N){
        ans = min(ans, a[i]+b[i+2]);
    }

    printf("%d", ans);

	return 0;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int n=s.size();
    long int ans=0;

    //bit
    //i...+を差し込む位置 n-1個
    for(int i=0;i<(1<<n-1);i++){
        long int tmp=0;
        int l=0;
        int r=l+1;
        //j...
        for(int j=0;j<n;j++){
            //最下位bitが1or0
            if((i>>j) & 1){
                tmp+=stol(s.substr(l,r-l));
                l=r;
                r=l+1;
            }else if(j==n-1){
                tmp+=stol(s.substr(l,r));
            }else{
                r++;
            }
        }
        //cout << tmp << endl;
        ans+=tmp;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n+2);
    a[0] = a[n+1] = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i+1];
    }
    LL total = 0;
    for(int i = 0; i+1 < n+2; ++i){
        total += abs(a[i] - a[i+1]);
    }
    for(int i = 0; i < n; ++i){
        cout << total + abs(a[i] - a[i+2]) - abs(a[i] - a[i+1]) - abs(a[i+1] - a[i+2]) << endl;
    }
    return 0;
}



Measured memory_bytes: 2048
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var INF = 1e15;

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var l = o.a();
  var a = o.m(m);
  var q = o.a();
  var s = o.m(q);
  var wf = xArray(INF,n,n);
  for(var i = 0; i < n; i++)wf[i][i] = 0;
  for(var i = 0; i < m; i++){
    wf[a[i][0]-1][a[i][1]-1] = a[i][2];
    wf[a[i][1]-1][a[i][0]-1] = a[i][2];
  }
  for(var k = 0; k < n; k++)
  for(var i = 0; i < n; i++)
  for(var j = 0; j < n; j++){
    if(wf[i][k]+wf[k][j] < wf[i][j])wf[i][j] = wf[i][k]+wf[k][j];
  }
  for(var i = 0; i < n; i++)
  for(var j = 0; j < n; j++){
    if(wf[i][j]){
      if(l < wf[i][j])wf[i][j] = INF;
      else wf[i][j] = 1;
    }
  }
  for(var k = 0; k < n; k++)
  for(var i = 0; i < n; i++)
  for(var j = 0; j < n; j++){
    if(wf[i][k]+wf[k][j] < wf[i][j])wf[i][j] = wf[i][k]+wf[k][j];
  }
  var ans = [];
  for(var i = 0; i < q; i++){
    var u = wf[s[i][0]-1][s[i][1]-1];
    if(u >= INF)u = 0;
    ans.push(u-1)
  }
  return ans.join("\n");
}

Measured memory_bytes: 75432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		/*int count = 0;*/

		Scanner scan = new Scanner(System.in);


		while (true) {

			int count = 0;

			int n = scan.nextInt();
			int x = scan.nextInt();

			if ((n == 0) && (x == 0)) {
				break;
			}
			else {
				for (int i = 1; i <= n - 2; i++) {

					for (int j = i + 1; j <= n - 1; j++) {
						
						int k;
						k = x - i - j;

						if (k <= n && j < k) {
							count++;
						}

						/*for (int k = j + 1; k <= n; k++) {

							if (i + j + k == x) {
								count++;
							}
						}*/
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] input = ReadInt();
			int D = input[0];
			int N = input[1];
			int ans;
			if (D == 0)
			{
				if(N == 100)
				{
					ans = N + 1;
				}
				else
				{
					ans = N;
				}
				
			}
			else if (D == 1)
			{
				if (N == 100)
				{
					ans = N * 101;
				}
				else
				{
					ans = N * 100;
				}
			}
			else
			{
				if (N == 100)
				{
					ans = N * 10100;
				}
				else
				{
					ans = N * 10000;
				}
			}
			Console.WriteLine(ans);
			Console.ReadKey();
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadInt()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
H, W = map(int, input().split())
#A = str(input())
c = []
for _ in range(H) :
  c.append(str(input()))
#print (c)

for i in range(H) :
  for _ in range(2) :
    print (c[i])




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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	int m, n, s = 0, x;
	cin >> m >> n;
	for (int i = 0; i < n; i++){
		cin >> x;
		s += x;
	}
	cout << max(-1ll, m - s);
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int64 N, M;
vector<int32> G[112345];
int64 dp1[112345][2] = {};
int64 dp2[112345] = {};

int64 dfs1(int32 v, int32 p, int32 c){ // c== 1 -> black
	if(~dp1[v][c]) return dp1[v][c];
	dp1[v][c] = 1;
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		int64 x = 0;
		REP(j, c+1){
			x += dfs1(G[v][i], v, j);
		}
		dp1[v][c] = dp1[v][c]*x%M;
	}
	return dp1[v][c];
}

int64 dfs2(int32 v, int32 p, int64 val){
	if(~dp2[v]) return dp2[v];
	dp2[v] = 0;
	if(p == -1){
		dp2[v] = dfs1(v, p, 1);
	}else{
		dp2[v] = dfs1(v, p, 1)*val%M;
	}
	vector<int64> mul1(G[v].size()+1,1 ), mul2(G[v].size()+1, 1);
	REP(i, G[v].size()){
		if(G[v][i] == p){
			mul1[i+1] = val;
			mul2[G[v].size()-i] = val;
		}else{
			mul1[i+1] = dfs1(G[v][i], v, 0)+dfs1(G[v][i], v, 1);
			mul2[G[v].size()-i] = mul1[i+1];
		}
	}
	REP(i, G[v].size()) mul1[i+1] = mul1[i+1]*mul1[i]%M;
	REP(i, G[v].size()) mul2[i+1] = mul2[i+1]*mul2[i]%M;

	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		int64 mul = mul1[i]*mul2[G[v].size()-i-1]%M;
		mul = (mul+1)%M;
		dfs2(G[v][i], v, mul);
	}
	return dp2[v];
}

int main(void){
	memset(dp1, -1, sizeof dp1);
	memset(dp2, -1, sizeof dp2);
	cin >> N >> M;
	REP(i, N-1){  
		int32 x, y;
		cin >> x >> y; x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	REP(i, N){
		cout << dfs2(i, -1, 1)%M << endl;
	}
}


Measured memory_bytes: 22400
#include<iostream>
#include<string>
#include<tuple>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define loop(i, n) for (int i = 0; i < n; ++i)
#define loop1(i, n) for (int i = 1; i < n; ++i)
#define ti tuple<int, int, int>

const int INF = 1e9 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    int nxt[n], used[n];
    loop(i, n) {
        cin >> nxt[i];
        --nxt[i];
        used[i] = -1;
    }
    int cur = 0, cnt = 0;
    while (used[cur] == -1) {
        used[cur] = cnt++;
        cur = nxt[cur];
    }
    if (k < cnt || cur == 0) {
        k %= cnt;
        loop(i, n)
            if (used[i] == k)
                cout << i + 1;
    }
    else {
        k -= cnt;
        int x = used[cur];
        loop(i, n)
            used[i] -= x;
        cnt -= x;
        k %= cnt;
        loop(i, n)
            if (used[i] == k)
                cout << i + 1;
    }
    
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 6780
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d %d\n", 100, 100);
	int pt = b - 1;
	for (int i = 0; i < 50; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (i % 2 == 0 && j % 2 == 0 && pt > 0)printf("#"), pt--;
			else printf(".");
		}
		printf("\n");
	}
	pt = a - 1;
	for (int i = 0; i < 50; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (i % 2 == 1 && j % 2 == 0 && pt > 0)printf("."), pt--;
			else printf("#");
		}
		printf("\n");
	}
}

Measured memory_bytes: 128
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

void Main()
{
  ll a, b; cin >> a >> b;
  vll aa = enum_div(a), bb = enum_div(b);
  vll key;
  map<ll, ll> ans;
  rep(i, aa.size()) ans[aa[i]];
  rep(i, bb.size())
  {
    if(ans.count(bb[i]))
    {
      if(IsPrime(bb[i])) key.pb(bb[i]);
    }
  }
  fin(key.size() + 1);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int pos;
string str;
map<string, int> idx;

int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a/gcd(a,b)*b; }

vector<int> getCof(){
	vector<int> res(idx.size(), 0);
	if(str[pos]=='+'||str[pos]=='-'||str[pos]=='.'||str[pos]==')') return res;
	if(str[pos]=='('){ pos++; res = getCof(); pos++; }
	else {
		string t;
		t += str[pos++];
		if(pos<str.size()&&islower(str[pos])) t += str[pos++];
		res[idx[t]]++;
	}
	int mul = 1;
	if(isdigit(str[pos])){
		mul = str[pos++]-'0';
		if(isdigit(str[pos])) mul = 10*mul + str[pos++]-'0';
	}
	vector<int> next = getCof();
	for(int i=0;i<res.size();i++) res[i] = res[i]*mul + next[i];
	return res;
}

int main(){
	while(cin >> str){
		if(str == ".") break;
		int size = 0;
		idx.clear();
		for(int i=0;i<str.size();i++){
			string t;
			if(isupper(str[i])){
				t += str[i];
				if(i+1<str.size()&&islower(str[i+1])) t += str[i+1];
				if(!idx.count(t)){ idx[t] = size++; }
			}
		}
		pos = 0;
		bool rev = false;
		vector< vector<int> > v(size);
		while(str[pos]!='.'){
			if(str[pos]=='+') pos++;
			if(str[pos]=='-') { rev = true; pos += 2; }
			vector<int> cof = getCof();
			for(int i=0;i<size;i++)
				v[i].push_back(!rev ? cof[i] : -cof[i]);
		}
		for(int i=0;i<v[0].size()-1;i++){
			if(v[i][i]==0){
				int idx = i;
				while(!v[idx][i]) idx++;
				swap(v[i], v[idx]);
			}
			for(int j=0;j<size;j++){
				if(j == i) continue;
				if(v[j][i]==0) continue;
				int mulA = v[j][i]/gcd(v[i][i],v[j][i]);
				int mulB = v[i][i]/gcd(v[i][i],v[j][i]);
				for(int k=0;k<v[j].size();k++) v[j][k] = v[j][k]*mulB-v[i][k]*mulA;
			}
			for(int j=0;j<size;j++){
				int div = 0;
				for(int k=0;k<v[j].size();k++)
					if(v[j][k]!=0) div = !div ? abs(v[j][k]) : gcd(div, abs(v[j][k]));
				if(div!=0)
					for(int k=0;k<v[j].size();k++) v[j][k] /= div;
			}
		}
		long long mul = 1;
		for(int i=0;i<v[0].size()-1;i++) mul = lcm(mul, abs(v[i][i]));
		for(int i=0;i<v[0].size()-1;i++) cout << mul/abs(v[i][i])*abs(v[i].back()) << " ";
		cout << mul << endl;
	}
}

Measured memory_bytes: 0
import math

def resolve():
    cnt = 0
    n = int(input())
    ans = [0] * n
    m = math.ceil(math.sqrt(n))
    for x in range(1, m):
        for y in range(1, m):
            for z in range(1, m):
                a = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if a <= n:
                    ans[a-1] += 1
                else:
                    break
    
    for a in ans:
        print(a)

resolve()

Measured memory_bytes: 68872
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String A = sc.next();
        String B = sc.next();
        
        boolean a = A.equals("H");
        boolean b = B.equals("H");
        b = a?b:!b;
        System.out.println(b?"H": "D");
    }
}

Measured memory_bytes: 21332
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A<10 && B<10) {
      System.out.println(A*B);
    }else{
      System.out.println(-1);
    }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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 powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int n; cin >>n;
  set<int> A;
  rep(i, n){
    int buf; cin >>buf;
    A.insert(buf);
  }
  if (A.size() == n) cout <<"YES" <<endl;
  else cout <<"NO" <<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    // 前処理
    COMinit();

    reps(i,1,k+1){
        // 計算例
        cout << COM(n-k+1,i)*COM(k-1,i-1)%MOD << endl;
    }




}

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

#define int long long

signed main() {
	int a1, a2, a3, a4;
	cin >> a1 >> a2 >> a3 >> a4;
	int N;
	cin >> N;
	int mn2;
	int mn1;
	mn2 = a1 * 8;
	mn1 = a1 * 4;
	mn2 = min(mn2, a2 * 4);
	mn2 = min(mn2, a3 * 2);
	mn2 = min(mn2, a4 * 1);
	mn1 = min(mn1, a2 * 2);
	mn1 = min(mn1, a3 * 1);
	int res = (N / 2)*mn2 + (N % 2)*mn1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
int main(void){
    int n, i, a[101], diff_0_1, diff_1_2, diff_2_3, diff_3_4;
    
    while(1){
        scanf("%d", &n);
        if(n == 0) break;
        for(i=0; i<n+1; i++){
            scanf("%d", &a[i]);
        }
    
        diff_0_1 = a[1] - a[0];
        diff_1_2 = a[2] - a[1];
        diff_2_3 = a[3] - a[2];
        diff_3_4 = a[4] - a[3];
        
        if(diff_0_1 == diff_1_2 && diff_1_2 == diff_2_3 && diff_2_3 == diff_3_4){
            int diff = diff_0_1;
            for(i=4; i<n+1; i++){
                if(a[i+1]-a[i] != diff){
                    printf("%d\n", a[i+1]);
                    break;
                }
            }
        }
        else if(diff_0_1 == diff_1_2 && diff_1_2 == diff_2_3){
            printf("%d\n", a[4]);
        }
        else if(diff_0_1 == diff_1_2 && diff_1_2 == (diff_2_3 + diff_3_4)){
            printf("%d\n", a[3]);
        }
        else if(diff_0_1 == (diff_1_2 + diff_2_3) && diff_0_1 == diff_3_4){
            printf("%d\n", a[2]);
        }
        else if((diff_0_1 + diff_1_2) == diff_2_3 && diff_2_3 == diff_3_4){
            printf("%d\n", a[1]);
        }
        else if(diff_1_2 == diff_2_3 && diff_2_3 == diff_3_4){
            printf("%d\n", a[0]);
        }
    }
    return 0;
}



Measured memory_bytes: 2104
/*
a b 0 1 2 4 8 16 ... 2^29
*/
#include<cstdio>
#include<vector>

using namespace std;

#define BIT_MAX 30

struct cmd_t
{
	int act, i, j, k;
	bool operator==(const cmd_t&rhs)
	{
		if(act!=rhs.act) return false;
		if(i!=rhs.i) return false;
		if(j!=rhs.j) return false;
		if(k!=rhs.k) return false;
		return true;
	}
};

vector<cmd_t> ans;
void cmd(int act, int i, int j, int k)
{
	ans.push_back(cmd_t{act, i, j, k});
}

enum{
	A=0,
	B,
	ANS,
	ZERO,
	ONE,
	T,
	T1, T2,
	X,
	CARRY, NCARRY,
	BB_REV, BA_TAR, BC_TAR,
	BEKI2=100,
	BEKI2_=200,
	CHK_B_B=300,
	SHIFT_A=400,
	BIN_A=500,
	BIN_B=600,
	BIN_C=700,
	WORK1=1000,
	WORK2=2000,
};

int beki2(int bit)
{
	return BEKI2+bit;
}

int beki2_(int bit)
{
	return BEKI2_+bit;
}


int chk_b_bit(int bit)
{
	return CHK_B_B+bit;
}


void my_xor(int a, int b, int x)
{
	cmd('<', b, a, T1);
	cmd('<', a, b, T2);
	cmd('+', T1, T2, x);
}


void adder(int a, int b, int c, int x, int y)
{
	my_xor(a, b, T);
	my_xor(T, c, x);

	cmd('+', a, b, T1);
	cmd('+', T1, c, T1);
	cmd('<', ONE, T1, y);
}


void set(int a, int b)
{
	cmd('+', ZERO, a, b);
}


void value_divide(int v, int t, int work)
{
	int tmp=work+70;
	int is_bit_used=work+71;

	for(int i=0;i<=BIT_MAX*2;i++) cmd('+', ZERO, beki2_(i), work+i);
	for(int i=BIT_MAX*2;i>=0;i--)
	{
		cmd('<', work+i, v, is_bit_used);
		cmd('+', ZERO, is_bit_used, t+i);
		cmd('+', ZERO, is_bit_used, tmp);
		for(int j=0;j<i;j++) cmd('+', tmp, tmp, tmp);
		for(int j=i;j>=0;j--)
		{
			cmd('+', work+j, tmp, work+j);
		}
	}
}



int main(void)
{
	cmd('<', ZERO, A, ONE);
	// a[100]-[129] 1 2 4 8 ... 2^29
	// a[200]-[229] 0 1 3 7 ... 2^29-1
	set(ONE, beki2(0));
	for(int i=1;i<=BIT_MAX*2;i++)
	{
		cmd('+', beki2(i-1), beki2(i-1), beki2(i));
		cmd('+', beki2_(i-1), beki2(i-1), beki2_(i));
	}

	value_divide(A, BIN_A, WORK1);
	value_divide(B, BIN_B, WORK1);

	for(int bb=0;bb<=BIT_MAX;bb++)
	{
		cmd('<', BIN_B+bb, ONE, BB_REV);
		cmd('+', ZERO, ZERO, CARRY);
		for(int ba=0;ba<=BIT_MAX;ba++)
		{
			int bc=bb+ba;
			cmd('<', BB_REV, BIN_A+ba, BA_TAR);
			set(BIN_C+bc, BC_TAR);
			adder(BA_TAR, BC_TAR, CARRY, BIN_C+bc, NCARRY);
			set(NCARRY, CARRY);
		}
	}
	set(ZERO, ANS);
	for(int i=BIT_MAX*2;i>=0;i--)
	{
		cmd('+', ANS, ANS, ANS);
		cmd('+', ANS, BIN_C+i, ANS);
	}

	int n=ans.size();
	printf("%d\n", n);
if(1)
{
	for(auto&m:ans) printf("%c %d %d %d\n", m.act, m.i, m.j, m.k);
}
else
{
	cmd_t prev=ans[0];
	int c=1;
	for(int i=1;i<n;i++)
	{
		auto&m=ans[i];
		if(prev==m)
		{
			c++;
		}
		else
		{
			printf("%c %d %d %d", prev.act, prev.i, prev.j, prev.k);
			if(c>1) printf(" x %d\n", c);
			else printf("\n");
			c=1;
		}
		prev=m;
	}
}

	return 0;
}


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

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<=b;i++)
using namespace std;
int n;const int maxn=1e5+5;
typedef long long int ll;
ll a[maxn];
__int128 aa[maxn];
int main(){
	cin>>n;rep(i,1,n)cin>>a[i];
	rep(i,1,n)aa[i]=a[i];
	int tot=0;rep(i,1,n)if(aa[i]<0)tot++;
	__int128 ans=0;
	rep(i,1,n)ans+=abs(aa[i]);
	if(tot&1){
		__int128 ma=0x7f7f7f7f7f7f7f7fll;
		rep(i,1,n)ma=min(ma,abs(aa[i]));
		rep(i,1,n)if(abs(aa[i])==ma){ans-=2*abs(aa[i]);break;}
	}
	cout<<ll(ans)<<endl;
	return 0;}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int d; cin >> d;
    if (d == 25) cout << "Christmas" << endl;
    else if (d == 24) cout << "Christmas Eve" << endl;
    else if (d == 23) cout << "Christmas Eve Eve" << endl;
    else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;

}

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

using namespace std;

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m;
   cin >> n >> m;
   if(n == 1 || m == 1)
      cout << 1;
   else
      cout << (1ll * n * m + 1) / 2;
   return 0;
}


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

const int maxn=2e5+7;
char a[maxn],c[maxn];
int n,k,r,s,p,ans;

int main()
{
	scanf("%d %d",&n,&k);
	scanf("%d %d %d",&r,&s,&p);
	scanf("%s",c+1);
	for(int i=1;i<=n;++i) {
		if(i<=k) {
			if(c[i]=='r') {
				a[i]='p';
				ans+=p;
			}
			else if(c[i]=='s') {
				a[i]='r';
				ans+=r;
			}
			else {
				a[i]='s';
				ans+=s;
			}
		}
		else {
			if(c[i]=='r') {
				if(a[i-k]=='p') {
					if(c[i+k]=='s') a[i]='s';
					else a[i]='r';
				}
				else a[i]='p',ans+=p;
			}
			else if(c[i]=='s') {
				if(a[i-k]=='r') {
					if(c[i+k]=='p') a[i]='p';
					else a[i]='s';
				}
				else a[i]='r',ans+=r;
			}
			else {
				if(a[i-k]=='s') {
					if(c[i+k]=='r') a[i]='r';
					else a[i]='p';
				}
				else a[i]='s',ans+=s;
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int H,W,i,j;
 
  while( scanf("%d %d",&H,&W),!(H==0&&W==0)){
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(i==0||j==0||i==H-1||j==W-1){
	  printf("#");
	}
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
      
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
int main()
{
	int i;
	cin>>n>>s; 
    for(i=0;i<n;i++)
        if(s[i]=='W')
            cnt++;
    for(i=n-cnt;i<n;i++)
        if(s[i]!='W')
            ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3700
// problem: "https://atcoder.jp/contests/abc158/tasks/abc158_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll power(ll a,ll n,ll p)
{
    if(!n)
        return 1;

    ll b = 1;
    if(n%2)
        b = a;

    ll ans = power(a,n/2,p);
    ans = ((ans*ans)%p * b)%p;

    return ans;
}

ll numStr(string &s,ll n,ll p)
{
    if(p == 2 || p == 5)
    {
        ll c,i;
        c = 0;
        for(i=0;i!=n;i++)
            if(stoi(s.substr(i,1))%p == 0)
                c += i+1;

        return c;
    }


    vector<ll>V(n,0);
    ll i,x;
    x = 0;
    for(i=0;i!=n;i++)
    {
        x = ((x * 10)%p + stoi(s.substr(i,1)))%p;       // define
        V[i] = (x * power(power(10,i,p),p-2,p))%p;        // define
    }

    ll c = 0;
    vector<ll>P(p,0);
    for(i=0;i!=n;i++)
    {
        if(V[i] == 0)
            c += 1 + P[V[i]];
        else
            c += P[V[i]];

        P[V[i]]++;
    }

    return c;
}

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

    string s;
    cin>>s;

    cout<<numStr(s,n,p);        // define

    return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll sum[500],v[500];
ll dp[500][500];

ll solve(int l,int r){
    if(l>r)return 0;
    if(l==r)return 0;
    if(dp[l][r]!=-1)return dp[l][r];
    ll res=ll(1e18);
    for(int i=l;i<r;i++){
        if(l==0)res=min(res,solve(l,i)+solve(i+1,r)+v[r]);
       else res=min(res,solve(l,i)+solve(i+1,r)+v[r]-v[l-1]);
    }
    return (dp[l][r]=res);
}

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=1;i<n;i++)v[i]+=v[i-1];
    for(int i=0;i<500;i++)for(int j=0;j<500;j++)dp[i][j]=-1;
    cout<<solve(0,n-1);
    
    
}

Measured memory_bytes: 2176
import sys
readline = sys.stdin.readline

N = readline().rstrip()
N = list(map(int, N))
L = len(N)

total = 0

for i in range(L - 1, -1, -1):
    k = N[i]
    if k <= 4:
        total += k
    elif k >= 6:
        total += 10 - k
        if i == 0:
            total += 1
        else:
            N[i - 1] += 1
    else:
        if i == 0:
            total += k
        else:
            if N[i - 1] <= 4:
                total += k
            else:
                total += 10 - k
                N[i - 1] += 1

print(total)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 212345;
const ll INF = 1LL << 61;
ll dp[MAX_N][3];

int main2() {
  int N = nextInt();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();

  REP(i, MAX_N) REP(j, 3) dp[i][j] = -INF;

  const int O = 2;
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    chmax(dp[i+O][0], dp[i-2+O][0] + A[i]);
    chmax(dp[i+O][1], dp[i-2+O][1] + A[i]);
    chmax(dp[i+O][2], dp[i-2+O][2] + A[i]);
    if (i-3+O >= 0) {
      chmax(dp[i+O][1], dp[i-3+O][0] + A[i]);
      chmax(dp[i+O][2], dp[i-3+O][1] + A[i]);
    }
    if (i-4+O >= 0) {
      chmax(dp[i+O][2], dp[i-4+O][0] + A[i]);
    }
  }

  // REP(k, 3) {
  //   REP(i, N+3) cout << dp[i][k] << " ";
  //   cout << endl;
  // }

  if (N % 2 == 1) {
    ll ans = max({
      dp[O+N-3][0],
      dp[O+N-2][1],
      dp[O+N-1][2],
    });
    cout << ans << endl;
  } else {
    ll ans = max({
      dp[O+N-2][0],
      dp[O+N-1][1],
    });
    cout << ans << endl;

  }

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 9792
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datH, datW, datK) = readLine.split(" ").map(_.toInt)
    val datA = for(i <- 1 to datH) yield readLine

    var ans = 0;

    val maxH = math.pow(2, datH).toInt
    val maxW = math.pow(2, datW).toInt
    for (i <- 0 until maxH; j <- 0 until maxW) {
      def countInLine(ln:Int, chcol:Int): Int = {
        var a = 0;
        for (x <- 0 until datW) {
          if (((chcol & (math.pow(2, x).toInt)) != 0) && (datA(ln)(x) == '#'))
            a += 1
        }
        a
      }

      var a = 0;
      for (x <- 0 until datH) {
        if ((i & (math.pow(2, x).toInt)) != 0) a += countInLine(x, j)
      }

      //println("DEBUG:" + i + " " + j + " " + a)
      if (a == datK) ans += 1
    }

    println(ans)
  }
}


Measured memory_bytes: 54856
import itertools
import math


N = int(input())
cities = [tuple(map(int, input().split())) for _ in range(N)]

distance = 0
for c in itertools.combinations(range(N), 2):
    c1, c2 = c
    distance += ((cities[c1][0] - cities[c2][0]) ** 2 + (cities[c1][1] - cities[c2][1]) ** 2) **0.5

answer = 2 * distance * (N-1) * math.factorial(N-2) / math.factorial(N)

print(answer)

Measured memory_bytes: 3064