akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

typedef pair<double,double> pos;
const double r = 1;
const double eps = 0.0000000001;
int count(vector<pos> ps,double x,double y,int ban1,int ban2){
	int c=0;//2;
	for(int i=0;i<ps.size();i++){
		if(//i!=ban1&&i!=ban2&&
				pow(ps[i].first-x,2)+pow(ps[i].second-y,2)<=pow(1.0+eps,2)){
			c++;
		}
	}
	return c;
}

bool range(pos p1,pos p2,double r){
	return pow(p1.first-p2.first,2)+pow(p1.second-p2.second,2) <= r*r;
}

double len(pos p){
	return sqrt(pow(p.first,2)+pow(p.second,2));
}

double len2(pos p){
	return (pow(p.first,2)+pow(p.second,2));
}

vector<pos> point2(pos p1,pos p2){
	pos m = make_pair((p1.first+p2.first)/2,(p1.second+p2.second)/2);
	pos vec = make_pair(p1.first-p2.first,p1.second-p2.second);
	pos q = m;//make_pair(p2.first+vec.first/2,p2.second+vec.second/2);
	double l = sqrt(1-pow(len(vec)/2.0,2));
	double ll = len(vec);
	pos vec2 = make_pair(-vec.second,vec.first);
	vec2.first=vec2.first/ll*l;
	vec2.second = vec2.second/ll*l;
	vector<pos> ret;
	ret.push_back(make_pair(q.first+vec2.first,q.second+vec2.second));
	ret.push_back(make_pair(q.first-vec2.first,q.second-vec2.second));
	return ret;
}

int solve(vector<pos> ps){
	int mx=1;
	for(int i=0;i<ps.size()-1;i++)
		for(int k=i+1;k<ps.size();k++){
			if(range(ps[i],ps[k],2)){
				//cerr << "*****" << i << " " << k << endl;
				vector<pos> vp = point2(ps[i],ps[k]);
				mx = max(mx,count(ps,vp[0].first,vp[0].second,i,k));
				mx = max(mx,count(ps,vp[1].first,vp[1].second,i,k));
			}
		}
	return mx;
}

int main(){
	//cerr << point2(make_pair(0,0),make_pair(1,1))[1].first << endl;
	while(true){
		int n;
		vector<pos> v;
		cin >> n;
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			double x,y;
			cin >> x >> y;
			v.push_back(make_pair(x,y));
		}
		cout << solve(v) << endl;
	}
}

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

