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

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

using namespace std;

const double EPS=1e-8;

struct point3{
	double x,y,z;
	point3():x(0),y(0),z(0){}
	point3(double x,double y,double z):x(x),y(y),z(z){}
	point3 &operator+=(const point3 &a){ x+=a.x; y+=a.y; z+=a.z; return *this; }
	point3 &operator-=(const point3 &a){ x-=a.x; y-=a.y; z-=a.z; return *this; }
	point3 &operator*=(double c){ x*=c; y*=c; z*=c; return *this; }
	point3 &operator/=(double c){ x/=c; y/=c; z/=c; return *this; }
	point3 operator+(const point3 &a)const{ return point3(x+a.x,y+a.y,z+a.z); }
	point3 operator-(const point3 &a)const{ return point3(x-a.x,y-a.y,z-a.z); }
	point3 operator/(double c)const{ return point3(x/c,y/c,z/c); }
	point3 operator-()const{ return point3(-x,-y,-z); }
};

point3 operator*(double c,const point3 &a){ return point3(c*a.x,c*a.y,c*a.z); }

double dot(const point3 &a,const point3 &b){ return a.x*b.x+a.y*b.y+a.z*b.z; }

point3 cross(const point3 &a,const point3 &b){ return point3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x); }

double abs(const point3 &a){ return sqrt(a.x*a.x+a.y*a.y+a.z*a.z); }

double abs2(const point3 &a){ return a.x*a.x+a.y*a.y+a.z*a.z; }

point3 rot(const point3 &p,const point3 &a,double t){
	return cos(t)*p+(1-cos(t))*dot(p,a)*a+sin(t)*cross(a,p);
}

struct line3{
	point3 a,b;
	line3(){}
	line3(const point3 &a,const point3 &b):a(a),b(b){}
};

struct sphere{
	point3 c;
	double r;
	sphere():c(point3(0,0,0)),r(0){}
	sphere(const point3 &c,double r):c(c),r(r){}
};

point3 proj(const point3 &p,const line3 &L){ return L.a+dot(p-L.a,L.b-L.a)/abs2(L.b-L.a)*(L.b-L.a); }

