akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll n;
vector<vector<pair<ll, ll>>> e(100010);
ll dist[100010];
ll q, k;

void dfs(ll v, ll p, ll cost) {
    dist[v] = dist[p] + cost;
    rep(i, 0, (int)e[v].size()) {
        ll nextv = e[v][i].first;
        ll nextcost = e[v][i].second;
        if (dist[nextv] != -1) continue;
        dfs(nextv, v, nextcost);
    }
}

int main() {
    cin >> n;

    rep(i, 0, n - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }

    cin >> q >> k;
    k--;

    rep(i, 0, 100010) dist[i] = -1;
    dist[k] = 0;
    dfs(k, k, 0);

    rep(i, 0, q) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n;cin>>n;
    vector<ll>A(n),B(n),C(n),countA(n),countB(n);
    rep(i,n)cin>>A[i];rep(i,n)cin>>B[i];rep(i,n)cin>>C[i];
    sort(A.begin(),A.end(),greater<ll>());sort(B.begin(),B.end(),greater<ll>());sort(C.begin(),C.end(),greater<ll>());
    C.push_back(-1);B.push_back(-1);
    int j=0;int i=0;
    while(1){
        if(B[j]>=C[i]){countB[j]=i;j++;i--;}
        if(j==n)break;
        i++;
    }
    j=0;ll sum=0;
    i=0;
    while(1){
        if(A[j]>=B[i]){countA[j]=sum;j++;i--;}
        else sum+=countB[i];
        if(j==n)break;
        i++;
    }
    ll ans=0;
    rep(i,n)ans+=countA[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int L,R,D;
  int M=0;
  cin>>L>>R>>D;
  for(int X=L;X<=R;X++){
    if(X%D==0){
      M++;
    }
  }
  cout<<M<<endl;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    String S = sc.next();
    String s[] =S.split("",0);
    int t[] =new int[N];
    long w=0;long a=0;long b=0; long c=0;
    for(int i=0;i<N;i++){
      if(s[i].equals("R")){t[i]=1;b=b+1;}
      else if(s[i].equals("G")){t[i]=2;a=a+1;}
      else{t[i]=3;c=c+1;}}
    for(int k=2;k<N;k++){
      for(int j=1;j<k;j++){
        if(2*k-j>N){continue;}
        if(t[k-1]==t[j-1]){continue;}
          if(t[k-1]+t[j-1]+t[2*k-j-1]==6){
            w=w+1;}}}
    long z=a*b*c-w;
    System.out.println(z);
  }
}


Measured memory_bytes: 36672
#include <iostream>

