akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
int K;
ll a[3010];
ll dp[3010][3010]={0};
int main(){
	cin>>N;
	rep(i,N)cin>>a[i],dp[i+1][i+1]=a[i];
	//rep(i,N)rep(j,N)cout<<dp[i+1][j+1]<<endl;
	for(int i=N;i>=1;i--){
		for(int j=i+1;j<=N;j++){
			dp[i][j]=max(-dp[i+1][j]+a[i-1],-dp[i][j-1]+a[j-1]);
		}
	}
	ll ans=0;
	cout<<dp[1][N]<<endl;
}

Measured memory_bytes: 70016
n = gets.to_i
n.times do
    o = gets.strip
    m = gets.strip
    o.reverse.each_char do |ord|
        case ord
        when "J"
            m = m.split(//).rotate(-1).join
        when "C"
            m = m.split(//).rotate(1).join
        when "E"
            if m.length % 2 == 0
                m[0...(m.length/2)], m[(m.length/2)...m.length] = m[(m.length/2)...m.length], m[0...(m.length/2)]
            else
                m[0...(m.length/2)], m[(m.length/2 + 1)...m.length] = m[(m.length/2 + 1)...m.length], m[0...(m.length/2)]                
            end
        when "A"
            m.reverse!
        when "P"
            m.each_char.with_index do |c,i|
                if c.match(/[0-9]/)
                    num = (c.to_i - 1)
                    m[i] = num >= 0 ? num.to_s : "9"
                end
            end
        when "M"
            m.each_char.with_index do |c,i|
                if c.match(/[0-9]/)
                    num = (c.to_i + 1)
                    m[i] = num < 10 ? num.to_s : "0"
                end
            end
        end
    end
    puts m
end

Measured memory_bytes: 6160
#include<iostream>
int main() {
	int a = 0, b = 0;
	std::cin >> a >> b;

	if (a == b) {
		std::cout << a + a << std::endl;
	}else if (a > b) {
		std::cout << a + a - 1 << std::endl;
	}else {
		std::cout << b + b - 1 << std::endl;
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 1 << 18;
int N;
int A[MAX_N];

class Node {
public:
  Node(int l = -INF_INT_MAX, int r = -INF_INT_MAX) : l(l), r(r) {}
  int l, r;

  void add(const Node& node) {
    vector<int> vec;
    vec.push_back(l);
    vec.push_back(r);
    vec.push_back(node.l);
    vec.push_back(node.r);
    sort(begin(vec), end(vec), greater<int>());
    r = vec[0]; l = vec[1];
  }

}nodeList[MAX_N];

signed main()
{
  cin >> N;
  REP(i,1 << N) {
    cin >> A[i];
    nodeList[i].r = A[i];
  }

  REP(i,N) {
    for(int j = 0; j < (1 << N); j += (1 << (i+1))) {
      for(int k = 0; k < (1 << i); k++) {
        nodeList[j+(1 << i)+k].add(nodeList[j+k]);
      }
    }
  }

  int ans = -INF_INT_MAX;
  FOR(i,1,1 << N) {
    ans = max(ans, nodeList[i].l + nodeList[i].r);
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
long long power_mod(long long x, long long y, long long m){
  long long res = 1 ;
  if(y>0){
    res = power_mod(x,y/2,m) ;
    if(y%2==0) res = (res*res)%m ;
    else res = (((res*res)%m)*x)%m ;
  }
  return res ;
}

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

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

  ll a, b, x, y;
  cin >> a >> b;
  cout << power_mod(a,b,MOD) <<endl;




  return 0;
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 1000005;
string S;
int dp[MAX_N][2];

signed main()
{
  cin >> S;
  reverse(begin(S), end(S));

  REP(n,MAX_N) {
    dp[n][0] = dp[n][1] = INF_LL;
  }
   
  dp[0][0] = 0;

  REP(n,S.size()) {
    dp[n+1][0] = min(dp[n+1][0], dp[n][0] + S[n] - '0');
    dp[n+1][1] = min(dp[n+1][1], dp[n][0] + 10 - (S[n] - '0'));

    if(S[n] <= '8') {
      dp[n+1][0] = min(dp[n+1][0], dp[n][1] + S[n] - '0' + 1);
      dp[n+1][1] = min(dp[n+1][1], dp[n][1] + 10 - (S[n] - '0' + 1));
    } else {
      dp[n+1][1] = min(dp[n+1][1], dp[n][1]);
    }
  }

  cout << min(dp[S.size()][0], dp[S.size()][1] + 1) << endl;

  return 0;
}


Measured memory_bytes: 17028
import itertools

b_lis = []
j_lis = []
N,M = map(int,input().split())
for i in range(M):
    b_lis.append(list(map(int,input().split())))
    
n_lis =list(range(2,N+1))
#print(n_lis)
count = 0
for i in itertools.permutations(n_lis):
    frag = 1
    #print(i)
    l = [1]
    l.extend(i)
    
    for k in range(N-1):
        if [l[k],l[k+1]] in b_lis or [l[k+1],l[k]] in b_lis:
            pass
            #print(k,b_lis,[l[k+1],l[k]])
        else:
            frag = 0
            break
    if frag == 1:
        count += 1
        #print(l)

print(count)
        


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int n,L,ans,a;
  scanf("%d%d",&n,&L);
  if(L>0)a=L;
  else if(n+L-1<0)a=n+L-1;
  else a=0;
  ans=(2*L+n-1)*n/2-a;
  
  
  printf("%d",ans);
}


Measured memory_bytes: 128
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int (t); cin>>(t);while((t)--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif

	char str[10];

	cin>>str;

	if (str[2]==str[3]  && str[4]==str[5])
		cout<<"Yes\n";

	else
		cout<<"No\n";

	return 0;
}

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

bool vis[50];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;++i){
        int x;
        cin>>x;
        vis[x]=1;
	}
	for(int i=n;;++i){
        int j=i;
        bool fg=0;
        while(j>0){
            if(vis[j%10]){fg=1;break;}
            j/=10;
        }
        if(fg==0){
            cout<<i<<endl;return 0;
        }
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

int main(void) {
	while(true) {
		int N, K;
		scanf("%d %d", &N, &K);
		if(N == 0 && K == 0)
			break;
		int blood[100];

		// int **order = (int **)calloc(N, sizeof(int));
		//int *order = (int *)calloc(N, sizeof(int));
		/*for(int i = 0; i < N; i++)
			order[i] = (int *)calloc(K, sizeof(int));
		*/
		for(int i = 0; i < K; i++) {
			scanf("%d", &blood[i]);
		}

		for(int i = 0; i < N; i++) {
			for(int j = 0; j < K; j++) {
				int order;
				scanf("%d", &order);
				blood[j] -= order;
			}
		}
		bool flag = true;
		for(int i = 0; i < K; i++) {
			if(blood[i] < 0)
				flag = false;
		}

		if(flag == true)
			printf("Yes\n");
		else
			printf("No\n");

	}
	return 0;
}

Measured memory_bytes: 732
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007

#define pb push_back
#define fs first
#define se second
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //  #ifndef ONLINE_JUDGE
    //     freopen("mengawasi_sample_1.in", "r", stdin);
    //     freopen("mengawasi_sample_1.out", "w", stdout);
    // #endif
    ll n;
    unordered_map<string,ll>um;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        string h;
        cin>>h;
        sort(h.begin(),h.end());
        um[h]++;
    }
    ll ans=0;
    for(auto i:um)
    {
        ll k=i.se;
        ans+=k*(k-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
char s[maxn];
int n,p,c[13],dp[13];
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a,int b) {
  a+=b;
  return a>=mod?a-mod:a;
}
int sub(int a,int b) {
  a-=b;
  return a<0?a+mod:a;
}
int mul(int a,int b) {
  return (int)((long long)a*b%mod);
}



int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    reverse(s+1,s+1+n);
    p=1;
    dp[0]=1;
    for(int i=1;i<=n;i++){
        memset(c,0,sizeof(c));
        for(int j=0;j<10;j++){
            if(j==(s[i]-'0')||s[i]=='?'){
            for(int k=0;k<13;k++){
                int cur=((k+((1LL*j*p)%13))%13);
                plusle(c[cur],dp[k]);
            }
            }
        }
        for(int j=0;j<13;j++){
            dp[j]=c[j];
        }
        p=((1LL*p*10)%13);
    }
    cout<<dp[5]<<'\n';

}
/*
    Good Luck
        -Lci70121
*/


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

int main(){
    int x, y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0)
            break;
        if(x > y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


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

bool kai(string s, int b, int e) {
    int n = e - b;
    bool tf = true;
    for(int i = b; i < n/2; i++) {
        if(s[i] != s[n-1-i])
            tf = false;
    }
    
    return tf;
}

int main() {
    string s;
    cin >> s;
    
    int n = (int)s.size();
    
    bool ans1 = kai(s,0,n);
    bool ans2 = kai(s,0,n/2);
    bool ans3 = kai(s,(n+1)/2,n);
    //cout << ans1 << ans2 << ans3 << endl;
    
    if(ans1 && ans2 && ans3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(5);
    ll m = 1e18;
    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
        m = min(m, a[i]);
    }
    ll x = n / m;
    if(x == 0)
    {
        cout << 5 << endl;
        return 0;
    }
    if(n % m != 0)
    {
        x++;
    }
    cout << x + 4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <set>
using namespace std;
int main() {
    set<int> sq;
    for (int i = 0; i <= 316; i++) sq.insert(i * i);
    string a, b;
    cin >> a >> b;
    set<int>::iterator itr = sq.find(atoi((a+b).c_str()));
    cout << (itr == sq.end() ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
class Point
	@@RAD60 = Math::PI * 60.0 / 180.0

	attr_accessor :x, :y

	def initialize(x, y)
		@x, @y = x, y
	end

	def to_s
		sprintf("%.8f %.8f", @x, @y)
	end

	def self.trisection(p1, p2)
		x1 = (2 * p1.x + p2.x) / 3
		y1 = (2 * p1.y + p2.y) / 3
		x2 = (p1.x + 2 * p2.x) / 3
		y2 = (p1.y + 2 * p2.y) / 3
		return Point.new(x1, y1), Point.new(x2, y2)
	end

	def self.triangle_vertex(p1, p2)
		x = (p2.x - p1.x) * Math.cos(@@RAD60) - (p2.y - p1.y) * Math.sin(@@RAD60) + p1.x
		y = (p2.x - p1.x) * Math.sin(@@RAD60) + (p2.y - p1.y) * Math.cos(@@RAD60) + p1.y
		Point.new(x, y)
	end

	def self.print_koch_curve(start_point, end_point, depth)
		print_koch_curve_base(start_point, end_point, depth)
		puts end_point
	end

	private
	def self.print_koch_curve_base(start_point, end_point, depth)
		if depth == 0
			puts start_point
			return
		end

		p1, p2 = trisection(start_point, end_point)
		p3 = triangle_vertex(p1, p2)

		print_koch_curve_base(start_point, p1, depth - 1)
		print_koch_curve_base(p1, p3, depth - 1)
		print_koch_curve_base(p3, p2, depth - 1)
		print_koch_curve_base(p2, end_point, depth - 1)
	end

end

start_point = Point.new(0.0, 0.0)
end_point   = Point.new(100.0, 0.0)
depth = STDIN.gets.to_i
Point.print_koch_curve(start_point, end_point, depth)

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


int main() 
{
	int a,b;
  	char op;
  
  	while(op!='?'){
      cin>>a>>op>>b;
      
      if(op=='+')
        cout<<a+b<<endl;
      else if(op=='-')
        cout<<a-b<<endl;
      else if(op=='*')
        cout<<a*b<<endl;
      else if(op=='/')
        cout<<a/b<<endl;
    }
  
    return 0;
}




Measured memory_bytes: 3092
import itertools

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0
for ht in itertools.product((0, 1), repeat=H):
    for wt in itertools.product((0, 1), repeat=W):
        black = 0
        for h, w in itertools.product(range(H), range(W)):
            if C[h][w] == '#' and not (ht[h] or wt[w]):
                black += 1
        if black == K:
            ans += 1
print(ans)

Measured memory_bytes: 9008
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

if(n==1):
    print(a[0]-x)
    exit()
ope=0
if(a[0]>x):
    ope+=a[0]-x
    a[0]=x

for i in range(n-1):
    c=a[i]+a[i+1]
    if(c>x):
        a[i+1]-=c-x
        ope+=c-x
print(ope)

Measured memory_bytes: 14540
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		int mini = 10000;
		
		for(int i = 1; i < 1001; ++i){
		    
		    int a_ans = (int)(i * 0.08);
		    int b_ans = (int)(i * 0.10);
		    
		    if((a_ans == a) && (b_ans == b)) {
		        if(mini >= i) mini = i;
		        else continue;
		    }
		    else continue;
		}
		
		//System.out.println(a);
		//System.out.println(b);
		//System.out.println(mini);
		
		if(mini == 10000) System.out.println(-1);
		else System.out.println(mini);
		
	}
}

Measured memory_bytes: 24020
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a[100001],vis[100001];
inline int read(){
	int x=0,f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			f=-1;
	for(;isdigit(c);c=getchar())
		x=x*10+c-'0';
	return x*f;
}
int main(){
	int N=read();
	for(int i=1;i<=N;i++){
		a[i]=read();
		vis[a[i]]++;
	}
	int ans=0;
	for(int i=1;i<=100000;i++)
		ans=max(ans,vis[i]+vis[i-1]+vis[i+1]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");


stack<char> getstk(const string &s){
    stack<char> stk;
    for(char c:s){
        
        if(c=='('){
            stk.push(c);
        }else{
            
            if(!stk.empty() && stk.top()=='('){
                stk.pop();
            }else{
                stk.push(c);
            }
        }
        
    }
    return stk;
}

string f(const string &s){
    stack<char> stk=getstk(s);
    string ss="";
    while(!stk.empty()){
        ss+=stk.top();
        stk.pop();
    }
    reverse(all(ss));
    return ss;
}

signed main(){
    FASTER;
    int n;cin>>n;
    vector<string> opn,cls,mid;
    
    for(int i=0;i<n;i++){
        string s;cin>>s;
        s=f(s);
        if(s=="")continue;
        bool op=1,cl=1;
        for(char c:s)op&=(c=='(');
        for(char c:s)cl&=(c==')');
        if(op)opn.push_back(s);
        if(cl)cls.push_back(s);
        if(!op && !cl)mid.push_back(s);
    }
    
    sort(all(mid),[](const string &a,const string &b){
            int aka=0,bka=0;
            for(const char &c:a){
                if(c=='(')aka++;
                else aka--;
            }
            for(const char &c:b){
                if(c=='(')bka++;
                else bka--;
            }
            return aka>bka;
    });
    
    
    string s="";
    for(string a:opn)s+=a;
    for(string a:mid)s+=a;
    for(string a:cls)s+=a;
    
    if(getstk(s).empty())cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 37208
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int x;
    cin >> x;
    if(x) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
} /*atcoder*/


Measured memory_bytes: 3616
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std; 
int main(){ long long s;
           cin >>s;
           int v=pow(10,9);
           int a=(v-s%v)%v;
             int b=(a+s)/v;
        
          
           cout<<"0 0 1000000000 1 "<< " " << a << " " << b <<endl;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    double tmp_x;
    string tmp_u;
    double sum;
    const double btc = 380000.0;

    for ( int i = 0; i < n; i++ ) {
        cin >> tmp_x >> tmp_u;
        if ( tmp_u == "JPY" ) {
            sum += tmp_x;
        }
        else if ( tmp_u == "BTC" ) {
            sum += tmp_x * btc;
        }
    }

    printf("%lf", sum);

    return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int> dp(k+1);
	dp[0]=0;
	for(int i=1;i<=k;i++){
		int x=0;
		for(int j=0;j<n;j++){
			if(i-a[j]>=0&&dp[i-a[j]]==0){
				x=1;
				break;
			}
		}
		dp[i]=x;
	}
	cout <<(dp[k]==1?"First":"Second")<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder w = new StringBuilder(sc.nextLine());
		sc.close();
		
		int index = 0;

		while (true) {

			index = w.indexOf(w.substring(0, 1),1);
			if (index == -1) {
				System.out.println("No");
				break;
			}
			
			w.delete(index, index+1);
			w.delete(0, 1);

			if (w.length() == 0) {
				System.out.println("Yes");
				break;
			}
		}
	}
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef tuple<int, int, int> TT;
signed main() {
    int N, M, S;
    cin >> N >> M >> S;
    vector<int> Graph[N];
    int A[N][N], B[N][N];
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        Graph[u].push_back(v);
        Graph[v].push_back(u);
        int a;
        cin >> a;
        A[u][v] = a;
        A[v][u] = a;
        int b;
        cin >> b;
        B[u][v] = b;
        B[v][u] = b;
    }
    int C[N], D[N];
    rep(i, N) cin >> C[i] >> D[i];
    vector<vector<int>> dis(N, vector<int>(2501, INF));
    S = min(S, (int)2500);
    dis[0][S] = 0;
    priority_queue<TT, vector<TT>, greater<TT>> que;
    que.push(make_tuple(0, 0, S));
    while(!que.empty()) {
        TT t = que.top();
        que.pop();
        int time, now, money;
        tie(time, now, money) = t;
        //cout << time << ' ' << now << ' ' << money << endl;
        if(dis[now][money] < time) continue;
        int nextmoney = min((int)2500, money + C[now]);
        if(dis[now][nextmoney] > time + D[now]) {
            dis[now][nextmoney] = time + D[now];
            que.push(make_tuple(time + D[now], now, nextmoney));
        }
        for(auto next : Graph[now]) {
            int a = A[now][next], b = B[now][next];
            if(money < a) continue;
            if(dis[next][money - a] > time + b) {
                dis[next][money - a] = time + b;
                que.push(make_tuple(time + b, next, money - a));
            }
        }
    }

    for(int i = 1; i <= N - 1; i++) {
        int ans = INF;
        rep(j, 2501) chmin(ans, dis[i][j]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 7400
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);

#define FILENAME ""

const ll maxn = 500000 + 10;
 
 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    for (double i = a; i <= c + 0.5; i+=a) {
        ans += b;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <list>
#include <string>

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

using namespace std;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	list<int> l;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'i') {
			int x;
			cin >> x;
			l.push_front(x);
		}
		else {
			if (s[6] == 'F') {
				l.pop_front();
			}
			else if (s[6] == 'L') {
				l.pop_back();
			}
			else {
				int x;
				cin >> x;
				for (auto itr = l.begin();itr != l.end();++itr) {
					if (*itr == x) {
						l.erase(itr);
						break;
					}
				}
			}

		}
	}
	int i = 0;
	
	for (auto itr = l.begin(); itr != l.end();++itr) {
		if(i++)cout << " ";
		cout << *itr;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 34296
n=int(input())

ans=[]

for i in range(n):
  ans.append(input())
  
def func(ans,moji):
  num=ans.count(moji)
  print(moji,"x",str(num))

mojis=["AC","WA","TLE","RE"]
for moji in mojis:
	func(ans,moji)

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);

template<long P = 1000000007>
class Mod {
public:
  Mod() : a(0) {}
  Mod(long x) : a(x) {}
  long get() { return a; }
  Mod operator + (Mod x) { return Mod<P>((a + x.get()) % P); }
  Mod operator += (Mod x) { a = (a + x.get()) % P; return *this; }
  Mod operator - (Mod x) { return Mod<P>((a + P - x.get()) % P); }
  Mod operator -= (Mod x) { a = (a + P - x.a) % P; return *this; }
  Mod operator * (Mod x) { return Mod<P>((a * x.get()) % P); }
  Mod operator *= (Mod x) { a = (a * x.a) % P; return *this; }
  Mod operator / (Mod x) { return *this * pow(x, P - 2); }
  Mod operator /= (Mod x) { a = (*this * pow(x, P - 2)); return *this; }
private:
  long a;
};

template<typename T>
T pow(T x, long n) {
  T res = 1;
  T p = x;
  while( n != 0 ) {
    if( n & 0x01 ) res *= p;
    p *= p;
    n >>= 1;
  }
  return res;
}

long xs[112345];
long n;

long solve() {
  Mod<> x = 1;
  long c = 0;
  long rem = n;
  for(long i = 1; i < n; ++i) {
    c += 1;
    if( c > (xs[i] + 1) / 2 ) {
      x = x * std::min(c, rem);
      rem -= 1;
      while( c > (xs[i] + 1) / 2 ) {
        c -= 1;
      }
    }
  }
  while( rem != 1 && rem != 0 ) {
    x *= rem;
    rem -= 1;
  }      
  return x.get();
}

int main() {
  scanf("%ld", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%ld", &xs[i]);
  }
  long t = solve();
  printf("%ld\n", t);  
  return 0;
}

Measured memory_bytes: 1024
using System.Text;
using System;

public class hello
{
    public static void Main()
    {
        getAns();
    }
    static void getAns()
    {
        var sb = new StringBuilder();
        var q = int.Parse(Console.ReadLine().Trim());
        var c = 0;
        var a = 0uL;
        while (c++ < q)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0")
            {
                var i = int.Parse(line[1]);
                sb.Append(((a >> i) & 1) == 1 ? "1\n" : "0\n");
            }
            else if (line[0] == "1")
            {
                var i = int.Parse(line[1]);
                a |= 1uL << i;
            }
            else if (line[0] == "2")
            {
                var i = int.Parse(line[1]);
                a &= ~(1uL << i);
            }
            else if (line[0] == "3")
            {
                var i = int.Parse(line[1]);
                a ^= (1uL << i);
            }
            else if (line[0] == "4")
                sb.Append(bitCount(a) == 64 ? "1\n" : "0\n");
            else if (line[0] == "5")
                sb.Append(a > 0 ? "1\n" : "0\n");
            else if (line[0] == "6")
                sb.Append(a == 0 ? "1\n" : "0\n");
            else if (line[0] == "7")
                sb.Append(bitCount(a).ToString() + "\n");
            else sb.Append(a.ToString() + "\n");
        }
        Console.Write(sb);
    }
    static int bitCount(ulong bits)
    {
        bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
        bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
        bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
        bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
        bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
        return (int)(bits & 0x00000000ffffffff) + (int)(bits >> 32);
    }
}



Measured memory_bytes: 20240
#include<iostream>
using namespace std;
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(90);
double r,pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
cin>>r;
r*=pi;
cout<<r*2<<endl;
}

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

int main()
{
	char str[50];
	int arr[50];
	int top;
	int len;
	int num;
	int ans1,ans2;
	scanf("%s",str);
	scanf("%d",&num);
	len=strlen(str);
	arr[0]=str[0]-'0';
	top=0;
	for(int i=1; i<len; i+=2){
		if(str[i]=='*'){
			arr[top]*=str[i+1]-'0';
		}else{
			arr[++top]=str[i+1]-'0';
		}
	}
	ans1=0;
	for(int i=0; i<=top; i++)
		ans1+=arr[i];
	ans2=str[0]-'0';
	for(int i=1; i<len; i+=2){
		if(str[i]=='*')
			ans2*=str[i+1]-'0';
		else
			ans2+=str[i+1]-'0';
	}
	if(ans1==num && ans2==num)
		printf("U\n");
	else if(ans1==num && ans2!=num)
		printf("M\n");
	else if(ans1!=num && ans2==num)
		printf("L\n");
	else if(ans1!=num && ans2!=num)
		printf("I\n");
	
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int t1,t2;
  cin>>t1>>t2;
  t1 *= 10000;
  t2 *= 10000;
  int ans = 1e9;
  const int MAX = 360 * 10000;
  FOR(i,-MAX,MAX){
    int l = (t1+i+MAX+MAX)%MAX;
    int r = (t2-i+MAX+MAX)%MAX;
    if(l==r){
      if(abs(i)<abs(ans))ans = i;
    }
  }
  ans = (ans+t1+MAX)%MAX;
  double yo = (double)ans / 10000;
  printf("%.9f\n",yo);
  return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int X, Y;
    cin >> X >> Y;

    for (int a = 0; a < 110; ++a) {
        for (int b = 0; b < 110; ++b) {
            if (a+b == X and a*2+b*4 == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
const double eps=1e-8;
const double PI=acos(-1);
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
	int main() {
		double a=0,b=0,x=0,Ans=0;
		cin >> a >> b >> x;
		
		if (x > a * a * b / 2.0) {
			double l = 0, r = b;
			while (r - l > eps) {
				double Mid = (l + r) / 2.0;
				double len = a * a * Mid + a * a * (b - Mid) / 2.0;
				(len - x > eps)? r = Mid: l = Mid;
			}
			Ans = atan((b - l) / a) * 180.0 / PI;
			printf("%.9lf\n", Ans);
		} else {
			double l = 0, r = a;
			while (r - l > eps) {
				double Mid = (l + r) / 2.0;
				double len = a * b * Mid / 2.0;
				(len - x > eps)? r = Mid: l = Mid;
			} 
			Ans = atan(b / l) * 180.0 / PI;
			printf("%.9lf\n", Ans);
		} return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n;
  cin >> n;
  cout << (n-1)/2 << endl;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n), b(n);
    loop(i, n) cin >> a[i] >> b[i];
    vector<pair<ll, ll>> c(n); //a+b,aの順
    loop(i, n)
    {
        c[i] = make_pair(a[i] + b[i], a[i]);
    }
    sort(all(c));
    reverse(all(c));
    ll T = 0, A = 0;
    loop(i, n)
    {
        if (i % 2 == 0)
            T += c[i].second;
        else
            A += c[i].first - c[i].second;
    }
    putout(T - A);
    return 0;
}


Measured memory_bytes: 3328
#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>;

int main() {
    int k, x;
    cin >> k >> x;

    if(500*k >= x){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int r, c, i, j, s[100][100], sum = 0, tho[2][100];
	scanf("%d %d", &r, &c);
	for(i = 0; i < r; ++i) {
		for(j = 0; j < c; ++j) {
			scanf("%d", &s[i][j]);
			tho[0][i] += s[i][j];
			tho[1][j] += s[i][j];
			sum += s[i][j];
		}
	}
	for(i = 0; i < r + 1; ++i) {
		for(j = 0; j < c + 1; ++j) {
			if(i == r) {
				if(j == c) {
					printf("%d\n",sum);
					break;
				}
				printf("%d ", tho[1][j]);
				continue;
			}
			if(j == c) {
				printf("%d\n", tho[0][i]);
				break;
			}
			printf("%d ", s[i][j]);
		}
	}
	return 0;
}


Measured memory_bytes: 2132
S = list(input())
K = int(input())
L = len(S)

sum = 0
x = 1
if L == 1:
  print(K//2)
elif L == 2 and S[0] == S[1]:
  print(K)
elif S[0] != S[-1]:
  for i in range(0, L-1):
    if S[i] == S[i+1]:
      x += 1
    else:
      sum += (x // 2)*K
      x = 1
  sum += (x // 2)*K
  print(sum)
else:
  for i in range(0, L-1):
    if S[i] == S[i+1]:
      x += 1
    else:
      sum += (x // 2)
      break
  if x == L:
    print((L * K) // 2)
  else:
    y = x
    x = 1
    for i in range(y, L-1):
      if S[i] == S[i+1]:
        x += 1
      else:
        sum += (x // 2) * K
        x = 1
    sum += (x // 2)
    sum += ((x+y) // 2) * (K-1)
    print(sum)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

// const long long MOD = 1000000007;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint& operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint& operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a)
{
    return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a)
{
    return os << a.x;
}

mint choose(int n, int a)
{
    mint x = 1, y = 1;
    rep(i, a)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

void solve(long long n, long long a, long long b)
{
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
}

int main()
{
    long long n;
    scanf("%lld", &n);
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var A = Reader.IntLine();
        long atmost = Math.Min(A[0], Math.Min(A[3], A[4]));
        long L = 0, R = atmost;

        while (R - L > 3)
        {
            long x1 = L + (R - L) / 3;
            long x2 = L + (R - L) / 3 * 2;
            long fx1 = F(x1, A[0], A[3], A[4]);
            long fx2 = F(x2, A[0], A[3], A[4]);
            if (fx1 < fx2) L = x1;
            else R = x2;
        }
        long ans = 0;
        for (long x = Math.Max(0, L - 10); x <= Math.Min(atmost, L + 10); x++)
            ans = Math.Max(ans, F(x, A[0], A[3], A[4]));
        ans += A[1] * 2L;

        Console.WriteLine(ans / 2);
    }

    long F(long use, long a, long b, long c)
    {
        long res = use * 6L;
        res += (a - use) / 2L * 4;
        res += (b - use) / 2L * 4;
        res += (c - use) / 2L * 4;
        return res;
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 2648
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def solve(N, K, X):
    A = [abs(x - X[0]) for x in X]

    ans = INF
    for i in range(N - K + 1):
        if ans > abs(X[i]) + A[i + K - 1] - A[i]:
            ans = abs(X[i]) + A[i + K - 1] - A[i]

    return ans


def main():
    N, K, *X = map(int, read().split())

    ans = solve(N, K, X)
    ans = min(ans, solve(N, K, X[::-1]))

    print(ans)
    return


if __name__ == '__main__':
    main()


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

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


  

Measured memory_bytes: 3600