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

const int maxn = 1005;
int X[maxn], Y[maxn];
char s[32];

int iabs (int x) {
    return x >= 0 ? x : -x;
}

int main () {
    int n, c = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> X[i] >> Y[i];
        if ((X[i] + Y[i]) & 1) ++c;
        else --c;
    }
    if (iabs(c) != n) {
        cout << -1 << endl;
        return 0;
    }
    int m = 31 + (c < 0);
    cout << m << endl;
    for (int i = 0; i <= 30; ++i) {
        cout << (1 << i) << ' ';
    }
    if (c < 0) cout << 1 << ' ';
    cout << endl;
    for (int i = 1; i <= n; ++i) {
        int x = X[i], y = Y[i], sgn = 0;
        if (c < 0) s[31] = 'R', --x;
        for (int j = 30; j >= 0; --j) {
            if (iabs(x) < iabs(y)) swap(x, y), sgn ^= 1;
            if (x > 0) x -= 1 << j, s[j] = sgn ? 'U' : 'R';
            else x += 1 << j, s[j] = sgn ? 'D' : 'L';
        }
        cout << (string)s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
L = [0] * n
for i in range(n):
  L[i] = int(input())

iter = [[]]
for i in range(n):
  temp = []
  for num in range(0, 4):
    for lis in iter:
      temp.append(lis + [num])
  else:
    iter = temp

min_cost = 1000000000000000
for lis in iter:
  length = [0, 0, 0, 0]
  cost = -30
  if 1 in lis and 2 in lis and 3 in lis:
    for i in range(n):
      length[lis[i]] += L[i]
      if lis[i] != 0: 
        cost += 10
    cost += abs(length[1] - a)
    cost += abs(length[2] - b)
    cost += abs(length[3] - c)
    min_cost = min(min_cost, cost)
  else:
    continue
print(min_cost)

Measured memory_bytes: 58972
import java.util.Scanner;
class Main{
    int W,H,x,y,r;
    public void en() {
        Scanner sc = new Scanner(System.in);
            W = sc.nextInt();
            H = sc.nextInt();
            x = sc.nextInt();
            y = sc.nextInt();
            r = sc.nextInt();
         
        if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    public static void main(String[] args) {
        new Main().en();
    }
}

Measured memory_bytes: 17352
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto cs = new long[](N+1);
    foreach (long i; 0..N+1) {
        cs[i] = i;
        if (i) cs[i] += cs[i-1];
    }
    long r;
    foreach (k; K..N+1) {
        auto d = (cs[N] - cs[N-k] - cs[k-1] + 1) % P;
        r += d %= P;
    }
    writeln((r+1)%P);
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){

  string s;

  cin >> s;
  int N = s.length();

  int l = 0, r = N-1;
  while(true){
    if(s[l] != s[r]){
      cout <<"No" << endl;
      return 0;
    }
    l++; r--;
    if(l >= r){
      break;
    }
  }

  l = 0; r = (N-1)/2-1;
  while(true){
    if(s[l] != s[r]){
      cout <<"No" << endl;
      return 0;
    }
    l++; r--;
    if(l >= r){
      break;
    }
  }

  l = (N+3)/2-1; r = N-1;
  while(true){
    if(s[l] != s[r]){
      cout <<"No" << endl;
      return 0;
    }
    l++; r--;
    if(l >= r){
      break;
    }
  }

  cout << "Yes" << endl;
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    long x, a, b;
    std::string s;
    std::cin >> x >> a >> b;
    if (b-a <= 0) s = "delicious";
    else if (b-a <= x) s = "safe";
    else s = "dangerous";
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
def check(amidakuji,w):
    before=0
    flag=True
    for _ in range(w-1):
        if amidakuji&1==1 and before==1:
            flag=False
            break
        elif amidakuji&1==1:
            before=1
            amidakuji>>=1
        else:
            before=0
            amidakuji>>=1
    return flag

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    h,w,k=map(int,readline().split())

    dp=[[0]*w for _ in range(h+1)]
    dp[0][0]=1
    for i in range(1,h+1):
        for bit in range(1<<(w-1)):
            if check(bit,w)==False:
                continue
            else:
                for j in range(w):
                    if j==0:
                        if bit&1==1:
                            dp[i][j+1]+=dp[i-1][j]
                        else:
                            dp[i][j]+=dp[i-1][j]
                    elif j==w-1:
                        if bit&1==1:
                            dp[i][j-1]+=dp[i-1][j]
                        else:
                            dp[i][j]+=dp[i-1][j]
                    else:
                        if bit&1==1:
                            dp[i][j-1]+=dp[i-1][j]
                            bit>>=1
                        else:
                            bit>>=1
                            if bit&1==1:
                                dp[i][j+1]+=dp[i-1][j]
                            else:
                                dp[i][j]+=dp[i-1][j]

                for j in range(w):
                    dp[i][j]%=mod

    print(dp[h][k-1])

if __name__=="__main__":
    main()

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

using namespace std;

#define PII pair<int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

pair<PII,int>queries[500002];
int n,a[500002],ans[500002],cnt[500002],lastIdx[500002];

bool Compare(pair<PII,int>&x,pair<PII,int>&y)
{
    return x.first.second < y.first.second;
}

void Update(int idx,int val)
{
    while(idx <= n)
    {
        cnt[idx]+=val;
        idx+=idx & (-idx);
    }
}

int Query(int idx)
{
    int ans=0;
    while(idx > 0)
    {
        ans+=cnt[idx];
        idx-=idx & (-idx);
    }
    return ans;
}

int main()
{
    FAST();
    int i,q,cur=1;
    cin >> n >> q;
    for(i=1;i<=n;i++)cin >> a[i];
    for(i=1;i<=q;i++)
    {
        cin >> queries[i].first.first >> queries[i].first.second;
        queries[i].second=i;
    }
    sort(queries+1,queries+q+1,Compare);
    for(i=1;i<=q;i++)
    {
        for( ;cur <= queries[i].first.second;cur++)
        {
            if(!lastIdx[a[cur]])
            {
                Update(cur,1);
                lastIdx[a[cur]]=cur;
            }
            else
            {
                Update(lastIdx[a[cur]],-1);
                Update(cur,1);
                lastIdx[a[cur]]=cur;
            }
        }
        ans[queries[i].second]=Query(queries[i].first.second)-Query(queries[i].first.first-1);
    }
    for(i=1;i<=q;i++)cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 17404
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h = readline() |> parseInt
	w = readline() |> parseInt
	n = readline() |> parseInt
	if h>w
		println(ceil(Int,n/h))
	else
		println(ceil(Int,n/w))
	end
end

main()

Measured memory_bytes: 164404
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> C(N),S(N),F(N);
  for(int i=0; i<N-1; i++){
    cin >> C[i] >> S[i] >> F[i];
  }
  int T;
  for(int i=0; i<N-1; i++){
    T = S[i];
    T += C[i];
    for(int j=i+1; j<N-1; j++){
      if(T<=S[j]){
        T = S[j];
      }else{
        int x;
        x = (T-S[j])%F[j];
        if(x != 0){
          T += F[j]-x;
        }
      }
      T += C[j];
    }
    cout << T << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int x;
    cin >>x;
    if(x == 1) cout << 0 << endl;
    if(x == 0) cout << 1 << endl;
}

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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli i=1,x,n;

  cin>>n;

  while(1){
    while(1){
      x=i;
      if(x%3==0){
	cout<<" "<<i;
	break;
      }
      while(1){
	if(x%10==3){
	  cout<<" "<<i;
	  break;
	}
	x /= 10;
	if(x==0)break;
      }
      break;
    }
    if(++i > n)break;
  }

  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 3068
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

Q,H,S,D,N = map(int,read().split())

if H > Q+Q:
    H = Q+Q
if S > H+H:
    S = H+H
if D > S+S:
    D = S+S

q,r = divmod(N,2)
answer = q * D + r * S
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b, k;
int cnt;

signed main() {
	cin >> a >> b >> k;
	for (int i = 100; i >= 1; i--) {
		if (!(a%i) && !(b%i))cnt++;
		if (cnt == k) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
S = input()

# 求解処理
ACGT = ["A", "C", "G", "T"]
ans = 0
N = len(S)
for i in range(N):
    for j in range(i, N):
        if all([S[k] in ACGT for k in range(i, j + 1)]):
            ans = max(ans, j - i + 1)

# 結果出力
print(ans)

Measured memory_bytes: 9060
#include<stdio.h>
int main(){
	int n,side[3],i,tmp,jud;
	scanf("%d",&n);
	for(;0<n;n--){
		scanf("%d %d %d",&side[0],&side[1],&side[2]);
		jud=0;                   
		if(side[0]*side[0]==side[1]*side[1]+side[2]*side[2]){
			jud++;
		}
		else if(side[1]*side[1]==side[0]*side[0]+side[2]*side[2]){
			jud++;
		}
		else if(side[2]*side[2]==side[1]*side[1]+side[0]*side[0]){
			jud++;
		}
		if(jud!=0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

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

#define fi first
#define se second

const int N = 100100;
const int Q = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("teleports.in", "r", stdin);
        //freopen("teleports.out", "w", stdout);
        ios_base::sync_with_stdio(0);

        long long n;
        cin >> n;
        long long x = 1;
        long long res = 0;
        while(x <= n){
                long long l = x;
                x = n / (n / x) + 1;
                long long r = x - 1;

                long long k = n / l;
                if(n % k){
                        continue;
                }
                k = n / k - 1;
                if(l <= k && k <= r){
                        res += k;
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())

    L = []
    for _ in range(N - 1):
        c, s, f = map(int, input().split())
        L.append((c, s, f))

    for i in range(len(L)):
        x = 0
        for c, s, f in L[i:]:
            if x <= s:
                x = s + c
            else:
                x = s + f * ceil(x - s, f) + c
        print(x)
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,i,j,k,n,m,x,y,z,t;
    double a1,a2,a3,a4,ans=0.0;
    cin>>n;
    double aa[100][100];
    pair<long long,long long>pp[10];
    for(i=1;i<=n;i++)
    {
        cin>>pp[i].first>>pp[i].second;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i!=j)
            {
                aa[i][j]=sqrt(pow((pp[i].first-pp[j].first),2)+pow((pp[i].second-pp[j].second),2));
                //cout<<aa[i][j]<<endl;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            aa[i][j]=aa[i][j]*(n-1);
            ans=ans+aa[i][j];
        }
    }
    //cout<<ans<<endl;
    a1=ans/(n*(n-1));
    //cout<<a1<<endl;
    printf("%.10lf\n",a1);

}


Measured memory_bytes: 256
my $n_tmp = get;
my $n = chomp($n_tmp);

my $in = get;
my $input = chomp($in);

my @data = split(' ', $input);
my $ans = 1;

for @data -> $l {
	if $l == 0 {
		say '0';
		exit();
	}
}


for @data -> $i {
	if $i <= 1000000000000000000/$ans {
		$ans = $ans * $i;
	} else {
		say '-1';
		exit();
	}

}

say $ans



Measured memory_bytes: 132084
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	int H,Hprev;
	int cnt=0,mcnt=0;
	cin >> Hprev;
	for(int i=1;i<N;i++){
		cin >> H;
		if(Hprev>=H){
			cnt++;
			if(mcnt<cnt){
				mcnt=cnt;
			}
		}else{
			cnt=0;
		}
		Hprev=H;
	}
	cout << mcnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

vector<int> v[100005];
vector<int> dp;

ll dfs(int u)
{
	ll d = 0;
	if (dp[u] != -1) {
		return dp[u];
	}

	for (int w : v[u]) {
		d = max(d, dfs(w) + 1);
	}

	return dp[u] = d;
}

int main(int argc, char *argv[])
{
	int N, M;

	cin >> N >> M;

	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		v[x].push_back(y);
	}

	dp = vector<int>(100005, -1);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, dfs(i));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8192
import math
def vec(a, b):
    return [b[0] - a[0], b[1] - a[1]]

def norm(a):
    return math.sqrt(a[0]**2 + a[1]**2)

def cross(a, b):
    return a[0]*b[1] - b[0]*a[1]

def gift_wrap(p_a, p_h, a):
    while True:
        p_h.append(a)
        b = p_a[0]
        for i in range(len(p_a)):
            c = p_a[i]
            if b == a:
                b = c
            else:
                ab = vec(a, b)
                ac = vec(a, c)
                v = cross(ab, ac)
                if v > 0 or (v == 0 and norm(ac) > norm(ab)):
                    b = c
        a = b
        if a == p_h[0]:
            break

while True:
    n = int(input())
    if n == 0:
        break
    p_all = []
    p_hull = []
    for i in range(n):
        p_all.append(list(map(float, input().split(","))))
    p_all = sorted(p_all)
    gift_wrap(p_all, p_hull, p_all[0])
    print(len(p_all) - len(p_hull))



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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second
#define nl '\n'

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << nl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << nl;
}

const int MOD = 1000000007;
int n;
string s1,s2;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("test.txt", "r", stdin);
	cin >> n >> s1 >> s2;
	ll ans = 3;
	int pre = s1[0] == s2[0];
	int i = 1 + !pre;
	if (!pre) ans *= 2;
	for(; i < n; i++) {
		if (pre) {
			ans = (ans * 2ll) % MOD;
			if (s1[i] != s2[i]) {
				i++;
				pre = 0;
			} 
		} else {
			if (s1[i] == s2[i]) {
				pre = 1;
			} else {
				i++;
				ans = (ans * 3ll) % MOD;
			}
		}
	}
	cout << ans;

}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<(1<<s.size());++i){
        int cnt=0;
        for(int j=1;j<=s.size();++j){
            if((i>>j)&1){
                ans+=(ll)stoll(s.substr(cnt,j-cnt));
                cnt=j;
            }
        }
        if(cnt!=s.size()){ans+=(ll)stoll(s.substr(cnt,s.size()-cnt));}
    }
    cout<<ans/2<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int path[][]=new int[101][101];
			for(int i=1;i<=n;i++)
			{
				int m=in.nextInt();
				for(int j=0;j<m;j++)
					path[i][in.nextInt()]=1;
			}
			int k=in.nextInt();
			int leak[]=new int[k];
			for(int i=0;i<k;i++)
				leak[i]=in.nextInt();
			int ans=0;
			int cnt=0;
			for(int i=1;i<=n;i++)
			{
				int judge=0;
				for(int j=0;j<k;j++)
				{
					if(path[i][leak[j]]==1)
						judge=1;
					else 
					{
						judge=0;
						break;
					}
				}
				if(judge==1)
				{
					cnt++;
					ans=i;
				}
			}
			System.out.println(cnt==1 ? ans:-1);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}

int main ()
{
	int n, m; read (n), read (m);
	for (int i = 1; i <= m; ++i) {
		int x; read (x); n -= x;
	}
	if (n < 0) printf ("-1\n");
	else printf ("%d\n", n);
	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;


int main(){
   int n,h,w;
   cin >> n >> h >>w;
   int ans = 0;
   rep(i,n){
       int a,b;
       cin >> a>>b;
       if(a>=h&&b>=w) ans++;
   }
   cout << ans <<endl;
}

Measured memory_bytes: 3544
#include<iostream>
using namespace std;
int map[20][20];


int solve(int x,int y){
	int count = 0;
	if(map[y][x] == 0){
		count++;
		map[y][x] = 1;
		if(x-1 >= 0){
			count += solve(x-1,y);
		}
		if(y-1 >= 0){
			count += solve(x,y-1);
		}
		if(20 > x+1){
			count += solve(x+1,y);
		}
		if(20 > y+1){
			count += solve(x,y+1);
		}
	}
	return count;
}

int main(){
	int w,h;
	int startX,startY;

	while(true){
		cin >> w >> h;

		if(w == 0 && h == 0){
			break;
		}

		for(int i=0;i<20;i++){
			for(int j=0;j<20;j++){
				map[i][j] = 1;
			}
		}

		char c;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> c;
				switch(c){
				case '.':
					map[i][j] = 0;
					break;
				case '#':
					map[i][j] = 1;
					break;
				case '@':
					map[i][j] = 0;
					startX = j;
					startY = i;
					break;
				}
			}
		}

		cout << solve(startX,startY) << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
//#define mod 1000000007
#define mod 998244353



int calc_pow(int x, int pow,int m) {
    if (pow == 0) return 1;
    int a = calc_pow(x, pow / 2,m);
    a = a * a % m;
    if (pow % 2 == 1) a *= x;
    return a % m;
}//最小二乗法

int calc_div(int a,int b,int m) {
    return a * calc_pow(b, m - 2,m) % m;
}//フェルマーの小定理
struct Combination{
    int MAX_N;
    int MOD;
    int *fac, *finv, *inv;
    Combination(int max_n,int MOD): MAX_N(max_n+1),MOD(MOD){ //make table
        fac = new int[MAX_N];finv = new int[MAX_N];inv = new int[MAX_N];
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for (int i = 2; i < MAX_N; 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;
        }
    }
    int 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;
    }
    void free_COM(){
        delete[] fac;
        delete[] finv;
        delete[] inv;
    }
    
};

int N,K,M;
signed main(){
    scanf("%lld %lld %lld",&N,&M,&K);
    int ans=0;
    Combination CB(N,mod);
    for(int i=0;i<=K;i++){
        int sans=1;
        sans*=(CB.COM(N-1,i)*M)%mod;
        sans*=calc_pow(M-1,N-i-1,mod);
        ans+=sans%mod;
        ans%=mod;
        //printf("%lld:%lld\n",i,sans);
    }
    CB.free_COM();
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7544
n=int(input())
ans=[]
def dfs(num,step,tmp):
    if len(ans)>1e5:
        return
    if num==step:
        ans.append(tmp)
        return
    if step==0:
        for i in range(1,10):
            dfs(num,step+1,tmp*10+i)
    else:
        if tmp%10!=0:
            dfs(num,step+1,tmp*10+tmp%10-1)
        dfs(num,step+1,tmp*10+tmp%10)
        if tmp%10!=9:
            dfs(num,step+1,tmp*10+tmp%10+1)
for i in range(11):
    dfs(i+1,0,0)
print(ans[n-1])

Measured memory_bytes: 7276
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
vector<pair<int,int> > g[100003];
bool visited[100003];
long int cost=0;
int v,k,u;
bool inpath;
long int arr[100003];
void dfs(int uu)
{
	//u is unvisited
	visited[uu]=1;
	arr[uu]=cost;
	for(int i=0;i<g[uu].size();i++)
	{
		if(!visited[g[uu][i].first])
		{
			cost+=g[uu][i].second;
			if(g[uu][i].first==k)
				inpath=1;
			dfs(g[uu][i].first);
			cost-=g[uu][i].second;
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		g[a].push_back(make_pair(b,c));
		g[b].push_back(make_pair(a,c));
	}
	int q;
	scanf("%d%d",&q,&k);
	dfs(k);
	for(int ii=0;ii<q;ii++)
	{
		scanf("%d%d",&u,&v);
		printf("%ld\n",arr[u]+arr[v]);
	}


	return 0;
}

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

int	main()
{
	int	H, W;
	cin >> H >> W;
	int	cost[10][10];
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j)
			cin >> cost[i][j];
	}
	int	A[200][200];
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			cin >> A[i][j];
	}
	for (int k = 0; k < 10; ++k) {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j)
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
		}
	}
	int	total_cost = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (A[i][j] == -1)
				continue;
			total_cost += cost[A[i][j]][1];
		}
	}
	cout << total_cost << endl;
}
			


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

