akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;

int main() {
	int n, m;
	long long k;
	cin >> n >> m >> k;
	vector<long long> a(n + 1);
	a.push_back(0);
	int a_n;
	rep2(i, 1, n + 1) {
		cin >> a_n;
		a[i] = (i == 0) ? a_n : a_n + a[i - 1];
	}
	vector<long long> b(m + 1);
	b.push_back(0);
	int b_n;
	rep2(i, 1, m + 1) {
		cin >> b_n;
		b[i] = (i == 0) ? b_n : b_n + b[i - 1];
	}
	int ans = 0;
	int j = m;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) break;
		while (b[j] > k - a[i]) {
			j -= 1;
		}
		ans = max(ans, i + j);
	}
	cout << ans << endl;
}

Measured memory_bytes: 7796
#include <stdio.h>
#include <iostream>
#include <map>
using namespace std;
map<int, int> mp;
map<int, int>::reverse_iterator itor;
int tmp, cnt, side[10];
long long ans;

int main() {
//	freopen("in.in", "r", stdin);
	int n = 0;
	while(scanf("%d", &n) == 1) {
		mp.clear(), cnt = 0, ans = 0;
		for (int i = 0; i < n; ++i) {
			scanf("%d", &tmp);
			++mp[tmp];
		}
		for (itor = mp.rbegin(); itor != mp.rend(); ++itor) {
			if (itor->second < 2) continue;
			if (itor->second >= 4 && cnt == 0) {
				ans = (long long) (itor->first) * (itor->first);
				break;
			}
			side[cnt++] = itor->first;
			if (cnt == 2) break;
		}
		if (cnt) {
//			cout << side[0] << " * " << side[1] << endl;
			ans = (long long)side[0] * side[1];
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) v.begin(), v.end()
#define int long long
#define MAX 200000+5
int indegree[MAX];
void topoSort(vi adj[], int N, vi dp){
    set<int> q;
    FOR1(i, N){
        if(indegree[i] == 0){
            q.insert(i);
        }
    }
    while(!q.empty()){
        int v = *q.begin();
        //cout << v << " ";
        for(int neigh : adj[v]){
            dp[neigh] = max(dp[neigh], dp[v] + 1);
        }
        q.erase(q.begin());
        for(int i = 0; i < adj[v].size(); i++){
            indegree[adj[v][i]]--;
            if(indegree[adj[v][i]] == 0) q.insert(adj[v][i]);
        }
    }
    cout << *max_element(all(dp));
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int T = 1;
	//cin>>T;
	while(T-->0)
	{
        int N, M;
        cin>>N>>M;
        vector<int> adj[N+1];
        while(M--){
            int x, y;
            cin >> x >> y;
            adj[x].pb(y);
            indegree[y]++;
        }
        vi dp(N+1, 0);
        topoSort(adj, N, dp);
	    cout<<'\n';
	}
	return 0;
}


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

#define int long long

int dp[50];
int n;

void init() {
  dp[1] = dp[2] = dp[3] = 1;
  for (int i = 1; i <= 30; i++) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }
}

signed main() {
  init();
  while (1) {
    cin >> n;
    if (n == 0) break;
    int kind = dp[n] / 10;
    int year = kind / 365;
    int days = kind % 365;
    cout << max(1LL, year + (days >= 1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

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

int main(void){
  string str;
  while(cin>>str){
    if(cin.eof())break;
    for(int i = 0 ; i < str.size() ; i ++){
      if(str[i] == '@'){
        int re = str[++i] - '0';
        i++;
        rep(j,re){
          cout<<str[i];
        }
        continue;
      }
      cout<<str[i];
    }
    cout<<endl;
  }	
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, ans;
    
    cin >> A >> B >> C;
    ans = A+B+C-max(A, max(B, C));

    cout << ans << endl;

    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(ans == 0)
    // 	puts("YES");
    // else
    // 	puts("NO");
	
}


Measured memory_bytes: 764
program prob5
    implicit none
    character(100005) :: s, t
    character(200010) :: ss
    logical :: x(26), y(26)
    integer, allocatable :: next(:,:)
    integer :: i, j, ls, lt, first, tmp
    integer(8) :: ans
    read(*,*) s, t
    ls = len_trim(s)
    lt = len_trim(t)
    ss = trim(adjustl(s)) // trim(adjustl(s))
    allocate(next(ls, 26))
    x = .false.
    y = .false.
    next = 0
    do i = 1, ls
        x(ichar(s(i:i)) - ichar('a') + 1) = .true.
    end do
    do i = 1, lt
        y(ichar(t(i:i)) - ichar('a') + 1) = .true.
    end do

    ! do i = 1, 26
    !     if(x(i))then
    !         write(*,*) 'x', i
    !     end if
    !     if(y(i))then
    !         write(*,*) 'y', i
    !     end if
    ! end do

    do i = 1, 26
        if((x(i) .eqv. .false.) .and. (y(i) .eqv. .true.)) then
            write(*,'(a)') "-1"
            stop
        end if
    end do

    do i = 1, 26
        if(x(i) .eqv. .false.) then
            cycle
        end if
        do j = 1, ls
            if(s(j:j) == char(ichar('a') - 1 + i)) then
                first = j
                exit
            end if
        end do

        tmp = ls + first
        do j = ls + first - 1, first, -1
            next(mod(j - 1, ls) + 1, i) = tmp - j
            if(ss(j:j) == char(ichar('a') - 1 + i)) then
                tmp = j
            end if
        end do
    end do

    do j = 1, ls
        if(s(j:j) == t(1:1)) then
            first = j
            exit
        end if
    end do
    tmp = first
    ans = first
    do i = 2, lt
        ans = ans + next(tmp, ichar(t(i:i)) - ichar('a') + 1)
        tmp = mod(ans - 1, ls) + 1
    end do


    write(*,*) ans

    deallocate(next)
    stop
contains
end program prob5

Measured memory_bytes: 13756
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println(execute(sc.nextInt()));

    }

    public static int execute(int a1) {
        Set<Integer> numSet = new HashSet<>();
        int am = a1;
        while(!numSet.contains(am)){
            numSet.add(am);
            am = collatz(am);
        }
        return numSet.size() + 1;

    }

    public static int collatz(int n){
        if(n%2 == 0){
            return n / 2;
        }
        return 3 * n + 1;
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N,H, n,m , M, K,a;

vector<ll> v;
int main(){
	string s, t;
  	cin >> s >> t;
	vector<vector<int>> dp(t.size() + 1, vector<int> (s.size() + 1 , 0));
	for(int i= 1; i <= t.size(); ++i ){
		for(int j = 1; j <= s.size(); ++j){
			if(s[j-1] == t[i-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
     //     	cout << dp[i][j] << " ";
		}
     // cout << "\n";
	}

	string ans = "";
	int iter_s = s.size();
	int iter_t = t.size();
	while(iter_s > 0 and iter_t > 0 and dp[iter_t][iter_s] > 0){
		if(dp[iter_t][iter_s] == dp[iter_t][iter_s -1]) --iter_s;
		else if(dp[iter_t][iter_s] == dp[iter_t-1][iter_s]) --iter_t;
		else if(dp[iter_t][iter_s] == dp[iter_t-1][iter_s -1] + 1){
			ans.push_back(s[iter_s-1]);
			--iter_s;
			--iter_t;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}



Measured memory_bytes: 35584
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    H = sorted([int(i) for i in input().split()], reverse=True)
    if K >= len(H):
        print(0)
    else:
        print(sum(H[K:]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 26024
# ABC042 A  Iroha and Haiku (ABC Edition)
a,b,c = map(int,input().split())

count_five = 0
count_seven = 0

if a == 5:
    count_five += 1
elif a == 7:
    count_seven += 1

if b == 5:
    count_five += 1
elif b == 7:
    count_seven += 1

if c == 5:
    count_five += 1
elif c == 7:
    count_seven += 1

if count_five == 2 and count_seven == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define maxn 100005
#define INF 0x3f3f3f3f
#define mod 1000000007
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
using namespace std;

ll n,m,a[maxn];

void slove()
{
	cin >> n >> m;
	set<int> st;
	vector<set<int>> G(n+1);
	rep(i,1,n+1) cin>>a[i], st.insert(i);
	ll u,v,res=0;
	rep(i,0,m) {
		cin >> u >> v;
		//st.erase(u);st.erase(v);
		G[u].insert(v); G[v].insert(u);
	}
	rep(i, 1, n+1) {
		int flag = 1;
		//cout << i << "---\n";
		for(set<int>::iterator j = G[i].begin(); j != G[i].end(); j++) {
			//cout << "--j=" << *j << ' ';
			if (a[i] <= a[*j]) {flag = 0; break;}
		}
		if (flag) res++;
		//cout << "res=" << res << "--\n";
	}
	//cout << st.size() << '\n';
	//res+=st.size();
	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	slove();

	return 0;
}

Measured memory_bytes: 22732
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A[4];
	cin>>A[1]>>A[2]>>A[3];
	sort(A+1,A+1+3);
	if (A[1]<A[2] && A[2]<A[3]) printf("No\n");
	else if (A[1]==A[3]) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scanf("%d %d", &x, &y)

	if (y - 2 * x) % 2 != 0 {
		fmt.Printf("No")
		return
	}
	var b = (y - 2 * x) / 2
	var a = x - b
	if a < 0 || b < 0 {
		fmt.Printf("No")
	} else if (x == (a + b) && y == (2 * a + 4 * b)) {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}


Measured memory_bytes: 1820
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> weight(n);
  for(int i = 0; i < n; i++)
    cin >> weight.at(i);
  int total = 0;
  for(int i = 0; i < n; i++)
    total += weight.at(i);
  int diff = 10000;
  for(int i = 0; i < n; i++){
    int sum = 0;
    for(int j = 0; j < i; j++){
      sum += weight.at(j);
    }
    if(diff > abs((total - sum) - sum))
      diff = abs((total - sum) - sum);
  }
  cout << diff << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)

vector<long long int> divisor(long long int a) {
    vector<long long int> res;
    for (long long int i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            res.push_back(i);
            if (i != 1 && i * i != a)
                res.push_back(a / i);
        }
    }
    return res;
}

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

    long long int n;
    cin >> n;

    vector<long long int> a;

    a = divisor(n);

    int ans = 100;
    rep(i, a.size()) {
        string s, t;
        s = to_string(a[i]);
        t = to_string(n / a[i]);

        ans = min(ans, max((int)t.size(), (int)s.size()));
    }
    cout << ans << endl;
}

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

int gcd(long long a, long long b){
	if(a == 0)
	return b;
	if(b == 0)
	return a;

	if(a == b)
	return a;

	if(a > b)
	return gcd(a-b,b);
	return gcd(a,b-a);
}

int lcm(long long a, long long b){
	return (a*b)/gcd(a,b);
}
int arr[10001];
int main(){
	int n;
	cin >> n;
	if(n == 0){
	cout << "1" << endl;
	}
	else{
	cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£???
		Scanner sc = new  Scanner(System.in);
		//a?????\??????
		int a = sc.nextInt();
		//b?????\??????
		int b = sc.nextInt();
		//c?????\??????
		int c = sc.nextInt();
		//????????????
		int count =0;
		//?´???°?????°????????????
		for(int i= a; i <= b; i++){
			if(c % i <=0){
				count++;
			}else{

			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26304
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	char *p=strstr((char*)s.c_str(),"AC");
	if (p){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n+1];
  for(int i=1; i<=n; i++){
    cin>>a[i];
  }
  if(n%2==0){
	for(int i=n; i>=1; i-=2){
      cout<<a[i]<<" ";
    }
    for(int i=1; i<=n; i+=2){
      cout<<a[i]<<" ";
    }
  }
  else{
    for(int i=n; i>=1; i-=2){
      cout<<a[i]<<" ";
    }
    for(int i=2; i<=n; i+=2){
      cout<<a[i]<<" ";
    }
  }
  cout<<endl;
}

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

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a*c,max(a*d,max(b*c,b*d)));
}


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

using ll=long long;

int main() {
  int A,B,M; cin >>A >>B >>M;
  vector<int> a(A);
  rep(i,0,A) {cin >>a[i];}
  vector<int> b(B);
  rep(i,0,B) {cin >>b[i];}
  int ans=*min_element(a.begin(),a.end())+*min_element(b.begin(),b.end());
  rep(i,0,M) {
    int x,y,c; cin >>x >>y >>c;
    int temp=a[x-1]+b[y-1]-c;
    ans=min(ans,temp);
  }
  cout <<ans <<endl;
  return 0;
}


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

ll N, M;
vector<ll> x, y, z;

ll f(ll op1, ll op2, ll op3) {
  auto v = vector<ll>(N);
  for (int i = 0; i < N; ++i) {
    v[i] = op1 * x[i] + op2 * y[i] + op3 * z[i];
  }
  sort(begin(v), end(v), greater<ll>());

  ll res = 0;
  for (int i = 0; i < M; ++i) res += v[i];
  return res;
}

int main() {
  cin >> N >> M;
  x = y = z = vector<ll>(N);
  for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> z[i];

  ll ans = 0;
  for (int i = -1; i <= 1; i += 2) {
    for (int j = -1; j <= 1; j += 2) {
      for (int k = -1; k <= 1; k += 2) {
        ans = max(ans, f(i, j, k));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 and i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  int ans = 0;
  string w;
  cin >> w;
  vector<string> t;
  while(true) {
    string s;
    cin >> s;
    if(s == "END_OF_TEXT") break;
    for(int i = 0; i < s.size(); i++) s.at(i) = tolower(s.at(i));
    if(s == w) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3184
#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
    int H,W;
    while(1){
        cin >> H;
        cin >> W;
        if(H == 0 && W == 0){
            break;
        }
        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
                if((i % 2 == 0 && j % 2 == 1) || (j % 2 == 0 && i % 2 == 1) ){
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 100005;

int main() {
	int n, x;
	scanf("%d %d", &x, &n);
	set<int> s;
	while(n--) {
		int val;
		scanf("%d", &val);
		s.insert(val);
	}
	int pv = x, nx = x;
	while(s.count(pv)) pv--;
	while(s.count(nx)) nx++;

	if(x - pv <= nx - x) printf("%d\n", pv);
	else printf("%d\n", nx);
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int MOD = (int) 1e9+7;
		int [] array = new int[N+1];
		for(int i=1;i<=N;i++) {
			array[i] = sc.nextInt();
		}

		long[][] dp = new long[N+2][K+2];

		for(int i=0;i<=K;i++) {
			dp[1][i] = (i<=array[1]) ? 1 : 0;
		}


		for(int i=2;i<=N;i++){
			for(int j=0;j<=K;j++) {
				if (j==0) dp[i][j] = dp[i-1][j];
				else {
					long val = (j-1-array[i]) >= 0 ? dp[i-1][j-1-array[i]] : 0;		
					dp[i][j] = (MOD+ dp[i-1][j] + dp[i][j-1] - val)%MOD;	
				}				
			}
		}

		return dp[N][K];

	}

}

Measured memory_bytes: 140332
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
#define ll       long long

int char_cnt(string s,char a){
  int cnt=0;
  for(unsigned int i=0;i<s.size();i++){
    if(s[i]==a){
      cnt++;
    }
  }
  return cnt;
}

/*int main() {
  int n=0;
  string s;
  cin>>n>>s;
  ll ans=0;
  ans=(char_cnt(s,'R')*char_cnt(s,'B')*char_cnt(s,'G'));
  ll ans2=0;
  int r=0;
  int g=0;
  int b=0;
  rep(l, n) {
        if (s[l] == 'R') r++;
        if (s[l] == 'G') g++;
        if (s[l] == 'B') b++;
    }
  ans2=r*g*b;
  cerr<<ans-ans2;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k=2 * j - i;
      if(k>=n)continue;
      if((s[k]!=s[j])&&(s[j]!=s[i])&&(s[i]!=s[k]))ans--;
    }
  }
  cout<<ans;
}*/
int main() {
    int n; string s;
    cin >> n >> s;
 
    ll r=0, g=0, b=0;
    r=char_cnt(s,'R');
    g=char_cnt(s,'G');
    b=char_cnt(s,'B');
    ll ans = r*g*b;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int k = 2 * j - i;
            if (k >= n) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
import sys,itertools
if sys.version_info[0]>=3: raw_input=input

def dfs(a):
	if len(a)<2: yield (a[0],str(a[0]))
	for i in range(len(a)-1):
		for l in dfs(a[:i+1]):
			for r in dfs(a[i+1:]):
				yield (l[0]+r[0],'(%s + %s)'%(l[1],r[1]))
				yield (l[0]-r[0],'(%s - %s)'%(l[1],r[1]))
				yield (l[0]*r[0],'(%s * %s)'%(l[1],r[1]))

def solve(a):
	for e in itertools.permutations(a):
		for n,s in dfs(e):
			if n==10:
				print(s)
				return True

try:
	while True:
		a=[int(e) for e in raw_input().split()]
		if a==[0,0,0,0]: break
		if not solve(a): print(0)
except EOFError:
	pass

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int N;cin>>N;
    vector<double> x(N),y(N);
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i];
    }
    
    double dp[N][N];
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dp[i][j]=double(INF);
        }
    }
    
    dp[0][0]=0;
    dp[0][1]=hypot(x[1]-x[0],y[1]-y[0]);
    
    for(int j=1;j<N;j++){
        for(int i=0;i<j;i++){
            if(i==0&&j==1) continue;
            if(i+1==j){
                for(int k=0;k<i;k++){
                    dp[i][j]=min(dp[i][j],dp[k][i]+hypot(x[j]-x[k],y[j]-y[k]));
                }
            }else{
                dp[i][j]=min(dp[i][j],dp[i][j-1]+hypot(x[j]-x[j-1],y[j]-y[j-1]));
            }
        }
    }
    
    double ans=double(INF);
    
    for(int i=0;i<N;i++){
        ans=min(ans,dp[i][N-1]+hypot(x[N-1]-x[i],y[N-1]-y[i]));
    }
    
    cout<<setprecision(25)<<ans<<endl;
    
}




Measured memory_bytes: 11160
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, w, a, b, ans = 0;
  scanf("%lld%lld", &n, &w);
  ll dp[n * 1000 + 1];
  for(i = 0; i <= n * 1000; ++i) dp[i] = 1e18;
  dp[0] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a, &b);
    for(j = n * 1000; j >= 0; --j) if(j + b <= n * 1000 && dp[j] + a < dp[j + b]) dp[j + b] = dp[j] + a;
  }
  for(i = 0; i <= n * 1000; ++i) if(dp[i] <= w) ans = i;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 896
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
def inli()
  n = gets.to_i
  as = []
  n.times {
    as << gets.split.map(&:to_i)
  }
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

def get_GCD(m, n)
  tmp = [n, m].max
  n = [n, m].min
  m = tmp
  while n != 0
    tmp = m % n
    m = n
    n = tmp
  end
  m
end


n = i()
as =li()
bs = li()
sum = 0
n.times {|i|
  if as[i] >= bs[i]
    sum += bs[i]
  elsif bs[i]-as[i] > as[i+1]
    sum += as[i] + as[i+1]
    as[i+1] = 0
  else
    sum += bs[i]
    as[i+1] -= (bs[i]-as[i])
  end
}
p sum

Measured memory_bytes: 15500
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long N, W, H;
    cin >> N >> H >> W;
    long a; //たて
    long b; //横
    int ret = 0;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        if(a >= H && b>= W){
            ret++;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
S = list(input())
i=0
if(S[i]==S[i+1]==S[i+2]==S[i+3]):
    print('No')
elif S[i]==S[i+1] and S[i+2]==S[i+3]:
    print('Yes')
elif S[i]==S[i+2] and S[i+1]==S[i+3]:
    print('Yes')
elif S[i]==S[i+3] and S[i+1]==S[i+2]:
    print('Yes')

else:
    print('No')

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

int main() {
  int a, b;
  string op;
  for (;;) {
    cin >> a >> op >> b;
    if (op == "+") cout << a + b << endl;
    else if (op == "-") cout << a - b << endl;
    else if (op == "*") cout << a * b << endl;
    else if (op == "/") cout << a / b << endl;
    else break;
  }

  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>

using namespace std;

namespace {
constexpr char abc[] = "ABC";
}

int main() {
  int N;
  string str;
  cin >> N >> str;
 
  int64_t cnt = 0;
  size_t idx = 0;
  for (char c : str) {
    if (c == abc[idx]) {
      if (idx == 2) {
        ++cnt;
        idx = 0;
      } else {
        ++idx;
      }
    } else {
      if (c == abc[0]) {
        idx = 1;
      } else {
        idx = 0;
      }
    }
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
dp = [nil, false, false, false, true, false, false, true] # 1-7

N = $stdin.readline.to_i
for i in 8..N do
    dp << (dp[i-4] || dp[i-7])
    # puts "#{i} #{dp[i]}"
end

if dp[N] then
    puts "Yes"
else
    puts "No"
end


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

#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

long rec(long x)
{
    if(x == 0) return 0;
    long p = popcountll(x);
    return rec(x%p)+1;
}

void Main()
{
    long n;
    string xs;
    cin >> n >> xs;
    vector<int> xi(n);
    long xp = 0;
    for (int i = 0; i < n; i++)
    {
        int a = (xs[n-1-i] == '1' ? 1 : 0);
        xi[i] = a;
        xp += a;
    }

    if(xp != 1){
        vector<long> m1(n), m2(n);
        m1[0] = 1  % (xp-1);
        m2[0] = 1  % (xp+1);
        for (int i = 1; i < n; i++)
        {
            m1[i] = (m1[i-1]<<1) % (xp-1);
            m2[i] = (m2[i-1]<<1) % (xp+1);
        }
        long s1 = 0, s2 = 0;
        for (int i = 0; i < n; i++)
        {
            if(xi[i]){
                s1 = (s1 + m1[i])%(xp-1);
                s2 = (s2 + m2[i])%(xp+1);
            }
        }

        for (int i = 0; i < n; i++)
        {
            long xt;
            int idx = n-1-i;
            if(xi[idx]) {
                xt = (s1 - m1[idx])%(xp-1);
                xt = (xt + xp-1)%(xp-1);
            } else {
                xt = (s2 + m2[idx])%(xp+1);
            }
            cout << rec(xt)+1 << endl;
        }
    }else{
        vector<long> m1(n), m2(n);
        m2[0] = 1  % (xp+1);
        for (int i = 1; i < n; i++)
        {
            m2[i] = (m2[i-1]<<1) % (xp+1);
        }
        long s1 = 0, s2 = 0;
        for (int i = 0; i < n; i++)
        {
            if(xi[i]){
                s2 = (s2 + m2[i])%(xp+1);
            }
        }

        for (int i = 0; i < n; i++)
        {
            long xt;
            int idx = n-1-i;
            if(xi[idx]) {
                cout << 0 << endl;
            } else {
                xt = (s2 + m2[idx])%(xp+1);
                cout << rec(xt)+1 << endl;
            }
        }
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 7572
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 3048
package main

import "fmt"

func main() {
	var W, H, x, y float64
	fmt.Scan(&W, &H, &x, &y)
	p := 0
	if W/2 == x && H/2 == y {
		p = 1
	}
	a := W * H / 2
	fmt.Println(a, p)
}


Measured memory_bytes: 512
#include <stdio.h>

int graph[6][2] = {
	{1, 2},
	{-1, 3},
	{1, -1},
	{4, 5},
	{5, 2},
	{2, 1},
};

int main()
{
	char p[128];
	
	while (scanf("%s", p), *p != '#'){
		int i;
		int current = 0;
		
		for (i = 0; p[i] != 0; i++){
			current = graph[current][p[i] - '0'];
			if (current == -1) break;
		}
		puts(current == 5 ? "Yes" : "No");
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int a,b,c;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>a>>b>>c;
  for(int i=0;i<10;i++){
    c=c*a-b;
    cout<<c<<endl;
  }
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,K,t;
  t=0;
  cin >> N;
  cin >> K;
  vector<long long> vec(N);
  for (int i=0;i<N;i++) {
   cin >> vec.at(i);
  }
  //cout << vec.at(0) << vec.at(1) << vec.at(2) << vec.at(3) << vec.at(4) << endl;
  sort(vec.begin(),vec.end());
  //cout << vec.at(0) << vec.at(1) << vec.at(2) << vec.at(3) << vec.at(4) << endl;  
  for (int i=0;i<N-K;i++) {
    t=t+vec.at(i);
  }
cout << t << endl;
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {


    int getA,getB,max;
    int getTotal[3];

    cin >> getA >> getB ;

    if(getA > getB) max = 2*getA - 1;
    if(getB > getA) max = 2*getB - 1;
    if(getA ==getB) max = getA+getB;

    cout << max << endl;    

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    int len = s.length();
    bool ans = true;
    for (int i = 0; i < len; i++) {
        if (i % 2) {
            if (s[i] == 'R') {
                ans = false;
                break;
            }
        }
        else {
            if (s[i] == 'L') {
                ans = false;
                break;
            }
        }
    }
    if (ans) cout << "Yes" << E;
    else cout << "No" << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;

long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}


const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=400000;

ll n;
ll b0[62],b1[62];
ll a[MAX_N];

void twoadic(ll v){
    ll b=1LL<<59;
    for(ll i=0;i<=59;i++){
        if(v/b>0) {
            b1[59-i]++;
            v-=b;
        }
        else b0[59-i]++;
        b/=2;
    }
}

void solve(){
    rep(i,n){
        twoadic(a[i]);
    }
    ll ans=0;
    rep(i,60){
        ll pl=(1LL<<i) % MOD *b0[i];
        pl%=MOD;
        pl*=b1[i];
        ans+=pl;
        ans%=MOD;
    }
    cout << ans << endl;
}

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,60){
        b0[i]=0;b1[i]=0;
    }
    solve();
}

//twoadic(3);
// rep(i,61) cout << b0[i] << " " << b1[i] << endl;

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int H, W; cin >> H >> W;
    string s;
    rep(i, 0, H) {
        cin >> s;
        cout << s << endl << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x[] = {a, b, c};
    sort(x, x+3);

    if(x[0]+x[1] == x[2]) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b, c int
	var op string
	con.Scan(&a, &op, &b)
	switch op {
	case "+":
		c = a + b
	case "-":
		c = a - b
	}
	con.Println(c)
	return nil
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#include<vector>
#include<algorithm>
#include<string>
using ll=long long;
using P =pair<int,int>;


int main(){
  int n,m,sum=0;
  cin >> n >> m;
  vector<int>a(n);
  rep(i,n){cin >> a[i];sum+=a[i];}
  int cnt=n;
  rep(i,n){
    if(a[i]*4*m<sum)cnt--;
  }
  if(cnt>=m)cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long N, D, x, y, ans=0; cin >> N >> D;
REP(i, N){ 
  cin >> x >> y;
  if(x*x+y*y<=D*D){ ans++; }    
}
cout << ans << "\n";
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long  
#define pb push_back

		   //       |----|       /\      |    |   -----   |
		   //       |   /       /  \     |    |     |     |
		   //       |--/       /----\    |----|     |     |
		   //       |   \     /      \   |    |     |     |
		   //       |    \   /        \  |    |   -----   -------
int n;
int32_t main()
{
	IOS;
	cin>>n;
	string arr[n];
	int c1=0,c2=0,c12=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(arr[i][0]=='B'&&arr[i][arr[i].length()-1]=='A')
			c12++;
		else if(arr[i][0]=='B')
			c2++;
		else if(arr[i][arr[i].length()-1]=='A')
			c1++;
	}
	int ans=0;
	if(c1!=0&&c12!=0&&c2!=0)
	{
		c1--;
		ans+=c12;
		ans++;
		c2--;
		ans+=min(c1,c2);
	}
	else if(c1==0)
	{
		if(c2==0)
			ans=max(0ll,c12-1);
		else
			ans=c12;
	}
	else if(c2==0)
	{
		if(c1==0)
			ans=max(0ll,c12-1);
		else
			ans=c12;
	}
	else
		ans=min(c1,c2);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<arr[i].length()-1;j++)
		{
			if(arr[i][j]=='A'&&arr[i][j+1]=='B')
				ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 768
# RGB coloring


import math
mod = 998244353


class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def C(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def P(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


def main():
    N, A, B, K = map(int, input().split())
    c = Combi(N, mod)    
    res = 0
    for i in range(N+1):
        if (K-A*i) % B == 0 and K >= A*i:
            res += c.C(N, i)*c.C(N, (K-A*i)//B)
    res %= mod
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 117592
#include <iostream>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, stu;
    cin >> n;
    map<int, int> pos;
    for (int i = 1; i <= n; i++)
    {
        cin >> stu;
        pos[stu] = i;
    }
    for (auto m : pos)
    {
        cout << m.second << " ";
    }
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define int long long int

int a[22][22] ,dp[22][(1<<22)] , n ;

int f(int i,int mask)
{
    if( i == n ) return 1 ;
    if( dp[i][mask] != -1 ) return dp[i][mask] ;
    int ans = 0 ;
    for(int k=0;k<n;k++)
    {
        if( (a[i][k] == 1 ) and ( (mask&(1<<k)) == 0 ) )
            {
                ans += f( i+1 , mask|(1<<k) ) ;
                ans %= 1000000007 ;
            }
    }
    return  dp[i][mask] = ans ;
}

signed main()
{
   cin >> n ;
   
   for(int i=0;i<n;i++){
       for(int j=0;j<n;j++){
           cin >> a[i][j] ;
       }
       
       for(int j=0;j<( 1 << (n+1) ) ; j++ )
        dp[i][j] =-1 ;
   }
   
   cout << f( 0 , 0 ) ;
   
   return 0;
}


Measured memory_bytes: 690432
from heapq import heappush, heappop

N, K, C = map(int, input().split())
S = input()

if C == 0 :
  if K == S.count('o') :
    for i, s in enumerate(S) :
      if s == 'o' :
        print(i + 1)

else :
  N += 2
  S = 'x' + S + 'x'

  dpL = [0] * N
  dpR = [0] * N
  for l in range(1, N) :
    r = N - 1 - l
    dpL[l] = max(dpL[l - 1], int(S[l] == 'o'))
    dpR[r] = max(dpR[r + 1], int(S[r] == 'o'))
    if l - C - 1 >= 0 and S[l] == 'o' :
      dpL[l] = max(dpL[l], dpL[l - C - 1] + 1)
    if r + C + 1 < N and S[r] == 'o' :
      dpR[r] = max(dpR[r], dpR[r + C + 1] + 1)

  h = []
  for r in range(C + 1) :
    heappush(h, (-dpR[r], r))

  for l in range(1, N) :
    r = l - 1 + C + 1
    if r < N :
      cost = dpL[l - 1] + dpR[r]
    else :
      cost = dpL[l - 1]
    heappush(h, (-cost, r))
    while h[0][1] <= l :
      heappop(h)
    
    if -h[0][0] < K and S[l] == 'o' :
      print(l)

Measured memory_bytes: 70060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a+b)>23){
            System.out.println((a+b)-24);
        }else{
            System.out.println(a+b);
        }

    }

}


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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	ll x;
	cin >> x;

	ll y = x / 100;
	if (x % 100 <= y * 5)
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int X,Y; cin >> X >> Y;
  cout << X + Y / 2 << endl;
}

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

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (i == 0 || i == h - 1) cout << "#";
                else if (j == 0 || j == w - 1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3080
S = [int(x) for x in list(input())]

for i in range(8):
    ch = S[0]
    for j in range(3):
        if int(i/(2**j)) % 2 == 0:
            ch += S[j+1]
        else:
            ch -= S[j+1]
    if ch == 7:
        print(S[0],end='')
        for j in range(3):
            if int(i/(2**j)) % 2 == 0:
                print('+',end='')
            else:
                print('-',end='')
            print(S[j+1],end='')
        print('=7')
        break


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
		static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		string[] t=new string[2];
		t[1]=sc.S;
		int[] dp=new int[s[1]];
		Stack<Tuple<int,int>> stk=new Stack<Tuple<int,int>>();
		int ans=0,p=0;
		for(int i = 0;i<s[0];i++) {
			if(i!=s[0]-1){t[i&1]=sc.S;}
			p=0;
			for(int j = 0;j<s[1];j++) {
				dp[j]++;
				p=j;
				while(stk.Count>0&&stk.Peek().Item1>dp[j]){
					ans=Math.Max(ans,stk.Peek().Item1*(1+j-stk.Peek().Item2));
					p=stk.Peek().Item2;
					stk.Pop();
				}
				if(stk.Count==0||stk.Peek().Item1<dp[j]){stk.Push(Tuple.Create(dp[j],p));}
				if(j!=s[1]-1&&i!=s[0]-1&&((t[0][j]+t[0][j+1]+t[1][j]+t[1][j+1])&1)==1){dp[j]=0;}
			}
			while(stk.Count>0){
				ans=Math.Max(ans,stk.Peek().Item1*(s[1]-stk.Peek().Item2));
				stk.Pop();
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 33488
n = int(input())
s = []
for i in range(n):
    s0 = input()
    s.append(s0)
l = []
s.sort()
count = 0
for i in range(n-1):
    count += 1
    if s[i] == s[i+1]:
        continue
    else:
        l.append([s[i],count])
        count = 0
count += 1
l.append([s[n-1],count])
l.sort(key=lambda x:x[1],reverse=True)
m = len(l)
a = l[0][1]
for i in range(m):
    if l[i][1] == a:
        print(l[i][0])
    else:
        break

Measured memory_bytes: 39084
H, W = gets.split.map &:to_i
Board = $<.map{|s|
  s.chomp.chars.map{|c| c == ?. ? 1 : 0 }
}

DIRS = [[1, 0], [-1, 0], [0, 1], [0, -1]]

def f(y, x)
  visited = H.times.map{ [-1] * W }
  visited[y][x] = count = 0
  q = [[y, x]]
  while !q.empty?
    count += 1
    new_q = []
    q.each{|y, x|
      DIRS.each{|dy, dx|
        yy = y + dy
        xx = x + dx
        next if !yy.between?(0, H-1)
        next if !xx.between?(0, W-1)
        next if Board[yy][xx] != 1
        next if visited[yy][xx] > -1
        visited[yy][xx] = count
        new_q << [yy, xx]
      } 
    }
    q = new_q
  end
  max = count -1
  # yxs = []
  # H.times{|y|
  #   W.times{|x|
  #     yxs << [y, x] if visited[y][x] == max
  #   }
  # }
  # [max, yxs]
end

ans = 0
H.times{|y|
  W.times{|x|
    ans = [ans, f(y, x)].max if Board[y][x] == 1
  }
}
p ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;


void solve(){

    ll s,w;
    cin >> w >> s;
    if(s>=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;

}

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


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define PI 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
int main()
{
    FIO;
    ll n,k,i,j;
    cin>>n>>k;
    vvll grap(n+1);
    for(i=1; i<=n; i++)
    {
        cin>>j;
        grap[i].pb(j);
    }
    queue<int>q;
    q.push(1);
    vct<bool> vis(n+1);
    vis[1]=1;
    ll cnt=0,u;
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        cnt++;
        if(k==cnt)break;
        if(vis[grap[u][0]]){q.push(grap[u][0]);break;}
        vis[grap[u][0]]=1;
        q.push(grap[u][0]);
    }
    if(k==cnt)
        return cout<<grap[u][0]<<endl, 0;
    k-=cnt;
    cnt=1;
    ll v=q.front();
    q.pop();
    u = grap[v][0];
    q.push(u);
    while(v!=u)
    {
        u = grap[u][0];
        cnt++;
    }
    k%=cnt;
    while(k--)
    {
        v = grap[v][0];
    }
    cout<<v<<endl;
    return 0;
}
/**
3 3 10
60 1 2 2
70 1 2 2
50 1 2 2
**/


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> d(n);
    for(int i = 0; i < n; ++i)
        cin >> d[i];
    vector<int> u(m), v(m);
    vector<pair<int,int>> uvp;
    vector<vector<int>> edges(n);
    for(int i = 0; i < m; ++i){
        cin >> u[i] >> v[i];
        --u[i], --v[i];
        uvp.emplace_back(minmax(u[i], v[i]));
        edges[u[i]].emplace_back(v[i]);
        edges[v[i]].emplace_back(u[i]);
    }
    vector<int> col(n, -1);
    map<pair<int,int>, int> weight;

    function<void(int)> f = [&](int x){
        for(auto& y : edges[x]){
            if(col[y] != -1 || d[x] > d[y])
                continue;
            weight[minmax(x, y)] = d[y];
            col[y] = !col[x];
            f(y);
        }
    };

    for(int i = 0; i < m; ++i){
        if(d[u[i]] == d[v[i]] && col[u[i]] == -1 && col[v[i]] == -1){
            col[u[i]] = 0;
            col[v[i]] = 1;
            weight[uvp[i]] = d[u[i]];
            f(u[i]);
            f(v[i]);
        }
    }

    if(count(col.begin(), col.end(), -1)){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 0; i < n; ++i)
        cout << (col[i] ? 'B' : 'W');
    cout << endl;
    for(int i = 0; i < m; ++i)
        cout << (weight[uvp[i]] == 0 ? 1000000000 : weight[uvp[i]]) << endl;
}



Measured memory_bytes: 26096
#include<iostream>

using namespace std;

int main() {
	int n;
	int h[100000];
	int ans = 0;
	int f = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	h[0]--;

	for (int i = 0; i < n-1; i++) {
		if (h[i] > h[i + 1]) {
			f = 1;
			break;
		}
		
		if (h[i] < h[i+1]) {
			h[i + 1]--;
		}
	}

	if (f == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 640