akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	string s;
	cin >> s;
	int n = sz(s);
	string x = "", y = "";
	for(int i = 0; i < (n - 1) / 2; ++i) x += s[i];
	for(int i = (n + 3) / 2 - 1;  i < n; ++i) y += s[i];
	string xx = x, yy = y, ss = s;
	reverse(all(xx));
	reverse(all(yy));
	reverse(all(ss));
	cout << (x == xx && y == yy &&  s == ss ? "Yes" : "No") << endl;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5+5)

vector<ll> gr[N];
ll dp[N];
bool vis[N];

ll fn(ll x)
{
    if(vis[x])
        return dp[x];

    ll ans = 0;
    for(ll el : gr[x])
    {
        if(!vis[el])
            fn(el);
        ans = max(ans,dp[el] + 1);
    }

    vis[x] = 1;
    dp[x] = ans;
    return ans;
}

void solve()
{
    ll n,m,x,y;
    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        gr[x].push_back(y);
    }

    ll ans = 0;

    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
            fn(i);
        ans = max(ans , dp[i]);
    }

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

int main()
{
    fio;
    ll tc = 1;
   // cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 8704
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if (a>b){
		printf("a > b\n");
	}else if (a<b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>
int main(void){
    int a,b,c,i,j=0;
    scanf("%d %d %d",&a,&b,&c);
    
    for(i=a;i<=b;i++){
        if(c%i==0) j++;
    }
    
    printf("%d\n",j);
    return 0;
}



Measured memory_bytes: 2108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int N = Integer.parseInt(br.readLine());
            int K = Integer.parseInt(br.readLine());
            int ans = 1;
            for (int i = 0; i < N; i++) {
                if (ans * 2 < ans + K) {
                    ans *= 2;
                } else {
                    ans += K;
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20820
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S1 = input()[:-1]
S2 = input()[:-1]
i = 0
ans = 1
MOD = 10**9+7

while i<N:
    if S1[i]==S2[i]:
        if i==0:
            ans *= 3
            ans %= MOD
        else:
            if flag==0:
                ans *= 2
                ans %= MOD
        
        flag = 0
        i += 1
    else:
        if i==0:
            ans *= 6
        else:
            if flag==0:
                ans *= 2
                ans %= MOD
            else:
                ans *= 3
                ans %= MOD
        
        flag = 1
        i += 2

print(ans)

Measured memory_bytes: 38256
#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 main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else if (s == "ARC") {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 using namespace std;

 int main(){
    int N, Y;
    int i, j;
    int x = -1;
    int y = -1;
    int z = -1;

    cin >> N >> Y;
    
    for (i=0; i<N+1; i++){
        for (j=0; j<(N-i+1); j++){
            if(Y==(10000*i+5000*j+1000*(N-i-j))){
                x = i;
                y = j;
                z = N-i-j;
                }
        }
    }

    cout << x << ' ' << y << ' ' << z <<endl;
        
    return 0;
 }



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

int main()
{
	char S[100],T[100],U[100];
	int A,B;

	scanf("%s %s %d %d %s", S,T,&A,&B,U);

	if(strcmp(S,U) == 0)
		A--;

	else if(strcmp(T,U) == 0)
		B--;

	printf("%d %d\n",A,B);
	

	return 0;
}

	

Measured memory_bytes: 128
n = int(input())

data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

q, mod = divmod(n-1, 26)
answer = data[mod]

while q >= 1:
    q, mod = divmod(q-1, 26)
    answer = data[mod] + answer

print(answer)

Measured memory_bytes: 9132
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	fastio;
	int n;
	cin >> n;
	map<int,int> m;
	ll s = 0;
	int a[n];
	forn(i,n){
		cin >> a[i];
		m[a[i]]++;
		s += a[i];
	}
	int t;
	cin >> t;
	while(t--)
	{
		int a,b;
		cin >> a >> b;
		ll x = m[a];
		s-= x * a;
		s += x * b;
		m[a] -= x;
		m[b] += x;
		cout << s << endl;
	}
}

Measured memory_bytes: 8428
n, m = [int(x) for x in input().split()]
red = [2] + [0 for _ in range(1, n)]
num = [1] * n

for _ in range(m):
    x, y = [int(x) for x in input().split()]
    x -= 1
    y -= 1
    if red[x] > 0:
        if num[x] == 1:
            red[y] = red[x]
            red[x] = 0
        else:
            red[x] = 1
            red[y] = 1

    num[x] -= 1
    num[y] += 1

print(len([True for r in red if r > 0]))


Measured memory_bytes: 5384
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b): (usize, usize) = read();
    let s: String = read();
    let s = s.into_bytes();

    let mut isok = true;
    for i in 0..a {
        isok &= is_digit(s[i]);
    }
    isok &= s[a] == b'-';
    for i in a+1..a+b+1 {
        isok &= is_digit(s[i]);
    }

    if isok {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn is_digit(c: u8) -> bool {
    b'0' <= c && c <= b'9'
}

Measured memory_bytes: 4352
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H = I()
    def dfs(x):
        if x == 1:
            return 1
        return 2 * dfs(x//2) + 1
    print(dfs(H))
if __name__ == '__main__':
    main()

Measured memory_bytes: 6540
n=int(input())
a=[list(map(int,input().split())) for i in range(2)]
if n!=1:
  max=0
  for i in range(n):
    sum=0
    for j in range(0,i+1):
      sum+=a[0][j]
    for j in range(i,n):
      sum+=a[1][j]
    if sum>=max:
      max=sum
  print(max)
else:
  print(a[0][0]+a[1][0])

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

        for(int loop=0; loop<5; loop++) {
            int x = scanner.nextInt();
            if(x==0) {
                System.out.println( loop+1 );
                break;
            }
        }

    }
}

Measured memory_bytes: 35768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) { cin >> a[i]; a[i] -= i + 1; }
    sort(a, a + n);
    int b = a[n / 2];
    ll sum = 0;
    rep(i, n) {
        sum += abs(a[i] - b);
    }
    out(sum);
}


