akhauriyash/Code-Regression huggingface dataset:
h, w = gets.split.map(&:to_i)
s = $<.read.tr(".#\n","10").to_i(2)
w += 1
lim = 1 << h * w - 1
t = 1
cnt = 0

cnt, pre, t = cnt + 1, t, (t | t << 1 | t >> 1 | t << w | t >> w) & s while t < lim && t != pre
p pre < t ? s.to_s(2).count(?1) - cnt : -1


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

int main() {
	int N; cin >> N;
	vector<int> V(N), C(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) ans += V[i] - C[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k % 2 != 0){
        int cnt = n / k;
        ans += cnt;
        ans += (ll)cnt * (cnt - 1) * 3;
        ans += (ll)cnt * (cnt - 1) * (cnt - 2);
    }
    else{
        int cnt = n / (k / 2);
        int cnt1 = n / k;
        ans += cnt;
        cnt -= cnt1;
        ans += (ll)cnt * (cnt - 1) * 3;
        ans += (ll)cnt * (cnt - 1) * (cnt - 2);
        ans += (ll)cnt1 * (cnt1 - 1) * 3;
        ans += (ll)cnt1 * (cnt1 - 1) * (cnt1 - 2);
    }
    cout << ans << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && a <= c){
    	cout << a << " ";
		if(b<=c)
			cout << b << " " << c << endl;
		else 
			cout << c << " " << b << endl; 
	} else if (b<=a && b<=c){
    	cout << b << " " ;
		if(a<=c)
			cout << a << " " << c << endl;
		else 
			cout << c << " " << a << endl; 
	} else if (c<=a && c<=b){
    	cout << c << " " ;
		if(a<=b)
			cout << a << " " << b << endl;
		else 
			cout << b << " " << a << endl; 
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int simulate(int target, vector<char> t, vector<char> d, string s)
{
    cerr << target;
    int q = t.size();
    rep(i, q)
    {
        if (target == -1 || target == s.size())
            break;

        if (t[i] == s[target])
        {
            if (d[i] == 'L')
                target--;
            else
                target++;
        }
    }
    cerr << "->" << target << endl;

    return target;
}

int main(int argc, char const *argv[])
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t, d;
    rep(i, q)
    {
        char _t, _d;
        cin >> _t >> _d;
        t.push_back(_t);
        d.push_back(_d);
    }
    int right = n, left = -1;
    while (left + 1 != right)
    {
        int med = (right + left) / 2;
        if (simulate(med, t, d, s) != -1)
        {
            right = med;
        }
        else
        {
            left = med;
        }
        cerr << left << "," << right << endl;
    }
    int start = right;

    right = n;
    left = -1;
    while (left + 1 != right)
    {
        int med = (right + left) / 2;
        if (simulate(med, t, d, s) != n)
        {
            left = med;
        }
        else
        {
            right = med;
        }
        cerr << left << "," << right << endl;
    }
    int end = left;
    cerr << start << endl;
    cerr << end << endl;

    cout << end - start + 1 << endl;
    return 0;
}


Measured memory_bytes: 1476
let () = 
  let s = read_line () in
  let head =
    Array.init (String.length s) (fun i -> i)
    |> Array.to_list
    |> List.filter (fun i -> s.[i] = 'A')
    |> List.hd in
  let tail = 
    Array.init (String.length s) (fun i -> i)
    |> Array.to_list
    |> List.filter (fun i -> s.[i] = 'Z')
    |> List.rev
    |> List.hd in
  Printf.printf "%d\n" @@ tail - head + 1


