akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  ll pre;
  ll kine = n;

  vP ps(n);
  rep(i,n) cin >> ps[i].first >> ps[i].second;
  Sort(ps);

  rep(i, n) {
    ll x, l;
    tie(x, l) = ps[i];
    if(i == 0) pre = x + l;
    else {
      if(x - l < pre) {
        kine--;
        pre = min(pre, x + l);
      } else pre = x + l;
    }
  }

  cout << kine << endl;

  return 0;
}


Measured memory_bytes: 4828
//31
#include<iostream>

using namespace std;

int dfs(int n){
  if(n<=3){
    return 1;
  }else{
    return dfs((n+2)/3)+1;
  }
}

int main(){
  int n;
  cin>>n;
  cout<<dfs(n)<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
  
void PrintWallLine( int length ) {
  using namespace std;
  for ( int i = 0; i < length; ++i ) {
    cout << '#';
  }
  cout << endl;
}
  
void PrintRoomLine( int length ) {
  using namespace std;
  
  for ( int i = 0; i < length; ++i ) {
    if ( i == 0 || i == length - 1 ) {
      cout << '#';
    } else {
      cout << '.';
    }
  }
  cout << endl;
}
  
void PrintArea ( int H, int W ) {
  using namespace std;
  
  for ( int i = 0; i < H; ++i ) {
    if ( i == 0 || i == H - 1 ) {
      PrintWallLine( W );
    } else {
      PrintRoomLine( W );
    }
  }
  cout << endl;
} 
  
int main() {
  using namespace std;
  
  while ( true ) {
    int H = 0;
    int W = 0;
    cin >> H >> W;
  
    if ( H == 0 && W == 0 ) { break; }
  
    PrintArea( H, W );
  
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define ll long long
#define ld long double
#define MAX (int)(pow(10,5)+10)
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,9);
ll INF = inf;
ll modulo = pow(10,9)+7;
double eps = 1e-10;
ifstream in;
ofstream out;


 
void deal(){
	ll n ,x;
	cin>>n>>x;
	vector<ll> arr(n);
	fori(n)
		cin>>arr[i];
	sort(arr.rbegin(), arr.rend());
	vector<ll> dp(MAX, 0);
	dp[x] = 1;
	fori(n){
		vector<ll> dpn(MAX,0);
		forj(MAX){
			dpn[j%arr[i]]+=dp[j];
			dpn[j] 		 +=(dp[j]*(n-i-1));
			dpn[j%arr[i]]%=modulo;
			dpn[j]		 %=modulo;
		}
		dp = dpn;
	}
	ll sum = 0;
	fori(MAX){
		sum+=dp[i]*i;
		sum%=modulo;
	}
	cout<<sum;
}



int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/*
	
*/

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    int n;
    cin >> n;
    cout << (n+1)/2;
    return 0;
}


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


int main()
{
    int n, k;
    scanf("%d", &n);
    ll ans = 0;
    ll a[n], b[n];
    int nw = 0;
    for(int i = 0; i<n; i++){
        scanf("%lld %lld", &a[i], &b[i]);
        a[i] = (a[i]+b[i]-1)/b[i]*b[i] - a[i];
    }
    ll prv = 0;
    for(int i = n-1; i>=0; i--)
    {
        if(a[i] < prv){
            a[i] += (prv - a[i] + b[i] - 1) / b[i] * b[i];
        }
        prv = a[i];
    }

    ll s = 0;
    for(int i = n-1; i>=0; i--)
        ans += a[i] - s, s += a[i] - s;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

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

using namespace std;

using pii =  pair<int, int>;
using ll = long long;

#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int H, W;
int N;
int a[10004];

int c[102][102];

int main(){
  cin.tie(0);
  
  cin>>H>>W;
  cin>>N;
  REP(i, N)cin>>a[i];

  int x=0, y=0;
  int d=1;

  REP(i, N) {
    REP(j, a[i]) {
      c[y][x] = i+1;
      if(x==0) {
        if(W==1) {
          y++;
          continue;
        }else if(d<0) {
          y++;
          d=1;
          continue;
        }
      }else if(x==W-1) {
        if(d>0) {
          y++;
          d=-1;
          continue;
        }
      }
      x+=d;
    }
  }

  REP(i, H) {
    REP(j, W) {
      cout<<c[i][j];
      if(j<W-1)cout<<' ';
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ansp=0LL;
    ll ansm=0LL;
    ll sump=0LL;
    ll summ=0LL;


    rep(i, n) {
        if(i&1) {
            if(a[i]+sump > 0) {
                sump += a[i];
            } else {
                ansp += 1LL - (a[i]+sump);
                sump = 1LL;
            }
            if(a[i]+summ < 0) {
                summ += a[i];
            } else {
                ansm += (a[i]+summ) + 1LL;
                summ = -1LL;
            }
            
        } else {
            if(a[i]+summ > 0) {
                summ += a[i];
            } else {
                ansm += 1LL - (a[i]+summ);
                summ = 1LL;
            }
            if(a[i]+sump < 0) {
                sump += a[i];
            } else {
                ansp += (a[i]+sump) + 1LL;
                sump = -1LL;
            }
        }
    }

    cout << min(ansm, ansp) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

typedef pair<long long int, long long int> P;

int main() {
	long long int n, c, k;
	cin >> n >> c >> k;
	vector<long long int> t(n);
	priority_queue<P, vector<P>, greater<P> > pq;
	for (long long int i = 0; i < n; i++) {
		cin >> t[i];
		pq.push(P(t[i], t[i]+k));
	}
	long long int aa = 0;
	while (!pq.empty()) {
		aa++;
		P p = pq.top();
		pq.pop();
		long long int r = 1;
		while (!pq.empty() && r < c) {
			P pp = pq.top();
			if (pp.first <= p.second) {
				pq.pop();
				r++;
			} else {
				break;
			}
		}
		//cout << pq.size() << endl;
	}
	cout << aa << endl;
	return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int H = sc.nextInt();
	int W = sc.nextInt();
	String s = "";
	for(int i=0;i<H;i++){
	    s += sc.next();
	}
	s.trim();
	char[][] hw = new char[H][W];
	boolean[] ww = new boolean[W];
	boolean[] hh = new boolean[H];
	for(int i=0;i<H;i++){
	    for(int j=0;j<W;j++){
		hw[i][j] = s.charAt(i*W + j);
		if(hw[i][j] == '#'){
		    ww[j]=true;
		    hh[i]=true;
		}
	    }
	}
	for(int i=0;i<H;i++){
	    boolean isp = false;
	    for(int j=0;j<W;j++){
		if(hh[i]==true && ww[j]==true){
		    System.out.print(hw[i][j]);
		    isp = true;
		}
	    }
	    if(isp){
		if(i!=H-1) System.out.println();
	    }
	}
    }
}


Measured memory_bytes: 29012
#include<stdio.h>
#define N 1201
 
int main(){
  char str[N];
  int i=0,j;
  int number[26];
  char Eng[26]={'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'};
  int num;
  for(j=0;j<26;j++){
    number[j]=0;
  }  
   
  while(1){
    if(scanf("%c",&str[i])==EOF)break;
    if('A'<=str[i]&&str[i]<='Z'){
      str[i]=str[i]+('a'-'A');
    }
    num=str[i] - 'a';
    number[num]++;
    i++;
  }
 
  for(i=0;i<26;i++){
    printf("%c : %d\n",Eng[i],number[i]);
  }
 
  return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<string> &s, string a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    int n, m;
    cin >> n >> m;
    vector<char> boxes(n, 'w');
    vector<int> boxes_c(n, 1);
    boxes[0] = 'r';
    rep(i, m) {
        int x, y;
        cin >> x >> y;

        x--;
        y--;

        char from = boxes[x], to = boxes[y];
        if (from == 'm') boxes[y] = 'm';
        else if (to == 'm') boxes[y] = 'm';
        else if (from == 'w' && to == 'w') boxes[y] = 'w';
        else if ((from == 'w' && to == 'r') || (from == 'r' && to == 'w')) boxes[y] = 'm';
        else if (to == 'n') boxes[y] = from;

        boxes_c[x]--;
        boxes_c[y]++;
        if (boxes_c[x] == 0) boxes[x] = 'n';

    }

    int ans = 0;

    for (char c : boxes) {
        if (c == 'r') {
            cout << 1 << endl;
            return 0;
        }
    }

    for (char b : boxes)if (b == 'm') ans++;
    cout << ans << endl;

}


Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    map<int, i64> mp;
    const int p = 2019, n = s.size();
    i64 cur = 0, k = 1, ans = 0;
    mp[0]++;
    reverse(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        cur += (s[i] - '0') * k;
        cur %= p;
        ans += mp[cur];
        mp[cur]++;
        k = k * 10 % p;
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3732
import sys
rr = lambda: sys.stdin.readline().strip()
ri = lambda: int(rr())
rs = lambda: [int(_) for _ in rr().split()]

N, M, C = rs()
B = rs()
A = [rs() for _ in range(N)]

ans = 0

for a in A:
	s = 0
	for i in range(M):
		s += B[i]*a[i]
	if s > -C:
		ans += 1
		
print(ans)

Measured memory_bytes: 3064
//b.c B-ATCoder
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int main(void){
    char msg[11];
    scanf("%s",msg);
    int max = 0,len = strlen(msg),count = 0;
    bool flag = false;
    for(int i=0;i<len;++i){
        if(msg[i] == 'A' || msg[i] == 'C' || msg[i] == 'G' || msg[i] == 'T'){
            if(!flag){
                count = 1;
            }else{
                count++;
            }
            if(max<count){
                max = count;
            }
            flag = true;
        }else{
            flag = false;
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
import glob

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\95\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        A = q[0]
        B = q[1]
        C = q[2]
        X = q[3]
        Y = q[4]

        if 2*C > A+B:
            result = A * X + B * Y
        else:
            if X > Y:
                result = C * Y * 2
                if A > C * 2:
                    result += (X - Y) * C * 2
                else:
                    result += (X -Y) * A

            else:
                result = C * X * 2
                if B > C * 2:
                    result += (Y - X) * C * 2
                else:
                    result += (Y -X) * B

        print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(void){
    int hight[10], i, j, tmp;
     
    for(i = 0; i < 10; i++) 
        cin >> hight[i];
     
    for(i = 0; i < 10; i++){
        for(j = i + 1; j < 10; j++){
            if(hight[i] >= hight[j]){
                tmp = hight[i];
                hight[i] = hight[j];
                hight[j] = tmp;
            }
        }
    }
     
    for(i = 9; i > 6; i--){
        cout << hight[i] << endl;
    }
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
int A, B, K;
cin >> A >> B >> K;
int cnt = 0;
for(int i = 100; i > 0; i--){ 
     if(A % i == 0 && B % i == 0) cnt++;
     if(cnt == K){
         print(i);
         return 0;
     }
}
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int a = GetInt();
		int b = GetInt();
		int c = GetInt();
		int sum = a + b + c;
		Console.WriteLine(sum - Math.Max(a, Math.Max(b, c)));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
const int mod = 1e9 + 7;

signed main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);    
     
    int bit[65] = {0};
    
    int n, ans = 0; cin >> n;
    int data[n+5];
    
    for(int i = 1; i <= n; i++){
          cin >> data[i];
          int x = data[i];
          for(int j = 0; j <= 60; j++){
                     if((1LL<<j)&x){
                         bit[j]++;
                     }
          }
    }
    
    for(int i = 1; i <= n; i++){
        int x = data[i];
        for(int j = 0; j <= 60; j++){
                 if((1LL<<j)&x){
                     bit[j]--;
                     int zero = n-i-bit[j];
                     zero%=mod;
                     int mul = 1LL<<j; mul%=mod;
                     zero = (zero*mul)%mod;
                     ans = (ans%mod + zero%mod)%mod;
                 }
                 else {
                     int zero = bit[j];
                     zero%=mod;
                     int mul = 1LL<<j; mul%=mod;
                     zero = (zero*mul)%mod;
                     ans = (ans%mod + zero%mod)%mod;
                 }
         }
    }
    
    cout << ans << '\n';
    
}


Measured memory_bytes: 2560
###
num = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]


def binsearch(list,q):
    min = 0
    max = len(list) -1
    mid = (min + max)//2
    while min <= max:
        #print(f"D:{min:>6} {mid:>6} {max:>6}: {list[mid]:>6}")
        if q < list[min]  or list[max] < q:
            return False
        if list[mid] == q:
            return True
        elif list[mid] > q:
            max = mid - 1
            mid = (min + max) // 2
        else:
            min = mid + 1
            mid = (min + max) // 2
    return False

count = 0
for k in t:
    if binsearch(s, k):
        count += 1
print(count)



Measured memory_bytes: 16892
N = int(input())
S = input()

Rs = 0
Gs = 0
Bs = 0
for il in S:
    if il == 'R':
        Rs += 1
    if il == 'G':
        Gs += 1
    if il == 'B':
        Bs += 1
num = 0
for i in range(N):
    for step in range(1, N):
        j = i + step
        k = i + 2*step
        if k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            num += 1
print(Rs*Gs*Bs - num)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n, x, t;
    cin >> n >> x >> t;
    if(n % x == 0) cout << (n / x) * t;
    else cout << ((n / x) + 1) * t;
}   

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define fastio ios::sync_with_stdio(false)
#define FIR first
#define SEC second
#define PB push_back
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
int sum[500000+20]; 
LL a[500000+20],x[500000+20],dp[500000+20][2];
const int MOD=1e9+7; 
map<LL,int> m;
int cnt=0;
vector<int> v[500000+2];
int main(){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout); 
	fastio;
	cin>>n;
	rb(i,1,n) cin>>a[i],x[i]=x[i-1] xor a[i];
	if(x[n]==0){
		LL res=1;
		rb(i,1,n-1)
			if(x[i]==0){
				res<<=1;
				res%=MOD;
			}//每块xor为0 
		rb(i,1,n)
			m[x[i]]=1;
		for(map<LL,int> :: iterator ite=m.begin();ite!=m.end();ite++){
			if(ite->FIR) ite->SEC=++cnt;
		}	
		m[0]=0;
		rb(i,1,n)
			x[i]=m[x[i]],v[x[i]].PB(i);
		rb(i,1,n){		if(x[i]==0) sum[i]=sum[i-1]+1;
			else sum[i]=sum[i-1];} 
		LL dpsum=0;
		rb(j,1,cnt)
		{	LL dpval=0;
			LL dppro=0;
			int las;
			for(int i=0;i<v[j].size();i++){
				int k=v[j][i];
				if(i==0){
					dpval=1;
					dppro=1;
				}		
				else{
					dppro+=dpval*(sum[k]-sum[las])%MOD;
					dppro%=MOD;
					LL now=dppro;
					dpval+=now;
					dpval%=MOD;
				}
				las=k;
			}
			dpsum+=dpval;
			dpsum%=MOD;
		}
		res+=dpsum;
		res%=MOD;
		cout<<res<<endl;
	}
	else{
		LL X=x[n];
		dp[0][0]=1;
		rb(i,1,n)
		{
			dp[i][0]=dp[i-1][0];
			dp[i][1]=dp[i-1][1];
			if(x[i]!=X&&x[i]) continue;
			if(x[i]==X){
				dp[i][1]+=dp[i-1][0];
				dp[i][1]%=MOD;
			}
			else{
				dp[i][0]+=dp[i-1][1];
				dp[i][0]%=MOD;
			}
		}
		cout<<dp[n-1][0]<<endl;
	}
	return 0;
}
/*

3
1 2 3

3
1 2 2

24
1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2
*/

Measured memory_bytes: 52236
program answer
  implicit none

  integer ::a, N

  read(*,*) N

  if (1<N.and.N<105) then
     a = 0
  else if(105<=N.and.N<135) then
     a = 1
  else if(135<=N.and.N<165) then
     a = 2
  else if(165<=N.and.N<189) then
     a = 3
  else if(189<=N.and.N<195) then
     a = 4
  else if(195<=N.and.N<=200) then
     a = 5
  end if

  write(*,*) a
  stop
 end program answer


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

int main()
{
    int N, M;
    cin >> N >> M;

    vector<int> lights[M];
    vector<int> on;
    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s = 0;
            cin >> s;
            s--;
            lights[i].push_back(s);
        }
    }

    for (int i = 0; i < M; i++)
    {
        int p = 0;
        cin >> p;
        on.push_back(p);
    }

    int ans = 0;
    for (long long bit = 0; bit < (1 << N); bit++)
    {
        // それぞれの電球がONになるか確認
        bool ok = true;
        for (int i = 0; i < M; i++)
        {
            int turned_sum = 0;
            for (int light : lights[i])
            {
                if (bit & (1 << light))
                {
                    turned_sum++;
                }
            }
            if (turned_sum % 2 != on[i])
            {
                ok = false;
                break;
            }
        }
        if (!ok)
            continue;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int an(int m){
    if(m==1) return 1;
    else{
        return 3*an(m-1) + 1;
    }
}
 
 
int main(){
    const int MAX=1000000;
    int arr[MAX], G[MAX];
    int N, cnt = 0;
    cin >> N;
     
    int m = (int)(log(2*N+1)/log(3.0));
     
    for(int i=0; i<m; i++){
        G[m-1-i] = an(i+1);
    }
     
    for(int i=0; i<N; i++){
        cin >> arr[i];
    }
     
    for(int k=0; k<m; k++){
        int g = G[k];
         
        for(int i=g; i<N; i++){
            int v = arr[i];
            int j = i - g;
            while(j >= 0 && arr[j] > v){
                arr[j+g] = arr[j];
                j = j - g;
                cnt++;
            }
            arr[j+g] = v;
        }
    }
     
    cout << m << endl;
    for(int i=0; i<m; i++){
        if(i==0){
            cout << G[i];
        }
        else{
            cout << " " << G[i];
        }
    }
    cout << endl;
     
    cout << cnt << endl;
     
    for(int i=0; i<N; i++){
        cout << arr[i] << endl;
    }
     
}

Measured memory_bytes: 7212
#include <stdio.h>

int num[101010];
int dirty[101010];

main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)num[i]=1;
	dirty[0]=1;
	
	for(int t=0;t<m;t++){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		
		if(dirty[x]==1)dirty[y]=1;
		num[x]--;
		num[y]++;
		if(num[x]==0)dirty[x]=0;
	}
	int ans=0;
	for(int i=0;i<n;i++)if(dirty[i]==1)ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 896
#include<stdio.h>
int main()
{
    int n,mod;
    scanf("%d",&n);
    mod=n%10;
    if(mod==2 || mod==4 || mod==5 || mod==7 || mod==9)
    {
        printf("hon");
    }
    if(mod==0 || mod==1 || mod==6 || mod==8)
    {
        printf("pon");
    }
    if(mod==3)
    {
        printf("bon");
    }
return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
#include <math.h>
struct xy{
	double x;
	double y; 
};
int kock(int n,struct xy,struct xy);
int main(){
	struct xy p1 ={0,0}, p2 ={100,0};
	int n;
	scanf("%d",&n);
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	kock(n,p1,p2);
	printf("%.8lf %.8lf\n",p2.x,p2.y);
	return 0;
}

int kock(int n,struct xy p1,struct xy p2){
	struct xy s,t,u;
	if(n==0) return 0;
	s.x = (2*p1.x+1*p2.x)/3;
	s.y = (2*p1.y+1*p2.y)/3;
	t.x = (1*p1.x+2*p2.x)/3;
	t.y = (1*p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)/2 -(t.y-s.y)*sqrt(3)/2 +s.x;
	u.y=(t.x-s.x)*sqrt(3)/2 +(t.y-s.y)/2 +s.y;
	kock(n-1,p1,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	kock(n-1,t,p2);
}


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

Measured memory_bytes: 128
using System;
public class Class1
{
	public static void Main()
	{
		string dataSet =Console.ReadLine();
		string[] data=dataSet.Split();
		int n=int.Parse(data[0]);//row
		int m=int.Parse(data[1]);//column		
		int[] columnSum=new int[m];
		int sum=0;
		
		for (int i =0; i < n; i++)
		{
			string matrixSet =Console.ReadLine();
			string[] matrix=matrixSet.Split();
			int a=0;
			int rowSum=0;
			for(int j =0;j<m;j++)
			{
				a=int.Parse(matrix[j]);
				rowSum+=a;
				columnSum[j]+=a;
			}	
			Console.WriteLine(matrixSet+" "+rowSum);
			sum+=rowSum;			
		}
	
		for(int k=0;k<m;k++)
		{				
				Console.Write(columnSum[k]+" ");				
		}
		Console.Write(sum+"\r\n");		
	}		
}

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 


int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] and s[4]==s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int ans = 0;
    for(int i = 1; i <= n-1; i++) {
        string x = s.substr(0, i);
        string y = s.substr(i, n-i);
        
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++) {
            int flagX = 0;
            int flagY = 0;
            rep(j, x.size()) {
                if(x[j] == c) {
                    flagX = 1;
                    break;
                }
            }
            rep(j, y.size()) {
                if(y[j] == c) {
                    flagY = 1;
                    break;
                }
            }
            if(flagX && flagY) {
                cnt++;
            }
        }

        ans = max(ans, cnt);
    }

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

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

typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

ll llpow(ll a, ll x){
    ll res = 1;
    REP(i,x){
        res *= a;
    }
    return res;
}

ll f(ll x){
    if(x<=1)return 1;
    else return 9*(llpow(2,x-1)-1);
}

ll g(ll x){
    if(x<=1)return 1;
    else return (llpow(2,x-1));
}

int main() {
    while(1){
        ll n;
        cin >> n;
        if(n == 0)break;
        ll sum = 0, k = 2;
        while(1){
            ll tmp;
            tmp = 45*(llpow(2,k)-2) - f(k);
            if(sum+tmp >= n)break;
            sum += tmp;
            k++;
        }
        vector<int> ans,use;
        REP(i,k){
            REP(j,10){
                if(i==0&&j==0)continue;
                if(i==k-1 && use.size()==1 && ans[0]==j)continue;
                ll tmp;
                if(i==0||j==ans[0]){
                    tmp = f(k-i);
                }
                else{
                    tmp = g(k-i);
                }
                if(sum+tmp>=n){
                    ans.push_back(j);
                    if(use.size()==0 || ans[0]!= j){
                        use.push_back(j);
                    }
                    break;
                }
                sum += tmp;
            }
            if(use.size()>1)break;
        }
        sort(use.begin(),use.end());
        while(ans.size()<k){
            REP(j,2){
                ll tmp;
                tmp = g(k-ans.size());
                if(sum+tmp>=n){
                    ans.push_back(use[j]);
                    break;
                }
                sum += tmp;
            }
        }

        REP(i,k){
            cout << ans[i];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
h, n = map(int, input().split())
magic_cost = []
for _ in range(n):
    magic, cost = map(int, input().split())
    magic_cost.append((magic, cost))

dp = [float('infinity')] * h

for i in range(h):
    for j in range(n):
        magic, cost = magic_cost[j]
        if i >= magic:
            dp[i] = min(dp[i], dp[i - magic] + cost)
        else:
            dp[i] = min(dp[i], cost)

print(dp[-1])

Measured memory_bytes: 44064
from collections import defaultdict
dct=defaultdict(int)
dct2=defaultdict(int)

h,w=map(int,input().split())
for i in range(h):
  s=input()
  for j in range(w):
    dct[s[j]]+=1


for k,v in dct.items():
  dct2[4]+=v//4
  dct2[2]+=v//2-2*(v//4)
  dct2[1]+=v%2


f=0

if h%2==0 and w%2==0:
  if dct2[1]==dct2[2]==0:
    f=1
elif h%2==1 and w%2==1:
  if dct2[1]==1 and dct2[4]>=((h-1)*(w-1))//4:
    f=1
elif h%2==1:
  if dct2[1]==0 and dct2[4]>=((h-1)*(w))//4:
    f=1
else:
  if dct2[1]==0 and dct2[4]>=((w-1)*(h))//4:
    f=1

if f==1:print("Yes")
else:print("No")

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N , A, B; cin >> N >> A >> B;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;

  ll cab = 0, cb = 0, w = 0;
  rep(i, N) {
    bool ok = false;
    switch(s[i]) {
    case 'a':
      if(cab < A + B) {
	ok = true;
	cab++;
      }
      break;
    case 'b':
      cb ++;
      if(cab < A + B && cb <= B) {
	ok = true;
	cab++;
      }
      break;
    case 'c':
	break;
    }
    cout << (ok?"Yes":"No") << endl;
  }
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  ll k; cin >> k;
  vector<ll> p(n);
  for (ll i=0; i<n; i++){
    cin >> p[i]; p[i]--;
  }
  vector<ll> c(n);
  for (ll i=0; i<n; i++){
    cin >> c[i];
  }

  ll ans = -inf;
  for (ll i=0; i<n; i++) {
    vector<bool> used(n, false);
    ll pointer = i;
    while (!used[pointer]) {
      used[pointer] = true;
      pointer = p[pointer];
    }
    ll t = 0;
    ll loopscore = 0;
    rep(i, n) {
      if (used[i]) {
        t++;
        loopscore += c[i];
      }
    }

    ll tk = k;
    ll tmp = 0;
    if (tk/t >= 2) {
      ll g = tk/t - 1;
      tk -= g*t;
      if (loopscore > 0) tmp += loopscore*g;
    }
    tmp += c[i];
    ll mx = tmp;
    pointer = i;
    for (int j=0; j<tk; j++) {
      mx = max(mx, tmp);
      pointer = p[pointer];
      tmp += c[pointer];
    }

    ans = max(ans, mx);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

bool ok[10000][1000];

signed main(){
	int n,m;
	while(cin >> n >> m,n){
		int s[1000],ans = 0,point[10000] = {};
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++) ok[i][j] = false;
		}
		for(int i = 0;i < m;i++){
			int k;
			cin >> s[i] >> k;
			for(int j = 0;j < k;j++){
				int c;
				cin >> c; c--;
				if(k == 1){
					point[c] += s[i];
					s[i] = 0;
				}
				ok[c][i] = true;
			}
		}
		for(int i = 0;i < n;i++){
			int score = point[i],mi = INF;
			for(int j = 0;j < n;j++){
				if(i != j) mi = min(mi,point[j]);
			}
			for(int j = 0;j < m;j++){
				if(ok[i][j]) score += s[j];
			}
			ans = max(ans,score - mi);
		}
		cout << ans + 1 << endl;
	}
}


Measured memory_bytes: 12944
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n] <- readInt
  a <- readInt
  print $ solve a

solve a = length a - ((a' + 1) `div` 2) * 2
  where
    a' = sum $ map ((\x -> x - 1) . length) (group $ sort a)

Measured memory_bytes: 19836
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    R = list(reversed(sorted(zip(a, b), key=lambda x: x[1])))
    B = sorted(zip(c, d), key=lambda x: x[0])
    P = [0] * N
    counter = 0
    for b in B:
        for i, (a, p) in enumerate(zip(R, P)):
            if p == 0 and a[0] < b[0] and a[1] < b[1]:
                P[i] = 1
                counter += 1
                break
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)  # type: "List[int]" 
    d = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5352
// AOJ 2383: Rabbit Game Playing
// 2017.10.4 bal4u@uu
// 2017.11.12

#include <stdio.h>
#include <stdlib.h>

#define M 1000000007
int d[100002], n;
int f[100002];

int cmp(int *a, int *b) { return *a - *b; }

int bsch(int x)
{
	int m, l = 0, r = n;

    while (l < r) {
        m = (l + r) >> 1;
        if (d[m] < x) l = m + 1; else r = m;
    }
	return l;
}

char buf[20], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int t, i, j, v, vmin, vmax;
	long long ans;

	fgets(p=buf, 20, stdin);
	n = getint(), p++, t = getint();
	fgets(p=buf, 10, stdin), vmin = vmax = v = getint(), f[v] = 1;
	i = n-1; while (i--) {
		fgets(p=buf, 10, stdin);
		v = getint(), f[v]++;
		if (v < vmin) vmin = v;
		else if (v > vmax) vmax = v;
	}
	for (j = 0, i = vmin; i <= vmax; i++) while (f[i]) d[j++] = i, f[i]--;

    for (ans = 1, i = 0; i < n; i++) ans = (ans * (i+1-bsch(d[i]-t))) % M;
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
def solve():
    from collections import deque
    def bfs(start):
        q = deque()
        q.append(start)
        
        unvisited = [True] * (n + 1)
        unvisited[start] = False
        
        distances = [0] * (n + 1)
        
        while q:
            x = q.popleft()
            for i, d in adj_list[x]:
                if unvisited[i]:
                    q.append(i)
                    unvisited[i] = False
                    distances[i] = distances[x] + d    
        
        max_d = max(distances)
        return (distances.index(max_d), max_d)
    
    import sys
    file_input = sys.stdin
    while True:
        n = int(file_input.readline())
        if n == 0:
            break
        
        p = list(map(int, file_input.readline().split()))
        d = list(map(int, file_input.readline().split()))
        
        end_bridges_weight = 0
        adj_list = [[] for i in range(n + 1)]
        s = 0
        for i1, i2, b_l in zip(range(2, n + 1), p, d):
            if i1 not in p[i1-1:]:
                end_bridges_weight += b_l
            else:
                s = i1
                adj_list[i1].append((i2, b_l))
                adj_list[i2].append((i1, b_l))
        
        if p.count(1) == 1:
            del adj_list[2][0]
            end_bridges_weight += d[0]
        
        e, dm = bfs(s)
        e, dm = bfs(e)
        
        ans = sum(d) * 3 - end_bridges_weight * 2 - dm
        print(ans)

solve()


Measured memory_bytes: 6296
from sys import stdin


def main():
    O = stdin.readline().rstrip()
    E = stdin.readline().rstrip()
    for o, e in zip(O, E):
        print(o, e, sep='', end='')
    if len(O) > len(E):
        print(O[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 200005;
const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll a,b,c; cin >> a >> b >> c;
	int ans = -1;
	for(int i=1;i<MAXN;i++){
		if(a%2 == 1 || b %2 == 1 || c % 2 == 1){
			ans = i-1; break;
		}
		ll ta,tb,tc; ta = a; tb = b; tc = c;
		a = tb/2 + tc/2;
		b = ta/2 + tc/2;
		c = ta/2 + tb/2;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int main(int argc,char const* argv[])
{
  int n,m;
  bool put[200005];
  memset(put,0,sizeof(put));
  vector<int> appear;
  vector<int> inp;
  cin >> n >> m;
  for(int i=0;i<m;i++)
    {
      int e;
      cin >> e;
      inp.push_back(e);
    }
  for(int i=m-1;i>=0;i--)
    {
      if(!put[inp[i]])
	{
	  put[inp[i]]=true;
	  cout << inp[i] << endl;
	}
    }
  for(int i=1;i<=n;i++)
    {
      if(!put[i]) cout << i << endl;
    }

  return 0;
}



Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n,q;
	cin >> n >> q;
	vector<queue<int> > v(n);

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int x,t;
			cin >> t >> x;
			v[t].push(x);
		}
		else if (c == 1) {
			int t;
			cin >> t;
			if(!v[t].empty()) cout << v[t].front() << endl;
		}
		else {
			int t; cin >> t;
			if (!v[t].empty()) v[t].pop();
		}
	}
}
	



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

int main() {
    int N, a[100000];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    int b[100000] = {0};
    for (int i = 0; i < N; ++i) ++b[a[i]];

    int max = 0;
    for (int i = 1; i < 99999; ++i) {
        int sum = b[i - 1] + b[i] + b[i + 1];
        if (sum > max) {
            max = sum;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1]={0};
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(ll i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 5140
import re
s=input()
if re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

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

#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164


int main(){
	int k;
	cin >> k;
	int a,b;
	cin >> a >> b;
	for(int i = a; i <= b; ++i){
		if(i%k == 0){
			cout << "OK\n";
			return 0; 
		}
	}
	cout << "NG\n";
	return 0;
}

Measured memory_bytes: 3632
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(10e9)


def knapSack(W, wt, val, n):
    K = [[0 for x in range(W + 1)] for x in range(n + 1)]
    for i in range(n + 1):
        for w in range(W + 1):
            if i == 0 or w == 0:
                K[i][w] = 0
            elif wt[i - 1] <= w:
                K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w])
            else:
                K[i][w] = K[i - 1][w]

    return K[n][W]

n,w=mdata()
val=[0]*(n)
wt=[0]*(n)
for i in range(n):
    wt[i],val[i]=mdata()
print(knapSack(w,wt,val,n))

Measured memory_bytes: 171528
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

count = 1
tmpp, tmpq = 0, 0
li = []

for i in range(1, n + 1):
    li.append(i)

pattern = list(itertools.permutations(li))

for i in pattern:
    if i == p:
        tmpp = count

    if i == q:
        tmpq = count

    count += 1

print(abs(tmpp - tmpq))


Measured memory_bytes: 8052