Measured memory_bytes: 1024
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
	cout<<"Possible";
	else
	cout<<"Impossible";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2003;

int n;
int a[N],b[N];
struct point{
	int x,y;
	friend bool operator < (point a,point b){
		return a.x<b.x;
	}
}p[N];
int k;
int rig[N],lef[N];
int preb[N];
int cnt[N];

int getv(int l,int r){
	if (l<=r)return preb[r]-preb[l-1];
	return preb[r]-preb[l-1]+preb[n];
}

int main(){
	char s[N];
	scanf("%s",s+1);
	n=strlen(s+1);
	fo(i,1,n)a[i]=s[i]-'0';
	scanf("%s",s+1);
	fo(i,1,n)b[i]=s[i]-'0';
	fo(i,1,n)preb[i]=preb[i-1]+b[i];
	if (!preb[n]){
		fo(i,1,n)
		if (a[i]){
			printf("-1\n");
			return 0;
		}
		printf("0\n");
		return 0;
	}
	int w=0;
	fo(i,1,n)if (b[i]){w=i;break;}
	rig[n]=(1-b[n])*w;fd(i,n-1,1)rig[i]=(1-b[i])*(rig[i+1]+1);
	fd(i,n,1)if (b[i]){w=i;break;}
	lef[1]=(1-b[1])*(n-w+1);fo(i,2,n)lef[i]=(1-b[i])*(lef[i-1]+1);
	int ans=1e+9;
	fo(l,0,n-1){
		k=0;int v=0;
		fo(i,1,n){
			if (a[i]&&!b[(i+n-l-1)%n+1]){
				int x=(i+n-l-1)%n+1;
				if (getv(x,i)==0){p[++k].x=rig[i];p[k].y=lef[x];}
			}
			if (a[i]!=b[(i+n-l-1)%n+1])v++;
		}
		fo(i,0,n)cnt[i]=0;
		sort(p+1,p+1+k);
		fo(i,1,k)cnt[p[i].y]++;
		int w=n;
		int mv=0;
		while(w&&!cnt[w])w--;
		mv=w*2;
		fo(i,1,k){
			cnt[p[i].y]--;
			while(w&&!cnt[w])w--;
			mv=min(mv,w*2+p[i].x*2);
		}
		mv+=v+l;
		ans=min(ans,mv);
	}
	fo(r,0,n-1){
		k=0;int v=0;
		fo(i,1,n){
			if (a[i]&&!b[(i+r-1)%n+1]){
				int x=(i+r-1)%n+1;
				if (getv(i,x)==0){p[++k].x=lef[i];p[k].y=rig[x];}
			}
			if (a[i]!=b[(i+r-1)%n+1])v++;
		}
		fo(i,0,n)cnt[i]=0;
		sort(p+1,p+1+k);
		fo(i,1,k)cnt[p[i].y]++;
		int w=n;
		int mv=0;
		while(w&&!cnt[w])w--;
		mv=w*2;
		fo(i,1,k){
			cnt[p[i].y]--;
			while(w&&!cnt[w])w--;
			mv=min(mv,w*2+p[i].x*2);
		}
		mv+=v+r;
		ans=min(ans,mv);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        // ?????£???????¬???°
        int vertical = 0;
        // ??¨???£???????¬???°
        int horizontal = 0;
        // ?????????????????????¨??????°
        int x = 0;


            vertical = Integer.parseInt(br.readLine());

            // ?????£???????????????????
            int[] drowingLots = new int[vertical];
            // ???????????£???????????????´???????
            for (int i = 0; i < vertical; ++i) {
                drowingLots[i] = i + 1;
            }
 
            // ??¨???£? 2??????
            horizontal = Integer.parseInt(br.readLine());
  
 
                // ??¨??????\?????????????????????????????????????????? 3????????\???
                for (int i = 0; i < horizontal; ++i) {
                    String input = br.readLine();
                    if (input == null || input.isEmpty()) {
                        break;
                    }
 
                    String[] change = input.split(",");
                    int[] intInput = adjustment(change);
 
                    // a1???????????????
                    x = drowingLots[intInput[0]];
                    // b1???a1?????\??????
                    drowingLots[intInput[0]] = drowingLots[intInput[1]];
                    // a1???b1?????\??????
                    drowingLots[intInput[1]] = x;
                }
 
                for (int output : drowingLots) {
                    System.out.println(output);
                }

  
    }
 
    // ??\??????????????????int??????????????????-1??????
    private static int[] adjustment(String[] strInput) {
        // int????????????????????????
        int[] intInput = new int[strInput.length];
 
        intInput[0] = Integer.parseInt(strInput[0]) - 1;
        intInput[1] = Integer.parseInt(strInput[1]) - 1;
 
        return intInput;
    }
 
}

