akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

struct data {
	llong place;
	llong many;
	llong gas;

	data(){};
	data(llong p, llong m, llong g) :
		place(p),
		many(m),
		gas(g)
	{};

	bool operator<(const data &ri) const {
		return many == ri.many ?
			gas > ri.gas :
			many < ri.many;
	}
	bool operator>(const data &ri) const {
		return many == ri.many ?
			gas < ri.gas :
			many > ri.many;
	}
};

llong N, M, L, Q;
vector<vector<lpair>> edges;
vector<lpair> query;

vector<llong> solve(int start) {
	vector<data> dis(N+1, data(inf, inf, -inf));
	dis[start] = data(start, 0, L);

	vector<llong> ret(N+1, inf);

	priority_queue<data, vector<data>, greater<data>> que;
	que.push(data(start, 0, L));
	while (que.size()) {
		data now = que.top();
		que.pop();
		if (dis[now.place] < now) continue;
		ret[now.place] = min(ret[now.place], now.many);
		for (auto edge: edges[now.place]) {
			if (now.gas >= edge.second) {
				data next(edge.first, now.many, now.gas - edge.second);
				if (dis[next.place] > next) {
					dis[next.place] = next;
					que.push(next);
				}
			}
			data next(edge.first, now.many + 1, L - edge.second);
			if (dis[next.place] > next) {
				dis[next.place] = next;
				que.push(next);
			}
		}
	}

	return ret;
}

int main() {
	cin >> N >> M >> L;

	edges.resize(N+1);
	llong a, b, c;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		if (c > L) continue;
		edges[a].push_back(lpair(b, c));
		edges[b].push_back(lpair(a, c));
	}

	cin >> Q;
	query.resize(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> query[i].first >> query[i].second;
	}

	vector<vector<llong>> ans(N+1);
	for (int i = 1; i <= N; ++i) {
		ans[i] = solve(i);
	}

	for (auto q : query) {
		cout << (ans[q.first][q.second] == inf ? -1 : ans[q.first][q.second]) << endl;
	}

	return 0;
}


Measured memory_bytes: 4992
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define SCIN(x) string x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(q);CIN(h);CIN(s);CIN(d);CIN(n);
    s=min({q*4,h*2,s});
    d=min(s*2,d);
    ll ans=1LL*n/2*d+1LL*n%2*s;
    COUT(ans);

    return 0;
}


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

int main() {

	string input;
	int L0 = 0, L1 = 0, R0 = 0, R1 = 0;
	int change10 = 0, change01 = 0;
	cin >> input;

	for (int count = 0; count < input.length(); count++) {
		if (count % 2 == 0) {
			if (input[count] == '0')L0++;
			else L1++;
		}
		else {
			if (input[count] == '0')R0++;
			else R1++;
		}
	}

	for (int count = 0; count < input.length(); count++) {//1-0
		if (count % 2 == 0) { if (input[count] == '0')change10++; }//Left
		else if (input[count] == '1') { change10++; }//Right
	}

	for (int count = 0; count < input.length() ; count++) {//0-1
		if (count % 2 == 0) { if (input[count] == '1')change01++; }//Left
		else if (input[count] == '0'){change01++; }//Right
	}

	change01 < change10 ? cout << change01 << endl : cout << change10 << endl;
	//cout << change01 << endl; cout << change10 << endl;
	//cout << L0 << " " << L1 << " " << R0 << " " << R1 << endl;

	return 0;
}
//*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,N,i,c=0,max;
  char S[10];
  cin >> S;

  for(i=0;i<11;i++){
    if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C') c++;
    else{
      if(c>0 && c>max){
        max = c;
        c=0;
      }
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 100005
#define ll long long
ll read() {
    ll s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
	    if(ch=='-') w=-1;
	    ch=getchar();
	}
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return s*w;
}
map<ll,int> ap;
struct node{
    ll d;
    int id;
}a[M];
bool cmp(node p1,node p2) {return p1.d>p2.d;}
struct edge{
    int u,v;
    edge(int r_u=0,int r_v=0) {u=r_u,v=r_v;}
}ans[M];
vector<int> e[M]; 
int cnt;
int n,sz[M];
ll dep[M],sum;
void dfs(int x,int fa) {
    dep[x]=dep[fa]+1,sum+=dep[x];
    for(int i=0;i<e[x].size();i++)
	{
	    int to=e[x][i];
	    dfs(to,x);
	}
}
void work() {
    int tp=0;
    for(int i=1;i<=n;i++) ap[a[i].d]=a[i].id,sz[i]=1;
    for(int i=1;i<n;i++)
	{
	    ll d_F=a[i].d-n+2*sz[a[i].id];
	    if(d_F<0||d_F>=a[i].d||ap[d_F]==0) {tp=1;break ;}
	    sz[ap[d_F]]+=sz[a[i].id];
	    ans[++cnt]=edge(ap[d_F],a[i].id);
	    e[ap[d_F]].push_back(a[i].id);
	}
    dep[0]=-1;
    dfs(a[n].id,0);
    if(sum!=a[n].d) tp=1;
    if(tp) cout<<-1<<'\n';
    else for(int i=1;i<=cnt;i++) cout<<ans[i].u<<' '<<ans[i].v<<'\n';
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++) {a[i].d=read();a[i].id=i;}
    sort(a+1,a+n+1,cmp);
    work();
    return 0;
}

