akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main(void){

    ll m1, d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1==m2) cout<<0<<endl;
    else cout<< 1 <<endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int W,H,N,A[10][2];
static char s[1000+2][1000+2];
const int INF=1000000000;
int muki[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int f(int x){
	queue<int> que;
	static int cost[1000+2][1000+2];
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)cost[i][j]=INF;
	cost[A[x][0]][A[x][1]]=0;
	que.push(A[x][0]*1002+A[x][1]);
	while(cost[A[x+1][0]][A[x+1][1]]==INF){
		int c=que.front();
		int nY=c%1002,nX=(c-nY)/1002;
		for(int i=0;i<4;i++){
			if(s[nX+muki[i][0]][nY+muki[i][1]]!='X'&&cost[nX+muki[i][0]][nY+muki[i][1]]==INF){
				cost[nX+muki[i][0]][nY+muki[i][1]]=cost[nX][nY]+1;
				que.push((nX+muki[i][0])*1002+nY+muki[i][1]);
			}
		}
		que.pop();
	}
	return cost[A[x+1][0]][A[x+1][1]];
}

int main(){
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)s[i][j]='X';
	scanf("%d%d%d",&W,&H,&N);
	for(int i=1;i<W+1;i++){
		scanf("%s",&s[i]);
		for(int j=H;j>0;j--)s[i][j]=s[i][j-1];
		for(int j=1;j<H+1;j++){
			if(s[i][j]=='S'){A[0][0]=i; A[0][1]=j;}
			for(int k=1;k<N+1;k++){
				if(s[i][j]==k+48){A[k][0]=i; A[k][1]=j;}
			}
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		ans+=f(i);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6096
#include <iostream>
#include <string>
#include <regex>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int res=0;
    smatch m;
    for(auto it=cbegin(s); regex_search(it, cend(s), m, regex("[ACGT]+")); it=m[0].second)
        res=max<int>(res, m.str().size());
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> V;
const long long MOD=1000000007LL;
const long long INFL=1LL << 60;
const int INF=1<<29;


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

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


void solve(long long H, long long W, long long A, long long B){
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            int ret = 0;
            if (i<B && j <A) ret = 1;
            if (i>=B && j>=A) ret=1;
            printf("%d",ret);
        }
        printf("\n");
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(H, W, A, B);
    return 0;
}


Measured memory_bytes: 1280
x,y = map(int,input().split(" "))

line_1 = [[0 for _ in range(y)] for _ in range(x)]
for i in range(x):
	line_1[i] = list(map(int,input().split(" ")))

line_2 = [int(input()) for _ in range(y) ]

[print(sum([line_1[k][m] * line_2[m] for m in range(y)])) for k in range(x)]



Measured memory_bytes: 6036
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

vector<string> bbb;



int main(void){
    const double pi = 3.14159265358979323846;
    // cout << setprecision(11) << pi << endl;
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double hh = pi*(0.5-(double)h/6.0-(double)m/360.0);
    double mm = pi*(0.5-(double)m/30.0);
    // cout << setprecision(11) << hh << endl;
    // cout << setprecision(11) << mm << endl;
    double ax = cos(hh)*a;
    double ay = sin(hh)*a;
    double bx = cos(mm)*b;
    double by = sin(mm)*b;
    // cout << setprecision(11) << ax << endl;
    // cout << setprecision(11) << ay << endl;
    // cout << setprecision(11) << bx << endl;
    // cout << setprecision(11) << by << endl;
    cout << setprecision(11) << sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) << endl;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const ll INF = (1ll << 60) - 1;

int n,k;
int a[MAXN];

ll ans;
ll sum1[MAXN];
ll sum2[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i];
		sum1[i] = sum1[i - 1] + a[i];
		sum2[i] = sum2[i - 1] + max(a[i],0);
	}
	ans = -INF;
	for (int i = 1;i + k - 1 <= n;i++)
		ans = max(ans,max(0ll,sum1[i + k - 1] - sum1[i - 1]) + sum2[n] - sum2[i + k - 1] + sum2[i - 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
    int n,i,ans=0;
    int p[25];

    cin >> n;
    for (i=0;i<n;i++){
        cin >> p[i];
    }
    
    for (i=0;i<n-2;i++){
        if ((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1] && p[i+1]>p[i+2])){
            ans+=1;
        }
    }
    cout << ans << endl;
}

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