double dist(const point3 &a,const point3 &b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

double dist(const line3 &L,const point3 &p){
	return abs(cross(L.b-L.a,p-L.a))/abs(L.a-L.b);
}

int get_intersect(const sphere &S,const line3 &L,vector<point3> &res){
	point3 h=proj(S.c,L);
	double d=abs(S.c-h);
	if(d>S.r+EPS) return 0;
	if(d>S.r-EPS){
		res.push_back(h);
		return 1;
	}
	else{
		point3 v=L.b-L.a;
		v*=sqrt(S.r*S.r-d*d)/abs(v);
		res.push_back(h+v);
		res.push_back(h-v);
		return 2;
	}
}

int main(){
	for(int n;scanf("%d",&n),n;){
		point3 v; scanf("%lf%lf%lf",&v.x,&v.y,&v.z);
		sphere S[100];
		rep(i,n) scanf("%lf%lf%lf%lf",&S[i].c.x,&S[i].c.y,&S[i].c.z,&S[i].r);

		point3 p;
		while(1){
			int i_next=-1;
			point3 next;
			line3 L(p,p+v);
			rep(i,n) if(dot(v,S[i].c-p)>EPS) {
				vector<point3> Q;
				get_intersect(S[i],L,Q);
				rep(j,Q.size()){
					point3 q=Q[j];
					if(i_next==-1 || dist(p,next)>dist(p,q)) i_next=i, next=q;
				}
			}
			if(i_next==-1) break;

			point3 nor=next-S[i_next].c;
			double phi=acos(dot(-v,nor)/abs(v)/abs(nor));
			point3 h=cross(nor,-v); h/=abs(h);
			v=rot(-v,h,-2*phi);
			p=next;
		}

		printf("%.9f %.9f %.9f\n",p.x,p.y,p.z);
	}

	return 0;
}

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

typedef long long ll;

int main() {
	int n;

	std::deque<ll> deq;
	std::cin >> n;
	int r = n % 2;
	for(int i = 0; i < n; ++i) {
		ll a;
		std::cin >> a;
		if(i % 2 == r) {
			deq.push_back(a);
		} else {
			deq.push_front(a);
		}
	}

	for(int i = 0; i < n; ++i) {
		std::cout << deq[i] << " ";
	} std::cout << std::endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
const long long MAX=510000;

//階乗,逆元,逆元の階乗
long long fac[MAX],finv[MAX],inv[MAX];

//テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

//二項係数計算
long long COM(long long n,long long k){
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    COMinit();
    long long h,w,a,b; cin>>h>>w>>a>>b;
    long long ans=0;
    for(long long i=0;i<h-a;i++){
        ans+=(COM(i+b-1,b-1)*COM((h-i-1)+(w-b-1),h-i-1))%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12160
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

ans = 1
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            ans = 0


if ans:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 67436
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
		t *= 2;
	} 
	//
	int d = 0;
	for (int i = 0; i + 1 < n; i++) {
		if (i % 2 == 0) d += a[i];
		else d -= a[i];
	}
	int s = a[n - 1];
	{
		//d[n - 1] + d[0] = s
		//d[0] - d[n - 1] = d
	}
	vector<int> ans(n);
	ans[0] = (s + d) / 2;
	for (int i = 1; i <  n; i++) {
		ans[i] = (a[i - 1] - ans[i - 1]);
	}
	for (auto t : ans) {
		cout << t << ' ';
	}
	cout << endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n], buf[n+1];
    for (auto &ai:a) cin >> ai;
    for (int i=0; i<k; i++) {
        fill(buf, buf+n, 0);
        for (int j=0; j<n; j++) {
            buf[max(0,   j-a[j])]++;
            buf[min(n, j+a[j]+1)]--;
        }
        int prev = 0;
        bool all_n = true;
        for (int j=0; j<n; j++) {
            a[j] = prev + buf[j];
            prev = a[j];
            if (a[j] < n) all_n = false;
        }
        if (all_n) break;
    }
    for (auto &ai:a) cout << ai << ' ';
    cout << '\n';
    return 0;
}

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

int main(void) {
  ll i, n, ans = 0, now, max, m;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  bool b;
  while(1) {
    b = true;
    now = 0;
    for(i = 0; i < n; ++i) if(a[i] > 1000) b = false;
    if(b) break;
    for(i = 0; i < n; ++i) now += a[i] / (n + 1), a[i] %= n + 1;
    for(i = 0; i < n; ++i) a[i] += now;
    ans += now;
  }
  while(1) {
    b = true;
    now = 0;
    for(i = 0; i < n; ++i) if(a[i] >= n) b = false;
    if(b) break;
    max = 0;
    for(i = 0; i < n; ++i) if(max < a[i]) max = a[i], m = i;
    a[m] -= n + 1;
    for(i = 0; i < n; ++i) a[i]++;
    ans++;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] grid = new char[h+2][w+2];
		for(int i = 0; i < h+2; i++){
		    Arrays.fill(grid[i], '#');
		}
		for(int i = 0; i < h; i++){
		    String s = sc.next();
		    for(int j = 0; j < w; j++){
		        grid[i+1][j+1] = s.charAt(j);
		    }
		}
		
		// 計算
		//String result = "No";
		
		// 出力
		for(int i = 0; i < h+2; i++){
		    for(int j = 0; j < w+2; j++){
		        System.out.print(grid[i][j]);
		    }
		    System.out.println();
		}
		//System.out.println(result);
	}
}


Measured memory_bytes: 24148
#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  int zyun;
}node;
 
node B[100000];
int n;
 
/*int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
    r=i;
    return r;
      }
    }
  }
  return r;
}
*/
int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}
 
 
  int A[10000000]; 
int main(){
  int i,j=0,k,a,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    B[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&B[k].sa);
    B[k].zyun=j;
    for(c=0;c<B[k].sa;j++,c++){
      scanf("%d",&A[j]);

 B[A[j]].parent=k;
    }

  }
   
  /* for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  */
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,B[i].parent,B[i].reach);
    if(B[i].parent==-1)printf("root, ");
    else if(B[i].sa==0)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(k=0,j=B[i].zyun;k<B[i].sa;j++,k++){
      if(k==0)printf("%d",A[j]);
      else printf(", %d",A[j]);
    }
     printf("]\n");
 
  }
  return 0;
}

Measured memory_bytes: 2768
import math
a, b, C = map(int, input().split())
print('{0:.4f}'.format(0.5*a*b*math.sin(math.radians(C))))
L = (a+b) + math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
print(L)
print('{0:.4f}'.format(math.sin(math.radians(C)) * b))



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

MAX, MAX_index = 0, 0
positive_flg = True
for i, a in enumerate(A):
    if abs(a) > MAX:
        if a > 0:
            positive_flg = True
        else:
            positive_flg = False
        MAX = abs(a)
        MAX_index = i

ans = []
for i in range(N):
    ans.append((MAX_index, i))
if positive_flg:
    for i in range(N - 1):
        ans.append((i, i + 1))