Measured memory_bytes: 18944
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// n
			scanner.nextInt();
			int q = scanner.nextInt();
			scanner.nextLine();
			String s = scanner.nextLine();
			List<Integer> countList = new ArrayList<>();
			List<Integer> result = new ArrayList<>();
			char[] charArray = s.toCharArray();
			char previous = ' ';
			int count = 0;
			for (int i = 0; i < charArray.length; i++) {
				char current = charArray[i];
				if (('A' == previous) && ('C' == current)) {
					count++;
				}
				previous = current;
				countList.add(count);
			}
			for (int i = 0; i < q; i++) {
				int l = scanner.nextInt();
				int r = scanner.nextInt();
				result.add(countList.get(r - 1) - countList.get(l - 1));
			}
			result.forEach(System.out::println);
		}
	}
}

Measured memory_bytes: 101308
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  string n;
  cin >> n;

  if(n[0]=='Y' && n[1]=='A' && n[2]=='K' && n[3]=='I'){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!


#ord(s)
import copy

H, W, K = list(map(int, input().split()))
c = ["" for i in range(H)]
for i in range(H):
    c[i] = input()
ans = 0
for i in range(2**(H+W)):
    d = copy.deepcopy(c)
    
    for j in range(H):
        if (i >> j ) & 1 == 1:
            d[j] = "." * W
    for j in range(W):
        if (i >> (j + H) ) & 1 == 1:
            for k in range(H):
                
                d[k] = d[k][0:j] + "." + d[k][j+1:W] 
    count = 0
    for j in range(H):
        for k in range(W):
            if d[j][k] == "#":
                count += 1
                
    if count == K:
        ans += 1
print(ans)


    
    
    
    
    
    
    




Measured memory_bytes: 9308
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		String t = stdIn.next();
		
		boolean ans = false;
		
		
		for(int i = 0; i < s.length(); i++) {
			if(s.equals(t)) {
				ans = true;
				break;
			}
			s = s.substring(s.length()-1)+s.substring(0,s.length()-1);
		}
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,a[110];

bool fn(){
    for(ll k=0; k<n-1; k++){
        if( a[k]>a[k+1] ) return false;
    }
    return true;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(ll i=0; i<n; i++) cin >> a[i];

    if( fn() ){
        cout << "YES";
        return 0;
    }

    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<n; j++){
            swap( a[i] , a[j] );
            if( fn() ){
                cout << "YES";
                return 0;
            }
            swap( a[i] , a[j] );
        }
    }

    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))


double pi = std::acos(-1);

