akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,n,m,k,z,y;
    cin>>n>>m>>k;
    for(i=0;i<=n;++i)
    {
        z=i*m;
        for(j=0;j<=m;++j)
        {
            y=z+n*j;
            y-=2*i*j;
            if(y==k)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
}


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

const int INF = 1 << 28;
int n, m, s, g1, g2;
int dist[110][110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n >> m >> s >> g1 >> g2, n) {
    s--, g1--, g2--;
    fill_n((int*)dist, 110 * 110, INF);
    for (int i = 0; i < n; i++) {
      dist[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
      int b1, b2, c;
      cin >> b1 >> b2 >> c;
      b1--, b2--;
      dist[b1][b2] = c;
    }
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
      ans = min(ans, dist[s][i] + dist[i][g1] + dist[i][g2]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3048
void main() {
	auto n = ri;
	auto a = readAs!(int[]);
	ulong res = ulong.max;

	// 0: (odd, even) -> (+, -)
	// 1: (odd, even) -> (-, +)
	foreach(k; 0..2) {
		ulong cnt;
		long tmp;
		foreach(i, v; a) {
			tmp += v;
			if((i+1 + k) % 2 == 0) {
				if(tmp <= 0) {
					cnt += -tmp+1;
					tmp = 1;
				}
			} else {
				if(tmp >= 0) {
					cnt += tmp+1;
					tmp = -1;
				}
			}
		}
		res = min(res, cnt);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 << "\n";
    } else {
        cout << (n / 2) + 1 << "\n";
    }


}




















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

int main(){
  int N;
  string S;
  cin >> N >> S;
  deque<char> dq;
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='('){
      count++;
      dq.push_back('(');
    }else if(S.at(i)==')'){
      dq.push_back(')');
      if(count==0){
        dq.push_front('(');
      }else{
        count--;
      }
    }
  }
  while(count>0){
    dq.push_back(')');
    count--;
  }
  for(int i=0;i<dq.size();i++){
    cout << dq.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

def combo(n,k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD

    d = 1
    for i in range(1, k+1):
        d *= i
        d %= MOD

    return (c * pow(d, MOD-2, MOD)) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  int ans = a * x + b * y;
  int a1 = c * y + a * max(0, x - y);
  int a2 = c * x + b * max(0, y - x);
  ans = min({ans, a1, a2});
  cout << ans << endl;
}

Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    read = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    read = raw_input
readint = lambda: int(rr())
readlist = lambda: map(int, read().split())

####

print 15 - sum(readlist())


Measured memory_bytes: 64268
n,m=map(int,input().split())
xy=[]
data=[[] for i in range(n+1)]
for _ in range(m):
    x,y,z=map(int,input().split())
    xy.append([x,y])
    data[x].append(y)
    data[y].append(x)
flag=[0]*(n+1)
count=0
for i in range(1,n+1):
    if flag[i]==0:
        count+=1
        flag[i]=1
        que=[i]
        while que:
            h=que.pop()
            for u in data[h]:
                if flag[u]==0:
                    flag[u]=1
                    que.append(u)
print(count)

Measured memory_bytes: 84512
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	string s;
	cin>>s;
	bool tag1=0,tag2=0;
	for(int i=0;i<s.size();++i){
		if(s[i]=='C') tag1=1;
		if(s[i]=='F'&&tag1) tag2=1;
	}
	(tag1&&tag2)?puts("Yes"):puts("No");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod = 998244353;
const int N = 1200000;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int n = s.length();
    if (n % 2){
        cout << "No";
        return 0;
    }
    for (int i = 0; i < n; i += 2) if (s[i] != 'h'){
        cout << "No";
        return 0;
    }
    for (int i = 1; i < n; i += 2) if (s[i] != 'i'){
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


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

using namespace std;

int main()
{
	string s;
	int a = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if(s[i] == '1') a++;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#define ESP (1e-13)
#define INF 2000000000
/*
#define FOR(i,m,n)    for(int i=m;i<n;i++)
#define FORB(i,m,n)    for(int i=m;i>=n;i--)
#define INF 999999999
*/

#define ll long long
/*
#define PUSH(a) push_back(a)
#define POP() pop_back()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(v.begin(),v.end())
*/

using namespace std;

int dy[] = { 0,0,1,-1 };
int dx[] = { 1,-1,0,0 };
/*
typedef struct {
	long int A;
	long int B;
}Item ;

Item item[100000];
int N, W,K;
int C[100001][32], G[100001][32];

void compute(int &maxValue, vector<int> &selection) {
	for (int w = 0;w <= W;w++) {
		C[0][w] = 0;
		G[0][w] = 1;
	}
	for (int i = 1;i <= N;i++) C[i][0] = 0;
	for (int i = 1;i <= N;i++) {
		for (int w = 1;w <= W;w++) {
			C[i][w] = C[i - 1][w];
			G[i][w] = 0;
			if (item[i].A > w) continue;
			if (item[i].B + C[i - 1][w - item[i].A] > C[i - 1][w]) {
				C[i][w] = item[i].B + C[i - 1][w - item[i].A];
				G[i][w] = 1;
			}
		}
	}
	maxValue = C[N][W];
	selection.clear();
	for (int i = N, w = W;i >= 1;i--) {
		if (G[i][w] == 1) {
			selection.push_back(i);
			w -= item[i].A;
		}
   }
	reverse(selection.begin(), selection.end());
}

void input() {
	cin >> N >> W;
	for (int i = 0;i < N;i++) {
		cin >>item[i].A; cin >> item[i].B;
	}

}*/
/*

int Node[51] = { 0 };
int edge;
for (int i = 0;i < M;i++) {
	cin >> edge;
	Node[edge] ++;
	cin >> edge;
	Node[edge]++;
}
int br = 0;
for (int i = 1;i <= N;i++) {
	if (Node[i] == 1)
	{
		br++;
		Node[i]--;
	}
}
for (int i = 1;i <= N;i++) {

}
*/


int E[51][51] = { 0 };


int main() {
	int N, M;
	cin >> N; cin >> M;
	int n,m;
	for (int i = 0;i < M;i++) {
		cin >> n>>m;
		E[n][m]=1;
		E[m][n]=1;
	}
	
	int br = 0,flag=0;
	int keep = 0;
	while (1) {
		keep = 0;
		for (int i = 1;i <= N;i++) {
			flag = 0;
			for (int j = 1;j <= N;j++) {
				if (E[i][j] == 1) {
					flag++;
				}
			}
			if (flag == 1) {
				for (int j = 1;j <= N;j++) {
					E[i][j] = 0;
					E[j][i] = 0;
				}
				keep = 1;
				br++;
			}
		}
		if (keep == 0) break;
	}

	cout << br << endl;
}










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

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << (b - a) * (b - a + 1) / 2 - b << '\n';
  return 0;
}

Measured memory_bytes: 3592
//use proconio::{input, fastout};
use proconio::input;
use regex::Regex;

//#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }
    let r = Regex::new(&"^[a-zA-Z0-9]+$").unwrap();
    if  r.is_match(&s)
     && r.is_match(&t)
     && s.len() + 1 == t.len()
     && t.starts_with(&s) {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int n, T, v[100100], rap_max, ans;

int main()
{
    cin >> n >> T;
    cin >> v[1];
    int prev_max=v[1];
    for(int i = 2; i<=n ;++i)
    {
        cin >> v[i];
        if(v[i]> prev_max)
        {
            if(v[i]-prev_max > rap_max)
            {
                rap_max=v[i]-prev_max;
                ans = 1;
            }
            else if(v[i]-prev_max == rap_max)
            {
                ++ans;
            }
        }
        prev_max=min(prev_max, v[i]);

    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

man = 0

for i in range(N):
    # if i == 0:
    #     continue
    # man += B[A[i]-1]
    # if i-1 >= 0:
    #     if A[i-1]+1 == A[i]:
    #         man += C[i-1-1]

    man += B[A[i]-1]
    if i-1 >= 0 and A[i-1]+1 == A[i]:
        man += C[A[i-1]-1]

#     print("i {} man {}".format(i,man))
# 
# print("result {}".format(man))

print(man)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>

using namespace std;

int main(){
	int size, num;
	vector<int> List;
	
	List.clear();
	
	cin >> size;
	
	for(int i = 0; i < size; i++){
		cin >> num;
		List.push_back(num);
	}
	
	for(int i = size - 1; i >= 0; i--){
		if(i != size - 1)	cout << " ";
		cout << List[i];
	}
	cout << endl;
}

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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  if( 500*a >= b ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc173/abc173_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  int cnt = (N / 1000);
  ll ans = (cnt + 1) * 1000 - N;
  if (ans == 1000) ans = 0;

  cout << ans << endl;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys
import copy
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    H,W = MAP()
    S = [input() for _ in range(H)]
    answerLabel = [[S[i][j]=="#" for j in range(W)] for i in range(H)]

    def dfs(cur,isVisited):
        i,j = cur
        isVisited[i][j] = True
        v = copy.deepcopy(isVisited)
        v2 = copy.deepcopy(isVisited)
        
        if i == H-1 and j == W-1:
            if isVisited == answerLabel:
                print("Possible")
                sys.exit()
            return
        if i+1<H:
            dfs((i+1,j),v)
        
        if j+1<W:
            dfs((i,j+1),v2)
    
    dfs((0,0),[[False]*W for _ in range(H)])

    print("Impossible")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int[] d=new int[n];
        for(int i=0;i<n;i++){
            d[i]=fsc.nextInt();
        }
        fsc.close();
        long res=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                res+=d[i]*d[j];
            }
        }
        System.out.println(res);
        
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int N,D,X,A;
//int A[N+10]={};
int counter=0;
int main(){
  cin >> N >> D >> X;
  for(int i=0;i<N;i++){
    cin >> A;
    int c=0;
    while(c*A+1<=D){
      counter++;
      c++;
    }
  }
  cout << X+counter << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int w,a,b;
	cin >> w >> a >> b;
	   if(b-a-w>0){
       cout << b-a-w << endl;
   }
   else if(a-b-w>0){
       cout << a-b-w << endl;
   }
   else{
       cout << 0 << endl;
   }
   
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int numB = 0;
	long long res = 0;
	for (char c : S) {
		if (c == 'B') {
			numB ++;
		} else if (c == 'W'){
			res += numB;
		} else assert(false);
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 720
c = []
while True:
    s = input()
    if s=="=": break
    c.append(s)
ans = int(c[0])
for i in range(2, len(c), 2):
    o, v = c[i-1], int(c[i])
    if o=="+":
        ans += v
    elif o=="-":
        ans -= v
    elif o=="/":
        ans = ans // v
    else:
        ans *= v
print(ans)

Measured memory_bytes: 7668
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	map<ll, ll> A = prime_factor(a);
	map<ll, ll> B = prime_factor(b);
	int ans = 1;
	for(auto p : A){
		if(B[p.first] > 0) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout<< (abs(a[1]-a[0]) + abs(a[2] - a[1])) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  string s, ans;
  cin >> s;
  for (int i=0; i<s.size(); i++) {
    if (s[i]=='0') ans.push_back('0');
    else if (s[i]=='1') ans.push_back('1');
    else if (!ans.empty()) ans.erase(ans.end()-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	int n;
	cin>>n;
	map<string,int>cnt;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		cnt[s]++;
	}
	cout<<"AC x "<<cnt["AC"]<<'\n';
	cout<<"WA x "<<cnt["WA"]<<'\n';
	cout<<"TLE x "<<cnt["TLE"]<<'\n';
	cout<<"RE x "<<cnt["RE"]<<'\n';
	
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int ans=0;
int main() {
	int n,k,mi;
	cin>>n>>k;
	vector<int>vec(n);
	for(int i=0;i<n;i++){
		cin>>vec.at(i);
		mi=min(vec.at(i)-0,k-vec.at(i));
		ans+=mi*2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D) cout << "Left" << endl;
  else if(A + B == C + D) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


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

typedef long long ll;

typedef pair<ll,ll> P;
constexpr ll INF = INT_MAX;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<P> ls;
    for(int i=0;i<n;i++){
        int l, r;
        cin >> l >> r;
        ls.push_back(P(l,+1));
        ls.push_back(P(r+1,-1));
    }
    sort(ls.begin(), ls.end());
    ll cnt = 0, cmax = 0, lmin = INF, rmax = 0;
    for(int i=0;i<n*2;i++){
        cnt += ls[i].second;
        if(ls[i].second > 0){
            if(cnt > cmax){
                cmax = cnt;
                lmin = ls[i].first;
            }
            else if(cnt == cmax){
                lmin = min(lmin, ls[i].first);
            }
        }
        else{
            if(cnt+1 == cmax){
                rmax = max(rmax, ls[i].first-1);
            }
        }
    }
    if(cmax%2){
        cout << (cmax-1)*m + rmax << endl;
    }
    else{
        cout << (cmax-1)*m + (m-lmin) << endl;
    }
}


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


int main(){


    long long n, i;

    long long k = 0;

 
    cin >> n;


    for( i = n - 1 ; 0 < i ; i = i - 1 ){

         k += i;

         }


    cout << k << endl;
         

    return 0;


    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define F first
#define S second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;


void solve()
{
	long double l;
	cin>>l;
	long double x = l / 3.0;
	long double ans = x*x*x;
	cout<<setprecision(10);
	cout<<fixed<<ans<<endl;
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
mod = 2019
s = input().rstrip()
n = len(s)
mod_list = [0]
for i in range(n - 1, -1, -1):
    mod_list.append((mod_list[-1] + int(s[i]) * pow(10, n - 1 - i, mod)) % mod)
from collections import Counter
c = Counter(mod_list)
ans = 0
for i in c.keys():
    ans += c[i] * (c[i] - 1) // 2
print(ans)





Measured memory_bytes: 16716
#include <iostream>

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



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

int main() {
	ll N, A, M = 1;
	cin >> N;
	vector<ll> X(N);
	for (int i = 0;i < N;i++) {
		cin >> X[i];
		if (X[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0;i < N;i++) {
		A = X[i];
		if (LLONG_MAX / A < M) {
			cout << -1 << endl;
			return 0;
		}
		M *= A;
	}
	if (M > 1000000000000000000) 
		cout << -1 << endl;
	else 
		cout << M << endl;
}

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

int main() {
    int N,x;
    cin >> N >> x;
    vector<int> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int res = 0;
    for(int i=0; i<N; ++i) {
        if(a[i] > x) break;
        if(i != N-1) {
            ++res;
            x -= a[i];
        } else {
            if(x == a[i]) ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n & 1) n--;
    else n -= 2;
    for (; n >= 1; n -= 2) {
        int t = n / 2;
        if (s.substr(0, t) == s.substr(t, t)) break;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

typedef long long ll;

#define debug(x) cerr << #x << ": " << x << "\n";
#define rep(i,n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;

  bool ok = false;
  rep(i,26){
    if((s+char('a'+i)) == t) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}
      


Measured memory_bytes: 3624
N, M = map(int, input().split())

ans = 0

# 隣接リストの作成
vertex_list = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    vertex_list[a].append(b)
    vertex_list[b].append(a)

def dfs(v):
    global ans, used
    if len(used) == N:
        ans += 1
        return
    else:
        for next_v in vertex_list[v]:
            if next_v not in used:
                used.add(next_v)
                dfs(next_v)
                used.remove(next_v)
        return

used = set([1])
dfs(1)

print(ans)

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

using namespace std;

char in[12];
string s;
map<string, int>mp;

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n; long long res = 0;
	for(int i = 1; i <= n; i++) {
		cin >> in;
		sort(in, in + 10);
		s = string(in);
		res += mp[s];
		mp[s]++;
	} cout << res << endl;
	return 0;
}

Measured memory_bytes: 11264
n = int(input())
s = input()
res = [[None for j in range(10)] for i in range(n)]
res[-1][int(s[-1])] = n - 1
for i in range(n - 2, -1, -1):
    for j in range(10):
        res[i][j] = res[i + 1][j]
    res[i][int(s[i])] = i
ans = 0
for i in range(10):
    x = res[0][i]
    if x is None or x > n - 3:
        continue
    for j in range(10):
        y = res[x + 1][j]
        if y is None or y > n - 2:
            continue
        for k in range(10):
            z = res[y + 1][k]
            if z is not None:
                ans += 1
print(ans)


Measured memory_bytes: 10292
#include <bits/stdc++.h>
#define inf 100000000000000ll
using namespace std;

int read();

int n;
long long f[100005][3];
void chmax(long long &x, long long y) { x = x > y ? x : y; }

int main() {
    n = read();
    f[0][0] = 0, f[0][1] = f[0][2] = -inf;
    for (int i = 1, x; i <= n; ++i) {
        x = read();
        {
            f[i][0] = max(f[i - 1][0], f[i - 1][1]),
            f[i][1] = max(f[i - 1][1], f[i - 1][2]);
            f[i][2] = f[i - 1][2];
        }
        f[i][0] += x, f[i][1] -= x, f[i][2] += x;
        if (x < 0) chmax(f[i][2], f[i][1]), chmax(f[i][1], f[i][0]);
    }
    printf("%lld\n", max(f[n][0], max(f[n][1], f[n][2])));
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 2560
#include <climits>
#include <iostream>

int main() {
    std::string S;
    std::cin >> S;

    int diff = INT_MAX;
    for (unsigned long i = 0; i < S.size() - 2; i++) {
        int var = abs(753 - std::stoi(S.substr(i, 3)));
        if (diff > var) {
            diff = var;
        }
        if (diff == 0) {
            break;
        }
    }
    std::cout << diff << std::endl;
    return 0;
}

Measured memory_bytes: 256
#ATCGのみを含む部分文字列の最長長さ

s=input()
list=[0,0,0,0,0,0,0,0,0,0]
j=0

for i in range(len(s)):
	if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
		list[j]+=1
	else:
		j+=1

print(max(list))



Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	string s;
	cin>>s;
	if((s.size()-2-(s[0]==s[s.size()-1]))%2==0)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[100005],b[100005];
    for(int i=0;i<n+1;i++){
        cin>>a[i];
    }
    long long res=0;
    for(int i=0;i<n;i++){
        cin>>b[i];
        if(b[i]<=a[i]){
            res+=b[i];
        }
        else if(b[i]<=(a[i]+a[i+1])){
            res+=b[i];
            a[i+1]-=(b[i]-a[i]);
        }
        else{
            res+=(a[i]+a[i+1]);
            a[i+1]=0;
        }
    }
    cout<<res;
}


Measured memory_bytes: 1024
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    set<string> goods;
    string tmp;
    for(int i = 0; i < N; i++)
    {
        cin >> tmp;
        goods.insert(tmp);   
    }
    cout << goods.size() << endl;

    return 0;
}

Measured memory_bytes: 19264
s = int(input())

max_ = 1000000
chk = [0]*max_
a = s
i = 1
while i <= max_:
    if chk[a] == 0:
        chk[a] += 1
    else:
        print(i)
        exit()
    if a%2 == 0:
        a = int(a/2)
    else:
        a = 3*a + 1
    i += 1


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

#define ll long long int
#define vi vector<int>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> graph[n];
    vector<int> hei(n);
    for(int i=0;i<n;i++){
        cin >> hei[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int k = hei[i];
        int cnt=0;
        for(int x:graph[i]){
            if(k>hei[x])cnt++;
        }
        if(cnt>=(int)graph[i].size()){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 8804
#include <iostream>
#include <algorithm>
#define INF 1<<28
using namespace std;
int G[801][801];
int deg[801];
int n;
void dijkstra(int s,int dist[801]){
  for(int i=1;i<=n;++i) dist[i]=INF;
  dist[s]=0;
  bool used[801]={};
  while(true){
    int id = -1,m=INF;
    for(int i=1;i<=n;++i){
      if(!used[i] && dist[i]<m){
	id=i;
	m=dist[i];
      }
    }
    if(id==-1) break;
    used[id]=true;
    for(int i=1;i<=n;++i)
      if(G[id][i]) dist[i]=min(dist[i],m+G[id][i]);
  }
}

int diam(){
  int dist[801]={};
  int s = 1; for(int i=1;i<=n;++i) if(deg[i]>1){
      s=i;
      break;
    }
  dijkstra(s,dist);
  int node1=0,M=-1;
    
  for(int i=1;i<=n;++i)
    if(deg[i]>1 && M<dist[i]) node1=i,M=dist[i];
  dijkstra(node1,dist);
  int node2=0;M=-1;
  for(int i=1;i<=n;++i)
    if(deg[i]>1 && M<dist[i]) node2=i,M=dist[i];
  return M;
}

int main(){
  while(cin>>n,n){
    int p[801]={};
    int E=0;
    for(int i=1;i<=n;++i) deg[i]=0;
    for(int i=2;i<=n;++i) cin >> p[i];
    for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j) G[i][j]=G[j][i]=0;
    for(int i=2;i<=n;++i){
      int w; cin>>w;
      E+=w;
      G[i][p[i]] = G[p[i]][i] = w;
      deg[i]++;
      deg[p[i]]++;
    }

    int leafw=0;
    for(int i=1;i<=n;++i) if(deg[i]==1) for(int j=1;j<=n;++j) if(G[i][j]) leafw+=G[i][j],G[i][j]=G[j][i]=0;
    int d = diam();
    cout <<  E*3-leafw*2-d << endl;
  }
  return 0;
}

Measured memory_bytes: 3672
import fractions
n = int(input())
a = list(map(int, input().split()))

gcd_from_left = [a[0]]
gcd_from_right = [a[-1]]

for i in range(1, n):
    gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i]))
    gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i]))

gcd_from_right.reverse()

ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, gcd_from_right[1])
    elif i == n - 1:
        ans = max(ans, gcd_from_left[n - 2])
    else:
        ans = max(ans, fractions.gcd(gcd_from_left[i - 1], gcd_from_right[i + 1]))
print(ans)


Measured memory_bytes: 16120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long r,d,x;
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++)
	{
		x=r*x-d;
		cout<<x<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
 
#define N 100
 
int Point[N+1];
int Matrix[N+1][N+1];
int n;
 
void MatrixChange(void){
 int i,j,k,l;
 for(i = 1;i <= n;i++){
    Matrix[i][i] = 0;
  }
  for(k = 2;k <= n;k++){
    for(i = 1;i <= n-k+1;i++){
      j = i + k -1;
      Matrix[i][j] = 1000000000;
      for(l = i;l <= j-1;l++){
    if(Matrix[i][j] > Matrix[i][l]+Matrix[l+1][j]+Point[i-1]*Point[l]*Point[j]){
      Matrix[i][j] =  Matrix[i][l]+Matrix[l+1][j]+Point[i-1]*Point[l]*Point[j];
    }
    else{
      Matrix[i][j] = Matrix[i][j];
    }
      }
    }
  }
}
int main(){
 
  int i;
   
  scanf("%d",&n);
 
  for(i = 1;i <= n;i++){
    scanf("%d%d",&Point[i-1],&Point[i]);
  }
  MatrixChange();
 
  printf("%d\n",Matrix[1][n]);
     
    return 0;
}

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

class kpk 
{ 
 public : long long gcd(long long a, long long b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
  
   
// Function to return LCM of two numbers  
  long long lcm(long long a, long long b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
} ; 
// Driver program to test above function  
int main()  
{  
    kpk g; 
    long long a, b;
    scanf("%lld %lld",&a,&b);  
    printf("%lld\n",g.lcm(a, b));  
    return 0;  
}  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
  int a ,b, temp, i;
  for(i=1; i<=3000; i++)
  {
    cin >> a >> b;
    if(a==0 && b==0)
       break;
    if(a > b)
    {
    temp = a;
    a = b;
    b = temp;
    }
    cout << a << " " << b << endl; 
  }
}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s;
	cin >> s;
	int len = s.length();
	int cnt = 0; rep(i, len - 1) {
		if (s[i] != s[i + 1])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] H = new int[N];
    for (int i = 0; i < N; i++) H[i] = scanner.nextInt();
    Arrays.sort(H);

    long sum = 0;
    for (int i = 0; i < N - K; i++) {
      sum += H[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 65780
import java.io.*;
import java.util.*;

/**
 * Created by fcdkbear on 15.10.16.
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        new Task().solve(in, out);
        out.close();
    }


    static class Task {

        public void solve(InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int x = in.nextInt();
            n = n + n - 1;
            if ((x == 1) || (x == n)) {
                out.println("No");
                return;
            }
            int mid = (n + 1) / 2;
            int[] res = new int[n];
            if (x == mid) {
                for (int i = 0; i < res.length; ++i) {
                    res[i] = i + 1;
                }
            } else if (x < mid) {
                int midIndex = n / 2;
                for (int i = n - 1; i > midIndex; --i) {
                    res[i] = i + 1;
                }
                res[midIndex] = x;
                res[midIndex - 1] = 1;
                int index = midIndex - 2;
                for (int i = mid; i > 1; --i) {
                    if (i != x) {
                        res[index] = i;
                        index--;
                    }
                }
            } else {
                int midIndex = n / 2;
                for (int i = 0; i < midIndex; ++i) {
                    res[i] = i + 1;
                }
                res[midIndex] = x;
                res[midIndex + 1] = n;
                int index = midIndex + 2;
                for (int i = mid; i < n; ++i) {
                    if (i != x) {
                        res[index] = i;
                        index++;
                    }
                }
            }
            out.println("Yes");
            for (int i = 0; i < res.length; ++i) {
                out.println(res[i]);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}


Measured memory_bytes: 24748
#include <iostream>
using namespace std;
int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  int a = (A-1)/K;
  
  bool ok = false;
  if (B/K > a) ok = true;
  
  if (ok) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    string A;
    cin >> A;

    if(A == "AAA" || A == "BBB"){
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes"<< endl;
    }

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    N = N % 10;
    if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9){
        printf("hon");
    }
    else if(N == 0 || N == 1 || N == 6 || N == 8){
        printf("pon");
    }
    else{
        printf("bon");
    }
}

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

namespace Tenka1_2017_D___IntegerotS
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = (int)NK[0]; var K = NK[1];
            var A = new long[N]; var B = new long[N];
            for (int i = 0; i < N; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                A[i] = ab[0]; B[i] = ab[1];
            }

            var result = new long[31];
            for (int i = 29; i >= 0; i--)
            {
                if ((K & (1 << i)) > 0)
                {
                    for (int j = 0; j < N; j++)
                    {
                        var check = true;
                        for (int k = 29; k > i; k--)
                        {
                            if ((K & (1 << k)) - (A[j] & (1 << k)) < 0)
                            {
                                check = false;
                                break;
                            }
                        }
                        if (check && (A[j] & (1 << i)) == 0) result[i] += B[j];
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                if ((A[i] | K) == K) result[30] += B[i];
            }
            Console.WriteLine(result.Max());
        }
    }
}


Measured memory_bytes: 18748
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto p = new long[](N);
	foreach (i; 0..N)
		p[i] = RD;

	auto pos = new long[](N);
	foreach (i; 0..N)
	{
		pos[p[i]-1] = i;
	}

	long ans;
	long streak;
	long last;
	foreach (i; 0..N)
	{
		if (pos[i] >= last)
			++streak;
		else
		{
			ans.chmax(streak);
			streak = 1;
		}
		last = pos[i];
	}
	ans.chmax(streak);

	writeln(N-ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 5244
A, B = map(int, input().split())
ans = []
for i in range(2000, 0, -1):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        ans.append(i)

if len(ans) > 0:
    print(min(ans))
else:
    print(-1)

Measured memory_bytes: 39280
// 木の深さでマージ
#include<unordered_map>
#include<utility>
template<typename T> class UnionFind {
 public:
  void unite(const T& a, const T& b) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y);
    if(rank_[x] == rank_[y]) ++rank_[x];
    parent_[y] = x;
  }
  T find(const T& x) {
    if(!parent_.count(x)) rank_[x] = 1, parent_[x] = x;
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> rank_;
};

// 要素数でマージ
#include<unordered_map>
#include<utility>
template<typename T> class UnionFindBySize {
 public:
  void unite(const T& a, const T& b) {
    T x = find(a), y = find(b);
    if(size_[x] < size_[y]) std::swap(x, y);
    if(x != y) parent_[y] = x, size_[x] += size_[y];
  }
  const T find(const T& x) {
    if(!parent_.count(x)) size_[x] = 1, parent_[x] = x;
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
  const int size(const T& x) {
    return size_[find(x)];
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> size_;
};

// 省メモリ, 要素数でマージ (x が根 ⇒ p_[x] = -(要素数))
#include<vector>
#include<utility>
class UnionFindLight {
 public:
  UnionFindLight(int n) : p_(n, -1) {}
  void unite(int a, int b) {
    auto x = find(a), y = find(b);
    if(x == y) return;
    if(p_[x] < p_[y]) std::swap(x, y);
    p_[x] += p_[y];
    p_[y] = x;
  }
  int find(int x) {return p_[x] < 0 ? x : p_[x] = find(p_[x]);}
  int size(int x) {return -p_[x];}
 private:
  std::vector<int> p_;
};

// 重み付き: W はアーベル群
#include<cassert>
#include<unordered_map>
#include<utility>
template<typename T, typename W> class WeightedUnionFind {
 public:
  void unite(const T& a, const T& b, const W& w) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y), weight_[y] = weight(b) - weight(a) - w;
    else                                     weight_[y] = weight(a) - weight(b) + w;
    if(rank_[x] == rank_[y]) ++rank_[x];
    parent_[y] = x;
  }
  T find(const T& x) {
    if(!parent_.count(x)) rank_[x] = 1, parent_[x] = x;
    if(parent_[x] == x) return x;
    auto root = find(parent_[x]);
    weight_[x] += weight_[parent_[x]];
    return parent_[x] = root;
  }
  W weight(const T& x) {
    find(x);
    return weight_[x];
  }
  W diff(const T& a, const T& b) {
    assert(find(a) == find(b));
    return weight(b) - weight(a);
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, W> weight_;
  std::unordered_map<T, int> rank_;
};

#include<iostream>
using namespace std;
int main() {
  using LL = long long;
  int n, q;
  cin >> n >> q;
  WeightedUnionFind<int, LL> UF;
  for(auto i=0; i<q; ++i) {
    int c, x, y, z;
    cin >> c >> x >> y;
    if(c) {
      if(UF.find(x) == UF.find(y)) cout << UF.diff(x, y) << endl;
      else                         cout << "?" << endl;
    } else {
      cin >> z;
      UF.unite(x, y, z);
    }
  }
}



Measured memory_bytes: 15128