akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=gInt();
		char[]v=s.next().toCharArray();
		int[] e=new int[n];
		int[] w=new int[n];
		
		e[0]=v[0]=='E'?1:0;
		w[n-1]=v[n-1]=='W'?1:0;
		for(int i=1;i<n;++i)
			e[i]=e[i-1]+(v[i]=='E'?1:0);
		for(int i=n-2;i>=0;--i)
			w[i]=w[i+1]+(v[i]=='W'?1:0);
		
		System.out.println(
				REP(n).map(i->(i-e[i])+(n-i-w[i]))
//				.peek(System.err::println)
				.min().getAsInt()
				);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

Measured memory_bytes: 33220
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int x;
	cin >> x;
	vector<int> res;

	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int  n,k;
    long long s=0;
    cin>>n>>k;
    for(int j=1,i=k+1;i<=n;i++){
        s+=(n/i)*j;
        if(k!=0&&n%i>=k)
            s+=(n%i)-k+1;
        else if(k==0&&n%i>=k)
            s+=n%i;
        j++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
# define M_PI           3.14159265358979323846  /* pi */
ll mob=1000000007;
using namespace std;
int main()
{   int n,k;
    cin>>n>>k;
    ll sum[1000000];
    ll ans=0;ll maxi,mini;
    sum[0]=0;
    for(int i=1;i<=1000000;i++)
    {
        sum[i]=sum[i-1]+i;
    }
    for(int i=k;i<=n+1;i++)
    {
        mini=sum[i-1];
        if(i!=n+1)
        maxi=sum[n]-sum[n-i];
        else
         maxi=sum[n]-sum[0];
        
        ans+=(maxi-mini+1);
       ans%=mob;
      
        
    }
    cout<<ans%mob;


return 0;
}











Measured memory_bytes: 11424
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>n;
    vl<ll> arr(n);
    for(i=0;i<n;i++) cin>>arr[i];
    for(i=n-1;i>0;i--) if(arr[i-1]>arr[i]) arr[i-1]--;
    for(i=0;i<n-1;i++)
    {
        if(arr[i]>arr[i+1])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 4028
l, r = map(int, input().split())

ans_list = []
for i in range(l, min(l+2019, r)):
  for j in range(i + 1, min(i + 2019, r + 1)):
    ans = (i * j) % 2019
    ans_list.append(ans)
    if ans == 0:
      break
print(min(ans_list))

Measured memory_bytes: 59316
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int R, S, P;
    cin >> R >> S >> P;
    map<char, int> mp;
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;
    string T; cin >> T;
    int ans = 0;
    bool ok[100010];
    rep(i, N) ok[i] = true;
    rep(i, N) {
        //printf("%d", mp[T[i]]);
        if (i + K < N && ok[i] && T[i] != T[i + K]) {
            ans += mp[T[i]];
        }
        else if (i + K < N && ok[i] && T[i] == T[i + K]) {
            ok[i + K] = false;
            ans += mp[T[i]];
        }
        else if (ok[i]) {
            ans += mp[T[i]];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 592
from collections import defaultdict
import heapq
N, M = map(int, input().split())
dct = defaultdict(list)

for i in range(N):
  A, B = map(int, input().split())
  if A > M:
    continue
  dct[M-A].append(-B)

h = []
ans = 0
for i in range(M-1,-1,-1):
  if dct[i]:
    for item in dct[i]:
      heapq.heappush(h,item)
  if h:
    ans += heapq.heappop(h)

print(-ans)

Measured memory_bytes: 27680
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int a[MAX_N];

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    int cnt = 0;
    int ans = 1;
    rep(i,n){
        cnt++;
        if(cnt > (a[i]+1)/2){
            ans = mul(ans, cnt);
            cnt--;
        }
    }
    srep(i,1,cnt+1){
        ans = mul(ans, i);
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    int A,B,C;
    cin>>A>>B>>C;

    if(B<=A&&C<=A){
        cout<<A*10+B+C<<endl;
        return 0;
    }
    if(A<=B&&C<=B){
        cout<<B*10+A+C<<endl;
        return 0;
    }
    if(A<=C&&B<=C){
        cout<<C*10+A+B<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector <int> num(9);
  for(int i = 0;i<9;i++){
    cin >> num.at(i);
  }
  if(num.at(4) == num.at(3)+num.at(1)-num.at(0) &&
     num.at(5) == num.at(3)+num.at(2)-num.at(0) &&
     num.at(7) == num.at(6)+num.at(1)-num.at(0) &&
     num.at(8) == num.at(6)+num.at(2)-num.at(0)
     )
  {
    cout << "Yes" << endl;
  }
  else{cout << "No" << endl;
      }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

vector<int> neig[100010];
ll dp[100010][2];

ll fun(int cur, int prev, int color){
	if(dp[cur][color]!=-1)	return dp[cur][color];
	dp[cur][color]=1;
	for(int i=0;i<neig[cur].size();i++){
		if(neig[cur][i]==prev)	continue;
		dp[cur][color]*=fun(neig[cur][i],cur,0);	dp[cur][color]%=mod;
	}
	if(color==0){
		ll temp=1;
		for(int i=0;i<neig[cur].size();i++){
			if(neig[cur][i]==prev)	continue;
			temp*=fun(neig[cur][i],cur,1);	temp%=mod;
		}
		dp[cur][color]+=temp;	dp[cur][color]%=mod;
	}
	return dp[cur][color];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i,j,n;	cin>>n;
    for(i=0;i<n;i++){
    	dp[i+1][0]=-1;	dp[i+1][1]=-1;
    }
    for(i=0;i<n-1;i++){
    	int u,v;	cin>>u>>v;
    	neig[u].pb(v);	neig[v].pb(u);
    }
    cout<<fun(1,0,0)<<endl;
    return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3e5 + 5;

typedef pair<int,int>   ii;

struct BIT  {
    int t[N];

    int upd(int p,int x)    {
        for(; p < N ; p += p & -p)
            t[p] += x;
        return  1;
    }
    int get(int p)  {
        int ans = 0;
        for(; p > 0 ; p -= p & -p)
            ans += t[p];
        return  ans;
    }
}   T[2];
int p[N];

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

    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   {
        cin >> p[i];
        if((i & 1) != (p[i] & 1))   {
            cout << "No";
            return  0;
        }
    }
    ll  x = 0;
    ll  y = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        int v = i % 2;

        x += T[v].get(n) - T[v].get(p[i]);  v ^= 1;
        y += T[v].get(n) - T[v].get(p[i]);  v ^= 1;

        T[v].upd(p[i],1);
    }
    if (y == x + x) cout << "Yes";
    else            cout << "No";
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/
    
    /*
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    
    sort(a.begin(), a.end());
    */
    
    /*
    if( a == b ){
        cout << c << endl;
    } else if (b == c){
        cout << a << endl;
    } else {
        cout << b << endl;
    }
    */
    
    cout << b * 2 - a << endl;

    return 0; 
}


Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
  std::string s;

  cin >> s;

  std::sort(s.begin(), s.end());

  if (s == "abc") {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i,N) cin >> s[i];
    multiset<string> set_s;
    rep(i,N) set_s.insert(s[i]);


    int M;
    cin >> M;
    vector<string> t(M);
    rep(i,M) cin >> t[i];
    multiset<string> set_t;
    rep(i,M) set_t.insert(t[i]);

    int ans = 0;
    for(multiset<string>::iterator itr = set_s.begin(); itr != set_s.end(); itr++)
    {
        if( set_t.find( *itr ) != set_t.end() ) chmax(ans, (int)(set_s.count(*itr)-set_t.count(*itr)) );
        else chmax(ans, (int)(set_s.count(*itr)) );
    }
    cout << ans << endl;
}


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

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

	vector<int> v(n);
	for(int &e : v)
		cin >> e;
	
	vector<int> v2 = v;
	sort(v2.rbegin(), v2.rend());
	
	for(int &e : v)
		cout << (e == v2[0] ? v2[1] : v2[0]) << '\n';
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read() {
	int x; scanf("%lld", &x); return x;	
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long 
main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	int x = read(), k = read(), d = read();
	x = abs(x);
	int ans;
	int p;
	if (x / d <= k) {
		k -= (x / d);
		if (k % 2 == 0) {
			ans = x - (x / d) * d; 
			if (k >= 2) ans = min(ans, abs(x - (x / d) * d - 2 * d));
		}
		else if (k & 1) {
			ans = abs(x - (x / d) * d - d);
			if (k >= 2 || (x / d) >= 2) ans = min(ans, abs(x - (x / d) * d + 2 * d));
		}
	} else {
		ans = x - k * d;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3760
import sys 
L,R = map(int, input().split())

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

ans = 10*100
for i in range(L,R):
    for j in range(i+1,R+1):
        number = (i*j)%2019
        ans = min(ans,number)

print(ans)  

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

int main() {
    ll X;
    cin >> X;

    ll ans = 0;
    if (X < 600) {
        ans = 8;
    } else if (X < 800) {
        ans = 7;
    } else if (X < 1000) {
        ans = 6;
    } else if (X < 1200) {
        ans = 5;
    } else if (X < 1400) {
        ans = 4;
    } else if (X < 1600) {
        ans = 3;
    } else if (X < 1800) {
        ans = 2;
    } else {
        ans = 1;
    }

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


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=200005;
char ch[MAXN];
char c1[15],c2[15];
int a[MAXN];
int n,m;
struct oper{int x,o;}w[MAXN];
int hd,tl;
int main()
{
	n=read();m=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)a[i]=ch[i]-'A'+1;
	for(int i=1;i<=m;i++)
	{
		scanf("%s",c1+1);
		scanf("%s",c2+1);
		w[i].x=c1[1]-'A'+1;
		if(c2[1]=='L')w[i].o=0;
		else w[i].o=1;
	}
	hd=1;tl=n;
	bool tf1=false,tf2=false;
	for(int i=m;i>=1;i--)
	{
		if(w[i].o)
		{
			if(w[i].x==a[tl])tl--;
			if(w[i].x==a[hd-1]&&hd-1)hd--;
		}
		else
		{
			if(w[i].x==a[hd])hd++;
			if(w[i].x==a[tl+1]&&tl+1<=n)tl++;
		}
	}
	if(hd>tl)puts("0");
	else pr2(tl-hd+1);
	return 0;
}



Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdint>
#include <deque>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <queue>

using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<int, vector<pair<int, uint64_t>>> edges;
  for (int i = 1; i < n; i++) {
    int from, to, weight;
    cin >> from >> to >> weight;
    edges[from].emplace_back(make_pair(to, weight));
    edges[to].emplace_back(make_pair(from, weight));
  }
  int q, k;
  cin >> q >> k;

  vector<uint64_t> dist(n + 1);
  priority_queue<pair<int, uint64_t>> queue;  // vertex, dist
  queue.push(make_pair(k, 0));  // starting point
  while (!queue.empty()) {
    auto start = queue.top();
    queue.pop();
    uint64_t current_dist = start.second;
    dist[start.first] = current_dist;

    auto edge = edges.find(start.first);
    for (auto& entry : edge->second) {
      if (dist[entry.first] == 0 && entry.first != k) {
        queue.push(make_pair(entry.first, current_dist + entry.second));
      }
    }
  }

  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << "\n";
  }
}


Measured memory_bytes: 15888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
  auto c3 = [](const P &a, const P &b, const P &c){
    ld A = norm(b - c);
    ld B = norm(c - a);
    ld C = norm(a - b);
    ld S = abs(cross(b - a, c - a));
    P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
    ld r = abs(p - a);
    return make_pair(r, p);
  };

  auto c2 = [](const P &a, const P &b){
    P c = (a + b) / (ld)2;
    ld r = abs(a - c);
    return make_pair(r, c);
  };

  auto in_circle = [](const P &a, const C &c){
    return norm(a - c.pnt) <= c.rad*c.rad + eps;
  };

int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

int main(){
     srand(time(0));
     int n;
     cin >> n;
     vector<P> ps(n);
     for(int i = 0; i < n; ++i){
         ld x,y;
         cin >> x >> y;
         ps[i] = P(x,y);
     }

     printf("%.10lf\n", (double)smallest_enclosing_disc(ps).rad);
 }


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

main :: IO ()
main = do
  [n, tl] <- f
  solve tl <$> replicateM n f >>= putStrLn
  where
    f = map read <$> words <$> getLine
    

solve :: Int -> [[Int]] -> String
solve tl cts = let cts' = filter (\[_,t] -> t <= tl) cts
               in if null cts' then "TLE" else (show . (!! 0) . minimum) cts'


Measured memory_bytes: 1020
N,M=map(int,input().split())

chk=[True]*(10**5+1)
for i in range(M):
    a=int(input())
    chk[a]=False

mod=10**9+7

if N==1:
    print(1)
    exit()

f=[0]*(N+1)
f[0]=1
if chk[1]:
    f[1]=1
else:
    f[1]=0


for i in range(2,N+1):
    if chk[i-2]:
        f[i]+=f[i-2]
    if chk[i-1]:
        f[i]+=f[i-1]
    f[i]=f[i]%mod

print(f[N])

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

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

Measured memory_bytes: 3628
// ABC167 - A
function main(input) {
  var inputs = input.split('\n');
  var s = inputs[0].split('');
  var t = inputs[1].split('');

  for (var i = 0; i < s.length; i++) {
    if (s[i] != t[i]) {
      console.log('No');
      return;
    }
  }
  console.log('Yes');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  map<string,bool> mp;
  int n;
  cin >> n;
  string s1,s2;
  cin >> s1;
  mp[s1] = 1;
  for (int i = 1; i < n; i++) {
    cin >> s2;
    bool f = true;
    if (s2[0] == s1[s1.size()-1]) {
      for (auto p: mp) {
        if(p.first == s2) f = false;
      }
    } else {
      f = false;
    }
    if (f) {
      mp[s2] = 1;
      s1 = s2;
    } else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,x;

  scanf("%d %d",&a,&b);
  if(a<b){
    x=b;
    b=a;
    a=x;
  }
  x=a%b;
  while(x!=0){
    a=b;
    b=x;
    x=a%b;
  }
  printf("%d\n",b);

  return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	lli a,b,c,d;
	cin>>a>>b>>c>>d;

	cout<<max({a*c, b*d, a*d, b*c})<<endl;
	

	return 0;
}

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

const long long MOD = 1000000007;

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

    long long dp[100000] = {0};
    int j = 0;
    dp[0] = 1;
    if(a[0] == 1){
        dp[1] = 0;
        j++;
    }else{
        dp[1] = 1;
    }
    for(int i=2;i<=n;i++){
        if(i != a[j]){
            dp[i] = (dp[i-1] + dp[i-2])%MOD;
        }else{
            dp[i] = 0;
            j++;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
// Comment
// easy

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int N, K;
int main() {
	cin >> N >> K;
	cout << (1 + (N-K+(K-1)-1)/(K-1)) << endl;
	return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;
using db = long double;

ll const INF=ll(3e9);
db const EPS=1e-9;

struct dist_func {
	ll l1,r1,l2,r2,m1,m2;
	ll t1,t2;
	
	dist_func(ll a,ll b,ll c,ll d,ll e,ll f): l1(a),r1(b),l2(c),r2(d),m1(e),m2(f) {
		t1=lower_bound();
		t2=upper_bound();
	}
	
	ll operator()(ll t) const {
		return max({r1+t,r2-t,m2})-min({l1+t,l2-t,m1});
	}
	
	db operator()(db t) const {
		return max({r1+t,r2-t,db(m2)})-min({l1+t,l2-t,db(m1)});
	}
	
	ll lower_bound() {
		ll l=0,r=INF;
		while (l<r) {
			ll m=l+(r-l)/2;
			ll d1=this->operator()(m);
			ll d2=this->operator()(m+1);
			if (d1>d2) l=m+1; else r=m;
		}
		return l;
	}
	
	ll upper_bound() {
		ll l=0,r=INF;
		while (l<r) {
			ll m=l+(r-l)/2;
			ll d1=this->operator()(m);
			ll d2=this->operator()(m+1);
			if (d1>=d2) l=m+1; else r=m;
		}
		return l;
	}
};

db check(const dist_func &dx, const dist_func &dy, db t) {
	return dx(t)*dy(t);
}

db cross(const dist_func &dx, const dist_func &dy) {
	db l=dx.t2,r=dy.t1;
	if (l-EPS>r) return l;
	rep(i,0,60) {
		db m=l+(r-l)/2;
		db d1=dx(m);
		db d2=dy(m);
		if (d1+EPS<d2) l=m; else r=m;
	}
	return l;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll r1=INF,r2=-INF;
	ll l1=INF,l2=-INF;
	ll d1=INF,d2=-INF;
	ll u1=INF,u2=-INF;
	ll x1=INF,x2=-INF;
	ll y1=INF,y2=-INF;
	
	int N;
	cin>>N;
	rep(i,0,N) {
		ll x,y;
		string s;
		cin>>x>>y>>s;
		x*=2;
		y*=2;
		switch (s[0]) {
			case 'R':
				r1=min(r1,x);
				r2=max(r2,x);
				y1=min(y1,y);
				y2=max(y2,y);
				break;
			case 'L':
				l1=min(l1,x);
				l2=max(l2,x);
				y1=min(y1,y);
				y2=max(y2,y);
				break;
			case 'U':
				u1=min(u1,y);
				u2=max(u2,y);
				x1=min(x1,x);
				x2=max(x2,x);
				break;
			case 'D':
				d1=min(d1,y);
				d2=max(d2,y);
				x1=min(x1,x);
				x2=max(x2,x);
				break;
			default:
				throw;
		}
	}
	
	dist_func dx(r1,r2,l1,l2,x1,x2);
	dist_func dy(u1,u2,d1,d2,y1,y2);
	
	ll res=dx(0ll)*dy(0ll);
	rep(t,1,int(2e8)) res=min(res,dx(ll(t))*dy(ll(t)));
	
	//~ db res=check(dx,dy,dx.t1);
	//~ res=min(res,check(dx,dy,dx.t2));
	//~ res=min(res,check(dx,dy,dy.t1));
	//~ res=min(res,check(dx,dy,dy.t2));
	
	//~ res=min(res,check(dx,dy,cross(dx,dy)));
	//~ res=min(res,check(dx,dy,cross(dy,dx)));
	
	cout<<db(res)/4<<"\n";
}


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

using namespace std;

// bool min(int a, int b) {
//     if (a > b) {
//         return true;
//     }
//     return false;
// }

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

    if (a >= b && a >= c) {
        ans = b+c;
    } else if (b >= a && b >= c)
        {
            ans = a + c;
        } else {
            ans = a+ b;
        }

    cout << ans << endl;
}

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

#define INF INT_MAX

#define MAX 10000
vector<vector<pair<int, int>>> adj_list(MAX);

void dijkstra(int start_node, int node_size){
    vector<int> visited(node_size, 0);
    vector<int> cost_table(node_size, INF);

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    
    visited.at(start_node) = 1;
    cost_table.at(start_node) = 0;
    //queueの初期化 startノードに隣接するノードとそのコストをpush
    // cout << "queue pushed : ";
    int i = 0;
    while(adj_list.at(start_node).at(i).first != -1){
        pair<int, int> x = make_pair(adj_list.at(start_node).at(i).second, adj_list.at(start_node).at(i).first);
        q.push(x);
        // cout << x.first << " " << x.second << "  ";
        cost_table.at(x.second) = x.first;
        i++;
    }
    // cout << endl;

    // cout << "cost_table ====" << endl;
    // rep(i, node_size) cout << i << " " << cost_table.at(i) << endl;
    // cout << endl;


    while(q.size() != 1){
        pair<int, int> Nnode = q.top(); q.pop();
        int nearestNode = Nnode.second;

        visited.at(nearestNode) = 1;

        int i = 0;

        while(adj_list.at(nearestNode).at(i).first != -1){
            int v = adj_list.at(nearestNode).at(i).first; // 構築中の木に隣接するノードvと、追加したノード(nearestNode)からのコストc
            int c = adj_list.at(nearestNode).at(i).second;// 

            // cout << "nearest node : " << nearestNode << " " << v << " " << c << endl;

            if(visited.at(v) == 1){
                // cout << "old" << endl;
                i++;
                continue;
            }else{
                // cout << "new : cost_table " << cost_table.at(v) << " " <<  cost_table.at(nearestNode) << endl;

                if(cost_table.at(v) > cost_table.at(nearestNode) + c){
                    cost_table.at(v) = cost_table.at(nearestNode) + c;
                    q.push(make_pair(cost_table.at(v), v));
                    // cout << "queue pushed : cost " << cost_table.at(v) << " node " << v << endl; 
                }
            }
            i++;
        }
    }

    rep(i, node_size){
        cout << i << " " << cost_table.at(i) << endl;
    }
}



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

    //　隣接リストの作成
    rep(i, n){
        int from, k; cin >> from >> k;

        rep(j, k){
            int to, weight; cin >> to >> weight;
            adj_list.at(from).push_back(make_pair(to, weight));
        }
    }

    //番兵の挿入
    rep(i, n){
        adj_list.at(i).push_back(make_pair(-1, -1));
    }

    // cout << endl;
    // rep(i, n){
    //     int j = 0;
    //     while(adj_list.at(i).at(j).first != -1){
    //         cout << adj_list.at(i).at(j).first << " " << adj_list.at(i).at(j).second << " ";
    //         j++;
    //     }
    //     cout << endl;
    // }

    dijkstra(0, n);

}



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

int main(){
  string s;
  cin >> s;
  
  int nums[4];
  for (int i = 0; i < 4; i++){
    nums[i] = s.at(i) - '0';
  }

  for (int i = 0; i < (1 << 4); i++){
    bitset<4> op(i);
    op = op << 1;
    int sum = 0;
    for (int j = 0; j < 4; j++){
      if (op.test(j)) sum -= nums[j];
      else sum += nums[j];
    }
    if (sum == 7){
      for (int j = 0; j < 4; j++){
        if (j > 0){
          if (op.test(j)) cout << "-";
          else cout << "+";
        }
        cout << nums[j];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
const int nax = 1e5+3;;

int n;;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1)
             return 0;
	if(dp[i]!=-1) 
             return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) 
             ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){

	cin>>n;

	for(int i=0; i<n; i++) 
               cin>>a[i];;;
	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    /*
    
    int N;
    std::cin >> N;
    vector<vector<int>> A;
    for (int i = 0; i < N; i++) {
        vector<int> ai(N-1);
        for (int j = 0; j < N-1; j++) {
            int a;
            std::cin >> a;
            ai[j] = a;
        }
        A.push_back(ai);
    }
    //リーグの試合に番号をつける
    //i vs j = i + (N-1)*j
    
    //有向グラフの勉強をする
    */
    int N;
    std::cin >> N;
    vector<vector<int>> A;
    for (int i = 0; i < 2; i++) {
        vector<int> ai(N);
        for (int j = 0; j < N; j++) {
            int a;
            std::cin >> a;
            ai[j] = a;
        }
        A.push_back(ai);
    }
    //dp[i][j] = (i,j)に来るまでに回収できる飴の最大値
    vector<vector<int>> dp;
    ndarray(dp, 3, N+1);
    
    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= N; j++) {
            dp[i][j] = A[i-1][j-1] + std::max(dp[i-1][j], dp[i][j-1]);
        }
    }
    std::cout << dp[2][N] << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
N,K=map(int, input().split())
*h,=map(int,input().split())
INF=10**12

dp = [INF]*N
dp[0]=0

for i in range(1,N):
  if i <= K:
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,i+1)])
  else:
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,K+1)])
  