int main() {

	int a,b,h,m;
	cin>>a>>b>>h>>m;

	double hangle = 0.5 * (h * 60 + m);  
    double mangle = 6 * m;  
    double angle = ABS((hangle - mangle));  

	angle = min(360 - angle, angle);  

	double cosine = cos(angle*pi/180);
	
 	double l = a*a + b*b - 2*a*b*cosine;
 	double ans = sqrt(l);
 	printf("%0.11lf\n", ans);

 	return 0;

}

Measured memory_bytes: 4220
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

def EulerTour(n, X, i0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    P = [-1] * n
    ct = -1
    ET1 = [0] * n
    ET2 = [0] * n
    ANS = [f(n)] * n
    IND = [0] * n
    i = i0
    while i >= 0:
        ind = IND[i]
        if ind == 0:
            if i: ORG[i] = USED[C[P[i]]]
            ct += 1
            ET1[i] = ct
        
        if ind >= len(X[i]):
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                k = ET2[i] - ET1[i] + 1 - USED[C[P[i]]] + ORG[i]
                ANS[C[P[i]]] -= f(k)
                TMP[P[i]] += k
            i = P[i]
            continue
        
        j = X[i][ind]
        if P[i] == j:
            IND[i] += 1
            continue
        P[j] = i
        IND[i] += 1
        i = j
    
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, X, 0), sep = "\n")

