akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll cnt = 0;
    cnt += (h / 2) * w;
    if(h & 1) cnt += (w + 1)/2;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
//
// Created by 佐竹俊哉 on 2019/11/12.
//

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int A, B;
    cin >> A >> B;
    int ans = max(0, A - B * 2);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
const int base1 = 317;
const int base2 = 269;
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
long long ans = 0;
string s;
int n;
map<pair<int, int>, int> mp;
int color[40], pw1[40], pw2[40];
void calc(int i, int r, int t) {
    if (i == r) {
        int cnt = 0, a1 = 0, b1 = 0, a2 = 0, b2 = 0;
        for (int j = r - n; j < r; j++)
            if (color[j] == 0) {
                a1 = (1ll * a1 * base1 + s[j] - 'a' + 1) % mod1;
                a2 = (1ll * a2 * base2 + s[j] - 'a' + 1) % mod2;
                cnt++;
            }
        for (int j = r - 1; j >= r - n; j--)
            if (color[j] == 1) {
                b1 = (1ll * b1 * base1 + s[j] - 'a' + 1) % mod1;
                b2 = (1ll * b2 * base2 + s[j] - 'a' + 1) % mod2;
            }
        if (t == 0) {
            a1 = 1ll * a1 * pw1[n - cnt] % mod1;
            a1 -= b1;
            if (a1 < 0) a1 += mod1;

            a2 = 1ll * a2 * pw2[n - cnt] % mod2;
            a2 -= b2;
            if (a2 < 0) a2 += mod2;

            mp[make_pair(a1, a2)]++;
        }
        else {
            b1 = 1ll * b1 * pw1[cnt] % mod1;
            b1 -= a1;
            if (b1 < 0) b1 += mod1;

            b2 = 1ll * b2 * pw2[cnt] % mod2;
            b2 -= a2;
            if (b2 < 0) b2 += mod2;

            ans += mp[make_pair(b1, b2)];
        }
        return;
    }
    color[i] = 0;
    calc(i + 1, r, t);
    color[i] = 1;
    calc(i + 1, r, t);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    cin >> s;
    pw1[0] = 1; pw2[0] = 1;
    for (int i = 1; i <= n; i++) pw1[i] = 1ll * pw1[i - 1] * base1;
    for (int i = 1; i <= n; i++) pw2[i] = 1ll * pw2[i - 1] * base2;
    calc(0, n, 0);
    calc(n, 2 * n, 1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M,C,T;
  cin >> N >> M >> C;
  T=0;
  vector<long long> b(M);
  for (int i=0;i<M;i++) {cin >> b[i];}
  for (int i=0;i<N;i++) {
    vector<long long> a(M);
    for (int j=0;j<M;j++) {cin >> a[j];}
	long long Z=0;
	for (int j=0;j<M;j++) {
	  Z+=a[j]*b[j];
	}
	if (Z+C>0) {T++;}
  }
  cout << T << endl;
}

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

int main() {
    ll N, ans=0;
    cin >> N;
    ll tmp = N/500;
    ans += tmp*1000;
    N -= tmp*500;
    tmp = N/5;
    ans += tmp*5;
    cout << ans << endl;
} 




Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 100100
#define eps 1e-7
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+7;
const long long Maxx=2e18;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
struct node{
	int l,r;
	int id;
	bool operator < (const node &a)const{
		return r>a.r;
	}
};
bool cmp(node a,node b){
	if(a.l==b.l) return a.r<b.r;
	return a.l<b.l;
}
node a[MAXN],b[MAXN];
priority_queue<node>q;
int vis[MAXN];
int n,m,tmp;
void solve(){
	cin>>n>>m;
	while(!q.empty()) q.pop();
	met(vis,0);
	For(i,1,m){
		scanf("%d%d",&a[i].l,&a[i].r);
	}
	sort(a+1,a+1+m,cmp);
	For(i,1,m){
		if(!tmp) {b[tmp++]=a[i];continue;}
		if(b[tmp-1].l<=a[i].l && b[tmp-1].r>=a[i].r) b[tmp-1]=a[i];
		else if(b[tmp-1].l>=a[i].l && b[tmp-1].r<=a[i].r) continue;
		else b[tmp++]=a[i];
	}
	tmp=0;
	For(i,1,m)
		if(!vis[i]) b[tmp++]=a[i];
	sort(b,b+tmp,cmp);
	met(vis,0);
	For(i,0,tmp-1){
		b[i].id=i;
		q.push(b[i]);
	}
	int now=0,ans=0;
	while(!q.empty()){
		node tp=q.top();
		if(vis[tp.id]) {q.pop();continue;}
		while(now<tmp){
			if(b[now].l<tp.r) vis[b[now].id]=1,now++;
			else break;
		}
		q.pop();
		ans++;
	}
	cout<<ans<<endl;
}
int main(){
//  fre("in.txt","r",stdin);
    int t=0;
    solve();
    return 0;
}


Measured memory_bytes: 4600
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};