print(dp[-1])

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

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

int main() {
  int N;
  ll A[100000],g[100000],gr[100000];
  cin>>N;
  for(int i(0);i<N;i++)cin>>A[i];
  g[0]=A[0];gr[N-1]=A[N-1];
  for(int i(1);i<N;i++){
    g[i]=gcd(A[i],g[i-1]);
  }
  for(int i(N-1);i>=0;i--){
    gr[i]=gcd(A[i],gr[i+1]);
  }

  ll maxi(0),gcdi;
  for(int i(1);i<N-1;i++){
    gcdi=gcd(g[i-1],gr[i+1]);
    maxi=max(maxi,gcdi);
  }
  maxi=max(g[N-2],max(gr[1],maxi));
  cout<<maxi;
}


Measured memory_bytes: 2560
N, K = (int(i) for i in input().split())

D = {}
count = 0
for i in range(N):
    a, b = (int(i) for i in input().split())
    if a in D:
        D[a] += b
    else:
        D[a] = b

else:
    aL = [a for a in D.keys()]
    aL.sort()
    for a in aL:
        count += D[a]
        if count >= K:
            print(a)
            break

Measured memory_bytes: 10592
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int[] a=new int[N];
    for(int i=0;i<N;i++){
      a[i]=scan.nextInt();
    }
    int count4=0;
    int count2=0;
    for(int i=0;i<N;i++){
      if(a[i]%4==0){
        count4++;
      }
      else if(a[i]%2==0){
        count2++;
      }
    }

    if(count4>=N/2){
      System.out.println("Yes");
    }
    else if(N-count2-count4==count4){
      System.out.println("Yes");
    }else if(count2==N){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 51152
n = int(input())
a = [int(input()) for _ in range(n)]
if a[0] != 0:
    print(-1)
    exit()

ans = 0
for i in range(1, n):
    if a[i - 1] + 1 == a[i]:
        ans += 1
    elif a[i - 1] >= a[i]:
        ans += a[i]
    else:
        print(-1)
        exit()
else:
    print(ans)

Measured memory_bytes: 11052
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

bool cmp(int a, int b){
	return a > b;
}

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;
int a[SIZE];

int main(){ 
	speedhack()
	int k; cin >> k;
	int n = (1 << k);

	multiset<int> data;

	for(int i = 1; i <= n; i++){
		int cur; cin >> cur;
		data.insert(cur*-1);
	}
	vector<int> vals;
	vals.push_back(*(data.begin()));
	data.erase(data.begin());
	for(int it = 1; it <= k; it++){
		vector<int> newv;
		for(int i = 0; i < vals.size(); i++){
			if(data.upper_bound(vals[i]) == data.end()){
				cout << "No" << endl;
				return 0;
			}
			newv.push_back(*(data.upper_bound(vals[i])));
			data.erase(data.upper_bound(vals[i]));
		}
		for(int i = 0; i < newv.size(); i++){
			vals.push_back(newv[i]);
		}
		sort(all(vals));
	}
	cout << "Yes" << endl;
	return 0;
}







Measured memory_bytes: 13984
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, h;
    cin >> a >> b >> h;
    cout << a*h + (b-a)*h/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
def examA():
    A, B = LI()
    if A==B:
        ans = "Draw"
    elif (A>B and B!=1) or (A==1):
        ans = "Alice"
    else:
        ans ="Bob"
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3444
n = int(input())
a = list(map(int, input().split()))
aa = min(a)
ab = max(a)
mina = []
for i in range(aa,ab+1):
	sum = 0
	for j in range(n):
		sum += (i-a[j])**2
	mina.append(sum)
print (min(mina))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve() {
    double x; cin >> x;
    cout << fixed << setprecision(8) << (x / 3) * (x / 3) * (x / 3);
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	bool flag =true;
	while(flag){
		priority_queue<pair<int,char> > data;
		while(!data.empty())data.pop();
		for(int i='A';i <='E';i++){
			int x,y;
			cin>>x>>y;
			int sum =x+y;
			if(sum==0){
				flag =false;
				break;
			}
			data.push(mp(sum,i));
		}
		if(flag)
			cout <<data.top().second<<" "<<data.top().first<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
program main;
var n,sum,h : longint;
    m,a,i : integer;
begin
    sum:=0;
    readln(n,m);
    for i := 1 to m do begin
        read(a);
        sum := sum + a;
    end;
    h:= n-sum;
    if h >= 0
    then writeln(h)
    else writeln('-1')
end.

Measured memory_bytes: 1376
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std ;
static const int INF = 1e9;
static const int MAX_N = 1e+6 +10;
typedef pair<int,int> pii;

struct edge{
    int to,cost;
    edge(){}
    edge(int p1,int p2){
        to=p1;
        cost=p2;
    }
};

int N,K;
vector<int> V[5010];
pii G[6010];
vector<int> D[5010];
int d[6010];
//vector<edge> S[5010];
int A[6010];

void bfs(int s){
    //fill(d,d+5005,INF);
    for(int i=0;i<6000;++i)d[i]=INF;
    queue<pii> que;
    que.push(pii(s,0));
    while(!que.empty()){
        pii p=que.front();
        que.pop();
        int v = p.FI;
        if(d[v]==1)continue;
        d[v]=1;
        if(p.SE<=G[s].SE&&p.FI!=s){
             D[s].PB(v);
        }
        for(int i=0;i<V[v].size();++i){
             que.push(pii(V[v][i],p.SE+1));
        }
     }
}

void dijkstra(int s){
    priority_queue<pii,vector<pii>,greater<pii> > que;
    for(int i=0;i<6000;++i)A[i]=INF;
    A[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int v=p.SE;
        if(A[v]<p.FI)continue;
        for(int i=0;i<V[v].size();i++){
            int e = V[v][i];
            if(A[e]>A[v]+G[v].FI){
                A[e] = A[v]+G[v].FI;
                que.push(pii(A[e],e));
            }
        }
    }
}

signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>G[i].FI>>G[i].SE;
    }
    for(int i=0;i<K;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        V[a].PB(b);
        V[b].PB(a);
    }
    for(int i=0;i<N-1;++i)bfs(i);
    for(int i=0;i<N-1;++i){
        V[i].clear();
    }
    for(int i=0;i<N-1;++i){
        for(int j=0;j<D[i].size();++j){
            int a=i;
            int b=D[i][j];
            V[a].PB(b);
        }
    }
    dijkstra(0);
    cout<<A[N-1]<<endl;
}

Measured memory_bytes: 252088
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int A[200000],B[200000];
priority_queue<pii> H;
int main() {
    int i;
    int N,d = 0;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);
    for (i = 0; i < N; i++) scanf("%d",&B[i]),H.push(mp(B[i],i)),d += (A[i] != B[i]);
    for (i = 0; i < N; i++) {
        if (B[i] < A[i]) {
            printf("-1\n");
            return 0;
        }
    }

    LLI ans = 0;
    while (d > 0) {
        if (H.empty()) {
            printf("-1\n");
            return 0;
        }
        int u = H.top().second;
        H.pop();
        if (B[u] == A[u]) continue;
        int c = B[(u+N-1) % N]+B[(u+1) % N];
        if ((LLI) c+A[u] > B[u]) continue;
        d -= (B[u] != A[u]);
        ans += (B[u]-A[u])/c;
        B[u] -= ((B[u]-A[u])/c)*c;
        d += (B[u] != A[u]);
        H.push(mp(B[u],u));
    }
    printf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 3700
require 'prime'
class Integer
  def modinv(m)
    a, b, i, j = self, m, 1, 0
    while b > 0
      t = a / b
      a, b = b, a - t * b
      i, j = j, i - t * j
    end
    return i % m
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)
result = a.inject(&:lcm)%1000000007
a = a.map{|i| (result * i.modinv(1000000007))%1000000007}
puts a.inject(&:+)%1000000007

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