Measured memory_bytes: 84328
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int n,n2;
    cin>>n;
    for(int i=0;;i++){
        n2=n-i*4;
        if(n2<0)break;
        for(int j=0;;j++){
            n2-=j*7;
            if(n2<0)break;
            else if(n2==0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  ll a[N];
  ll R[N+1];
  R[0] = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    R[i+1] = R[i] + a[i]; 
  }
  vector<ll> lis;
  for (int i = 0; i <= N; i++) {
    for (int j = i+1; j <= N; j++) {
      lis.push_back(R[j] - R[i]);
    }
  }
  for (int bit = 50; bit >= 0; bit--) {
    vector<ll> lis2;
    
    for (int i = 0; i < (int)lis.size(); i++) {
      if ((1LL << bit) & lis[i]) {
        lis2.push_back(lis[i]);
      }
    }
    if ((int)lis2.size() >= K) {
      lis = lis2;
      
      ans += (1LL << bit);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
int main(void){
    IOS;
    int n; ll d; cin >> n >> d;
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        ll x, y; cin >> x >> y;
        if (x*x+y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (0 <= S-i-j && K >= S-i-j) count++;
    }
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
N,A = map(int,input().split())
x = list(map(int,input().split()))
dp = [[[0]*(N*50+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
#print(dp[0])

for i in range(N):
    for j in range(N):
        for k in range(N*50+1):
            if k+x[i] < N*50+1:
                dp[i+1][j+1][k+x[i]] += dp[i][j][k]
                dp[i+1][j][k] += dp[i][j][k]

#print(dp)
ans = 0
for j in range(1,N+1):
    ans += dp[N][j][A*j]
    #print(j,A*j)
print(ans)

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

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin >> n;
  vector<int> a(n);
  Bint j("1000000000000000000");
  arep(i, a) cin >> i;
  sort(all(a));

  Bint ans = a[0];
  // cout << b << ' ';

  rep(i, 1, n) {
    ans *= a[i];
    // cout << s.size() << ' ' << v.size() << ' ';
    if (ans > j) {
      cout << -1 << '\n';
      return 0;
    }
    // cout << ans << ' ';
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define ll long long
#define lf double
#define E complex<lf>
#define inf 0x3f3f3f3f
#define eps 1e-8
#define pa pair<int,int>
#define pb push_back
#define ms(x,y) memset(x,y,sizeof(x))
#define l(x) (x<<1)
#define r(x) (x<<1|1)
#define mod 1000000007
#define N 100010
using namespace std;
inline ll read() {
	ll x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int n,m;
ll x,t[N],a[N],r[N];
int main() {
	x=read(),n=read();
	for (int i=1; i<=n; i++) r[i]=read();
	m=read();
	for (int i=1; i<=m; i++) t[i]=read(),a[i]=read();
	ll h=0,k=1,opt=-1,mx=x,mn=0;
	for (int i=1; i<=m; i++) {
		while (k<=n&&t[i]>=r[k]) {
			ll v=(r[k]-r[k-1])*opt;
			mx+=v,mn+=v,h+=v;
			mx=min(mx,x),mx=max(mx,0ll);
			mn=min(mn,x),mn=max(mn,0ll);
			k++,opt*=-1;
		}
		ll now=a[i]+h,d=(t[i]-r[k-1])*opt;
		now=max(now,mn),now=min(now,mx);
		now+=d,now=max(now,0ll),now=min(now,x);
		cout << now << endl;
	}
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red\n";
	}

	return 0;
}

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, m, used[max_n], cnt[max_n], lev[max_n];
vector<int> g[max_n], g2[max_n], down[max_n];

void dfs(int v) {
    used[v] = 1;
    cnt[v] = 0;
    for (int to : g[v]) {
        if (!used[to]) {
            lev[to] = lev[v] + 1;
            dfs(to);
            g2[v].push_back(to);
            cnt[v] += 1 + cnt[to];
        } else if (lev[to] + 1 < lev[v]) {
            down[to].push_back(v);
            ++cnt[to];
        }
    }
    //cout << v << ", cnt = " << cnt[v] << endl;
}

void proc(int v) {
    while (down[v].size() >= 2) {
        int x = down[v].back();
        down[v].pop_back();
        int y = down[v].back();
        down[v].pop_back();
        printf("%d %d\n", v, x);
        printf("%d %d\n", v, y);
    }
}

void dfs2(int v) {
    for (int to : g2[v]) {
        //cout << v << " -> " << to << " " << cnt[v] << endl;
        if (cnt[to] % 2 == 0) {
            down[v].push_back(to);
        } else {
            down[to].push_back(v);
        }
    }
    //cout << v << ": " << down[v].size() << endl;
    assert(down[v].size() % 2 == 0);
    proc(v);
    for (int to : g2[v]) {
        dfs2(to);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    if (m % 2) {
        puts("-1");
        return 0;
    }
    while (m--) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    dfs2(1);
    return 0;
}


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

typedef long long ll;

const int Maxn = 100005;
const ll Inf = 1000000000000000000ll;

int n;
int a[Maxn];
ll dp[Maxn][2];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    fill((ll*)dp, (ll*)dp + Maxn * 2, -Inf);
    dp[1][0] = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 2; j++) if (dp[i][j] >= 0) {
            int lft = a[i] - j;
            if (lft > 0 && a[i + 1] > 0)
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][j] + (lft - 1) / 2 + 1);
            dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + lft / 2);
        }
    printf("%lld\n", dp[n + 1][0]);
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    double PI = acos(-1);
    int a, b, C;
    double t;
    cin >> a >> b >> C;
    t = C*PI / 180;
    
    double S, L, h,c;
    c = sqrt(a*a + b*b - 2*a*b*cos(t));
    S = a*b*sin(t) / 2;
    L = a+b+c;
    h = 2*S/a;
    
    printf("%f\n%f\n%f\n",S, L, h);
    
    return 0;
    

}


Measured memory_bytes: 3352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int search(int,int *,int);
int main(){
  int n,q,*S,i,key,cnt=0;
  while(1){
    
    scanf("%d",&n);
    if(n<=10000) break;
  }
     S = (int *)malloc((n+1)*sizeof(int));
    for(i=0;i<n;i++){
      scanf("%d",&S[i]);
      if(S[i]<0&&S[i]>pow(10,9)) exit(2);
    }
     while(1){
    
    scanf("%d",&q);
    if(q<=500) break;
  }

 for(i=0;i<q;i++){
      scanf("%d",&key);
      if(key<0||key>pow(10,9)) exit(2);
      if(search(key,S,n)) cnt++;
 }
 printf("%d\n",cnt);
 return 0;
}

int search(int key,int *S,int n){
  int i=0;
  S[n] = key;

  while(S[i] != key) {
    i++;
    // printf("%d  %d\n",S[i],key);
  }
  

  return i != n;
}



Measured memory_bytes: 2048
#include<iostream>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<queue>

#include<vector>

#include<map>

#include<set>

#include<cstdio>

#define ll long long

#define mset(a,x) memset(a,x,sizeof(a))

 

using namespace std;

const double PI=acos(-1);

const int inf=0x3f3f3f3f;

const double esp=1e-6;

const int maxn=1e6+5;

const int mod=1e9+7;

int dir[4][2]={0,1,1,0,0,-1,-1,0};

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

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

ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}

ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

ll Fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;}

ll upd(ll x,ll v){x=x+v>=mod?x+v-mod:x+v;return x;}

struct node{

	int next,v,u,w;

}p[maxn];

int head[maxn],cnt,vis[maxn],n,k,maxx;

 

void add(int u,int v)

{

	p[cnt].v=v;

	p[cnt].next=head[u];

	head[u]=cnt++;

}

 

void dfs(int now,int fa,int step)

{

	maxx++;

	if(step==0)

	return ;

	for(int i=head[now];~i;i=p[i].next)

	{

		if(p[i].v==fa)

		continue;

		dfs(p[i].v,now,step-1);

	}

}

 

int main()

{

	int i,j,x,y;

	scanf("%d%d",&n,&k);

	for(i=0;i<=n;i++)

	head[i]=-1;

	for(i=0;i<n-1;i++)

	{

		scanf("%d%d",&x,&y);

		add(x,y);

		add(y,x);

	}

	int ans=0;

	if(k%2)    //k为奇数，枚举边，跑k/2的点 

	{

		for(i=1;i<=n;i++)

		{

			for(j=head[i];~j;j=p[j].next)

			{

				maxx=0;

				int t=p[j].v;

				dfs(t,i,k/2);

				dfs(i,t,k/2);

				ans=max(maxx,ans);

			}

		}

	}

	else      //k为偶数，枚举点，跑k/2的点 

	{

		for(i=1;i<=n;i++)

		{

			maxx=0;

			dfs(i,0,k/2);

			ans=max(maxx,ans);

		}

	}

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

}


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

vector<int> p;
vector<int> s;

void ms (int v){
    p[v] = v;
    s[v] = 1;
}

int fs (int v){
    if(p[v] == v)
        return v;
    return p[v] = fs(p[v]);
}

void us (int u, int v) {
    u = fs(u);
    v = fs(v);
    if(u != v) {
        if(s[u] < s[v])
            swap(u, v);
        p[v] = u;
        s[u] += s[v];
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    p.resize(n + 1);
    s.resize(n + 1);
    for(int i = 1; i <= n; i++)
        ms(i);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        us(u, v);
    }
    int mx = 0;
    for(int i = 1; i <= n; i++){
        mx = max(mx, s[i]);
    }
    cout << mx;
}



Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++) cin >> weight[i] >> value[i];
	int v_max = *max_element(value.begin(), value.end());

	vector<vector<int>> dp(n, vector<int>(n * v_max + 1, INF));
	dp[0][0] = 0;
	for (int j = 1; j <= value[0]; j++) dp[0][j] = weight[0];

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n * v_max; j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if (0 <= j - value[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - value[i]] + weight[i]);
			else {
				dp[i][j] = min(dp[i - 1][j], weight[i]);
			}
		}
	}

	int ans = 0;
	for (int j = 0; j <= n * v_max; j++) {
		if (dp[n - 1][j] <= w) ans = j;
	}
	cout << ans << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

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

