akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

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

	string head, tale;
	int left = 0, right = 0;

	int l = S.length();
	REP(i, l) {
		if (S[i] == '(') {
			left++;
		}
		else {
			right++;
		}
		if (right > left) {
			head.push_back('(');
			left++;
		}
	}

	REP(i, left - right) {
		tale.push_back(')');
	}

	cout << head + S + tale << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
if N==1:
    print(1)
    exit()
T=[[A[0],A[1]]]
for i in range(2,N):
    if len(T[-1])<=1:
        T[-1].append(A[i])
        continue
    if not((T[-1][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[-1][0]<=A[i-2]<=A[i-1]<=A[i])):
        T.append([A[i]])
    else:
        T[-1].append(A[i])
print(len(T))


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

void solve () {
	ll a, b, ans = 0;
	scanf("%lld%lld",&a,&b);
	if(a>b) swap(a, b);
	ans = a-1;
	ll S = a+1, E = b;
	while(S<E) {
		ll M = (S+E)/2;
		M >= (a*b-1)/M ? E = M : S = M+1;
	}
	ans += S-a-1 + (a*b-1)/S;
	printf("%lld\n",ans);
}

int main()
{
	int q;
	scanf("%d",&q);
	while(q--) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
 if(n<m)
 {
   for(int i=0;i<m;i++)
     cout<<n;
 }
  else
  {
    for(int i=0;i<n;i++)
      cout<<m;
  }

}


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

int main(){
    int n, m;

    cin >> n >> m;

    vector<int> S[n+1];
    int v;

    for (int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;

        S[a].push_back(b);
        S[b].push_back(a);
    }

    queue<int> Q;
    vector<int> dist(n+1, -1);
    vector<int> pre(n+1, -1);

    Q.push(1);
    dist[1] = 1;


    while (!Q.empty()){
        v = Q.front();
        Q.pop();

        for(vector<int>::iterator it = S[v].begin(); it != S[v].end(); it++){
            if (dist[*it] != -1) continue;

            dist[*it] = dist[v] + 1;
            Q.push(*it);
            pre[*it] = v;
        }
    }

    cout << "Yes" << endl;
    
    for (int i = 1; i <= n; i++){
        if (i == 1) continue;
        else cout << pre[i] << endl;
    }

    return 0;

    
}

Measured memory_bytes: 10740
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    double ans = 0.;
    repi(i, n + 1, 1)
    {
        if (i % 2)
            ans += 1. / n;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int adj[101][101];

int main(void) {
  int n, node, k, c;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &node, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &c);
      adj[node][c] = 1;
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      printf("%d", adj[i][j]);
      if (j != n)
	printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i, j;
        i = sc.nextInt();
        j = sc.nextInt();
        if ((i + j) % 2 == 0) {
            System.out.println((i + j) / 2);
        } else {
            System.out.println((i + j) / 2 + 1);
        }

    }

}

Measured memory_bytes: 21716
class Card:
    def __init__(self, name, number):
        self.name = name
        self.number = number

    def __le__(self, other):
        return self.number <= other.number

    def __str__(self):
        return f'{self.name} {self.number}'


def partition(arr, p, r):
    x = arr[r]
    index = p - 1  # arr[p,index] <= x,arr[index+1,i)>x
    for i in range(p, r):
        if arr[i] <= x:
            arr[i], arr[index + 1] = arr[index + 1], arr[i]
            index += 1
    arr[index + 1], arr[r] = arr[r], arr[index + 1]
    return index + 1


def quick_sort(arr, l, r):
    if l >= r:
        return
    q = partition(arr, l, r)
    quick_sort(arr, l, q - 1)
    quick_sort(arr, q + 1, r)