ll N,M;

const ll MOD = 1e9+7;
const int index = 1e6+1;

ll add(ll a,ll b){
      return ((a%MOD)+(b%MOD))%MOD;
}

ll mul(ll a,ll b){
      return ((a%MOD)*(b%MOD))%MOD;
}

ll pow(ll a,ll b){
      if(b==0) return 1;
      else if(b%2==0) return ((pow(a,b/2)%MOD)*(pow(a,b/2)%MOD))%MOD;
      else return ((pow(a,b-1)%MOD)*(a%MOD))%MOD;
}
ll dvd(ll a,ll b){
      return ((a%MOD)*(pow(b,MOD-2)%MOD))%MOD;
}

ll frac[index+1];
void calc(){ 
      frac[0]=1;
      rep0(i,index){
            frac[i+1]=mul(frac[i],i+1);
      }
}

vector<pair<ll,ll>> primeFactorDecomp(ll n){
      vector<pair<ll,ll>> ret;
      ll m=n;
      for(int i=2;i*i<=m;i++){
            if(n%i!=0) continue;
            int cnt=0;
            while(n%i==0){
                  cnt++;
                  n/=i;
            }
            ret.push_back({i,cnt});
      }
      if(n>1){
            ret.push_back({n,1});
      }
      return ret;
}

int main (){
      cin>>N>>M;
      calc();
      vector<pair<ll,ll>> ps=primeFactorDecomp(M);
      ll ans=1;
      for(auto p : ps){
            ll a=p.second;
            ll comb = dvd(frac[a+N-1],mul(frac[a],frac[N-1]));
            ans=mul(ans,comb);
      }
      cout<<ans<<endl;
      return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    ll A;
    long double B;
    cin >> A >> B;

    ll ans = A * B;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748
#include <stdio.h>
 int main(void){
  float a, b;
  scanf("%f", &a);
  scanf("%f", &b);
  if (a == b){
    printf("a == b\n");
  }
  else if (a > b) {
    printf("a > b\n");
  }
  else {
    printf("a < b\n");
  }
 
  return 0;
}


Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String s = br.readLine();

        double r = Double.parseDouble(s);
        String area = String.format("%.6f", r*r*Math.PI);
        String circum = String.format("%.6f", r*2*Math.PI);
        System.out.println(area + " " + circum);
    }
}

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

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        String sura = sc.next();
        ArrayList<Character> list = new ArrayList<>();
        for(int i = 0; i < hoge; i++){
            if(i == 0){
                list.add(sura.charAt(i));
            }else{
                list.add(sura.charAt(i));
                if(list.get(list.size() - 2) == list.get(list.size() - 1)){
                    list.remove(list.size() - 1);
                }
            } 
        }
        System.out.println(list.size());
    }     
}

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

int main(){
    int ticket_train , pass_train, ticket_bus, pass_bus;
    cin >> ticket_train >> pass_train >> ticket_bus >> pass_bus;

	cout << (ticket_train > pass_train ? pass_train : ticket_train) + (ticket_bus > pass_bus ? pass_bus : ticket_bus) << endl ;

    return 0;
}


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