Measured memory_bytes: 14720
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    A=[int(input()) for i in range(5)]
    A.sort(key=lambda x:(x-1)%10)
    #print(A)
    ans=A[0]
    for n in range(1,5):
        a=A[n]
        if a%10==0:
            ans+=a
        else:ans+=(1+a//10)*10
    print(ans)
        
#%%submit!    
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define INF (1<<28)
double dp[1<<8][30];
int t[8];
int e[30][30];
int n,m,p,a,b;

double dfs(int bit,int pos){
	if(pos == b) return 0;
	if( dp[bit][pos] != -1 ) return dp[bit][pos];
	double ans = INF;
	for(int i = 0 ; i < m ; i++){
		for(int j = 0 ; j < n ; j++){
			if(bit>>j&1){
				ans = min(dfs(bit-(1<<j),i) + 1.0*e[pos][i]/t[j],ans);
			}
		}
	}
	return dp[bit][pos] = ans;
}
int main(){
	while(cin >> n >> m >> p >> a >> b && n){
		a--,b--;
		for(int i = 0 ; i < n ; i++)
			cin >> t[i];
		for(int i = 0 ; i < 30 ; i++)
			for(int j = 0 ; j < 30 ; j++)
				e[i][j] = INF;
		for(int i = 0 ; i < (1<<8) ; i++)
			for(int j = 0 ; j < 30 ; j++)
				dp[i][j] = -1;
		
		for(int i = 0 ; i < p ; i++){
			int x,y,c;
			cin >> x >> y >> c;
			x--,y--;
			e[x][y] = e[y][x] = c;
		}
		double res = dfs((1<<n)-1,a);
		if( res >= 1000000){	
			cout << "Impossible" << endl;
		}else{
			printf("%.10lf\n",dfs((1<<n)-1,a));
		}
	}
}

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

void trace(int A[], int N){
    int i;
    for(i=0; i<N; i++){
        if(i>0){
            cout<<" ";
        }
        cout<<A[i];
    }
    cout<<"\n";
}
int main(){
    int num, i, j, tmp, change_num=0;
    cin>>num;
    int arr[100];
    for(i=0; i<num; i++){
        cin>>arr[i];
    }
    for(i=0; i<num; i++){
        for(j=1; j<num-i; j++){
            if(arr[num-j] < arr[num-j-1]) {
                tmp = arr[num-j];
                arr[num-j] = arr[num-j-1];
                arr[num-j-1] = tmp;
                change_num++;
            }
        }
    }
    trace(arr, num);
    cout<<change_num<<endl;
    return 0;
}

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


int main(){
  int a,b;
  cin>>a>>b;
  ll A;
  if(a>b)rep(i,a)cout<<b;
  else rep(i,b)cout<<a;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal[] nums = ReadLine().Split(' ').Select(decimal.Parse).ToArray();
            decimal H = nums[0];
            decimal A = nums[1];
            WriteLine(Ceiling(H / A));
        }
    }
}

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