int main() {
	char c[2][3];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	string ans = "NO";
	if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
	}
	sort.Sort(sort.IntSlice(arr))
	prev := arr[n - 1]
	parallel := 0
	for i := n - 2; i > -1; i-- {
		current := arr[i]
		if prev == current {
			arr[i + 1] = -1
			arr[i] = -1
			parallel = current
			break
		}
		prev = current
	}
	prev = arr[n - 1]
	vertical := 0
	for i := n - 2; i > -1; i-- {
		current := arr[i]
		if current == -1 {
			prev = current
			continue
		}
		if prev == current {
			vertical = current
			break
		}
		prev = current
	}
	fmt.Println(parallel * vertical)
}

Measured memory_bytes: 5504
#include<stdio.h>
int dp[50][3001];
int main(){
	int n,m,s;
	int i,j,k;
	while(1){
	scanf("%d %d %d",&n,&m,&s);
	if(n==0)return 0;
	for(i=0;i<=n*n;i++)for(j=0;j<=s;j++)dp[i][j]=0;
	dp[0][0]=1;
	for(i=1;i<=m;i++){
		for(j=s-i;j>=0;j--){
			for(k=0;k<n*n;k++){
				dp[k+1][j+i]=(dp[k+1][j+i]+dp[k][j])%100000;
			}
		}
	}
	printf("%d\n",dp[n*n][s]);
	}
}

Measured memory_bytes: 1184
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	LL a,b;
	cin >> a >> b;
	for(int i=1; i<N; i++){
		LL x,y;
		cin >> x >> y;
		for(LL j=max(a/x,b/y); j<=LL_MAX; j++){
			if(x*j >= a && y*j >= b){
				a = x*j;
				b = y*j;
				break;
			}
		}
	}
	cout << a+b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0&&b==0&&c==1){cout<<"Open"<<endl;}else
    if(a==1&&b==1&&c==0){cout<<"Open"<<endl;}else
    {cout<<"Close"<<endl;}
}



Measured memory_bytes: 3092
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int rec = 0, rho = 0;
	
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if (c * c == a * a + b * b){
			rec++;
		}
		else if (a == b){
			rho++;
		}
	}
	
	printf("%d\n", rec);
	printf("%d\n", rho);
	
	return (0);
}

Measured memory_bytes: 596