public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;

    void solveA() throws IOException {
        int x = nextInt();
        int a = nextInt();
        int b = nextInt();
        int diff1 = Math.abs(x - a);
        int diff2 = Math.abs(x - b);
        if (diff1 < diff2) {
            outln("A");
        }
        else {
            outln("B");
        }
    }

    void solveB() throws IOException {

    }

    void solveC() throws IOException {

    }

    void solveD() throws IOException {

    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        solveA();

        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 21076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 +5;
int a[M] = {0};
vector<int> primes;
void sieve(int n){
	for(int i=2;i<n;i++){
		if(a[i] == 0){
			primes.push_back(i);
			for(int j=2;j*i<=n;j++){
				a[j*i] = 1;
			}
		}
	}
}
int main(){
	int n;
	cin>>n;
	sieve(n*2);
	cout << *lower_bound(primes.begin(),primes.end(),n) << '\n';
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long


int main(void){
    ll n;
    cin >> n;
    rep(i,n){
        int num;cin >> num;
        if(num%2==1){cout << "first" << endl; return 0;}
    }
    cout << "second" << endl;
    return 0;
}

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

struct UnionFind {
    vector<int> par; 
    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return; 
        par[rx] = ry; 
    }
    void reset(int n){ 
        for(int i=0;i<n;i++)par[i] = root(par[i]);
    }
    bool con(int x,int y){
        return par[x]==par[y];
    }
    int solve(int n){
        map<int,int> mp;
        for(int i=0;i<n;i++){
            mp[par[i]]++;
        }
        int ans=0;
        for(auto u:mp)ans=max(ans,u.second);
        return ans;
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind tree(n);
  int x,y;
    for(int i=0;i<m;i++){
        cin >> x >> y;
        tree.unite(x-1, y-1);
    }
    tree.reset(n);
    cout << tree.solve(n);
}

Measured memory_bytes: 13140
// https://atcoder.jp/contests/dp/tasks/dp_z
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

template <const int MAXN, class T, class Comparator = less<T>> struct ConvexHullTrick {
    Comparator cmp; T M[MAXN], B[MAXN]; int front = 0, back = 0;
    void addLine(T m, T b) { // in non decreasing order of slope, as sorted by the comparator
        while (back >= 2 && (M[back - 1] - m) * (B[back - 2] - b) <= (B[back - 1] - b) * (M[back - 2] - m)) back--;
        while (back >= 1 && !cmp(m, M[back - 1]) && !cmp(M[back - 1], m) && !cmp(b, B[back - 1])) back--;
        M[back] = m; B[back++] = b;
    }
    T getMax(T x) { // in non decreasing order of x, regardless of comparator
        while (front < back - 1 && !cmp(M[front + 1] * x + B[front + 1], M[front] * x + B[front])) front++;
        return M[front] * x + B[front];
    }
    void clear() { front = back = 0; }
};

const int MAXN = 2e5 + 5;

int N;
ll C, H, dp;
ConvexHullTrick<MAXN, ll, greater<ll>> cht;

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // freopen("err.txt", "w", stderr);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        cin >> H;
        cht.addLine(-2 * H, H * H + (dp = i == 0 ? 0 : H * H + C + cht.getMax(H)));
    }
    cout << dp << nl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/*template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
*/
int main(){
    int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    int t1=h1*60+m1;
    int t2=h2*60+m2;
    int ans=0;
    for(int i=t1;i<=t2;i++){
    	//cout<<i<<endl;
    	if(i+k<t2){
    		ans++;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#define pb push_back

using namespace std;

const int Maxn = 100010;

vector<int> edge[Maxn];

int n, siz[100010];

void dfs(int u, int fa) {
	siz[u] = 1;
	int cnt = 0;
	for(int it = 0; it < edge[u].size(); ++it) 
		if(edge[u][it] != fa) {
			dfs(edge[u][it], u);
			siz[u] += siz[edge[u][it]];
			if(siz[edge[u][it]]&1) cnt++;
		}
	if((n-siz[u])&1) cnt++;
	if(cnt >= 2) {
		puts("First");
		exit(0);
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1, 0);
	puts("Second");
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

signed main(){
  roflan;
  int n, k;
  cin >> n >> k;
  vector <int> a(n), dp(n, 1e18);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for (int i = 2; i < n; i++){
    for (int j = max(0LL, i - k); j < i; j++){
      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
  }
  cout << dp[n - 1];
  return 14 / 88;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[1000];
int main(){
	while(1) {
		fgets(s,500,stdin);
		int n = strlen(s);
		n--;
		if(n == 1 && s[0] == '.') {
			break;
		}


		stack<int> last;

		bool f = true;int rb = 0,sb = 0;
		REP(i,n) {
			if(!last.empty() && last.top() == 0 && s[i] == ']') {
				f = false;
				break;
			}
			if(!last.empty() && last.top() == 1 && s[i] == ')') {
				f = false;
				break;
			}
			if(s[i] == ')') {
				rb--;
				last.pop();
				if(rb < 0) {
					f = false;
					break;
				}
			}
			if(s[i] == ']') {
				sb--;
				last.pop();
				if(sb < 0) {
					f = false;
					break;
				}
			}
			if(s[i] == '(')  {
				rb++;
				last.push(0);
			}
			if(s[i] == '[')  {
				sb++;
				last.push(1);
			}
		}
		if(!last.empty()) {
			f = false;
		}
		if(f) {
			cout << "yes" << endl;
		}else {
			cout << "no" << endl;
		}
	}
	return 0;
}



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

using namespace std;

int main () {
/*
    int n = 10;      
    cin >> n;

    int arr[n];
    arr[0] = 1;
    arr[1] = 1;

    for (int i = 2; i < n; ++i) {
        arr[i] = arr[i - 1] + arr[i - 2];
    }

    cout << arr[n - 1] << "\n";


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

    int r[m + 1];

    for (int i = 0; i <= m; ++i) {
        r[i] = 0;
    }

    for (int i = 1; i <= m; ++i) {
        
        int q = -1;

        for (int j = 1; j <= i; ++j)
            q = max(q, r[i - j] + arr[j]);

        r[i] = q;
    }

    cout << r[m] << "\n";
*/

    int n;
    cin >> n;

    if (n % 2 == 1) cout << n / 2 + 1 << "\n";
    else cout << n / 2 << "\n";
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n) {
    long ans = n * (n + 1) / 2 - n;
    return ans;
}

void main() {
    int n; scan(n);
    writeln(calc(n));
}


Measured memory_bytes: 256
import io.{StdIn => in}

object Main extends App {
  val Array(n, x) = in.readLine.split(" ").map(_.toLong)
  val a = in.readLine.split(" ").map(_.toLong)
  val ans = a.tail./:(0L,a.head)((acc,ai) => {
    val bi = acc._2
    val gap = if(bi + ai > x) bi + ai - x else 0
    val adj = if(ai < gap) ai - gap else 0
    (acc._1 + gap, ai - gap - adj)
  })._1
  println(ans)
}

Measured memory_bytes: 50664
#include<bits/stdc++.h>//头文件
using namespace std;
char a,b;
int main(){
    cin>>a>>b;//输入字符
    if(a=='A'&&b=='A')cout<<"="<<endl;
    if(a=='A'&&b=='B')cout<<"<"<<endl;
    if(a=='A'&&b=='C')cout<<"<"<<endl;
    if(a=='A'&&b=='D')cout<<"<"<<endl;
    if(a=='A'&&b=='E')cout<<"<"<<endl;
    if(a=='A'&&b=='F')cout<<"<"<<endl;
    if(a=='B'&&b=='A')cout<<">"<<endl;
    if(a=='B'&&b=='B')cout<<"="<<endl;
    if(a=='B'&&b=='C')cout<<"<"<<endl;
    if(a=='B'&&b=='D')cout<<"<"<<endl;
    if(a=='B'&&b=='E')cout<<"<"<<endl;
    if(a=='B'&&b=='F')cout<<"<"<<endl;
    if(a=='C'&&b=='A')cout<<">"<<endl;
    if(a=='C'&&b=='B')cout<<">"<<endl;
    if(a=='C'&&b=='C')cout<<"="<<endl;
    if(a=='C'&&b=='D')cout<<"<"<<endl;
    if(a=='C'&&b=='E')cout<<"<"<<endl;
    if(a=='C'&&b=='F')cout<<"<"<<endl;
    if(a=='D'&&b=='A')cout<<">"<<endl;
    if(a=='D'&&b=='B')cout<<">"<<endl;
    if(a=='D'&&b=='C')cout<<">"<<endl;
    if(a=='D'&&b=='D')cout<<"="<<endl;
    if(a=='D'&&b=='E')cout<<"<"<<endl;
    if(a=='D'&&b=='F')cout<<"<"<<endl;
    if(a=='E'&&b=='A')cout<<">"<<endl;
    if(a=='E'&&b=='B')cout<<">"<<endl;
    if(a=='E'&&b=='C')cout<<">"<<endl;
    if(a=='E'&&b=='D')cout<<">"<<endl;
    if(a=='E'&&b=='E')cout<<"="<<endl;
    if(a=='E'&&b=='F')cout<<"<"<<endl;
    if(a=='F'&&b=='A')cout<<">"<<endl;
    if(a=='F'&&b=='B')cout<<">"<<endl;
    if(a=='F'&&b=='C')cout<<">"<<endl;
    if(a=='F'&&b=='D')cout<<">"<<endl;
    if(a=='F'&&b=='E')cout<<">"<<endl;
    if(a=='F'&&b=='F')cout<<"="<<endl;
    /*36种情况*/
    return 0;//完美结束
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;
const int N = (int)1e5 + 9;
const int MOD = 1e9 + 7;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);


bool isprime(ll n) {
	if (n <= 1)
		return 0;
	for (ll i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
	return 1;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll power(ll x, int y)
{
	ll temp;
	if (y == 0)
		return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp * temp;
	else
		return x * temp*temp;
}
int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	vector<int> aa, bb, c;
	for (int i = 0; i < n; i++)
	{
		int z;
		scanf("%d", &z);
		if (z <= a) aa.pb(z);
		else if (z > a && z <= b) bb.pb(z);
		else c.pb(z);
	}
	printf("%d\n", min(aa.size(),min(bb.size(),c.size())));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ss = sorted([sorted(input()) for _ in range(n)])
ans = 0
cnt = 1
for i in range(n - 1):
    if ss[i] != ss[i + 1]:
        ans += cnt * (cnt - 1) // 2
        cnt = 0
    cnt += 1
ans += cnt * (cnt - 1) // 2
print(ans)

Measured memory_bytes: 31460
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N;cin >> N;
    int count = 0;
    for(int i = 0;i<N;i++){
        int a;cin >> a;
        if(a%2 == 1) count++;
    }
    cout << (count%2 == 0 ? "YES" : "NO") << endl;
}


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

int func(string s, string t){
  int ans=0;
  for (char c= 'a'; c<='z'; c++){
    bool founds = false, foundt = false;
    for (int i=0; i<s.length(); i++){
      if (s[i]==c){
        founds = true;
      }
    }
    for (int i=0; i<t.length(); i++){
      if (t[i]==c){
        foundt = true;
      }
    }
    
    if (founds && foundt){
      ans++;
    }
  }
  return ans;
}
int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i=0; i<=N; i++){
    int tmp = func(S.substr(0, i), S.substr(i));
    ans = max(ans, tmp);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
pair<int, int> p[N], a[N];
int visited[N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i].second;
	}
	for (int i = 1; i <= n; i++) {
		cin >> p[i].first;
	}
	sort(p + 1, p + 1 + n);
	for (int i = 1; i <= n; i++) {
		a[i].first = p[i].second;
		a[i].second = i;
	}
	sort(a + 1, a + 1 + n);
	int flag = 1;
	for (int i = 1; i <= n; i++) {
		if (a[i].first > p[i].first) {
			flag = 0;
			break;
		}
	}
	if (flag) {
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (!visited[i]) {
				cnt++;
				int j = i;
				do {
					visited[j] = 1;
					j = a[j].second;
				} while (j != i);
			}
		}
		if (cnt >= 2)
			flag = 1;
		else {
			flag = 0;
			for (int i = 1; i < n; i++) {
				if (p[i].first >= a[i + 1].first) {
					flag = 1;
					break;
				}
			}
		}
	}
	if (flag)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;

  ll sum = 0;
  vector<char> rireki;
  for (int i = 0; i < t.length(); i++){
    if(i <= k - 1){
      if(t[i] == 'r'){
        sum += p;
        rireki.push_back('w');
      }else if(t[i] == 's'){
        sum += r;
        rireki.push_back('w');
      }else{
        sum += s;
        rireki.push_back('w');
      }
    }else{
      if(t[i] == 'r'){
        if(t[i - k] == 'r'){
          if(rireki[i - k] == 'w'){
            rireki.push_back('l');
          }else{
            sum += p;
            rireki.push_back('w');
          }
        }else{
          sum += p;
          rireki.push_back('w');
        }
      }else if(t[i] == 's'){
        if(t[i - k] == 's'){
          if(rireki[i - k] == 'w'){
            rireki.push_back('l');
          }else{
            sum += r;
            rireki.push_back('w');
          }
        }else{
          sum += r;
          rireki.push_back('w');
        }
      }else{
        if(t[i - k] == 'p'){
          if(rireki[i - k] == 'w'){
            rireki.push_back('l');
          }else{
            sum += s;
            rireki.push_back('w');
          }
        }else{
          sum += s;
          rireki.push_back('w');
        }
      }
    }
  }
  say(sum);
}

Measured memory_bytes: 640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, N;
    scan(H, N);
    auto A = aryread();
    writeln(A.sum() < H ? "No" : "Yes");
}


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

int main() {
    int a, b;
    cin >> a >> b;
    rep(i, 1009) {
        if(floor(double(i) * 0.08) == a and floor(double(i) * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;
int DP[N];
bool BROKEN[N];

void init(){

}

void solve(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++){
        int a; scanf("%d", &a);
        BROKEN[a] = true;
    }
    DP[1] = (BROKEN[1] ? 0 : 1);
    DP[2] = (BROKEN[2] ? 0 : 1+DP[1]);
    for(int i = 3; i <= n; i++){
        DP[i] = (BROKEN[i] ? 0 : (DP[i-1] + DP[i-2])%1000000007);
    }
    printf("%d", DP[n]);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 768
#include <unordered_set>
#include <cstdio>

int main(){
    int n;
    std::scanf("%d", &n);
    std::unordered_set<int> set;
    for(int i = 0; i < n; ++i){
        int v;
        std::scanf("%d", &v);
        set.insert(v);
    }

    int m;
    std::scanf("%d", &m);
    int count = 0;
    for(int i = 0; i < m; ++i){
        int v;
        std::scanf("%d", &v);
        if(set.find(v) != set.end()) ++count;
    }

    std::printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 6388
#include<stdio.h>

int main()
{
	int a;
	int b;
	int d, r;
	double f;
	
	scanf(" %d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	
	printf("%d %d %.5lf\n", d, r, f);
	
	return 0;
}

Measured memory_bytes: 640
def solve():
    N, T = map(int,input().split())
    t = list(map(int,input().split()))
    t.append(float('inf'))

    ans = 0
    for i in range(N):
        ans += min(t[i+1]-t[i], T)
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 90832
A, B = map(int, input().split())
S = input()
c = [str(i) for i in range(10)]
ans = True
for i in range(len(S)):
  if i == A and S[i] != '-':
    ans = False
  if i != A and S[i] not in c:
    ans = False
if ans:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  char s[105];
  scanf("%s",s);
  int size=-1;
  for(int i=0;i<105;i++){
    if(s[i]==NULL) {size=i;break;}
  }
  printf("%c%d%c",s[0],size-2,s[size-1]);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N, K;
int A[100010], B[100010];
int ans = 0;
int calc(int K, int bit, int s) {
    //cout << K << " " << bit << " " << s << " ";
    if (bit < 0) {
        int sum = 0;
        rep(i, N) {
            if (A[i] == 0) sum += B[i];
        }
        return sum + s;
    }
    int sum = 0;
    int k = K - (K & (1 << bit));
    if (K & (1 << bit)) {
        rep(i, N) {
            if (!(A[i] & (1 << bit)) && A[i] <= K) sum += B[i];
            A[i] = A[i] - (A[i] & (1 << bit));
        }
    }
    //cout << sum << endl;
    return max(sum, calc(k, bit - 1, s));
    
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K;
    rep(i, N) {
        cin >> A[i] >> B[i];
    }
    cout << calc(K, 31, 0) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
  	cin >>N;
    int maxv =0;
    map<string,int>memo;
    REP(i,N){
        string S;
        cin >>S;
        memo[S]++;
    }
    for(auto it = memo.begin();it!=memo.end();it++){
        int v;
        v = it->second;
        maxv = max(maxv,v);
    }
    for(auto it = memo.begin();it!=memo.end();it++){
        if(it->second == maxv){
            cout << it->first << endl;
        }
    }
}

Measured memory_bytes: 25216
K, X = map(int, input().split())

first_point = X - K + 1
last_point = X + K - 1

if first_point < -1000000:
    first_point = -1000000
if last_point > 1000000:
    last_point = 1000000

for _ in range(first_point, last_point+1):
    print(_)


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

int main(){
	int n, m, l, i, j, k, a[100][100], b[100][100];
	long long c[100][100] = {};

	cin>>n>>m>>l;

	for(i = 0; i < n; i++)
		for(j = 0; j < m; j++)
			cin>>a[i][j];
	for(i = 0; i < m; i++)
		for(j = 0; j < l; j++)
			cin>>b[i][j];
	
	for(i = 0; i < n; i++)
		for(j = 0; j < l; j++)
			for(k = 0; k < m; k++)
				c[i][j] += a[i][k] * b[k][j];

	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			cout<<c[i][j];
			if(j < l - 1) cout<<" ";
		}
		cout<<endl;
	}

	return 0; 
	
}


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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();
    vector<long long> cnt(26);
    for (int i = 0; i < len; i++) {
        cnt.at(s.at(i) - 'a')++;
    }

    long long ans = (long long)len * (len - 1) / 2 + 1;
    for (int i = 0; i < 26; i++) {
        ans -= cnt.at(i) * (cnt.at(i) - 1) / 2;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string O,E;
    cin >> O >> E;
    int n = O.length() + E.length();

    for(int i=0;i<O.length();i++){
        cout << O.at(i);
        if(i<E.length()) cout << E.at(i);
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
ll ara[mx]; 
int main()
{
    fast; 
    ll n; 
    cin>>n; 
    set<ll> s; 
    s.insert(-1);
    s.insert(n);
    for(ll i=0;i<n;i++)
    {
        ll x; cin>>x; 
        ara[i]=x; 
        if(x==0) s.insert(i);
    }
    ll ans=0; 
    while((ll)s.size()>1)
    {
        auto it=s.begin();
        auto it1=it; 
        it1++; 
        //cout<<*it<<' '<<*it1<<endl; 
        if(*(it)+1==*it1)
        {
            s.erase(it);
            continue; 
        }
        else
        {
            ll val=200; 
            for(ll i=*(it)+1;i<*(it1);i++)
            {
                val=min(val,ara[i]);
            }
            if(val) ans+=val; 
            for(ll i=*(it)+1;i<*(it1);i++)
            {
                ara[i]-=val; 
                if(ara[i]==0) s.insert(i);
            }
        }
        //line; 
        //for(auto x: s) cout<<x<<' '; 
        //cout<<endl ;
        //line; 
        //cout<<ans<<endl; 
    }
    cout<<ans<<endl; 
    
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static long mod(long x, long y){
    return x%y<0?x%y+(y<0?-y:y):x%y;
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
        x = Math.abs(x);
		long k = sc.nextLong();       
        long d = sc.nextLong();
		long ans = 0;
        if(x/d>k){ans=x-d*k;}
        else{if((k-x/d)%2==0){ans=mod(x,d);}
            else{ans=d-mod(x,d);}
            }      
		System.out.println(ans);
	}
} 

Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int x,money=100;
  int count=0;
  cin >> x;
  while(1){
    if(money>=x)break;
    money*=1.01;
    count++;
  }
  cout << count << endl;
return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
   char a[11];
   int i,j=0;
   int max=0;
   int count[11]={0};
  
    scanf("%s", a);
    for(i=0;i<10;i++){
      if(a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')
        count[j]++;
     else if(a[i]=='\0')
         break;
     else
       j++;      
    }
      max=count[0];
      j=1;
    while(i>0){
     if(max<count[j]){
         max=count[j];
      }
       j++;
       i--;
    }
     printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+((A)%(B)==0?0:1)
#define read(type,name) type name;cin>>name
using namespace std;


/*
  予想と答えをすべて比較するのが最速。O(n)
*/
void A() {
	string s, t;
	cin >> s >> t;
	int answer = 0;
	rep(i, s.length()) {
		if (s[i] == t[i])answer++;
	}
	cout << answer << endl;
}

/*
  タップを使うごとにA-1ずつ増える。Bと1の距離をA-1で割った（切り上げ）のが答え。
  A,Bの値によらないのでO(1)の解法である。
*/
void B() {
	int A, B; cin >> A >> B;
	cout << roundup(B-1, A-1) << endl;
}

/*
  左から走査することで最大長を求めることができる。最大長を0で初期化し、
  左端からスタートする。右に進める限り現在の長さをincrementし、進めなくなったところで最大長を更新する。
  そして止まったところからリセットして再開する。これを繰り返すことで最大長を求めることができる。
  計算量はO(n)、空間量はO(1)となる。
*/
void C() {
	int n; cin >> n;
	int length = 0, max_length = 0;
	int prev = 0, current;
	rep(i, n) {
		cin >> current;
		if (prev >= current) {
			length++;
		} else {
			max_length = max(max_length, length);
			length = 0;
		}
		prev = current;
	}
	max_length = max(max_length, length);
	cout << max_length << endl;
}

/*
　剰余を最大にするのは、MをM+1で割った場合であるから、
 iに対して1つずれた順列を作れば最適である。配列の最後Nについては、
 N+1を用意することはできないので、1で剰余を取る（必ず10になる）。
 このやり方で和を求めた場合は、1からN-1までの和に等しいので(N-1)(N)/2となる。
 　　->これが最大っていうのはどうわかるの?
*/
void D() {
	read(int, n);
	cout << n * (n - 1) / 2 << endl;
}

/*
　総当たりで調べてO(N^2)を試してみよう
*/
struct Player {
	queue<int> versus{};
	bool available{ true };
	bool matchable(int i) {
		return available && versus.front() == i;
	}
};
void E() {
	read(int, n);
	auto ps = vector<Player>(n);
	rep(i, n) {
		rep(j, n - 1) {
			read(int, p);
			ps[i].versus.push(p - 1);
		}
	}
	int days = 0;
	int remains = n;
	while (true) {
		bool matched = false;
		rep(i, ps.size()) {
			if (!ps[i].available||ps[i].versus.empty())continue;
			auto v = ps[i].versus.front();
			if (ps[v].matchable(i)) {
				matched = true;
				ps[i].versus.pop(); ps[i].available = false; if (ps[i].versus.empty()) remains--;
				ps[v].versus.pop(); ps[v].available = false; if (ps[v].versus.empty()) remains--;
			}
		}
		for (auto& p : ps)p.available = !p.versus.empty();
		days++;
		if (remains == 0) {
			cout << days << endl;
			return;
		}
		if (!matched) {
			cout << -1 << endl;
			return;
		}
	}
}

int main() {
	E();
}



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

int main()
{
	char a, b;
	cin >> a >> b;
	bool ad_is_honest = (a == 'H');
	bool td_is_honest = (b == 'H');

	if(!ad_is_honest) td_is_honest = !td_is_honest;

	char out = td_is_honest? 'H' : 'D';

	cout << out << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
 
int main(void){
	int n;
	std::cin >> n;
	std::vector<int64_t> a(n);
	for(int i=0;i<n;i++)std::cin >> a[i];
	std::vector<int64_t> ans(n);
	//2 * a[i] == ans[i] + ans[i+1]
	int64_t sum = 0;
	for(int i=0;i<n;i++)sum += a[i];
	ans[0] = sum;
	for(int i=1;i<n;i+=2)ans[0] -= 2 * a[i];
	for(int i=1;i<n;i++){
		ans[i] = 2 * a[i-1] - ans[i-1];
	}
	for(int i=0;i<n;i++){
		if(i != 0)std::cout << " ";
		std::cout << ans[i];
	}
	std::cout << std::endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vector<tuple<ll,ll,ll>> q(n);
    ll x,y,h;
    rep(i,n){
        cin >> get<0>(q[i]) >> get<1>(q[i]) >> get<2>(q[i]);
        if(get<2>(q[i])>0){
            x=get<0>(q[i]);y=get<1>(q[i]);h=get<2>(q[i]);
        }
    }
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            ll H=h+abs(x-cx)+abs(y-cy);
            bool ex=true;
            rep(i,n){
                if(get<2>(q[i])!=max(H-abs(get<0>(q[i])-cx)-abs(get<1>(q[i])-cy),(ll)0)){
                    ex=false;
                    break;
                }
            }
            if(ex){
                cout << cx << " " <<cy <<" " << H <<endl;
                return 0;
            }
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    int Li;
    vector<int> L;
    for(int i=0;i<N;i++){
        cin >> Li;
        L.push_back(Li);
    }
    auto vmax = *max_element(L.begin(), L.end());
    auto sum = accumulate(L.begin(), L.end(), 0);
    if(vmax >= sum - vmax) cout<<"No"<<endl;
    else                   cout<<"Yes"<<endl;

    return 0;
}

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

int main(){
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555555555555";
	for(int i=0;i<104;i++) cout<<cunning[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160