const int INF = 1001001001;
int n,a,b;

int main() {
  cin>>n>>a>>b;
  a -= b;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin>>d[i];
  int l = 0, r = INF;
  while (l+1<r) {
    ll mid = (l+r)>>1; // mid, 切り捨て
    ll t = 0;
    for (int i=0; i<n; i++) {
      ll x = max(d[i]-mid*b,0LL);
      ll s = (x+a-1)/a;  // ll s = (x>=a)?x/a:1
      t += s;
    }
    if (t <= mid) r = mid;
    else l = mid;
  }
  cout << r << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  
  for(int i=0;i<N;i++){
    cin >> l.at(i) >> r.at(i);
  }
  
  int answer = 0;
  
  for(int i=0;i<N;i++){
    answer = answer + r.at(i) - l.at(i) + 1;
  }
  
  cout << answer << endl;
}

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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE 
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    long long int sum=0;
    for(int i=0;i<s.length();i++)
        sum=sum+(s[i]-'0');
    if(sum%9==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
 } 

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	int n;
	cin >> n;
	map < string, int > cnt;
	for(string tmp; n-- && cin >> tmp; cnt[tmp]++);
	vector < string > order = {"AC", "WA", "TLE", "RE"};
	for(string & s : order)
		cout << s << " x " << cnt[s] << "\n";
	return 0;
}


Measured memory_bytes: 3680
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()
print(max(a+b, a-b, a*b))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    """
    書き足した辺は，子孫に対してのものなのでいわゆるショートかっと．
    後から同じ頂点にたどり着いた場合，そちらを優先する？

    """
    
    mod=10**9+7
    N,M=MI()
    fro=[[]for _ in range(N)]
    to=[[]for _ in range(N)]
    
    for _ in range(N+M-1):
        a,b=MI()
        a-=1
        b-=1
        fro[b].append(a)
        to[a].append(b)
        
    root=0
    target=[0]*N
    for i in range(N):
        target[i]=len(fro[i])
        if target[i]==0:
            root=i
        
    P=[-1]*N
    
    #何回通ったかカウント，これがtargetと一致した場合だけ先に進む（最後の一個だけを通すようにする）
    count=[0]*N
    
    import queue
    q=queue.Queue()
    q.put(root)
    
    while not q.empty():
        v=q.get()
        for nv in to[v]:
            count[nv]+=1
            if count[nv]==target[nv]:
                q.put(nv)
                P[nv]=v
                
    for i in range(N):
        print(P[i]+1)
    
        

main()


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

#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
//UnionFind