int main(){
  int h,w; cin >> h >> w;
  char color[50][50];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      cin >> color[i][j];
  int distance[50][50] = {};
  Fill(distance,1001001001);
  queue<tuple<int,int,int>> que;
  que.emplace(0,0,1);
  int mr[] = {-1,1,0,0};
  int mc[] = {0,0,1,-1};
  while(!que.empty()){    
    auto [r,c,d] = que.front();
    que.pop();
    if(distance[r][c] <= d) continue;
    distance[r][c] = d;
    for(int i = 0; i < 4; ++i){
      auto [nr,nc,nd] = make_tuple(mr[i]+r,mc[i]+c,d+1);
      if(nr < 0 || nr >= h || nc < 0 || nc >= w)continue;
      if(color[nr][nc] == '#')continue;
      if(distance[nr][nc] <= nd)continue;
      que.emplace(nr,nc,nd);
    }
  }
  int cnt = 0;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      cnt += color[i][j] == '#';
  cout << max(-1,h * w - cnt - distance[h-1][w-1]) << endl; 
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

LL f[5000 * 5000 + 2333];

int main() {
	ios::sync_with_stdio(false);
	int n, a1, b1, c1, a2, b2, c2;
	cin >> n >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
	memset(f, 0, sizeof(f));
	for(int i = 0; i <= n; ++i) {
		if(i + a1 <= n) chmax(f[i + a1], f[i] + a2);
		if(i + b1 <= n) chmax(f[i + b1], f[i] + b2);
		if(i + c1 <= n) chmax(f[i + c1], f[i] + c2);
		chmax(f[i + 1], f[i] + 1);
	}
	n = f[n];
	memset(f, 0, sizeof(f));
	for(int i = 0; i <= n; ++i) {
		if(i + a2 <= n) chmax(f[i + a2], f[i] + a1);
		if(i + b2 <= n) chmax(f[i + b2], f[i] + b1);
		if(i + c2 <= n) chmax(f[i + c2], f[i] + c1);
		chmax(f[i + 1], f[i] + 1);
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 195712
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, d] <- getIntList
    print $ (n - 1) `div` (2 * d + 1) + 1

Measured memory_bytes: 380
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (abs(a-b)>abs(a-c))
    {
    printf("B\n");
    }
		
	else{
        printf("A\n");
	}
		
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int Q = scanner.nextInt();

            NavigableSet<Long> temples = new TreeSet<>();
            NavigableSet<Long> shrines = new TreeSet<>();
            for (int i = 0; i < A; i++) {
                shrines.add(scanner.nextLong());
            }
            for (int i = 0; i < B; i++) {
                temples.add(scanner.nextLong());
            }
            for (int i = 0; i < Q; i++) {
                long startPos = scanner.nextLong();
                long min = Math.min(dist(shrines, temples, startPos), dist(temples, shrines, startPos));
                System.out.println(min);
            }
        }
    }

    static long dist(NavigableSet<Long> set1, NavigableSet<Long> set2, long pos) {
        long min = Long.MAX_VALUE;
        Pair pair1 = closestDist(set1, pos);
        if (pair1.left != null) {
            min = Math.min(min, dist2(set2, pair1.left, pos));
        }
        if (pair1.right != null) {
            min = Math.min(min, dist2(set2, pair1.right, pos));
        }
        return min;
    }

    static long dist2(NavigableSet<Long> set, Long secondPos, Long pos) {
        if (secondPos == null) {
            return Long.MAX_VALUE;
        }
        Pair second = closestDist(set, secondPos);
        long firstStep = Math.abs(pos - secondPos);
        long min = Long.MAX_VALUE;
        if (second.left != null) {
            long dist = firstStep + Math.abs(second.left - secondPos);
            min = Math.min(dist, min);
        }
        if (second.right != null) {
            long dist = firstStep + Math.abs(second.right - secondPos);
            min = Math.min(dist, min);
        }
        return min;
    }

    static Pair closestDist(NavigableSet<Long> set, long pos) {
        Long ceiling = set.ceiling(pos);
        Long floor = set.floor(pos);
        return new Pair(floor, ceiling);
    }

    static class Pair {
        final Long left;
        final Long right;

        Pair(Long left, Long right) {
            this.left = left;
            this.right = right;
        }
    }

}


