akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,a,b=0;
	cin>>x>>a>>b;
	cout<<((abs(x-a)<abs(x-b))?"A":"B")<<endl;



//	int m,n;
//	cin>>n>>m;
//	vector<string> a(n);
//	vector<string> b(m);
//
//	rep(i,n)cin>>a[i];
//	rep(i,m)cin>>b[i];
//
//	rep(i,n-m+1)rep(j,n-m+1){
//		rep(k,m)rep(l,m)if(a[i+k][j+l]!=b[k][l])goto BB;
//		cout<<"Yes"<<endl;
//		return 0;
//BB:
//		continue;
//	}
//	cout<<"No"<<endl;
//
//
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion


int n, m;
vector<int> graph[222'222];
int vst[222'222];
int fldfil(int now, int col)
{
    if(vst[now]) return 0;
    vst[now] = col;
    int ret = 1;
    for(int it: graph[now])
    {
        ret +=fldfil(it, col);
    }
    return ret;
}
void solve()
{
    cin>>n>>m;
    forn(_, m)
    {
        int x, y; cin>>x>>y;
        --x,--y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    int ans = 0;
    forn(i, n)
    {
        if (vst[i]) continue;
        ans = max(ans, fldfil(i, i + 1));
    }
    cout << ans << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 26012
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,k,s,t[200001],ans=1,vis[200001],now;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		cin>>t[i];
	}
	while((!vis[ans])&&k)
	{
		++now;
		vis[ans]=now;
		ans=t[ans];
		--k;
	}
	k%=now-vis[ans]+1;
	while(k)
	{
		ans=t[ans];
		--k;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<int,pair<int,int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000000000000

vector<int> parent;
int find(int x){
  int y=parent.at(x);
  while(y!=parent.at(y)){
    y=find(y);
  }
  return parent.at(x)=y;
}

void unite(int a,int b){
  int x=find(a);
  int y=find(b);
  if(x!=y){
    parent.at(x)=y;
  }
}


int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> xy(N);
  for(int i=0;i<N;i++){
    cin>>xy.at(i).first>>xy.at(i).second;
  }
  vector<pair<int,int>> X(N),Y(N);
  for(int i=0;i<N;i++){
    X.at(i).first=xy.at(i).first;
    X.at(i).second=i;
    Y.at(i).first=xy.at(i).second;
    Y.at(i).second=i;
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  priority_queue<pp,vector<pp>,greater<pp>> pq;
  for(int i=0;i<N-1;i++){
    pp p1=make_pair(X.at(i+1).first-X.at(i).first,make_pair(X.at(i).second,X.at(i+1).second));
    pp p2=make_pair(Y.at(i+1).first-Y.at(i).first,make_pair(Y.at(i).second,Y.at(i+1).second));
    pq.push(p1);
    pq.push(p2);
  }

  parent.resize(N);
  for(int i=0;i<N;i++){
    parent.at(i)=i;
  }

  int ans=0;
  while(!pq.empty()){
    pp p=pq.top();
    pq.pop();
    int d=p.first;
    int i=p.second.first;
    int j=p.second.second;
    if(find(i)!=find(j)){
      ans+=d;
      unite(i,j);
    }
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 7284
H,W=map(int,input().split())
#G=[[-1 if input() else 0 for i in range(W)] for _ in range(H)]
MOD=10**9+7
#リストver
dp=[[-1]*W for _ in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=='#':
            dp[i][j]=0
dp[0][0]=1

'''
#numpy ver
import numpy as np
dp=np.array([list(input()) for _ in range(H)])

dp=np.where(dp=='.',-1,dp)
dp=np.where(dp=='#',0,dp)

dp[0][0]=1
'''
for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            elif i>=1 and j==0:
                dp[i][j]=dp[i-1][j]
            elif i==0 and j>=1:
                dp[i][j]=dp[i][j-1]

print(dp[H-1][W-1]%MOD)

Measured memory_bytes: 156532
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 K, A, B;
  std::cin >> K >> A >> B;
  std::cout << (B - A > 2 && A - 1 <= K ? A + (K - (A - 1)) / 2 * (B - A) + (K - (A - 1)) % 2 : K + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
    var w = input.split("\n").slice(0,1);
    var y = w[0].split(" ").map(a => parseInt(a) );

    var ans = 'Yes';
    if(y[0] % 2 == 0 || y[1] % 2 == 0) {ans = 'No';}
    console.log(ans);
} );
process.stdin.on('end', function() {
});

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


string s[20];
void make(int h,int w){
    for(int j=0;j<h;j++)for(int i=0;i<w;i++) s[j]+='.';
}
void dbg(int h,int w){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cerr<<s[i][j];
        }
        cerr<<endl;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int h,w,n;
    cin>>w>>h>>n;
    vector<vector<int>> v(h);
    // make(h,w);
    int wall[h]={};
    for(int i=0;i<h;i++) wall[i] = i-1;
    for(int i=0;i<n;i++){
        int x,y; cin>>x>>y;
        x--,y--;
        // s[y][x]='#';
        if(wall[y]+1==x) wall[y] = x;
        v[y].push_back(x);
    }
    //dbg(h,w);
    for(int i=0;i<h;i++){
        sort(v[i].begin(),v[i].end());
    }
    int ans = w;
    for(int i=0;i<h;i++){
        if(i) wall[i] = max(wall[i],wall[i-1]+1);
        if(v[i].size()==0) continue;
        if(i==0){
            ans = v[i][0];
            continue;
        }
        for(int j=0;j<v[i].size();j++){
            if(v[i][j]<=wall[i]+1){
                wall[i] = max(wall[i],v[i][j]);
                continue;
            }
            if(v[i][j]>=ans) break;
            if(j==0){
                ans = v[i][j];
                break;
            }
            if(v[i][j-1]+1 == v[i][j]) continue;
            ans = v[i][j];
            break;
        }
        //cerr << i << " " << ans << " "<< wall[i]<<endl;
    }
    cout << ans << endl;

}

Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)




int main() {

	int n;
	cin >> n;
	double x = n / 1.08;
	int y = (int)(x+0.9);
	int z = (int)(y * 1.08);
	if (z == n) {
		cout << y;
	}
	else cout<<":(";
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	writefln(FMT_F, N % 2 == 0 ? 0.5 : cast(double)(N / 2 + 1) / N);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
multiset<int>h1,h2;
ll s1,s2;
void push(int x){
	if(!h1.empty()&&x<*h1.rbegin()){   //先插入小堆
		h1.insert(x);
		s1+=x;
	}
	else{
		h2.insert(x);
		s2+=x;
	}
	while(h1.size()>h2.size()){
		const int cur=*h1.rbegin();
		h2.insert(cur);
		auto it=h1.end();
		it--;
		h1.erase(it);
		s1-=cur;
		s2+=cur;
	}
	while(h2.size()>h1.size()){
		const int cur=*h2.begin();
		h1.insert(cur);
		h2.erase(h2.begin());
		s1+=cur;
		s2-=cur;
	 }
 }
 ll num;
 int main(){
	int q;
	cin>>q;
	while(q--){
		int n;
		cin>>n;
		if(n==1){
			int a,b;
			cin>>a>>b;
			num+=b;
			push(a);
		}
		else{
			int x=*h1.rbegin();
	ll ans=1ll*x*(int)(h1.size())-s1+s2-1ll*x*(int)(h2.size())+num;
	    cout<<x<<' '<<ans<<'\n';
		}
	}
}


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

int main(){
    int a , b , c;
    cin >> a >> b >> c;
    if(b-a == c-b){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAXLENGTH_ARRAY 1000000
typedef struct
{
    char name[100];
    int time;
}Process;
Process p[MAXLENGTH_ARRAY];
int front,tail=0;
void InQ(Process new){p[tail++]=new;}
Process OutQ(){return p[front++];}
int main() {
    int n,q,duration=0;
    scanf("%d %d", &n, &q);
    for(int i=0;i<n;i++)
    {
        scanf("%s %d", p[i].name, &p[i].time);
    }
    tail = n;
    while(front!=tail)
    {
        Process x = OutQ();
        x.time-=q;
        if(x.time>0){InQ(x);duration +=q;}
        else{
                duration +=q + x.time;
                printf("%s %d\n", x.name, duration);
        }
    }
    return 0;
}




Measured memory_bytes: 20964
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll n, g[2], s[2], b[2], ans;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> n;
	cin >> g[0] >> s[0] >> b[0] >> g[1] >> s[1] >> b[1];
	if ((g[0] >= g[1] && s[0] >= s[1] && b[0] >= b[1]) || (g[1] >= g[0] && s[1] >= s[0] && b[1] >= b[0]))
	{
		sort(g, g + 2);
		sort(s, s + 2);
		sort(b, b + 2);
		for (int i = 0; i <= n; i++)
		{
			for (int j = 0; j <= n - i; j++)
			{
				ll zan = 0;
				zan += i % g[0] + i / g[0] * g[1];
				zan += j % s[0] + j / s[0] * s[1];
				zan += (n - i - j) % b[0] + (n - i - j) / b[0] * b[1];
				ans = max(ans, zan);
			}
		}
	}
	else if (g[0] <= g[1] && s[0] >= s[1] && b[0] >= b[1])
	{
		n = n % g[0] + n / g[0] * g[1];
		for (ll i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % s[1] + i / s[1] * s[0];
			zan += (n - i) % b[1] + (n - i) / b[1] * b[0];
			ans = max(ans, zan);
		}
	}
	else if (s[0] <= s[1] && b[0] >= b[1] && g[0] >= g[1])
	{
		n = n % s[0] + n / s[0] * s[1];
		for (ll i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % b[1] + i / b[1] * b[0];
			zan += (n - i) % g[1] + (n - i) / g[1] * g[0];
			ans = max(ans, zan);
		}
	}
	else if (b[0] <= b[1] && g[0] >= g[1] && s[0] >= s[1])
	{
		n = n % b[0] + n / b[0] * b[1];
		for (ll i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % g[1] + i / g[1] * g[0];
			zan += (n - i) % s[1] + (n - i) / s[1] * s[0];
			ans = max(ans, zan);
		}
	}
	else if (g[0] <= g[1] && s[0] <= s[1] && b[0] >= b[1])
	{
		ll m = 0;
		for (int i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % g[0] + i / g[0] * g[1];
			zan += (n - i) % s[0] + (n - i) / s[0] * s[1];
			m = max(m, zan);
		}
		ans = m % b[1] + m / b[1] * b[0];
	}
	else if (s[0] <= s[1] && b[0] <= b[1] && g[0] >= g[1])
	{
		ll m = 0;
		for (int i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % s[0] + i / s[0] * s[1];
			zan += (n - i) % b[0] + (n - i) / b[0] * b[1];
			m = max(m, zan);
		}
		ans = m % g[1] + m / g[1] * g[0];
	}
	else
	{
		ll m = 0;
		for (int i = 0; i <= n; i++)
		{
			ll zan = 0;
			zan += i % b[0] + i / b[0] * b[1];
			zan += (n - i) % g[0] + (n - i) / g[0] * g[1];
			m = max(m, zan);
		}
		ans = m % s[1] + m / s[1] * s[0];
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
int n,W,w[110],v[110];
ll dp[110][100010],ans;
void update(ll &x,ll y) {
	if (x<=y) x=y;
}
int main() {
//	freopen("1.txt","r",stdin);
	read(n); read(W);
	for (int i=1;i<=n;i++) read(w[i]),read(v[i]);
	for (int i=1;i<=n;i++) {
		for (int j=0;j<=W;j++) {
			dp[i][j]=dp[i-1][j];
			if (j>=w[i]) update(dp[i][j],dp[i-1][j-w[i]]+v[i]);
			update(ans,dp[i][j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 79360
def main(N, M, H, AB):
    bad = []
    for A, B in AB:
        if H[A - 1] >= H[B - 1]: #pythonは一個ずれる
            bad.append(B)
        if H[B - 1] >= H[A - 1]:
            bad.append(A)
    print(N - len(list(set(bad))))

if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    AB = []
    for i in range(M):
        AB.append(list(map(int, input().split())))
    main(N, M, H, AB)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int g[50][50];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    cout << (s[0] == '1') + (s[1] == '1') + (s[2] == '1') << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int reverse_info[128];
char info[52];

void func(int N){
	int key[N],div;

	for(int i = 0; i < N; i++)scanf("%d",&key[i]);

	char buf[101];

	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0'; i++){
		div = key[i%N];

		if(reverse_info[buf[i]] - div >= 0){
			printf("%c",info[reverse_info[buf[i]] - div]);
		}else{
			printf("%c",info[reverse_info[buf[i]] + 52 - div]);
		}
	}
	printf("\n");
}

int main(){

	int N;

	for(int i = 0; i <= 25; i++){
		info[i] = 'a' + i;
		reverse_info[info[i]] = i;
		info[26+i] = 'A' + i;
		reverse_info[info[26+i]] = 26+i;
	}

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

	return 0;
}

Measured memory_bytes: 2700
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100010],sum,i,j;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i=j+1)
	{
		for(j=i;j<n;j++)
			if(a[j+1]!=a[i])break;
		if(j-i+1>=a[i])sum+=j-i+1-a[i];else sum+=j-i+1;
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 640
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int age = sc.nextInt();
    if(age == 1){
      System.out.println("Hello World");
    }else{
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(a + b);
    }
  }
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <queue>
using namespace std;
#define P pair <int, int>
struct node
{
    int dis, cost;
    int no;
};
vector <node> edge[10005];
int mindis[10005];
bool use[10005];
int n, m;
void dijkstra()
{
    memset(use, false, sizeof(use));
    memset(mindis, 127, sizeof(mindis));
    priority_queue <P, vector <P>, greater<P> > que;
    que.push(make_pair(0, 1));
    mindis[1] = 0;
    while(que.size())
    {
        P now = que.top();
        que.pop();
        if(mindis[now.second] < now.first)
            continue;
        for(int i = 0; i < edge[now.second].size(); i++)
        {
            node next = edge[now.second][i];
            if(mindis[now.second] + next.dis < mindis[next.no])
            {
                mindis[next.no] = mindis[now.second] + next.dis;
                que.push(make_pair(mindis[next.no], next.no));
            }
        }
    }
}
int main()
{
    while(scanf("%d%d", &n, &m), n || m)
    {
        memset(edge, 0, sizeof(edge));
        for(int i = 0; i < m; i++)
        {
            int a, b, c, d;
            scanf("%d%d%d%d", &a, &b, &c, &d);
            node tmp;
            tmp.no = a;
            tmp.dis = c;
            tmp.cost = d;
            edge[b].push_back(tmp);
            tmp.no = b;
            edge[a].push_back(tmp);
        }

        dijkstra();
        int ans = 0;
        for(int i = 2;i <= n;i++)
        {
            int tmp = 2100000;
            for(int j = 0;j < edge[i].size();j++)
            {
                if(mindis[edge[i][j].no] + edge[i][j].dis == mindis[i] && edge[i][j].cost < tmp)
                    tmp = edge[i][j].cost;
            }
            ans += tmp;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int N,cnt=0,a;
  cin>>N;
  int H[N];
  for(int i=0;i<N;i++) cin>>H[i];
  for(int i=0;i<N;i++){
    if(i==0) a=H[0];
    a=max(H[i],a);
    if(a<=H[i]) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int a[200000];
int b[200000];
int pp[31][200000];

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);

	for (int i = 1; i < 30; i++) {
		for (int j = 0; j < n; j++)
			pp[i][j] = b[j] % (2 << i);
		sort(pp[i], pp[i] + n);
	}

	int cc = 0;
	for (int i = 0; i < n; i++)
		cc += b[i] % 2;

	int ans = 0;
	int cnt;

	for (int i = 0; i < n; i++) {
		int ttt = a[i] % 2;

		if (ttt == 1) cnt = n - cc;
		else cnt = cc;
		if (cnt % 2) ans ^= 1;

		for (int j = 1; j < 30; j++) { // 2^j자리를 결정하다
			int tt = a[i] % (2 << j);
			cnt = n - (lower_bound(pp[j], pp[j] + n, (1LL << j) - tt) - pp[j]); // tt + 임의의 값이 1 << j를 넘는 것의 개수.
			cnt -= n - (lower_bound(pp[j], pp[j] + n, (2LL << j) - tt) - pp[j]); // tt + 임의의 값이 2 << j를 넘는 것의 개수.
			cnt += n - (lower_bound(pp[j], pp[j] + n, (3LL << j) - tt) - pp[j]);

			if (cnt % 2) ans ^= (1 << j);
		}
	}



	printf("%d", ans);
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
//#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int M = 1010;
int n,m;
int dp[M][(1<<12)];
int a[M],b[M],c[M][13];
int full=0;
int solve(int id,int msk){
  if(msk==full)return 0;
  if(id==m+1)return 1e9;
  int &x = dp[id][msk];
    if(x!=-1)return x;
    x=solve(id + 1,msk);
    
    int nmsk = msk;
    for(int j=1;j<=b[id];j++){
      nmsk|=(1<<c[id][j]);
    }
    x = min(x,a[id] + solve(id+1,nmsk));
    return x;
}

// long long ? ?
int mark[13];
int32_t main(){
  memset(dp,-1,sizeof(dp));
  fastio;
  cin>>n>>m;
  full = (1<<n) - 1;
  for(int i=1;i<=m;i++){
    cin>>a[i]>>b[i];
    for(int j=1;j<=b[i];j++){
      cin>>c[i][j];
      c[i][j]--;
      mark[c[i][j]]++;
    }
  }
  for(int i=0;i<n;i++){
    if(!mark[i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<< solve(1,0)<<endl;

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 16512
K = int(input())

# init
lst = [[i for i in range(1,10)]]
total=9

## 8: 7, 8, 9
## 9: 8, 9
## 0: 0, 1

while total < K:
    lst.append([])
    for i in lst[-2]:
        strnum = str(i)
        last = int(strnum[-1])
        
        lst[-1].append(strnum + str(last))
        if last <= 8:
            lst[-1].append(strnum + str(last+1))
        if last >= 1:
            lst[-1].append(strnum + str(last-1))
            
    total += len(lst[-1])

lst[-1].sort()
print(lst[-1][K-total-1])

Measured memory_bytes: 17244
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S;
    int N;
    cin >> N >> S;

    bool ok = false;
    if (N % 2 == 0) {
        ok = true;
        rep(i, N/2) {
            if (S[i] != S[i + N/2]) {
                ok = false;
                break;
            }
        }
    }


    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1,n):
            l1 = l[i]
            l2 = l[j]
            l3 = l[k]
            if l1 != l2:
                if l2 != l3:
                    if l1 + l2 > l3:
                        count += 1
print(count)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
 using namespace std;
typedef long long int ll ;
typedef long double ld;

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 
#define forab(i,a,b) for(__typeof(a) i = a ; i < b ; i++) 
#define forba(i,b,a) for(__typeof(a) i = b ; i > a ; i--) 
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005

int n , m;
ll d, A, B;
vector<ll> x , y;
vector<ll> a , b;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

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

  for(int i = 0 ; i < n ; i++)
  {
  	scanf("%lld" , &d);
  	x.push_back(d);
  }

  for(int i = 0 ; i < m ; i++)
  {
  	scanf("%lld" , &d);
  	y.push_back(d);
  }

  for(int i = 0 ; i < n-1 ; i++)
   	a.pb(x[i+1] - x[i]);
  
  for(int j = 0 ; j < m - 1 ; j++)
  	b.push_back(y[j+1] - y[j]);

  A = B = 0;

  for(int i = 0 ; i < n-1 ; i++)
  {
  	A = (A + ( ((a[i] * (i+1))%MOD) * (n - i - 1) ) % MOD ) % MOD;
  }

  for(int i = 0 ; i < m-1 ; i++)
  {
  	B = (B + ( ((b[i] * (i+1))%MOD) * (m - i - 1) ) % MOD ) % MOD;
  }

  // printf("%lld %lld\n" , A , B);

  ll ans = (A * B) % MOD;
  printf("%lld" , ans);

  return 0;
}

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

#define ll long long

int main(void){

    int n,m=0;
    cin>>n>>m;
    int food[m];
    for(int i=0;i<m;i++){
        food[i]=0;
    }
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            food[a-1]++;
        }
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        if(food[i]==n)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::VecDeque;
fn main() {
    input! {
    N:usize,
    M:usize,
    AB:[[Usize1;2];M]
    }
    // 部屋iから繋がっている部屋のリスト
    let mut tonari: Vec<Vec<usize>> = vec![Vec::with_capacity(M); N];
    let mut ans: Vec<i32> = vec![-1; N];
    for ab in AB {
        tonari[ab[0]].push(ab[1]);
        tonari[ab[1]].push(ab[0]);
    }
    //    for i in 0..N {
    //        println!("{}={:?}", i, tonari[i]);
    //    }
    let mut nexts: VecDeque<usize> = VecDeque::new();
    nexts.push_front(0);
    while let Some(i) = nexts.pop_back() {
        //        println!("{}={:?}", i, tonari[i]);
        for &j in tonari[i].iter() {
            if ans[j] == -1 {
                ans[j] = i as i32;
                nexts.push_front(j);
            }
        }
    }
    println!("Yes");
    for j in 1..N {
        println!("{}", ans[j] + 1);
    }
}


Measured memory_bytes: 19748
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int k = sc.nextInt();
		for (int i = 0; i < arr.length - 1; i++) {
			if (arr[i] == 'a') {
				continue;
			}
			int x = 26 - (arr[i] - 'a');
			if (x <= k) {
				arr[i] = 'a';
				k -= x;
			}
		}
		arr[arr.length - 1] = (char)((arr[arr.length - 1] - 'a' + k) % 26 + 'a');
		System.out.println(arr);
	}
}


Measured memory_bytes: 27980
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	String S = scan.next();
	StringBuilder str = new StringBuilder(N);

	int stock = 0;
	for (int i = 0; i < N; i++) {
	    char c = S.charAt(i);
	    str.append(c);

	    switch(c) {
		case '(':
		    stock++;
		    break;
		case ')':
		    if(stock > 0) stock--;
		    else str.insert(0, '(');
		    break;
	    }
	}
	
	for (int i = 0; i < stock; i++) {
	    str.append(')');
	}
	    
	System.out.println(str.toString());
	scan.close();
    }
}


Measured memory_bytes: 21972
s = gets.chomp
s.gsub!(??, ?.)
t = gets.chomp
sl = s.length
tl = t.length
(0..(sl - tl)).reverse_each do |i|
  if t =~ Regexp.new(s[i...(i+tl)])
    ans = ""
    (0...i).each do |j|
      ans << (s[j] == ?. ? ?a : s[j])
    end
    ans << t
    (i+tl...sl).each do |j|
      ans << (s[j] == ?. ? ?a : s[j])
    end
    puts ans
    exit
  end
end
puts "UNRESTORABLE"

Measured memory_bytes: 1916
import math
import sys

def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())

prime_list = get_sieve_of_eratosthenes(10**5*2)
#print(prime_list)
for p in prime_list:
  if p>=n:
    print(p)
    sys.exit()

Measured memory_bytes: 64076
# -*- coding: utf-8 -*-
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out


n, k = map(int,input().split())

x = int(Base_10_to_n(n, k))
#print(x)
ans = 0
while x >= 1:
    x /= 10
    ans += 1
print(ans)


Measured memory_bytes: 3060
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            int Min = int.Parse(s[0]);
            int Max = int.Parse(s[1]);


            for (int i = 1; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');

                int L = int.Parse(s[0]);
                int R = int.Parse(s[1]);

                if (Min < L)
                    Min = L;
                if (Max > R)
                    Max = R;
            }

            if (Min > Max)
                ans = 0;
            else
                ans = Max - Min + 1;


            Console.WriteLine(ans.ToString());
        }
    }

}


Measured memory_bytes: 15304
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    char c;
    cin>>x>>c>>y;
    if(c=='+')
    {
        cout<<x+y<<endl;
    }
    else if(c=='-')
    {
        cout<<x-y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
long int a,b,i,c;
  scanf("%ld",&a);
b=pow(10,9)+7;    
  c=1;
  for(i=1;i<=a;++i)
  {
  c=i*c;
   c=c%b;
  }

printf("%ld",c);
  
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;cin>>a>>b;
  	string s;
  cin>>s;
  int e = 1;
  int seen=0;
  for(int i=0;i<a+b+1;i++){
  	if(i!=a && s[i]=='-'){e=0;break;}
    if(i==a && s[i]=='-')seen=1;
  }
  if(e==1 && seen==1)cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 10;
int n, a[maxN], ans[maxN];
vector<int> edge[maxN], v;
void dfs(int x, int par) {
	int tmp = 0, pos, flag = 0;
	if(v.empty() || a[x] > v.back()) {
		v.push_back(a[x]);
	}else {
		flag = 1;
		pos = lower_bound(v.begin(), v.end(), a[x]) - v.begin();
		tmp = v[pos];
		v[pos] = a[x];
	}
	ans[x] = v.size(); 
	for(auto to : edge[x]) {
		if(to != par) {
			dfs(to, x);
		}
	}
	if(!flag) {
		v.pop_back();
	}else {
		v[pos] = tmp;
	}
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		scanf("%d%d", &u, &v); 
		--u, --v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(0, -1);
	for(int i = 0; i < n; i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 30460
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;

template <typename T>
void readVec(vector<T>& v, int n)
{
	for(int i = 0; i < n; ++i)
			cin >> v[i];
}

int main()
{
	int n, m; cin >> m >> n;
	vector<int> v(n);
	readVec(v, n);
	long long int total = accumulate(begin(v), end(v), 0LL);
    if(total > m)
			cout << -1;
	else
			cout << m - total;
	return 0;
}


Measured memory_bytes: 3632
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000
applied = 1000
for i in range(-1,102):
    if i in p:
        pass
    else:
        dif = abs(x-i)
        if dif < ans:
            ans = dif
            applied = i
        else:
            pass
print(applied)

Measured memory_bytes: 9180
#include <vector>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
	const string tmp(1048576, '0');

	istream_iterator<double> first(cin), last;
	vector<double> v(first, last);
	printf("%f", *max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end()));
	
	for(int i = 0; i < 4; ++i){
		fputs(tmp.c_str(), stdout);
		fflush(stdout);
	}
	
	puts("");
}

Measured memory_bytes: 2064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<vector<long long int>>dp(N + 1, vector<long long int>(M + 1, 1));
	vector<vector<long long int>>sum(N + M + 1, vector<long long int>(N + 1, 1));
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
			sum[i + j][i] = dp[i][j];
		}
	}
	for (int i = 1; i <= N + M; i++) {
		for (int j = 1; j <= N; j++) {
			sum[i][j] += sum[i][j - 1];
			sum[i][j] %= MOD;
		}
	}
	vector<long long int>naname(N + 1);
	for (int i = 0; i <= N; i++)naname[i] = sum[i][i];
	for (int i = 1; i <= N; i++) {
		naname[i] += naname[i - 1];
		naname[i] %= MOD;
	}
	long long int ans = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			long long int by = 0;
			int r = j, b = i - j;
			if (b > M - 1)continue;
			if (b == 0) {
				ans++;
				continue;
			}
			int bb = b - 1;
			for (int k = 0; k <= r; k++) {
				by += sum[bb][min(k,bb)];
			}
			//for (int k = 0; k < min(r,bb); k++) {
			//	by += sum[bb][min(k,bb)];
			//}
			//for (int k = min(r, bb); k <= r; k++) {
			//	by += sum[bb][min(k, bb)];
			//}

			by %= MOD;
			long long int add = dp[i - j][M - 1 - i + j];
			ans += add * by;
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a (n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mx = 1;
  int cur = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] <= a[i - 1]) {
      cur++;
    } else {
      mx = max (mx, cur);
      cur = 1;
    }
  }
  cout << max (mx, cur) - 1 << '\n';
  return 0;
}



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

int main() {
	long long score[5050];
	long long dp[3050][3050];
	int n;
	cin>>n;
	for (int i = 1; i <= n; i++)
	{
		cin>>score[i];
	}
	for (int i = 1; i <= n; i++)
	{
		dp[i][i] = score[i];
	}
	for (int k = 2; k <= n; k++)
	{
		for (int i = 1; i <= n + 1 - k; i++)
		{
			dp[i][i + k - 1] = max(score[i] - dp[i + 1][i + k - 1], score[i + k - 1] - dp[i][i + k - 1 - 1]);
		}	
	}
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 72704
// AOJ ITP1_10_A Distance
// 2018.4.28 bal4u

#include <stdio.h>
#include <math.h>

int main()
{
	double x1, y1, x2, y2;
	
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	printf("%.8lf\n", hypot(x1-x2, y1-y2));
	return 0;
}



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

int main(){
  string S; cin >> S;
  while(1){
    S.pop_back();
    if(S.size()%2==0){
      if(S.substr(0,S.size()/2)==S.substr(S.size()/2)) break;
    }
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
int main()
{
	ll i,n,sum=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		if((i%3)&&(i%5))sum+=i;
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
long long a,b,t,w,ans;
inline long long dis(const long long&l,const long long&r)
{
	if(l>r)
		return 0ll;
	else
		return r-l+1;
}
int main(void)
{
	scanf("%lld%lld",&a,&b);
	if(a>=b)
		return 0*puts("1");
	for(int i=63;~i;i--)
		if((b&(1ll<<i))&&!(a&(1ll<<i)))
		{
			t=(1ll<<i);
			a&=t-1;
			b&=(t<<1)-1;
			w=t;
			for(int j=i-1;~j;j--)
				if(b&(1ll<<j))
				{
					w|=(1ll<<j+1)-1;
					break;
				}
			break;
		}
	ans=dis(a,w)+dis(t+a+1,t<<1)-dis(t+a,w);
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string a[8];

void dfs(int x,int y){

  int i;

  a[y][x]='0';
  for(i=-3;i<=3;i++) if(x+i>=0 && x+i<8) if(a[y][x+i]=='1') dfs(x+i,y);
  for(i=-3;i<=3;i++) if(y+i>=0 && y+i<8) if(a[y+i][x]=='1') dfs(x,y+i);

}

int main(){

  int x,y,n,i;

  cin>>n;

  for(int j=0;j<n;j++){
    for(i=0;i<8;i++) cin>>a[i];
    cin>>x>>y;

    dfs(x-1,y-1);
    cout<<"Data "<<j+1<<":"<<endl;
    for(i=0;i<8;i++) cout<<a[i]<<endl;
  }

    return 0;

}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)
int mpower(int x, int y, int p){int res = 1;x = x % p;while(y > 0){if(y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1) res = res*x;y = y>>1;x = x*x;}return res;}
bool isPrime(int n){if (n <= 1)  return false;if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false;int p=sqrt(n);for(int i=5;i<=p;i=i+6)if (n%i == 0 || n%(i+2) == 0)return false;return true;}

bool q(pair<int,int> a, pair<int,int> b)
{
    return a.ss > b.ss;
    
}

int32_t main()
{
	fast();

	/*test()
	{
	}*/
	
	int n ;
	cin >> n;
	
    vector<vector<int> > v(n,vector<int> (3,0));
    vector<vector<int> > dp(n,vector<int> (3,0));
    
    f(i,n)
    {
        cin >> v[i][0];
        cin >> v[i][1];
        cin >> v[i][2];
    }
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    
    
    f1(i,n-1)
    {
        dp[i][0] = v[i][0] +  max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i][1] +  max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = v[i][2] +  max(dp[i-1][1],dp[i-1][0]);
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    



	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a[4];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    sort(a,a+5);
    cout<<a[4]<<" "<<a[3]<<" "<<a[2]<<" "<<a[1]<<" "<<a[0]<<endl;
    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int INF = 1e9;
inline int read(){
	int X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

int dat[100005];
int dp[100005];
int main() 
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>dat[i];
	}
	for(int i=1;i<=100000;i++)
	{
		dp[i]=INF;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+abs(dat[i+1]-dat[i]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(dat[i+2]-dat[i]));
	}
	cout<<dp[n];
    return 0;
}

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

int dp[105][10005];

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i,N) cin >> v[i] >> w[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7044
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int>s, t;
	int n, q;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		s.push_back(a);
	}
	cin >> q;
	for (int i = 0; i < q; i++){
		int a; cin >> a;
		t.push_back(a);
	}
	int num = 0;
	for (int i = 0; i < q; i++){
		if (find(s.begin(), s.end(), t[i]) != s.end()) {
			num++;
		}
	}
	cout << num << endl;
	char c; cin >> c;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s1,s2,s3;
  cin>>s1>>s2>>s3;
  if(s1!=s2||s2!=s3){
cout<<"Yes"<<endl;
  }
else{
  cout<<"No"<<endl;
}
return 0;
}

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

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

    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
class Map{
    public:
    vector<vector<P>> map;
    P sm;
    int k;
    Map(int K){
        k=K;
        map.resize(k+5,vector<P>(k+5,{0,0}));
        sm={0,0};
    }
    void add(int x,int y,int value){
        //(0,0)を白にする場合
        map[0][0].first+=value;map[0][x+1].first-=value;
        map[y+1][0].first-=value;map[y+1][x+1].first+=value;
        map[y+1][x+1].first+=value;map[y+1][k].first-=value;
        //(0,0)をくろにする場合
        map[0][0].second-=value;map[0][x+1].second+=value;
        map[y+1][0].second+=value;map[y+1][x+1].second-=value;
        map[y+1][x+1].second-=value;map[y+1][k].second+=value;
    }
    void RES(){
        rep(i,k+1){
            rep1(j,k){
                map[i][j].first+=map[i][j-1].first;
                map[i][j].second+=map[i][j-1].second;
            }
        }
        rep(j,k+1){
            rep1(i,k){
                map[i][j].first+=map[i-1][j].first;
                map[i][j].second+=map[i-1][j].second;
            }
        }
        P res={-inf,-inf};
        rep(i,k){
            rep(j,k){
                res.first=max(res.first,map[i][j].first);
                res.second=max(res.second,map[i][j].second);
            }
        }
        cout<<max(res.first+sm.first,res.second+sm.second)<<"\n";
    }
    void output(){
        rep(i,k){
            rep(j,k){
                cout<<map[k-1-i][j].first<<" ";
            }
            cout<<endl;
        }
    }
};
signed main(){
  lint n,k;cin>>n>>k;
  Map map(k);
  rep(i,n){
      int x,y;cin>>x>>y;
      char c;cin>>c;
      lint hoge=x/k+y/k;
      x%=k;y%=k;
      if((c=='W'&&hoge%2==0)||(hoge%2==1&&c=='B')){
          map.add(x,y,1);
          map.sm.second+=1;
      }
      else{
          map.add(x,y,-1);
          map.sm.first+=1;
      }
  }
  map.RES();
  //map.output();
  return 0;
}

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

int main (void) {
	cin.tie(0);
	cin.sync_with_stdio(false);
	int year, month, day;
	char tmp;
	cin >> year >> tmp >> month >> tmp >> day;
	if (year <= 2019 && month <= 4 && day <= 30)
		cout << "Heisei\n";
	else
		cout << "TBD\n";
	return 0;
}

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

long long a,b,c,d,ans,e;

int gcd(int a,int b){
    while(1){
        if(a<b){swap(a,b);}
        if(!b){break;}
        a%=b;
    }
    return a;
}

int main(){
    cin>>a>>b>>c>>d;
    a-=1;
    ans=b-a;
    ans-=b/c-a/c;
    ans-=b/d-a/d;
    e=c/gcd(c,d)*d;
    ans+=b/e-a/e;
    cout<<ans<<endl;
}

Measured memory_bytes: 256