akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = [input() for _ in range(n)]
x = [] #(の方が多いもの
y = [] #)の方が多いもの
for i in range(n):
    cnt1 = 0
    cnt2 = 0
    for j in range(len(s[i])):
        if s[i][j] == '(':
            cnt1 += 1
        else:
            cnt2 += 1
    if cnt1 - cnt2 > 0:
        x.append([cnt2, cnt1, s[i]])
    else:
        y.append([cnt1, cnt2, s[i]])
x.sort() #)が少ない順
y.sort(reverse=True) #(が多い順
tmp = 0
que = deque()
for i, j, k in x:
    for l in k:
        if l == '(':
            tmp += 1
        else:
            if tmp > 0:
                tmp -= 1
            else:
                print('No')
                quit()
for i, j, k in y:
    for l in k:
        if l == '(':
            tmp += 1
        else:
            if tmp > 0:
                tmp -= 1
            else:
                print('No')
                quit()
if tmp != 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 309792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n) cin >> b[i];

	vector<int> ans;

	while(n > 0) {
		for(int j = n - 1; j >= 0; j--){
			if (b[j] > (j + 1)) {
				cout << -1 << endl;
				return 0;
			}
			if (b[j] == (j + 1)) {
				ans.push_back(b[j]); // b[j]を抜き出す
				n--;
				Rep(k, j, n) { // 前に詰める
					b[k] = b[k + 1];
				}
				break;
			}
		}
	}

	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    S = input().split()

    ans = len(set(S))

    if ans == 4:
        print("Four")
    else:
        print("Three")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61936
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int MAX = 1e5+10;
const int MAX1 = 1e5+10;
const int INF = 1e9+10;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string x;
    cin >> x;
    if(x[0] == x[1] && x[0] == x[2] && x[0] == 'R'){
        cout << 3;
    }
    else if(x[0] == x[1]&& x[0] == 'R'){
        cout << 2;
    }
    else if(x[1] == x[2]&& x[1] == 'R'){
        cout << 2;
    }
    else{
        bool tr = 0;
        for(int i = 0;i < 3;i++){
            if(x[i] == 'R'){
                tr = 1;
            }
        }
        if(!tr){
            cout << 0;
        }
        else{
            cout << 1;
        }

    }
}


/*
3 4
1 2
2 3
4 1
2 1
3
1 2
2 3
1 2

*/


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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	h[0]--;
	int flag=1;
	rep(i,n-1){
		if(h[i] <h[i+1]) h[i+1]--;
		if(h[i] >h[i+1]) flag=0;
	}
	if(flag == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



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

int main(){
  int N,K;
  int sum=0;
  cin >> N >> K;
  
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x*x<=(x-K)*(x-K)) sum+=x;
    else if(x>K) sum+=x-K;
    else sum+=K-x;
  }
  cout << 2*sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int w,a=0;
    for(int i=0;i<200;i++){
        cin>>w;
        a=1150;
        if(w>=10&&w<20){
            cout<<4280-(a+125*(w-10))<<endl;
            }
            else if(w>=20&&w<30){
                cout<<4280-(a+1250+140*(w-20))<<endl;
            }
            else if(w>=30){
                cout<<4280-(a+1250+1400+160*(w-30))<<endl;
            }
            else if(w<10&&w>=0){
                cout<<4280-1150<<endl;
            }
            
            if(w==-1){
            break;
            }
        }
        
        
    

}


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