if __name__ == '__main__':
    n = int(input())
    arr = []
    for _ in range(n):
        name, number = input().split()
        arr.append(Card(name, int(number)))
    sort_before_record = {}
    for ele in arr:
        if ele.number in sort_before_record:
            sort_before_record[ele.number].append(ele.name)
        else:
            sort_before_record[ele.number] = [ele.name]

    quick_sort(arr, 0, n - 1)

    sort_after_record = {}
    for ele in arr:
        if ele.number in sort_after_record:
            sort_after_record[ele.number].append(ele.name)
        else:
            sort_after_record[ele.number] = [ele.name]
    flag = True

    for key in sort_before_record:
        if sort_before_record[key] != sort_after_record[key]:
            flag = False
            break

    if flag:
        print('Stable')
    else:
        print('Not stable')
    for ele in arr:
        print(ele)



Measured memory_bytes: 34608
n = int(input())
mod = 10**9+7

def factors(N):
    factors = []
    while N%2 == 0:
        factors.append(2)
        N //=2

    for f in range(3, int(N**0.5)+ 1, 2):
        while N%f == 0:
            factors.append(f)
            N //= f
    if N != 1:
        factors.append(N)
    return factors

cd = dict()
for i in range(1, n+1):
    facs = factors(i)
    for f in facs:
        cd.setdefault(f, 0)
        cd[f] += 1

ans = 1
for key, v in cd.items():
    ans *= (v+1)
    ans %= mod

print(ans)


Measured memory_bytes: 9296
#include <bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n,k;
  cin>>n>>k;
  if(n%k==0)cout<<0<<endl;
  else cout<<1<<endl;






return 0;}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		ArrayList<Character> ansList = new ArrayList<>();
		int ans = 0;

		for (char c: s.toCharArray()){
			if (ansList.size() == 0){
				ansList.add(c);
			}else if (ansList.get(ansList.size()-1) != c){
				ansList.remove(ansList.size()-1);
				ans += 2;
			}else {
				ansList.add(c);
			}
		}
		System.out.println(ans);
	}
}


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