else:
    for i in reversed(range(N - 1)):
        ans.append((i + 1, i))


print(len(ans))
for x, y in ans:
    print(x + 1, y + 1)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

int main(){

  int k;
  cin>>k;

  auto next_l = [](ll x)->ll{
    if(x<10)return x+1;
    string s = to_string(x);
    int n = s.size();
    reverse(s.begin(),s.end());
    rep(i,n-1){
      if(s[i]!='9'&&abs(s[i]+1-s[i+1])<=1){
        s[i]++;
        for(int j=i-1;j>=0;--j){
          s[j] = max(char(s[j+1]-1),'0');
        }
        reverse(s.begin(),s.end());
        return stoll(s);
      }
    }
    reverse(s.begin(),s.end());
    if(s[0]!='9'){
      s[0]++;
      for(int i=1;i<n;++i){
        s[i] = max(char(s[i-1]-1),'0');
      }
    }else{
      s = '1'+s;
      rep(i,n)s[i+1]='0';
    }
    return stoll(s);
  };
  ll ans = 1;
  k--;
  while(k--){
    dump(ans);
    ans = next_l(ans);
  }
  cout<< ans <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000003;
const int maxn = 1e6+5;
int main()
{
    string s;
    while(cin>>s)
    {
        int n = s.size();
        ll ans = 0;
        ll res = 0;
        ll now = -1;
        for(int i = n-1; i >= 0; --i)
        {
            if(s[i] == 'A')
            {
                if(now == 3)
                    res = 0;
                ans += res;
                now = -1;
                continue;
            }
            if(s[i] == 'B')
            {
                if(now == 3)
                {
                    now = -1;
                    res++;
                }
                else
                {
                    res = 0;
                    now = -1;
                }
            }
            else if(s[i] == 'C')
            {
                if(now == -1)
                {
                    now = 3;
                }
                else
                {
                    res = 0;
                }
            }
        }
        cout<<ans<<endl;
    }
}













Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
int n,m,p;
int num[20000+10];
double dp[20000+10];
struct E
{
	int u,v;
}e[100+10];
double qpow(double d,int c)
{
	if(c==0)return 1;
	if(c==1)return d;
	double ret=qpow(d,c/2);
	ret=ret*ret;
	if(c&1)ret=ret*d;
	return ret;
}
int main()
{
	while(scanf("%d%d%d",&n,&m,&p)!=EOF)
	{
		memset(num,0,sizeof(num));
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&e[i].u,&e[i].v);
		}
		for(int i=1;i<(1<<n);i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(i&(1<<(e[j].u-1))&&i&(1<<(e[j].v-1)))num[i]++;
			}
		}
	//	for(int i=1;i<=n;i++)dp[1<<(i-1)]=1;
		for(int i=1;i<(1<<n);i++)
		{
			for(int j=i&(i-1);j;j=i&(j-1))
			{
				if(j&(i&(-i)))
				dp[i]+=(1-dp[j])*qpow(p*1.0/100,num[i]-num[j]-num[i&(~j)]);
			}
		}
		printf("%.12f\n",1-dp[(1<<n)-1]);
	}
	return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <pii> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  sort(all(arr));
  int cur = 0;
  ll ans = 0;
  priority_queue <int> pq;
  for (int day = 1; day <= m; day++) {
    while (cur < n and arr[cur].first <= day) {
      pq.push(arr[cur].second);
      cur++;
    }
    if (not pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 1660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	a := scanInt()
	b := scanInt()
	c := scanInt()

	if a == b {
		if a != c {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		if a == c || b == c {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 640
from heapq import heappush, heappop

N,M = map(int,input().split())

list_work = []
for n in range(N):
  a,b = map(int,input().split())
  list_work.append([a,b])  

list_work.sort(reverse=True)
q = []
ans = 0


for m in range(1,M+1):
  
  while list_work and list_work[-1][0] <= m:
    _, b = list_work.pop()
    heappush(q,-b)
  
  if q:
    b = heappop(q)
    ans -= b

print(ans)

Measured memory_bytes: 20236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>

using namespace std;

string str;
int p;

bool isopen(int p){
    return str[p] == '[';
}

bool isclose(int p){
    return str[p] == ']';
}

int getdig(){
    return str[p++] - '0';
}

int getnum(){
    //cout << "num" << endl;
    int n = 0; 
    while(isdigit(str[p])){
        n*=10;
        n+=getdig();
    }
    return n;
}

int getfirst(){
    //cout << "fir" << endl;
    vector<int> fir;
    p++; // jump [
    while(isopen(p)){
        p++; // jump [
        fir.push_back(getnum());
        p++; // jump ]
    }
    p++; // jump ]
    int ans = 0;
    sort(fir.begin() , fir.end());
    for(int i=0; i<fir.size()/2+1; i++){
        ans += fir[i]/2+1;
    }
    return ans;
}

int getsecond(){
    //cout << "sec" << endl;
    if(isopen(p) && isopen(p+1) && isopen(p+2)){
        // some firsts
        p++; // jump [
        vector<int> sec;
        while(isopen(p)){
            sec.push_back(getsecond());
        }
        p++; // jump ]
        int n = 0;
        sort(sec.begin() , sec.end());
        for(int i=0; i<sec.size()/2+1; i++){
            n+=sec[i];
        }
        return n;
    } else {
        return getfirst();
    }
}

int main(){
    int n;
    cin >> n;
    while(n--){
        p = 0;
        cin >> str;
        //cout << str << endl;
        cout << getsecond() << endl;
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  int now, index;
  set<int> st;
  rep(i, n) {
    cin >> now;
    st.insert(now);
  }
  int res = n == 0 ? x : INF;
  for(int i = -1; i <= 101; ++i) {
    now = abs(i - x);
    if(!st.count(i) && now < res) {
      res = now;
      index = i;
    }
  }
  cout << index << endl;
  return 0;
}

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

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    int index_min = -1;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] == 1)  index_min = i;
    }
    cout <<  (N - 1 + K - 1 - 1) / (K - 1)  << endl;
}

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

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

    int mod = a%b;
    int plus = a;

    a += plus;
    bool f;
    while(1) {
        if(a%b == c) {
            f = true;
            break;
        } else if(a%b == mod) {
            f = false;
            break;
        }
        a += plus;
    }

    std::string ans = f?"YES":"NO";

    std::cout << ans << std::endl;


}

Measured memory_bytes: 3536
/* agc 040 a */
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

long	cnt_down(long n)
{
	long sum = 0;
	while (n > 0)
	{
		sum += n;
		n--;
	}
	return sum;
}

int  main()
{

	string s;
	cin >> s;
	long sum = 0;
	vector<long> q;
	long cnt ;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '<')
			q.push_back(-1);
		else if (s[i] == '>')
		{
			cnt = 0;
			int j = i;
			while(s[j] && s[j] == '>')
			{
				cnt++;
				j++;
			}
			q.push_back(cnt);
			i = j - 1;
		}
	}
	deque<long> t;
	t.push_back(0);
	long p;
	rep(i, q.size())
	{
		if (q[i] == -1 && (q[i+1] == -1 || q[i + 1] == '\0'))
		{
			p = 1 + t.back();
			sum += p;
			t.push_back(p);
		}
		else if(q[i] == -1 && q[i + 1]  >= 0)
		{
			if (t.back() + 1 >= q[i + 1])
			{
				p = 1 + t.back();
				sum += p;
				t.push_back(p);
				q[i + 1] -= 1;
			}
			else if (t.back() + 1 < q[i + 1])
			{
				p = (q[i+1] - t.back()) + t.back();
				sum += p;
				q[i+1] -= 1;
			}
		} 
		else if (q[i] >= 0)
		{
			sum += cnt_down(q[i]);
			p = 0;
			t.push_back(p);
		}
	}
	cout << sum << endl;
	return (0);
}