Measured memory_bytes: 110236
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#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> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

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

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 &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    string s;
    read(s);

    const int N = s.length();

    vector<int> ans(N);
    {
        int lastL = N - 1;
        repr(i, N-1, 0) {
            if (s[i] == 'R') {
                const int d = lastL - i;
                if (d & 1) ++ans[lastL - 1];
                else ++ans[lastL];
            } else {
                lastL = i;
            }
        }
    }

    {
        int lastR = 0;
        reps(i, 1, N - 1) {
            if (s[i] == 'L') {
                const int d = i - lastR;
                if (d & 1) ++ans[lastR + 1];
                else ++ans[lastR];
            } else {
                lastR = i;
            }
        }
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 1104
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var mae = lines[0];
 if(mae == "ARC"){
   console.log("ABC");
 }else{
   console.log("ARC");
 }
});

Measured memory_bytes: 30064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
	int a[10];
	scanf("%d %d %d", &a[1], &a[2], &a[3]);
	sort(a + 1, a + 1 + 3);
	int ans = 0;
	ans = ans + (a[3] - a[1]) / 2;
	ans = ans + (a[3] - a[2]) / 2;
	if((a[3] - a[1]) % 2 == 1) a[1] = a[3] - 1;
	else a[1] = a[3];
	if((a[3] - a[2]) % 2 == 1) a[2] = a[3] - 1;
	else a[2] = a[3];
	if(a[1] == a[2] && a[1] == a[3]) {}
	else if(a[1] == a[2] && a[1] == a[3] - 1) ans++;
	else if(a[1] == a[3] - 1 && a[2] == a[3] || a[2] == a[3] - 1 && a[1] == a[3]) ans+= 2;
	printf("%d\n", ans);
}

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