int main(){
  int N;cin >> N;
  vector<ll> vec(N);
  map<ll,ll> mp;
  rep(i,N) cin >> vec[i];
  rep(i,N){
    mp[vec[i]]++;
  }
  vector<pair<ll,ll>> edge;
  for(auto m : mp){
    if(m.second >= 2) edge.push_back({m.first,m.second});
  }
  sort(rall(edge));
  if(edge.size() == 0) {
    cout << 0 << endl;
    return 0;
  }else if(edge.size() == 1){
    if(edge[0].second < 4) cout << 0 << endl; 
    return 0;
  }
  if(edge[0].second >= 4) cout << edge[0].first*edge[0].first << endl;
  else {
    cout << edge[0].first * edge[1].first << endl;
  }
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	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{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint dp[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    set<int> a;
    rep(i,m){
        int x;
        cin >> x;
        a.insert(x);
    }
    dp[0] = 1;
    rep(i,n){
        if(a.find(i+1) == a.end()) dp[i+1] += dp[i];
        if(a.find(i+2) == a.end()) dp[i+2] += dp[i];
    }
    cout << dp[n].x << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, j, now = 0;
  char s[200];
  scanf("%s", s);
  for(i = 0; i < strlen(s); ++i) {
    if(s[i] == '(') now++;
    else if(s[i] == ')') now--;
    else break;
  }
  printf("%d\n", now);
  return 0;
}


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

int main(){
  vector<int> c(9);
  rep(i,9){
    cin >> c[i];
  }
  
  int a1 = 0;
  int a2,a3,b1,b2,b3;
  
  b1 = c[0];
  b2 = c[1];
  b3 = c[2];
  
  a2 = c[4]-b2;
  a3 = c[8]-b3;
  
  if(a2+b1==c[3] && a2+b3==c[5] && a3+b1==c[6] && a3+b2==c[7]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = 1 - x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if((x>0)&&(y>0)&&(x<=w-r)&&(y<=h-r)){
		printf("Yes\n");
	}else{
		printf("No\n");
	} 
	
	return 0;
}

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

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

    int avg1 = sum / n;
    int avg2 = avg1 + 1;

    int ans = 0;
    for(i = 0; i < n; i++) {
        ans += pow(abs(avg1 - x[i]), 2);
    }
    int tmp = 0;
    for(i = 0; i < n; i++) {
        tmp += pow(abs(avg2 - x[i]), 2);
    }
    cout << min(ans, tmp) << endl;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		long K = stdIn.nextLong();
		ArrayList<Integer> A = new ArrayList<Integer>();
		ArrayList<Integer> B = new ArrayList<Integer>();
		
		for(int i = 0; i < N; i ++) {
			A.add(stdIn.nextInt());
		}
		for(int i = 0; i < M; i ++) {
			B.add(stdIn.nextInt());
		}
		
		long time = 0;
		int ans = 0;
		
		int idxA = -1;
		int idxB = -1;
		while(true) {
			idxB ++;
			if(M <= idxB) {
				idxB --;
				break;
			}
			time += B.get(idxB);
			ans ++;
			if(K < time) {
				time -= B.get(idxB);
				ans --;
				idxB --;
				break;
			}
		}
		
		int max = ans;
		
		while(idxA < N) {
			idxA ++;
			if(N <= idxA) {
				idxA --;
				break;
			}
			time += A.get(idxA);
			ans ++;
			while(0 <= idxB && K < time) {
				time -= B.get(idxB);
				idxB --;
				ans --;
			}
			if(K < time) {
				time -= A.get(idxA);
				idxA --;
				ans --;
				break;
			}
			max = Math.max(max, ans);
		}
		
		System.out.println(max);
	}
}

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

int main(){

    int a,b;
    cin >> a >> b;

    int ans=0;
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
    if(a>b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp!.to_i
s = gets.chomp!.split('')

cnt = s.count('R') * s.count('G') * s.count('B')

0.upto(n).each do |i|
  (1..).each do |j|
    break if i + 2 * j >= n
    cnt -= 1 if s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j]
  end
end

puts cnt


Measured memory_bytes: 14464
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()


N,M = na()
light = []
for i in range(M):
    t = na()
    s = 0
    for i in t[1:]:
        s += 1 << (i-1)
    light.append(s)

ppp = na()
sum_s = 0
for i in range(1<<N):
    t=0
    for s,p in zip(light,ppp):
        if p == bin(i&s).count("1")%2:
            t+=1
    if t == M:
        sum_s+=1
print(sum_s)

Measured memory_bytes: 3064
# 2019/07/03

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

dp=[[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    v,w=map(int,input().split())
    for j in range(1,W+1):
        if j-w>=0:
            dp[i+1][j]=dp[i][j-w]+v
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
print(dp[-1][-1])



Measured memory_bytes: 25488
import math

N, D = map(int, input().split())
X = [0] * N

for i in range(N):
    X[i] = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    for k in range(i+1, N, 1):
        d = 0
        for l in range(D):
            d += abs((X[i][l] - X[k][l])**2)
        a = math.sqrt(d)
        if a.is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
a = [int(item) for item in input().split()]

cumsum = [0] * n
for i in range(n):
  if i == 0:
    cumsum[0] = a[0]
  else:
    cumsum[i] = cumsum[i-1] + a[i]
    
l = 0
r = 2
ans = sum(a)
for i in range(1, n-1):
  while cumsum[i] - cumsum[l+1] > cumsum[l]:
    l += 1
  while cumsum[-1] - cumsum[r+1] > cumsum[r] - cumsum[i]:
    r += 1
  a = cumsum[l]
  b = cumsum[i] - cumsum[l]
  c = cumsum[r] - cumsum[i]
  d = cumsum[-1] - cumsum[r]
  
  ans = min(ans, max(a,b,c,d) - min(a,b,c,d))
print(ans)

Measured memory_bytes: 24672
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int a,b,C;
    cin >> a >> b >> C;
    double rad;
    double PI = acos(-1);
    rad = C*PI/180;

    double S,L,h,c;
    h = b*sin(rad);
    S = a*h/2;
    c = sqrt(a*a+b*b-2*a*b*cos(rad));
    L = a+b+c;

    printf("%f\n%f\n%f\n",S,L,h);

    return 0;
}


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

int main(){
  int n,m;
  int d[300][4];
  int dp[3][301];
  string tmp;

  while(cin >> n >> m){
    for(int i=0;i<n;i++){
      cin.ignore();
      getline(cin,tmp);
      for(int j=0;j<4;j++)cin >> d[i][j];
    }

    

    for(int i=0;i<3;i++){
      for(int j=0;j<=m;j++)dp[i][j] = 0;
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
	dp[j][d[i][0]] = max(dp[j][d[i][0]],d[i][j+1]);
      }
    }

    for(int i=0;i<3;i++){
      for(int j=1;j<=m;j++){
	for(int k=0;k<=j/2;k++){
	  dp[i][j] = max(dp[i][j],dp[i][k]+dp[i][j-k]);
	}
      }
    }

    int ans = 0;
    for(int i=0;i<3;i++)ans = max(ans,dp[i][m]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>

int main(int argc, char** argv)
{
	int a, b;
	char op;

	while (true)
	{
		std::cin >> a >> op >> b;

		if (op == '?')
		{
			break;
		}

		switch (op)
		{
		case '+':
			std::cout << a + b << std::endl;
			break;
		case '-':
			std::cout << a - b << std::endl;
			break;
		case '*':
			std::cout << a * b << std::endl;
			break;
		case '/':
			std::cout << a / b << std::endl;
			break;
		default:
			break;
		}
	}

	return 0;
}


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

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

    int ans = 100000000;
    for(int i=1;i<=100;i++){
        int p = i;
        int sum = 0;
        for (int j = 0; j < n; ++j) {
            sum+=(x[j]-p)*(x[j]-p);
        }
        ans =  min(ans, sum);
    }
    cout<<ans<<endl;

    return 0;
}

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

#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define pii pair<int,int>
#define vi vector<int>
#define vit vector<int>::iterator it
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)(v.size())
#define si set<int>
#define ms(a,f) memset((a),(f),sizeof (a))

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf=0x7f7f7f7f;
const int N=1e5+10;
int n;
int main() {
	ll ans=0;
	cin>>n;
	rep(i,1,n) rep(j,1,n) rep(k,1,n) ans+=__gcd(i,__gcd(j,k)); 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N;
  cin >> N;
  
  vi d(N);
  rep(i,N) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  int ans = 0;
  cout << d.at(N/2) - d.at(N/2-1) << endl;
}

Measured memory_bytes: 640
/**
*    created: 04.07.2020 20:55:43
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b;
    cin >> a >> b;
    cout << max(a-b,0LL) << endl;
    return 0;
}

Measured memory_bytes: 3652
using AtCoderBeginnerContest149.Questions;
using AtCoderBeginnerContest149.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest149.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var x = inputStream.ReadInt();
            yield return GetPrimes(x * 10).First(i => i >= x);
        }

        IEnumerable<int> GetPrimes(int max)
        {
            var isMultipleNumber = new bool[max + 1];

            for (int i = 2; i < max; i++)
            {
                if (!isMultipleNumber[i])
                {
                    yield return i;
                    for (int mul = 1; i * mul <= max; mul++)
                    {
                        isMultipleNumber[i * mul] = true;
                    }
                }
            }
        }
    }
}


namespace AtCoderBeginnerContest149
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest149.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest149.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 12000
import numpy as np
N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))
H = np.array(h)

def test(n):
    x = H - n*B
    x[x<0] = 0
    return np.ceil(x/(A-B)).sum() <= n

left = 0
right = 10**9

while right - left > 1:
    mid = (left + right)//2
    if test(mid):
        right = mid
    else:
        left = mid
ans = right
print(ans)

Measured memory_bytes: 20752
import math
import heapq
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7


def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n)]
    cd = [list(map(int, input().split())) for i in range(m)]

    for i in range(n):
        c = float("inf")
        ans = 0
        for j in range(m):
            if c > abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]):
                c = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
                ans = j + 1
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

/*

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp>     //required
using namespace __gnu_pbds;              //required
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<int> s;
// special `tree` functions:
cout << s.order_of_key(3) << endl;	// the number of elements in s less than 3 (in this case, 0-based index of element 3)
out << *s.find_by_order(1) << endl; // 1-st elemt in s (in sorted order, 0-based)

*/

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n,i,j,k,t,temp;
    LL w,h;
    cin>>h>>w;
    if(h==1 || w==1)
    {
        cout<<1<<endl;
        return 0;
    }
    LL ans=h*w;
    ans/=2;
    ans+=(h*w)%2;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println(800 * n - n / 15 * 200);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;

typedef vector<pair<int,int>> vpii;
typedef pair<int,int> pr;

int main(){
    int a,b,i,res;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_S 110
#define MAX_K 60
#define MAX_D 110
#define MAX_M 410

using namespace std;

int s,d,m,k[MAX_S],w[MAX_S][MAX_K],p[MAX_S][MAX_K],f[MAX_D],pre[MAX_S][MAX_M],dp[MAX_D][MAX_M],mincost[MAX_D][MAX_M];


int main(){

  while(cin >> s >> d >> m){

    rep(i,s){
      cin >> k[i];
      rep(j,k[i]) cin >> w[i][j] >> p[i][j];
    }
    rep(i,d) cin >> f[i];

    rep(i,MAX_S)rep(j,MAX_M)pre[i][j] = -1;
    rep(i,MAX_D)rep(j,MAX_M)dp[i][j] = -1, mincost[i][j] = IINF;
    rep(i,MAX_S)pre[i][0] = 0;
    dp[0][0] = 0, mincost[0][0] = 0; 

    rep(i,s){
      rep(j,k[i]){
	for(int l=m;l>=0;l--){
	  if(pre[i][l]==-1)continue;
	  int cost = l + p[i][j];
	  if( cost > m ) continue;
	  pre[i][cost] = max(pre[i][cost],pre[i][l]+w[i][j]);
	}
      }
    }

    int ans = -1;
    rep(i,d){
      rep(j,m+1){
	if( dp[i][j] == -1 ) continue;
	rep(l,m+1){
	  if(pre[f[i]][l] == -1) continue;
	  int cost = j + l;
	  if( cost > m ) continue;
	  if( dp[i+1][cost] == dp[i][j]+pre[f[i]][l] ) {
	    mincost[i+1][cost] = min(mincost[i+1][cost],mincost[i][j]+l);
	  }
	  else {
	    dp[i+1][cost] = max(dp[i+1][cost],dp[i][j]+pre[f[i]][l]);
	    mincost[i+1][cost] = mincost[i][j]+l;
	  }
	  ans = max(ans,dp[i+1][cost]);
	}
      }
    }

    int mini = IINF;
    rep(j,m+1)if(dp[d][j] == ans)mini = min(mini,mincost[d][j]);
    cout << ans << " " << mini << endl;
  }

  return 0;
}

Measured memory_bytes: 1748
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination(int, int);
};
int Combination::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination::Combination(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

void A_Round_One(void) {

	int A, B;
	cin >> A >> B;

	if		(A != 1 && B != 1)	cout << 1 << flush;
	else if (A != 2 && B != 2)	cout << 2 << flush;
	else						cout << 3 << flush;
}

int main(void) {

	A_Round_One();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;cin>>H>>W;
    string board[50];for(int i=0;i<H;++i)cin>>board[i];
    
    const int di[8]={1,1,0,-1,-1,-1,0,1};
    const int dj[8]={0,-1,-1,-1,0,1,1,1};
    
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(board[i][j]=='#')continue;
            
            int num=0;
            for(int d=0;d<8;++d){
                int ni=i+di[d];if(ni<0||H<=ni)continue;
                int nj=j+dj[d];if(nj<0||W<=nj)continue;
                if(board[ni][nj]=='#')++num;
            }
            board[i][j]=char(num+'0');
        }
    }
    for(int i=0;i<H;++i)cout<<board[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import resource
n = int(input())
sys.setrecursionlimit(10**5)

wl = [[] for i in range(n+1)]

for i in range(2,n+1):
    ai = int(input())
    wl[ai].append(i)

dp = [-1 for i in range(n+1)]

def calc_dp(a):
    if len(wl[a]) == 0:
        return 0
    else:
        dps = []
        for i in wl[a]:
            dps.append(calc_dp(i))
        dps.sort(reverse=True)
        ma = 0
        for i,dpi in enumerate(dps):
            if ma < dpi+i:
                ma = dpi+i
        return ma+1

print(calc_dp(1))


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

int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int i;
        int num=0;
        for(i=0;i<n;i++)
        {
            int x;
            cin>>x;
            if(x>=m)
                num++;
        }
        cout<<num<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY (1<<30)
using namespace std;
int H,heep[2000001];
void maxheepify(int i){
  int l,r,leagest;
  l=i*2;
  r=i*2+1;
  //左の子、自分、右の子で値が最大のものを選ぶ
  if(l<=H&&heep[l]>heep[i]) leagest=l;
  else leagest=i;
  if(r<=H&&heep[r]>heep[leagest]) leagest=r;
  if(leagest!=i){
    swap(heep[i],heep[leagest]);
    maxheepify(leagest);
  }
}
void increagkey(int i,int key){
  if(key<heep[i]) return;
  heep[i]=key;
  while(i>1&&heep[i/2]<heep[i]){
    swap(heep[i/2],heep[i]);
    i=i/2;
  }
}
void insert(int key){
  H++;
  heep[H]=-INFTY;
  increagkey(H,key);
}
int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=heep[1];
  heep[1]=heep[H--];
  maxheepify(1);
  return maxv;
}
int main(){
  if(H!=0){
    cin>>H;
    for(int i=1;i<=H;i++){
      cin>>heep[i];
    }
    for(int i=H/2;i>=1;i--){
      maxheepify(i);
    }
    for(int i=1;i<=H;i++){
      cout<<heep[i]<<' ';
    }
    cout<<endl;
  }
  int key;
  string com;
  while(1){
    cin>>com;
    if(com=="end") break;
    if(com=="insert"){
      cin>>key;
      insert(key);
    }else{
      cout<<extract()<<endl;
    }
  }
  return(0);
}


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    int sv[100001];
    int tmpsv[100001];
    int ans = 0;

    rep(i,n){
        if(s[i] == 'L'){
            sv[i] = (-1);
        }else sv[i] = (1);
    }

    function<int(int, int)> turn = [&](int leftside, int rightside)-> int{
        int l = 0;
        int r = n - 1;

        rep(i,n){
            tmpsv[i] = (sv[i]);
        }


        rep(i,k){
            if(l > r) break;

            while(tmpsv[l] == leftside * ((i % 2) * -2 + 1) ){
                if(i % 2 == 1) tmpsv[l] = tmpsv[l] * -1;
                l++;
            }

            while(tmpsv[r] == rightside * ((i % 2) * -2 + 1)){
                if(i % 2 == 1) tmpsv[r] = tmpsv[r] * -1;
                r--;
            }

            tmpsv[l] = leftside;
            tmpsv[r] = rightside;

            //cerr << l << " " << r << endl;

            l++;
            r--;
        }

        if(k % 2 == 1){
            for(int i = l; i <= r; i++){
                tmpsv[i] = tmpsv[i] * -1;
            }
        }

        int happy = 0;

        rep(i,n){
            if(i == 0 && tmpsv[i] == -1) continue;
            if(i == n - 1 && tmpsv[i] == 1) continue;
            
            if(tmpsv[i] == tmpsv[i + tmpsv[i]]) happy++;
        }

        return happy;
    };

    //all -1
    int tmpans1 = turn(-1, -1);
    ans = max(ans, tmpans1);

    //all 1
    int tmpans2 = turn(1, 1);
    ans = max(ans, tmpans2);

    //from left -1, from right 1
    int tmpans3 = turn(-1, 1);
    ans = max(ans, tmpans3);


    //from left 1, from right -1
    int tmpans4 = turn(1, -1);
    ans = max(ans, tmpans4);

    cout << ans << endl;
    return 0;
}


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

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

    int r[N+1], t[N+1];

    for (int i =1; i<=N ;i++) {
        cin >> r[i];
        cin >> t[i];
    }

    for (int i=1; i<=N;i++) {
        if (r[i] % 100 == 0 && t[i] % 30 == 0) {
            cout << (r[i] / 100) + (5 * (t[i] / 30 )) << endl;
        } else if (r[i] % 100 != 0 && t[i] % 30 == 0) {
            int temp_r = r[i] % 100;
            cout <<  ( (r[i] - temp_r) / 100 ) + (5 * (t[i] / 30) );
            cout << " ";
            cout <<  ( (r[i] + 100 - temp_r) / 100 ) + (t[i] / 30 * 5) << endl;
        } else if (r[i] % 100 == 0 && t[i] % 30 != 0) {
            int temp_t = t[i] % 30;
            cout <<  (r[i] / 100 ) + ( (t[i] - temp_t) / 30 * 5);
            cout << " ";
            cout <<  (r[i] / 100 ) + ( (t[i] + 30 - temp_t) / 30 * 5)<< endl;
        } else {
            int temp_r = r[i] % 100;
            int temp_t = t[i] % 30;
            cout <<  ( (r[i] - temp_r) / 100 ) + ( (t[i] - temp_t) / 30 * 5);
            cout << " ";
            cout <<  ( (r[i] + 100 - temp_r) / 100 ) + ( (t[i] - temp_t) / 30 * 5);
            cout << " ";
            cout <<  ( (r[i] - temp_r) / 100 ) + ( (t[i] + 30 - temp_t) / 30 * 5);
            cout << " ";
            cout <<  ( (r[i] + 100 - temp_r) / 100 ) + ( (t[i] + 30 - temp_t) / 30 * 5) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> ac(N), sum(N + 1);
    for (int i = 0; i < N - 1; i++) if (S[i] == 'A' && S[i + 1] == 'C') ac[i + 1] = 1;
    for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + ac[i];

    int l, r;
    int cnt;
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        cnt = sum[r] - sum[l - 1];
        if (ac[l - 1]) cnt--;
        cout << cnt << '\n';
    }
}


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

struct Node {
	long long to, cost, rev;
};

vector<Node> X[1009]; bool used[1009];

void add_edge(int u, int v, int w) {
	X[u].push_back(Node{ v, w, (long long)X[v].size() });
	X[v].push_back(Node{ u, 0, (long long)X[u].size() - 1 });
}

int dfs(int pos, int to, long long f) {
	if (f == 0) return 0;
	if (pos == to) return f;
	used[pos] = true;

	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i].to] == true) continue;
		int G = dfs(X[pos][i].to, to, min(f, X[pos][i].cost));
		
		if (G != 0) {
			X[pos][i].cost -= G;
			X[X[pos][i].to][X[pos][i].rev].cost += G;
			return G;
		}
	}
	return 0;
}