int main(){
  int n,a[110],b;
  string c;

  while(cin >> n,n){
    cin >> c; b = 0;
    for(int i=0;i<n;i++)a[i] = 0;

    for(int i=0;i<c.size();i++){
      int p = i%n;
      if(c[i] == 'M'){
	a[p]++;
      }else if(c[i] == 'S'){
	b += a[p]+1; a[p] = 0;
      }else{
	a[p] += b+1; b = 0;
      }
    }

    sort(a,a+n);
    for(int i=0;i<n;i++)cout << a[i] << " ";
    cout << b << endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s[1]!='R'){
        if(s[0]=='R'||s[2]=='R'){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else if(s[0]!='R'&&s[2]!='R'){
        cout << 1 << endl;
    }else if(s[0]!='R'||s[2]!='R'){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
	return 0;
}

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

using namespace std;

int N, A, B, C, X;
int Y[110];

void solve() {
	int frame = 0, reel = 0;
	
	while (1) {		
		if (Y[reel] == X) reel++;
		if (reel == N) break;
		
		X = (A * X + B) % C;
		frame++;
		
		if (frame > 10000) {
			cout << -1 << endl;
			return;
		}
	}
	
	cout << frame << endl;
}

int main() {
	while (1) {
		cin >> N >> A >> B >> C >> X; if (N == 0) break;
		for (int i = 0; i < N; i++) cin >> Y[i];
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1160
class SegmentTree:
    def __init__(self, data):
        # 単位元
        self.ide_ele = 0
        # num: n以上の最小の2のべき乗
        self.num = 2 ** (N - 1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(N):
            self.seg[i + self.num - 1] = 1 << (ord(data[i]) - 97)
        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.seg[2 * i + 1] | self.seg[2 * i + 2]

    def update(self, k, x):
        k += self.num - 1
        self.seg[k] = 1 << (ord(x) - 97)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k * 2 + 1] | self.seg[k * 2 + 2]

    def query(self, left, right):
        if right <= left:
            return self.ide_ele
        left += self.num - 1
        right += self.num - 2
        res = self.ide_ele
        while right - left > 1:
            if left & 1 == 0:
                res = res | self.seg[left]
            if right & 1 == 1:
                res = res | self.seg[right]
                right -= 1
            left = left // 2
            right = (right - 1) // 2
        if left == right:
            res = res | self.seg[left]
        else:
            res = (res | self.seg[left]) | self.seg[right]
        return res


N = int(input())
S = list(input().strip())
Q = int(input())
MAX_DIGIT = 26
st = SegmentTree(S)


for i in range(Q):
    q, a, b = map(str, input().split())
    if int(q) == 1:
        a = int(a) - 1
        st.update(a, b)
    if int(q) == 2:
        a = int(a) - 1
        b = int(b)
        res = st.query(a, b)
        print(str(bin(res)).count('1'))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  if (n % 3 == 1) {
    map<ll, int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;
    if ((mp.size() == 2 && mp[0] == n / 3) || (n == mp[0])) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (n % 3 == 2) {
    bool ok = true;
    for (int i = 0; i < n; i++) if (a[i] > 0) ok = false;
    if (ok) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    map<ll, int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;
    vector<ll> v;
    for (auto &pr : mp) v.push_back(pr.first);
    if (v.size() > 3) {
      cout << "No" << endl;
    } else if (mp[0] == n || (mp[0] * 3 == n && mp.size() == 2)) {
      cout << "Yes" << endl;
    } else if (v.size() == 3 && mp[v[0]] == mp[v[1]] && mp[v[1]] == mp[v[2]] && ((v[0] ^ v[1] ^ v[2]) == 0)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6904
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
typedef pair<pii,pii> s4;
int n,c[555][4],cc[555]; s4 t[555][4],g[555];
#define S 5
map<s4,ll> ms[S];
ll f[17];
#define p4(a,b,c,d) make_pair(pii(a,b),pii(c,d))
s4 py(s4 x)
{
	return min(min(x,p4(x.fi.se,x.se.fi,x.se.se,x.fi.fi)),
	min(p4(x.se.fi,x.se.se,x.fi.fi,x.fi.se),
	p4(x.se.se,x.fi.fi,x.fi.se,x.se.fi)));
}
ll fac[S];
void add(int x)
{
	for(int j=S-1;j>1;--j)
		ms[j][g[x]]+=ms[j-1][g[x]]*cc[x];
	ms[1][g[x]]+=cc[x];
}
void del(int x)
{
	ms[1][g[x]]-=cc[x];
	for(int j=1;j<S;++j)
		ms[j][g[x]]-=ms[j-1][g[x]]*cc[x];
}
int main()
{
	fac[0]=1; ll aa=0;
	for(int i=1;i<S;++i) fac[i]=fac[i-1]*i;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=0;j<4;++j) scanf("%d",&c[i][j]);
	for(int x=1;x<=n;++x)
	{
		for(int i=0;i<4;++i)
			t[x][i]=p4(c[x][i],c[x][(i+3)&3],
			c[x][(i+2)&3],c[x][(i+1)&3]);
		g[x]=min(min(t[x][0],t[x][1]),min(t[x][2],t[x][3]));
		for(int i=0;i<4;++i)
			cc[x]+=(g[x]==t[x][i]);
		add(x);
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			del(i); del(j);
			for(int k=0;k<4;++k)
			{
				map<s4,int> tar;
				for(int p=0;p<4;++p)
					++tar[py(p4(c[i][p],c[i][(p+1)&3],
					c[j][(4-p+k)&3],c[j][(4-p+k+1)&3]))];
				ll ans=1;
				for(auto s:tar)
					ans*=ms[s.se][s.fi]*fac[s.se];
				aa+=ans;
			}
			add(i); add(j);
		}
	}
	printf("%lld\n",aa/3);
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010
#define MAX_FACT 30

ll L;
ll fact[MAX_FACT];
ll to_cost[MAX_FACT] = {};  // ノード i に行くエッジの最大コスト(0 じゃないほう)

// [lb, ub) の範囲で val 以下の要素で最大のもののインデックスを返す
// なければ -1 を返す
ll bin_search4(ll lb, ll ub, ll val) {
    lb--; ub--;
    while(ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if(fact[mid] >= val) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    // この時点で lb + 1 = ub
    if(fact[ub] <= val) { return ub; }
    if(lb < 0) { return -1; }
    if(fact[lb] > val) { return -1; }
    return lb;
}

// num 以下の表現できる最大の 2 べきの値を返す
ll get_max(ll num) {
    ll index = bin_search4(0, MAX_FACT, num);
    if(index < 0) { return -1; }
    return fact[index];
}
// num 以下の表現できる最大の 2 べきの指数を返す
ll get_index(ll num) { return bin_search4(0, MAX_FACT, num); }


struct Edge { int from, to, cost; };

signed main()
{
    cin >> L;

    // fact の作成
    fact[0] = 1;
    for(int i = 1; i < MAX_FACT; ++i) { fact[i] = fact[i-1] * 2; }

    // ノード数の決定とグラフのベースを作成
    vector<Edge> ans;
    ll nodes = 1;   // ノード数
    ll loop_val = get_max(L/2);
    while(loop_val > 0) {
        ans.push_back({nodes, nodes+1, loop_val});
        ans.push_back({nodes, nodes+1, 0});
        to_cost[nodes+1] = loop_val;
        nodes++;
        loop_val /= 2;
    }

    // 残りの辺を適切に生やす
    ll remain = L - get_max(L);
    ll cur_cost = get_max(L);   // 増やすエッジのコスト
    while(remain > 0) {
        ll node_to = nodes - get_index(remain); // エッジの指し先
        ans.push_back({1, node_to, cur_cost});
        cur_cost += to_cost[node_to];
        remain -= get_max(remain);
    }

    // 答えの表示
    printf("%lld %zu\n", nodes, ans.size());
    for(auto& e : ans) { printf("%lld %lld %lld\n", e.from, e.to, e.cost); }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int[] countSum = new int[N + 2];

            int sumind = 0;
            int count = 0;
            bool isB = true;

            string s0 = Console.ReadLine();
            for (int i = 0; i < s0.Length; i++)
            {
                if(isB)
                {
                    if(s0[i] != '1')
                    {
                        countSum[sumind] = count;
                        sumind++;
                        isB = false;
                    }
                }
                else
                {
                    if(s0[i] != '0')
                    {
                        countSum[sumind] = count;
                        sumind++;
                        isB = true;
                    }
                }

                count++;
            }

            if(isB)
            {
                countSum[sumind] = count;
                sumind++;
            }
            else
            {
                countSum[sumind] = count;
                sumind++;
                countSum[sumind] = count;
                sumind++;
            }

            int ans = 0;
            for (int i = 0; i < sumind; i += 2)
            {
                if ( i - K * 2 - 1 < 0)
                {
                    ans = Math.Max(ans, countSum[i]);
                }
                else
                {
                    ans = Math.Max(ans, countSum[i] - countSum[i - K * 2 - 1]);
                }
            }

            Console.WriteLine(ans);
        }
    }
}




Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;
long long int a[100005],b[100005],x,res,ten[15]={1},n,color[100005],num[100005]={};
queue<long long int>ed[100005];
queue<long long int>task;
map<pair<long long int,long long int>,long long int >mp;
string str;
int main() {
	cout << fixed << setprecision(18);
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        mp[{a[i],b[i]}]=INF;
        ed[a[i]].push(b[i]);
        num[a[i]]++;
        num[b[i]]++;
    }
    for(int i=0;i<n;i++){
        res=max(num[i],res);
    }

    task.push(1LL);
    while(!task.empty()){
        long long int memo=1;
        while(!ed[task.front()].empty()){
            if(memo==color[task.front()]){memo++;}
            mp[{task.front(),ed[task.front()].front()}]=memo;
            color[ed[task.front()].front()]=memo;
            memo++;
            task.push(ed[task.front()].front());
            ed[task.front()].pop();
        }
        task.pop();
    }
    cout<<res<<endl;
    for(int i=0;i<n-1;i++){
        cout<<mp[{a[i],b[i]}]<<endl;
    }
} 


Measured memory_bytes: 77056
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x[] = new int[n + 1];
		int y[] = new int[m + 1];
		x[0] = sc.nextInt();
		y[0] = sc.nextInt();

		for (int i = 1; i <= n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 1; i <= m; i++) {
			y[i] = sc.nextInt();
		}
		Arrays.sort(x);
		Arrays.sort(y);
		
		if (x[x.length-1]<y[0])
			System.out.println("No War");
		else 
			System.out.println("War");

	}
}


Measured memory_bytes: 23380
a=input()
b=input()
la=len(a)
lb=len(b)
ans="UNRESTORABLE"
for i in range(la-lb+1):
  k=1
  for j in range(lb):
    if a[i+j]=="?":
      continue
    if a[i+j]!=b[j]:
      k=0
  if k==1:
    ans=i
if ans=="UNRESTORABLE":
  print(ans)
else:
  ans=a[:ans]+b+a[ans+lb:]
  print(ans.replace("?","a"))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    t = 1
    ans = 0
    while True:
        if t >= B:
            print(ans)
            break
        t += A-1
        ans += 1
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61636
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

int N, M;
vector<int> v[50];
vector<int> A(50, 0);
vector<int> B(50, 0);

bool bridge(int a, int b) {

    bool result = true;

    vector<int> check(N, 0);
    check[a] = 1;

    queue<int> q;
    q.push(a);

    while ( ! q.empty() ) {
        int temp = q.front();
        q.pop();

        for( int x: v[temp] ) {
            if ( temp == a && x == b ) continue;
            if ( check[x] == 0 ) {
                check[x] = 1;
                q.push(x);
            }
            if ( x == b ) {
                result = false;
                break;
            }
        }
    }
    return result;
}

int main() {

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a;
        B[i] = b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if ( bridge(A[i], B[i]) ) {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M, ans, a, b, c, d, e;
string s, t;

int main()
{
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'o')
            a++;
    }
    N = s.size();
    if (15 - N + a > 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(begin(a), end(a), [] (const auto& l, const auto& r) {
    return l.second < r.second;
  });
  int t = 0;
  for (int i = 0; i < n; ++i) {
    t += a[i].first;
    if (t > a[i].second) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main (void) {
    int N;
    map<int, int> a;

    cin >> N;
    long long max=0, tmp;
    for ( int i=0; i<N; i++ ) {
        cin >> tmp;
        a[tmp]++;
        if ( tmp > max )
            max = tmp;
    }

    long long ans=0;
    for ( auto m : a ) {
        if ( m.second > m.first )
            ans += m.second - m.first;
        else if ( m.second < m.first )
            ans += m.second;
    }

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


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

int cmp1(const void *a,const void *b)
{
  if(*(char*)a>*(char*)b)
  {
    return 1;
  }
  else if(*(char*)a<*(char*)b)
  {
    return -1;
  }
  else
  {
    return 0;
  }
}

int cmp2(const void *a,const void *b)
{
   if(*(char*)a<*(char*)b)
  {
    return 1;
  }
  else if(*(char*)a>*(char*)b)
  {
    return -1;
  }
  else
  {
    return 0;
  }
} 
int main()
{
  char s[100]={},t[100]={};
  
  scanf("%s%s",s,t);
  
  int ls=strlen(s),lt=strlen(t);
  int i;
  
  qsort(s,ls,sizeof(char),cmp1);
  qsort(t,lt,sizeof(char),cmp2);
  
  if(strcmp(s,t)<0)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
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;
ll A[100010];
vector<int> G[100010];
bool flag = true;
bool used[100010];

ll dfs(int v){
    used[v] = true;

    ll l = 0, r = 0;
    int son = 0;
    ll mx = 0;
    for(auto& u : G[v]){
        if(used[u]) continue;
        son++;
        ll val = dfs(u);
        chmax(mx, val);
        r += val;
    }
    if(son == 0) return A[v];
    else if(son == 1){
        if(r != A[v]) flag = false;
        return A[v];
    }else{
        l = max((r + 1) / 2, mx);
        if(A[v] < l || r < A[v]) flag = false;
        return A[v] * 2 - r;
    }
}

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    int p = 1;
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        if(G[a].size() == 1) p = a;
        if(G[b].size() == 1) p = b;
    }
    if(dfs(p) != A[p]) flag = false;
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <math.h>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int N;
  cin >> N;
  long long ans = 0;
  FOR(i,0,N+1){
    ans = (i+1)*(i+1);
    if(ans > N){
      cout << i*i << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int X[20][20];
    int Y[20][20];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 0; j < A[i]; j++) {
            cin >> X[i][j];
            cin >> Y[i][j];
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << N); bit++) {
        bool ok = true;
        int cnt = 0;
        for(int i = 0; i < N; i++) {
            if(((bit>>i)&1) == 0) {
                continue;
            }
            for(int j = 0; j < A[i]; j++) {
                if(Y[i][j] == 1 && ((bit>>(X[i][j]-1))&1) == 0){
                    ok = false;
                }
                else if(Y[i][j] == 0 && ((bit>>(X[i][j]-1))&1) == 1) {
                    ok = false;
                }
            }
            cnt += (bit>>i)&1;
        }
        if(ok) {
            ans = max(ans,cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

A, B = inpl()

L = [["."]*50 for i in range(100)]
R = [["#"]*50 for i in range(100)]

def plot(R):
    print("\n".join(["".join(r) for r in R]))

count = 0
for i in range(11):
    for j in range(48):
        if count == B-1:
            break
        L[j+3*i+1][j+1] = "#"
        count += 1

count = 0
for i in range(11):
    for j in range(48):
        if count == A-1:
            break
        R[j+3*i+1][j+1] = "."
        count += 1
        
ANS = [l+r for l, r in zip(L, R)]

print(100, 100)
plot(ANS)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define INF     1e9
#define ld      long double
#define lli     long long int
#define PI 	    acos(-1)
#define read    freopen("in.txt","r",stdin)
#define uu		first
#define vv		second
#define write   freopen("out.txt","w",stdout)
#define pii     pair<int,int>
using namespace std;
int n,cnt=1;
int main()
{
    cin>>n;
    while(cnt<n){
        cnt<<=1;
    }
    if(cnt>n) cnt/=2;
    cout<<cnt<<endl;
    return 0;
}


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

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

using namespace std;

int main(void){
  int n,i;
  cin >> n;
  vector<int> input(n+1);
  REP(i,n) cin >> input[i] >> input[i+1];
  
  vector<vector<int>> res(n+1, vector<int>(n+1));
  vector<int> p(n+1);
  FOR(i,1,n+1) res[i][i]=0;
  FOR(l,2,n+1){
    FOR(i,1,n-l+2){
      int j = i+l-1;
      res[i][j] = (1<<21);
      FOR(k,i,j){
        res[i][j] = min(res[i][j],res[i][k]+res[k+1][j] + input[i-1]*input[k]*input[j]);

        
      }
    }
  }
  /*
  REP(i,n+1){
    REP(j,n+1){
      cout << res[i][j] << " ";
    }
    cout << endl;
  }
  */
  cout << res[1][n] << endl;


  return 0;
}

Measured memory_bytes: 3176
<?php
fscanf(STDIN, "%d %d", $A, $B);
$C = gcd($A, $B);
$factor[1] = 1;
while ($C !== 1) {
    $sqrt = sqrt($C);
    $bool = false;
    for ($i = 2; $i <= $sqrt; $i++) {
        if ($C % $i === 0) {
            $factor[$i] = 1;
            $C /= $i;
            $bool = true;
            break;
        }
    }
    if ($bool === false) {
        $factor[$C] = 1;
        $C = 1;
    }
}

echo count($factor);

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}


Measured memory_bytes: 4728
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll dp[1000100][4];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	dp[0][0]=8;
	dp[0][1]=1;
	dp[0][2]=1;
	dp[0][3]=0;
	forn(i,1,n-1)
	{
		dp[i][0]=(dp[i-1][0]*8+mod)%mod;
		dp[i][1]=(dp[i-1][0]+(dp[i-1][1]*9)%mod+mod)%mod;
		dp[i][2]=(dp[i-1][0]+(dp[i-1][2]*9)%mod+mod)%mod;
		dp[i][3]=(dp[i-1][1]+dp[i-1][2]+(dp[i-1][3]*10)%mod+mod)%mod;
	}
	cout<<dp[n-1][3]%mod<<endl;
	return 0;
}



Measured memory_bytes: 34892
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int x,y,id;
}f[200001];
int n,fa[200001],p[200001],k[200001],id[200001],cnt1,cnt2,root;
bool cmp(node a,node b){
	return a.x<b.x;
}
int father(int a){
	if(fa[a]==a)return a;
	fa[a]=father(fa[a]);
	return fa[a];
}
int find(int a){
	if(cnt1>cnt2)return 0;
	if(a<k[cnt2])return 0;
	int l=cnt1,r=cnt2;
	while(l<r){
		int mid=(l+r)/2;
		if(k[mid]<=a)r=mid;
		else l=mid+1;
	}
	return l;
}
void add(int a,int b){
	int s=find(a);
	if(s==0){
		cnt2++;
		fa[cnt2]=cnt2;
		id[b]=cnt2;
		p[cnt2]=1;
		k[cnt2]=a;
	}else{
		id[b]=father(s);
		p[father(s)]++;
		for(int i=s+1;i<=cnt2;i++){
			if(father(i)!=father(s)){
				p[father(s)]=p[father(s)]+p[father(i)];
				p[father(i)]=0;
				fa[father(i)]=father(s);
			}
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&f[i].x,&f[i].y);
		f[i].id=i;
		p[i]=1;
	}
	cnt1=1;
	cnt2=0;
	sort(f+1,f+n+1,cmp);
	for(int i=1;i<=n;i++)add(f[i].y,f[i].id);
	for(int i=1;i<=n;i++)printf("%d\n",p[father(id[i])]);
}

Measured memory_bytes: 7808
A,B = map(int,input().split())
ami,ama = A/0.08,(A+1)/0.08
bmi,bma = B/0.1,(B+1)/0.1
#print(ami,ama,bmi,bma)
ans = 0
flag = False
for x in range(1,1200):
    if ami<=x<ama and bmi<=x<bma:
        ans = x
        flag = True
        break
if flag:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 38512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    int p=-1;
    for(int i=0;i<n;i++){
       string s1=s.substr(i);
       string s2=t.substr(0,(n-i));
       //cout<<s1<<s2<<endl;
       if(s1==s2){
           p=i;
           break;
       }

    }
    if(p!=-1){p = n-p;}else{p=0;}
    cout<<2*n-p<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,h[100005],dp[100005];
int main()
{
	cin >> n >> k;
	for(int i=1; i<=n; i++) cin >> h[i];
	dp[n-1]=abs(h[n-1]-h[n]);
	for(int i=n-2; i>=1; i--) 
	{
		dp[i]=1e9;
		for(int j=1; j<=k && i+j<=n; j++) dp[i]=min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
		
	}
	cout << dp[1];
	return 0;
}

Measured memory_bytes: 4388
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
ans=0
for i in range(1,n):
    if n%i==0:
        ans+=(n//i)-1
    else:
        ans+=(n//i)
print(ans)

Measured memory_bytes: 10364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int a, b;
	cin >> a >> b;
	if (a < b)
	{
		for (int i = 0; i < b; i++)
			cout << a;
	}
	else
	{
		for (int i = 0; i < a; i++)
			cout << b;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=9;i++)
	{
		for(int c=1;c<=9;c++)
		{
			if(i*c==n)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main()
{
  double L;
  cin >> L;
  
  double side = L / 3;
  
  printf("%.10f\n", pow(side, 3));

  return 0;
}


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

int main(){
  int N ;
  int i,j,k ;
  
  cin >> N ;
  
  k=0 ;
  
  for(i=0;4*i<=N;i++){
    for(j=0;7*j<=N;j++){
      if(N == 4*i + 7*j){
      	k=1 ;
      }
    }
  }
  
  if(k==1){cout << "Yes" << endl;}
  else{cout << "No" << endl ;}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char ch[4];
    scanf("%s",ch);
    if(ch[0]==ch[1] || ch[1]==ch[2] || ch[2]==ch[3])
    {
        printf("Bad");
    }

    else
    {
        printf("Good");
    }
    return 0;
}


Measured memory_bytes: 128
s = input()
t = input()
s = s[::-1]
t = t[::-1]
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] != t[j] and s[i+j] != '?':
      break
  else:
    break
else:
  print('UNRESTORABLE')
  exit(0)
s = s[:i] + t + s[i+len(t):]
s = s.replace('?','a')
s = s[::-1]
print(s)

Measured memory_bytes: 3064
/*
ID: rajiv
TASK: test
LANG: C++14
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>
#include<iterator>
#include<random>
#include<chrono>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ONLINE_JUDGE

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int rnd(int a, int b){ // including a and b
	return a+(rng()%(b-a+1));
}
#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sortr(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb push_back
#define endl '\n'

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};

void solve(){
	int n; cin>>n;
	lli ans=1,x;
	bool f=false, z=false;
	lli k=3e18,h=1e18;
	rep(i,n){
		cin>>x;
		if(x==0) z=true;
		if(z) continue;
		if(x<=(k/ans)){
			if(x*ans>h){
				f=true;
			}else{
				ans=ans*x;
			}		
		}else{
			f=true;
		}	
	}
	if(z) cout<<"0"<<endl;
	else if(f) cout<<"-1"<<endl;
	else cout<<ans<<endl;	
}

int main(){
	fast_io
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif 
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}



Measured memory_bytes: 3536
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n; ll ans = -1; ll num = 0;
  
  while(ans == -1){
    if(n < pow(2,num)){
      ans = pow(2,num - 1);
    }
    num++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n, a[2], x[2][3][2], s;
double ans;
char d;
inline double calc(double time){
    double ret = 1;
    rep(i,2) ret *= min(min((double)x[i][0][0], x[i][1][0] + time), x[i][2][0] - time) - max(max((double)x[i][0][1], x[i][1][1] + time), x[i][2][1] - time);
    return ret;
}
int main(){
    scanf("%d", &n);
    rep(i,2) rep(j,3) x[i][j][1] = -(x[i][j][0] = 1e8);
    rep(i,n){
        scanf("%d%d %c", a, a+1, &d);
        int t = d == 'U' || d == 'D';
        int k = d == 'L' || d == 'D';
        x[t^1][0][0] = min(x[t^1][0][0], a[t^1]);
        x[t^1][0][1] = max(x[t^1][0][1], a[t^1]);
        x[t][1+k][0] = min(x[t][1+k][0], a[t]);
        x[t][1+k][1] = max(x[t][1+k][1], a[t]);
    }
    ans = calc(0);
    rep(i,2) rep(j,2){
        double cand[3] = {(double)x[i][0][j] - x[i][1][j], (double)x[i][2][j] - x[i][0][j], ((double)x[i][2][j] - x[i][1][j])/2};
        rep(k,3) if(cand[k] > 0) ans = min(calc(cand[k]), ans);
    }
    printf("%0.10f\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c,d,e,f,g,h;
  while(1){
    cin >> n;
    if(n==0) break;
    while(n){
      cin >> a >> b >> c >> d >> e >> f >> g >> h;
      cout << a*e-b*f-c*g-d*h << ' ' << a*f+b*e+c*h-d*g << ' ';
      cout << a*g+c*e-b*h+d*f << ' ' << a*h+d*e+b*g-c*f << endl;
      n--;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
A, B, C = sorted([int(_) for _ in input().split()])
A, B, C = [0, C - B, C - A]
if B % 2 and C % 2:
    print(1 + (B - 1) // 2 + (C - 1) // 2)
elif B % 2:
    print(1 + (B + 1) // 2 + C // 2)
elif C % 2:
    print(1 + (C + 1) // 2 + B // 2)
else:
    print(B // 2 + C // 2)


Measured memory_bytes: 3060
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  //X == 1 だけ例外
  val n = readLine.trim.toInt
  val strs = readLine.trim.split(' ').map(_.toInt)
  if ((1 until strs.length).forall(it ⇒ strs(it) > strs(it - 1))){
    println(1)
  }else {
    val list = strs.toList
    val head = strs(0)
    var left = 2
    var right = n
    while (left < right){
      val mid = (left + right) / 2
      if (canMake(list.tail, mid, List(new CharWithLength(1, head)), head)) {
        right = mid
      }else {
        left = mid + 1
      }
    }
    println(right)
  }
  def canMake(strs: List[Int], x: Int, current: List[CharWithLength], currentLength: Int): Boolean = {

    strs match {
      case str::r if str == currentLength ⇒
        countUp(current, x) match {
          case Some(next) ⇒ canMake(r, x, next, currentLength)
          case None ⇒ false
        }
      case str::r if str > currentLength ⇒ canMake(r, x, new CharWithLength(1, str - currentLength)::current, str)
      case str::r ⇒ countUp(shrink(current, currentLength - str), x) match {
        case Some(next) ⇒ canMake(r, x, next, str)
        case None ⇒ false
      }
      case Nil ⇒ true
    }
  }
  def shrink(current: List[CharWithLength], remove: Int): List[CharWithLength] = {
    current match {
      case h::t if h.length > remove ⇒ new CharWithLength(h.rank, h.length - remove)::t
      case h::t if h.length == remove ⇒ t
      case h::t ⇒ shrink(t, remove - h.length)
    }
  }
  def countUp(current: List[CharWithLength], x: Int): Option[List[CharWithLength]] = {
    current match {
      case h::Nil if h.rank == x ⇒ None
      case h::t if h.rank == x ⇒ countUp(t, x) match {
        case Some(upped) ⇒ Some(new CharWithLength(1, h.length)::upped)
        case None ⇒ ???
      }
      case h::i::t if h.length == 1 && h.rank + 1 == i.rank ⇒ Some(new CharWithLength(i.rank, i.length + 1)::t)
      case h::t if h.length == 1 ⇒ Some(new CharWithLength(h.rank + 1, 1)::t)
      case h::t ⇒ Some(new CharWithLength(h.rank + 1, 1)::new CharWithLength(h.rank, h.length - 1)::t)
    }

  }
  def exponent(base: Int, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ exponent(base, exp / 2).let{it ⇒ it * it * exponent(base, exp % 2)}
    }
  }

  class CharWithLength(val rank: Int, var length: Int) {
    override def toString: String = rank.toString * length
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

Measured memory_bytes: 127496
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x<b&&a<y){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}


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


int main(){
    int n;
    cin >>n;
    int h[n];
    rep(i,n){
        int x;
        cin >> x;
        h[i] = x;
    }
    bool check='true';
    h[0] -= 1;
    rep(i,n-1){
      	 if(h[i+1] < h[i]){
            check = 0;
            break;
        }
        if(h[i+1]-1>=h[i]){
            h[i+1] -= 1;
        }
    }
    if(check==1){
        cout <<"Yes" <<endl;
    }
    else{
        cout <<"No" <<endl;
    }
    
    
    
    
    return 0;
    
}









Measured memory_bytes: 640
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true) {
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		if(n==0)break;
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		int[] s = new int[n+1];
		s[0] = 0;
		
		for(int i = 0; i < n; i++) {
			s[i+1] = s[i]+a[i];
		}
		
		long ans = Long.MIN_VALUE;
		
		for(int i = 0; i <=n-k; i++) {
			long val = s[k+i] - s[i];
			if(ans < val) ans = val;
		}
		
		System.out.println(ans);
		
		}
		
		
	}

}



Measured memory_bytes: 67400
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
  
};
//INSERT ABOVE HERE
const int MAX = 4040;
using M = Mint<int>;
M dp[MAX][MAX];
signed main(){
  int n,m,k;
  cin>>n>>m>>k;

  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      dp[i][j]=0;

  dp[0][0]=1;
  
  M ans=0;
  for(int i=0;i+1<MAX;i++){
    M res=0;
    for(int j=0;j<MAX;j++){
      if(j-k>=0) res-=dp[i][j-k];
      res+=dp[i][j];
      dp[i+1][j]+=res;
    }
  }
  for(int i=0;i+1<MAX;i++){
    int l=i*(k-1)+k;
    for(int j=0;j<=m;j++){
      int a=(m-j)%(k-1);
      if(a==0) a=k-1;
      int x=j+a,y=l-x;
      if(x>m||y>n) continue;
      if((m-x)%(k-1)) continue;
      if((n-y)%(k-1)) continue;
      ans+=dp[i][j];
    }
  }  
  cout<<ans.v<<endl;
  return 0;
}


Measured memory_bytes: 64000
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int tim = 0;
    int xx = 0, yy = 0;
    for(int i = 0; i < n; i++){
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(x - xx) + abs(y - yy);
        if(d > (t - tim) || d % 2 != (t - tim) % 2){
            cout << "No";
            exit(0);
        }
        tim = t;
        xx = x, yy = y;
    }
    cout << "Yes";
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256