Measured memory_bytes: 8692
// AOJ Volume5 0522 JOI and IOI

#include <stdio.h>
#include <string.h>

int main(void)
{
	char in[10001];
	int p;
	int len;
	int ni, nj;
	int i;
	
	while (scanf("%s", in) != EOF){
		ni = nj = 0;
		
		len = strlen(in);
		
		for (i = 0; i <= len - 3; i++){
			if (strncmp(in + i, "IOI", 3) == 0){
				ni++;
			}
			else if (strncmp(in + i, "JOI", 3) == 0){
				nj++;
			}
		}
		printf("%d\n%d\n", nj, ni);
	}
	
	return (0);
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	// freopen("temp.1", "r", stdin);

	int N;
	cin >> N;
	cout << (N < 1000 ? "ABC" : "ABD") << endl;
	return 0;
}

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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        set<string> s;
        string x;
        for (int i = 0; i < n; ++i)
        {
            cin >> x;
            s.insert(x);
        }
        cout << s.size() << "\n";
    }
}

Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[N];
    int b=0,c=10000000;
    for(int i=0;i<N;i++){
        cin >> a[i];
        b = max(b,a[i]);
        c = min(c,a[i]);
    }
    cout << b-c << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
string a, b, c;
int ans = 0;
int main()
{
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i] && b[i] == c[i] && c[i] == a[i])
            continue;
        else if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])
            ans += 2;
        else
            ans += 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

