akhauriyash/Code-Regression huggingface dataset:
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll llinf=(ll)1e18+7;
const ld eps=1e-7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	ll n;
	cin>>n;
	map<ll,int> freq;
	while(n%2==0){
		freq[2]++;
		n/=2;
	}
	for(ll i=3;i*i<=n;i+=2){
		while(n%i==0){
			freq[i]++;
			n/=i;
		}
	}
	if(n>2) freq[n]++;
	int ans=0;
	trav(i,freq){
		int j=1;
		while(i.ss-j>=0){
			i.ss-=j;
			j++;
			ans++;
		}
	}
	cout<<ans<<newl;
}

int main(){
	FAST_IO
	cout<<fixed<<setprecision(15);
	cerr<<fixed<<setprecision(10);
	//init_fact();
	//TEST_CASE(solve)
	//TEST_CASE_2{}
	//TEST_CASE_3(solve)
	solve();
	return 0;
}

Measured memory_bytes: 3520
h,w,k = gets.chomp.split().map { |e|e.to_i }
list = Array.new(h).map { Array.new(w,0) }
for i in 0..h - 1 do
  list[i] = gets.chomp.split("")
end
count, ans = 0, 0
default = list.flatten.count("#")

for maskR in 0..(1 << h) - 1 do
  for maskC in 0..(1 << w) - 1 do
    count = 0
    for i in 0..h - 1 do
      for j in 0..w - 1 do
        if ((maskR >> i) & 1) == 0 && ((maskC >> j) & 1) == 0 && list[i][j] == '#'
          count += 1
        end
      end
    end
    if count == k
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 14392
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll dp[201][100001];

