akhauriyash/Code-Regression huggingface dataset:
//全方位で木の直径を求める
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A&lang=jp
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


struct edge{
  int to, cost;
};
vector<vector<edge>  >g;
vector<int> d;

void dfs(int now, int par){
    for(auto e: g[now])if(e.to != par){
        dfs(e.to,now);
        d[now] = max(d[now], d[e.to] + e.cost);
    }
}

void dfs2(int now, int d_par, int par){
    vp d_child;//深さ、頂点番号
    d_child.push_back(pii(0,-1));
    for(auto e: g[now]){
        if(e.to == par){
            d_child.push_back(pii(d_par + e.cost, e.to));
        }else{
            d_child.push_back(pii(d[e.to] + e.cost, e.to));
        }
    }
    sort(all(d_child));
    reverse(all(d_child));
    int ans = d_child[0].first + d_child[1].first;
    d[now] = max(d[now], ans);
    for(auto e: g[now])if(e.to != par){
        dfs2(e.to, d_child[d_child[0].second == e.to].first,now);
    }
}

signed main(void) {
    int n;
    cin >> n;
    g.resize(n);
    d = vi(n,0);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        edge e1 = {b,c};
        g[a].push_back(e1);
        edge e2 = {a,c};
        g[b].push_back(e2);
    }
    dfs(0,-1);
    dfs2(0,0,-1);
    int ans = 0;
    rep(i,n)ans = max(ans, d[i]);
    cout << ans << endl;
}



Measured memory_bytes: 29368
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int w = sc.nextInt();
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < S.length(); i+=w) {
      ans.append(S.charAt(i));
    }
    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 21844
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};


int main(){
	int glaph[100][100]={};
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int k;
		cin>>k>>k;
		for(int j=0;j<k;j++){
			int v;
			cin>>v;
			v--;
			glaph[i][v]=1;
		}
	}
	queue<int> widesearch;
	int ans[100]={};
	int counter=1;
	ans[0]=1;
	widesearch.push(0);
	while(widesearch.size()>0){
		counter++;
		int size=widesearch.size();
		for(int i=0;i<size;i++){
			int from=widesearch.front();
			widesearch.pop();
			for(int j=0;j<n;j++){
				if(glaph[from][j]==1 and ans[j]==0){
					ans[j]=counter;
					widesearch.push(j);
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<i+1<<" "<<ans[i]-1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3124
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = 0;
        for(int i=1; i<=n; i++) {
            int a = sc.nextInt();
            if(i%2==1 && a%2==1) {
                res++;
            }
        }
        System.out.println(res);
    }


}

Measured memory_bytes: 35792
a=gets.chomp.to_i
line=gets.chomp.split.map(&:to_i)
line.map!.with_index {|ai, i| ai - i - 1}
line.sort!
b = line[line.length/2]
puts line.map{|x| (x - b).abs}.inject(:+)

## 他の方のコードを参考にしました

Measured memory_bytes: 19456
#include <iostream>
#include <string>
#include <utility>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    PP dp[3002][3002];
    fill(dp[0], dp[0] + 3002, PP(0, P(-1, -1)));
    for(int i = 0; i < 3002; i++){
        dp[i][0] = PP(0, P(-1, -1));
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]) dp[i][j] = PP(dp[i - 1][j - 1].first + 1, P(i - 1, j - 1));
            else{
                if(dp[i - 1][j].first >= dp[i][j - 1].first) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = dp[i][j - 1];
            }
        }
    }
    P p = dp[n][m].second;
    char c[3002];
    while(p.first >= 0 && p.second >= 0){
        c[dp[p.first][p.second].first] = s[p.first];
        p = dp[p.first][p.second].second;
    }
    for(int i = 0; i < dp[n][m].first; i++) cout << c[i];
    cout << endl;
}

Measured memory_bytes: 105856
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)((x)>(y)?(x):(y))
#define min(x,y)((x)>(y)?(y):(x))
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