int main(void){
    int x, y, z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll gcd(ll a, ll b){
	if(a<b) swap(a, b);
	if(b==0) return a;
	return gcd(b, a%b);
}

int main(){
	int t;
	cin >> t;
	for(int i=0; i<t; i++){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		if(a<b || d<b) cout << "No" << endl;
		else if(b-1<=c) cout << "Yes" << endl;
		else{
			ll g=gcd(b, d);
			if(b-g+a%g<=c) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   int n,k;
   
   cin>>n>>k;
   
   int a[n];
   fr(i,n){
     cin>>a[i];
   }
   
   sort(a,a+n);
   int s=0;
   fr(i,k){
     s+=a[i];
   }
   
   cout<<s <<endl;
   return 0;
}
    

Measured memory_bytes: 3656
#include <iostream>
#include<vector>
#include<algorithm>
#define ll long long 
#define rep(n) for(int i=0;i<n;++i)
using namespace std;
int main(void){
    // Your code here!

int n;
cin>>n;
vector<int> vec(n);
rep(n){
    cin>>vec[i];
}

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

long double sum=0;

sum= vec[0];
for(int i=1;i<n;i++){
    sum= (sum+vec[i])/2;
}
cout<<sum;
}


Measured memory_bytes: 3248
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && y-r>=0){
		if(x+r<=W && y+r<=H){
			printf("Yes\n");
	    }
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2696
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int d[100];
    vector<int> v;
    int cnt = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&d[i]);
    }

    for(int i=0;i<n;i++){
        if(find(v.begin(),v.end(),d[i]) == v.end()){
            v.push_back(d[i]);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void)
{
  int x,n,a[201],p,ans=0,d,i;
  for(i=0;i<=200;i++){a[i]=0;}
  cin>>x>>n;
  for(i=0;i<n;i++)
  {
    cin>>p;
    a[p]=1;
  }
  bool f=0;
  for(i=x;i>=0;i--)
  {
    if(a[i]==0)
    {
      ans=i;
      d=x-i;
      break;
    }
  }
  for(i=x;i<x+d;i++)
  {
    if(a[i]==0)
    {
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[3];
int main(){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[2]==a[0]+a[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
  ll n, ans = 0;
  cin >> n;
  vector<ll> A(n);
  RAP(i,n){
    cin >> A[i];
  }
  sort(A.begin(), A.end(), std::greater<ll>());
  ans += A[0];
  ll check = 0, idx = 1;
  FOR(i,2,n){
    ans += A[idx];
    if(++check==2){
      check = 0;
      idx++;
    }
  }
  cout << ans << endl;
}


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

int main(){
  using namespace std;
  int n;
  string str;
  vector<string> s;
  cin >> n;
  while(getline(cin,str)){
    s.push_back(str);
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << s.size()-1 << endl;
  return 0;
}


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

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

int main() {
  int tmp_min=0;
  string s;
  cin >> s;
  int count = 0;
  string acgt = "ACGT";
  rep(i, s.size()) {
    if (acgt.find(s[i]) != string::npos) {
      tmp_min = max(++count, tmp_min);
    }else {
      count = 0;
    }
  }
  cout << tmp_min << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
def main(n,m,c):
    cost_map = dict([(i, [])for i in range(1,m+1)])
    for a, b in c:
        if a <= m:
            cost_map[a].append(b)
        
    hp =[]
    ret = 0
    for i in range(1, m+1):
        costs = cost_map[i]
        [heapq.heappush(hp, -c) for c in costs]
        if(len(hp) > 0):
            c = heapq.heappop(hp)
            ret -= c
    return ret
if __name__ == "__main__":
    n,m = map(lambda x: int(x), input().strip().split())
    c = [ list(map(lambda x: int(x), input().strip().split())) for i in range(n)]
    print(main(n,m,c))

Measured memory_bytes: 55072
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define ll long long
#define ld long double
#define ss string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) \
  for (int i = l; (l > r ? i >= r : i <= r); (l > r ? i-- : i++))
#define pb push_back
#define pc __builtin_popcount
#define pcll __builtin_popcountll
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
using namespace std;
ll n;
ss s[500];
int main() {
  speed;
  oprecision;
  // code
  cin >> n;
  s[1] = s[0] = s[6] = s[8] = "pon";
  s[3] = "bon";
  s[2] = s[4] = s[5] = s[7] = s[9] = "hon";
  cout << s[n % 10];
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

int H, W, N;
int ix, iy;
string S, T;

bool solve() {
    // left, right
    int left = 0, right = W;
    if (S[N-1] == 'L') ++left;
    if (S[N-1] == 'R') --right;
    for (int i = N-2; i >= 0; --i) {
        if (T[i] == 'L') right = min(right+1, W);
        else if (T[i] == 'R') left = max(0, left-1);
        if (S[i] == 'L') left = left + 1;
        else if (S[i] == 'R') right = right - 1;
        if (left >= right) return false;
    }
    if (iy < left || iy >= right) return false;

    // up, down
    left = 0, right = H;
    if (S[N-1] == 'U') ++left;
    if (S[N-1] == 'D') --right;
    for (int i = N-2; i >= 0; --i) {
        if (T[i] == 'U') right = min(right+1, H);
        else if (T[i] == 'D') left = max(0, left-1);
        if (S[i] == 'U') left = left + 1;
        else if (S[i] == 'D') right = right - 1;
        if (left >= right) return false;
    }
    if (ix < left || ix >= right) return false;

    return true;
}

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

  while (cin >> H >> W >> N >> ix >> iy >> S >> T) {
    --ix, --iy;
    if (solve()) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}


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

int main() {

  while(1) {

    int n, x;
    cin >> n >> x;

    if (n == 0 && x == 0) {
      return 0;
    }

    int answer = 0;

    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        for (int k = j + 1; k <= n; k++) {
          if (i + j + k == x) {
            answer++;
          }
        }
      }
    }

    cout << answer << endl;

  }

  return 0;

}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n;
int main(){
	n=read();
	double tmp=n/3.0;
	printf("%.10lf\n",tmp*tmp*tmp);
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc116/tasks/abc116_c
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <vector>
#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define MOD 1000000007
using namespace std;

int getMax(vector<int> v) {
    int maxElement = *std::max_element(v.begin(), v.end());
    return maxElement;
}

int solve(int n, vector<int> h) {
    int m = getMax(h);
    int c = 0;
    bool seq = false;

    rep(i, 1, m + 1) {
        rep(j, 0, n) {
            if (h[j] >= i) {
                if (!seq) {
                    c++;
                    seq = true;
                }
            } else {
                seq = false;
            }
        }
        seq = false;
    }
    return c;
}

int main() {
    int n, hi;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<int> h;

    rep(i, 0, n) {
        cin >> hi;
        h.push_back(hi);
    }

    int ans = solve(n, h);
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define enld endl
int main(){
    int i,j,k;
    string s;
    cin>>i>>j>>k;
    cout<<min(i*j,k)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(x=0;x<(to);x++)

std::vector<int> to[200000];
std::vector<int> ans;

void dfs(int v,int p=-1){
    for (int u : to[v])
    {
        if (u==p)continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}

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

    for (int i = 0; i < n-1; ++i)
    {
        int a,b;cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    ans.resize(n);
    for (int i = 0; i < q; ++i)
    {
        int p,x;std::cin >> p>>x;
        --p;
        ans[p]+=x;
    }

    dfs(0);
    for(int i=0;i<n;i++){
    
        cout<<ans[i]<<' ';
    }
    

}






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

int main(void) {
  int n, x, y;
  
  cin >> n >> x >> y;
  
  long long l[3000];
  
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int len1 = j-i-1;
      int len2 = abs(x-i-1) + abs(y-j-1);
      int len3 = abs(y-i-1) + abs(x-j-1);
      l[min({len1, len2, len3})]++;
    }
  }
  
  for(int i = 0; i < n-1; i++) {
    cout << l[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
"""
imos方を使えばよさそう
imos[i][0] => iマス目に到達する場合の数
imos[i][1] => imosの累積
imos[i+l][1] += imos[i]
imos[i+r+1][1] -= imos[i]
"""
mod = 998244353
N,K = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(K)]

imos = [[0]*2 for _ in range(N)]
imos[0][0] = 1

for i in range(N):
    if i > 0:
        imos[i][1] += imos[i-1][1]
        imos[i][1] %= mod
    imos[i][0] += imos[i][1]
    for l,r in LR:
        if i+l < N:
            imos[i+l][1] += imos[i][0]
            imos[i+l][1] %= mod
        if i+r+1 < N:
            imos[i+r+1][1] -= imos[i][0]
            imos[i+r+1][1] %= mod
print(imos[-1][0])



Measured memory_bytes: 94516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807


int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> v;
ll asum=0,bsum=0;
rep(i,n){
  ll a , b ;
  cin >> a >> b ;
  asum+=a;
  bsum+=b;
  v.push_back({a,i});
  v.push_back({b,i});
}
sort(v.begin(),v.end());
set<ll> s;
rep(i,n){
  ans+=v[i].first;
  s.insert(v[i].second);
}
ll anss=INF;
if(s.size()==n){
  if(v[n].second==v[n-1].second){
    anss=ans;
    ans-=v[n-2].first;
    anss+=v[n+1].first;
    anss-=v[n-1].first;
  }
  else ans-=v[n-1].first;
  ans+=v[n].first;
}
ans=min({ans,asum,bsum,anss});
cout << ans << endl;
return 0;
}


Measured memory_bytes: 8684
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a,b,c;

void input(){
    cin >> a >> b >> c;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    if(a == b && b == c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int n;
int a[55];
long long ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans+=a[i]*a[j];
	cout<<ans;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
  int n, l;
  cin >> n >> l;
  string s[n];
  for(int i = 0; i < n; i++)
    cin >> s[i];
 
  sort(s, s + n);
 
  for(int i = 0; i < n; i++)
    cout << s[i];
 
  cout << endl;
      
    
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>

int bit_count(int value) {
	int count = 0;
	while (value > 0) {
		count += value & 1;
		value >>= 1;
	}
	return count;
}
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int height, width, piece; std::cin >> height >> width >> piece;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	std::vector<std::vector<int>> sum(height + 1, std::vector<int>(width + 1, 0));
	for (auto i = 0; i < height; ++i) for (auto j = 0; j < width; ++j) {
		sum[i + 1][j + 1] = state[i][j] - '0';
		sum[i + 1][j + 1] += sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
	}
	int min_cut = INT_MAX;
	for (auto h = 1 << height; h < (2 << height); h += 2) {
		auto cut = bit_count(h) - 1;
		int last{ 0 }, count{ 0 };
		for (auto j = 1; j <= width; ++j) {
			int upper{ 0 };
			bool is_cut{ false };
			for (auto i = 1; i <= height; ++i) {
				if ((h & (1 << i)) != 0) {
					if (sum[i][j] - sum[i][last] - sum[upper][j] + sum[upper][last] > piece) {
						if (last + 1 == j) {
							cut = height * width;
							break;
						}
						is_cut = true;
					}
					upper = i;
				}
			}
			if (is_cut) {
				++cut;
				last = j - 1;
			}
		}
		if (min_cut > cut) {
			min_cut = cut;
		}
	}
	std::cout << min_cut << std::endl;
}

Measured memory_bytes: 384
def inpl():
    return list(map(int, input().split()))


def simulate(i):
    for t, d in td:
        if i == -1 or i == N:
            return i
        elif S[i] != t:
            continue
        elif d == "L":
            i -= 1
        elif d == "R":
            i += 1
    return i


N, Q = inpl()
S = input()
td = [input().split() for i in range(Q)]

# right find
right = N
left = 0
while right - left > 0:
    if simulate((right + left) // 2) == N:
        right = (right + left) // 2
    else:
        left = (right + left) // 2 + 1
if right == N and simulate(N - 1) != N:
    right_limit = N
else:
    right_limit = right

# left find
right = N
left = 0
while right - left > 0:
    if simulate((right + left) // 2) == -1:
        left = (right + left) // 2 + 1
    else:
        right = (right + left) // 2
if right == 0 and simulate(0) != -1:
    left_limit = 0
else:
    left_limit = right

# print(left_limit)
# print(right_limit)
if left_limit >= right_limit:
    print(0)
else:
    print(N - (left_limit + N - right_limit))


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

int calc(int n, int x)
{
	int res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (i + j + k == x) {
					res++;
				}
			}
		}
	}
	return res;
}

int main()
{
	int n, x;
	while (cin >> n >> x, n || x) {
		cout << calc(n, x) << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

typedef pair<int, ll> type;
typedef pair<int,type> event;
vector<event> table;

int n,q;
int main(){
    cin >> n >> q;
    int s,t,x,d;
    rep(i,n){
        cin >> s >> t >> x;
        table.push_back(event(s-x,type(0,x)));
        table.push_back(event(t-x,type(-1,x)));
    }
    rep(i,q){
        cin >> d;
        table.push_back(event(d,type(1,i)));
    }
    stable_sort(table.begin(),table.end());
    int ans[q];
    multiset<int> xs;
    xs.clear();
    rep(i,table.size()){
        int t=table[i].first,x=table[i].second.second,b=table[i].second.first;
        if (b==0) xs.insert(x);
        else if (b==-1) xs.erase(xs.lower_bound(x));
        else if (b==1) {
            if(xs.empty()){
                ans[x]=-1;
            }else{
                auto itr = xs.begin();
                ans[x]=*itr;
            }
        }
        //cout << b << " " << xs.size() <<endl;
    }
    rep(i,q){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 30564
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,j;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;
    
    for(i=1;i<=H;++i){
        if(i%2){
        for(j=1;j<=W;++j){
            if(j%2){
                cout << "#";
            }else{
                cout << ".";
            }
        }    
        }else{
            for(j=1;j<=W;++j){
                if(j%2){
                cout << ".";    
                }else{
                cout << "#";
                }
            }
        }cout << endl;
    }
    cout << endl;}
}


Measured memory_bytes: 3028
from collections import deque
h,w,k = map(int,input().split())
a,b,c,d = map(int,input().split())
a -= 1
b -= 1
c -= 1
d -= 1
maze = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
depth = [[float("inf") for _ in range(w)] for _ in range(h)]
dq = deque([(b,a)])
depth[a][b] = 0
while dq:
    x,y = dq.popleft()
    if x == d and y == c:
        break
    for i in range(4):
        nx,ny,K = x,y,k
        while K:
            K -= 1
            nx += dx[i]
            ny += dy[i]
            if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "@" and depth[ny][nx] > depth[y][x]:
                if depth[ny][nx] == depth[y][x]+1:
                    continue
                depth[ny][nx] = depth[y][x] +1
                dq.append((nx,ny))
            else:
                break
print(depth[c][d] if depth[c][d] != float("inf") else -1)

Measured memory_bytes: 55216
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 500050
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int l = 1, r = 0;
    int a[N];
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        r = max(r, a[i]);
    }
    while (l != r)
    {
        int mid = (l+r)/2;
        ll c = 0;
        for(int i=0; i<n; i++)
        {
            c += (a[i]-1)/mid;
        }
        if (c <= k)
            r = mid;
        else
            l = mid+1;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 4340
def main():
    H, W, M = (int(i) for i in input().split())
    hc = [0]*(H+1)
    wc = [0]*(W+1)
    maps = set()
    for _ in range(M):
        h, w = (int(i) for i in input().split())
        hc[h] += 1
        wc[w] += 1
        maps.add((h, w))
    mah = max(hc)
    maw = max(wc)
    ans = mah+maw
    hmaps = []
    wmaps = []
    for i, h in enumerate(hc):
        if mah == h:
            hmaps.append(i)
    for i, w in enumerate(wc):
        if maw == w:
            wmaps.append(i)

    if M < len(hmaps) * len(wmaps):
        # 爆破対象の合計が最大になるマスがM個より多ければ，
        # 必ず爆破対象がないマスに爆弾を置くことができる
        # 逆にM個以下なら3*10^5のループにしかならないので
        # このようにif文で分けなくても，必ずO(M)になるのでelse節のforを回してよい
        print(ans)
    else:
        for h in hmaps:
            for w in wmaps:
                if (h, w) not in maps:
                    print(ans)
                    return
        else:
            print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 166904
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;


void solve(){
  int x, y, z; cin >> x >> y >> z;
  x -= z;
  cout << x / (y + z) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void) {

	int a = 0, b = 0;
	scanf("%d", &a);
	scanf("%d", &b);

	if (a <= b) {

		printf("%d", a);
	}
	else {

		printf("%d", a - 1);

	}

	return 0;

}



Measured memory_bytes: 128
a_1= [[0 for i in range(10)] for j in range(3)]
a_2= [[0 for i in range(10)] for j in range(3)]
a_3= [[0 for i in range(10)] for j in range(3)]
a_4= [[0 for i in range(10)] for j in range(3)]

def print_ninzu(a):
    print("",end=" ")
    print(" ".join(map(str,a[0])))
    print("",end=" ")
    print(" ".join(map(str,a[1])))
    print("",end=" ")
    print(" ".join(map(str,a[2])))

n = int(input())
for i in range(n):
    com = list(map(int,input().split()))
    if com[0] == 1:
        a_1[com[1]-1][com[2]-1] += com[3]
    if com[0] == 2:
        a_2[com[1]-1][com[2]-1] += com[3]
    if com[0] == 3:
        a_3[com[1]-1][com[2]-1] += com[3]
    if com[0] == 4:
        a_4[com[1]-1][com[2]-1] += com[3]    
        
print_ninzu(a_1)
print("####################")
print_ninzu(a_2)
print("####################")
print_ninzu(a_3)
print("####################")
print_ninzu(a_4)

Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void Merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  for(int i = 0; i < n1; i++) L[i] = A[left + i];
  for(int i = 0; i < n2; i++) R[i] = A[mid + i];

  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for(int k = left; k < right; k++){
    if(L[i] <= R[j]){ // L < R 小さい方を左から挿入していく
      A[k] = L[i++];
    } else { // R < L
      A[k] = R[j++];
    }
    cnt++;
  }
}

void MergeSort(int A[], int n, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    MergeSort(A, n, left, mid);
    MergeSort(A, n, mid, right);
    Merge(A, n, left, mid, right);
  }
}

int main() {
  int n, A[MAX], i;
  cnt = 0;

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

  MergeSort(A, n, 0, n);

  for(int i = 0; i < n; i++){
    if ( i < n - 1 ) printf("%d ", A[i]);
    else printf("%d\n", A[i]);
  }

  printf("%d\n", cnt);

  return 0;
}



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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        long n=fsc.nextLong();
        long a=fsc.nextLong();
        long b=fsc.nextLong();
        fsc.close();
        if((a-b)%2==0){
            System.out.println(Math.abs((a-b)/2));
        }
        else{
            long lmin=Math.min(a-1, b-1);
            long lmax=Math.max(a-1, b-1);
            long rmin=Math.min(n-a, n-b);
            long rmax=Math.max(n-a, n-b);
            System.out.println(Math.min(lmin+1+(lmax-lmin-1)/2, rmin+1+(rmax-rmin-1)/2));
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 23124
N = int(input())
H = list(map(int,input().split())) + [10**9+7]

count = 0
ans = 0

for i in range(N):
    if H[i] >= H[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0

print(ans)

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    int M = 30;
    vector<queue<int>> q(M);
    for ( int j = 0; j < M; j++ ) {
        q[j].push(-1);
        q[j].push(-1);
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ll a = A[i];
        int md = N+1;
        for ( int j = 0; j < M; j++ ) {
            if ( (a>>j) & 1 ) {
                q[j].push(i);
                q[j].pop();
            }
            int d = i - q[j].front();
            if ( md > d ) md = d;
        }
        ans += md;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

bool is_frame(int H, int W, int x, int y){
	if(x == 1 || x == W) return true;
	if(y == 1 || y == H) return true;
	return false;
}

int main(){
	int H, W;

	while(true){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int y = 1; y <= H; y++){
			for(int x = 1; x <= W; x++){
				if(is_frame(H, W, x, y)) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll A,B,K;
    cin >> A >> B >> K;

    for(ll i = A;i <= min(B,A+K-1);i++)
        cout << i << endl;

    
    for(ll i = max(B-K+1,A+K);i <= B;i++)
        cout << i << endl;


    return 0;

}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$r = [];
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s %d", $s, $p);
    $r[] = [
        's' => $s,
        'p' => $p,
        'i' => $i + 1
    ];;
}
$sort_key = [];
$sort_key['s'] = array_column($r, 's');
$sort_key['p'] = array_column($r, 'p');

array_multisort(
    $sort_key['s'], SORT_ASC, SORT_STRING,
    $sort_key['p'], SORT_DESC, SORT_NUMERIC,
    $r
);
for ($i = 0; $i < $n; $i++) {
    echo $r[$i]['i']."\n";
}
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

long int a,b,n;

long int compute(long int x){
	long int val1 = (a * x) / b;
	long int val2 = x / b;
	val2 *= a;

	return val1 - val2;
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   cin>>a>>b>>n;

   long int ans = 0;

   ans = max(ans,compute(n));
   if(n > 0)
   	ans = max(ans,compute(n - 1));

   if(a > 0 && a <= n)
   	ans = max(ans,compute(a));

   if(a > 1 && a - 1 <= n)
   	ans = max(ans,compute(a - 1));

   if(b > 0 && b <= n)
   	ans = max(ans,compute(b));

   if(b > 1 && b - 1 <= n)
   	ans = max(ans,compute(b - 1));

   cout<<ans;

   return 0;
}

Measured memory_bytes: 3636
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
W,H,N = inputlist()
flag = [[True]*(H+1) for _ in range(W+1)]
def search(x,y,a):
    if a == 3:
        for i in range(W+1):
            for j in range(y+1):
                flag[i][j] = False
    if a == 4:
        for i in range(W+1):
            for j in range(y+1,H+1):
                flag[i][j] = False
    if a == 2:
        for i in range(x+1,W+1):
            for j in range(H+1):
                flag[i][j] = False
    if a == 1:
        for i in range(x+1):
            for j in range(H+1):
                flag[i][j] = False
for i in range(N):
    x,y,a = inputlist()
    search(x,y,a)
ans = 0
for i in range(1,W+1):
    for j in range(1,H+1):
        if flag[i][j]:
            ans +=1
print(ans)

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
   ll a, b, x;
   cin >> a >> b >> x;
   ll ans;
   if(a > 0)
   {
       ans = b/x - (a-1)/x;
   }
   else
   {
       ans = b/x + 1;
   }

   cout << ans << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int q = Integer.parseInt(sc.next());
    List<Rule> rules = new ArrayList<>();
    for (int i = 0; i < q; i++) {
      rules.add(
        new Rule(
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next()),
          Integer.parseInt(sc.next())
        )
      );
    }
    RuleList ruleList = new RuleList(rules);
    int array[] = new int[n];
    pw.println(dfs(0, 0, m, array, ruleList));
  }

  static long dfs(int index, long max, int m, int[] array, RuleList ruleList) {
    if (index == array.length) {
      return ruleList.calc(array);
    }
    int begin = index == 0 ? 1 : array[index - 1];
    for (int i = begin; i <= m; i++) {
      array[index] = i;
      max = Math.max(max, dfs(index + 1, max, m, array, ruleList));
    }
    return max;
  }

  static class RuleList {

    private List<Rule> rules;

    RuleList(List<Rule> rules) {
      this.rules = rules;
    }

    long calc(int[] array) {
      return rules.stream().mapToInt(rule -> rule.calc(array)).sum();
    }
  }

  static class Rule {

    int a;
    int b;
    int c;
    int d;

    public Rule(int a, int b, int c, int d) {
      this.a = a;
      this.b = b;
      this.c = c;
      this.d = d;
    }

    int calc(int[] array) {
      if (array[b - 1] - array[a - 1] == c) {
        return d;
      }
      return 0;
    }
  }
}


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

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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  int mx = gcd(A, B);
  vector<int> ans;
  for (int i = 1; i <= mx; i++)
  {
    if (mx % i == 0)
    {
      ans.push_back(i);
    }
  }
  cout << ans[ans.size() - K] << endl;
  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, M;
    cin >> N >> M;

    vector<vector<int>> G(N, vector<int>(0));
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<lint> color(N, -1);
    lint c = 0;
    for (int i = 0; i < N; i++) {
        if (color[i] != -1) continue;
        color[i] = c;
        queue<int> q({i});
        while (!q.empty()) {
            int cn = q.front();
            q.pop();
            for (auto nn : G[cn]) {
                if (color[nn] == -1) {
                    color[nn] = c;
                    q.push(nn);
                }
            }
        }
        c++;
    }

    vector<lint> cnt(c, 0);
    for (int i = 0; i < N; i++) {
        cnt[color[i]]++;
    }

    lint ma = -1;
    for (int i = 0; i < c; i++) {
        ma = max(ma, cnt[i]);
    }
    cout << ma << endl;

    // dump(cnt);
    return 0;
}

Measured memory_bytes: 16468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		if(a == b && a != c) {
			System.out.println("Yes");
		}
		else if(b == c && b != a) {
			System.out.println("Yes");
		}
		else if(a == c && b != c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
int a,b;
  cin>>a>>b;
  if(a<=5) cout<<0;
  else if(a<13) cout<<b/2;
  else cout<<b;
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256