long long mincost_flow(int u, int v) {
	long long F = 0;
	while (true) {
		for (int i = 0; i < 1009; i++) used[i] = false;
		long long Z = dfs(u, v, (1 << 30));
		if (Z == 0) break;
		F += Z;
	}
	return F;
}

long long N, a[100009], sum; vector<int>L1, L2;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i]; sum += max(0LL, a[i]);
		if (a[i] >= 0) L2.push_back(i);
		else L1.push_back(i);
	}

	for (int i = 0; i < L1.size(); i++) add_edge(0, L1[i], -a[L1[i]]);
	for (int i = 0; i < L2.size(); i++) add_edge(L2[i], N + 1, a[L2[i]]);
	for (int i = 0; i < L1.size(); i++) {
		for (int j = 0; j < L2.size(); j++) { if (L2[j] % L1[i] == 0) add_edge(L1[i], L2[j], (1 << 30)); }
	}
	long long E = mincost_flow(0, N + 1);
	cout << sum - E << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long K){
    cout << K/2 * (K-K/2) << endl;
}

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


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

using namespace std;

typedef long long int Int;

int main(void)
{
    string s;
    char data[4]= {'Y','A','K','I'};
    cin>>s;

    if(s.size() < 4)
    {
	cout<<"No"<<endl;

	return 0;
    }
    for(int i = 0;i < s.size() && i < 4;i++)
    {
	if(s[i] != data[i])
	{
	    cout<<"No"<<endl;

	    return 0;
	}
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
/*    
 *  eat_code    
 *  IIIT Allahabad
 */
#include <bits/stdc++.h>
//#include "pretty_print.h"
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; cin >> ___T; while (___T-- > 0) 


#define rep(it, st, en) for(ll it = st; it < en; it++)
#define rep1(it, st, en) for(ll it = st; it <= en; it++)
#define per(it, st, en) for(ll it = en - 1; it >= st; it--)

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
    boost;
    if(fopen("input.txt", "r")){
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    }
    int n, m;
    cin >> n;
    ll d, t;
    map<ll, int> cnt;
    rep(i, 0, n){
        cin >> d;
        cnt[d]++;
    }
    cin >> m;
    bool ok = true;
    rep(i, 0, m){
        cin >> t;
        if(!CONTAINS(cnt, t) || cnt[t] == 0)ok = false;
        else cnt[t]--;
    }
    if(ok)cout << "YES" << "\n";
    else cout << "NO" << "\n";
    return 0;
}
//  Train Insane or Remain the same
 

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    for (size_t i = 0; i < 10; i++)
    {
        cout << a*c-b << endl;
        c = a*c-b;
    }
    
    return 0;
}

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

int n,ans,s,e,se;
char x[15];

int main(){
    scanf("%d",&n);
    for(int sz,i=0; i<n; ++i){
        scanf("%s",x);
        sz=strlen(x);
        if(x[0]=='B'){
            if(x[sz-1]=='A') ++se;
            else ++e;
        } else{
            if(x[sz-1]=='A') ++s;
        }
        for(int j=1; j<sz; ++j){
            if(x[j-1]=='A' && x[j]=='B') ++ans;
        }
    }
    if(!s && !e){
        if(se) printf("%d",ans+se-1);
        else printf("%d",ans);
    } else{
        printf("%d",ans+se+min(s,e));
    }
    return 0;
}


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

int main()
{

    int n;
    cin>>n;
    string s,t;
    char ch[2*n];
    cin>>s>>t;
    int k=0;

    for(int i=0;i<n;i++)
    {
        ch[k]=s[i];
        ch[k+1]=t[i];
        k+=2;
    }

for(int i=0;i<2*n;i++)
{
    cout<<ch[i];
}

    return 0;

}


Measured memory_bytes: 256