int main(){
    int N, X;
    cin >> N >> X;
    ll mod=1e9+7;
    vector<int> s(N);
    for(int i=0; i<N; i++) cin >> s[i];
    sort(s.rbegin(), s.rend());
 
    dp[0][X] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=X;j++){
            dp[i+1][j%s[i]]+=dp[i][j];
            dp[i+1][j%s[i]]%=mod;
            dp[i+1][j]+=dp[i][j]*(N-(i+1));
            dp[i+1][j]%=mod;
        }
    }
    ll ans=0;
    REP(i,X+1){
        ans+=i*dp[N][i];
        ans%=mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 156544
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i32 a, b;
    char c;
    std::cin >> a >> c >> b;
    std::cout << (c=='+' ? a+b : a-b) << '\n';
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 21:23:17 2019

@author: yuta
"""

N = int(input())
H = list(map(int,input().split()))

def main(n,h):
    count = 1
    max_h = h[0]
    for i in range(1,n):
        if h[i] >= max_h:
            max_h = h[i]
            count += 1
    print(count)
main(N,H)

Measured memory_bytes: 3060
package main

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

var scd = bufio.NewScanner(os.Stdin)

func inputd() int {
	scd.Scan()
	s := scd.Text()
	a, _ := strconv.Atoi(s)
	return a
}

func main() {
	scd.Split(bufio.ScanWords)
	var s int
	s = inputd()
	arr := []int{}
	for i := 0; i < s; i++ {
		var a int
		a = inputd()
		arr = append(arr, a)
	}
	min := 1000000000
	for {
		b := true
		if arr[0] < min {
			min = arr[0]
		}
		for i, v := range arr {
			if v%min != 0 {
				arr[i] = v % min
				if arr[i] < min {
					min = arr[i]
					b = false
				}
			}
		}
		if b || min == 1 {
			break
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 5504
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    for n in range(1,3501):
        for h in range(1,3501):
            x = 4*n*h-N*n-N*h
            if x<=0:
                continue
            else:
                if (N*h*n)%x==0:
                    print(n, h, (N*h*n)//x)
                    exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int abc[5][4][11]={{}};
    int b,f,r,v;
    int i,j,k,n;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        abc[b][f][r] += v;
    }
    for(i=1;i<=4;i++){
        if(i>1) cout << "####################" << endl;
        for(j=1;j<=3;j++){
            for(k=1;k<=10;k++){
                cout << " " << abc[i][j][k];
            }
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	string t;
	cin >> t;
	int n = 0, s = 0, w = 0, e = 0;
	for (auto i : t) {
		if (i == 'N')n = 1;
		if (i == 'S')s = 1;
		if (i == 'W')w = 1;
		if (i == 'E')e = 1;
	}
	if (n != s || w != e)cout << "No\n";
	else cout << "Yes\n";
	return 0;
};

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),ans=1;
    string s;
    cin >> s;
    char cl=s[0];
    for (int i=1;i<n;i++) {
        if (cl!=s[i]) {
            ans++;
            cl=s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define vi vector<ll>
# define vvi vector<vi>
# define rep(i, N) for (int i = 0; i < N; i++)
# define Rep(i, N) for (int i = 1; i <= N; i++)
# define deb(x) cerr << #x << ": " << x << endl;
# define deb2(x, i) cerr << #x << "[" << i << "]: " << x[i] << endl;
/*
vi v(10, 2); 
rep(i, 10) deb2(v, i); 
*/

/*
int a; cin >> a;
int a, b; cin >> a >> b;
rep(i, n){cin >> v[i];}
cout <<   << endl;
*/



signed		main()
{
	int n, m; cin >> n >> m;
	vi v(n + 1);
	Rep(i, n) cin >> v[i];
	vvi v2(n + 1);
	rep(i, m)
	{
		int a, b; cin >> a >> b;
		v2[a].push_back(b);
		v2[b].push_back(a);
	}
	int ans = 0;
	for (int i = 1; i < v2.size(); i++)
	{
		bool f = 1;
		for (int j = 0; j < v2[i].size(); j++)
		{
			if (v[i] <= v[v2[i][j]])
			{
				f = 0;
				break;
			}
		}
		if (f) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 9868
use std::cmp;

fn solve(a: i32, b: i32, c: i32, d: i32) -> i32 {
    cmp::max(0, cmp::min(b, d) - cmp::max(a, c))
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut iter = s.split_whitespace().map(|w| w.trim().parse().ok().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let c = iter.next().unwrap();
    let d = iter.next().unwrap();
    let res = solve(a, b, c, d);
    println!("{}", res);
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();

    vector<ll> l(n, 0);
    REP(i, n) if (s[i] == '<') l[i] = 1;
    REP(i, n - 1)
        if (l[i + 1] != 0 && l[i] != 0)
            l[i + 1] += l[i];
    // REP(i, n) cout << l[i];
    // cout << '\n';

    vector<ll> r(n, 0);
    for (int i = n - 1; i >=0; i--)
        if (s[i] == '>') r[i] = 1;
    for (int i = n - 1; i >0; i--)
        if (r[i - 1] != 0 && r[i] != 0)
            r[i - 1] += r[i];
    // REP(i, n) cout << r[i];
    // cout << '\n';

    vector<ll> tmp(n, 0);
    REP(i, n)
        if (l[i] != 0) tmp[i] = l[i];
        else tmp[i] = r[i];
    // REP(i, n) cout << tmp[i];
    // cout << '\n';

    vector<ll> res;
    REP(i, n - 1) {
        if (s[i] == '<' && s[i + 1] == '>') {
            res.push_back(max(tmp[i], tmp[i + 1]));
            i++;
        } else res.push_back(tmp[i]);
        if (s[i] == '>' && s[i + 1] == '<')
            res.push_back(0);
    }
    if (!(s[n - 2] == '<' && s[n - 1] == '>'))
        res.push_back(tmp[n - 1]);
    // REP(i, res.size()) cout << res[i];
    // cout << '\n';

    ll ans = accumulate(res.begin(), res.end(), 0LL);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 19092
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()[0]

    if n%500 <= a:
        print('Yes')
    else:
        print('No')

solve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  vi arr(n), ans;
  fi(0, n) {
    cin >> arr[i];
    if(arr[i] > i + 1) {
      cout << "-1\n";
      return 0;
    }
  }

  // from n to 1, take arr[i] when arr[i] is i
  // ex:
  // [1] 1 1 2 2 1 2 3 2
  // [1] 1 2 2 1 2 3 2
  // 1 [2] 2 1 2 3 2
  // 1 [2] 1 2 3 2
  // [1] 1 2 3 2
  // 1 2 [3] 2
  // 1 [2] 2
  // 1 [2]
  // [1]
  // answer is bottom to up: 1, 2, 2, 3, 1, 2, 2, 1, 1
  //
  // ex:
  // 1 1 1 4 5 [6]
  // 1 1 1 4 [5]
  // 1 1 1 [4]
  // [1] 1 1
  // [1] 1
  // [1]
  // answer is bottom to up: 1, 1, 1, 4, 5, 6
  while(arr.size()) {
    for(int i = arr.size() - 1; i >= 0; i--) {
      if(arr[i] == i + 1) {
        ans.push_back(arr[i]);
        arr.erase(arr.begin() + i);
        break;
      }
    }
  }
  reverse(all(ans));
  for(int x: ans)
    cout << x << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, pair<int, int>>> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
 

 
 
int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s[k - 1] == 'A') {
      s[k-1] = 'a';
  }else if(s[k - 1] == 'B') {
      s[k-1] = 'b';
  }else{ 
      s[k-1] = 'c';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
max_x=max(x)
min_y=min(y)
for Z in range(X+1,Y+1):
    if max_x<Z<=min_y:
        print("No War")
        exit()
print("War")

Measured memory_bytes: 9080
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
   
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
               char[] chrs = line.toCharArray();
               StringBuilder sb=new StringBuilder("");
               ArrayList<String> alStr = new ArrayList<String>();
               for(int i=0;i<chrs.length;i++){
                   char c = chrs[i];
                   if(c==' '||c==','||c=='.'){//kugiri moji
                       String str = sb.toString();
                       if(str.length()<=6&&str.length()>=3){alStr.add(str);}
                       sb =new StringBuilder("");
                   }else{
                       sb.append(c);
                   }
               }//bun sagasi owatta
               String out= "";
               for(String strin:alStr){out+=strin+" ";}
               out=out.trim();
                 System.out.println(out);
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
    
     
     
}
 

Measured memory_bytes: 17128
#include <iostream>

using namespace std;

typedef long long    ll;
typedef long double  ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


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

ll solve(ll a) {
  return a + a*a + a*a*a;
}

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

  ll a;
  cin >> a;

  auto ans = solve(a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3160
def resolve():
    (N, M) = list(map(int,input().split(" ")))
    cities = [list(map(int, input().split(" "))) + [i] for i in range(M)]
    sorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))

    pref = 0
    cnt = 0
    for city in sorted_cities:
        if pref != city[0]:
            pref = city[0]
            cnt = 0
        cnt = cnt + 1
        city.append("{:06d}{:06d}".format(pref, cnt))
    
    #sorted_cities = sorted(cities, key=lambda x: x[2])
    # for city in sorted_cities:
    #     print(city[3])

    for city in cities:
        print(city[3])

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 35428
#include<iostream>
#include<cstdio>
#include<cmath>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=1010;
int n,D1,D2,K,m,cnt,c[2][N][N],s[4];
void work(int L,int C[N][N]){
	L=log2(L&-L);
	K=!(L&1);L>>=1;
	FOR(i,0,m)FOR(j,0,m) C[i][j]=i+K*j>>L&1;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d%d",&n,&D1,&D2);
	m=2*n-1;
	work(D1,c[0]);work(D2,c[1]);
	FOR(i,0,m)FOR(j,0,m) s[c[0][i][j]|c[1][i][j]<<1]++;
	FOR(k,0,3)if(s[k]>=n*n){
		FOR(i,0,m)FOR(j,0,m)if((c[0][i][j]|c[1][i][j]<<1)==k && cnt<n*n)
			cout<<i<<' '<<j<<'\n',++cnt;
		return 0;
	} 
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	string s;
	cin >> s;
	int l = (int)s.size();
	
	if(l % 2 == 1) s = s.substr(0, l-1);
	else s = s.substr(0, l-2);
	
	l = (int)s.size();
	while(l > 0){
		//cout << s << endl;
		if(s.substr(0,l/2) == s.substr(l/2, l/2)){
			break;
		}
		else{
			l -= 2;
			s = s.substr(0, l);
		}
	}
	cout << l;
		 
		

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
 
typedef long long ll;
 
ll dp[51][51][2501];
ll N, A, x[51];
 
 
void solve() {
    dp[0][0][0] = 1;
    
    for (ll i = 1; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            for (ll k = 0; k <= 2500; k++) {
                //not select
                dp[i][j][k] = dp[i-1][j][k];
                if (j > 0 && k >= x[i])
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i]];
            }
        }
    }
    
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
            ans += dp[N][i][i*A];
    }
    
    cout << ans << endl;
}
 
int main() {
    
    cin >> N >> A;
    for (ll i = 1; i <= N; i++)
        cin >> x[i];
    
    
    solve();
    
    
    
    return 0;
}

Measured memory_bytes: 50048
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a<=c && c<=b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22868
#include<stdio.h>
#include<math.h>
main(){
  double x,h;
  double S;
  double z,n;

  while(1){

  scanf("%lf %lf",&x,&h);

  if(x==0 && h==0){
    break;
  }

  n=(x/2)*(x/2)+h*h;
  z=sqrt(n);
  S=x*x+z*(x/2)*4;

  printf("%f\n",S);

  }

  return 0;
}

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

int main()
{
    ll N, cnt = 0, ans = 0, minA = 1e10;
    cin >> N;
    vector<ll> A(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];

        if (A[i] < 0)
        {
            cnt++;
            A[i] = abs(A[i]);
        }

        ans += A[i];
        minA = min(minA, A[i]);
    }

    if (cnt % 2 == 1)
    {
        cout << ans - 2 * minA << endl;
    }

    else
    {
        cout << ans << endl;
    }
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL A,P;
  cin>>A>>P;
  P += A * 3;
  cout << P / 2 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int t = 0;
    rep(i,n-1){
        if(s[i] == s[i+1])t++;
    }
    cout << min(n-1,t+2*k) << endl;
}

Measured memory_bytes: 512
N = int(input())
nums = []

for i in range(N):
    nums.append(int(input()))

nums_sorted = sorted(nums,reverse=True)
max1 = nums_sorted[0]
max2 = nums_sorted[1]

for num in nums:
    if(num!=max1):
        print(max1)
    else:
        print(max2)

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


using namespace std;

int n , d;
int const N = 1e6+1000;
long long x , y;
double ans , a;

int main()
{
    
        cin >> n >> d;
        for ( int j = 0; j<n ; j++ )
        {
            cin >> x >> y;
            x = pow( x ,2 );
            y = pow( y ,2 );
            
            a = sqrt ( x+y );
      
            if ( a <= d ) ans++;

       }
         cout << ans;
	return 0;
}

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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define RFOR(v, b, e)  for (int v = (e) - 1; (b) <= v; --v)
#define REP(v, n)      FOR(v, 0, n)
#define RREP(v, n)     RFOR(v, 0, n)

int main () {
	int N;
	int L[200] = {};
	cin >> N;

	REP(i, N * 2) cin >> L[i];
	sort(L, L + N * 2);

	int sum = 0;
	REP (i, N) {
		sum += min(L[i * 2], L[(i * 2) + 1]);
	}

	cout << sum << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
PII a[222];
int ord[222];
int c[222];

inline bool cmp(const int &lhs, const int &rhs) {
    return a[lhs] < a[rhs];
}

int main() {
    scanf("%d", &n);
    int cnt = 2 * n;
    forn(i, cnt) scanf("%d%d", &a[i].first, &a[i].second);
    forn(i, cnt) ord[i] = i;
    sort(ord, ord + cnt, cmp);
    int ans = 0;
    forn(ii, cnt) {
        int i = ord[ii];
        if (i < n) {
            ++c[a[i].second];
        } else {
            for (int j = a[i].second - 1; j >= 0; --j) {
                if (c[j] > 0) {
                    --c[j];
                    ++ans;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(void) {
	int K, X;
	cin >> K >> X;
	if (X >= 0) {
		if (X + K - 1 <= 1000000) {
			for (int i = X - K + 1; i <= X + K - 1; i++) {
				cout << i<<endl;
			}
		}
		else {
			for (int i = X - K + 1; i <= 1000000; i++) {
				cout << i << endl;
			}
		}
	}
	else {
		if (X - K + 1 >= -1000000) {
			for (int i = X - K + 1; i <= X + K - 1;i++) {
				cout << i << endl;
			}
		}
		else {
			for (int i = -1000000; i <= X + K + 1; i++) {
				cout << i << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<pii> yx;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        yx.emplace_back(y, x - y);
    }
    sort(yx.begin(), yx.end());
    int top = 0;
    int col = 0;
    int ret = h;
    for (int i = 0; i < n; ++i) {
        if (yx[i].second < top)
            continue;
        if (yx[i].first != col) {
            col = yx[i].first;
        }
        if (top == yx[i].second)
            top++;
        if (yx[i].second > top)
            chmin(ret, yx[i].first + yx[i].second - 1);
    }
    cout << ret << "\n";
    return 0;
}

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

int main(){
  long long int MOD=1000000007;
  long long int N, K;
  cin >> N >> K;
  long long int sum=0;
  for(long long int i=K; i<=N+1; i++){
    sum += (N-i+1) * i + 1;
  }
  cout << sum % MOD << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#define N 100
int main(){
  int n,i,j,count=0;
  int A[N];
  int flag=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){  
scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    for(j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	flag=A[j];
        A[j]=A[j-1];
	A[j-1]=flag;
	count++;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    if((a+b)&1)cout<<"IMPOSSIBLE";
    else cout<<(a+b)/2;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin

s = stdin.readline().rstrip()
len_s = len(s)

count0 = 0
count1 = 0
for i in range(len_s):
  if (int(s[i]) == i%2):
    count0 += 1
  if (int(s[i]) != i%2):
    count1 += 1


if (count0 < count1):
  print("{0}".format(count0))
else:
  print("{0}".format(count1))

Measured memory_bytes: 3188
#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>;

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;
}

int main() {
  int x, n;
  cin >> x >> n;
  set<int> s;
  int result = 1 << 30;
  int resultDiff = 1 << 30;
  rep(i, n) {
    int a;
    cin >> a;
    s.insert(a);
  }

  for (int i = 0; i < 102; i++) {
    if (s.count(i) > 0) {
      continue;
    }
    if (abs(i - x) < resultDiff || (abs(i - x) == resultDiff && i < result)) {
      result = i;
      resultDiff = abs(i - x);
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3636
// USACO_2020_1_a.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
//#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
#define endl "\n"
struct el { string word; int x, y, dir; };
int n, m, k, cnt, i, j, a = 0, b = 0, used[100][100], minx=1e9, miny=1e9, maxx=0, maxy=0, cntminx, cntmaxx, cntminy, cntmaxy;
	char c[100][100];
	void dfs(int x, int y)
	{
		if (x < 0) return;
		if (x >= n) return;
		if (y < 0) return;
		if (y>= m) return;
		if (c[x][y] == '#') return;
		if (used[x][y]) return;
		cnt--; used[x][y] = 1;
		dfs(x, y - 1);
		dfs(x, y + 1);
		dfs(x-1 , y);
		dfs(x+1 , y);
		dfs(x+1, y - 1);
		dfs(x-1, y + 1);
		dfs(x - 1, y-1);
		dfs(x + 1, y+1);
	}
int main()
{
//	freopen("cartin.txt", "r", stdin);
//	freopen("cartout.txt", "w", stdout);
	cin >> m >> n;
	cout << (m > n ? "No" : "Yes");
	fclose(stdin);
	fclose(stdout);
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int d,n,i,k,p=0,t,a[3]={1,100,10000};
	cin>>d>>n;
	for (i=a[d];;i+=a[d]){
		t=i;
		k=0;
		while (t%100==0){
			t/=100;
			k++;
		}
		if (k==d){
			p++;
		}
		if (n==p){
			cout<<i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    rep(i, 0, n) {
        if (s[i] != s[k - 1]) cout << '*';
        else cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   2019
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline int lcm(int a,int b){return ((a*b)/gcd(a,b));}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

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


ll pro=1;
ll cur=0;
ll dp[2019]={0};
dp[cur]++;
for(int i=0;i<n;i++)
{
	ll ne=s[n-i-1]-'0';
	cur=(cur+(pro*ne))%2019;
	pro=mmul(pro,10);
	dp[cur]++;
}



ll ans=0;

for(int i=0;i<2019;i++)
{ll m=dp[i];
	ans+=((m*(m-1))/2);
}


cout<<ans;






}return 0;}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int n;
Graph G;

vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (auto nv : G[v]) {
        if (nv == p) continue;
        dfs(nv, d+1, v);
    }
}

vector<int> calcDist(int s) {
    dist = vector<int>(n, 0);
    dfs(s);
    return dist;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int s, t;
    cin >> n >> s >> t;
    --s, --t;
    G.resize(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> distS = calcDist(s);
    vector<int> distT = calcDist(t);

    int mx = 0;
    rep(i, n) {
        if (distS[i] < distT[i]) {
            chmax(mx, distT[i]);
        }
    }

    cout << mx - 1 << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	cout << d[N / 2] - d[N / 2 - 1] << endl;

	return 0;
}


Measured memory_bytes: 640
A,B,C,X,Y=map(int,input().split())
M=[A,B,C]

ans=[]

ans.append(A*X+B*Y)
ans.append(C*max(X,Y)*2)

if X>Y:
  ans.append(C*min(X,Y)*2+A*(X-min(X,Y)))
if Y>X:  
  ans.append(C*min(X,Y)*2+B*(Y-min(X,Y)))

print(min(ans))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
 
using namespace std;
typedef long long ll;
const int N = 9;
const int MAXN = 15;
 
int n, m, Map[MAXN][MAXN];
 
int main(){
	scanf( "%d%d", &n, &m );
	for( int i = 0; i <= N; ++i )
		for( int j = 0; j <= N; ++j )
			scanf( "%d", &Map[i][j] );
	for( int k = 0; k <= N; ++k )
		for( int i = 0; i <= N; ++i )
			for( int j = 0; j <= N; ++j )
				Map[i][j] = min( Map[i][j], Map[i][k] + Map[k][j] );
	ll ans = 0;
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j ){
			int x; scanf( "%d", &x );
			if( x == -1 || x == 1 ) continue;
			ans += Map[x][1];
		}
	printf( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
N = int(input())
A = list(map(int, input().rstrip().split()))
cnt = 0
perfect = 0
while perfect == 0:
    for i in range(N):
        if A[i] % 2:
            perfect = 1
        else:
            A[i] //= 2
    if perfect == 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
vector<int> v, op;
int a[100005];
int main(){
    int n, ans = 0;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    sort(a+1, a+1+n);
    v.push_back(a[n]);
    v.push_back(a[1]);
    op.push_back(-1);
    ans += a[n];
    ans -= a[1];
    for(int i=2;i<=n-1;i++){
        if(a[i] < 0) v.push_back(a[i]), op.push_back(-1), ans += -a[i];
        else v.push_back(a[i]), op.push_back(1), ans += a[i];
    }
    printf("%d\n", ans);
    bool f = 0;
    int j = 1;
    int sum = 0;
    for(int i=1;i<op.size();i++){
        if(op[i] == 1){
            sum = v[i];
            for(int k=i;k<op.size();k++){
                printf("%d %d\n", sum, v[k+1]);
                sum -= v[k+1];
            }
            j = i;
            f = 1;
            break;
        }
    }
    if(!f){
        int sum = v[0];
        for(int i=0;i<v.size()-1;i++){
            printf("%d %d\n", sum, v[i+1]);
            sum -= v[i+1];
        }
    }
    else{
        int sum2 = v[0];
        for(int i=0;i<j-1;i++){
            printf("%d %d\n", sum2, v[i+1]);
            sum2 -= v[i+1];
        }
        printf("%d %d\n", sum2, sum);
    }
}

Measured memory_bytes: 3316
def merge(l):
    t = [-1]*len(l)
    if(len(l) == 2):
        if(l[0]<l[1]):
            t[1] = l[0]
            t[0] = l[1]
        else:
            t=l
    elif(len(l) > 2):
        x = merge(l[:len(l)//2])
        y = merge(l[len(l)//2:])
        p,q = 0,0
        for i in range(len(l)):
            if(p<len(x) and q<len(y)):
                if(x[p] > y[q]):
                    t[i] = x[p]
                    p += 1
                else:
                    t[i] = y[q]
                    q += 1
            elif(p == len(x)):
                t[i] = y[q]
                q += 1
            else:
                t[i] = x[p]
                p += 1
    else:
        t = l
    return t
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
a = [x,y,0]
P = merge(p)
Q = merge(q)
R = merge(r)
X = P[:x]
Y = Q[:y]
for i in range(x+y):
    if(a[2] == c):
        break
    elif(a[0] == 0):
        if(Y[a[1]-1] < R[a[2]]):
                a[1] -= 1
                a[2] += 1
        else:
            break
    elif(a[1] == 0):
        if(X[a[0]-1] < R[a[2]]):
                a[0] -= 1
                a[2] += 1
        else:
            break
    else:
        if(X[a[0]-1] > Y[a[1]-1]):
            if(Y[a[1]-1] < R[a[2]]):
                a[1] -= 1
                a[2] += 1
            else:
                break
        else:
            if(X[a[0]-1] < R[a[2]]):
                a[0] -= 1
                a[2] += 1
            else:
                break
m = 0
for i in range(a[0]):
    m += P[i]
for i in range(a[1]):
    m += Q[i]
for i in range(a[2]):
    m += R[i]
print(m)

Measured memory_bytes: 22716
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}



int  H,W,c[11][11],ans,N,A,B;
string S,s;


int main() {
	cin >> N;
	B = N;
	A = 10;
	ans = 0;
	while (B!=0) {
		H = B % 10;
		ans += H;
		B = B / 10;
	}

	if (N%ans==0){
	cout << "Yes" << endl; 
	}else{
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;



int main(){
    string s;
    cin>>s;
    int n=s.size();
    int r=0,l=0;
    ll ans=0,a,b;
    for(int i=0;i<n;i++){
        if(s[i]=='>' && s[i+1]=='<'){
            l++;
            a=max(r,l);
            b=min(r,l)-1;
            ans+=((a+1)*a/2);
            ans+=((b+1)*b/2);
            r=0;
            l=0;
        } 
        else if(s[i]=='>') l++;
        else r++;
    }
    //cout<<r<<""<<l<<endl;
    if(r>0 || l>0){
        a=max(r,l);
        b=min(r,l)-1;
        ans+=((a+1)*a/2);
        ans+=((b+1)*b/2);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#define ll long long
using namespace std;

vector<int> a;
ll k;
int ans;
bool ok = false;
int start, cnt1;
void dfs(int u) {
    if (k == 0) {ans = u; return;}
    k--;
    dfs(a[u]);
}

void dfs1(int u, vector<int>& vis, int& cnt) {
    if (vis[u] == 2){start = u; return;}
//    cout<< u + 1 <<" -> ";
    if (vis[u]) {
        ok = true;
    }else cnt1++;
    if (ok) {
        cnt++;
    }
    vis[u]++;
    dfs1(a[u], vis, cnt);
}

int main() {
    int n;
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    if (k <= 2e5) {
        dfs(0);
    }else{
        int cnt = 0;
        vector<int> vis(n, 0);
        dfs1(0, vis, cnt);
        cnt1-=cnt;
        k -= (cnt1);
        k %= cnt;
//        cout<<k;
//        cout<<start;
        dfs(start);
    }
    cout<<ans + 1;
}


Measured memory_bytes: 4784
#include<iostream>
#include<cstring>
using namespace std;
int judge(int);
char S[100];
char l[16]="qwertasdfgzxcvb";
int main()
{
  int i,sum=0;
  int SS[100];

  while(1){
    cin>>S;
    if(S[0]=='#')break;

    for(int i=0;i<strlen(S);++i){
      SS[i]=judge(i);
    }
    for(int i=0;i<strlen(S)-1;++i){
      if(SS[i]!=SS[i+1]){sum++;
      }
    }
    cout << sum<<endl;
    sum=0;
  }
  return 0;
}

int judge(int ii)
{
  for(int i=0;i<15;++i){
    if(S[ii]==l[i])return 1;
  }
  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

    vector<vector<ll>> dp(s.size() + 1, vector<ll>(t.size() + 1, 0));
    vector<vector<pair<ll, ll>>> pre(s.size() + 1, vector<pair<ll, ll>>(t.size() + 1, {-1, -1}));

    ll max_value = -1;
    for (ll i = 0; i < s.size(); i++) {
        for (ll j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) {
                if (dp[i][j] + 1 > dp[i + 1][j + 1]) {
                    max_value = max(max_value, dp[i + 1][j + 1] = dp[i][j] + 1);
                    pre[i + 1][j + 1] = {i, j};
                }
            }

            if (dp[i][j] > dp[i + 1][j]) {
                dp[i + 1][j] = dp[i][j];
                pre[i + 1][j] = {i, j};
            }
            if (dp[i][j] > dp[i][j + 1]) {
                dp[i][j + 1] = dp[i][j];
                pre[i][j + 1] = {i, j};
            }
        }
    }

    string ans;
    for (ll i = 0; i <= s.size(); i++) {
        for (ll j = 0; j <= t.size(); j++) {
            if (dp[i][j] == max_value) {
                while (pre[i][j].first != -1) {
                    auto p = pre[i][j];
                    if (0 <= p.first && p.first < i && 0 <= p.second && p.second < j && s[p.first] == t[p.second]) {
                        ans += s[p.first];
                        max_value--;
                    }
                    i = p.first;
                    j = p.second;
                }
                i = s.size() + 1;
                j = t.size() + 1;
            }
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 211712
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

const int MaxN = 2e5 + 5;

vector<int> gb[MaxN], gr[MaxN];

int dep[MaxN], fa[MaxN], d[MaxN];
bool safe[MaxN], vis[MaxN];

int main() {
  ios_base::sync_with_stdio(false);
  int n, sx, sy;
  cin >> n >> sx >> sy;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    gr[x].emplace_back(y);
    gr[y].emplace_back(x);
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    gb[x].emplace_back(y);
    gb[y].emplace_back(x);
  }
  queue<int> Q;
  Q.push(sy);
  fa[sy] = -1;
  vis[sy] = true;
  while (!Q.empty()) {
    int k = Q.front();
    for (int x : gb[k]) {
      if (!vis[x]) {
        Q.push(x);
        vis[x] = true;
        dep[x] = dep[k] + 1;
        fa[x] = k;
      }
    }
    Q.pop();
  }
  for (int i = 1; i <= n; ++i) {
    for (int k : gr[i]) {
      if (![](int x, int y) -> bool {
        return fa[x] == fa[y] || fa[x] == y || x == fa[y] || fa[fa[x]] == y || x == fa[fa[y]];
      } (i, k)) {
        safe[i] = safe[k] = true;
      }
    }
  }
  if (safe[sx]) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  memset(d, 0xff, sizeof d);
  memset(vis, 0x00, sizeof vis);
  d[sx] = 0;
  Q.push(sx);
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    if (d[k] >= dep[k]) {
      continue;
    }
    if (safe[k]) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, dep[k] * 2);
    for (int x : gr[k]) {
      if (!vis[x] && d[k] + 1 < dep[x] && [](int x, int y) -> bool {
        return fa[x] == fa[y] || fa[x] == y || x == fa[y] || fa[fa[x]] == y || x == fa[fa[y]];
        } (k, x)) {
        d[x] = d[k] + 1;
        vis[x] = true;
        Q.push(x);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 26996
# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int,input().split()))

count = N
Sum = 0
r = 1
Sum = A[0]

for l in range(0, N-1):

    while r < N and Sum + A[r] == Sum ^ A[r]:
            #print(l,r)
            Sum += A[r]
            r += 1
    count += r-l-1

    Sum -= A[l]    

print(count)

Measured memory_bytes: 32044