template <typename T>
std::vector<T> divisor_list(const T N)
{
    std::vector<T> result;

    for (T val = 1; val * val <= N; val++)
    {
        if (N % val == 0)
        {
            result.push_back(val);
            result.push_back(N / val);
        }
    }
    sort(result.begin(), result.end());

    return result;
}

int main()
{
    int64_t n, m;
    cin >> n >> m;

    auto divisors = divisor_list<int64_t>(m);

    int64_t max_div = 1;
    for (auto& d : divisors)
    {
        if (n <= m / d)
        {
            max_div = max(max_div, d);
        }
    }
    cout << max_div << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 0
    if 2*C < A+B:     # C買うフェイズ
        ge = min(X, Y)
        ans += C*2*ge
        X -= ge
        Y -= ge

    if X > 0:                   # コスパよくAを集める
        if 2*C < A:
            ans += C*2*X
        else:
            ans += A*X
    if Y > 0:
        if 2*C < B:
            ans += C*2*Y
        else:
            ans += B*Y
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//----------------------------------------------
ll par[N],sz[N];
void preprs(ll n){
	for(ll i=1;i<=n;i++){
		par[i]=i; sz[i]=1;
	}
}
ll root(ll a){
	while(par[a]!=a){
		par[a]=par[par[a]];
		a=par[a];
	}
	return a;
}
void dunion(ll a,ll b){
	a=root(a); b=root(b);
	if(a==b) return ;
	if(b<a) swap(a,b);
	sz[a]+=sz[b];
	par[b]=a;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	
	ll i,j,k,l,n,m;
	cin>>n>>m;
	preprs(n);

	for(i=1;i<=m;i++){
		cin>>k>>l;
		dunion(k,l);
	}

	ll an=0;
	for(i=1;i<=n;i++){
		if(root(i)==i){
			an=max(an,sz[i]);
		}
	}
	cout<<an<<endl;
	return 0;	
}

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

int main() {
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	m = S%3600/60;
	s = S % 3600 % 60;
	cout << h<<":"<< m << ":"<< s<<endl;
	return 0;
}

Measured memory_bytes: 3056
#include <stdio.h>
#include <stdlib.h>

int main() {
  int N, Q;
  long K;
  scanf("%d %ld %d", &N, &K, &Q);

  long A[N];
  for (int i = 0; i < N; i++) {
    A[i] = 0;
  }

  int a;
  for (int i = 0; i < Q; i++) {
    scanf("%d", &a);
    A[a-1] += 1;
  }

  for (int i = 0; i < N; i++) {
    if ((K-Q+A[i]) > 0) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
using namespace std;
using Weight = int;
using Array = vector<int>;
using Matrix = vector<Array>;
constexpr int INF = 1000000000;


pair<Weight, Array> hungarian(const Matrix &m) {
  int n = m.size();
  int p, q;
  Array fx(n, INF), fy(n, 0);
  vector<int> x(n, -1), y(n, -1);
  //REP(i,n)REP(j,n) fx[i] = max(fx[i], m[i][j]);
  for (int i = 0; i < n; ) {
    vector<int> t(n, -1), s(n+1, i);
    for (p = q = 0; p <= q && x[i] < 0; ++p)
      for (int k = s[p], j = 0; j < n && x[i] < 0; ++j)
        if (fx[k] + fy[j] == m[k][j] && t[j] < 0) {
          s[++q] = y[j], t[j] = k;
          if (s[q] < 0)
            for (p = j; p >= 0; j = p)
              y[j] = k = t[j], p = x[k], x[k] = j;
        }
    if (x[i] < 0) {
      Weight d = INF;
      for (int k = 0; k <= q; ++k)
        for (int j = 0; j < n; ++j)
          if (t[j] < 0) d = min(d, fx[s[k]] + fy[j] - m[s[k]][j]);
      for (int j = 0; j < n; ++j) fy[j] += (t[j] < 0 ? 0 : d);
      for (int k = 0; k <= q; ++k) fx[s[k]] -= d;
    } else ++i;
  }
  Weight ret = 0;
  for (int i = 0; i < n; ++i) ret += m[i][x[i]];
  return make_pair(ret, x);
}

int main() {
  int n;
  cin>>n;
  Matrix w(n, Array(n));
  REP(i,n)REP(j,n) cin >> w[i][j];
  Matrix e(n, Array(n));
  REP(i,n)REP(j,n) cin >> e[i][j];
  vector<string> m(n);
  Matrix mat(n, Array(n));
  int cost = 0;
  REP(i,n) {
    cin>>m[i];
    REP(j,n) {
      if (m[i][j] == 'o') {
        mat[i][j] = 1000 + e[i][j];
        cost += e[i][j];
      } else {
        mat[i][j] = 1000 - w[i][j];
      }
    }
  }
  auto res = hungarian(mat);
  cout << (n*1000 - res.first + cost) << endl;
  int cnt = 0;
  stringstream ss;
  REP(i,n)REP(j,n) {
    if (m[i][j] == 'o') {
      if (res.second[i] != j) {
        ss << (i+1) << ' ' << (j+1) << " erase" << endl;
        ++cnt;
      }
    } else {
      if (res.second[i] == j) {
        ss << (i+1) << ' ' << (j+1) << " write" << endl;
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
  cout << ss.str() << flush;
  return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[400005];
long long aabs(long long x) {
    return max(x, -x);
}
int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << '+';
    else if (a * b == 15) cout << '*';
    else cout << 'x';
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n=int(input())
ablist=[[int(x) for x in input().split()] for _ in range(n)]

ablist.sort(key=lambda x:x[1])
#print(ablist)

ruiseki=np.cumsum([item[0] for item in ablist])

if all([ruiseki[i]<=ablist[i][1] for i in range(n)]):
  print("Yes")
else:
  print("No")


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

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char t = s[k-1];
    if(t == 'A')s[k-1] = 'a';
    if(t == 'B')s[k-1] = 'b';
    if(t == 'C')s[k-1] = 'c';
    cout << s << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n;
	cin >> n;
	map<string, ll> mp;
	rep(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}

	ll ans = 0;
	for (auto m : mp) {
		ans += m.second * (m.second - 1) / 2;
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 11264
h,w,n = map(int,input().split())
sx,sy = map(int,input().split())
S = input()
T = input()
S = list(S[::-1])
T = list(T[::-1])
area = [1,h,1,w]
#上下左右
for s,t in zip(S,T):
  if t == "R":
    area[2] = max(1,area[2]-1)
  if t == "L":
    area[3] = min(w,area[3]+1)
  if t == "D":
    area[0] = max(1,area[0]-1)
  if t == "U":
    area[1] = min(h,area[1]+1)
  if s == "L":
    area[2] = min(w+1,area[2]+1)
  if s == "R":
    area[3] = max(0,area[3]-1)
  if s == "U":
    area[0] = min(h+1,area[0]+1)
  if s == "D":
    area[1] = max(0,area[1]-1)
  if area[0] > area[1] or area[2] > area[3]:
    print("NO")
    exit()
if area[0] <= sx <= area[1] and area[2] <= sy <= area[3]:
  print("YES")
else:
  print("NO")
  

Measured memory_bytes: 8288
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var inputs [3]int
	if sc.Scan() {
		for i, v := range strings.Split(sc.Text(), " ") {
			inputs[i], _ = strconv.Atoi(v)
		}

		min := inputs[0]
		max := inputs[0]
		for _, v := range inputs {
			if v < min {
				min = v
			} else if v > max {
				max = v
			}
		}

		fmt.Printf("%d %d\n", min, max)

	}
}



Measured memory_bytes: 1104
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s=input()
t=input()
for i in range(len(s)):
  if s[i]!=t[i]:
    count += 1
print(count)

Measured memory_bytes: 68592
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
const int maxn=100500;
int n,ans,tot;
map<ll,int> mp,vis;
ll a[maxn],b[maxn],pri[maxn],p[maxn];
int main(){
    int N=2500;
    rep(i,2,N) {
        int gg=0;
        for (int j=2;j*j<=i;j++) if (i%j==0) {gg=1; break;}
        if (!gg) pri[++tot]=i; 
    }
    scanf("%d",&n);
    rep(i,1,n) scanf("%lld",&a[i]);
    rep(i,1,n){
        b[i]=p[i]=1;
        for (int j=1;j<=tot&&a[i]>1;j++){
            if (a[i]%pri[j]==0){
                int cnt=0;
                while (a[i]%pri[j]==0) a[i]/=pri[j],cnt++;
                cnt%=3;
                if (!cnt) continue;
                if (cnt==2) b[i]*=pri[j]*pri[j],p[i]*=pri[j];
                else b[i]*=pri[j],p[i]*=pri[j]*pri[j];
            }
        }
        if (a[i]>1){
            ll x=sqrt(a[i]+0.5);
            b[i]*=a[i]; 
            if (x*x==a[i]) p[i]*=x;
            else p[i]*=a[i]*a[i];
        }
    }
    rep(i,1,n) mp[b[i]]++;
    rep(i,1,n) if (!vis[b[i]]){
        if (b[i]!=p[i]) ans+=max(mp[b[i]],mp[p[i]]);
        else ans++;
        vis[b[i]]=vis[p[i]]=1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 27648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  
  int N, M; cin >> N >> M;
  
  vector <bool> checked(N);
  vector < vector<int> > graph(N);

  for (int i = 0; i < M; i++){
    int X, Y, Z; cin >> X >> Y >> Z;
    X--; Y--;
    graph[X].push_back(Y);
    graph[Y].push_back(X);
  }
  
  queue <int> que;
  que.push(0); checked[0] = true;
  int ans = 1, now = 0;

  while (!que.empty()){
    int start = que.front(); que.pop();

    for (int i = 0; i < graph[start].size(); i++){
      int next = graph[start][i];

      if (checked[next] == false){
        checked[next] = true;
        que.push(next);
      }
    }
    
    if (que.empty()){
      for (int i = now; i < N; i++){
        if (checked[i] == false){
          checked[i] = true;
          que.push(i);
          now = i;
          ans++;
          break;
        }
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N, M;
    cin >> N >> M;
    int a, b;
    vector<set<int>> v(N);
    REP(i, M){
        cin >> a >> b;
        a--;
        b--;
        v[a].insert(b);
        v[b].insert(a);
    }
    REP(i, N){
        if (v[0].find(i) != v[0].end() && v[N-1].find(i) != v[N-1].end()){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

#define inp 200005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }

using namespace std;

// ... :)

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

    int arr[n][n];

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

    vector<ll> dp(1<<n,0);
    dp[0]=1;

    for(int mask=0;mask<(1<<n);mask++)
    {
        //trace(mask);
        int taken = __builtin_popcount(mask);
        for(int b=0;b<n;b++)
        {
            if(!arr[taken][b] || (mask & (1<<b))) continue;
            dp[mask|(1<<b)]+=dp[mask];
            dp[mask|(1<<b)]%=mod;
        }
        //deb(dp);
    }
    cout << dp[(1<<n)-1];

    return 0;
}

Measured memory_bytes: 19524
#include <stdio.h>
int F[45];

int main(){

  int n,i;

  F[0] = F[1] = 1;

  scanf("%d",&n);

  for(i=2; i<=n; i++)
    F[i] = F[i-2] + F[i-1];

  printf("%d\n",F[n]);
 
  return 0;
}

Measured memory_bytes: 596
n = int(input())
height_ar = [int(x) for x in input().split()]

flag = 1
for i in range(n-1):
    sub = height_ar[i] - height_ar[i+1]
    if sub > 1:
        print("No")
        flag = 0
        break
    elif sub == 1:
        height_ar[i+1] = height_ar[i+1] + 1
    else:
        pass

if flag == 1:
    print("Yes")



Measured memory_bytes: 14224
n, h, *t=map(int,open(0).read().split())
a = t[::2]
b = t[1::2]
ma = max(a)
b_high = [i for i in b if i > ma]
if sum(b_high) > h:
  ans = 0
  b_high = sorted(b_high)
  while h > 0:
    h = h - b_high.pop()
    ans += 1
  print(ans)
else:
  if (h - sum(b_high)) % ma == 0:
    print(len(b_high) + (h - sum(b_high)) // ma)
  else:
    print(len(b_high) + ((h - sum(b_high)) // ma) + 1)


Measured memory_bytes: 25124
#include<iostream>
using namespace std;
int extgcd(int a, int b, int &x, int &y){
    int g = a;
    x = 1, y = 0;
    if(b != 0){
        g = extgcd(b, a%b, y, x);
        y -= (a / b) * x;
    }
    return g;
}
int main(){
    int a, b, x, y, g;
    cin >> a >> b;
    g = extgcd(a, b, x, y);
    cout << x << " " << y << endl;
}


Measured memory_bytes: 3108
#include<stdio.h>

int main(){

  int N,i,k=0;

  scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    while(a[i]%2==0){
      a[i]/=2;
      k++;
    }
  }

  printf("%d",k);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int x,y;
  cin>>x>>y;
  cout<<x+y/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int h[N], n, memo[N], k;
int solve(int idx)
{
    if(idx == n - 1)
        return 0;
    if(memo[idx] != -1)
        return memo[idx];
    memo[idx] = 1e9 + 5;
    for(int i = 1 ; i <= k ; i++)
        if(i + idx <= n - 1)
            memo[idx] = min(memo[idx], abs(h[idx] - h[i + idx]) + solve(i + idx));
    return memo[idx];
}

int main()
{
    memset(memo, -1, sizeof(memo));
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
        int n,m;
        cin >> n >> m;
        vector<pp> sc(m);
        rep(i,m){
                 int a,b;
                cin >> a >> b;
                --a;
                sc.at(i) = pp(a,b);
        }
        int ans = -1;
        rep(i,1000){
                int now = i;
                vector<int> p;
                while(now > 0){
                        p.push_back(now%10);
                        now /= 10;
                }
                
                if(i == 0) p.push_back(0);
                
                if(p.size() != n) continue;
                reverse(p.begin(),p.end());
                
                bool ok = true;
                rep(j,m){
                         if(p.at(sc.at(j).first) != sc.at(j).second) ok = false;
                }
                if(ok){
                        ans = i;
                        break;
                }
        }
        cout << ans << endl;
                         
        
        //rep(i,m){
         //        cout <<sc.at(i).first <<" "<< sc.at(i).second << endl;
       // }      

        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, H, W);

    vector<string> mat(H);
    read(mat);

    auto left = makeV(0, H, W);
    auto right = makeV(0, H, W);
    auto top = makeV(0, H, W);
    auto bot = makeV(0, H, W);

    rep(i, 0, H) {
        int l = 0;
        rep(j, 0, W) {
            if (mat[i][j] == '#') l = j+1;
            else left[i][j] = l;
        }

        int r = W-1;
        repr(j, W-1, 0) {
            if (mat[i][j] == '#') r = j-1;
            else right[i][j] = r;
        }
    }
    rep(j, 0, W) {
        int t = 0;
        rep(i, 0, H) {
            if (mat[i][j] == '#') t = i+1;
            else top[i][j] = t;
        }

        int b = H-1;
        repr(i, H-1, 0) {
            if (mat[i][j] == '#') b = i-1;
            else bot[i][j] = b;
        }
    }
    //
    // print();
    // print(left);
    // print();
    // print(right);
    // print();
    // print(top);
    // print();
    // print(bot);

    i64 ans = 0;
    rep(i, 0, H) rep(j, 0, W) {
        if (mat[i][j] == '#') continue;
        chmax(ans, (right[i][j] - left[i][j] + 1) + (bot[i][j] - top[i][j] + 1) - 1);
    }

    print(ans);

    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    int mini = b*10;
    while(int(mini*0.1)==b){
        if(int(mini*0.08)==a){
            break;
        }
        mini++;
    }
    if(int(mini*0.1)==b && int(mini*0.08)==a){
        cout<<mini<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  map<char,int>mp;
  cin>>s;
  for(int i=0;i<4;i++){
    mp[s[i]]++;
  }
  bool flag=true;
  for(auto e:mp){
    if(e.second!=2)flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    int i,n,p[50],count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;i++){
        if(p[i] != i+1){
            count++;
        }
    }
    if(count == 2 || count == 0){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

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

/**
 * Made by egor https://github.com/chermehdi/egor.
 * 
 * @author azize
   
 */
public class Main {

    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        char[] arr = in.next().toCharArray();
        int[][] count = new int[n + 1][3];

        for (int i = arr.length - 1; i >= 0; --i) {
            for (int j = 0; j < 3; ++j) {
                count[i][j] = count[i + 1][j];
            }
            ++count[i][get(arr[i])];
        }
        long ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (arr[i] == arr[j]) continue;
                ans += count[j + 1][cmp(arr[i], arr[j])];
                if (j + j - i < n && get(arr[j + j - i]) == cmp(arr[i], arr[j])) {
                    --ans;
                }
            }
        }

        out.println(ans);
    }

    public static int cmp(char a, char b) {
        return 3 - get(a) - get(b);
    }

    public static int get(char c) {
        switch (c) {
            case 'R' : return 0;
            case 'G' : return 1;
            case 'B' : return 2;
        }

        System.err.println("!!");
        return -1; // should never get here
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


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

#define endl '\n'
#define ll long long
#define For(i,l,r) for(int i = l; i <= r; i++)
#define ForR(i,l,r) for(int i = l; i >= r; i--)

int main(){
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll n,d=0,t=0;
	cin>>n;
	char a[n+5];
	For(i,1,n){
		cin>>a[i];
		if(a[i]=='R')d++;
		}
	For(i,1,d){
		if(a[i]=='R')t++;
		}
	cout<<d-t;
	return 0;
}


Measured memory_bytes: 3808