int main(){
	int N;
	set<int> sa;
	cin >> N;
	for(int i = 1; i <= N; i++){
		int d;
		cin >> d;
		sa.insert(d);
	}
	cout << sa.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll mx = 1000002;

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll a[n],i,b[mx]={};

    forn(i,n){
        cin>>a[i];
        if(b[a[i]] == 0){
            b[a[i]]=-1;
            for(ll j=2*a[i];j<mx;j+=a[i]){
                b[j]=1;
            }
        }
        else if(b[a[i]]==-1)b[a[i]]=1;
    }
    ll ans=0;
    forn(i,n){
        if(b[a[i]]==-1)ans++;
    }
    cout<<ans<<endl;

}

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

using vec = vector<int>;

using matrix = vector<vec>;

matrix power(const matrix &a, int n){

	int sz = a.size();

	matrix res(sz,vec(sz));

	REP(i,sz)REP(j,sz){

		if(i==j) res[i][j] = 1;

		else res[i][j] = 0;

	}

	matrix r = a;

	while(n>0){

		if(n&1){

			matrix tmp(sz,vec(sz,0));

			REP(i,sz)REP(j,sz)REP(k,sz){

				tmp[i][j] += res[i][k]*r[k][j];
                tmp[i][j]%=1000000007;

			}

			res = tmp;

		}

		matrix tmp(sz,vec(sz,0));

		REP(i,sz)REP(j,sz)REP(k,sz){

			tmp[i][j] += r[i][k]*r[k][j];
            tmp[i][j]%=1000000007;

		}

		r = tmp;

		n >>= 1;

	}

	return res;

}