int main() {
	char* str = new char[6];
	for (int i = 0; i < 6; i++) {
		std::cin >> str[i];
	}
	if ( (str[2] == str[3]) && (str[4] == str[5]) ) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
	~debug() {cout<<endl;}
	template<class T> debug& operator<<(T x) {cout<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
};


bool solve(void) {

	int n, ans = 0;
	string s;
	cin>>n>>s;
	for(int i = 0; i <= n - 3; i++)
		ans += s.substr(i, 3) == "ABC";
	printf("%d\n", ans);
	return true;
}

int main(int argc, char* argv[]) {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int f = 0;
    if(a+b == 15){
        f = 1;
    }else if(a * b == 15){
        f = 2;
    }
    if(f == 1){
        printf("+");
    }else if(f == 2){
        printf("*");
    }else{
        printf("x");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

int main() {
	int N, K;
	int A[100001];
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		if (N <= (K - 1)*(i - 1) + K) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

using namespace std;


void __solve() {
    int n; cin >> n;
    vector<int> a(n), indeg(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        indeg[a[i]]++;
    }
    if (n == 2) {
        cout << -1; return;
    }
    set<int> bucket;
    set<pair<int,int>> lookup;
    for (int i = 0; i < n; i++) {
        bucket.insert(i);
        lookup.insert({indeg[i], i});
    }
    vector<int> p(n);
    vector<bool> trk(n);
    const int L = 3; 
    for (int i = 0; i < n-L; i++) {
        auto it = --lookup.end();
        int cnt,z;
        tie(cnt,z) = *it;
        for (int x: bucket) {
            if (i == 0 || a[p[i-1]] != x) {
                // if erase x, no invalid
                if (z == x || cnt - (i && a[p[i-1]]==z) < n-i-1) {
                    p[i] = x;
                    break;
                }
            }
        }
        if (i > 0) {
            int x = a[p[i-1]];
            if (!trk[x]) {
                lookup.erase({indeg[x],x});
                lookup.insert({--indeg[x], x});
            }
        }
        trk[p[i]] = true;
        bucket.erase(p[i]);
        lookup.erase({indeg[p[i]], p[i]});
    }

    for (int i = max(0, n-L); i < n; i++) {
        p[i] = *bucket.begin();
        bucket.erase(p[i]);
    }
    do {
        bool yes = true;
        for (int i = max(1, n-L); i < n; i++) {
            if (a[p[i-1]] == p[i]) yes = false;
        }
        if (yes) {
            for (int x: p) cout << x+1 << ' ';
            return;
        }
    } while (next_permutation(p.begin(), p.end()));
}

void solve() {
    int n; cin >> n;
    vector<int> a(n), indeg(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        indeg[a[i]]++;
    }
    if (n == 2) {
        cout << -1; return;
    }
    set<int> bucket;
    for (int i = 0; i < n; i++) {
        bucket.insert(i);
    }
    vector<int> p(n);
    vector<bool> trk(n);
    const int L = 3; 
    for (int i = 0; i < n-L; i++) {
        for (int x: bucket) {
            if (i == 0 || a[p[i-1]] != x) {
                if (trk[a[x]] || indeg[a[x]] - (i && a[p[i-1]]==a[x]) < n-i-1) {
                    p[i] = x;
                    break;
                }
            }
        }
        if (i > 0) {
            int x = a[p[i-1]];
            if (!trk[x]) indeg[x]--;
        }
        trk[p[i]] = true;
        bucket.erase(p[i]);
    }
    for (int i = max(0, n-L); i < n; i++) {
        p[i] = *bucket.begin();
        bucket.erase(p[i]);
    }
    do {
        bool yes = true;
        for (int i = max(1, n-L); i < n; i++) {
            if (a[p[i-1]] == p[i]) yes = false;
        }
        if (yes) {
            for (int x: p) cout << x+1 << ' ';
            return;
        }
    } while (next_permutation(p.begin(), p.end()));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define inf 1000000007

using namespace std;

typedef long long ll;

ll z=0;
int a[100005];

int main()
{
    int n, k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        z+=a[i];
    }
    printf("%lld",z);
    return 0;
}


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

signed main() {
  int N;
  cin >> N;

  vector<int> sum(N + 1, 0);
  map<int, int> mp;

  mp[sum[0]]++;
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    sum[i] += sum[i - 1] + A;
    mp[sum[i]]++;
  }

  int ans = 0;
  for (int i = 0; i <= N; i++) {
    ans += mp[sum[i]] - 1;
  }

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

Measured memory_bytes: 14336
#include <iostream>
using namespace std;
 
#define CARRY 10000000000000000000ULL
 
typedef struct {
    unsigned long long lsl;
    unsigned long long msl;
} u64_t;
 
u64_t *adder(u64_t *input1, u64_t *input2)
{
    u64_t *r = new(u64_t);
    r->lsl = 0;
    r->msl = 0;
 
    r->msl = input1->msl + input2->msl;
 
    unsigned long long width = 8 * sizeof(unsigned long long), x = 1;
    unsigned long long mycarry = 0;
 
    for (unsigned long long i = 0; i < width; i++) {
        unsigned long long tmp1, tmp2;
        mycarry = 0;
 
        tmp1 = (input1->lsl >> i) & 0x1;
        tmp2 = (input2->lsl >> i) & 0x1;
 
        unsigned long long t1 = ((x << i) * tmp1);
        unsigned long long t2 = ((x << i) * tmp2);
 
        r->lsl += t1 + t2;
        if (r->lsl > CARRY) {
            mycarry += 1;
            r->lsl -= CARRY;
        }
        r->msl += mycarry;
    }
    r->msl += mycarry;
    return r;
}
 
u64_t *multiplier(u64_t *input1, u64_t *input2)
{
    u64_t *r = new(u64_t);
    r->lsl = 0;
    r->msl = 0;
 
    size_t width = 8 * sizeof(unsigned long long);
    for (size_t i = 0; i < width; i++) {
        if ((input2->lsl >> i) & 0x1) {
            r->msl += input1->msl << i;
 
            u64_t tmp;
 
            tmp.lsl = (input1->lsl << i);
            tmp.msl = 0;
            r = adder(r, &tmp);
        }
    }
 
    for (size_t i = 0; i < width; i++) {
        if ((input2->msl >> i) & 0x1) {
            r->msl += input1->lsl << i;
        }
    }
    return r;
}
 
int main()
{
    int H, W;
    u64_t *color_h = new(u64_t);
    u64_t *color_w = new(u64_t);
    u64_t *white_h = new(u64_t);
    u64_t *white_w = new(u64_t);
    u64_t *answer = new(u64_t);
    cin >> H;
    cin >> W;
    if (H == 1 || W == 1) {
        cout << 1 << "\n";
        return 0;
    }
    color_h->lsl = ((H & 1) == 1) ? H / 2 + 1 : H / 2;
    color_w->lsl = ((W & 1) == 1) ? W / 2 + 1 : W / 2;
    // cout << color_h->lsl << " " << color_w->lsl << endl;
    white_h->lsl = H - color_h->lsl;
    white_w->lsl = W - color_w->lsl;
    answer = adder(multiplier(color_h, color_w), multiplier(white_h, white_w));
    if (answer->msl)
        cout << answer->msl << answer->lsl << "\n";
    else
        cout << answer->lsl << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define N 100000
const int INF = 1 << 30; // > 10^9
int n;
using namespace std;
struct edge : vector<pair<int, int> > {
    void add_edge(int to, int cost) {
        push_back(pair<int, int>(to, cost));
    }
} info[N];
void bfs();
int hoge[N];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        while (k--) {
            int v, c;
            cin >> v >> c;
            info[u].add_edge(v, c);
        }
    }
    bfs();
    for (int i = 0; i < n; i++) {
        cout << i << " " << hoge[i] << endl;
    }
}
void bfs() {
    fill_n(hoge, n, INF); //hoge ~ hoge + v <- INF
    queue<int> que;
    que.push(0);
    hoge[0] = 0;
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        for (int i = 0; i < info[p].size(); i++) {
            if (info[p][i].second + hoge[p] < hoge[info[p][i].first]) {
                que.push(info[p][i].first);
                hoge[info[p][i].first] = info[p][i].second + hoge[p];
            }
        }
    }
    
}



Measured memory_bytes: 10120
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	rep(i, 5) {
		int buf;
		cin >> buf;
		if (i + 1 != buf) {
			cout << i + 1;
		}
	}
	return 0;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
typedef int* intarray;
typedef char* string;

int main(){
    int N;
    scanf("%d", &N);
    printans((((N-1)/111)+1)*111);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//x=y=z=L/3のとき、体積Vは最大
		//このとき、V = L^3 / 27

		//読み込む
		string S = Console.ReadLine();
		double L = double.Parse(S);

		double answer = L*L*L/27;

		Console.WriteLine(answer);

	}
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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(){
    ll N,ans=1;
    string S;
    cin>>N>>S;
    map<char,ll> m;
    for(ll i=0;i<N;i++) m[S[i]]++;
    sort(S.begin(),S.end());
    for(ll i=0;i<N;i++){
        ans*=m[S[i]]+1;
        i+=m[S[i]]-1;
        ans%=MOD;
    }
    ans=(ans-1)%MOD;
    cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  set<string> S;
  
  for(int i=0; i<N;i++){
    string s;
    cin >> s;
    S.insert(s);
  }
  
  cout << S.size() << endl;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1]-a[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=25;
int a[N],b[N],c[N],ans;
int main()
{
    int  n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    for(int i=1;i< n;i++) scanf("%d",&c[i]);
    for(int i=1;i<=n;i++)
    {
        ans+=b[a[i]];
        if(a[i-1]+1==a[i]&&a[i-1]!=0)
            ans+=c[a[i-1]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forp(x,a,b) for(int x=a; x<b; x++)
#define forn(x,a,b) for(int x=a; x>b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define w(x) while(x--)
using namespace std;
typedef long long ll;
const int n=3;

string s;
 vi ga;
void solve(){int t=0;
    forp(i,0,n){if(s[i]=='R'){t++;}
else{if(t>0) ga.pb(t);t=0;}}
    ga.pb(t);
    cout<<*max_element(all(ga));
}

int main(){
 ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin>>s;
 solve();        
        
    
    return 0;}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int k, act;
bitset<1100000> have;

int main() {
	int cnt = 0;
	cin >> k;
	while (true) {
		act = act * 10 + 7;
		act %= k;
		cnt++;
		if (act == 0) {
			cout << cnt;
			return 0;
		}
		if (have[act]) {
			cout << -1;
			return 0;
		}
		have[act] = true;
	}
    return 0;
}


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

int main(void){
  int n;
  int in_tunnel;
  vector<int> in;
  vector<int> out;
  cin >> n; cin >> in_tunnel;
  for(int i=0; i < n; i++){
    int t1, t2; cin >> t1 >> t2;
    in.push_back(t1);
    out.push_back(t2);
  }

  int max_cars = in_tunnel;
  for(int i=0; i < n; i++){
    in_tunnel += in[i] - out[i];
    if(in_tunnel < 0){
      cout << 0 << endl;
      return 0;
    }
    max_cars = max(max_cars, in_tunnel);
  }
  cout << max_cars << endl;
  return 0;
}

Measured memory_bytes: 1340
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
typedef long long ll;
int n;
ll ans,a[MAXN],L,lft,rit,nstl,nstr,num;
int main(){
	SF("%lld%d",&L,&n);
	for(int i=1;i<=n;i++)
		SF("%lld",&a[i]);
	ans=a[n];
	nstl=n;
	nstr=n+1;
	for(int i=n;i>=1;i--){//block between i and i-1
		num=min(n-i,i-1);
		rit-=a[i];
		while(i-nstr<num&&nstr>1){
			nstr--;
			rit+=(a[nstr]);	
		}
		while(nstl-i>num&&nstl>0){
			lft-=(L-a[nstl]);
			nstl--;
		}
//		PF("[%d %lld %lld %lld]\n",i,lft,rit,(lft+rit)*2+max(L-a[i],a[i]));
		int lastl,lastr;
		if(nstl==n)
			lastl=0;
		else
			lastl=(L-a[nstl+1])*2;
		if(nstr==0)
			lastr=0;
		else
			lastr=a[nstr-1]*2;
		ans=max(ans,(lft+rit)*2+max(a[i]+lastl,L-a[i]+lastr));
		lft+=(L-a[i]);
	}
	PF("%lld",ans);
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

struct edge{
  int ans;
  int lim;
  int cost;
};
typedef struct edge Edge;

int main(void)
{
  int n,i,a,ans,lim,cost,data,count=0,A[10000];
  Edge *edges,*p;

  edges=malloc(sizeof(Edge)*500000);
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&ans,&a);
      while(a--)
        {
          scanf("%d%d",&lim,&cost);
          p=&edges[count++];
          p->ans=ans;
          p->lim=lim;
          p->cost=cost;
        }
      A[i]=INT_MAX;
    }
  A[0]=0;
  data=1;
  while(data)
    {
      data=0;
      for(i=0;i<count;i++)
        {
          ans=edges[i].ans;
          lim=edges[i].lim;
          cost=edges[i].cost;
          if(A[ans]<INT_MAX && A[lim]>cost+A[ans])
            {
              A[lim]=cost+A[ans];
              data=1;
            }
        }
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d\n",i,A[i]);
    }
  return 0;
}


Measured memory_bytes: 7536
#!python3

def resolve():
    N = tuple(map(int,input()))

    if len(N) == 1:
        print(N[0])
        return

    n = len(N)
    dp = [[[0]*10 for j in range(2)] for i in range(2)]

    k0  = N[0]

    dp0, dp1 = dp

    dp0[0][k0] = 1
    for i in range(1, k0):
        dp0[1][i] = 1
    for i in range(1, n-1):
        for k in range(1, 10):
            dp1[1][k] = 10 * dp0[1][k] + 1

        x, y = N[i], dp0[0][k0]
        dp1[1][k0] += x * y
        dp1[0][k0] = y

        #print(dp1)
        dp0, dp1 = dp1, dp0

    dp2 = [[0]*10 for i in range(10)]
    for i in range(1, 10):
        for j in range(1, 10):
            dp2[i][j] = dp0[1][i]

        for j in range(1, N[-1]+1):
            dp2[i][j] += dp0[0][i]

        dp2[i][i] += 1

    #for x in dp2:
    #    print(x)

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += dp2[i][j]*dp2[j][i]
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    string s;
    cin>>s;
    ll ans=1;
    s.push_back('_');
    string pre;
    vector<string>vec;
    vec.push_back(s.substr(0,1));
    for(int i=1;i<s.size()-1;i++){
        if(s.at(i)!=s.at(i+1) && s.substr(i,1)!=vec.at(vec.size()-1)){
            vec.push_back(s.substr(i,1));
        }
        else if(s.at(i)!=s.at(i+1) && s.substr(i,1)==vec.at(vec.size()-1)){
            vec.push_back(s.substr(i,2));
            i++;
        }
        else if(s.at(i)==s.at(i+1) && s.substr(i,1)!=vec.at(vec.size()-1)){
            vec.push_back(s.substr(i,1));
        }
        else if(s.at(i)==s.at(i+1) && s.substr(i,1)==vec.at(vec.size()-1)){
            vec.push_back(s.substr(i,2));
            i++;
        }
        ans++;
    }
    if(vec.at(vec.size()-2)==vec.at(vec.size()-1).substr(0,1) && vec.at(vec.size()-2).size()==1 && vec.at(vec.size()-1).at(1)=='_'){
        ans--;
    }
    cout<<ans<<endl;
    // for(int i=0;i<vec.size();i++){
    //     cout<<vec.at(i)<<endl;
    // }


    // for(int i=0;i<s.size()-1;i++){
    //     if(s.at(i)==s.at(i+1)){
    //         ans++;
    //     }
    //     else{
    //         int j=1;
    //         while(s.at(i)==s.at(i+j)){
    //             j++;
    //         }
    //         if(j%2==0){
    //             ans=ans+j/2+1;
    //             i=i+j;
    //         }
    //         else{
    //             ans=ans+j/2;
    //             i=i+j-1;
    //         }
    //     }
    // }
    // cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 10996
#include<bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;
vector<ii> vet;
int n,k;

main(){
	int a,b;
	cin >> n >> k;
	for(int i = 0;i<n;i++){
		cin >>a >> b;
		vet.emplace_back(a,b);
	}
	sort(vet.begin(),vet.end());
	int cont = 0;
	
	for(auto it: vet){	
		cont += it.second;
		
		if(cont >= k){
			cout<<it.first;
			return 0;
		}
	}
	
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<double> v(n);
	for(int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	
	sort(v.begin(), v.end());
	
	double ans = v[0];
	for(int i = 1; i < n; ++i) {
		ans = (ans + v[i]) / 2.0;
	}
	
	printf("%.10f\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int d[N];
  REP(i, N) { cin >> d[i]; }
  sort(d, d + N);
  int cnt = d[N / 2] - d[N / 2 - 1];
  cout << cnt;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans = 0;
  rep(i,n){
    ans+=min(a[i]*2,abs(a[i]-k)*2);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m = MII()
    ab = [MIIZ() for _ in range(m)]
    cnt = 0
    for i in range(m):
        graph = [[] for _ in range(n)]
        for k,(a,b) in enumerate(ab):
            if i == k: continue
            graph[a].append(b)
            graph[b].append(a)
        dist = [-1]*n
        dq = deque()
        dist[0] = 0
        dq.append(0)
        while dq:
            v = dq.popleft()
            for nv in graph[v]:
                if dist[nv] != -1: continue
                dist[nv] = dist[v] + 1
                dq.append(nv)
        if -1 in dist:
            cnt += 1
    print(cnt)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3392
//g++  7.4.0

#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll n,W;
    cin>>n>>W;
    vector <vector<ll>> dp(n+1,vector<ll> (100001,9999999999));
    vector<ll> w(n);
    vector <ll> v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(ll i=0;i<n;i++)
    {
        dp[i+1][v[i]]=w[i];
        for(ll j=1;j<100001;j++)
        {
            if(j<v[i])
                dp[i+1][j]=dp[i][j];
            else    
                dp[i+1][j]=min(dp[i][j-v[i]]+w[i],min(dp[i+1][j],dp[i][j]));
            
        }
      }
     ll ans=0;
    for(ll j=100000;j>=0;j--)
        {
            if(dp[n][j]<=W and dp[n][j]!=0)
            {
                ans=j;
                break;
            }
                       
        }
    cout<<ans;
    
}

Measured memory_bytes: 83244
N, K = map( int, input().split())
A = list( map( int, input().split()))
# 1の個数をそれぞれの桁でカウントしたい
V = [0]*41
for a in A:
    for i in range(40,-1,-1):
        if a%2 == 0:
            pass
        else:
            V[i] += 1
        a //= 2
        if a == 0:
            break
W = [0]*41
for i in range(40,-1,-1):
    if K%2 == 0:
        pass
    else:
        W[i] += 1
    K //= 2
    if K == 0:
        break
ans = 0
check = 0
dp = [[-1]*2 for _ in range(42)]
dp[0][0] = 0
for i in range(41):
    if dp[i][1] != -1:
        dp[i+1][1] = dp[i][1] + (2**(40-i))*max(V[i], N-V[i])
    if dp[i][0] != -1:
        if W[i] == 1:
            dp[i+1][1] = max( dp[i+1][1], dp[i][0]+(2**(40-i))*V[i] )
    if dp[i][0] != -1:
        if W[i] == 1:
            dp[i+1][0] = dp[i][0] + (2**(40-i))*(N-V[i])
        else:
            dp[i+1][0] = dp[i][0] + (2**(40-i))*V[i]
print( max( dp[-1][0], dp[-1][1]))


Measured memory_bytes: 14620
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=200005;
const LL inf=(LL)1e16;

int n,m,a,b;
LL sum[N],x[N],f[N];

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

struct Segment_Tree
{
    struct tree{LL mn;}t[N*4];

    void build(int d,int l,int r)
    {
        t[d].mn=inf;
        if (l==r) return;
        int mid=(l+r)/2;
        build(d*2,l,mid);build(d*2+1,mid+1,r);
    }

    void ins(int d,int l,int r,int x,LL y)
    {
        if (l==r) {t[d].mn=y;return;}
        int mid=(l+r)/2;
        if (x<=mid) ins(d*2,l,mid,x,y);
        else ins(d*2+1,mid+1,r,x,y);
        t[d].mn=min(t[d*2].mn,t[d*2+1].mn);
    }

    LL query(int d,int l,int r,int x,int y)
    {
        if (l==x&&r==y) return t[d].mn;
        int mid=(l+r)/2;
        if (y<=mid) return query(d*2,l,mid,x,y);
        else if (x>mid) return query(d*2+1,mid+1,r,x,y);
        else return min(query(d*2,l,mid,x,mid),query(d*2+1,mid+1,r,mid+1,y));
    }
}t1,t2;

void dp()
{
    t1.ins(1,1,m,x[0],f[1]-x[0]-sum[1]);
    t2.ins(1,1,m,x[0],f[1]+x[0]-sum[1]);
    for (int i=2;i<=n;i++)
    {
        f[i]=min(t1.query(1,1,m,1,x[i])+x[i],t2.query(1,1,m,x[i],m)-x[i])+sum[i-1];
        t1.ins(1,1,m,x[i-1],f[i]-x[i-1]-sum[i]);
        t2.ins(1,1,m,x[i-1],f[i]+x[i-1]-sum[i]);
    }
}

int main()
{
    m=read();n=read();a=read();b=read();
    for (int i=1;i<=n;i++) x[i]=read();
    for (int i=2;i<=n;i++) sum[i]=sum[i-1]+abs(x[i]-x[i-1]);
    LL ans=inf;
    f[1]=abs(a-x[1]);x[0]=b;
    t1.build(1,1,m);t2.build(1,1,m);
    dp();
    for (int i=1;i<=n;i++) ans=min(ans,f[i]+sum[n]-sum[i]);
    f[1]=abs(b-x[1]);x[0]=a;
    t1.build(1,1,m);t2.build(1,1,m);
    dp();
    for (int i=1;i<=n;i++) ans=min(ans,f[i]+sum[n]-sum[i]);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 17408
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <cstdlib>
#define ri register int 
#define ll long long 
#define ull unsigned long long 
using namespace std;
template <class T>inline void read(T &x){
    x=0;int ne=0;char c;
    while(!isdigit(c=getchar()))ne=c=='-';
    x=c-48;
    while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
    x=ne?-x:x;return ;
}
const int maxn=1000005;
const int inf=0x7fffff;
int n;
ll a[maxn];
ll sum[maxn],mi=1e18,mx=-1e18,ans=1e18,tmp;
int main(){
    int x,y;
    read(n);
    sum[0]=0;
    for(ri i=1;i<=n;i++)read(a[i]),sum[i]=sum[i-1]+a[i];
    int l=1,r=3;
    for(ri k=2;k<=n-2;k++){
        while((abs((sum[k]-sum[l+1])-(sum[l+1]))<abs(sum[k]-sum[l]-sum[l]))&&l+1<k)l++;
        while((abs((sum[n]-sum[r+1])-(sum[r+1]-sum[k]))<abs((sum[n]-sum[r])-(sum[r]-sum[k])))&&r+1<n)r++;
        mi=1e18,mx=-1e18;
        tmp=sum[k]-sum[l];
		mi=min(mi,tmp),mx=max(mx,tmp);
        tmp=sum[l];
		mi=min(mi,tmp),mx=max(mx,tmp);
        tmp=sum[n]-sum[r];
		mi=min(mi,tmp),mx=max(mx,tmp);
        tmp=sum[r]-sum[k];
		mi=min(mi,tmp),mx=max(mx,tmp);
        ans=min(ans,mx-mi);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5888
import itertools
import math
import fractions
import functools
import copy
from collections import deque

n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)


a = [-1]*n
d = deque([0])
while d:
    f = d.popleft()
    for i in g[f]:
        if a[i] == -1:
            a[i] = f
            d.append(i)

print("Yes")
for i in range(1,n):
    print(a[i]+1)


Measured memory_bytes: 98404
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

string s;

int main() {
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

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

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

int main() {
  int a, b, c, x, y, res = numeric_limits<int>::max();
  cin >> a >> b >> c >> x >> y;
  for (int i = 0; i <= 200000; ++i) chmin(res, a * max(x - i / 2, 0) + b * max(y - i / 2, 0) + c * i);
  cout << res << endl;
}



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

int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool flag = true;
  for(int i = 0 ; i < N ; i++){
  	if(S.at(i)!=T.at(i)){
    	flag = false;
    }
  }
  if(flag){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  ll c;
  ll count = 0;
  ll i;
  c = min(a, b);
  for(i = c; count != k; i--){
    if(a % i == 0 && b % i == 0)
      count++;
  }
  
  cout << i + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

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

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL long long
#define ll long long
#define LD double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);


int main() {
    HabdModeActive
    string s;
    cin >> s;
    string tmp = "";
    string lst = "";
    int mx = 0;
    for (int i = 0; i < s.size(); i++) {
        tmp += s[i];
        if (tmp != lst) {
            lst = tmp;
            mx++;
            tmp = "";
        }
    }
    cout << mx;


    return 0;
}

Measured memory_bytes: 720
def main():
    from sys import stdin
    input = stdin.readline

    n = int(input())
    a = []
    for _ in range(n):
        a.append(list(map(int, input().split())))
    
    ans = 0
    tf = [[True] * n for _ in range(n)]
    # Warshall-Floyd algorithm
    for k in range(n):
        for i in range(n-1):
            if i == k:
                continue
            for j in range(i, n):
                if j == k:
                    continue
                elif a[i][j] > a[i][k] + a[k][j]:
                    print(-1)
                    exit()
                elif a[i][j] == a[i][k] + a[k][j] and tf[i][j]:
                    ans -= a[i][j]
                    tf[i][j] = False
    
    ans += sum([sum(i) for i in a]) // 2
    print(ans)

main()

Measured memory_bytes: 75772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

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

vector<ll> po(19,1);

ll calc(int i,int j,ll e){
    if (j>i-1-j) return (e==0?1:0);
    ll res=0;
    int diff=(j==i-1-j?0:e/(po[i-1-j]-po[j]));
    for (ll d=diff-1;d<=diff+1;++d){
        if (j==i-1-j&&d!=0) continue;
        ll ne=e-(po[i-1-j]-po[j])*d;
        if (ne<-(po[i-1-j]-po[j])||po[i-1-j]-po[j]<ne) continue;
        for (int k=(!j?1:0),cnt=0;k<10;++k){
            if (k+d>=0&&k+d<10) ++cnt;
            if (k==9) res+=calc(i,j+1,ne)*cnt;
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i=0;i<18;++i) po[i+1]=po[i]*10;
    ll D; cin >> D;
    ll ans=0;
    for (int i=2;i<=19;++i){
        ans+=calc(i,0,D);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  int a,b,c;
  cin>>a>>b>>c;

if(a==b+c||a+b==c||b==a+c) 
cout<<"Yes"<<endl;

else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int d,n;
    cin >> d >> n;
    int x = 1;
    rep(i,d){
        x *= 100;
    }
    int cnt = 0;
    int ans = 0;
    for (int i = x; cnt != n; i+=x){
        if(i % (x*100) != 0){
            cnt++;
        }
        ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int a, b; cin >> a >> b;
	string s; cin >> s;
	if (s[a] == '-') {
		for (int i = 0; i < (a + b + 1); i++) {
			if (i == a)continue;
			if (s[i] == '-') {
				cout << "No" << endl; return 0;
			}
		}
	}
	else {cout << "No" << endl; return 0;}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- lines <$> getContents :: IO [String]
  mapM_ print $ solve xs

solve :: [String] -> [Int]
solve = map (toAl 0 . map toInt)

toAl :: Int -> [Int] -> Int
toAl s [x] = s + x
toAl s (x:y:ys) | x < y = toAl (s - x) (y:ys)
                | otherwise = toAl (s + x) (y:ys)

toInt :: Char -> Int
toInt x | x == 'I' = 1
        | x == 'V' = 5
        | x == 'X' = 10
        | x == 'L' = 50
        | x == 'C' = 100
        | x == 'D' = 500
        | x == 'M' = 1000

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  /*
  A[i]:=iが素数かどうかを保持する配列

  ex.A[2]=prime, A[4]=non prime;

  type bool yes or no

  */
  int A[100100];
  int i;
  int j;
  for(i=2;i<=100010;i++){
    int prime=1;
    for(j=2;j*j<=i;j++){
      if(i%j==0){
        prime=0;
      }
    }

    A[i]=prime;
  }

  int B[100100];
  for(i=0;i<100100;i++){
    B[i]=0;
  }

  for(i=3;i<100100;i+=2){
    if(A[i]==1 && A[(i+1)/2]==1){
      B[i]++;
    }
    B[i]+=B[i-2];
  }
  //B[i]:=1~iまでの2017に似た数の数

  int q;
  scanf("%d",&q);
  while(q--){
    int l,r;
    scanf("%d%d",&l,&r);
    printf("%d\n",B[r]-B[l-2]);
  }


  return 0;
}

Measured memory_bytes: 2484
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    string cmp="YAKI";
    int ct=0;
    for(int i=0;i<4;i++)
    {
        if(s[i]==cmp[i])
            ct++;
    }
    if(ct==4)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,i,j,c,r,tmp;
  scanf("%d",&n);
  int a[n][n];


for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    a[i][j]=0;
  }
 }
 for(j = 0;j<n;j++){
  scanf("%d %d",&c,&r);
  
  for(i = 0;i<r;i++){
    scanf("%d",&tmp);
    a[c-1][tmp-1] = 1;
  }

 }
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j == n-1) printf("%d\n",a[i][j]);
    else printf("%d ",a[i][j]);
  }
 }
  return 0;
}



Measured memory_bytes: 2052
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

int m, k;
vi seq;

void solve () {
	if (m == 1) {
		if (k >= 1) return;
		else {
			seq.push_back(0);
			seq.push_back(0);
			seq.push_back(1);
			seq.push_back(1);
		}
		return;
	}
	int n = (1 << m) - 1;
	if (k > n) return;
	seq.push_back(k);
	for (int i = 0; i <= n; i++) if (i != k) seq.push_back(i);
	seq.push_back(k);
	for (int i = n; i >= 0; i--) if (i != k) seq.push_back(i);
}

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &m, &k);
	solve();
	if (seq.empty()) printf("-1\n");
	else {
		for (int i = 0; i < seq.size(); i++) printf("%d%c", seq[i], " \n"[i == seq.size() - 1]);
	}
}


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

const int maxn=2005;

int vis[10005];

int main()
{
	for( int i=1;i<=100;i++ )
	{
		for( int j=1;j<=100;j++ )
		{
			for(int k=1;k<=100;k++ )
			{
				int tmp=i*i+j*j+k*k+i*j+j*k+i*k;
				if( tmp<=1e4 ) vis[tmp]++;
			}
		}
	}
	int n;
	cin>>n;
	for( int i=1;i<=n;i++ )cout<<vis[i]<<endl;
} 


Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
int a,b;
scanf("%d",&a);
scanf("%d",&b);
if(a<b){
printf("a < b\n");
}
if(a==b){
printf("a == b\n");
}
if(a>b){
printf("a > b\n");
}
return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N;
    cin >> N;
    ll N1 = N / 2;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    /*
    if (N % 2 == 0){
        ll a = 0, b = 0;
        REP(i, N){
            if (i % 2 == 0) a += A[i];
            else b += A[i];
        }
        cout << max(a, b) << endl;
        return 0;
    }
    */
    A.push_back(-1e18);
    A.push_back(-1e18);
    vector<vector<ll>> v(N+5, vector<ll>(3, -1e18));
    v[0][0] = 0;
    //v[0][1] = 0;
    REP(i, N+2)REP(j, 3){
        v[i+2][j] = max(v[i+2][j], v[i][j] + A[i]);
        if (j != 2) v[i+1][j+1] = max(v[i+1][j+1], v[i][j]);
    }

    cout << max(v[N+1][2], v[N+1][1]) << endl;
    return 0;
}



Measured memory_bytes: 15380
N, K = map(int, input().split())
ans = 0
base = 1 / N
for i in range(1, N + 1):
    if i >= K:
        ans += base
    else:
        c = 1
        while i * (2 ** c) <= K - 1:
            c += 1
        ans += base / (2 ** c)
print(ans)

Measured memory_bytes: 39536
n = gets.to_i
a = gets.split.map(&:to_i)

qq = []
ww = []

(n-n/2).times{|i|
  qq<<a[i*2]
  ww<<a[i*2+1] if i*2+1<n
}

if n%2==0 then
  tmp = ww
  ww = qq
  qq = tmp
end

ans = qq.reverse
ans<<ww

puts ans.join(" ")

Measured memory_bytes: 26140