akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            for(var i = 0; i < N; i++)
            {
                if (long.Parse(Console.ReadLine()) % 2 != 0)
                {
                    Console.WriteLine("first");return;
                }
            }
            Console.WriteLine("second");
            
            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplit()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitL()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplitD()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

    }
}


Measured memory_bytes: 17232
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAXM = 2e3 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-3;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define rc(x) ch[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int b, w;
ll inv2, inv[MAXN], fact[MAXN];
void exgcd(int a, int b, int &x, int &y) {
	if (b == 0) { x = 1, y = 0; return; }
	exgcd(b, a%b, y, x); y -= (a / b) * x;
}
void init(int n) {
	int x, y;
	exgcd(2, MOD, x, y);
	inv2 = (x%MOD + MOD) % MOD;
	fact[0] = fact[1] = 1;
	rep(i, 2, n)fact[i] = fact[i - 1] * i%MOD;
	exgcd(fact[n], MOD, x, y);
	inv[n] = (x%MOD + MOD) % MOD;
	for (int i = n - 1; ~i; i--)inv[i] = inv[i + 1] * (i + 1) % MOD;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> b >> w;
	init(b + w);
	ll q = 0, p = 0, denominator = 1;
	rep(i, 0, b + w - 1) {
		if (i >= b) {
			p = (p + denominator * fact[i - 1] % MOD * inv[i - b] % MOD * inv[b - 1]) % MOD;
		}
		if (i >= w) {
			q = (q + denominator * fact[i - 1] % MOD  * inv[i - w] % MOD  * inv[w - 1]) % MOD;
		}
		denominator = denominator * inv2%MOD;
		cout << (1 + q - p + MOD) % MOD * inv2 %MOD << '\n';
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <bits/stdint-uintn.h>
#include <cstdint>

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

using namespace std;

int64_t attack(int64_t x) {
  if (x == 1) {
    return 1;
  }
  return attack(x / 2) * 2 + 1;
}

int main() {
  uint64_t h;
  std::cin >> h;

  std::cout << attack(h) << std::endl;
  return 0;
}


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

int N;

int main () {
  cin >> N;
  cout << (N >= 1000 ? "ABD" : "ABC") << endl;

  return 0;
}


Measured memory_bytes: 256
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        long n = nl(), a = nl(), b = nl();
        long temp = n / (a + b);
        long noOfBlues = temp * a;
        long rem = n % (a + b);
        noOfBlues += Math.min(a, rem);
        pl(noOfBlues);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 23252
s = input()


alb_list = [0, 0, 0]

for i in range(3):
    t = s[i]
    
    if s[i] == "a":
        alb_list[0] += 1
    elif s[i] == "b":
        alb_list[1] += 1
    elif s[i] == "c":
        alb_list[2] += 1
    else:
        continue

ans = 0
for i in range(3):
    if alb_list[i] != 1:
        ans = 1

if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        while (sc.hasNext()) {
            String[] str = sc.next().split("[^0-9]");
            for (int i = 0; i < str.length; i++) {
                if (str[i].length() > 0) {
                    sum += Integer.parseInt(str[i]);
                }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 26476
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};
#define int ll
int n, ga[2], sa[2], ba[2];

int gsbtable[2][30000001] = {};

void func(int wh, int g,int s,int b, int gt, int st, int bt) {

	REP(i, 30000001) {
		if(i >= g)
			chmax(gsbtable[wh][i], gsbtable[wh][i - g] + gt);
		if (i >= s)
			chmax(gsbtable[wh][i], gsbtable[wh][i - s] + st);
		if (i >= b)
			chmax(gsbtable[wh][i], gsbtable[wh][i - b] + bt);

		if(i)
			chmax(gsbtable[wh][i], gsbtable[wh][i - 1] + 1);

	}
}


signed main(void) {

	cin >> n >> ga[0] >> sa[0] >> ba[0] >> ga[1] >> sa[1] >> ba[1];
	int ans = 0;

	func(0, ga[0], sa[0], ba[0], ga[1], sa[1], ba[1]);
	func(1, ga[1], sa[1], ba[1], ga[0], sa[0], ba[0]);

	REP(i, n + 1) {
		int cans = gsbtable[0][i];
		
		chmax(ans, gsbtable[1][n - i + cans]);
	}


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


Measured memory_bytes: 468992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
typedef long long ll;
int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    int num, ans = 0;
    int a, b, c;
    rep(i, n) {
      cin >> a >> b >> c;
     if(ans < b + c) {
        num = a;
        ans = b + c;
      }
    }
    cout << num << " " << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
input()
x = input()
nums = x.split()

#print(nums)

for i in range(len(nums)):
  nums[i] = int(nums[i])

nums.sort()
  
h = int(len(nums)/2)

if nums[h] == nums[h-1]:
  print("0")
  exit()

print(nums[h] - nums[h-1])

Measured memory_bytes: 10612
sa = input()
sb = input()
sc = input()

tmp_a = 0
tmp_b = 0
tmp_c = 0

turn = 'a'

for _ in range(300):
    if turn == 'a':
        if tmp_a == len(sa):
            print('A')
            exit()
        turn = sa[tmp_a]
        tmp_a += 1
    if turn == 'b':
        if tmp_b == len(sb):
            print('B')
            exit()
        turn = sb[tmp_b]
        tmp_b += 1
    if turn == 'c':
        if tmp_c == len(sc):
            print('C')
            exit()
        turn = sc[tmp_c]
        tmp_c += 1

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

using namespace std;
using ll = long long;


int main()
{
    int k; cin >> k;
    string s; cin >> s;
    if((int)s.size() > k) {
        cout << s.substr(0, k) << "..." << endl;
    } else {
        cout << s << endl;
    }
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

import static java.util.stream.Collectors.toList;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            final List<Long> numList = Arrays.stream(args.get(1).split(" ")).map(Long::valueOf).collect(toList());
            Long max = 0L;
            Long ans = 0L;
            for (int i = 0; i < numList.size(); i++) {
                if (numList.get(i) >= max) {
                    max = numList.get(i);
                    ans++;
                }
            }
            System.out.println(ans);
        };
    }

}


Measured memory_bytes: 28364
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        cout << 1 + b / x << endl;
        return 0;
    }
    cout << b / x - (a - 1) / x << endl;
}


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

int main(){
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U){
        cout << A-1 << " " << B << endl;
    }
    else{
        cout << A << " " << B-1 << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(330)


void deal(){
	ll n;
	cin>>n;
	vector<vector<ll> > g(n, vector<ll> (n,0));
	fori(n)
		forj(n)
			cin>>g[i][j];
	vector<ll> dp((1<<n), 0);
	dp[0] = 1;
	for(ll i = 1; i<(1<<n); i++){
		ll cnt = __builtin_popcount(i);
		--cnt;
		forj(n)
			if(((1<<j) & i) && g[cnt][j])
				dp[i] += dp[i^(1<<j)];
		dp[i] %= modulo;
	}
	cout<<dp[(1<<n)-1];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

def main():
    import bisect
    mod=10**9+7
    S=input()
    N=len(S)
    R=[]
    L=[]
    for i in range(N):
        if S[i]=="R":
            R.append(i)
        else:
            L.append(i)
            
    ans=[0]*N
    
    for i in range(N):
        if S[i]=="R":#右側にある一番近いLを探す，それとの距離の偶奇，で
            num = bisect.bisect_left(L,i)
            ii=L[num]
            d=ii-i
            
            if d%2==0:
                ans[ii]+=1
            else:
                ans[ii-1]+=1
                
        else:
            num = bisect.bisect_left(R,i)
            ii=R[num-1]
            d=i-ii
            if d%2==0:
                ans[ii]+=1
            else:
                ans[ii+1]+=1
                
    print(' '.join(map(str, ans)))
            
            
    
    
    

main()


Measured memory_bytes: 84356
#include<bits/stdc++.h>
	#define ll long long
	#define f   first
	#define s   second
	#define pb          push_back
	#define mod         1000000007
	#define hell        998244353
	#define inf         1000000000000000000LL
	using namespace std;
	ll n,k,m,l,mx,sum,q;
	ll a[200005];
	vector<ll> adj[200005];
	ll ans[200005];
	void dfs(ll v,ll p,ll &len,vector<ll> &dp)
	{   ll y;
		ll oldlen=len;
		auto it=lower_bound(dp.begin(),dp.begin()+len,a[v]);
		if(it==dp.begin()+len)
			dp[len++]=a[v];
		else {y=*it;*it=a[v];}
		ans[v]=len;
		for(auto x:adj[v])
		{
			if(x==p) continue;
			dfs(x,v,len,dp);
		}
		if(oldlen==len) *it=y;
		else len--;
	}
	void solve()
	{   ll x;
		cin>>n;
		for(int i=1;i<=n;i++) cin>>a[i];
		for(int i=0;i<n-1;i++)
		{
			ll x,y;
			cin>>x>>y;
			adj[x].pb(y);
			adj[y].pb(x);
		}
		vector<ll> dp(n+10);
		ll len=0;
		dfs(1,0,len,dp);
		for(int i=1;i<=n;i++)
			cout<<ans[i]<<"\n";

	}    
	int main()
	{   
	    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	    //cout<<primes.size();
	    

	    ll t=1;
	   //cin>>t;
	    for(int i=1; i<=t; i++) {
        solve();
    }
}

	


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

int main() {
  int n, i, m;
  cin >> n;
  
  long long sum = 0;
  vector<int> t(n);
  for(i = 0; i < n; i++){
    cin >> t.at(i);
    sum += t.at(i);
  }
  
  cin >> m;
  
  vector<int> p(m), x(m);
  for(i = 0; i < m; i++){
    cin >> p.at(i) >> x.at(i);
  }
  
  for(i = 0; i < m; i++){
    cout << sum - t.at(p.at(i) - 1) + x.at(i) << endl;;
  }
}

Measured memory_bytes: 256
INF = 1e9

n = int(input())
adj_matrix = [[INF for i in range(n)] for j in range(n)]

for i in range(n):
    u, k, *line = list(map(int, input().split()))
    for j in range(k):
        adj_matrix[u][line[2*j]] = line[2*j+1]

def dijkstra(x):
    isVisited = [False] * x
    d = [INF] * x 
    d[0] = 0
    p = [0] * x 
    
    while True:
        min_cost = INF
        
        for i in range(x):
            if isVisited[i] != True and d[i] < min_cost:
                min_cost = d[i]
                u = i
        
        if min_cost == INF:
            break
        
        isVisited[u] = True
        
        for v in range(x):
            if isVisited[v] != True and adj_matrix[u][v] != INF:
                if d[u] + adj_matrix[u][v] < d[v]:
                    d[v] = d[u] + adj_matrix[u][v]
                    p[v] = u
    return d

for i, di in enumerate(dijkstra(n)):
    print(i, di)

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long LL;

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

int main(int argc, char* argv[]) {
	while (true) {
		int len = -1, cnt = 0;
		cin >> len;
		string s;
		cin >> s;
		if (len <= 0) break;
		for (int i = 0; i < len; ++i) {
			if (s[i] == '(') {
				++cnt;
			} else {
				if (cnt <= 0) {
					s = "(" + s;
					++len;
					++i;
				} else {
					--cnt;
				}
			}
		}
		while (cnt-- > 0) {
			s += ")";
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;

  while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){

    y=(c*d-a*f)/(b*d-e*a);
    x=(c-(b*y))/a;

    if(x==-0)x=0;
    if(y==-0)y=0;

    printf("%.3f %.3f\n",x,y);

  }
  return 0;

}

Measured memory_bytes: 652
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

const long long mod = 1e9 + 7;
int n, m;
const int MAXN = 1e5 + 100;
const int MAXM = 1e5 + 100;
ll x[MAXN] = { };
ll y[MAXM] = { };

long long area(int i, int j, int k, int l) {
  return ((abs(x[j] - x[i]) % mod) * (abs(y[l] - y[k]) % mod)) % mod;
}

void rev_solve() {
  ll sumx, sumy;
  sumx = 0;
  sumy = 0;
  for (int k = 1; k <= n; ++k) {
    ll xk = (k - 1) * x[k] - (n - k) * x[k];
    sumx = sumx + xk;
  }
  for (int k = 1; k <= m; ++k) {
    ll yk = (k - 1) * y[k] - (m - k) * y[k];
    sumy = sumy + yk;
  }
  sumx = sumx % mod;
  sumy = sumy % mod;
  cout << (sumx * sumy) % mod << endl;
}

int main() {
  cin >> n >> m;
  x[0] = y[0] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i];
  }
  for (int i = 1; i <= m; ++i) {
    cin >> y[i];
  }
  rev_solve();
}



Measured memory_bytes: 1792
"""
# 標準入力取得
## 文字列
     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())

## 数値
     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A, B = map(int, sys.stdin.readline().split())
    if B % A == 0:
        print(A + B)
    else:
        print(B - A)

Measured memory_bytes: 5352
N = int(input())
A = list(map(int,input().split()))

B = [sum(A[:i]) for i in range(1,N + 1)]
s = sum(A)
ans = B[-1]
for i in range(N):
  ans = min(ans,abs(sum(A[i:N + 1]) - sum(A[:i])))
  
print(ans)

Measured memory_bytes: 3064
require 'matrix'
N = gets.split.map &:to_i
B = Vector.elements(gets.split.map(&:to_i), false)
ans = 0
N[0].times {
  ans += Vector.elements(gets.split.map(&:to_i), false).dot(B) + N[2] > 0 ? 1 : 0
}
p ans

Measured memory_bytes: 15084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];
    
    sl = r.readLine().split(" ");
    int v = Integer.parseInt(sl[0]);
    int d = Integer.parseInt(sl[1]);
    int c = Integer.parseInt(sl[2]);

    for(int i = 0; i < 10; i++)
    {
      c = v * c - d;
      System.out.println(c);
    }
    
    
  }


}


Measured memory_bytes: 21204
from copy import copy
from collections import deque

N = int(input())

A = [None]*N
Adict = {}
for i in range(N):
    Ai = int(input())
    A[i] = Ai
    Adict[i] = Ai

Asorted = deque(sorted(A))
first = Asorted.pop()
second = Asorted.pop()

for i in range(N):
    Ai = Adict[i]
    Amax = first
    if Amax == Ai:
        Amax = second
    print(Amax)


Measured memory_bytes: 87584
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, b, c;
	while(cin >> a >> b >> c) {
		cout << c - min(a - b, c) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n, m; std::cin >> n >> m;
	std::string state; std::cin >> state;
	std::vector<int> min_step(n + 1, -1); min_step[n] = 0;
	std::vector<int> max_reachable{ n, n };
	for (auto i = 1; i <= n; ++i) {
		auto pos = n - i;
		if (state[pos] == '0') {
			if (max_reachable[max_reachable.size() - 2] <= pos + m) {
				max_reachable.back() = pos;
			}
			else if (max_reachable.back() <= pos + m) {
				max_reachable.push_back(pos);
			}
		}
	}
	if (max_reachable.back() != 0) {
		std::cout << "-1\n";
		return 0;
	}
	for (auto i = 1; i < max_reachable.size(); ++i) {
		auto current = max_reachable[max_reachable.size() - i];
		auto next = max_reachable[max_reachable.size() - i - 1];
		if (i != 1) std::cout << ' ';
		std::cout << next - current;
	}
	std::cout << '\n';
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


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

#ifdef _DEBUG
//  			freopen("input.txt", "r", stdin);
//        freopen("output", "w", stdout);
#endif
    
    int n,m;
    cin >> n >> m;
    int count = 0;
    for(int i=1; i<=n; i++) {
        count += n-i;
    }
    for(int i=1; i<=m; i++) {
        count += m-i;
    }
    cout<<count;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int num1,num2,i,j=0,count=0;
  int N1[10000];
  int N2[500];

  scanf("%d",&num1);
  for(i=0; i<num1; i++){
    scanf("%d",&N1[i]);
  }

  scanf("%d",&num2);
  for(i=0; i<num2; i++){
    scanf("%d",&N2[i]);

    while(N1[j] != N2[i]){ j++;

      if(j == num1) break;
    }
    
    if(j == num1) count+=0;
    else count++; 

    j=0;
  }

  printf("%d\n",count);
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
  }
  long long ans = 1000000000000000;
  for(int i = 0; i <= 100; i++){
    long long tmp = 0;
    for(int j = 0; j < n; j++){
      tmp += abs(x[j] - i) * abs(x[j] - i);
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<int, int> > v(q);
  rep(i, q){
    int l, r;
    cin >> l >> r;
    v[i] = make_pair(l, r);
  }
  vector<int> t(n+1,0), k(n,0);

  for(int i = 0; i < n-1; i++){
    if(s[i] == 'A' && s[i+1] == 'C'){
      k[i] = 1;
    }
    t[i+1] = t[i]+k[i];
  }
  for(int i = 0; i < q; i++){
    cout << t[v[i].second-1]-t[v[i].first-1] << endl;
  }
  system("pause");
}


Measured memory_bytes: 2816
#include <iostream>

using namespace std;

long long A[300001],B[300001];

int main(){
  int i,N,c;
  string S;
  cin >> N;
  cin >> S;
  A[0]=0;
  c=0;
  for (i=0;i<N-1;++i) {
    if (S[i]=='W'){
      c+=1;
    }
    A[i+1]=c;
  }
  c=0;
  B[N-1]=0;
  for (i=N-1;i>0;--i) {
    if (S[i]=='E'){
      c+=1;
    }
    B[i-1]=c;
  }
  int mini=0;
  for(i=1;i<N;++i) {
    if (A[mini]+B[mini] > A[i]+B[i]) {
      mini=i;
    }
  }
  cout << A[mini]+B[mini] << endl;
  return 0;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string Sa,Sb,Sc,dod=".";
	int TATE, YOKO ;
    cin >> TATE >> YOKO >>Sb ;
    Sa = dod + dod + dod;
    Sb = dod+Sb+dod;
  

  
    for (int tate = 0; tate  < TATE ; tate++){

      if (tate != TATE){   
        cin >> Sc ;
      if (tate == (TATE-1)) {
        Sc = dod + dod + dod ;
      }
      }
  
       for (int LOOK = 0; LOOK < YOKO ; LOOK++){
         
         int sum = 0;
         
  			if ( tate == 0){
    			Sa = Sa + dod;
    				}
            
   			if (LOOK==0){
                      Sc = dod+Sc;
   					 }
            if (tate == (TATE-1)){
                     Sc = Sc + dod  ;
            }
         
   			if (LOOK==(YOKO-1)){
                      Sc = Sc+dod;
   					 }
          
    
    		char A,B,C,D,E,F,G,H,I;
   			 A = Sa.at(LOOK);
   			 B = Sa.at(LOOK+1);
   			 C = Sa.at(LOOK+2);
   			 D = Sb.at(LOOK);
   			 E = Sb.at(LOOK+1);
   			 F = Sb.at(LOOK+2);
   			 G = Sc.at(LOOK);
   			 H = Sc.at(LOOK+1);
   			 I = Sc.at(LOOK+2);
  
  
    		 if (E == '#'){
    			cout << '#';
   			 }else{
   			   if (A == '#'){
  			      sum++;
   			   }if (B == '#'){
  			      sum++;
   			   }if (C == '#'){
			      sum++;
   			   }if (D == '#'){
  			      sum++;
   			   }if (F == '#'){
   			      sum++;
  			   }if (G == '#'){
  			      sum++;
   			   }if (H == '#'){
 			      sum++;
 		       }if (I == '#'){
   			      sum++;
  		       }
                        
   	          cout << sum;
             }

    } 
           
     Sa = Sb;
     Sb = Sc;

     cout << endl;
   }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k)
{
  while(u!=NIL && k!=u->key)
    {
      if(k< u->key) u=u->left;
      else u=u->right;
    }
  return u;

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key < x->key) x=x->left;
      else x=x->right;
    }
  z->parent=y;
  
  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;
}



void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25144
# S = input()
#N = int(input())
N = list(map(int, input().split()))
# a = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

ans = 0

N.sort()

if N[0] == 1 and N[1] == 4 and N[2] == 7 and N[3] == 9:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 2940
using System;

namespace _0077
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
             //   var yommikomichu = false;
                string gh = Console.ReadLine();
                if (gh == null) { break; }
                for (int i = 0; i < gh.Length; i++)
                {
                    if (gh.Substring(i, 1) == "@")
                    {
                      //  yommikomichu = true;
                        for (int k = 0; k < int.Parse(gh.Substring(i + 1, 1)); k++)
                        {
                            Console.Write(gh.Substring(i + 2, 1));
                          //  i += 2;
                        }
                        i +=2;
                    }
                    else //if //(!yommikomichu)
                    { Console.Write(gh.Substring(i, 1)); }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8852
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>

using namespace std;

int n, q;
int S[100000];
int T[50000];

int bsearch(int g)
{
	int l = 0, r = n, mid;
	while (l < r) {
		mid = (l + r) / 2;
		if (S[mid] == g) return 1;
		else if (S[mid] > g) r = mid;
		else l = mid + 1;
	}
	return 0;
}

void solve()
{
	int res = 0;
	for (int i = 0; i < q; i++) {
		res += bsearch(T[i]);
	}
	cout << res << endl;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> S[i];
	cin >> q;
	for (int i = 0; i < q; i++) cin >> T[i];
	solve();
	return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b){
    return *(int*)a-*(int*)b;
}

int main(void)
{
    int N,M,ans=0;
    scanf("%d %d",&N,&M);
    int X[M+1];
    for(int i=0;i<M;i++){
        scanf("%d",&X[i]);
    }

    qsort(X,M,sizeof(int),comp);

    for(int l=0;l<M-1;l++){
        X[l]=X[l+1]-X[l];
    }
    X[M-1]=0;

    qsort(X,M,sizeof(int),comp);
  
    for(int i=0;i<=M-N;i++){
        ans+=X[i];
    }


    printf("%d\n",ans);
          
    return 0;
}



Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define pf push_front
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vc4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
const ll oo=(1ll<<60);
int gg(){
    int x=0,w=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')w=0,ch=getchar();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return w?x:-x;
}

int main()
{
     io;
    int T=1;
    //T=gg();
    //cin>>T;
    //for(int cas=1;cas<=T;cas++)
    while(T--)
    {
       string s,t;
       cin>>s>>t;
       ll i,j,k,ans=oo,sl=s.size(),tl=t.size(),cnt=0;
       for(i=0;i+tl<=sl;i++)
       {
           k=i;cnt=0;
           for(j=0;j<tl;j++,k++)
           {
               cnt+=(s[k]!=t[j]);
           }
           ans=min(ans,cnt);
       }
       cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int i,j,k,a[3][3],n;
    rep(i,3){
        rep(j,3){
            scanf("%d",&a[i][j]);
        }
    }
    scanf("%d",&n);
    int b[n];
    rep(i,n) scanf("%d",&b[i]);
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if(b[k]==a[i][j]) a[i][j]=0;
            }
        }
    }
    int ans=0;
    rep(i,3){
        if((a[i][1]==a[i][2]&&a[i][2]==a[i][0])&&a[i][0]==0) ans++;
        else if((a[0][i]==a[1][i]&&a[1][i]==a[2][i])&&a[0][i]==0) ans++;
        else if((a[0][0]==a[1][1]&&a[1][1]==a[2][2])&&a[i][i]==0) ans++;
        else if((a[2][0]==a[1][1]&&a[1][1]==a[0][2])&&a[1][1]==0) ans++;
    }
    if(ans>0) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 1728
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　    int N = int.Parse(Console.ReadLine()); //標準入力
        　  int A = int.Parse(Console.ReadLine());
            if(N % 500 <= A){
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
        }
 }

Measured memory_bytes: 11092
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    H, W, A, B = mi()
    ans = [[None]*W for i in range(H)]
    for i in range(B):
        for j in range(A):
            ans[i][j] = '0'
        for j in range(A, W):
            ans[i][j] = '1'
    for i in range(B, H):
        for j in range(A):
            ans[i][j] = '1'
        for j in range(A, W):
            ans[i][j] = '0'

    print(*[''.join(ans[i]) for i in range(H)], sep='\n')

if __name__ == '__main__':
    main()


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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define all(a)	a.begin(), a.end()
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int a, b;
	cin >> a >> b;
	cout << a * b;	

	return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL)
        h1 = setHeight(T[u].left)+1;
    if(T[u].right != NIL)
        h2 = setHeight(T[u].right) + 1;
    return H[u] = (h1 > h2 ? h1 : h2);
}

//節点uの兄弟を返す
int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ", T[u].parent);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if(T[u].left != NIL) deg++;
    if(T[u].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
    
    if( T[u].parent == NIL ){
        printf("root\n");
    }else if (T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }
}

int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);

    for(int i=0; i<n; i++) T[i].parent = NIL;

    for(int i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    for(int i=0; i<n; i++) if(T[i].parent == NIL) root = i;

    setDepth(root, 0);
    setHeight(root);

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

    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
/*
CE
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

*/
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios  can not be used with scanf,printf.  IF  ios MUST cin,cout.
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
const ll mod=998244353;
const int INF=0x3f3f3f3f;
ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e5+10;
int n,k;
ll sum[N],dp[N];
int L[N],R[N];
ll get(int l,int r){
    if(l<=1)l=1;
    return ((sum[r]-sum[l-1])%mod+mod)%mod;
}
int main(){
    scanf("%d%d",&n,&k);
    rep(i,1,k){
        scanf("%d%d",&L[i],&R[i]);
    }
    dp[1]=sum[1]=1;
    rep(i,1,n){
        rep(j,1,k){
            dp[i]=(dp[i]+get(i-R[j],i-L[j]))%mod;
        }
        sum[i]=sum[i-1]+dp[i];
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e5+5;
const ll inf=1e17;




int main()
{
    idfc;

    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();

    int i,j;

    int ans=n;
    int c;
    int p;

    for(i=0;i<n;i++)
    {
        p=i+m;
        if(p<=n)
        {
            c=0;
            for(j=0;j<m;j++)
            {
                if(s[i+j]!=t[j])c++;
            }
            ans=min(ans,c);
        }
        else break;
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int ans = 0;

		for(int i = a; i <= b; i++){
			if(c%i == 0)ans++;
		}

		System.out.printf("%d\n",ans);
	}
}



Measured memory_bytes: 26452
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=LINF;
	cin>>n;
	vl v(n),sum(n+1),lp(n),rp(n);
	rep(i,n)cin>>v[i],sum[i+1]=sum[i]+v[i];
	int pos=1;
	for(int i=1;i+2<n;i++){
		ll lsum=sum[i+1]-sum[0];
		while(abs((lsum-sum[pos])-sum[pos])>=abs((lsum-sum[pos+1])-sum[pos+1]))pos++;
		lp[i]=pos;
	}
	pos=n-1;
	for(int i=n-2;i>=2;i--){
		ll rsum=sum[n]-sum[i];
		while(abs((sum[n]-sum[pos])-(sum[pos]-sum[i]))>=abs((sum[n]-sum[pos-1])-(sum[pos-1]-sum[i])))pos--;
		rp[i]=pos;
	}
	for(int i=2;i+2<=n;i++){
		ll a=sum[lp[i-1]];
		ll b=sum[i]-a;
		ll c=sum[rp[i]]-(a+b);
		ll d=sum[n]-(a+b+c);
		//cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
		chmin(ans,max({a,b,c,d})-min({a,b,c,d}));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int N=505;
typedef long long LL;
int s[N],t[N],n;unsigned long long u[N],v[N],a[N][N];
bool work(){
	for(int i=0;i<64;i++){
		for(int j=1;j<=n;j++)
			if(s[j]==0&&(u[j]&(1ull<<i)))for(int k=1;k<=n;k++)a[j][k]|=(1ull<<i);
		for(int j=1;j<=n;j++)
			if(t[j]==0&&(v[j]&(1ull<<i)))for(int k=1;k<=n;k++)a[k][j]|=(1ull<<i);
		for(int j=1;j<=n;j++){
			if(!(s[j]==1&&(u[j]&(1ull<<i))))continue;
			int w=0;
			for(int k=1;k<=n;k++)
				if((a[j][k]&(1ull<<i))||(v[k]&(1ull<<i))){w=k;break;}
			if(w){a[j][w]|=(1ull<<i);continue;}
			for(int k=1;k<=n;k++){
				if(t[k]==1)continue;int num=0;
				for(int l=1;l<=n;l++)if(a[l][k]&(1ull<<i))num++;
				if(num<n-1){w=k;break;}
			}
			if(!w)return 0;
			a[j][w]|=(1ull<<i);
		}
		for(int j=1;j<=n;j++){
			if(t[j]==1&&(v[j]&(1ull<<i))){
				int w=0;
				for(int k=1;k<=n;k++)
					if((a[k][j]&(1ull<<i))||(u[k]&(1ull<<i))){w=k;break;}
				if(w){a[w][j]|=(1ull<<i);continue;}
				for(int k=1;k<=n;k++){
					if(s[k]==1)continue;int num=0;
					for(int l=1;l<=n;l++)if(a[k][l]&(1ull<<i))num++;
					if(num<n-1){w=k;break;}
				}
				if(!w)return 0;
				a[w][j]|=(1ull<<i);
			}
		}
		for(int j=1;j<=n;j++){
			unsigned long long w=(1ull<<i);
			if(s[j]==0)for(int k=1;k<=n;k++)w&=a[j][k];
			else{
				w=0;
				for(int k=1;k<=n;k++)w|=a[j][k]&(1ull<<i);
			}
			if(w!=(u[j]&(1ull<<i)))return 0;
		}
		for(int j=1;j<=n;j++){
			unsigned long long w=(1ull<<i);
			if(t[j]==0)for(int k=1;k<=n;k++)w&=a[k][j];
			else{
				w=0;
				for(int k=1;k<=n;k++)w|=a[k][j]&(1ull<<i);
			}
			if(w!=(v[j]&(1ull<<i)))return 0;
		}
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",s+i);
	for(int i=1;i<=n;i++)scanf("%d",t+i);
	for(int i=1;i<=n;i++)scanf("%llu",u+i);
	for(int i=1;i<=n;i++)scanf("%llu",v+i);
	if(!work())return puts("-1"),0;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)printf("%llu%c",a[i][j],j==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 7308