akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
vector<vector<ll> >v;

void bfs(vector<ll>&vis,vector<ll>&ans,ll s){
	
	queue<pair<ll,ll> >q;
	q.push({s,0});
	vis[s]=1;
	while(!q.empty()){
		pair<ll,ll>p=q.front();
		q.pop();
		if(p.ff>s){
			ans[p.ss]++;
		}
		for(auto u:v[p.ff]){
			if(!vis[u]){
				vis[u]=1;
				q.push({u,p.ss+1});
			}
		}
	}
	
	return ;
}

void init(vector<ll>&vis,ll en){
	for(ll i=1;i<=en;i++){
		vis[i]=1;
	}
	return ;
}


int main(){
	io;
	ll n,x,y;
	cin>>n>>x>>y;
	v.resize(n+1);
	for(ll i=1;i<n;i++){
		v[i].push_back(i+1);
		v[i+1].push_back(i);
	}
	
	v[x].push_back(y);
	v[y].push_back(x);
	vector<ll>ans(n+1);
	
	for(ll i=1;i<=n;i++){
		vector<ll>vis(n+1);
		//init(vis,i-1);
		bfs(vis,ans,i);
	}
	
	for(ll i=1;i<n;i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
//
// Created by 12243 on 2017/10/28.
//

//
// Created by 12243 on 2017/10/28.
//
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int change=0;

    for (int i=s.size()-t.size();i>=0;i--){
        int flag=1;
        for (int j=0;j<t.size();j++){
            if ((s[i+j]!='?'&&s[i+j]!=t[j])){
                flag=0;
                break;
            }
        }
        if (flag){
            for (int j=0;j<t.size();j++){
                s[i+j]=t[j];
            }
            change=1;
            break;
        }
    }
    if (!change) cout<<"UNRESTORABLE";
    else {
        for (int i = 0; i < s.size(); i++) {
            if (s[i]=='?') s[i]='a';
        }
        cout<<s;
    }


}



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

using namespace std;

#define MAX 15010
typedef pair<int,int> pii;
typedef pair<pii,int> P;

bool check(int a,int b,int c){
  if(a >= b+c || b >= a+c || c >= a+b) return false;
  return true;
}

int main(){
  vector<int> prime;
  bool p[MAX];
  fill(p,p+MAX,true);
  p[0] = p[1] = false;
  for(int i = 2 ; i < MAX ; i++){
    if(!p[i]) continue;
    prime.push_back(i);
    for(int j = 2*i ; j < MAX ; j += i){
      p[j] = false;
    }
  }
  int T;
  while(cin >> T, T){
    int cnt = 0;
    set<P> st;
    int size = prime.size();
    for(int i = 0 ; i < size ; i++){
      for(int j = i ; j < size ; j++){
        int k = T-prime[i]-prime[j];
        if(k < 0 || k >= MAX || !p[k]) continue;
        int a[3] = {prime[i],prime[j],k};
        sort(a,a+3);
        if(st.count(P(pii(a[0],a[1]),a[2]))) continue;
        st.insert(P(pii(a[0],a[1]),a[2]));
        if(check(a[0],a[1],a[2])){
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 7488
N = int(input())
anslist = [0] * (N + 1)
for x in range(1,100): #100demo iikamo?
  for y in range(1,100):
    for z in range(1,100):
      temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if temp <= N:
        anslist[temp] += 1

anslist.pop(0)

for i in anslist:
  print(i)

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {               
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    	if (a[i] & 1) {
    		ans = 1;
    	}
    }
    if (ans) cout << "first";
    else cout << "second";
    return Accepted;
}

// Coded By OB

Measured memory_bytes: 18688
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;

    int d = min(b,c)+a;
    if(d<max(b,c))cout<<max(b,c)-d;
    else cout<<0;
}

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

int main(){
    int i;
    int n;
    cin >> n;
    int base[3]={0};
    int nout=0;
    int point=0;
    string HIT("HIT");
    string HOMERUN("HOMERUN");
    string OUT("OUT");
    while(n--){
        for(i=0;i<3;i++){
            base[i]=0;
        }
        nout=0;
        point=0;
        while(nout!=3){
            string str;
            cin >> str;
            if(str == HIT){
                for(i=2;i>=0;i--){
                    if(i==2){
                        point += base[i];
                    }
                    if(i!=0){
                        base[i]=0;
                        base[i] += base[i-1];
                    }else{
                        base[i] = 1;
                    }
                }
            }
            if(str == HOMERUN){
                for(i=0;i<3;i++){
                    point += base[i];
                    base[i] = 0;
                }
                point++;
            }
            if(str == OUT){
                nout++;
            }
        }
        cout << point << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<queue>
//int[1e7] ll[5*1e6]
typedef long long ll;
typedef unsigned long long ull; 
using std::string;using std::cin;using std::cout;

int n,r;

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> r >> n;
    if(r >= 10) cout << n << "\n";
    else {
        cout << n + 100 * (10 - r) << "\n";
    }
    

    return 0;
}

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

using namespace std;

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

    int cnt = 0;
    for(int i = 1; i < s.length(); i++)
        if( s[i] == s[i-1])
        {
           cnt++;
           if( s[i] == '1')s[i] = '0';
           else s[i] = '1';
        }

    cout << cnt << endl;

    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    int N = s.size();
    int c = 0;
    string t;
    bool flag = true;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'x') {
            c++;
        } else {
            t += s[i];
            flag = false;
        }
    }
    if (flag) {
        cout << 0 << endl;
        return;
    }
    string u = t;
    reverse(all(u));
    if (u != t) {
        cout << -1 << endl;
        return;
    }

    map<int,int> cnt;
    int now = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'x') {
            cnt[now]++;
        } else {
            now++;
        }
    }

    int ans = c;
    for(int i = 0; i <= u.size() / 2; i++) {
        int j = u.size() - i;
        if (i >= j) continue;
        ans -= 2 * min(cnt[i], cnt[j]);
    }
    if (u.size() % 2 == 0) {
        ans -= cnt[u.size() / 2];
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>

using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,int> P;

int main(){
	stack<int> s;
	stack<P> q;
	char c;
	int i=0,ans=0;
	while(cin>>c){
		if(c == '\\') s.push(i);
		else if(c == '/' && !s.empty()) {
			int j = s.top(),ws;
			s.pop();
			ws  = i-j;
			ans += ws;
			for(;!q.empty();){
				P w = q.top();
				if(w.first.first > j && w.first.second < i)	{
					q.pop();
					ws +=w.second;
				}
				else break;
			}
			q.push(P(P1(j,i),ws));
		}
		i++;
	}
	vector<P>v;
	cout << ans << endl << q.size() ;
	for(;!q.empty();){
		P w = q.top();q.pop();
		v.push_back(w);
	}
	std::reverse(v.begin(), v.end());
    for(P x : v ) std::cout << " " <<x.second ;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3208
/*
 * 2582.cc: Step Aerobics
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    int x = 0, l = 0, r = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      if (s == "lu") l++;
      else if (s == "ru") r++;
      else if (s == "ld") l--;
      else r--;

      if (l == r && l != x) cnt++, x = l;
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 1204
(setf l (make-array 3))

(defun in (a b c)
  (when (< b c)
	(progn 
	  (setf (aref a b) (read))
	  (in a (1+ b) c))))

(in l 0 3)

(let ((x (sort l #'>)))
  (princ (+ (* (aref x 0) 10) (aref x 1) (aref x 2))))


Measured memory_bytes: 4448
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[][] map = new int[n][2];
			for(int i=0;i<n;i++) map[i][0] = sc.nextInt();
			for(int i=0;i<n;i++) map[i][1] = sc.nextInt();
			
			int[] ans = new int[2];
			for(int i=0;i<2;i++){
				int x = i;
				int y = 0;
				int count = 0;
				ArrayDeque<Integer> que = new ArrayDeque<Integer>();
				
				while(true){	
					if(que.contains(x*1000+y)==true){
						ans[i] = -1;
						break;
					}
					if(y==n-1 && map[y][x]!=2){
						ans[i] = count;
						break;
					}
					
					que.push(x*1000+y);
					if(y<n-1 && map[y][x]==1 && map[y+1][x]==1){
						y++;
					}else if(y<n && map[y][x]==2){
						y--;
					}else{
						if(x==0) x=1;
						else x=0;
						
						if(y==n-2) y+=1;
						else y+=2;
						
						count++;
					}
				}
			}
			if(ans[0]==-1 && ans[1]==-1) System.out.println("NA");
			else if(ans[0]==-1) System.out.println(ans[1]);
			else if(ans[1]==-1) System.out.println(ans[0]);
			else if(ans[0]>ans[1]) System.out.println(ans[1]);
			else System.out.println(ans[0]);
		}
	}	
}

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

typedef pair<int, int> PII;
const int MAXN = 300000 + 10, inf = 1e9;

struct Node {
    PII e;
    Node *ls, *rs;
    int dim, cur, sub;
} pool[MAXN], *cnt;

struct Point {
    int x, y, z;
    Point() {}
    Point(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}
    bool operator < (const Point &rhs) const {
        return x < rhs.x || (x == rhs.x && y < rhs.y) || (x == rhs.x && y == rhs.y && z < rhs.z);
    }
} P[MAXN];

map<int, int> best[MAXN];
int dp[MAXN], ret;

int r(int &a, int &b) {
    static const int C = ~(1u << 31), M = (1 << 16) - 1;
    a = 36969 * (a & M) + (a >> 16);
    b = 18000 * (b & M) + (b >> 16);
    return (C & ((a << 16) + b)) % 1000000;
}

inline bool check(const map<int, int> &mp, int x, int y) {
    auto it = mp.lower_bound(x);
    return it != mp.begin() && (-- it)->second < y;
}

int query(int x, int y) {
    int left = 0, right = ret;
    while (left < right) {
        int mid = (left + right + 1) >> 1;
        if (check(best[mid], x, y)) left = mid;
        else right = mid - 1;
    }
    return left;
}

void update(map<int, int> &mp, int x, int y) {
    auto it = mp.upper_bound(x);
    if (it != mp.begin() && (-- it)->second <= y) return;
    it = mp.lower_bound(x);
    while (it != mp.end() && it->second >= y) mp.erase(it ++);
    mp[x] = y;
}

int main() {
    int N, M, A, B;
    while (scanf("%d%d%d%d", &M, &N, &A, &B) == 4 && (N + M)) {
        for (int i = 0; i < M; ++ i) {
            scanf("%d%d%d", &P[i].x, &P[i].y, &P[i].z);
        }
        N += M;
        for (int i = M; i < N; ++ i) {
            P[i].x = r(A, B);
            P[i].y = r(A, B);
            P[i].z = r(A, B);
        }
        for (int i = 0; i <= N; ++ i) best[i].clear();
        sort(P, P + N);
        ret = 0;
        for (int i = 0, j; i < N;) {
            for (j = i; j < N && P[i].x == P[j].x; ++ j) dp[j] = query(P[j].y, P[j].z) + 1;
            for (; i < j; ++ i) {
                update(best[dp[i]], P[i].y, P[i].z);
                ret = max(ret, dp[i]);
            }
        }
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 36104
#include <iostream>

using namespace std;

int main(){
  int a,b,w;
  cin>>w>>a>>b;
  if((a<=b && b<=a+w) || (b<=a && a<=b+w)){
    cout<<0<<endl;
  }else{
    cout<<min(abs(b-(a+w)),abs((b+w)-a))<<endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000000;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int n = s.size();
	rep(i, n) {
		cout << 'x';
		if (i == n - 1)cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,t[N],x[N],y[N],id[N];
bool cmp(int x,int y)
{
	return t[x]<t[y];
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	  t[i]=read(),x[i]=read(),y[i]=read(),id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		int u=id[i-1],v=id[i],len=abs(x[u]-x[v])+abs(y[u]-y[v]);
		if(len>t[v]-t[u]||(len-t[u]+t[v])&1)
		  {printf("No\n",i);return 0;}
	}
	puts("Yes");
	return 0;
}


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

void solve() {
    ll X;
    cin >> X;
    int y500 = 0;
    int y5 = 0;
    while (0 < X) {
        int d = 0;
        if (500 <= X) d = 500;
        else if (5 <= X) d = 5;
        else if (100 <= X) d = 100;
        else if (50 <= X) d = 50;
        else if (10 <= X) d = 10;
        else if (1 <= X) d = 1;

        int count = X / d;
        X -= count * d;
        if (d == 500) y500 += count;
        if (d == 5) {
            y5 += count;
            break;
        }
    }
    cout << (1000 * y500 + 5 * y5) << endl;

}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	long long a, b, x;
	cin >> a >> b >> x;
	double l = 0, r = 90;
	double volume = a * a * b;

	while (abs(l - r) > eps)
	{
		double mid = (l + r) / 2;
		double side = a * tan(mid * M_PI / 180);
		double tv = 0;
		if (side > b)
		{
			side = b * tan(( 90 -mid) * M_PI / 180);
			tv = b * a * side / 2.0;
			if (tv > x)
				l = mid;
			else
				r = mid;
		}
		else
		{
			tv = a * a * side / 2.0;
			if (volume - tv >= x)
				l = mid;
			else
				r = mid;
		}

	}	
	cout << setprecision(9) << fixed << (l + r) / 2;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
using namespace std;

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

	int baketto[26] = { 0 };
	for (int i = 0; i < S.size(); ++i) baketto[S[i] - 'a'] ++;

	for (int i = 0; i < 26; ++i) {
		
		if (baketto[i] == 0) {
			cout << char(i + 'a') << endl;
			return 0;
		}
}

	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
use io::*;
use std::*;

const YES: &'static str = "Possible";
const NO: &'static str = "Impossible";
fn solve(A: i64, B: i64) {
    if (A % 3 == 0) | (B % 3 == 0) | ((A + B) % 3 == 0){
        println!("{}", YES);
    }else{
        println!("{}", NO);
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut A: i64;
    A = scanner.next();
    let mut B: i64;
    B = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(A, B)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
using namespace std;

struct node{
	string name;
	long number;
	node *next;
};

class myQueue{
private:
	node *head;
	node *tail;
public:
	myQueue(string name,long number);
	void pushBack(string name,long number);
	void pop();
	node *top();
	void printQueue();
	bool isEmpty();
};

myQueue::myQueue(string name,long number){
	node *newNode = new node;
	newNode->name = name;
	newNode->number = number;
	newNode->next = NULL;
	head = newNode;
	tail = newNode;
}

void myQueue::pushBack(string name,long number){
	node *newNode = new node;
	newNode->name = name;
	newNode->number = number;
	newNode->next = NULL;
	tail->next = newNode;
	tail = newNode;
}



void myQueue::pop(){
	node *targetNode;
	targetNode = head;
	head = targetNode->next;
	delete targetNode;
}

node* myQueue::top(){
	return head;
}

void myQueue::printQueue(){
	node *node;
	node = head;
	while(node != NULL){
		cout <<node->name <<" "<< node->number << endl;
		node = node->next;
	}
}

bool myQueue::isEmpty(){
	if(head == NULL) return true;
	return false;
}

int main()
{
	int n;
	long q;
	cin >> n >> q;
	string name;
	long num;
	cin >> name >> num;
	myQueue myQ = myQueue(name,num);
	for(int i = 1; i < n; i++){
		cin >> name >> num;
		myQ.pushBack(name,num);
	}
	long time = 0;
	while( !myQ.isEmpty()){
		if( myQ.top()->number <= q){
			time += myQ.top()->number;
			cout<< myQ.top()->name<<" "<<time<<endl;
			myQ.pop();
		}else{
			time += q;
			myQ.pushBack(myQ.top()->name,myQ.top()->number - q);
			myQ.pop();
		}
	}
	return 0;
}





Measured memory_bytes: 6940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int haba = y+z+z;
		int ninzuu = 0;

		while(x>=haba) {
			haba=haba+y+z;
			ninzuu++;
		}

		System.out.print(ninzuu);
	}

}

Measured memory_bytes: 23124
N = int(input())						# 5

ans="No"
W=[]

w = input()
W.append(w)

for i in range(N-1):
	w = input()
	if W[i][-1]!=w[0]:
		print(ans)
		exit(0)
	W.append(w)

W.sort()

for i in range(N-1):
	if W[i]==W[i+1]:
		print(ans)
		exit(0)

ans="Yes"
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    ll n,c;
    cin >> n >> c;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        ll f,g;
        cin >> f >> g;
        a[i].first=f;a[i].second=g;
    }
    vector<ll> aa(n,0),bb(n+1,0);
    ll l=0,o=0,now=0;
    rep(i,n){
        o+=a[i].second-a[i].first+l;
        l=a[i].first;
        now=max(now,o);
        aa[i]=now;
    }
    l=c,o=0,now=0;
    rep(i,n){
        o+=a[n-i-1].second-l+a[n-i-1].first;
        l=a[n-i-1].first;
        now=max(now,o);
        bb[n-i-1]=now;
    }
    ll ans=max(aa[n-1],bb[0]);
    rep(i,n){
        ll f=a[i].first,g=a[i].second;
        if (f>c/2) break;
        ans=max(ans,aa[i]-f+bb[i+1]);
    }
    rep(i,n){
        ll f=c-a[n-i-1].first,g=a[n-i-1].second;
        if (f>c/2) break;
        ll k;
        if (n-i-2<0) k=0;
        else k=aa[n-i-2];
        ans=max(ans,bb[n-i-1]-f+k);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3328
h,w = gets.split.map(&:to_i)

count = -1
s = []
h.times do 
    s << gets.chomp!
    count += s.last.count(".")
end

dp = Array.new(h){Array.new(w)}
dp[0][0] = 0
stack = [[0,0]]
d = [[-1, 0], [1, 0], [0, -1], [0, 1]]

while stack != []
    x,y = stack.shift
    break if x == h-1 && y == w-1

    d.each do |ex,ey|
        nx = x + ex
        ny = y + ey
        next if (nx < 0 || h <= nx || ny < 0 || w <= ny || s[nx][ny] == "#" || dp[nx][ny])

        stack << [nx, ny]
        dp[nx][ny] = dp[x][y] + 1
    end
end

puts dp[h-1][w-1] ? count - dp[h-1][w-1] : -1

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int A, B ,C, D;
    cin >> A >> B >> C >> D;
    string judge;
  	while(1) {
      C -= B;
      if(C <= 0) {
        judge = "Yes";
        break;
      }
      A -= D;
      if(A <= 0) {
        judge = "No";
        break;
      }
    }
  cout << judge << endl;
  return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
int main(){
	scanf("%d",&n);
	a=n%10;
	n/=10;
	b=n%10;
	n/=10;
	c=n%10;
	n/=10;
	d=n%10;
	if(a==b||b==c||c==d)printf("Bad\n");
	else printf("Good\n");
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, M, X; cin >> N >> M >> X;
  vector<int> c(N);
  vector<vector<int>> a(N, vector<int>(M));
  rep(i, N){
    cin >> c[i];
    rep(j, M) cin >> a[i][j];
  }
  int ans = INF;
  for (int bit = 0; bit < (1<<N); ++bit){
    vector<int> vec(M, 0);
    int tot = 0;
    for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) {
        tot += c[i];
        rep(j, M) vec[j] += a[i][j];
      }
    }
    bool flag = true;
    rep(j, M){
      if (vec[j] < X) {flag = false; break;}
    }
    if(flag) ans = min(ans, tot);
  }
  if (ans != INF) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3652
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include<bits/stdc++.h>
#include <math.h>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;


int main()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> adj[n];
    forn(i,m)
    {
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    queue<ll> q;
    ll parent[n]={-1};
    bool vis[n]={false};
    vis[0]=true;

    q.push(0);

    while(!q.empty())
    {
        ll p=q.front();
        q.pop();
        for(ll i=0;i<adj[p].size();i++)
        {
            if(!vis[adj[p][i]])
            {
                vis[adj[p][i]]=true;
                parent[adj[p][i]]=p;
                q.push(adj[p][i]);
            }
        }
    }

    forn(i,n)
    {
        if(!vis[i])
        {
            cout<<"No\n";
            return 0;
        }
    }

    cout<<"Yes\n";

    for(ll i=1;i<n;i++)
    {
        cout<<parent[i]+1<<"\n";
    }

	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 13092
#include <iostream>
#define NMAX 100002
using namespace std;
int N,H[NMAX],dp[NMAX] ={};

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> H[i];
	}
	dp[1] = abs(H[1]-H[0]);
	for (int i = 2; i < N; ++i)
	{
		dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]));
	}
	cout << dp[N-1] << endl;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,B;
  cin>>A>>B;
  string res="No";
  if(A*B%2==1)res="Yes";
  cout<<res<<endl;
}


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

using namespace std;

typedef long long LL;

const int N = 4e6 + 5;
const LL INF = 1e15;

int n;
LL w[N] , mid;
int son[N][2];
vector < pair < LL , LL > > dp[N];
vector < pair < LL , LL > > aux1 , aux2;

template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void read(T &x) {
	T f = 1; x = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
	x *= f;
}

inline void dfs(int u) {
	dp[u].clear(); int ls = son[u][0] , rs = son[u][1];
	if (!ls) {
		dp[u].push_back(make_pair(0LL , 0LL));
		return;
	}
	dfs(ls); dfs(rs);
	aux1.clear() , aux2.clear();
	if (dp[rs].size()) {
		int j = 0;
		for (int i = 0; i < dp[ls].size(); ++i) {
			while (j < dp[rs].size() - 1 && dp[rs][j + 1].first + dp[ls][i].second + w[ls] + w[rs] <= mid) ++j;
			if (j < dp[rs].size() && dp[rs][j].first + dp[ls][i].second + w[ls] + w[rs] <= mid) aux1.push_back(make_pair(dp[ls][i].first + w[ls] , dp[rs][j].second + w[rs]));
		}
	}
	if (dp[ls].size()) {
		int j = 0;
		for (int i = 0; i < dp[rs].size(); ++i) {
			while (j < dp[ls].size() - 1 && dp[ls][j + 1].first + dp[rs][i].second + w[ls] + w[rs] <= mid) ++j;
			if (j < dp[ls].size() && dp[ls][j].first + dp[rs][i].second + w[ls] + w[rs] <= mid) aux2.push_back(make_pair(dp[rs][i].first + w[rs] , dp[ls][j].second + w[ls]));
		}
	}
	int j = 0 , k = 0; LL cur = INF;
	while (j < aux1.size() || k < aux2.size()) {
		if (k == aux2.size() || (j < aux1.size() && aux1[j].first <= aux2[k].first)) {
			if(aux1[j].second < cur) {
				dp[u].push_back(aux1[j]); 
				cur = aux1[j].second;
			}
			++j;
		} else {
			if (aux2[k].second < cur) { 
				dp[u].push_back(aux2[k]); 
				cur = aux2[k].second;
			}
			++k;
		}
	}
}
inline bool check(LL mid) {
	dfs(1);
	if (dp[1].size()) return true;
	else return false;
}

int main() {
	
	read(n);
	for (int i = 2; i <= n; ++i) {
		int u; LL x; read(u) , read(x);
		w[i] = x; if (son[u][0]) son[u][1] = i; else son[u][0] = i; 
	}
	LL l = 0 , r = INF , ans = 0;
	while (l <= r) {
		mid = (l + r) / 2LL;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}
	printf("%lld\n" , ans);
	return 0;
}

Measured memory_bytes: 122764
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
L=input().split( )
n=int(L[0])
m=int(L[1])

A=[[0 for i in range(m)] for j in range(n)]
b=[0 for i in range(m)]
x=0
y=0
while x<n:
    StrCollum = input().split( )
    for k in range(m):
        A[x][k] = int(StrCollum[k])
    x+=1
while y<m:
    StrVec = input()
    b[y] = int(StrVec)
    y+=1
c=[0 for i in range(n)]
for z in range(n):
    sum=0
    for u in range(m):
        sum = sum+(A[z][u]*b[u])
        c[z]=sum
for j in range(n):
    print(c[j])



Measured memory_bytes: 5964
(function(input) {
    var a = parse(input);
    var n = Number(a[0][0]);
    var an = a[1].map(Number).reverse();
    console.log(an.join(' '));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function parse(str, sep, ter) {
    sep = sep || ' ';
    ter = ter || '\n';
    str = str.replace(/\n$/, '');
    var a = str.split(ter);
    for (var i = 0; i < a.length; i++) {
        a[i] = a[i].split(sep);
    }
    return a;
}

Measured memory_bytes: 7644
#include<bits/stdc++.h>
using namespace std;
#define int long long int

bool check(int x,int y)
{
    while(x%y==0)x/=y;
    return x%y==1;
}
int32_t main()
{
    int n; cin>>n;

    int ans=1;
    for(int i=2;i<=sqrt(n);i++){
       if(n%i==0){
        if(check(n,i)){ans++;}
        if(i*i!=n && check(n,n/i)){ans++;}
       }
    }
    if(n>2){
        ans++;
        for(int i=2;i<=sqrt(n-1);i++)
        {
            if((n-1)%i==0){
                ans++;
                int z = (n-1)/i;
                if((n-1)/i != i)ans++;
            }

        }
    }


    cout<<ans;
}


Measured memory_bytes: 256
//蓝莲花__ 
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int n,f[N],g[N];
void check(int x){
	int sum=0;
	while(x)sum+=(x&1),x>>=1;
	if(sum==1){printf("No\n");exit(0);}
	printf("Yes\n");
	f[0]=1;for(int i=1;i<=30;++i)f[i]=f[i-1]<<1;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	check(n);
	
	int now=0;while(f[now+1]-1<=n)++now;
	int m=f[now]-1;
	
	for(int i=1;i<=m-1;++i)printf("%d %d\n",i,i+1),g[i]=i;
	printf("%d %d\n",m,1+n);
	for(int i=1;i<=m-1;++i)printf("%d %d\n",i+n,i+1+n),g[i+m]=i+n;
	
	int res=n-m;
	if(res==0)return 0;
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",1,m+1,m+1,m+2,1,m+2+n,m+2+n,m+1+n);
	if(res==2)return 0;
	printf("%d %d\n%d %d\n",m+2+n,m+3,2,m+3+n);
	if(res==3)return 0;
	for(int i=m+4;i<=n;++i)printf("%d %d\n%d %d\n",i-1+n,i,g[i-m-1],i+n);
	return 0;
}/*
26
1 2
2 3
3 4
4 5
5 6
6 7
7 14
14 15
15 16
16 17
17 18
18 19
19 20
1 8
8 9
1 22
22 21
22 10
2 23
23 11
3 24
24 12
4 25
25 13
5 26
*/

Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(10**7)

def update(v):
    for nv in G[v]:
        if seen[nv]:
            continue
        seen[nv]=1
        update(nv)

N,M=map(int,input().split())
seen=[0]*N
G=[[] for i in range(N)]
for i in range(M):
    X,Y,Z=map(int,input().split())
    X,Y=X-1,Y-1
    G[X].append(Y)
    G[Y].append(X)
ans=0
for i in range(N):
    if(seen[i]):
        continue
    ans+=1
    seen[i]=1
    update(i)
print(ans)

Measured memory_bytes: 110208
#include<iostream>
#define MAX_N 8
using namespace std;
int n,m;
bool g[MAX_N][MAX_N];
bool visited[MAX_N];
int ans;
void dfs(int v){
  visited[v]=true;
  for(int i=0;i<n;i++){
    if(v==i) continue;
    if(visited[i]) continue;
    if(g[v][i]) dfs(i);
  }
  bool path=true;
  for(int i=0;i<n;i++){
    if(!visited[i]) path=false;
  }
  if(path) ans++;
  visited[v]=false;
}
int main(void){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      g[i][j]=false;
    }
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a][b]=g[b][a]=true;
  }
  ans=0;
  for(int i=0;i<n;i++) visited[i]=false;
  dfs(0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main ()
{
    int x[10000]={0},j=0;
    char s[10001];
    gets(s);
    for(int i=0; i<strlen(s); i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
            x[j]++;
            else
                j++;

    }
    int ma=-1;
    for(j=0;j<100;j++)
    {
        if(ma<x[j])
            ma=x[j];
    }
    printf("%d",ma);
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  n <- readLn
  abs <- replicateM n $ (\(a:b:_) -> (a,b)) . map read . words <$> getLine :: IO [(Integer, Integer)]
  print $ solve n abs


solve n abs = (sumodd cs) - sumb
  where
    sumb = foldr (\(a,b) acc -> acc + b) 0 abs
    cs = reverse . sort $ map (\(a,b) -> a + b) abs
    sumodd [] = 0
    sumodd (a:[]) = a
    sumodd (a:aa:aaa) = a + (sumodd aaa)


Measured memory_bytes: 164220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    rep(i, 0, n) cout << 'x';
    cout << "\n";
}

Measured memory_bytes: 3520
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,ans=10000000,tempans,tempmin,tempsum,tempmp,tempkosuu,kaisuu=1,banngou,pos,A[3];
int jun[6][3]={{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};

int main(){
    cin>>N>>A[2]>>A[1]>>A[0];
    int l[N],ll[N];
    rep(i,N){
        cin>>ll[i];
    }
    rep(i,N){
        kaisuu*=2;
    }
    rep(m,6){
        rep(o,N){
            l[o]=ll[o];
        }
        tempans=0;
        rep(k,3){
            tempmin=10000000;
            repi(i,1,kaisuu){
                tempsum=0;
                tempkosuu=0;
                tempmp=0;
                rep(j,N){
                    tempsum+=(i>>j&1)*l[j];
                    tempkosuu+=(i>>j&1);
                    // out((i>>j&1)*l[j]);
                }
                if(tempkosuu>=2){
                    tempmp+=10*(tempkosuu-1);
                }
                tempmp+=abs(A[jun[m][k]]-tempsum);
                if(tempmp<tempmin){
                    tempmin=tempmp;
                    pos=i;
                }
            }
            // out(pos);
            rep(i,N){
                if((pos>>i&1)==1){
                    l[i]=10000000;
                }
            }
            // out(tempmin);
            tempans+=tempmin;
        }
        ans=min(ans,tempans);
    }
    out(ans);
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

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

int main() {
  ll N;
  cin >> N;
  vector<ll> v(N);
  for(ll i = 0LL; i < N; i++) {
    ll x;
    cin>>x;
    v[i]=x-i-1LL;
  }
  sort(v.begin(),v.end());
  ll ans = 0LL;
  for(ll i = 0LL; i < N; i++) {
    ans += abs(v[i]-v[N/2LL]);
  }
  cout<<ans<<endl;
}  

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

namespace ABC119
{
    class A
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string ans = "";
            if ((int.Parse(s.Substring(0, 4)) < 2019)) { ans = "Heisei"; }
            else if((int.Parse(s.Substring(0, 4)) > 2019)) { ans = "TBD"; }
            else
            {
                if((int.Parse(s.Substring(5, 2)) <= 4)) { ans = "Heisei"; }
                else { ans = "TBD"; }
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  int n = k;
  bool f = false;
  while(k<=b){
    if(k>=a) f = true;
    k += n;
  }
  if(f) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main()
{
    string s;
    char L,R,U,D;
    cin>>s;
    int x=s.size();
    int t=0;
    for(int i=0; i<=x; i=i+2)
    {
        if(s[i]=='L')
        {
            cout<<"No";
            t=1;
            break;

        }
    }
    if(t==0)
    {
        for(int i=1; i<=x; i=i+2)
        {
            if(s[i]=='R')
            {
                cout<<"No";
                t=1;
                break;

            }
        }
    }
    if(t==0) cout<<"Yes";
}

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

int main() {
  int n;cin>>n;
  for(int a=0; a<=100; a++) {
    for(int b=0; b<=100; b++) {
      if(7*a+4*b==n) {
	cout << "Yes"<<endl;
	return 0;
      }
    }
  }
  cout << "No"<<endl;
  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    unsigned int n[4];
    cin >> n[0];
    
    // 反転
    n[1] = ~n[0];
    // 左シフト
    n[2] = n[0] << 1;
    // 右シフト
    n[3] = n[0] >> 1;
    
    for(int i = 0;i < 4;++i){
        cout << bitset<32>(n[i]) << endl;
    }
}


Measured memory_bytes: 3224
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t X;
    std::cin >> X;

    auto check = [&](){
        while (true) {
            if (X == 0) return true;
            if (X < 100) return false;
            switch (X % 100) {
                case 0: X -= 100; break;
                case 1: X -= 101; break;
                case 2: X -= 102; break;
                case 3: X -= 103; break;
                case 4: X -= 104; break;
                default: X -= 105; break;
            }
        }
    };


    std::cout << (check() ? "1" : "0") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;
	int i = 0;
	int j = n - 1;
	int count = 0;
	while (true)
	{
		while (s[i] != 'W')
		{
			i++;
			if (i == j)
			{
				std::cout << count << std::endl;
				return 0;
			}
		}
		while (s[j] != 'R')
		{
			j--;
			if (i == j)
			{
				std::cout << count << std::endl;
				return 0;
			}
		}
		std::swap(s[i], s[j]);
		count++;
	}
	return 0;
}

Measured memory_bytes: 3724
#include<iostream>//itp17a
using namespace std;
int main(void)
{
	int m,f,r,total;
	while(1){
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1) break;
		total=m+f;
		if(total<30 || m==-1 || f==-1) cout<<"F"<<endl;
		else if(total>=80) cout<<"A"<<endl;
		else if(total>=65 && total<80) cout<<"B"<<endl;
		else if(total>=50 && total<65) cout<<"C"<<endl;
		else if((total>=30 && total<50) && (50<=r)) cout<<"C"<<endl;
		else if(total>=30 && total<50) cout<<"D"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

X = I()
num500 = X//500
num5 = (X%500)//5
print(num500*1000+num5*5)


Measured memory_bytes: 59500
#include<bits/stdc++.h>
#define LL long long
using namespace std;
priority_queue<LL , vector<LL> , greater<LL> > pq2;
priority_queue<LL> pq1;
LL add1,add2,val;
int n;
int main(){
	scanf("%d",&n);
	pq1.push(0);pq2.push((int)1e9);
	for(int i=1,last=0,l,r;i<=n;i++){
		scanf("%d%d",&l,&r);
		if(i!=1){
			add1-=r-l;
			add2+=last;
		}
		LL pl=pq1.top()+add1,pr=pq2.top()+add2;
		if(l<pl){
			pq1.pop(),pq2.push(pl-add2),pq1.push(l-add1),pq1.push(l-add1);
			val+=pl-l;
		}else if(l>pr){
			pq2.pop(),pq1.push(pr-add1),pq2.push(l-add2),pq2.push(l-add2);
			val+=l-pr;
		}else{
			pq1.push(l-add1),pq2.push(l-add2);
			val+=0;
		}
		last=r-l;
	}
	cout<<val<<endl;
	return 0;
}

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

#define M 1000003
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
}

/*convert a string into an integer value*/
long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i = 0 ; i < strlen(str) ; i++){
     sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}
int h2(int key){
  return 1+(key%(M-1));
}
int find(char str[]){
  int i,g,x=0;
  g = (int)getKey(str);
  for(i = 0 ; i < M ; i++){
    x = (h1(g)+i*h2(g))%M;
    if(strcmp(H[x],str) == 0) return 1;
    else if(strlen(H[x]) == 0) return 0;
  }
}
void insert(char str[]){
  int i,x=0,g;
  g = (int)getKey(str);
  for(i = 0 ; i < M ; i++){
    x = (h1(g)+i*h2(g))%M;
    if(strlen(H[x]) == 0){
      strcpy(H[x],str);
      return;
    }
  }
}

int main(void){
  int i,n,h;
  char str[L],com[9];

  for(i = 0 ; i < M ; i++){
    H[i][0] = '\0';
  }
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%s %s",com,str);
    
    if(com[0] == 'i'){
      insert(str);
    }
    else {
      if(find(str)){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 13000