int main() {
        int h, w;

        while(true) {
                cin >> h >> w;
                if(h == 0 && w == 0) break;
                for(int i = 0; i < h; i++) {
                        for(int n = 0; n < w; n++) {
                                if((i + n) % 2 == 0) {
                                        printf("#");
                                } else {
                                        printf(".");
                                }
                        }
                        cout << endl;
                }

                cout << endl;
        }
}



Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll ans = A[0];
  for(int i=0;i<N-2;++i) {
    ans += A[(i+2)/2];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4856
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a := nextInt()

	fmt.Println(a + a * a + a * a * a)
}


Measured memory_bytes: 1804
using System;
using System.IO;
using System.Collections.Generic;
namespace aoj{
    class program{
    static void Main() {
        distance dis=new distance(Console.ReadLine());
        Console.WriteLine("{0}",dis.dist());
    }
}

class point{
	public double x;
	public double y;
		public point(double dx,double dy){
		x=dx;
		y=dy;
	}
}
class distance{
	point p1;
	point p2;
    public distance(string str){
		char[] sep = new char[] {' '};
		string[] tmp=str.Split(sep);
		p1=new point(double.Parse(tmp[0]),double.Parse(tmp[1]));
		p2=new point(double.Parse(tmp[2]),double.Parse(tmp[3]));
	}
    public double dist(){
		return Math.Pow(Math.Pow(p1.x-p2.x,2)+Math.Pow(p1.y-p2.y,2),0.5);
    }
 
}
}

Measured memory_bytes: 5816
#遅くなるけど実装や思考が楽?なパターン，各Hで2^7を試す

import itertools

H,W,K=map(int,input().split())

#隣り合うとこ路に線を引く場合にfalse
def check(L):
    n=len(L)
    for i in range(1,n):
        if L[i]==1 and L[i-1]==1:
            return False
    return True
        


#高さiまででj番目の通り数
dp=[[0]*W for _ in range(H+1)]
dp[0][0]=1#高さ0では1に行けるのが1通り
mod=10**9+7

for i in range(H):
    for ite in itertools.product([0,1], repeat=(W-1)):
        ite=list(ite)
        ite.append(0)
        if check(ite):
            flag=0
            for j in range(W):
                if flag==1:
                    dp[i+1][j-1]+=dp[i][j]
                    dp[i+1][j-1]%=mod
                    flag=0
                elif ite[j]==1:
                    dp[i+1][j+1]+=dp[i][j]
                    dp[i+1][j+1]%=mod
                    flag=1
                else:
                    dp[i+1][j]+=dp[i][j]
                    dp[i+1][j]%=mod
                    
print(dp[-1][K-1])

Measured memory_bytes: 45148
k = int(input())