typedef struct data_{
   int x;
   int y;
}data_t;
typedef struct queue_{
    int n,f,t;
    data_t data[200000];
    int (*size)();
    int (*front)();
    int (*tail)();
    void (*enqueue)(data_t);
    data_t (*dequeue)(); 
    void (*init)();
    int (*isEmpty)();
}queue_t;
queue_t queue;
int size(){return queue.n;}
int front(){return queue.f;}
int tail(){return queue.t;}
void enqueue(data_t data){queue.n++;queue.data[queue.t++]=data;}
data_t dequeue(){queue.n--;return queue.data[queue.f++];}
void init(){queue.f=queue.t=queue.n=0;}
int isEmpty(){return queue.n?0:1;}
void setQueue(){
    queue.size=size;
    queue.front=front;
    queue.tail=tail;
    queue.enqueue=enqueue;
    queue.dequeue=dequeue;
    queue.init=init;   
    queue.isEmpty=isEmpty;
}
int h,w;
char s[40][40];
int dist[40][40];
int bfs(int x,int y){
    if(s[y][x]=='#')return -1;
    int max=-1;
    dist[y][x]=0;
    data_t data,now;
    data.x=x;data.y=y;
    queue.enqueue(data);
    while(!queue.isEmpty()){
        now=queue.dequeue();
        for(int i=0;i<4;i++){
            data.x=now.x+dx4[i];data.y=now.y+dy4[i];
            if(s[data.y][data.x]=='.'&&dist[data.y][data.x]==-1&&(0<=data.x&&data.x<w)&&(0<=data.y&&data.y<h)){
                queue.enqueue(data);
                dist[data.y][data.x]=dist[now.y][now.x]+1;
                max=max(max,dist[data.y][data.x]);
            }
        }
    }
    return max;
}

void initdist(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            dist[i][j]=-1;
        }
    }
}

int main(){
    setQueue();
    queue.init();

    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }

    int ans=-1,x;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            initdist();
            x=bfs(j,i);
            ans=max(x,ans);
        }
    }

    printf("%d\n",ans);
}

Measured memory_bytes: 1408
#include<vector>
#include<string>
#include<iostream>

using namespace std;

int N,M,cnt = 0;
int to[15][15]; int P[15]; bool switch1[15];

void count(){
    int count[15];
  
  for(int i = 1; i <= M ; i++){
    count[i] = 0;} //countを初期化
  //ある注目した電球(1からM)を灯すスイッチ全体のうち、onになっているものの個数をcountで表す
  for(int i = 1; i <= M; i++){
    for(int j = 1; j <= N; j++){
      if(to[i][j] > 0 && switch1[j] == true){ count[i]++;}}}
  //i番目の電球とj番目のスイッチがつながっていて、かつj番目のスイッチがonならば、インクリメント
    
    bool flag = true;//flag初期化
    
    for(int i = 1; i <= M; i++){
      if(count[i] % 2 != P[i]){ flag = false;}}//M個の電球に対し、点灯するかを調べる
    
    if(flag){ cnt++;} //flagが破られなければ、答えをインクリメント
  }

void dfs( int X){ //スイッチはNこ,深さXは１からNまで
  if(X == N + 1){ count(); return;}
  switch1[X] = false; dfs( X+1 );
  switch1[X] = true;  dfs( X+1 );
} //N個のスイッチに対し、on/off、をdfsで全列挙


  


int main(){
   cin >> N >> M;
 
  
  for(int i = 1; i <= M; i++){
    int c; cin >> c;
    for(int j = 1; j <= c; j++){ int d;
                                cin >> d; to[i][d]++;}}//toは隣接行列
 for(int i = 1; i <= M ; i++){ cin >> P[i];}
  
  dfs(1);
  

 cout << cnt << endl;
  
  return 0;
}
    


