akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()

if (N % 2) == 1:
    ans = "No"
else:
    n = int(N/2)
    s1 = S[0:n]
    s2 = S[-n:]
    if s1 == s2:
        ans="Yes"
    else:
        ans ="No"
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long t = sc.nextLong();
        long ans = 0;
        long[] al = new long[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextLong();
        }
        for(int i = 0; i < n-1; i++){
            ans += Math.min(al[i+1] - al[i], t);
        }
        System.out.println(ans+t);
    }
}


Measured memory_bytes: 64904
import sys
import itertools


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    wn, wm, r = list(map(int, input().rstrip('\n').split()))
    r = list(map(int, input().rstrip('\n').split()))
    inf = 10 ** 13
    wl = [[inf] * wn for _ in range(wn)]
    for i in range(wn):
        wl[i][i] = 0

    for i in range(wm):
        wa, wb, wc = list(map(int, input().rstrip('\n').split()))
        wl[wa - 1][wb - 1] = wc
        wl[wb - 1][wa - 1] = wc

    for i in range(wn):
        for j in range(wn):
            for k in range(wn):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    md = 10 ** 10
    for v in itertools.permutations(r, len(r)):
        l = 0
        d = 0
        for i, vv in enumerate(v):
            if i == 0:
                l = vv - 1
            else:
                d += wl[l][vv-1]
                l = vv-1
        md = min(md, d)
    print(md)


if __name__ == '__main__':
    solve()


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