int main() {
    int N, M, X, tmp;
    int ansl = 0;
    int ansr = 0;
    cin >> N >> M >> X;
    for (int m=0; m<M; ++m) {
        cin >> tmp;
        if (tmp < X) {
            ++ansl;
        }
        else {
            ++ansr;
        }
    }
    cout << min({ansl, ansr}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define SIZE 1024
#define UD -1
int memo[SIZE][SIZE];
char x[1024];
char y[1024];

void init(){
	int i, j;
	for( i = 0; i < SIZE; i++ ){
		for( j = 0; j < SIZE; j++ ){
			memo[i][j] = UD;
		}
	}
	return;
}

int get(int xi, int yi){
	int i, j, temp;
	if( memo[xi][yi] != UD ){ return memo[xi][yi]; }
	if( x[xi] == '\0' || y[yi] == '\0' ){ return 0; }
	temp = get(xi+1, yi);
	if( temp > memo[xi][yi] ){ memo[xi][yi] = temp; }
	temp = get(xi, yi+1);
	if( temp > memo[xi][yi] ){ memo[xi][yi] = temp; }
	if( x[xi]==y[yi] ){ temp = get(xi+1, yi+1) + 1; }
	if( temp > memo[xi][yi] ){ memo[xi][yi] = temp; }
	return memo[xi][yi];
}

int run(){
	init();
	scanf("%s", x);
	scanf("%s", y);
	return get(0, 0);
}

int main(){
	int q, i;
	scanf("%d", &q);
	for( i = 0; i < q; i++ ){ printf("%d\n", run()); }
	return 0;
}

Measured memory_bytes: 4820
#include<stdio.h>
int main(){
        int n,i,j,x=0,k;
        scanf("%d",&n);
        for(i=0;i<n;i++){
                int a[5]={0};
                scanf("%d %d %d",&a[0],&a[1],&a[2]);
                for(k=0;k<10;k++){
                for(j=0;j<3;j++){
                        if(a[j]<a[j+1]){
                                x=a[j];
                                a[j]=a[j+1];
                                a[j+1]=x;
                                x=0;
                        }
                }
                }
                if(a[1]*a[1]+a[2]*a[2]==a[0]*a[0])printf("YES\n");
                else printf("NO\n");
        }
        return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll n;
cin>>n;
ll a[n];
  ll b[n];
REP(i,n){
cin>>a[i];
  b[i]=a[i]-i;
}
sort(b,b+n);
  ll ans=0;
  if(n%2==1){
    ll mid=b[n/2];
  REP(i,n){
  ans+=abs(b[i]-mid);
  }
  }
  else{
    ll ans1=0;
    ll ans2=0;
  ll mid1=b[n/2];
    ll mid2=b[(n/2)-1];
    REP(i,n){
  ans1+=abs(b[i]-mid1);
        ans2+=abs(b[i]-mid2);
  }
    if(ans1<ans2)
      ans=ans1;
    else
      ans=ans2;
  }
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import static java.lang.Integer.parseInt;

/**
 * ACB068
 * C - Cat Snuke and a Voyage
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, M;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		M = parseInt(line.substring(line.indexOf(' ') + 1));

		Map<Integer, Set<Integer>> G = new HashMap<>();

		G.put(1, new HashSet<>());
		G.put(N, new HashSet<>());

		for (int i = 0; i < M; i++) {
			line = br.readLine();
			int a, b;
			a = parseInt(line.substring(0, line.indexOf(' ')));
			b = parseInt(line.substring(line.indexOf(' ') + 1));
			G.putIfAbsent(a, new HashSet<>());
			G.putIfAbsent(b, new HashSet<>());
			G.get(a).add(b);
			G.get(b).add(a);
		}

		for (int i : G.get(1)) {
			if (G.get(N).contains(i)) {
				System.out.println("POSSIBLE");
				return;
			}
		}

		System.out.println("IMPOSSIBLE");
	}
}

Measured memory_bytes: 121124
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    int N;
    cin >> N;
    ll a[N];
    int k = 0;
    REP(i, 0, N)
    {
        cin >> a[i];
        if(a[i]%2==1){
            k++;
        }
    }
    if(k%2==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
import sys

N = int(input())
S = list(str(input()) for _ in range(N))

mydict = {}

for i in range(N):
    mydict[S[i]] = 0

for i in range(N):
    mydict[S[i]] += 1

cnt = 0
for key in mydict.keys():
    cnt += 1
print(cnt)


Measured memory_bytes: 38388
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL INF = 1LL << 60;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;

int main() {
	int N;
	string S;
	cin >> N >> S;
	int l = 0, cnt = 0;
	rep(i, N) {
		if (S[i] == '(') cnt++;
		else if (cnt == 0) l++;
		else cnt--;
	}
	cout << string(l, '(') << S << string(cnt, ')') << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

//ITPC dice3

class dice{
public:
    int top, bottom, right, left, front, back;
    void North();
    void East();
    void South();
    void West();
    void clockRotate();
};
void dice:: North(){
    int tmp = top;
    top = front;
    front = bottom;
    bottom = back;
    back = tmp;
}
void dice:: East(){
    int tmp = top;
    top = left;
    left = bottom;
    bottom = right;
    right = tmp;
}
void dice:: South(){
    int tmp = top;
    top = back;
    back = bottom;
    bottom = front;
    front = tmp;
}
void dice:: West(){
    int tmp = top;
    top = right;
    right = bottom;
    bottom = left;
    left = tmp;
}
void dice:: clockRotate(){
    int tmp = front;
    front = right;
    right = back;
    back = left;
    left = tmp;
}

signed main(){
    dice d1, d2;
    cin >> d1.top >> d1.front >> d1.right >> d1.left >> d1.back >> d1.bottom;
    cin >> d2.top >> d2.front >> d2.right >> d2.left >> d2.back >> d2.bottom;
    string s = "NRRRRNRRRRNRRRRNRRRRERRRRERRRRERRRR";
    rep(i, 0, s.size()){
        if(d1.top == d2.top && d1.front == d2.front && d1.right == d2.right && d1.back == d2.back && d1.left == d2.left && d1.bottom == d2.bottom){
            cout << "Yes" << endl;
            return 0;
        }
        if(s[i] == 'N') d1.North();
        else if(s[i] == 'E') d1.East();
        else if(s[i] == 'S') d1.South();
        else if(s[i] == 'W') d1.West();
        else if(s[i] == 'R') d1.clockRotate();
    }
    cout << "No" << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool ok(string S) {
  int N = S.size();
  if(N % 2 == 1) return false;
  int i = N / 2;
  cerr << S.substr(0, i) << " " << S.substr(i, i) << endl;
  return (S.substr(0, i) == S.substr(i, i));
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
  string S;
  cin >> S;
  for(int i = S.size() - 1; i >= 0; i--) {
    string T = S.substr(0, i);
    if(ok(T)) {
      cout << i << endl;
      return 0;
    }
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[n-1-i]>>b[n-1-i];
    rep(i,n) {
        ll tmp=b[i]-(a[i]+ans)%b[i];
        if(tmp==b[i])tmp=0;
        ans+=tmp;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    ll s;
    cin >> n >> k >> s;
    ll ans_num;
    ll rep_num;
    if ( s == 1e9 ) {
        rep_num = 1LL;
    }
    else {
        rep_num = s + 1LL;
    }
    int cnt = 0;
    rep(i, n) {
        if ( i != 0 ) cout << " ";
        if ( cnt == k ) cout << rep_num;
        else {
            cout << s;
            ++cnt;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
import sys

sys.setrecursionlimit(200000)


def f_dfs(i: int) -> None:
    global f_edges, counter
    visited[i] = True
    for edge in f_edges[i]:
        if visited[edge]:
            continue
        f_dfs(edge)
    finish_order[i] = (counter, i)
    counter += 1


def b_dfs(i, group):
    global b_edges, groups
    visited[i] = True
    groups[i] = group
    for edge in b_edges[i]:
        if visited[edge]:
            continue
        b_dfs(edge, group)


if __name__ == "__main__":
    n, m = map(int, input().split())

    f_edges = [set() for _ in range(n)]  # type: ignore
    b_edges = [set() for _ in range(n)]  # type: ignore

    for _ in range(m):
        s, t = map(lambda x: int(x), input().split())
        f_edges[s].add(t)
        b_edges[t].add(s)

    visited = [False] * n
    finish_order = [(0, 0)] * n
    counter = 0

    for i in range(n):
        if not visited[i]:
            f_dfs(i)

    visited = [False] * n
    groups = [0] * n
    group = 0

    for d, i in sorted(finish_order, reverse=True):  # type: ignore
        if not visited[i]:
            b_dfs(i, group)
            group += 1

    q = int(input())
    for _ in range(q):
        u, v = map(lambda x: int(x), input().split())
        print(int(groups[u] == groups[v]))



Measured memory_bytes: 21832
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

char s[55];
char ss[55] = "FESTIVAL";
int main()
{
    int L = 0;
    scanf(" %s",s);
    int len = strlen(s);
    int len2 = strlen(ss);
    //printf("%d\n",len2);
    L = len - len2 - 1;
    for(int i=0;i<=L;i++)
        printf("%c",s[i]);
    printf("\n");
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<double> p(N);
	for(int i=0; i<N; i++) cin >> p[i];

	vector<vector<double>> dp(N,vector<double>(N+1));
	dp[0][0] = 1-p[0];
	dp[0][1] = p[0];
	for(int i=1; i<N; i++){
		for(int j=0; j<N; j++){
			dp[i][j]   += dp[i-1][j] * (1-p[i]);
			dp[i][j+1] += dp[i-1][j] * p[i];
		}
	}

	double ans = 0;
	for(int i=N/2+1; i<=N; i++) ans += dp[N-1][i];
	printf("%.9lf\n",ans);
	return 0;
}



Measured memory_bytes: 73708
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

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

int N;
char s[100001];

bool check(int n1, int n2, int n3, string &tmp){
  
  if(s[n1]=='o'){
    if(tmp[n1]=='S' && tmp[n2]==tmp[n3]) return true;
    if(tmp[n1]=='W' && tmp[n2]!=tmp[n3]) return true;
  }
  if(s[n1]=='x'){
    if(tmp[n1]=='S' && tmp[n2]!=tmp[n3]) return true;
    if(tmp[n1]=='W' && tmp[n2]==tmp[n3]) return true;
  }
  
  return false;
}

bool order(char a, char b, string& tmp){
  
  tmp[0]=a;
  tmp[1]=b;
  
  for(int i=1; i<N-1; i++){
    if(s[i]=='o'){
      if(tmp[i]=='S') tmp[i+1]=tmp[i-1];
      if(tmp[i]=='W'){
	if(tmp[i-1]=='S') tmp[i+1]='W';
	if(tmp[i-1]=='W') tmp[i+1]='S';
      }
    }
    if(s[i]=='x'){
      if(tmp[i]=='S'){
	if(tmp[i-1]=='S') tmp[i+1]='W';
	if(tmp[i-1]=='W') tmp[i+1]='S';
      }
      if(tmp[i]=='W') tmp[i+1]=tmp[i-1];
    }
  }
  return (check(N-1,N-2,0,tmp) && check(0,1,N-1,tmp));
}

int main(){

  ios_base::sync_with_stdio(false);
  cin>>N>>s;
  string t(N+1,' ');
  
  if(order('S','S', t)){
    cout<<t<<endl;
  }
  else if(order('S','W', t)){
    cout<<t<<endl;
  }
  else if(order('W','W', t)){
    cout<<t<<endl;
  }
  else if(order('W','S', t)){
    cout<<t<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int nodeNum = 210;
int graph[210][210] = {};

vector<bool> isused;

vector<int> getPath_rev(int now, int t)
{
	if(now == t){
		vector<int> res;
		res.push_back(t);
		return res;
	}
	for(int i = 0; i < nodeNum; i++){
		if(graph[now][i] <= 0 || isused[i]) continue;
		isused[i] = true;
		vector<int> res = getPath_rev(i, t);
		if(res.size() > 0){
			res.push_back(now);
			return res;
		}
	}
	return vector<int>();
}

int getMin(vector<int> path_rev)
{
	int res = mod;
	for(int i = path_rev.size() - 1; i > 0; i--){
		int from = path_rev[i];
		int to = path_rev[i - 1];
		res = min(res, graph[from][to]);
	}
	return res;
}

void updateGraph(vector<int> path_rev, int cost)
{
	for(int i = path_rev.size() - 1; i > 0; i--){
		int from = path_rev[i];
		int to = path_rev[i - 1];
		graph[from][to] -= cost;
		graph[to][from] += cost;
	}
}

int fordFulkerson(int s, int t)
{
	int ans = 0;
	isused = vector<bool>(nodeNum, false);
	isused[s] = true;
	vector<int> path = getPath_rev(s, t);
	while(path.size() > 0){
		int cost = getMin(path);
		updateGraph(path, cost);
		ans += cost;
		isused = vector<bool>(nodeNum, false);
		isused[s] = true;
		path = getPath_rev(s, t);
	}
	return ans;
}

int main()
{
	int h, w;
	cin >> h >> w;
	int sx, sy, tx, ty;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			char a;
			cin >> a;
			if(a == '.') continue;
			if(a == 'S'){
				sx = i;
				sy = j;
				graph[0][i] = mod;
				graph[0][100 + j] = mod;
			}
			if(a == 'T'){
				tx = i;
				ty = j;
				graph[i][205] = mod;
				graph[100 + j][205] = mod;
			}
			graph[i][100 + j] = 1;
			graph[100 + j][i] = 1;
		}
	}
	if(sx == tx || sy == ty) cout << -1 << endl;
	else cout << fordFulkerson(0, 205) << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(){
    int N, M, atr, btr;  cin >> N;
    M = N/2;
    vector<ll> v(N), a(M+1),b(M);
    for(int i=0; i<N; i++)    cin >> v[i];
    a[0] = 0;
    b[0] = 0;
    for(int i=0; i<N; i++){
        if(i == 0)  a[M] = v[N-1] - v[0];
        else if(i == N-1)    break;
        else if(i%2 == 1)    a[i/2+1] = a[i/2] + v[i] - v[i-1];
        else if(i%2 == 0)   b[i/2] = b[i/2-1] + v[i] - v[i-1];
    }
    btr = -(v[N-1] - v[N-2] - v[0] + b[M-1])/2;
    atr = v[0] - btr;
    for(int i=0; i<M+1; i++){
        if(i < M){
            cout << 2*(atr + a[i]) << " " << 2*(btr + b[i]) << " ";
        }else   cout << 2*(atr + a[i]);
    }
}

Measured memory_bytes: 4812
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100
int a[MAXN+5],b[MAXN+5];
int n,ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]=a[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=n-1;i>=1;i--)
		b[i]=b[i]+b[i+1];
	for(int i=1;i<=n;i++)
		ans=max(ans,a[i]+b[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

const int N = 2010;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

int head[N], nxt[N * N], to[N * N], cnt;
priority_queue<int> q;
bool g[N][N], vis[N];
int n, a[N], ind[N];

void add(int u, int v)
{
	nxt[++cnt] = head[u];
	head[u] = cnt;
	to[cnt] = v;
}

void dfs(int u)
{
	vis[u] = true;
	for (int v = 1; v <= n; ++v)
	{
		if (vis[v] || !g[u][v]) continue;
		++ind[v];
		add(u, v);
		dfs(v);
	}
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	
	sort(a + 1, a + n + 1);
	
	for (int i = 1; i < n; ++i)
	{
		for (int j = i + 1; j <= n; ++j)
		{
			if (gcd(a[i], a[j]) != 1)
			{
				g[i][j] = g[j][i] = true;
			}
		}
	}
	
	for (int i = 1; i <= n; ++i) dfs(i);
	
	for (int i = 1; i <= n; ++i) if (ind[i] == 0) q.push(i);
	
	while (!q.empty())
	{
		int u = q.top();
		q.pop();
		printf("%d ", a[u]);
		for (int i = head[u]; i; i = nxt[i])
		{
			int v = to[i];
			if (--ind[v] == 0) q.push(v);
		}
	}
	
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MAXL = 100;
string S;
int L, N, U, V;
bool changed[MAXL];

int main() {
    cin >> S >> N;
    L = sz(S);
    repp(i, 1, L - 1) {
        if(S[i] != S[i - 1] || changed[i - 1]) continue;
        changed[i] = true;
        ++U;
    }
    if(N == 1) {
        cout << U << "\n";
        return 0;
    }
    if(changed[L - 1] || S[L - 1] != S[0]) {
        cout << (ll)N * U << "\n";
    } else {
        memset(changed, 0, sizeof(changed));
        changed[0] = true;
        ++V;
        repp(i, 1, L - 1) {
            if(S[i] != S[i - 1] || changed[i - 1]) continue;
            changed[i] = true;
            ++V;
        }
        if(changed[L - 1]) {
            if(N % 2 == 1) cout << (ll)(U + V) * (N / 2) + U << "\n";
            else cout << (ll)(U + V) * (N / 2) << "\n";
        } else {
            cout << U + (ll)V * (N - 1) << "\n";
        }
    }
}

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

int main() {
	long long a, b, c, d, N , M;
	cin >> a >> b >> c >> d ;
	N = a * c;
	M = b * c;
	if (N < M) {
		N = M;
	}
	M = a * d;
	if (N < M) {
		N = M;
	}
	M = b * d;
	if (N < M) {
		N = M;
	}
	cout << N << endl;
}


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

const int MAX_N = 110000;
int dp[MAX_N];

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

    for (int i=0;i<MAX_N;++i) dp[i] = N;
    dp[0] = 0;
    
    for (int n=0;n<N;++n){
        for (int pow6=1;n+pow6<=N;pow6*=6) dp[n+pow6] = min(dp[n+pow6], dp[n]+1);
        for (int pow9=1;n+pow9<=N;pow9*=9) dp[n+pow9] = min(dp[n+pow9], dp[n]+1);
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
N, M, X = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(N)]

ans = 12000000

for i in range(2 ** N):
    c = 0
    und = [0] * M

    for j in range(0, N):
        if (i >> j) & 1:
            c += B[j][0]
            for k in range(M):
                und[k] += B[j][k+1]

    for l in range(M):
        if und[l] < X:
            break
    else:
        ans = min(ans, c)
        continue

print(-1) if ans == 12000000 else print(ans)


Measured memory_bytes: 9244
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, P = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for a, b, c in ABC:
    graph[a - 1].append((b - 1, P - c))


def bellman_ford(graph, from_v, to_v):
    """
    到達できないなら INF、負閉路があったら -INF
    :param list of (list of (int, int)) graph: (to, cap) の隣接リスト
    :param int from_v:
    :param int to_v:
    :rtype: int
    """

    def reachable(graph, from_v):
        """
        graph 上で from_v から到達できるかどうかのリスト
        :param graph:
        :param from_v:
        """
        ret = [False] * len(graph)
        ret[from_v] = True
        stack = [from_v]
        while stack:
            v = stack.pop()
            for u, _ in graph[v]:
                if not ret[u]:
                    ret[u] = True
                    stack.append(u)
        return ret

    # from_v から到達でき、かつ to_v へ到達できる頂点のみ考える
    # これら以外には負閉路があっても関係ない
    vertices = []
    revs = [[] for _ in range(len(graph))]
    for v, ud in enumerate(graph):
        for u, d in ud:
            revs[u].append((v, d))
    for v, (r1, r2) in enumerate(zip(reachable(graph, from_v), reachable(revs, to_v))):
        if r1 & r2:
            vertices.append(v)

    dist = [float('inf')] * len(graph)
    dist[from_v] = 0
    updated = True
    for _ in range(len(graph) + 1):
        updated = False
        for v in vertices:
            for u, d in graph[v]:
                if dist[v] + d < dist[u]:
                    dist[u] = dist[v] + d
                    updated = True
        if not updated:
            break
    return -float('inf') if updated else dist[to_v]


ans = -bellman_ford(graph, 0, N - 1)
if ans == INF or ans == -INF:
    print(-1)
else:
    print(max(0, ans))


Measured memory_bytes: 48604
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
using namespace std;
int n , p1 , p2 , p3 ;
vector <int> x[4] ;
int dp[100003][5] ;
int SAAD ( int idx , int idx2 ) {
	if ( idx == n ) return 0 ;
	if ( dp[idx][idx2] != -1 ) return dp[idx][idx2] ;
	int res = 0 ;
	for ( int i = 0 ; i <= 3 ; i++ ) {
		if ( i == idx2 || i == 0 ) continue ;
		res = max(res,SAAD(idx+1,i)+x[i][idx]) ;
	}
	return dp[idx][idx2] = res ;
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n ;
	for (int i=0;i<5;i++) memset(dp,-1,sizeof(dp));
	for ( int i = 0 ; i < n ; i++  ) {
		cin >> p1 >> p2 >> p3 ;
		x[1].push_back(p1);x[2].push_back(p2);x[3].push_back(p3);
	}
	cout << SAAD(0,0) ;
	return 0;
}

Measured memory_bytes: 11500
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int k, x;
    cin >> k >> x;
    cout << ((k * 500 >= x) ? "Yes\n" : "No\n");
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll n;cin>>n;
  rep(i,1,10){
    rep(j,i,10){
      if(n==i*j){
        out("Yes");
        return 0;
      }
    }
  }
  out("No");


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e4;
const int bias=1e4;
bool dp[2][MAXN];
char s[10000];
vector<int> h,v;

int main()
{
    while(scanf("%s",s+1)!=EOF)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        memset(dp,false,sizeof(dp));
        int len=strlen(s+1);
        h.clear();v.clear();
        int first=0;
        int p=1;
        while(p<=len&&s[p]=='F') {first++;p++;}
        dp[0][first+bias]=true;
        p++;
        bool horizontal=false;
        int tmp=0;
        for(;p<=len;p++)
        {
            tmp=0;
            while(s[p]=='F'&&p<=len)
            {
                tmp++;
                p++;
            }
            if(horizontal&&tmp) h.push_back(tmp);
            else if(tmp) v.push_back(tmp);
            horizontal=!horizontal;
        }
        int now=0;
        for(auto i:h)
        {
            now^=1;
            for(int j=0;j<=MAXN;j++)
            {
                if(dp[now^1][j])
                {
                    dp[now][j+i]=true;
                    dp[now][j-i]=true;
                }
            }
            for(int j=0;j<=MAXN;j++)
                dp[now^1][j]=false;
        }
        if(!dp[now][bias+x])
        {
            cout<<"No"<<endl;
        }else
        {
            memset(dp,false,sizeof(dp));
            dp[0][0+bias]=true;
            int now=0;
            for(auto i:v)
            {
                now^=1;
                for(int j=0;j<=MAXN;j++)
                {
                    if(dp[now^1][j])
                    {
                        dp[now][j+i]=true;
                        dp[now][j-i]=true;
                    }
                }
                for(int j=0;j<=MAXN;j++)
                    dp[now^1][j]=false;
            }
            if(!dp[now][y+bias])
                cout<<"No"<<endl;
            else cout<<"Yes"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
def create_input(N):
    honest_comments = []
    for _ in range(N):
        A = int(input())
        comment = []
        for _ in range(A):
            x, y = map(int, input().split())
            x = x - 1
            comment.append((x, y))
        honest_comments.append((A, comment))

    return honest_comments


def resolve():
    N = int(input())
    honest_comments = create_input(N)

    ans = 0
    for n in range(2**N):
        ss = [0] * N
        for i in range(N):
            if n & (1 << i) != 0:
                ss[i] = 1
        c = ss.count(1)
        if c <= ans:
            continue
        ok = True
        for i in range(N):
            s = ss[i]
            A, comment = honest_comments[i]
            for x, y in comment:
                if s == 1 and ss[x] != y:
                    ok = False
                    break
        if ok:
            ans = max(ans, c)
    print(ans)


resolve()

Measured memory_bytes: 3064
n = int(input())
m = int(input())
K = [[float('inf') for i in range(n)] for j in range(n)]
#print(K)
for i in range(m):
    a,b,c,d = map(int,input().split(','))
    #print(a,b,c,d)
    K[a-1][b-1] = c
    K[b-1][a-1] = d
for k in range(n):
    for i in range(n):
        for j in range(n):
            if K[i][j] > K[i][k]+K[k][j]:
                K[i][j] = K[i][k]+K[k][j]
    #print(K)
s,g,V,P = map(int,input().split(','))
print(V-P-K[s-1][g-1]-K[g-1][s-1])



Measured memory_bytes: 5620
import sys
input=sys.stdin.readline

def main():
    r,c,k=map(int,input().split())
    dp=[[[0 for jj in range(c+1)] for ii in range(r+1)] for kk in range(4)]

    g=[[0 for j in range(c)] for i in range(r)]
    for i in range(k):
        rr,cc,v=map(int,input().split())
        rr-=1
        cc-=1
        g[rr][cc]=v
    for i in range(1,r+1):
        for j in range(1,c+1):
            for k in range(4):
                dp[k][i][j]=max(dp[k][i][j],dp[k][i][j-1])#,dp[i][j-1][k])
                dp[0][i][j]=max(dp[0][i][j],dp[k][i-1][j])
                if g[i-1][j-1]>0:
                    if k>0:
                        if dp[k][i][j]<dp[k-1][i][j-1]+g[i-1][j-1]:
                            dp[k][i][j]=dp[k-1][i][j-1]+g[i-1][j-1]
                    if dp[1][i][j]<dp[k][i-1][j]+g[i-1][j-1]:
                        dp[1][i][j]=dp[k][i-1][j]+g[i-1][j-1]
    print(max(dp[0][r][c],dp[1][r][c],dp[2][r][c],dp[3][r][c]))
if __name__=='__main__':
    main()



Measured memory_bytes: 468116
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<double>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void input(BigNum* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atof(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atof(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Str s;
	AtCoder::input(&s);

	const std::string x = s[0];
	std::string str = "";

	if ("a" == x) { 
		str = "b"; 
	} else if ("b" == x) {
		str = "c";
	} else if ("c" == x) {
		str = "d";
	} else if ("d" == x) {
		str = "e";
	} else if ("e" == x) {
		str = "f";
	} else if ("f" == x) {
		str = "g";
	} else if ("g" == x) {
		str = "h";
	} else if ("h" == x) {
		str = "i";
	} else if ("i" == x) {
		str = "j";
	} else if ("j" == x) {
		str = "k";
	} else if ("k" == x) {
		str = "l";
	} else if ("l" == x) {
		str = "m";
	} else if ("m" == x) {
		str = "n";
	} else if ("n" == x) {
		str = "o";
	} else if ("o" == x) {
		str = "p";
	} else if ("p" == x) {
		str = "q";
	} else if ("q" == x) {
		str = "r";
	} else if ("r" == x) {
		str = "s";
	} else if ("s" == x) {
		str = "t";
	} else if ("t" == x) {
		str = "u";
	} else if ("u" == x) {
		str = "v";
	} else if ("v" == x) {
		str = "w";
	} else if ("w" == x) {
		str = "x";
	} else if ("x" == x) {
		str = "y";
	} else if ("y" == x) {
		str = "z";
	}

	printf("%s", str.c_str());

	return 0;
}

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

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

int pos[200000 + 10][26];
string s;

int main2() {
  cin >> s;
  int N = (int)s.size();
  memset(pos, -1, sizeof(pos));

  REP(i, N) {
    int k = s[i] - 'a';
    pos[i][k] = i;
    for (int j = i-1; j >= 0 && s[j] != s[i]; j--)
      pos[j][k] = i;
  }
  // REP(i, N) {
    // pv(pos[i], pos[i]+26);
  // }


  int ap[26] = {};
  int nz = 0;
  vector<int> rs;
  for (int i = N-1; i >= 0; i--) {
    int k = s[i] - 'a';
    if (ap[k] == 0) nz++;
    ap[k]++;
    if (nz == 26) {
      nz = 0;
      rs.push_back(i);
      REP(j, 26) {
        ap[j] = 0;
      }
    }
  }
  reverse(ALL(rs));
  // cout << "rs=";pv(ALL(rs));
  int len = (int)rs.size() + 1;
  string ans = "";
  REP(i, len) ans += '?';
  REP(iii, len) {
    REP(c, 26) {
      ans[iii] = (char)('a' + c);
      // cout << ans << endl;
      int p = 0;
      bool possible = true;
      REP(i, ans.size()) {
        if (ans[i] == '?') {
          int have = (int)(rs.end() - lower_bound(ALL(rs), p));
          int need = (len - i);
          possible = have >= need;
          // cout << p << " " << have << " " << need << " " << possible << endl;
          break;
        }
        int k = ans[i] - 'a';
        int np = pos[p][k];
        if (np == -1) { possible = false; break; }
        p = np+1;
      }
      if (possible) continue; else break;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 20868
#include <bits/stdc++.h>
#define MOD 1000000007
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define pii pair<long long, long long>
using namespace std;

int N;
map<pii, long long> slope;
set<pii> vis;
long long cntzer1, cntzer2;

long long GCD(long long A, long long B) {
  return B == 0 ? A : GCD(B, A % B);
}

long long POW(long long X, long long Y) {
  long long res = 1;
  while(Y) {
    if(Y & 1) res = res * X % MOD;
    X = X * X % MOD;
    Y >>= 1;
  }
  return res;
}

void frac(long long A, long long B) {
  long long gcd = GCD(ABS(A), ABS(B));
  slope[make_pair(A / gcd, B / gcd)]++;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  long long tam = 0;
  long long A, B;
  for(int i = 1; i <= N; i++) {
    cin >> A >> B;
    if((A == 0) && (B == 0)) tam++;
    else if(A == 0) {
      cntzer1++;
    }else if(B == 0) {
      cntzer2++;
    }else frac(A, B);
  }
  long long ans = 1; 
  while(!slope.empty()) {
    long long x = slope.begin()->first.first, y = slope.begin()->first.second;
    long long val1 = 0, val2 = 0;
    val1 += slope.begin()->second;
    slope.erase(slope.begin());
    if(slope.count(make_pair(y, -x))) {
      val2 += slope[make_pair(y, -x)];
      slope.erase(make_pair(y, -x));
    }
    if(slope.count(make_pair(-y, x))) {
      val2 += slope[make_pair(-y, x)];
      slope.erase(make_pair(-y, x));
    }
    if(slope.count(make_pair(-x, -y))) {
      val1 += slope[make_pair(-x, -y)];
      slope.erase(make_pair(-x, -y));
    }
    ans = ans * (POW(2, val1) + POW(2, val2) - 1 + MOD) % MOD;
  }
  ans = ans * (POW(2, cntzer1) + POW(2, cntzer2) - 1 + MOD) % MOD;
  cout << (ans - 1 + tam + MOD) % MOD << "\n";
}

Measured memory_bytes: 16080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int l,r,n,ans=0,a,b;
  cin >> l >> r >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if((a<=l and l<b) or (a<r and r<=b)){
      ans++;
    }
    if((l<=a and a<r) or (l<b and b<=r)){
      ans++;
    }
  }
  cout << (ans>0) << endl;
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    int L[N];
    for(int i=0;i<N;i++) cin>> L[i];
    vector<int> data;
    sort(L, L+N);
    long ans = 0;
    for(int i=0;i<N;i++) data.push_back(L[i]);
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            vector<int>::iterator Iter1 = lower_bound(data.begin(), data.end(), data[j]-data[i]+1);
            vector<int>::iterator Iter2 = lower_bound(data.begin(), data.end(), data[j]+data[i]);
            ans += Iter2 - Iter1;
            if(i >= Iter1-data.begin() && i < Iter2-data.begin()) ans-=1;
            if(j >= Iter1-data.begin() && j < Iter2-data.begin()) ans-=1;
        }
    }
    cout << ans/3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
#define test(a,n) REP(i,n) cout << a[i] << " ";
using namespace std;

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

  if(2*a*b<c*c+a*a+b*b-2*a*c-2*b*c && c-a-b>0) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i, j, n, c, o;
    scanf("%d", &n);
    for (i=1,o=0; i <= n ;i+=2) {
        for (j=1,c=0; j <= n ;j++) {
            if (i%j==0) c++;
        }
        if (c == 8) o++;
    }
    printf("%d\n", o);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
const int N = 2e5;
using namespace std;
int n,d,ans;
int main()
{
    scanf("%d%d",&n,&d);
    int x,y;
    for (int i = 1;i <= n;i++)
    {
        scanf("%d%d",&x,&y);
        if (1ll * x * x + 1ll * y * y <= 1ll * d * d)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
    return a*a + b*b;
}
int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    cout << fixed << setprecision(10) << sqrt(d) << endl;
}





Measured memory_bytes: 384
//-----------------------
// author : xyqkoala
// time : 2020-06-16
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	vector<int> nums(5);
	int res = 0;
	for(int i=0;i<5;i++){
		cin>>nums[i];
		if(nums[i]==0) res=i+1;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3572
module Main where
 
import           Data.List
 
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple f (a1, a2) = (f a1, f a2)
 
cut :: String -> Int
cut input = maximum $ map length leng
  where
    leng  = map (uncurry intersect . mapTuple nub) part
    part = map (`splitAt` input) [1..len]
    len  = length input
 
main :: IO()
main = interact $ show . cut . last . words


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int ans;
int n;

void solve(string a,string b,string c){
	for(int i=0;i<=a.size();i++){
		bool flag=true;
		if(max(a.size(),b.size()+i)>=ans)break;
		for(int j=i;j<min(a.size(),b.size()+i);j++){
			if(j<a.size() && j>=i && j<b.size()+i){
				if(a[j]!=b[j-i] && a[j]!='?' && b[j-i]!='?'){
					flag=false;
					break;
				}
			}
		}
		if(!flag)continue;
		string cur="";
		for(int j=0;j<max(a.size(),b.size()+i);j++){
			if(j<a.size() && j>=i && j<b.size()+i){
				if(a[j]=='?' && b[j-i]=='?'){
					cur+='?';
				}else{
					if(a[j]!='?')cur+=a[j];
					else{
						cur+=b[j-i];
					}
				}
			}else if(j<i){
				cur+=a[j];
			}else if(j<a.size()){
				cur+=a[j];
			}else{
				cur+=b[j-i];
			}
		}
		int nn=cur.size();
		for(int j=i;j<=nn;j++){
			if(max(nn,j+(int)c.size())>=ans)break;
			bool flag2=true;
			for(int k=j;k<min(nn,(int)c.size()+j);k++){
				if(k<cur.size() && k>=j && k<c.size()+j){
					if(cur[k]!=c[k-j] && cur[k]!='?' && c[k-j]!='?'){
						flag2=false;
						break;
					}
				}
			}
			if(flag2){
				ans=max(nn,j+(int)c.size());
			}
		}
	}
}

int main(void){
	string a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	n=a.size()+b.size()+c.size();
	ans=n;
	solve(a,b,c);
	solve(a,c,b);
	solve(b,a,c);
	solve(b,c,a);
	solve(c,a,b);
	solve(c,b,a);
	printf("%d\n",ans);
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;


	int dx = tx-sx, dy = ty-sy;

	cout << string(dx, 'R') << string(dy, 'U');
	cout << string(dx, 'L') << string(dy, 'D');
	cout << 'D' << string(dx+1, 'R') << string(dy+1, 'U') << 'L';
	cout << 'U' << string(dx+1, 'L') << string(dy+1, 'D') << 'R';

	return 0;	
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),x=sc.nextInt();
        int count = 0;
        for(int i = 0;i<=a;i++){
            for(int j =0;j<=b;j++){
                for(int k =0;k<=c;k++){
                    if(i*500+j*100+k*50==x){
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int calc(string& s, int& i) {
	if (s[i] == '-') {
		i++;
		return 2 - calc(s, i);
	}
	if (s[i] != '(') return s[i++] - '0';
	i++;
	int X = calc(s, i);
	char c = s[i];
	i++;
	int Y = calc(s, i);
	i++;
	if (c == '*') return min(X, Y);
	if (c == '+') return max(X, Y);
}

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == ".") break;
		int cnt = 0;
		for (int P = 0; P <= 2; P++)
			for (int Q = 0; Q <= 2; Q++)
				for (int R = 0; R <= 2; R++) {
					string _s = s;
					for (int i = 0; i < _s.length(); i++)
						if (_s[i] == 'P') _s[i] = '0' + P;
						else if (_s[i] == 'Q') _s[i] = '0' + Q;
						else if (_s[i] == 'R') _s[i] = '0' + R;
					int i = 0;
					if (calc(_s, i) == 2) cnt++;
				}
		cout << cnt << endl;
	}
}

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

int main(){
    long long K,N;
    cin >> N >> K;
    vector<long long> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    sort(H.begin(), H.end());

    long long min_h = H[0];
    long long max_h = H[K-1];
    long long ans = max_h - min_h;

    for(int i=0; i+K-1<H.size(); i++){
        long long val = H[i+K-1] - H[i];
        if(val < ans){
            ans = val;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
A = list(input())
B = list(input())
C = list(input())
t = A[0]
while True:
    if t == "a":
        if not A:
            print("A")
            break
        t = A[0]
        A = A[1:]
    elif t == "b":
        if not B:
            print("B")
            break
        t = B[0]
        B = B[1:]
    else:
        if not C:
            print("C")
            break
        t = C[0]
        C = C[1:]

Measured memory_bytes: 3064