Measured memory_bytes: 256
//B - Traveling AtCoDeer Problem: 
//Assunto:
#include<bits/stdc++.h>
#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 loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    vector<int> pos(n);
    loop(i, 0, n) cin >> pos[i];
    sort(all(pos));
    cout << pos[n-1] - pos[0] << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	long long X, Y;
	cin >> X >> Y;

	long long result = 0;
	while (X <= Y)
	{
		result++;
		X *= 2;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,c,d,e;
    rep(i,5){
        cin>>a;
        if(i+1!=a) cout << i+1 << endl;
    }



    



}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define N int(2e5+10)
#define mod 998244353
using namespace std;
ll dp[N], pre[N];
int l[N], r[N], n, k;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cin >> n >> k;
	for (int i = 1; i <= k; i++)
		cin >> l[i] >> r[i];
	pre[0] = dp[0] = 0ll;
	pre[1] = dp[1] = 1ll;
	for (int i = 2; i <= n; i++) {
		dp[i] = 0ll;
		for (int j = 1, u, v; j <= k; j++) {
			if (l[j] >= i)
				continue;
			u = l[j];
			v = min(i - 1, r[j]);
			dp[i] = ((dp[i] + pre[i - u]) % mod - pre[i - v - 1]) % mod;
			if (dp[i] < 0ll)
				dp[i] += mod;
		}
		pre[i] = (pre[i - 1] + dp[i]) % mod;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 6792
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define pll pair<ll, ll>

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

    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    rep(i, N) {
        cin >> a[i];
        b[i] = a[i];
    }

    ll tmp1 = 0, tmp2 = 0, ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            if (a[i] <= 0)
                tmp1 += (1 - a[i]), a[i] = 1;
            if (b[i] >= 0)
                tmp2 += (b[i] + 1), b[i] = -1;
        } else {
            if (a[i] >= 0)
                tmp1 += (a[i] + 1), a[i] = -1;
            if (b[i] <= 0)
                tmp2 += (1 - b[i]), b[i] = 1;
        }

        if (i != N - 1)
            a[i + 1] += a[i], b[i + 1] += b[i];
    }

    ans = min(tmp1, tmp2);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using LLONG = long long;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> img(H, vector<char>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            cin >> img[i][j];
        }
    }
    for (int i = 0; i < H; ++i)
    {
        for (int k = 0; k < 2; ++k)
        {
            for (int j = 0; j < W; ++j)
            {
                cout << img[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = tuple(input().split())
q = tuple(input().split())
count_p = 0
count_q = 0
count = 1
for i in itertools.permutations(sorted(p)):
  if i == p:
    count_p = count
  if i == q:
    count_q = count
  count += 1
print(abs(count_p - count_q))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;
 
#define REP(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "
 
template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(12) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int a[26]={0};
    string s;
    read(s);
    rep(i,s.size())a[s[i]-'a']++;
    rep(i,26)if(a[i]%2==1)write("No"),exit(0);
    write("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	char *ans, *d, *der, *e, *eer;
	char s[100000], cf[8], cl[7];
	scanf("%s", s);
	ans="YES";
	d="dream";
	der="dreamer";
	e="erase";
	eer="eraser";

	int l=(int)strlen(s);

	deque<char> qs;

	for(int i=0; i<l; i++){
		qs.push_back(s[i]);
	}
	while(1){
		int l=qs.size();
		if(l>=8){
			int j=0;
			for(auto itr=qs.begin(); itr!=qs.begin()+8; itr++){
				cf[j]=*itr;
				j++;
			}
			if(cf[0]=='d' && cf[1]=='r' &&cf[2]=='e' && cf[3]=='a' && cf[4]=='m'){
				if(cf[5]!='e'){
					for(int i=0; i<5; i++){
						qs.pop_front();
					}
					continue;
				}else if(cf[6]!='r'){
					ans="NO";
					break;
				}else if(cf[7]=='a'){
					for(int i=0; i<5; i++){
						qs.pop_front();
					}
					continue;
				}else{
					for(int i=0; i<7; i++){
						qs.pop_front();
					}
					continue;
				}
			}else if(cf[0]=='e' && cf[1]=='r' &&cf[2]=='a' && cf[3]=='s' && cf[4]=='e'){
				if(cf[5]!='r'){
					for(int i=0; i<5; i++){
						qs.pop_front();
					}
					continue;
				}else{
					for(int i=0; i<6; i++){
						qs.pop_front();
					}
					continue;
				}
			}else{
				ans="NO";
				break;
			}
		}else{
			int j=0;
			for(auto itr=qs.begin(); itr!=qs.end(); itr++){
				cl[j]=*itr;
				j++;
			}
			int c1, c2, c3, c4;
			c1=strcmp(cl, d);
			c2=strcmp(cl, der);
			c3=strcmp(cl, e);
			c4=strcmp(cl, eer);
			if(c1*c2*c3*c4!=0){
				ans="NO";
				break;
			}else{
				break;
			}
		}
	}
	printf("%s\n", ans);
	return 0;

}


Measured memory_bytes: 384
N, M = map(int, input().split())
H = list(map(int, input().split()))

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to = map(lambda a: int(a) - 1, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

ans = 0
for i, h in enumerate(H):
    mx = 0
    for to in edges[i]:
        mx = max(mx, H[to])
    if mx < h:
        ans += 1

print(ans)


Measured memory_bytes: 29500
#include<bits/stdc++.h>
using namespace std;
int a[200010],b[200010];
int main()
{
  int n;
  cin>>n;
  long long ans1=0,ans2=0;
  for(int i=0;i<n;i++)
  {
  	cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  if(n%2==1)
  {
  	ans1=a[(n+1)/2-1];
  	ans2=b[(n+1)/2-1];
  }
  else
  {
  	ans1=a[n/2-1]+a[n/2];
  	ans2=b[n/2-1]+b[n/2];
  }
  cout<<(ans2-ans1+1)<<endl;
  return 0;
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,M;
  cin>>N>>M;

  LL ki = (M + 1) / 2;
  LL guu = M / 2;
  
  REP(i,ki){
    cout<< i+1+1 SP (0-i+N)%N + 1 <<endl;
  }
  REP(i,guu){
    cout << M + 1 - i - 1+1 SP M + 1 + i + 1+1 << endl;
  }
}


Measured memory_bytes: 3656
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		long[] A = new long[N+1];
		for(int i = 0; i <= N; i++)
			A[i] = sc.nextInt();
		long[] B = new long[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		ans += Math.min(A[0], B[0]);
		B[0] = Math.max(B[0] - A[0], 0);
		ans += Math.min(A[N], B[N-1]);
		B[N-1] = Math.max(B[N-1] - A[N], 0);
		for(int i = 1; i < N; i++) {
			ans += Math.min(A[i], B[i-1]);
			A[i] = Math.max(A[i] - B[i-1], 0);
			ans += Math.min(A[i], B[i]);
			B[i] = Math.max(B[i] - A[i], 0);
		}
		System.out.println(ans);

	}

}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;

  cin >> n;

  int ans = INF;

  for(int i = 1; i*i <= n; i++) {
    if(n % i == 0) {
      ans = min(ans, i + n/i - 2);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    var ans string
    if a+b==c || a+c==b || b+c==a{
        ans = "Yes"
    } else {
        ans = "No"
    }
    fmt.Println(ans)
}





func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


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

using namespace std;

const int mod = 1e9+7;
int dp[101][4][4][4];

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

    dp[0][3][3][3] = 1;

    for(int len = 0; len < N; len++){
        for(int c1 = 0; c1 < 4; c1++){
            for(int c2 = 0; c2 < 4; c2++){
                for(int c3 = 0; c3 < 4; c3++){
                    if(dp[len][c1][c2][c3] == 0) continue;

                    for(int a = 0; a < 4; a++){
                        if(a == 2 && c1 == 1 && c2 == 0) continue;
                        if(a == 2 && c1 == 0 && c2 == 1) continue;
                        if(a == 1 && c1 == 2 && c2 == 0) continue;
                        if(a == 2 && c1 == 1 && c3 == 0) continue;
                        if(a == 2 && c2 == 1 && c3 == 0) continue;

                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;

    for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
                ans += dp[N][c1][c2][c3];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
string a,b;
cin>>a >>b;
if (a=="H"){
	if (b=="H"){
		cout<<"H"<<endl;
	}
	else{
		cout<<"D"<<endl;
	}
}
else{
	if(b=="H"){
		cout<<"D"<<endl;
	}
	else{
		cout<<"H"<<endl;
	}
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    ll N,ans=0;
    cin >> N;
    map<int,int> mp;
    int a;
    for(ll i=0;i<N;i++){
        cin >> a;
        mp[a]++;
    }
    for(auto e : mp){
        if(e.second % 2==1){
            ans++;
        }
    }
    cout << ans << endl;
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.assign(n, 0);
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = a[0];
  for(int i = 1; i < n; ++i) ans = GCD(ans, a[i]);
  return ans;
}

Measured memory_bytes: 1024
#include <iostream>
    #include <string>
    #include <vector>
    #include <set>
    #include <algorithm>
    #include <cctype>
    #include <cmath>
    #include <queue>
    #include <map>
    #include <numeric>
    #include <unordered_map>
    #include <iomanip>
    #include <functional>
    #include <bitset>
    #include <complex>
    #include <stack>
     
     
     
    #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 all(x) (x).begin(),(x).end()
     
    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; }
     
    typedef long long ll;
     
    using namespace std;
     
     
    int main()
    {
      ios::sync_with_stdio(false);
      cin.tie(0);
      int n,k;cin>>n>>k;
      int res=0;
      rep(i,n){int a;cin>>a;res+=min(k-a,a);}
      cout<<res*2<<endl;
     
      return 0;
     
    }

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

long long int memo[5000][50] = {};
int memo_f[5000][50] = {};
int geta = 2500;

long long int sertch(int v, int i, int x[50], int mval[50], int n, int a){
	long long int ret;
	int j;


//	for(j = 0; j<i;j++){ printf(" "); }
//	printf("[Start]v:%d i:%d\n",v,i);

	ret = 0;
	if(memo_f[v+geta][i] == 0){
		if(i==n){
			if( v == 0 ){
				ret = 1;
			}else{
				ret = 0;
			}
//			printf("---[End]v:%d i:%d ret:%lld\n",v,i,ret);
		}else{
//			if(v+mval[i] < 0){
//				ret = 0;
//			}
//			else{
				ret += sertch(   v              , i + 1, x, mval, n, a);
				ret += sertch( ( v + x[i] )     , i + 1, x, mval, n, a);
//				ret += sertch( ( v + x[i] ) % a , i + 1, x, mval, n, a);
//			}
		}
		memo_f[v+geta][i] = 1;
		memo[v+geta][i] = ret;
	}else{
		ret = memo[v+geta][i];
	}
//	for(j = 0; j<i;j++){ printf(" "); }
//	printf("---[End]v:%d i:%d ret:%lld\n",v,i,ret);
	return ret;
}


int main(void){

	int n;
	int a;
	int x[50];
	int i;
	int mval[50];

	scanf("%d %d",&n,&a);

	for(i=0;i<n;i++){		scanf("%d",&x[i]);	}
	qsort(x, n, sizeof(int), compare_int);

//	for(i=0;i<n;i++){	printf("%d ",x[i]);		}	printf("\n");	// 配列チェック


	for(i=0;i<n;i++){	x[i] -= a; }
//	for(i=0;i<n;i++){	x[i] = x[i] % a; }

//	for(i=0;i<n;i++){	printf("%d ",x[i]);		}	printf("\n");	// 配列チェック


//	mval[n-1] = x[n-1];
//	for(i=n-2;i>=0;i--){
//		mval[i] = mval[i+1] + x[i];
//	}

//	for(i=0;i<n;i++){	printf("%d ",x[i]);		}	printf("\n");	// 配列チェック
//	for(i=0;i<n;i++){	printf("%d ",mval[i]);	}	printf("\n");	// 配列チェック
	
	printf("%lld\n", sertch(0, 0, x, mval, n, a) - 1);

	return 0;
}

Measured memory_bytes: 896
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<int> d;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    for (int i = 0; i < n; i++)
    {
      int temp;
        cin >> temp;
      d.push_back(temp);
    }
    int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(i==j)continue;
      ans+=d[i]*d[j];
    }
  }
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int m, n, t[40], s[110];
int dp[110][40];

int main(){
	while(cin >> m, m){
		rep(i, m) cin >> t[i];
		cin >> n;
		rep(i, 110) rep(j, m) dp[i][j] = inf;
		rep(i, 110) s[i] = 24;
		rep(i, n){
			int a, b;
			cin >> a >> b;
			s[a - 1] = min(s[a - 1], b);
		}
		dp[0][0] = 0;
		rep(i, 105) rep(j, m) if(dp[i][j] < inf){
			if(t[(j + 1) % m] <= s[i + 1])
			dp[i + 1][(j + 1) % m] = min(dp[i + 1][(j + 1) % m], dp[i][j]);
			
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + 1);
		}
		int ans = inf;
		rep(i, m) ans = min(ans, dp[105][i]);
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int n, i, x = 0, ans = 0;
  cin >> n;
  string s;
  cin >> s;
  for (i = 0; i < n; ++i) {
    if (s[i] == 'I') {
      ++x;
    } else {
      --x;
    }
    ans = max(ans, x);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, D; cin >> N >> D;
	int X[N][D];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++)
		{
			cin >> X[i][j];
		}
	}

	int res = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			double tmp = 0;
			for (int k = 0; k < D; k++)
			{
				tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			for (int k = 0; k * k <= tmp; k++)
			{
				if(k * k == tmp) {
					res++;
					break;
				}
			}
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[100],h[100];

int main(){
	h[1] = 'Y',h[2] = 'A',h[3] = 'K',h[4] = 'I';
	cin >> s + 1;
	int n = strlen(s + 1);
	int flag = 0;
	for(int i = 1;i <= n;i++){
		flag = 0;
		for(int j = i;j <= i + 3;j++){
			if(s[j] == h[j - i + 1]) flag++;
		}
		if(flag == 4 && i == 1){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<set> 
using namespace std;
int main()
{
	long long a;
	cin>>a;
	if(a%2==0)cout<<a;
	else cout<<2*a;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = []
for h in range(1, 3501):
    for n in range(h, 3501):
        x = 4 * h * n - N * n - N * h
        if x == 0:
            continue
        w = N * h * n // x
        if 4 * h * n * w == N * (n * w + h * w + h * n):
            ans = [h, n, w]
            break
print(' '.join(map(str, ans)))

Measured memory_bytes: 41836
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else if(b > c){
				System.out.println("No");
			}
		}
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 26320
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for(;;){
			long n = sc.nextLong();
			if(n ==0 ){
				break;
			}
			char[] ch = ("1" + sc.next()).toCharArray();
			long d = decode(ch);
			long e = 0;
			long bound = (1L<<53);
			long now = d;
			long nowd = d;
			long remain = n;
//			System.out.println(encode(e,d));
//			System.out.println(d);
			for(;;){
				if(nowd == 0){
					break;
				}
				long next = (bound - now);
				long times = ((next - 1)/ nowd)+1;
//				System.out.println(bound+" "+next + " "+times);
				if(remain < times){
					now += nowd * remain;
					break;
				}
				
				now += nowd * times;
				now >>= 1;
				nowd >>= 1;
				e++;
				remain -= times;
			}
			System.out.println(encode(e,now));
		}	
	}
	String encode(long e,long now){
		
		String ee = String.format("%012d", 0)+Long.toBinaryString(e);
		String dd = String.format("%052d", 0)+Long.toBinaryString(now);
		ee = ee.substring(ee.length()-12);
		dd = dd.substring(dd.length()-52);
		return ee + dd;
	}
	long decode(char[] ch2){
		long res = 0;
		for(int i =0 ; i < ch2.length;i++){
			res *= 2;
			res += ch2[i] - '0';
		}
		return res;
	}
	
	
}



Measured memory_bytes: 39224
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a, b, c;

int main() {
	cin >> a >> b >> c;
	
	cout << max(0, c - (a - b)) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i%d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-14 10:45:07
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
const int N=1600010;
std::vector<int> e[N];
int n,q[N],l,r,id[N],vis[N],ans[N],m;
namespace dinic
{
	int e=1,begin[N],next[N],to[N],w[N],dis[N],n,S,T,q[N],l,r,cur[N];
#define fo(i,a) for(int i=begin[a];i;i=next[i])
#define Fo(i,a) for(int &i=cur[a];i;i=next[i])
	void add(int u,int v,int W){ e++; next[e]=begin[u]; begin[u]=e; to[e]=v; w[e]=W; }
	int bfs()
	{
		fr(i,1,n) dis[i]=n+1;
		fr(i,1,n) cur[i]=begin[i];
		q[l=r=1]=T; dis[T]=0;
		while(l<=r)
		{
			int u=q[l++];
			fo(i,u) if(w[i^1]&&dis[u]+1<dis[to[i]])
			{
				dis[to[i]]=dis[u]+1; q[++r]=to[i];
			}
		}
//		fr(i,1,n) printf("%d%c",dis[i],i==n?'\n':' ');
		return dis[S]<=n;
	}
	int dfs(int u,int F)
	{
		int ans=0;
		if(u==T) return F;
		Fo(i,u) if(w[i]&&dis[u]-1==dis[to[i]])
		{
			int f=dfs(to[i],std::min(F,w[i]));
			if(f)
			{
				F-=f; w[i]-=f; ans+=f; w[i^1]+=f;
				if(!F) return ans;
			}
		}
		return ans;
	}
	void Add(int u,int v,int w){ add(u,v,w); add(v,u,0); }
	void solve()
	{
//		fr(i,1,n) fo(j,i) if(w[j]) printf("%d %d\n",i,to[j]);
		while(bfs()) dfs(S,n);
		fr(i,1,::n-1) fo(j,i) if(to[j]>=::n+1&&w[j^1]) ::id[i]=to[j]-::n;
//		fr(i,1,n) fo(j,i) if(w[j]) printf("%d %d\n",i,to[j]);
//		fr(i,1,::n-1) printf("%d%c",::id[i],i==end_i?'\n':' ');
	}
}
int main()
{
	n=read(); dinic::n=n*2; dinic::S=n; dinic::T=n+1;
	fr(i,1,n-1)
	{
		int c=read();
		fr(j,1,c)
		{
			int u=read();
			e[u].push_back(i); if(u!=1) dinic::Add(i,u+n,1);
		}
	}
	fr(i,1,n-1){ dinic::Add(dinic::S,i,1); dinic::Add(i+n+1,dinic::T,1); }
	dinic::solve();
	fr(i,1,n-1) if(!id[i]){ printf("-1\n"); return 0; }
	q[l=r=1]=1; vis[1]=1;
/*	fr(i,1,n)
	{
		for(auto j:e[i]) printf("%d ",j);
		putchar(10);
	}*/
	while(l<=r)
	{
		int i=q[l++];
		for(auto j:e[i]) if(!vis[id[j]]){ m++; ans[j]=i; vis[id[j]]=1; q[++r]=id[j]; }
	}
	if(m<n-1) printf("-1\n");
	else fr(i,1,n-1) printf("%d %d\n",id[i],ans[i]);
	return 0;
}

Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int N,M;
string S;
int main(){
  cin>>S;
  int a=0,b=0;
  REP(i,0,3){
    if(S[i]=="A"[0]){
      a++;
    }
    else b++;
  }
  if((a==3)or(b==3))print("No")
  else print("Yes")

}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=20;

vector<ll> v;

void make(ll x,ll prev,ll num)
{
    if(x==-1)
    {
        v.pb(num);
        return;
    }
    f(i,max(prev-1,0ll),min(prev+1,9ll))
    {
        make(x-1,i,num*10+i);
    }
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll k;
        cin>>k;
        f(d,0,9)
        {
            f(i,1,9)
            {
                make(d-1,i,i);
            }
        }
        sort(all(v));
        v.resize(unique(all(v))-v.begin());
        d1(v[k-1]);
    }
    return 0;
}


















Measured memory_bytes: 2420
# -*- coding:utf-8 -*-

from collections import defaultdict

N, Q = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N-1)]
px = [tuple(map(int, input().split())) for _ in range(Q)]

parent_map = {b: a for a, b in ab}
child_map = defaultdict(list)
for parent, child in ab:
    child_map[parent].append(child)

operation_map = defaultdict(int)
for p, x in px:
    operation_map[p] += x

counter = [0] * N

counter[0] = operation_map[1]
stack = list(child_map[1])
node_no = 0
while True:
    try:
        node_no = stack.pop()
    except IndexError:
        break

    parent_no = parent_map[node_no]
    counter[node_no - 1] = counter[parent_no - 1] + operation_map[node_no]
    stack += list(child_map[node_no])

print(' '.join(map(str, counter)))


Measured memory_bytes: 156652
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ( a*b > c*d)
        cout << a*b;
    else if (c*d > a*b)
        cout << c*d;
    else if (a*b == c*d)
        cout << a*b;
    return 0;
}


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

int main(){
  int l;
  int a,b;
  int c,d;
  int ans;
  int j,m;
  
  scanf(" %d %d %d %d %d",&l,&a,&b,&c,&d);
  
  j = m = 0;
  if(a%c!=0){
    j=1;
  }
  if(b%d!=0){
    m=1;
  }
  
  ans = max(a/c+j,b/d+m);
  
  printf("%d\n",l-ans);
  
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;

const int mo=1000000007;
int power(int x,ll y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
const int N=105;
int a[N],mn[N][N];
int fxor[N][N];
int trans[N][N];
int mx[N],g[N],n;
int main(){
	scanf("%d",&n); n++;
	for (int i=2;i<=n;i++)
		scanf("%d",&a[i]);
	a[0]=a[1]=a[n+1]=a[n+2]=1;
	for (int i=1;i<=n;i++){
		mn[i][i]=i;
		for (int j=i+1;j<=n;j++)
			mn[i][j]=(a[j]<a[mn[i][j-1]]?j:mn[i][j-1]);
	}
	for (int i=1;i<=n+2;i++)
		fxor[i][i-1]=1;
	for (int l=n+2;l>=1;l--)
		for (int r=l;r<=n+2;r++){
			if (a[l]<a[l-1]||a[r]<a[r+1]) continue;
			int dn=max(a[l-1],a[r+1]),md=mn[l][r];
			if (a[md]<dn) continue;
			fxor[l][r]=1ll*power(2,a[md]-dn)*fxor[l][md-1]%mo*fxor[md+1][r]%mo;
		}
	for (int l=n+1;l>=1;l--)
		for (int r=l;r<=n+1;r++){
			for (int k=l-1;k<=r+1;k++) mx[k]=0;
			int tmp=a[l-1];
			for (int k=l;k<=r;k++)
				mx[k]=tmp=min(tmp,a[k]);
			tmp=a[r+1];
			for (int k=r;k>=l;k--)
				mx[k]=max(mx[k],tmp=min(tmp,a[k]));
			int las=l-1; trans[l][r]=1;
			for (int k=l;k<=r+1;k++)
				if (mx[k]>=a[k]||k==r+1) trans[l][r]=1ll*trans[l][r]*fxor[las+1][k-1]%mo,las=k;
		}
	g[1]=1;
	for (int i=2;i<=n+2;i++)
		for (int j=1;j<i;j++)
			UPD(g[i],1ll*g[j]*trans[j][i-1]%mo);
	printf("%d\n",1ll*g[n+2]*500000004ll%mo);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int R, G, B, N;

int main() {
	cin >> R >> G >> B >> N;
	
	int ans = 0;
	incII(r, 0, N) {
	incII(g, 0, N) {
		int b = (N - (R * r + G * g)) / B;
		if(inII(b, 0, N) && R * r + G * g + B * b == N) { ans++; }
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX 100000
using namespace std;

long long dp[MAX];
vector<long long> h(MAX);

int main(){
    long long n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> h.at(i);
    }
    /**/
    for(int x = 2;x <= n;x++){
        if(x == 2){
            dp[x] = abs(h.at(1) - h.at(0));
        }
        else{
            dp[x] = min((dp[x - 1] + abs(h.at(x - 1) - h.at(x - 2))),(dp[x - 2] + abs(h.at(x - 1) - h.at(x - 3))));
        }
    }
    
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_sum = 0
ans = 0
for i in range(n):
    p_sum += p[i]
    if i >= k:
        p_sum -= p[i - k]

    ans = max(p_sum, ans)

ans = (ans + k) / 2

print(ans)


Measured memory_bytes: 24804