int main(){
    int N, M; string S;
    cin >> N >> M >> S;
    reverse(S.begin(), S.end());

    vector<int> ans;

    int cur = 0;
    while(cur != N){
        bool stop = true;
        for(int i=M; i>=1; i--){
            if(S[cur+i] == '0'){
                ans.push_back(i);
                cur += i;
                stop = false;
                break;
            }
        }

        if(stop) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1144
n,m,x,y=map(int,input().split())
xx=list(map(int,input().split()))
yy=list(map(int,input().split()))
xx.append(x)
yy.append(y)
xx.sort()
yy.sort()
if xx[-1]<yy[0]:print("No War")
else:print("War")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

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

    int n;
    cin, n;
    vector<int> a(n), b(n);
    REP(i, 0, n) {
        cin, a[i];
    }
    REP(i, 0, n) {
        cin, b[i];
    }
    int ans = 0;
    REP(bit, 0, 29) {
        vector<int> ca(n), cb(n);
        int x = 1 << bit;
        REP(i, 0, n) {
            ca[i] = a[i] % (2 * x);
            cb[i] = b[i] % (2 * x);
        }
        sort(ca.begin(), ca.end());
        sort(cb.begin(), cb.end());

        ll cnt = 0;
        REP(i, 0, n) {
            if (ca[i] < x) {
                auto it = lower_bound(cb.begin(), cb.end(), x - ca[i]);
                cnt += lower_bound(cb.begin(), cb.end(), 2 * x - ca[i]) - it;
            } else {
                auto it1 = lower_bound(cb.begin(), cb.end(), 2 * x - ca[i]);
                auto it2 = lower_bound(cb.begin(), cb.end(), 3 * x - ca[i]);
                cnt += (cb.end() - it2) + (it1 - cb.begin());
            }
        }

        cnt %= 2;
        ans += cnt << bit;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3456
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int p,w,g,y;

int main(){

    int n;
    char a[10];
    cin>>n;
    REP(i,n){
        cin>>a;
        if(a[0]=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }

    }
    cout<<"Three"<<endl;
    

    return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B;
    cin >> A >> B;
    if (A == 1 || B == 1)
    {
        if (A == B)
        {
            cout << "Draw" << endl;
        }
        else if (A == 1)
        {
            cout << "Alice" << endl;
        }
        else
        {
            cout << "Bob" << endl;
        }
    }
    else
    {
        if (A == B)
        {
            cout << "Draw" << endl;
        }
        else if (A > B)
        {
            cout << "Alice" << endl;
        }
        else
        {
            cout << "Bob" << endl;
        }
    }
}

Measured memory_bytes: 3556
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int n;
	std::cin >> n;
	int nn = sqrt(n);
	std::cout <<nn*nn << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char sa[110],sb[110],max[110],min[110];
	int n,flag = 0,i;
	scanf("%s",sa);
	scanf("%s",sb);
	if(strlen(sa) > strlen(sb))
		printf("GREATER\n");
	else if(strlen(sa) < strlen(sb))
		printf("LESS\n");
	else
	{
		for(i = 0;sa[i] != '\0';i++)
		{
			if(sa[i] > sb[i])
			{
				printf("GREATER\n");
				flag = 1;
				break;
			}
			else if(sa[i] < sb[i])
			{
				printf("LESS\n");
				flag = 1;
				break;
			}
		}
		if(flag == 0)
			printf("EQUAL\n");
	}
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int n;
int dp[100005][4];
vector<vector<int>> A;
int minicost(int v, int pre)
{
    if (v >= n)
        return 0;
    if (dp[v][pre] != -1)
        return dp[v][pre];
    int maxi = 0;
    if (pre != 0)
    {
        maxi = max(maxi, A[v][0] + minicost(v + 1, 0));
    }
    if (pre != 1)
    {
        maxi = max(maxi, A[v][1] + minicost(v + 1, 1));
    }
    if (pre != 2)
    {
        maxi = max(maxi, A[v][2] + minicost(v + 1, 2));
    }
    return dp[v][pre]=maxi;
}
int main()
{
    cin >> n;
    A.resize(n);
    memset(dp, -1, sizeof(dp));
    rep(i, 0, n)
    {
        A[i].resize(3);
        cin >> A[i][0] >> A[i][1] >> A[i][2];
    }
    cout << minicost(0, 3);
}

Measured memory_bytes: 13568
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] - c[i] > 0) {
                ans += v[i] - c[i];
            }
        }
        
        System.out.println(ans);
    }
}


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

int solve(int n, int s, int l) {
	if (n == 0) {
		if (s == 0) return 1;
		else return 0;
	}
	int res = 0;
	for (int i = l + 1; i < 10; i++) {
		res += solve(n - 1, s - i, i);
	}
	return res;
}