Measured memory_bytes: 24180
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
typedef pair<ll,int> P;
int n,m;
P ps[100000];

int main(){
  cin>>n>>m;
  REP(i,n){
    ll a;
    int b;
    cin>>a>>b;
    ps[i] = P(a,b);
  }

  sort(ps, ps+n);

  ll ans=0;
  REP(i,n){
    ll a = ps[i].first;
    int b = ps[i].second;
    if(m - b >= 0){
      m -= b;
      ans += a*b;
    } else {
      ans += a*m;
      break;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
ans_max = 10**18

N = gets.to_i
A = gets.chomp.split(' ').map(&:to_i)

if A.include?(0)
  puts 0
  exit
end

ans = 1
A.each do |a|
  ans *= a
  if ans > ans_max
    puts -1
    exit
  end
end
puts ans


Measured memory_bytes: 23500
/*  Author : Alpha_The_Coder
    Created on 13/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
lli mod=1000000007;
void solve();
int main()
{
    iamalpha;
    int t=1;
    while(t--)
    {
        solve();
    }
}

void solve()
{

    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    lli p1,p2,p3,p4;

    p1=a*c;
    p2=a*d;
    p3=b*c;
    p4=b*d;

    cout<<max(p1,max(p2,(max(p3,p4))));




}


// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 3644
# 最小公倍数を求める
A,B=map(int,input().split())
# ユークリッドの互除法を求める．共通因数を求める．
big = max(A,B)
small = min(A,B)

amari = None
while not amari==0:
    shou = int(big/small)
    amari = big % small 
    if amari == 0:
        not_commonA = A/small
        not_commonB = B/small
    else:
        big = small
        small = amari

print(int(not_commonA * not_commonB * small))


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

#define ll long long int
#define endl "\n"
#define mod 1000000007

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll k, a, b, c, sum = 0;
	cin >> a >> b >> c >> k;
	if (k >= a) {
		sum = a;
		k = k - a;
	} else {
		sum = k;
		k = 0;
	}
	if (k >= b) {
		k = k - b;
	} else {
		k = 0;
	}
	cout << sum - k << endl;

	return 0;

}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7

B = [A[0]]
for i in range(1, n):
    B.append((B[-1] + A[i]) % mod)

ans = 0
for i in range(n-1,0,-1):
    ans = (ans + B[i-1] * A[i])
print(ans%mod)

Measured memory_bytes: 100004
N = int(input())
A = [int(i) for i in input().split()]
count = 0
prev_lastidx=-1
initial=0
for i in range(N):
    temp=initial
    for j in range(prev_lastidx+1,N):
        if temp & A[j] == 0:
            temp = temp + A[j]
            prev_lastidx = j
        else:
            prev_lastidx = j-1
            initial = temp - A[i]
            break;
    count = count + (prev_lastidx - i + 1)
print(count)    

Measured memory_bytes: 23560
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <numeric>

int main() {
  char buf[4];
  scanf("%s", buf);
  std::string s = buf;

  std::vector<std::string> t{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (size_t i = 0; i < t.size(); ++i) {
    if (s == t[i])
      return !printf("%zu\n", 7-i);
  }
  return 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
      int N; cin >> N;
      vector<pair<int,int>> BA, CD;
      rep(i, 0, N){
          int x, y; cin >> x >> y;
          BA.push_back({y,x});
      }
      rep(i, 0, N){
          int x, y;cin >>  x >> y;
          CD.push_back({x,y});
      }

      sort(BA.begin(), BA.end(), greater<pair<int, int>>());
      sort(CD.begin(), CD.end());

      vector<bool> f(N, false);

      //cの小さい順
      rep(i, 0, N){
          int c = CD.at(i).first;
          int d = CD.at(i).second;
          //bの大きい順
          rep(j, 0, N){
              int a = BA.at(j).second;
              int b = BA.at(j).first;

              if(f.at(j)) continue;
              if(a < c && b < d){
                  f.at(j) = true;
                  break;
              }
          }
      }

      int cnt =0;
      rep(i, 0, N) if(f.at(i)) cnt++;

      cout<<cnt<<endl;
  }


Measured memory_bytes: 256
//q5.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int n,m,k,s;
int p,q;
vector<int> way[SIZE];
int zomb_dis[SIZE];
int add_cost[SIZE];
bool visited[SIZE];

int main(){
    int a,b,c;
    ll ans = -1;
    
    
    scanf("%d%d%d%d%d%d",&n,&m,&k,&s,&p,&q);
    
    priority_queue<pair<int,int> > pq;
    
    for(int i=0;i<k;i++){
        scanf("%d",&c);
        c--;
        pq.push({0,c});
    }
    
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        a--; b--;
        
        way[a].push_back(b);
        way[b].push_back(a);
    }
    
    for(int i=0;i<n;i++){
        zomb_dis[i] = INF;
    }
    
    while(pq.size()){
        pair<int,int> t = pq.top();
        pq.pop();
        
        int dis = t.first;
        int now = t.second;
        
        if(zomb_dis[now]<INF) continue;
        zomb_dis[now] = -dis;
        
        for(int i=0;i<way[now].size();i++){
            pq.push({dis-1,way[now][i]});
        }
    }
    
    for(int i=1;i<n-1;i++){
        if(zomb_dis[i] == 0){
            add_cost[i] = -1;
        }else if(zomb_dis[i] <= s){
            add_cost[i] = q;
        }else{
            add_cost[i] = p;
        }
    }
    
    priority_queue<pair<ll,int> > pq2;
    
    pq2.push({0,0});
    
    while(pq2.size()){
        pair<ll,int> t = pq2.top();
        pq2.pop();
        
        ll cost = t.first;
        int now = t.second;
        
        
        if(visited[now]) continue;
        visited[now] = true;
        
        if(now == n-1){
            ans = -cost;
            break;
        }
        
        for(int i=0;i<way[now].size();i++){
            if(add_cost[way[now][i]]==-1) continue;
            
            pq2.push({cost-add_cost[way[now][i]],way[now][i]});
        }
    }
    
    assert(ans>=0);
    
    printf("%lld\n",ans);
    
    return 0;
}

Measured memory_bytes: 10904
#include <iostream>
#include <algorithm>
using namespace std;
long long n;
string s;

string f(long long n) {
    if (n == 0) return "";
    n--;
    return f(n / 26) + string(1, 'a' + (n % 26));
}

int main() {
    cin >> n;
//    cout << f(n);
    while (n > 0) {
        n--;
        s += 'a' + n % 26;
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n,k;
  cin>>n>>k;
  vector<long long> a(n);
  long long su1=0, su2=0;
  for(int i=0;i<n;++i){
    cin>>a[i];
    su1+=a[i];
    if(a[i]>0)su2+=a[i];
  }
  long long res = 0;
  long long de1 = 0,de2 = 0;
  for(int i=0;i<k;++i){
    de1 += a[i];
    if(a[i]>0) de2 += a[i];
  }
  res = max(res,max(su2-de2,su2-de2+de1));
  for(int i=k;i<n;++i){
    de1 += a[i];
    if(a[i]>0) de2+=a[i];
    de1 -= a[i-k];
    if(a[i-k]>0) de2-=a[i-k];
    res = max(res,max(su2-de2,su2-de2+de1));
  }
  cout<<res<<endl;
  return 0;
}


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

double f(double A, double B, double X)
{
	return floor(A*X/B);
}

int main()
{
	double A, B, N;
	cin >> A >> B >> N;
	cout << f(A,B,min(B-1,N)) << endl;
	return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

namespace INPUT{
	const int L=1<<15;
	char _buf[L],*S,*T,c;
	char _gc(){
		if(S==T){
			T=(S=_buf)+fread(_buf,1,L,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
	void readi(int &X){
		register bool flag;
		for(c=_gc();(c<'0'||c>'9')&&c!='-';c=_gc());
		if(c=='-') X=0,flag=true; else X=c&15,flag=false;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
		if(flag) X=-X;
	}
}
using INPUT::readi;

const int Maxn=4E5+5;

int N,M,K,V;
int a[Maxn];
int F[Maxn],G[Maxn];
int L[25][Maxn],R[25][Maxn];
char Ans[50],_1[50]={"Possible"},_2[50]={"Impossible"};
//int nxt[Maxn];

inline void MIN(int &x,int y){if(x>y)x=y;}
inline void MAX(int &x,int y){if(x<y)x=y;}

int main(){
	readi(N),readi(V);
	while(V>>M) ++M;
	for(int i=1;i<=N;++i) readi(a[i]);
	for(int i=0;i<=M;++i){
		L[i][1]=1;
		for(int j=2;j<=N;++j)
			if(a[j]-a[j-1]>(V>>i)) L[i][j]=j;
		for(int j=2;j<=N;++j)
			if(L[i][j]==0) L[i][j]=L[i][j-1];
		
		R[i][N]=N;
		for(int j=N-1;j>=1;--j)
			if(a[j+1]-a[j]>(V>>i)) R[i][j]=j;
		for(int j=N-1;j>=1;--j)
			if(R[i][j]==0) R[i][j]=R[i][j+1];
	}
	G[0]=N+1;
	for(int i=1;i<(1<<M);++i){
		G[i]=N+1;
		for(int j=0;j<M;++j)
			if((i>>j)&1)
				MAX(F[i],R[M-j][min(F[i-(1<<j)]+1,N)]),
				MIN(G[i],L[M-j][max(G[i-(1<<j)]-1,1)]);
	}
	for(int i=1;i<=N;++i)
		K+=(L[0][i]!=L[0][i-1]);
	if(K>20){
		for(int i=1;i<=N;++i)
			puts("Impossible");
		return 0;
	}
	for(int i=1,j;i<=N;++i)
		if(L[0][i]!=L[0][i-1]){
			for(j=0;j<(1<<M);++j)
				if(F[j]>=L[0][i]-1 && G[(1<<M)-1-j]<=R[0][i]+1)
					{memcpy(Ans,_1,sizeof(_1)); break ;}
			if(j==1<<M) memcpy(Ans,_2,sizeof(_2));
			printf("%s\n",Ans);
		}else printf("%s\n",Ans);
/*	memset(nxt,-1,sizeof(nxt));
	for(int i=0;i<(1<<M);++i) MAX(nxt[G[(1<<M)-1-i]],F[i]);
	for(int i=1;i<=N+1;++i) MAX(nxt[i],nxt[i-1]);
	for(int i=1;i<=N;++i)
		if(nxt[R[0][i]+1]>=L[0][i]-1)
			puts("Possible");
		else
			puts("Impossible");*/
	return 0;
}


Measured memory_bytes: 67328
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



int main()
{
    ll X;
    cin >> X;

    ll money = 100;

    ll cnt = 0;
    while (money < X)
    {
        cnt++;
        money += money / 100;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));

$a = (int) $a;
$b = (int) $b;
$c = (int) $c;

if ($a < $b && $b < $c) {
    echo "Yes\n";
} else {
    echo "No\n";
}
?>


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
    int n;
    cin >> n;
    veci a(n), pref(n);
    for(auto &it : a) cin >> it;
    int sum = 0;
    for(int i = 0; i < n; ++i) pref[i] = (!i ? a[i] : (pref[i - 1] + a[i]) % MOD1);
    for(int i = 0; i < n - 1; ++i)
        sum = (sum + a[i] * 1ll * ((pref[n - 1] - pref[i] + MOD1) % MOD1) % MOD1) % MOD1;
    cout << sum;
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 4780
N=int(input())
D=[tuple(map(int,input().split())) for _ in range(N)]
ans="No"
for i in range(N-2):
  if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
    ans="Yes"
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int H,W;
	cin >> H >> W;
	vector<vector<char>> vec(H,vector<char>(W));
	for(int i = 0;i < H;i++) {
		for(int j = 0;j < W;j++) {
			cin >> vec.at(i).at(j);
		}
	}
	int ret = 0;
	for(int i = 0;i < H;i++) {
		for(int j = 0;j < W;j++) {
			if(vec.at(i).at(j) == '#') {
				ret++;
			}
		}
	}
	if(ret == H + W - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0){
        cout<<"1"<<endl;
    }
    else if(x2==0){
        cout<<"2"<<endl;
    }
    else if(x3==0){
        cout<<"3"<<endl;
    }
    else if(x4==0){
        cout<<"4"<<endl;
    }
    else if(x5==0){
        cout<<"5"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    int a[100010];
    cin >> n;
    reps(i, 1, n){
        cin >> a[i];
    }

    int res = 0;
    reps(i, 1, n){
        if(a[a[i]] == i) res++;
    }

    cout << res/2 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 MOD = 1e9 + 7;

i64 solve(const vector<i64>& a) {
  i64 ans = 0;
  for(int i = 0;i < a.size();i++) {
    i64 x = a[i] % MOD;
    ans += x * (1 + i) % MOD * (a.size() - i) % MOD;
    ans %= MOD;
  }
  return ans;
}

int main() {
  vector<i64> xs;
  vector<i64> ys;
  int n, m;
  cin >> n >> m;
  vector<i64> x(n), y(m);
  for(int i = 0;i < n;i++) cin >> x[i];
  for(int i = 0;i < m;i++) cin >> y[i];
  for(int i = 1;i < n;i++) xs.push_back(x[i] - x[i - 1]);
  for(int i = 1;i < m;i++) ys.push_back(y[i] - y[i - 1]);
  cout << solve(xs) * solve(ys) % MOD << endl;
}


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

int main() {
    int n,k,ans=0;
    cin >> n >> k;
    vector<int> l(n,0);
    for(int i = 0;i < n;i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    for(int i = 0;i < k;i++){
        ans += l[i];
    }
    cout << ans << endl;
return 0;
}


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

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<int> cnt(m, 0);

    for(int i = 0; i < n; ++i){
        int k;
        std::cin >> k;
        for(int j = 0; j < k; ++j){
            int a;
            std::cin >> a;
            a--;
            cnt[a]++;
        }
    }

    int num = 0;

    for(int i = 0; i < m; ++i){
        if(cnt[i] == n){
            num++;
        }
    }

    std::cout << num << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> A(N);
for(int i=0;i<N;i++) cin>>A[i];

vector<int> rev(N);
for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
for(int i=0;i<N;i++) cout<<rev[i]<<endl;
return 0;
}


Measured memory_bytes: 3560
import java.util.*;
import java.util.stream.IntStream;

class Dice {
	int[] surfaces = new int[6];

	Dice(int[] diceNumArr) {surfaces = diceNumArr;}

	public int getTopNumber() {return surfaces[0];}

	public void move(String str) {
		for (char d : str.toCharArray()) {
			if (d == 'E') {roll(true, false, false);}
			else if (d == 'W') {IntStream.range(0, 3).forEach(e -> roll(true, false, false));}
			else if (d == 'S') {IntStream.range(0, 3).forEach(e -> roll(false, true, false));}
			else if (d == 'N') {roll(false, true, false);}
		}
	}

	private void roll(boolean x, boolean y, boolean z) {
		if (x && !y && !z) {roll(0, 3, 5, 2);}
		else if (!x && y && !z) {roll(0, 1, 5, 4);}
		else if (!x && !y && z) {roll(1, 2, 4, 3);}
	}

	private void roll(int w, int x, int y, int z) {
			int tmp = surfaces[w];
			surfaces[w] = surfaces[x];
			surfaces[x] = surfaces[y];
			surfaces[y] = surfaces[z];
			surfaces[z] = tmp;
	}

	public void setTopAndFront(int top, int front) {
		isSame(top, front, -1);
	}

	private boolean isSame(int... srf) {
		for (int xy = 0; xy < 6; xy++) {
			for (int z = 0; z < 4; z++) {
				if (surfaces[0] == srf[0] && surfaces[1] == srf[1] && srf[2] < 0) return false;
				int[] a = Arrays.copyOfRange(surfaces, 2, surfaces.length);
				int[] b = Arrays.copyOfRange(srf, 2, srf.length);
				if (Arrays.equals(a, b)) return true;
				roll(false, false, true);
			}
			if (xy % 2 == 0) {roll(true, false, false);}
			else {roll(false, true, false);}
		}
		return false;
	}

	@Override
	public boolean equals(Object obj) {
		Dice other = (Dice) obj;
		return isSame(other.surfaces);
	}
}
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int[] numArr = {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
			int[] numArr2 = {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
			Dice dice = new Dice(numArr);
			Dice dice2 = new Dice(numArr2);

			System.out.println(dice.equals(dice2) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 26468
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
    ll n;
    cin >> n;
    vector<ll> arr(n);
    ll allxor = 0;
    for (int i=0;i<n;i++)
        cin >> arr[i], allxor ^= arr[i];
    
    for (int i=0;i<n;i++)
        cout << (ll)(arr[i] ^ allxor) << " ";
    cout << "\n";
}

Measured memory_bytes: 4768
# 整数の入力
D, N = list(map(int, input().split(" ")))

if N == 100:
    if D == 0:
        print(101)

    elif D == 1:
        print(100 * 101)

    else:
        print(10000 * 101)

else:
    if D == 0:
        print(N)

    elif D == 1:
        print(100*N)

    else:
        print(10000*N)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		switch (n) {
		case 0:
			System.out.println(1);
			break;
		case 1:
			System.out.println(2);
			break;
		case 2:
			System.out.println(1);
			break;
		default:
			System.out.println(0);
			break;
		}
		sc.close();
	}

}

Measured memory_bytes: 17348
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long from; long long to; long long cost; 
	bool operator<(const edge& rhs) const {
		return cost > rhs.cost;
	}
};

priority_queue<edge> pq;

ll const MAX = 4006;
ll dep[MAX];
ll parent_uf[MAX];
ll rk[MAX];

void init(ll n) {
	for (ll i = 1; i <= n; i++) {
		parent_uf[i] = i;
		rk[i] = 1;
	}
}

ll find(ll x) {
	if (parent_uf[x] == x) {
		return x;
	}
	parent_uf[x] = find(parent_uf[x]);
	return parent_uf[x];
}

bool same(ll x, ll y) {
	return find(x) == find(y);
}

void unite(ll x, ll y) {
	if (!same(x, y)) {
		x = parent_uf[x];
		y = parent_uf[y];
		if (rk[x] < rk[y]) {
			parent_uf[x] = y;
		}
		else {
			parent_uf[y] = x;
			if (rk[x] == rk[y]) {
				rk[x]++;
			}
		}
	}
}

ll n, m, q;
vector<edge> G[MAX];

ll make_tree() {
	ll cnt = n - 1;	
	ll ttl = 0;

	while (cnt > 0) {
		edge cur = pq.top();
		pq.pop();
		ll cf = cur.from; ll ct = cur.to; ll cc = cur.cost;
		if (!same(cf, ct)) {
			unite(cf, ct);
			ttl += cur.cost;
			G[cf].push_back({ cf,ct,cc });
			G[ct].push_back({ ct,cf,cc });
			cnt--;
		}
	}
	return ttl;
}

ll parent[MAX];
ll costing[MAX];

void dfs() {
	parent[1] = 1;
	stack<ll> st;
	st.push(1);
	dep[1] = 0;
	while (!st.empty()) {
		ll cur = st.top();
		st.pop();
		for (ll i = 0; i < SIZE(G[cur]); i++) {
			
			ll next = G[cur][i].to;
			if (next == parent[cur]) {
				continue;
			}
			//cout << cur << " " << next << endl;
			parent[next] = cur;
			dep[next] = dep[cur] + 1;
			costing[next] = G[cur][i].cost;
			//cout << costing[next] << endl;
			st.push(next);
		}
	}
}

ll dp[MAX][MAX] = {};

ll query(ll s, ll t) {
	if (s == t) {
		return 0;
	}	
	if (dep[s] < dep[t]) {
		swap(s, t);
	}

	if (dp[s][t] != 0) {
		return dp[s][t];
	}
	//cout << v << " ?" << endl;
	dp[s][t] = max(costing[s],query(parent[s], t));
	return dp[s][t];
}

int main() {
	cin >> n >> m;
	init(n);
	REP(i, 1, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		pq.push({ a,b,c });
	}
	ll ttl = make_tree();
	dfs();
	cin >> q;
	REP(i, 1, q) {
		ll s, t;
		cin >> s >> t;
		cout << ttl - query(s, t) << endl;
	}
}

Measured memory_bytes: 138216
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int P,Q,R;
int main()
{
    scanf("%d%d%d",&P,&Q,&R);
    int ans=min(P+Q,Q+R);
    ans=min(ans,P+R);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    b++;//半壊区間
    vector<long long>bit;//bit毎の1の個数
    for(long long i=1;i<b;i*=2){
        bit.push_back(b/(i*2)*i+max(0ll,b%(i*2)-i));
    }
    int bs=bit.size();
    long long x=1,XOR=0;
    for(int i=0;i<bs;i++){
        bit[i]-=a/(x*2)*x+max(0ll,a%(x*2)-x);
        XOR+=bit[i]%2*x;
        x*=2;
    }
    cout<<XOR<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

//int dp[333][2];

void solve(){
	int n, m;
	cin>>n>>m;
	string s="", t="";
	FOR(i, 0, m){
		s+=(n+'0');
	}
	FOR(i, 0, n){
		t+=(m+'0');
	}
	if(sz(s)>sz(t)){
		cout<<s;
	}
	else if(sz(t)>sz(s)){
		cout<<t;
	}
	else{
		FOR(i, 0, sz(s)){
			if(s[i]-'0'>t[i]-'0'){
				cout<<s;
				return;
			}
			else if(s[i]-'0'<t[i]-'0'){
				cout<<t;
				return;
			}
		}
		cout<<s;
		return;
	}
}	

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int ans = min(A,K);
    if(K>A){
        K-= A+B;
        ans -= max(K,0);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var seqX = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(Array.IndexOf(seqX, 0) + 1);
    }
}


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

using namespace std;

int main(){
  int N,a;
  string s;
  cin >>N;
    tuple<string,int,int>p[110];
    for(long long int i=0;i<N;i++){
      cin >> s >>a;
      p[i]=make_tuple(s,-a,i);
    }
    sort(p,p+N);
    for(long long int i=0;i<N;i++){
      cout << get<2>(p[i])+1<<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 1010
#define MAXM 2010
#define MOD 1000000007
using namespace std;
int diff[MAXM];
struct node{
    int u,v,len;
    node () {}
    node (int u1,int v1,int len1):u(u1),v(v1),len(len1) {}
    bool operator < (const node &x) const {
        return len<x.len;
    }
}line[MAXM];
bool used[MAXM];
long long x,sum;
int fa[MAXN],fal[MAXN],deep[MAXN];
vector<int> a[MAXN],w[MAXN];
int get_fa(int x){
    if(fa[x]==0)
        return x;
    fa[x]=get_fa(fa[x]);
    return fa[x];
}
void build(int x,int fa1){
    fa[x]=fa1;
    deep[x]=deep[fa1]+1;
    for(int i=0;i<a[x].size();i++){
        if(a[x][i]==fa1){
            fal[x]=w[x][i];
            continue;
        }
        build(a[x][i],x);
    }
}
int find_max(int u,int v){
    int maxv=0;
    if(deep[u]<deep[v])
        swap(u,v);
    while(deep[u]>deep[v]){
        maxv=max(maxv,fal[u]);
        u=fa[u];
    }
    while(u!=v){
        maxv=max(maxv,max(fal[u],fal[v]));
        u=fa[u];
        v=fa[v];
    }
    return maxv;
}
int n,m,u,v,val;
long long bits[MAXM];
void prepare(){
    bits[0]=1;
    for(int i=1;i<=m;i++)
        bits[i]=(bits[i-1]*2ll)%MOD;
}
int main(){
    SF("%d%d",&n,&m);
    prepare();
    SF("%lld",&x);
    for(int i=0;i<m;i++){
        SF("%d%d%d",&u,&v,&val);
        line[i]=node(u,v,val);
    }
    sort(line,line+m);
    for(int i=0;i<m;i++){
        int u=get_fa(line[i].u);
        int v=get_fa(line[i].v);
        if(u!=v){
            fa[u]=v;
            sum+=line[i].len;
            a[line[i].u].push_back(line[i].v);
            a[line[i].v].push_back(line[i].u);
            w[line[i].u].push_back(line[i].len);
            w[line[i].v].push_back(line[i].len);
            used[i]=1;
        }
    }
    x=x-sum;
    if(x<0){
        PF("0");
        return 0;
    }
    memset(fa,0,sizeof fa);
    build(1,0);
    int cnt=0;
    for(int i=0;i<m;i++)
        if(used[i]==0){
            int maxd=find_max(line[i].u,line[i].v);
            diff[++cnt]=line[i].len-maxd;
        }
    sort(diff+1,diff+1+cnt);
    long long res=0;
    if(x==0)
        res=(bits[m]-2ll*bits[m-n+1]+2ll*MOD)%MOD;
    for(int i=1;i<=cnt;i++)
        if(x==diff[i]){
            res+=2ll*bits[cnt-i];
            res%=MOD;
        }
    PF("%lld",res);
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))

if 1:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==0:
        print("Yes")
    else:
        print("No")
else:
    tmp=0
    for item in a:
        tmp=tmp^item
    if tmp==2**len(str(bin(max(a))[2:]))-1:
        print(tmp)
        print("Yes")
    else:
        print("No")



#001 (1)
#010 (2)
#011 (3)
#001 (1)
#010 (2)
#011 (3)

#010 (2)
#011 (3)
#001 (1)

#011 (3)
#001 (1)
#010 (2)


Measured memory_bytes: 60784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int x,y,z;cin >> x >> y >> z;
    swap(x,y);swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256