int main() {
  int N;
  cin >> N;
  //dp[0]は何もしてない状態
  vector<int> h(N), dp(N+1);
  for(int i=0;i<N;i++) cin >> h[i];
  dp[0]=0,dp[1]=0,dp[2]=abs(h[0]-h[1]);
  for(int i=1;i<=N-2;i++) {
    dp[i+2] = min(dp[i]+abs(h[i+1]-h[i-1]), dp[i+1]+abs(h[i+1]-h[i]));
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int main(){
    int n;cin>>n;
    ll ans=0;
    ll mi=LINF;
    bool f=true;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        ans+=b;
        if(a>b){
            mi=min(b,mi);
        }
        if(a!=b)f=false;
    }
    if(f){
        cout<<0<<endl;
        return 0;
    }
    cout<<ans-mi<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[150];
  bool t=false;
  cin >> s;
  for(int i=0;i<strlen(s);i++){
    if(s[i]=='C'){
      t=true;
    }
    if(t==true&&s[i]=='F'){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;


int main(){
	vector<vector<long long> > trie;
	long long N;
	cin>>N;
	vector<long long> vbuf;
	for(int i=0; i<=N; i++){
		trie.push_back(vbuf);
	}
	vector<long long> outcolor(N+1,0);
	long long A,B;
	vector<long long> indegreelist;
	for(int i=0; i<N-1; i++){
		cin>>A>>B;
		trie[A].push_back(B);
		indegreelist.push_back(B);
	}
	long long outn=0;
	for(int i=1; i<trie.size(); i++){
		if(i==1){
			outn = trie[i].size();
		}else if(outn<trie[i].size()+1){
			outn=trie[i].size()+1;
		}
	}
	long long to;
	long long indegreecolor=1;
	long long colorbuf=1;
	for(long long now=1; now<trie.size(); now++){
		if(trie[now].size()==0){
			continue;
		}
		indegreecolor = outcolor[now];
		colorbuf = 1;
		for(int i=0; i<trie[now].size(); i++){
			to = trie[now][i];
			if(colorbuf == indegreecolor){
				colorbuf++;
			}
			outcolor[to] = colorbuf;
			colorbuf++;
		}
	}
	cout<<outn<<endl;
	for(int i=0; i<indegreelist.size(); i++){
		cout<<outcolor[indegreelist[i]]<<endl;
	}

	return 0;
}


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

using namespace std;

long long lcm(long long a, long long b) { return (a*b)/__gcd(a, b); }

int main()
{
    int t;
    t =1;
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // cin >> t;
    while(t--)
    {
       int n,m;
       cin >> n >> m;
       int ans;
       ans = n*m;
       cout << ans; 
    }
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char a = in.nc(), b = in.nc();
        if(a==b)out.println("=");
        else out.println(a>b?">":"<");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

struct point{
    double  x,y;
    point(){};
    point(double x,double y):x(x),y(y){}
    point operator + (point p){
        return point(x+p.x,y+p.y);
    }
    point operator - (point p){
        return point(x-p.x,y-p.y);
    }
    point operator * (double k){
        return point(x*k,y*k);
    }
    point operator / (double k){
        return point(x/k,y/k);
    }
};

double dot(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
double cross(point a,point b)
{
    return a.x*b.y-a.y*b.x;
}

double norm(point p)
{
    return p.x*p.x+p.y*p.y;
}
double ABS(point p)
{
    return sqrt(norm(p));
}

point project(point a,point b,point c)
{
    point base=b-a;
    double r=dot(base,c-a)/norm(base);
    return a+(base*r);
}

pair<point,point>getcrosspoints(point a,int r,point b,point c)
{
    point pr=project(b,c,a);
    point e=(b-c)/ABS(b-c);
    double base=sqrt(r*r*1.0-norm(pr-a));
    e=e*base;
    return make_pair(pr+e,pr-e);
}

int main()
{
    point a;
    int temp;
    cin>>a.x>>a.y>>temp;
    int q;
    cin>>q;
    point c,d;
    for(int i=0;i<q;i++){
        cin>>c.x>>c.y>>d.x>>d.y;
        pair<point,point>res=getcrosspoints(a,temp,c,d);
        if(res.first.x>res.second.x){
            swap(res.first,res.second);
        }else if(res.first.x==res.second.x){
            if(res.first.y>res.second.y){
                swap(res.first,res.second);
            }
        }
        printf("%.8f %.8f %.8f %.8f\n",res.first.x,res.first.y,res.second.x,res.second.y);
    }
    return 0;
}



Measured memory_bytes: 3288
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

vector<int> div(int n) {
	vector<int>ret;
	for (int i = 1; i* i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i*i != n)ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	LL sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}
	vector<int>ret = div(sum);
	int ans;
	for (int i = ret.size() - 1; i > -1; i--) {
		int sum_mod = 0;
		int tmp = 0;
		vector<int>mods;
		for (int j = 0; j < N; j++) {
			mods.push_back(A[j] % ret[i]);
		}
		sort(begin(mods), end(mods), std::greater<int>());
		int k = 0;
		int l = N - 1;
		while (k != l) {
			if (tmp <= 0) {
				sum_mod += ret[i] - mods[k];
				tmp += ret[i] - mods[k];
				k += 1;
			}
			else {
				sum_mod += mods[l];
				tmp -= mods[l];
				l -= 1;
			}
		}
		if ((sum_mod+abs(tmp)) / 2 <= K) {
			ans = ret[i];
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    vec a;
    for(int i=0;i<=25;i++){
        for(int j=0;j<=15;j++){
            a.push_back(4*i+7*j);
        }
    }
    sort(all(a));
    int m=lower_bound(all(a),n)-a.begin();
    if(a[m]==n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<ll> d;

ll dfs(vector<int> &A) {
    if (A.size() == N) {
        int score = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) score += d[i]; 
        }

        return score;
    }

    ll sum = 0;
    int prev = (A.empty() ? 1 : A.back());
    for (int in = prev; in <= M; in++) {
        A.push_back(in);
        chmax(sum, dfs(A));
        A.pop_back();
    }

    return sum;
}

int main() {
    cin >> N >> M >> Q;
    vector<int> A;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    cout << dfs(A) << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))

# N日目の最大の所持金
dp = [1000] + [0] * (N-1)
for i in range(1, N):
    dp[i] = dp[i-1]

    for j in range(i):
        # j日に買える最大の株数
        max_unit = dp[j] // A[j]
        # その場合の所持金の変化
        money = dp[j] + (A[i]-A[j])*max_unit
        dp[i] = max(money, dp[i])

print(dp[-1])


Measured memory_bytes: 8968
import java.io.*;
public class Main {
 public static void main(String[] args){
  try{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   char botton[][]={{' '},
                            {'\'' , ',' , '.' , '!' , '?'},
                            {'a' , 'b' , 'c' , 'A' , 'B' , 'C'},
                            {'d' , 'e' , 'f' , 'D' , 'E' , 'F'},
                            {'g' , 'h' , 'i' , 'G' , 'H' , 'I'},
                            {'j' , 'k' , 'l' , 'J' , 'K' , 'L'},
                            {'m' , 'n' , 'o' , 'M' , 'N' , 'O'},
                            {'p' , 'q' , 'r', 's' , 'P' , 'Q' , 'R' , 'S'},
                            {'t' , 'u' , 'v' , 'T' , 'U' , 'V'},
                            {'w' , 'x' , 'y' , 'z' , 'W' , 'X' , 'Y' , 'Z'}};
    int n[]={0,5,6,6,6,6,6,8,6,8};
    while(true){
     String s=br.readLine();
     s+="x";
     int sl=s.length();
     int cnt=1;
     
     for(int i=1;i<sl;i++){
      char x,ch;
      int num,l,a;
      if(s.charAt(i-1)!=s.charAt(i)){
       x=s.charAt(i-1);
       if(x!='0'){
        num=Character.getNumericValue(x);
        l=n[num];
        if(cnt%l==0)a=l;
        else a=cnt%l;
        ch=botton[num][a-1];
        System.out.print(ch);
       }
       else {for(int j=0;j<cnt-1;j++)System.out.print(" ");}
       cnt=0;
       cnt++;
      }
      else cnt++;
     }
     System.out.print("\n");
   }
  }
  catch(Exception e){return ;}
 }
}


Measured memory_bytes: 25184
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
 	String N = sc.nextLine();
    String[] num = N.split("");
    
    if(num[0].equals(num[1]) && num[1].equals(num[2])){
    	System.out.println("Yes");
    }else if(num[1].equals(num[2]) && num[2].equals(num[3])){
      	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
#include<iostream>

using namespace std;

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

	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

cnt = 0
flag = 1
while flag:
    for i in range(n):
        a = A[i]
        if a % 2 != 0:
            flag = 0
            break
        else:
            A[i] = a // 2
    else:
        cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define ll long long


ll dp[100001][4];

int solve(ll a[][4],ll i,ll prev,ll n)
{
	if(i==n)
	{
		return(0);
	}
	if(dp[i][prev]!=-1)
	{
		return(dp[i][prev]);
	}
    ll ans=INT_MIN,j;
	for(j=1;j<=3;j++)
	{
		if(prev!=j)
		{
			ans=max(ans,solve(a,i+1,j,n)+a[i][j]);
		}
	}
	return(dp[i][prev]=ans);
}

int main()
{
	ll n,i;
	cin>>n;
	ll a[n][4];
	for(i=0;i<n;i++)
	{
		cin>>a[i][1]>>a[i][2]>>a[i][3];
		dp[i][0]=-1;
		dp[i][1]=-1;
		dp[i][2]=-1;
		dp[i][3]=-1;
	}
	cout<<solve(a,0,0,n);
}

Measured memory_bytes: 17668
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vec L;
  for (int i = 0; i < 2 * N; i++) {
    int tmp;
    cin >> tmp;
    L.pb(tmp);
  }

  sort(ALL(L));
  int ans = 0;
  for (int i = 0; i < 2 * N; i += 2) {
    ans += L[i];
  }

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


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

long long N, K, T[200009], sum = 0;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> T[i];
	for (int i = 1; i <= N - 1; i++) {
		if (T[i + 1] - T[i] <= K) sum += (T[i + 1] - T[i]);
		else sum += K;
	}
	sum += K;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var A int
	var B int

	fmt.Scanf("%d", &A)
	fmt.Scanf("%d", &B)

	if B == 1 {
		fmt.Println(0)
		return
	}

	count := 1
	remaining := B - A
	for remaining > 0 {
		remaining = remaining - (A - 1)
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
x2, y2, n = [int(i) for i in input().split()]
x1, y1 = (0, 0)

for i in range(n):
    x, y, a = [int(x) for x in input().split()]
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    elif a == 4:
        y2 = min(y2, y)

print(max(x2 - x1, 0) * max(y2 - y1, 0))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int isUpper(char x) {
	if (x >= 'A'&&x <= 'Z') {
		return 1;
	}
	else {
		return 0;
	}
}

int check(char s[]) {
	int i;
	int sum = 0;

	for (i = 2; i <= strlen(s) - 2; i++) {
		if (s[i] == 'C') {
			sum++;
		}

		if (sum > 1) return 0;
	}

	if (sum == 1) return 1; else return 0;
}

int main() {
	char s[1000];

	scanf("%s", s);


	if (s[0] != 'A' || !check(s)) {
		printf("WA");
	}
	else {

		int i;
		for (i = 1; i < strlen(s); i++) {
			if (isUpper(s[i]) && s[i] != 'C') {
				printf("WA");
				return 0;
			}
		}

		printf("AC");
	}
	getchar(); getchar();
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    if (a==1) a = 14;
    if (b==1) b = 14;
    if (a<b){
        cout<<"Bob\n";
    }else if(a>b){
        cout<<"Alice\n";
    }else{
        cout<<"Draw\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b=0,ans=1;;
    cin >> n >> a;
    vector<int> l(n);
    for (int i=0;i<n;i++){
        cin >> l.at(i);
        b+=l.at(i);
        if (b<=a) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 0){
    cout << (a+b)/2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+11;
    int n;
    multiset<int> s;
    multiset<int>::iterator it;
    int main(){
    #ifdef flukehn
    	freopen("a.in","r",stdin);
    #endif
    	cin>>n;
    	int i,x;
    	for(i=0;i<n;++i){
    		scanf("%d",&x);
    		s.insert(x);
    	}
    	int ans=0,j,y;
    	for(;!s.empty();){
    		it=s.end();
    		--it;
    		x=*it;
    		s.erase(it);
    		for(j=30;j;--j){
    			y=(1<<j)-x;
    			it=s.lower_bound(y);
    			if(it==s.end()||*it!=y)continue;
    			s.erase(it);
    			++ans;
    			break;
    		}
    	}
    	cout<<ans<<endl;
    }

Measured memory_bytes: 9600
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main () {
  priority_queue<int> Q;
  string a; //??????
  while (cin >> a && a != "end") {
    int b; //?????\????????°
    if (a == "insert") {
      cin >> b;
      Q.push(b);
    }
    else {
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}
     

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

int N, M;
int P[2][22];

int main() {
  while(cin >> N >> M && (N|M)) {
    fill(P[0], P[2], 0);
    P[0][0] = N;
    int res = 0;
    for(int k = 0; ; ++k) {
      int p = k % 2;
      int q = 1 - p;
      if(P[p][M]) {
        res = k;
        break;
      }
      for(int i = 0; i < 22; ++i) P[q][i] = 0;
      for(int i = 0; i < 22; ++i) {
        int b = P[p][i] / 2;
        P[q][i] += P[p][i] - b * 2;
        P[q][0] += b;
        P[q][i+1] += b;
      }
    }
    static int tc = 0;
    cout << "Case " << ++tc << ": " << res << endl;
  }
  return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<sstream>

using namespace std;

const int MAX = 10000;

bool isOK(int n){

  stringstream ss;
  ss<<n;
  string s =  ss.str();
  //cout << n << " " << s << endl;
  for(int i = 0; i <= s.length()/2; i++)
    if(s[i] != s[s.length()-1-i]) return false;

  return true;
}

int main(){

  int n;
  cin >> n;
  int ans = 10000000;

  for(int i = MAX; i > 0; i--)
    if((abs(ans-n) >= abs(i-n)) && isOK(i)) ans = i;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;

int n;

int a[maxn],b[maxn];

int f[21][21];
char s[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",s);
		int len=strlen(s);
		int flag=0,cnt=0;long long x=0;
		for(int i=0;i<len;++i){
			if(s[i]=='.'){
				flag=1;continue;
			}
			if(flag)++cnt;
			x=x*10+s[i]-'0';
		}
		while(x%2==0){
			++a[i];x/=2;
		}
		while(x%5==0){
			++b[i];x/=5;
		}
		a[i]+=10-cnt;
		b[i]+=10-cnt;
	}
	long long ans=0;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=20;++j){
			for(int k=0;k<=20;++k){
				if(a[i]+j>=20&&b[i]+k>=20)ans+=f[j][k];
			}
		}
		f[min(a[i],20)][min(b[i],20)]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5392
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll gcd(ll a, ll b ){
    ll r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;
    cin >> a >> b >> n;
    n = min(n,b-1);
    ll ans = (a*n)/b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<vector<bool>>used;
int main(){
    int sx,sy,dx,dy;
    cin>>sy>>sx>>dy>>dx;
    string ans={},tmp={},tmp2={},tmp3={},tmp4={};
        for(int i=0;i<abs(dx-sx);i++){
            tmp+='U';
            tmp2+='D';
        }
            for(int i=0;i<abs(dy-sy);i++){
            tmp3+='R';
            tmp4+='L';
            }
           // cout<<tmp2<<endl;
if(sx<=dx)ans+=tmp;
else if(sx>dx) ans+=tmp2;
if(sy<=dy)ans+=tmp3;
else if(sy>dy) ans+=tmp4;
if(sx<=dx)ans+=tmp2;
else if(sx>dx)ans+=tmp;
if(sy<=dy)ans+=tmp4;
else if(sy>dy)ans+=tmp3;
if(sx<=dx&&sy<=dy){
    ans+="L";
    ans+=tmp+"U";
    ans+=tmp3+"RD";//つく
    ans+='R'+tmp2+"D";
    ans+=tmp4+"L"+"U";
}
else if(sx>dx&&sy<=dy){
    ans+="R";
    ans+=tmp+"U";
    ans+=tmp4+"L"+"D";//つく
    ans+="L"+tmp2+"D";
    ans+=tmp3+"R"+"U";
}
else if (sx<=dx&&sy>dy){
    ans+="L";
    ans+=tmp2+"D";
    ans+=tmp3+"R"+"U";//つく
    ans+="R"+tmp+"U";
    ans+=tmp4+"L"+"D";
}
else{
    ans+="R";
    ans+=tmp2+"D";
    ans+=tmp4+"L"+"U";//つく
    ans+="L"+tmp+"U";
    ans+=tmp3+"R"+"D";
}
cout<<ans<<endl;
}


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

int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    // クエリ処理
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1920
#include <stdio.h>

#define N 100

int main(){
    int n, i, j, v, a[100];
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (j = 0; j < n - 1; j++) {
        printf("%d ", a[j]);
    }
    printf("%d\n", a[j]);
    for (i = 1; i <= n - 1; i++) {
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        
        for (j = 0; j < n - 1; j++) {
            printf("%d ", a[j]);
        }
        printf("%d\n", a[j]);
    }
    
    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
	long a, b, c, d;
    string s;
 	cin >> s;
    for (int i = 0; i < s.size(); i += 2){
        if (s[i] == 'h' && s[i + 1] == 'i'){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int h,w;
	cin>>h>>w;
	char c;
	int cnt=0;
	rep(i,h*w){
		cin>>c;
		cnt+=c=='#';
	}
	cout<<(cnt==h+w-1?"P":"Imp")<<"ossible"<<endl;
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	if ((S[0] == S[1]) && (S[1] == S[2])) {
		cout << "Yes" << endl;
	}
	else if ((S[2] == S[3]) && (S[1] == S[2])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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



int main() {
  int n;
  cin >>n;
  int ans=0;
  map<int,int> p;
  rep(i,n){
    int g;
    cin >>g;
    for(int r=g-1;r<=g+1;r++){
    p[r]++;
    ans=max(ans,p[r]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    while(cin >> n, n) {
        vector<P> target(n);
        for(int i=0; i<n; ++i) {
            cin >> target[i].first >> target[i].second;
        }
        int m;
        cin >> m;
        map<P, bool> stars;
        for(int i=0; i<m; ++i) {
            int x, y;
            cin >> x >> y;
            stars[make_pair(x, y)] = true;
        }
        P now;
        for(auto& p : stars) {
            now = p.first;
            bool ok = true;
            for(int i=1; i<n; ++i) {
                now.first += target[i].first - target[i-1].first;
                now.second += target[i].second - target[i-1].second;
                ok &= stars.count(now) == 1;
            }
            if(ok) {
                cout << p.first.first - target[0].first << ' ' << p.first.second - target[0].second << endl;
                break;
            }
        }
    }
}


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

int nottable[3] = { 2,1,0 };
int andtable[3][3] = { {0,0,0},{0,1,1},{0,1,2} };
int ortable[3][3] = { {0,1,2},{1,1,2},{2,2,2} };

char tochar(int num) {
	if (num == 0) {
		return '0';
	}
	else if (num == 1) {
		return '1';
	}
	else {
		return '2';
	}
}

int solve(string::iterator& iter)
{
	int ret;

	if (*iter == '0') {
		ret = 0;
	}
	else if (*iter == '1') {
		ret = 1;
	}
	else if (*iter == '2') {
		ret = 2;
	}
	else if (*iter == '-') {
		iter++;
		return nottable[solve(iter)];
	}
	else if (*iter == '(') {
		iter++;
		ret = solve(iter);
		
		if (*iter == '+') {
			iter++;
			ret = ortable[ret][solve(iter)];
		}
		else if (*iter == '*') {
			iter++;
			ret = andtable[ret][solve(iter)];
		}
	}

	iter++;

	return ret;
}

int main()
{
	while (true) {
		string str;
		cin >> str;

		if (str == ".") {
			break;
		}

		int ans = 0;

		for (int i = 0; i <= 2; i++) {
			for (int j = 0; j <= 2; j++) {
				for (int k = 0; k <= 2; k++) {
					string temp = str;

					for (int l = 0; l < temp.size(); l++) {
						if (temp[l] == 'P') {
							temp[l] = tochar(i);
						}
						else if (temp[l] == 'Q') {
							temp[l] = tochar(j);
						}
						else if (temp[l] == 'R') {
							temp[l] = tochar(k);
						}
					}

					string::iterator iter = temp.begin();

					if (solve(iter) == 2) {
						ans++;
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3056
import math

def main():
    A, B, H, M = list(map(int, input().split()))
    at, bt = (H + M / 60) * 2 * math.pi / 12, M * 2 * math.pi / 60
    ax, ay = A * math.sin(at), A * math.cos(at)
    bx, by = B * math.sin(bt), B * math.cos(bt)

    return ((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5

print(main())


Measured memory_bytes: 9512
S=input()
L=list(S)

count = 0

if L.count('S') == 3:
    print(0)
elif L.count('S') == 2:
    print(1)
elif L.count('S') == 1:
    if L[1] == 'S':
        print(1)
    else:
        print(2)
else:
    print(3)

Measured memory_bytes: 9036
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
 ll p=0,q=0,r=0;

int main()
{
  vl v(5),w(5),x(5),y(5);
  cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
  
  rep(i,5){v[i]=((x[i]-1)/10+1)*10;p=v[i]-x[i];q=max(p,q);r+=v[i];}
  print(r-q)
  
}

Measured memory_bytes: 3556
import sys
N = list(input())
for bit in range(2 ** 3):
    op = ['-'] * 3
    for i in range(3):
        if (bit & (1 << i)):
            op[i] = '+'
    E = N[0] + op[0] + N[1] + op[1] + N[2] + op[2] + N[3]
    if eval(E) == 7:
        print(E + '=7')
        sys.exit()

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

int main(){
  int N;cin>>N;
  int A[105];
  for (int i=0;i<N;++i) cin>>A[i];
  
  sort(A,A+N,greater<int>());
  int Alice=0;
  int Bob=0;
  for (int i=0;i<N;++i){
    if (i%2==0)Alice+=A[i];
    else Bob+=A[i];
  }
  
  cout<<Alice-Bob<<endl;
}
    
  
  

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

double dp[3000][30000];
int n;
double arr[3000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - arr[i - 1]);
			if (j > 0) dp[i][j] += dp[i - 1][j - 1] * arr[i - 1];
		}
	}	
	double ans = 0;
	for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i];
	printf("%.11lf\n", ans);
	return 0;
}

Measured memory_bytes: 700800
//Chandigarh University
//author:- shivamkr21
#include<bits/stdc++.h>
//#define lli long long int
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i==k-1)
        {
            cout<<char(int(s[i])+32);
        }
        else
        {
            cout<<s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<int> factorization(1000, 1);
	for (int i = 2; i <= N; i++)
	{
		int rest_i = i;
		for (int j = 2; j <= (int)sqrt(i) && rest_i != 1; j++)
		{
			if (rest_i % j == 0)
			{
				int tmp = 0;
				for (; rest_i % j == 0;)
				{
					rest_i /= j;
					tmp++;
				}
				factorization[j] += tmp;
			}
		}
		factorization[rest_i]++;
	}

	lint ans = 1;
	for (int i = 2; i < 1000; i++)
	{
		ans *= factorization[i];
		ans %= INV;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int64_t calc(string s){
    int l = s.length();
    int64_t sum=0;
    string t="";
    rep(i,l){
        t = t + s[i];
        if(s[i]=='+'||i==l-1){
            sum += stoll(t);
            t = "";
        }
    }
    return sum;
}
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int64_t sum=0;
    //ビット全探索
    for (int tmp = 0; tmp < (1 << n-1); tmp++) { 
    //1を左に3ビットずらすと1000=8
    //1<<kで2のk乗
    bitset<10> bi(tmp);
    string c = "";
    // ビット列を出力
    for(int i=0;i<n;i++){
        //cout<<s[i];
        c += s[i];
        if(bi.test(i)==1){
            //cout<<'+';
            c += '+';
        }
    }
    //cout<<c<<"=";
    sum += calc(c);
    //cout<<calc(c)<<endl;
    //cout<<endl;
    //cout << bi << endl;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int a[100005];

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

    for(int i=0;i<=n-1;i++){
        int k;
        cin>>k;
        a[k]+=1;
    }
    int max=0;
    for(int i=0;i<=99998;i++){
        int sum=0;
        sum=a[i]+a[i+1]+a[i+2];
        if(sum>max)max=sum;
        
    }
    printf("%d",max);
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  int r;
  cin >> r;
  cout << r*r;
  return 0;
}


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

// int main(){
// 	vector<int> arr(3);
// 	cin>>arr[0]>>arr[1]>>arr[2];

// 	sort(arr.begin(),arr.end());
// 	int df = arr[2] - arr[1];
// 	int ans = 0;
// 	if(df>0){
// 	    ans+=df;
// 		arr[0]+=df;
// 	}
// 	//cout<<ans<<endl;
// 	if(arr[0]<arr[3]){
// 		if((arr[2]-arr[0])%2==0){
// 			cout<<ans+(arr[2] - arr[0])/2;
// 			return 0;
// 		}
// 		cout<<ans+(arr[2]-arr[0])/2 + 2;
// 		return 0;
// 	}
// 	cout<<ans;
// }

int main(){
	vector<int> arr(3);
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr.begin(),arr.end());

	int df = arr[2] - arr[1];
	int ans = 0;
	 ans+=df/2;
	arr[1]+=(df/2*2);
	if(arr[1]<arr[2]){
		ans+=1;
		arr[0]+=1;
		int d1 = arr[2]-arr[0];
		ans+=d1/2;
		arr[0]+=d1/2*2;
		if(arr[0]<arr[2]) ans+=2;
		cout<<ans;
		return 0;
	}
	int d1 = arr[2] - arr[0];
	ans+=d1/2;
	arr[0]+=(d1/2*2);
	if(arr[0]<arr[2]) ans+=2;
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		if (A + B <= C * 2) {
			System.out.println(A * X + B * Y);
		} else {
			long sum = 0;
			if (X < Y) {
				sum += C * X * 2;
				sum += Math.min(B * (Y - X), C * (Y - X) * 2);
			} else if (X > Y) {
				sum += C * Y * 2;
				sum += Math.min(A * (X - Y), C * (X - Y) * 2);
			} else {
				sum += C * X * 2;
			}

			System.out.println(sum);
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


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

int main()
{
	while (true)
	{
		char ch[1001];
		cin >> ch;
		if (ch[0] == '0') break;
		
		int i = 0;
		int sum = 0;
		while (ch[i] != '\0')
		{
			sum += (int)(ch[i] - '0');
			i++;
		}
		cout << sum << endl;
	}

	return 0;
}


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

using namespace std;

typedef struct {
	int a, b, c;
} fuku_t;

int d, n;

int t[200];
fuku_t fuku[200];

int dp[200][200];

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

	for (int i = 0; i < d; ++i) cin >> t[i];

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

	for (int i = 0; i < n; ++i) if (fuku[i].a <= t[1] && t[1] <= fuku[i].b) {
		for (int j = 0; j < n; ++j) if (fuku[j].a <= t[0] && t[0] <= fuku[j].b) {
			dp[1][i] = max(dp[1][i], abs(fuku[i].c - fuku[j].c));
		}
	}

	for (int i = 2; i < d; ++i) {
		for (int j = 0; j < n; ++j) if (fuku[j].a <= t[i] && t[i] <= fuku[j].b) {
			for (int k = 0; k < n; ++k) if (fuku[k].a <= t[i - 1] && t[i - 1] <= fuku[k].b) {
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(fuku[k].c - fuku[j].c));
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < n; ++i) ans = max(ans, dp[d - 1][i]);

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

Measured memory_bytes: 1388
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC109_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var n = aaa[0];
            var x = aaa[1];
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse).ToList();
            var dist = new List<long>();
            for (var i = 0; i < n; i++)
            {
                dist.Add(Math.Abs(num[i] - x));
            }
            if (n == 1)
            {
                Console.WriteLine(dist[0]);
                return;
            }
            var gcdd = gcd(dist[0], dist[1]);
            for (var i = 2; i < n; i++)
            {
                gcdd = gcd(gcdd, dist[i]);
            }
            Console.WriteLine(gcdd);
        }
        static long gcd(long a, long b)
        {
            if (b > a)
            {
                return gcd(b, a);
            }
            else
            {
                while (b != 0)
                {
                    var remainder = a % b;
                    a = b;
                    b = remainder;
                }
                return a;
            }
        }
    }
}


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

int main() {
    vector<int> a(28), s(0);
    rep(i, 28) cin >> a[i];
    int b = 0;
    sort(a.begin(), a.end());
    rep(i, 30) {
        if(a[i] != i + b + 1) {
            s.push_back(i +b+ 1);
            b++;
        }
    }
    rep(i, 2) cout << s[i] << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
const int N=2e5+5,INF=2e9;
using namespace std;
template<typename tp>inline void r(tp &n){
	n=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while( isdigit(c)) n=n*10+c-48,c=getchar();	
}
int main(){
	
	int n;
	r(n);int l=0,cnt=0;
	if((n&1)==0||(n%5==0)) return 0*puts("-1");
	while(true){
		++cnt;
		l=(l*10+7)%n;
		if(!l) {printf("%d\n",cnt);return 0;}	
		if(cnt>19260817) break;
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 3696
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
    print(X*A+Y*B)
    quit()
mi=min(X,Y)
X-=mi
Y-=mi
if X:
    print(mi*C*2+X*min(2*C,A))
else:
    print(mi*2*C+Y*min(2*C,B))


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


int main()
{
    long N;
    std::cin >> N;
    long count=1;
    long tempN=N;
    while(tempN>=10){
        tempN=tempN/10;
        count++;
    }
    int flag=0;
    if(count%2!=0){
        count=count/2;
        flag=1;
    }else{
        count=count/2;
    }
    long num=0;
    long temp=0;
    for(long i=0; i<count;i++){
        num+=9*pow(100,i);
        temp=pow(100,i);
    }
    if(flag==1 && count!=0){
        num+=N-temp*100+1;
    }
    if(flag==1 && count==0){
        num+=N;
    }
    std::cout << num << std::endl;
    return 0;
}

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

int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double z;
    z = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    cout << fixed << setprecision(5) << z << endl;
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll s;
    cin >> s;
    ll dp[s + 5] = {};  //dp[i]=総和をiとするときの通り数
    for (ll i = 3; i < s + 1; i++) dp[i] = 1;
    for (ll i = 3; i < s + 1; i++) {
        for (ll j = 3; j < i-2; j++) {
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
    }
    cout << dp[s] % MOD << endl;
}

Measured memory_bytes: 3612