r = set()
x = 7
i = 1
while True:
    rr = x % k
    if rr == 0:
        print(i)
        break
    if rr in r:
        print(-1)
        break
    x = (x * 10 + 7) % k
    i += 1
    r.add(rr)

Measured memory_bytes: 78084
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define zero(dp) memset(dp,0,sizeof(dp))
#define pb emplace_back
#define sublime 
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{
	string s;cin>>s;
	set<char> st;
	for(int i=0;i<3;i++)st.insert(s[i]);
	if(st.size()>1)cout<<"Yes\n";
	else cout<<"No";
}
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,a,b;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  if((b - a)%2 == 0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;

}

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


Measured memory_bytes: 256
import math
N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
answer=0
A.reverse()
B.reverse()
number=0
for a in A:
    a+=answer
    answer+=math.ceil(a/B[number])*B[number]-a
    number+=1
print(answer)


Measured memory_bytes: 56792
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll x;cin>>x;
  ll a,b;
  a=x/500;
  b=(x-a*500)/5;
  cout<<a*1000+b*5;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
P p[114514];
int main(){
	ll n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>p[i].second>>p[i].first;
	}
	sort(p,p+m);
	ll ans=0;
	ll now=-1;
	for(int i=0;i<m;i++){
		if(p[i].second>now){
			ans++;
			now=p[i].first-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+7,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v,v_1,v_2,v_3,v_4,v_5;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll arr[M],ar[M]= {0};
ll cnt=0,cost=0,mx=0,NODE,t;
deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];

int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    ll a,b,c=1,n,sum=0,mx=0,l,x,y,i=0,j=0,result=0,e,sum_2,ans=0,d,k;
    cin>>t;
    for(i=1;i<=5;i++)
    {
        c=c*10;
        if(i==1)
        {
            if(t>=9)
            {
                sum+=9;
            }
            else
            {
                sum+=t;
                break;
            }
        }
        if(i==2)
        {
            if(t>99)
            {
                if(t>1000)
                sum+=900;
                else
                {
                    sum+=t-99;
                }
            }
        }
        if(i==4)
        {
            if(t>9999)
            {
                if(t>=100000)sum+=(90000);
                else sum+=t-9999;
            }
        }
        if(c>t)break;
    }
    cout<<sum<<endl;

        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll numPaper, sumCash;
	cin >> numPaper >> sumCash;
	for (ll x = 0; x <= numPaper; x++) {
		for (ll y = 0; y <= numPaper; y++) {
			ll z = numPaper - x - y;
			ll tmpSum = x * 10000 + y * 5000 + z * 1000;
			if (z >= 0 && tmpSum == sumCash) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int count[26] = { 0 };
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		count[S[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (count[i] == 0) {
			cout << (char)('a' + i);
			return 0;
		}
	}
	cout << "None";
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
	bool f = true;
	int ans = 0;
	int x = 0;
	char y = 0;
	scanf("%d",&ans);
	while(1){
		if(!f){
			scanf(" %d",&x);
		}
		else if(f){
			scanf(" %c",&y);
		}

		if(y == '=')break;
		else if(y == '+' && !f){
			f = true;
			ans += x;
		}
		else if(y == '-' && !f){
			f = true;
			ans -= x;
		}
		else if(y == '*' && !f){
			f = true;
			ans *= x;
		}
		else if(y == '/' && !f){
			f = true;
			ans /= x;
		}
		else {
			f = false;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int min(int a, int b);

int main(){
    int N, B[100000], sum; // sumは整数列Aの合計
    scanf("%d %d",&N, &B[0]); 
    sum = B[0];// ①sumにB[0]を代入
	for (int i = 1; i < N - 1; i++)
	{
		scanf("%d", &B[i]);
        sum += min(B[i - 1], B[i]); // ②min(B[i - 1], B[i])を加算
	}
    sum += B[N - 2]; // ③B[N - 2]を加算
    printf("%d", sum);
}

int min(int a, int b)
{
	return (a < b) ? a : b;
}

Measured memory_bytes: 128