int main() {
	int n, s;
	while (cin >> n >> s) {
		if (n == 0 && s == 0) break;
		cout << solve(n, s, -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
    vector<pair<int , int> >e;
int r , c;
char g[60][60];

int dg;
int dx[] = { 1,0,1,1,0,-1,-1,-1 };
int dy[] = { 1,1,0,-1,-1,0,-1 , 1};
bool ok(int x,int y)
{
    return x>=0 && x<r && y>=0 && y<c;
}
void f( int p , int q ){


    for( int i=0;i<8;i++){

        int x = dx[i] + p;
        int y = dy[i] + q;

        if(ok(x, y) && g[x][y]=='#'){
                dg+=1;


        }
    }
}

void MAIN(){

    scanf("%d%d",&r,&c);
    vector<pair<int , int > >v;
    for(int i=0;i<r;i++){
        scanf("%s", g + i);
        for(int j=0;j<c;j++){
            if(g[i][j]=='.')v.push_back( make_pair( i , j));
        }
    }

    for(int i=0;i<v.size();i++){
            dg = 0;
        f(v[i].first , v[i].second);

        g[ v[i].first ][ v[i].second ] = (char) ( '0' + dg);
    }

     for(int i=0;i<r;i++)
    {
        for(int j = 0;j<c;j++){
            printf("%c",g[i][j]);
        }
        puts("");
    }

}

int main()
{
    MAIN();
}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc, PrintWriter out) {
        long ai = sc.nextInt();
        long ao = sc.nextInt();
        long at = sc.nextInt();
        long aj = sc.nextInt();
        long al = sc.nextInt();
        long as = sc.nextInt();
        long az = sc.nextInt();
 
        long size = 0;
 
        size = (ai / 2 + aj / 2 + al / 2) * 2 + ao;
        if (ai > 0 && aj > 0 && al > 0) {
            size = Math.max(size, 3 + ((ai - 1) / 2 + (aj - 1) / 2 + (al - 1) / 2) * 2 + ao);
        }
 
        out.println(size);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 25044
N, X, Y = map(int, input().split())

l = [0] * (N)

graph = [[0] * N] * N

for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i < X:
            distAX = X - i
        else:
            distAX = i - X            
        if j < Y:
            distBY = Y - j
        else:
            distBY = j -Y
        distAB = j - i
        if distAX + distBY + 1 < distAB:
            distAB = distAX + distBY + 1

        l[distAB] = l[distAB] + 1

for i in range(1, N):
    print(l[i])

Measured memory_bytes: 3444
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

#define inf 10000000000 + 5

string s;
int n;
int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; 
int answer = 0;
int answer1 = 0;
int answer2 = 0;

int main(){
  cin >> s;
  n = s.length();
  for(int i = 0; i < n; ++i){
    
    if(i % 2 == 0){
      cnt4++;
      if(s[i] == '0'){
        cnt1++;
      }
    }
    if(i % 2 == 1){
      cnt3++;
      if(s[i] == '0'){
        cnt2++;
      }
    }
  }
  //cout << cnt2 << endl;
  //cout << cnt4 - cnt1 << endl;
  /*
  if(min(cnt1, cnt4 - cnt1)  < min(cnt2, cnt3 - cnt2)){
    if(cnt1 < cnt4 - cnt1){
      answer += cnt1 + (cnt3 - cnt2);
      //cout << "a" << endl;
    }else{
      answer += (cnt4 - cnt1) + cnt2;
      //cout << "b" << endl;
    }
  }else{
    if(cnt2 < cnt3 - cnt2){
      answer += cnt2 + (cnt4 - cnt1);
      //cout << "c" << endl;
      //cout << cnt2 << endl;
    }else{
      answer += (cnt3 - cnt2) + cnt1;
      //cout << "d" << endl;
    }
  }
  */
  answer1 += cnt1 + (cnt3 - cnt2);
  answer2 += (cnt4 - cnt1) + cnt2;

  answer = min(answer1, answer2);
  cout << answer << endl;
  //cout << answer1 << endl;
  //cout << answer2 << endl;
}

Measured memory_bytes: 512
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

const int N = 1e6+5;

pls give {
    AC;
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << ' ' << b << nl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)

void quick(int array[], int left, int right){
  int pl = left, pr = right, x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n, x;  scanf("%d %d", &n, &x);
  int a[102];
  for(int i=0; i<n; i++)  scanf("%d", &a[i]);
  quick(a, 0, n-1);
  int count = 0;
  while(x-a[count] >= 0 && count < n){
    x -= a[count++];
  }
  if(count == n && x != 0)
    count--;
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
($A,$B,$C,$X,$Y)=glob<>;
$t=$X<$Y?$X:$Y;
$X-=$t;
$Y-=$t;
$C*=2;
$C-=$-=$C-$A-$B;
print$t*$C+$X*($A<$C?$A:$C)+$Y*($B<$C?$B:$C)


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

class Dictionary {
  public:
    Dictionary(unsigned int capacity) : capacity(capacity), table(capacity, NULL) {
    }

    ~Dictionary() {
      for (auto n : table) {
        if (!n) {
          continue;
        }

        Node *p = n;
        while (p->next) {
          Node *q = p->next;
          delete p;
          p = q;
        }
      }
    }

    void insert(string s) {
      if (find(s)) {
        return;
      }

      int h = hash(s);
      Node *n = table[h];
      if (!n) {
        table[h] = new Node(s);
      } else {
        while (n->next) {
          n = n->next;
        }
        n->next = new Node(s);
      }
    }

    bool find(string s) {
      int h = hash(s);
      Node *n = table[h];
      while (n) {
        if (s == n->val) {
          return true;
        }
        n = n->next;
      }
      return false;
    }

  private:
    struct Node {
      string val;
      Node *next;

      Node(string val) : val(val), next(NULL) {}
    };

    unsigned int capacity;
    vector<Node *> table;

    unsigned int hash(string s) {
      int h = 0;
      for (unsigned int i = 0; i < s.length(); ++i) {
        h *= 31;
        h += s[i];
        h %= capacity;
      }
      return h;
    }
};

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

  int n;
  cin >> n;

  Dictionary d(1000000);
  string c, s;
  for (int i = 0; i < n; ++i) {
    cin >> c >> s;
    if (c[0] == 'i') {
      d.insert(s);
    } else {
      if (d.find(s)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 32988
def MI(): return map(int, input().split())
N,W=MI()
w=[]
v=[]
for i in range(N):
  a,b=MI()
  w.append(a)
  v.append(b)
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j<w[i]:
      dp[i+1][j]=dp[i][j]
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])      
ans=dp[-1][-1]
print(ans)

Measured memory_bytes: 147280
/*input
4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328
*/

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

int n, m, q;
// vector<int> a(n), b(n), c(n), d(n);
int a[50], b[50], c[50], d[50];

int dfs(int i, vector<int> &p) {
  int res = 0;
  if (i == n-1) {
    rep(j, q) {
      if (p[b[j]]-p[a[j]] == c[j]) res += d[j];
    }
    return res;
  }
  for (p[i+1] = p[i]; p[i+1] <= m; ++p[i+1]) {
    res = max(res, dfs(i+1, p));
  }
  return res;
}

int main() {
  cin >> n >> m >> q;
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  rep(i, q) --a[i], --b[i];

  vector<int> p(n);
  p[0] = 1;
  cout << dfs(0, p) << endl;
  return 0;
}

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

using namespace std;

const int inf = (int) 1e9;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, t;
  scanf("%d %d", &n, &t);
  vector<pair<int, int>> a(n);
  int ans = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &a[i].first, &a[i].second);
    if (a[i].second <= t) {
      ans = ans == -1 ? a[i].first : min(ans, a[i].first);
    }
  }
  if (ans == -1) {
    puts("TLE");
  } else {
    printf("%d\n", ans);  
  }
  return 0;
}


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

using namespace std;

const int MAX = 10;
typedef long long ll;

ll N;
int K;

bool D[10];

bool f(long long n) {

    for (int i = 0; i < MAX; ++i) {
        if (n > 0) {
            if (!D[n % 10]) {
                return false;
            }
            n = n / 10;
        } else {
            break;
        }
    }

    return true;
}

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

    memset(D, true, 10);

    cin >> N >> K;

    int d;
    for (int i = 0; i < K; ++i) {
        cin >> d;
        D[d] = false;
    }

    while (true) {
        if (f(N)) {
            cout << N << endl;
            return 0;
        } else {
            N++;
        }
    }

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int length = s.length();
    int num = 0;

    for (int i = 0; i < length; i++) {
        if ( s[i] == 'o') {
            num++;
        }
    }

    if ( (15-length) >= (8-num) ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double[]arr=new double[n];
		double[][]dp=new double[n+1][n+1];
		dp[0][0]=1;
		for(int i=0;i<n;i++){
		    arr[i]=sc.nextDouble();
		}
		for(int j=1;j<=n;j++){
		    dp[j][0]=dp[j-1][0]*(1-arr[j-1]);
		}
		for(int i=1;i<=n;i++){
		    for(int j=1;j<=n;j++)
		        dp[i][j]=arr[i-1]*dp[i-1][j-1]+(1-arr[i-1])*dp[i-1][j];
		}
		double sum=0.0;
		for(int i=n;i>n/2;i--)
		    sum+=dp[n][i];
		System.out.println(sum);
	}
}


Measured memory_bytes: 145376
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
uf=UnionFind(h*w)
dyx=[(1,0),(-1,0),(0,1),(0,-1)]
for i in range(h):
    for j in range(w):
        if g[i][j]==".":
            continue
        p=i*w+j
        for dy,dx in dyx:
            y=i+dy
            x=j+dx
            if 0<=y<h and 0<=x<w:
                if g[y][x]==".":
                    np=y*w+x
                    uf.Unite(p,np)

rt=[0]*(h*w)
for i in range(h*w):
    rt[i]=uf.Find_Root(i)

m=min(rt)
rt=list(map(lambda x:x-m, rt))
m=max(rt)
a=[[0,0] for _ in range(m+1)]
for i in range(h*w):
    y=i//w
    x=i%w
    if g[y][x]=="#":
        a[rt[i]][0]+=1
    else:
        a[rt[i]][1]+=1
ans=0
for i,j in a:
    ans+=i*j

print(ans)


Measured memory_bytes: 88928
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;

int n, cnt[1000000];
ll ret;

int main()
{
    onlycc;
    cin >> n;
    for(int i = 1; i < n; i++)
        for(int j = i; j < n; j += i)
            cnt[j]++;

    for(int i = 1; i < n; i++)
        ret += cnt[i];

    cout << ret;

    return 0;
}


Measured memory_bytes: 7484
#include <bits/stdc++.h>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;
void solve()
{
   int n,k;
   cin>>n>>k;
   int a[n+1];
//    int temp=1;
   frf(i,1,n)
   {
       cin>>a[i];
   }
   int s=1,e=k+1;
    while(e<=n)
    {
        if(a[e]>a[s])
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
        s++;
        e++;
    }

    
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {

        solve();
    }
}

Measured memory_bytes: 5196
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
pm = [-1,1]

n,m = ma()
xyz = []
for i in range(n):
    xyz.append(lma())

def f(p0,p1,p2):
    xyz.sort(key=lambda x:p0*x[0]+p1*x[1]+p2*x[2],reverse=True)
    ret=0
    for i in range(m):
        t=xyz[i]
        ret+=p0*t[0]+p1*t[1]+p2*t[2]
    return ret
tmp=-10**15
for i in range(2**3):
    p=[1,1,1]
    for j in range(3):
        p[j]= pm[(i >> j) &1]
    #print(p)
    #print(f(*p))
    tmp=max(tmp,f(*p))
print(tmp)


Measured memory_bytes: 9576
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    S = input()
    T = input()

    l = len(T)
    n = len(S) - l
    ans = float("inf")
    for i in range(n + 1):
        d = 0
        s = S[i : i + l]
        for s_, t_ in zip(s, T):
            if s_ != t_:
                d += 1
        ans = min(ans, d)
    print(ans)


main()


Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    vector<int> A(4);
    for (int i = 0; i < 4; i++) {
        A[i] = (int)(S[i] - '0');
    }

    vector<int> op = {1, -1};
    vector<char> opc = {'+', '-'};
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                if (A[0] + A[1] * op[i] + A[2] * op[j] + A[3] * op[k] == 7) {
                    cout << A[0] << opc[i] << A[1] << opc[j] << A[2] << opc[k] << A[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll k;
    ll a,b;
    cin >> k >> a >> b;
    for (int z=1;z<=10000;z++){
        if (a<= k*z && k*z <= b){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
} 

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

struct Point {
  int x,y;
  Point(double x, double y) : x(x), y(y){}
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W >> N;
  char c[H][W];
  deque<Point> q;
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      c[i][j] = s[j];
      if (c[i][j] == 'S') q.push_back(Point(j, i));
    }
  }
  int sum = 0;
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  for (int i = 1; i <= N; i++) {
    int vis[H][W]{};
    int d[H][W]{};
    Point p = q.front();
    vis[p.y][p.x] = 1;
    while (true) {
      Point t = q.front();
      q.pop_front();
      if (c[t.y][t.x] == (char)(i + '0')) {
        q.clear();
        q.push_back(t);
        sum += d[t.y][t.x];
        break;
      }
      for (int j = 0; j < 4; j++) {
          int nx = t.x + dx[j];
					int ny = t.y + dy[j];
          if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
            if (vis[ny][nx] == 0 && c[ny][nx] != 'X') {
              vis[ny][nx] = 1;
              d[ny][nx] = d[t.y][t.x] + 1;
              q.push_back(Point(nx, ny));
            }
          }
      }
    }
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 11924
//organize , stay in moment and work -- Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define f(i,x,n) for(int i=x;i<n;++i)
#define sz(s) s.size()
#define pb push_back
int mod;
int nc2(int n){
    if(n<2)
        return 0;
    int pp=n-1;if(pp%2==0) pp/=2;
    else n/=2;
    n*=pp;
    return n;
}
int ans,cp;
vector<int> v1,v2;
int bs(int look){
    int l=0,hi=sz(v2)-1,poss=-1;
    if(look < v2[0])
        return hi+1;
    if(look > v2[hi])
        return 0;
    while(l<=hi){
        int mid=l+(hi-l)/2;
        if(v2[mid]>look){
            poss=mid;
            hi=mid-1;
        }else l=mid+1;
    }
    return sz(v2)-poss;
}
bool cpp(int a[],int n){
    int mn=a[0];
    f(i,1,n){
        if(a[i]<mn)
            return false;
        mn=a[i];
    }
    return true;
}
void solve(){
   int a[3][3];
   bool m[3][3];
   bool ap=0;
   f(i,0,3)
   f(j,0,3){
   cin>>a[i][j];m[i][j]=0;}
   int n; cin>>n;
   while(n--){
   		int t; cin>>t;
   		f(i,0,3)
   		f(j,0,3)
   		if(a[i][j]==t)
   		m[i][j]=1;
   }
   //row
   f(i,0,3){
   	 int cp=0;
   	 f(j,0,3)
		cp+=m[i][j];
		if(cp==3) //found
		ap=1;
   }
   f(i,0,3){
   	 int cp=0;
   	 f(j,0,3)
		cp+=m[j][i];
		if(cp==3) //found
		ap=1;
   }
   int cp=0;
   f(i,0,3)
   cp+=m[i][i];
   if(cp==3)
   ap=1;
   cp=0;
   f(i,0,3)
   cp+=m[i][2-i];
   if(cp==3)
   ap=1;
   if(ap)
   cout<<"Yes";
   else
   cout<<"No";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mod=1e9+7;
    int t;t=1;
   // cin>>t;
    //cout<<(t+1)/2;
    //return 0;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll A,B,K;
    cin >> A >> B >> K;
    if(A>=K){
        A = A-K;

    }else{
        B = B-K+A;
        A = 0;
    }
    if(B < 0)B = 0;
    cout <<A<<" "<<B<< "\n";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	S := io.Next()

	var sIndex, eIndex int
	var tmpS, tmpE int

	for i := 0; i < len(S); i++ {
		s := S[i]
		if s == 'A' || s == 'C' || s == 'G' || s == 'T' {
			tmpS = i
			j := i + 1
			for ; j < len(S); j++ {
				tmp := S[j]
				if !(tmp == 'A' || tmp == 'C' || tmp == 'G' || tmp == 'T') {
					break
				}
			}
			i = j
			tmpE = i

			if (eIndex - sIndex) < (tmpE - tmpS) {
				eIndex = tmpE
				sIndex = tmpS
			}
		}
	}
	io.PrintLn(len(S[sIndex:eIndex]))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
    if(n<5){
        fill(ret, ret+n*2-1, 0);
        for(size_t i=0; i<n; ++i)
        for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
    }else
    if(n&1){
        go_karatsuba(a,b,ret,n-1);
        ret[n*2-3] = 0;
        for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
        ret[n*2-2] = a[n-1]*b[n-1];
    }else{
        auto ar = a, al = a+n/2, 
		     br = b, bl = b+n/2,
        	 asum = ret+n*5, bsum = asum+n/2,
        	 x1 = ret, x2 = x1+n, x3 = x2+n;
        for(size_t i=0; i<n/2; ++i){
            asum[i] = al[i] + ar[i];
            bsum[i] = bl[i] + br[i];
        }
        go_karatsuba(ar, br, x1, n/2);
        go_karatsuba(al, bl, x2, n/2);
        go_karatsuba(asum, bsum, x3, n/2);
        for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
        for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	double a, b; cin >> a >> b;
	// cout << a*b/(a+b) << endl;
	printf("%.9f\n", a*b/(a+b));
	return 0;
}

Measured memory_bytes: 256
n=int(input())
def two(x):
	k=bin(x)
	return "0"*(12-len(k))+k[2:]
ans=-10**15
f=[]
p=[]
for _ in range(n):
	x=list(map(int,input().split()))
	f.append(x)
for _ in range(n):
	x=list(map(int,input().split()))
	p.append(x)
for i in range(1,2**10):
	pro=0
	for j in range(n):
		cnt=0
		for k in range(10):
			if two(i)[k]=="1" and f[j][k]==1:
				cnt+=1
		pro+=p[j][cnt]
	ans=max(ans,pro)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int a[200001],c[200002],n,k;
int main(){
	cin>>n>>k;
	register int i,j,t,s,f;
	for(i=1;i<=n;++i) {
		cin>>a[i];
	}
	for(j=1;j<=k;++j) {
		memset(c,0,sizeof(c));
		for (i=1;i<=n;++i) {
			++c[max(1,i-a[i])];
			--c[min(n+1,i+a[i]+1)];
		}
		s=0,f=1;
		for (i=1;i<=n;++i) {
			a[i]=s+=c[i];
			if (a[i]<n) f=0;
		}
		if(f)break;
	}
	for (i=1;i<=n;++i) {
		cout<<a[i]<<" ";
	}
}

Measured memory_bytes: 5084
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 205
#define MAXR 1005
#define MAXM 10005
int N,M,R;
int S[MAXN][MAXN],L[MAXN][MAXN];
int task[MAXR];
int dp[MAXR][MAXN];
int main()
{
	while(1)
	{
		scanf("%d%d",&N,&M);
		if(!N&&!M)break;
		for(int i=1;i<=N;i++)
			for(int j=1;j<=N;j++)
				S[i][j]=L[i][j]=1000000;
		for(int i=1;i<=N;i++)
			S[i][i]=L[i][i]=0;
		for(int i=1;i<=M;i++)
		{
			int a,b,t;char s[3];
			scanf("%d%d%d%s",&a,&b,&t,s);
			if(s[0]=='S')
			{
				S[a][b]=min(S[a][b],t);
				S[b][a]=min(S[b][a],t);
			}
			else
			{
				L[a][b]=min(L[a][b],t);
				L[b][a]=min(L[b][a],t);
			}
		}
		for(int k=1;k<=N;k++)
			for(int i=1;i<=N;i++)
				for(int j=1;j<=N;j++)
				{
					S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
					L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
				}
		scanf("%d",&R);
		for(int i=1;i<=R;i++)
			scanf("%d",task+i);
		for(int i=1;i<=R;i++)
			for(int j=1;j<=N;j++)
				dp[i][j]=1000000;
		dp[1][task[1]]=0;
		for(int i=2;i<=R;i++)//the Captain position
			for(int j=1;j<=N;j++)//the Ship position
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j]+L[task[i-1]][task[i]]);
				for(int k=1;k<=N;k++)
					dp[i][k]=min(dp[i][k],dp[i-1][j]+L[task[i-1]][j]+S[j][k]+L[k][task[i]]);
			}
		int ans=0x7FFFFFFF;
		for(int i=1;i<=N;i++)
			ans=min(ans,dp[R][i]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3800
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n, m;
	cin >> n >> m;
	vector<vector<int>> edge(n+1);
	vector<int> cnt(n+1), ans(n+1);
	for(int i = 0, a, b; i < m; i++)
		cin >> a >> b, edge[a].push_back(b), cnt[b]++;
	queue<int> bfs;
	for(int i = 1; i <= n; i++)
		if(!cnt[i])
			bfs.push(i);
	while(!bfs.empty()) {
		int w = bfs.front();
		bfs.pop();
		for(auto &a : edge[w]) {
			ans[a] = max(ans[a], ans[w]+1);
			cnt[a]--;
			if(!cnt[a])
				bfs.push(a);
		}
	}
	cout << *max_element(ans.begin(), ans.end()) << '\n';

	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int A[M], B[M], H[N];

    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
  
    bool flag[N];
    fill(flag, flag + N, true);//flagの中身をtrueで埋める
    for (int i = 0; i < M; i++) {
        if (H[A[i]] == H[B[i]]) {
            flag[A[i]] = false;
            flag[B[i]] = false;
        } else if (H[A[i]] < H[B[i]]) {
            flag[A[i]] = false;
        } else {
            flag[B[i]] = false;
        }
    }
    int cnt = 0;
    for (bool b : flag) {
        if (b) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
    
    long long  mi = 1LL<<60;
    int mii = -1;
    for (int i = 0; i < n; ++i) {
        if (mi > abs(sum - a[i] * n)) mi = abs(sum - a[i] * n), mii = i;
    }
    cout << mii << endl;
    
}

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

int main(){
	long long int x;
	cin>>x;
	long long int a = 100;
	int cnt=0;
	while(a<x){
		cnt++;
		a=a+a/100;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3608