signed main(){
    int n,k;
    cin>>n>>k;
    matrix a(n,vec(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    
    a=power(a,k);
    
    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<a[i][j]<<" ";
            
        }
        cout<<endl;
    }
    */
    
    
    
    ll ans=0;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans+=a[i][j];
            ans%=1000000007;
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	string s;
	bool a = true;
	bool b = false;
	cin >> s;
	if (s[0] != 'A')a = false;
	if ('A' <= s[1] && s[1] <= 'Z')a = false;
	if ('A' <= s[s.size() - 1] && s[s.size() - 1] <= 'Z')a = false;
	for (int i = 2; i < s.size()-1; i++) {
		if ('A' <= s[i] && s[i] <= 'Z') {
			if (s[i] == 'C'&&!b)b = true;
			else if (s[i] == 'C')a = false;
			else a = false;
		}
	}
	a &= b;
	if (a)cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define TRUE 1
#define FALSE 0

int main()
{
    /*変数宣言*/
    int N = 0;
    int A[16] = { 0 };
    int x[16][16] = { 0 }, y[16][16] = { 0 };
  
    int ans = 0;

    /*入力処理*/
    cin >> N;
    for (int i = 1; i <= N; i++ ) {
        cin >> A[ i ];
        for (int j = 1; j <= A[i]; j++ ) {
            cin >> x[ i ][ j ] >> y[ i ][ j ];
        }
    }

    /*判定*/
    for (int bits = 1; bits < (1 << N); bits++) { //N bitの列を用意
        bool error_flag = TRUE; 
        int tmp = 0 ; //bitカウント用
        for (int i = 1; i <= N; i++) {
            if (!(bits & (1 << (i - 1)))) { //右からi番目とbitsを比較して、両方とも1のとき、処理を続ける
                continue;
            }

            tmp = tmp + 1;

            for (int j = 1; j <= A[i]; j++) {
                if (( ( bits  >> ( x[i][j] - 1) ) & 1 ) ^ y[i][j]) {
                    error_flag = FALSE;
                    break;
                }
            }

            if (error_flag == FALSE) {
                break;
            }
        }

        if (error_flag == TRUE) {
            ans = ans > tmp ? ans : tmp;
        }
    }


    /*出力*/
    cout << ans;

    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b,c,k; cin>>a>>b>>c>>k;
    int res=max({a,b,c});
    rep(i,k)res*=2;
    cout<<res+a+b+c-max({a,b,c})<<endl;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s;
  cin >> s;
  if(s.size()==3){
    reverse(ALL(s));
  }
  rep(i, s.size()){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int dp[1<<19][55];

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

    int n; cin>>n;
    vi a = readVector<int>(n);
    vi b = readVector<int>(n);

    int all = (1<<n)-1;

    memset(dp, 0x7f, sizeof dp);
    dp[0][0] = 0;

    FOR(bm,all+1) {
        int moves=-1;
        FOR(i,n) {
            if(bm & (1<<i)) continue;
            moves++;

            int placed = __builtin_popcount(bm);
            int p = abs(i-placed)%2;
            int up = p==0 ? a[i] : b[i];

            RNG(j,0,up) {
                dp[bm|(1<<i)][up] |= MIN(dp[bm][j]+moves);
            }
        }
    }

    ll ans = 1e9;
    RNG(j,0,50) {
        ans |= MIN(dp[all][j]);
    }

    if(ans==1e9)
        ans=-1;
    cout<<ans<<endl;


    return 0;
}



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

using namespace std;

const int maxn=5e4+10;

struct pr {
	int l,r,id,bel;
}q[maxn*20];

int ans[maxn*20],a[maxn*20],n,m,num[1000010],cur;

bool cmp(pr x,pr y) {
	if(x.bel!=y.bel) {
		return x.bel<y.bel;
	}
	return x.r<y.r;
}

void add(int x) {
	num[x] ++;
	if (num[x] == 1)
		cur ++;
}

void del(int x) {
	num[x] --;
	if (num[x] == 0)
		cur --;
}

int main() {
	
	cin >> n;
  cin >> m;
	int blocks = sqrt(n);
	
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= m; ++i) {
		q[i].id = i;
		scanf("%d %d", &q[i].l, &q[i].r);
		q[i].bel = (q[i].l - 1) / blocks  + 1;
	}
	sort(q + 1, q + m + 1, cmp);
	
	
	int l = 1, r = 0;
	
	for (int i = 1; i <= m; ++i) {
		while (l < q[i].l) del(a[l++]);
		while (l > q[i].l) add(a[--l]);
		while (r < q[i].r) add(a[++r]);
		while (r > q[i].r) del(a[r--]);
		ans[q[i].id] = cur;//统计情况；
	}
	
	for (int i =1 ; i <= m; ++i) {
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;

  for (int i=0; i<n; i++){
    cout << s[i] << t[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#define SIZE 100005
#define MOD 1000000007
#define INF 1000000005

using namespace std;

class ETravelByCar {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        long long int n, m, l;
        cin >> n >> m >> l;

        graph.resize(n, vector<long long int>(n, INF));
        for (int i = 0; i < n; ++i) graph[i][i] = 0;
        for (int i = 0; i < m; ++i) {
            long long int a, b, c;
            cin >> a >> b >> c;
            graph[a - 1][b - 1] = c;
            graph[b - 1][a - 1] = c;
        }
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k) {
                    graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
                }

        dist.resize(n, vector<long long int>(n, INF));
        for (int i = 0; i < n; ++i) dist[i][i] = 0;
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (graph[i][j] <= l) dist[i][j] = 1;

        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k) {
                    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
                }
        long long int q;
        cin >> q;
        for (int i = 0; i < q; ++i) {
            int s, t;
            cin >> s >> t;
            if (dist[s - 1][t - 1] < INF) {
                cout << dist[s - 1][t - 1] - 1 << endl;
            } else {
                cout << -1 << endl;
            }
        }
    }

    vector<vector<long long int> > graph;
    vector<vector<long long int> > dist;
};


int main() {
    ETravelByCar solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1920
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var s = "";
			while((s = Console.ReadLine()) != null)
			{
				var arr = s.Split(',').Select(i => Double.Parse(i)).ToArray();
				var bmi = arr[1] / (arr[2] * arr[2]);
				if(bmi >= 25)
				{
					Console.WriteLine(arr[0]);
				}
			}
		}
	}
}

Measured memory_bytes: 6084
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll l[110];

int solve() {
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                ll s = l[i] + l[j] + l[k];
                ll m = max(l[i], max(l[j], l[k]));
                if (m*2 < s)
                    res++;
            }
        }
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> l[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
#define pb push_back

int main()
{
  vector<int>E[10005];
  int flag[10005] = {0};
  int indeg[10005] = {0};
  vector<int>out;
  int N,M,s,t;
  cin >> N >> M;
  while(M--) {
    cin >> s >> t;
    E[s].pb(t);
  }
  Rep(i,N) {
    Rep(j,E[i].size()) {
      int v = E[i][j];
      indeg[v]++;
    }
  }
  Rep(p,N) {
    if(!flag[p] && indeg[p] == 0) {
      
      queue<int>que;
      que.push(p);
      flag[p] = true;
      while(!que.empty()) {
	int v = que.front(); que.pop();
	out.pb(v);
	Rep(i,E[v].size()) {
	  int nv = E[v][i];
	  indeg[nv]--;
	  if(indeg[nv] == 0 && !flag[nv]) {
	    flag[nv] = true;
	    que.push(nv);
	  }
	}
      }
      
    }
  }
  Rep(i,N) {
    cout << out[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<pii> q;
int mn[100010];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++){
        int L, R;
        cin >> L >> R;
        q.push_back({L, R});
    }

    mn[N] = inf;
    sort(q.begin(), q.end());
    for(int i = N - 1; i >= 0; i--){
        mn[i] = min(q[i].second, mn[i + 1]);
    }
    int mx = 0;
    int mini = inf;
    int ans = 0;
    for(int i = 0; i < N - 1; i++){
        int res = 0;
        chmax(mx, q[i].second);
        if(i != 0) chmax(ans, max(mx - q[i].first + 1, 0) + max(min(mini, mn[i + 1]) - q[N - 1].first + 1, 0));
        chmin(mini, q[i].second);
        chmax(ans, max(mini - q[i].first + 1, 0) + max(mn[i + 1] - q[N - 1].first + 1, 0));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1524
X, Y, A, B, C = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
Q = gets.split.map(&:to_i)
R = gets.split.map(&:to_i)

aa = P.sort_by{ |v| -v }[0...X]
bb = Q.sort_by{ |v| -v }[0...Y]

puts (aa + bb + R).sort.reverse[0...X+Y].sum


Measured memory_bytes: 34884
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

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);
}

int main(void) {
  ll n;
  ll x =0;
  cin>>n;
  for(int i=0; i<n; i++)
    x+=i;
  std::cout << x << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s,mod=998244353;cin>>n>>s;
  lvector A(n),f(3010,0),ff(f);rep(i,n) cin>>A[i];
  f[0]=1;
  for(ll a:A) {
    rep(i,3010) ff[i]=2*f[i];
    for(ll i=a;i<3010;++i) ff[i]+=f[i-a];
    rep(i,3010) ff[i]%=mod;
    f=ff;
  }
  print(f[s]);
  return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;

//Tile
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		while(k--!=0){
			int i = sc.nextInt()-1;
			int j = sc.nextInt()-1;
			if(n/2<=i)i=n-i-1;
			if(n/2<=j)j=n-j-1;
			System.out.println(Math.min(i, j)%3+1);
		}

	}
}

Measured memory_bytes: 12000