akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

ll INF = 10e10;
int chmin(int a, int b){
  if (a > b){
    return b;
  }
  return a;
}

int main(){
  int N; cin >> N;
  vector<int> h(N);
  vector<ll> dp(N, 0);
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  
  for (int i = 2; i < N;i++){
    dp[i] = chmin(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]));
  }
  
  cout << dp[N-1];
  
  return 0;
}

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define ull unsigned long long
#define mod (ll)(1000000007)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))
#define S second
#define F first
#define mem(arr,a) memset(arr,a,sizeof arr)
//  freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ll fp(ll n , ll p )
{
    if(p==0)
        return 1 ;
    if(p==1)
        return n%mod ;
    ll res ;
    res = fp(n,p/2)%mod;
    res = (res*res)%mod ;
    if(p%2)
        res = (res*n)%mod ;
    return res;
}


int main()
{
    ENGZ;
    ll n , m, a, ans = 0 ;
    priority_queue<ll> pq;
    cin>>n >>m ;
    for(int i=0; i<n ; i++)
    {
        cin>>a ;
        pq.push(a);
    }
    for(int i=0 ; i<m ; i++)
    {
        a = pq.top();
        pq.pop();
        a/=2 ;
        pq.push(a);
    }
    while(sz(pq))
    {
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans <<endl ;
}


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

int main() {
  int N;
  cin >> N;
  bool win1 = false;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (tmp % 2 == 1) {
      win1 = true;
      break;
    }
  }
  if (win1) cout << "first" << endl;
  else cout << "second" << endl;
}


Measured memory_bytes: 3628
N = int(input())
R = [[] for i in range(N)]
B = [[] for i in range(N)]
for i in range(N):
  R[i] = [int(x) for x in input().split()]
for i in range(N):
  B[i] = [int(x) for x in input().split()]
B.sort()
cnt = 0
for i in range(N):
  pair = [N, -1]
  for j in range(N):
    if R[j][0] < B[i][0] and R[j][1] < B[i][1]:
      if R[j][1] > pair[1]:
        pair = [j, R[j][1]]
  if pair[0] < N:
    cnt += 1
    R[pair[0]][1] = 2 * N
print(cnt)

Measured memory_bytes: 39280
N, A, B = map(int, input().split())

diff = B - A - 1

if diff % 2 == 0:
    # A += diff // 2
    # B -= diff // 2
    # 次はAで結局Aが詰む
    print('Borys')

else:
    # A += diff // 2 + 1
    # B -= diff // 2
    # 次はB
    print('Alice')

Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

string s, t;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  // cout << s << endl;
  // cout << t << endl;

  bool ans = true;
  int i = 0, j = 0;
  while (i < s.size() && j < t.size()) {
    if (s[i] > t[i]) {
      cout << "No" << endl;
      return 0;
    }
    else if (s[i] < t[i]) {
      cout << "Yes" << endl;
      return 0;
    }
    i++, j++;
  }
  // s[i] == t[j]
  if (s.size() < t.size()) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}


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

    ll H=in(), W=in();
    ll S[50][50] = {0};

    rep(i, H) {
        rep(j, W) {
            char buff;
            cin >> buff;
            if (buff == '#')
                S[i][j] = 1;
        }
    }

    // 全てのマスをチェック
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == 1) {
                // 上下左右に塗るマスがあればよい
                // 上
                if (i!=0 && S[i-1][j]==1) {
                    // cout << 'a' << endl;
                    continue;}
                // 下
                if (i!=H-1 && S[i+1][j]==1) {
                    // cout << 'b' << endl;
                    continue;}
                // 左
                if (j!=0 && S[i][j-1]==1) {
                    // cout << 'c' << endl;
                    continue;}
                // 右
                if (j!=W-1 && S[i][j+1]==1) {
                    // cout << 'd' << endl;
                    continue;}

                // ない
                cout << "No" << endl;
                return 0;
            }
        }
    }

    // rep(i, H)
    //     rep(j, W)
    //         cout << S[i][j];
    //     cout << endl;
    // cout << endl;

    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
n = int(input())
strings = input()
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

new_strings = ''
for s in strings:
    index = letters.index(s)
    added_index = index + n
    new_index = added_index % 26
    new_s = letters[new_index]
    new_strings += new_s

print(new_strings)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int n,a,b;
    scanf("%d",&n);

    if(n == 1)
    {
        printf("Hello World\n");
        return 0;
    }

    else
    {
        scanf("%d",&a);
        scanf("%d",&b);

        printf("%d\n",a+b);
        return 0;
    }

}


Measured memory_bytes: 128
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    M = int(readline())
    print(48-M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9056
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

int kakuketanosum(int n) {
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n = n / 10;
	}
	/*if (s >= 10)
		s = kakuketanosum(s);
	else*/
		return s;
}
int main(void) {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	double s = 1;
	for (int i = 0; i < n; i++) {
		s *= a[i];
	}
	double sum = 0;
	for (int i = 0; i < n; i++) {
		sum += (s / a[i]);
	}
	cout << fixed << setprecision(10);
	cout << s / sum << endl;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, Q;
int A[100111];

LL sums[100111];
LL suma[100111];

void MAIN() {
    scanf("%d%d", &N, &Q);
    REP (i, N) scanf("%d", A+i);

    REP (i, N) sums[i+1] = sums[i] + A[i];
    REP (i, N) suma[i+1] = (i? suma[i-1]: 0) + A[i];

    REP (i, Q) {
	int x;
	scanf("%d", &x);

	int lo = 0, hi = N;
	while (hi - lo > 1) {
	    int mid = (lo + hi) / 2;
	    if (mid * 2 - 1 <= N && A[N-mid] - x >= x - A[N-mid-mid+1]) {
		lo = mid;
	    } else {
		hi = mid;
	    }
	}

	LL ans = (sums[N]-sums[N-lo]) + (N-lo-lo >= 0? suma[N-lo-lo]: 0);
	//eprintf("%lld %lld\n", sums[N]-sums[N-lo], suma[N-lo-lo]);
	printf("%lld\n", ans);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3712
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import bisect
import math


def main():
    s =input()

    for i in range(len(s)-5):
        for j in range(i, len(s)):
            if s[:i] + s[j:] == "keyence":
                print("YES")
                exit()

    print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
n=int(input())
s=input()

c_e=0

for i in range(1,n):
	if s[i]=='E':
		c_e+=1

cnt=[]
c_w=0
cnt.append(c_e)

for i in range(1,n):
	if s[i-1]=='W':
		c_w+=1
	if s[i]=='E':
		c_e-=1
	cnt.append(c_w+c_e)

print(min(cnt))

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	string S;
	cin>>N>>S;

	int r=count(all(S),'R');
	if(r>N-r)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    string s;
    cin >> s;
    
    ll a[200020];
    for (int i = 0; i < s.size(); i++) {
        if (i == 0) {
            if (char(s[i]) == 'A') a[i] = 1;
            else a[i] = 0;
        }
        else {
            if (char(s[i]) == 'A') a[i] = a[i - 1] + 1;
            else a[i] = a[i - 1];
        }
    }
    /*
    for (int i = 0; i < s.size() - 1; i++) {
        if (i == 0) bc[i] = 0;
        else {
            if (char(s[i]) == 'B' && char(s[i]) == 'C') bc[i] = bc[i - 1] + 1;
            else bc[i] = bc[i - 1];
        }
    }*/
    
    /*for (int i = 0; i < s.size(); i++) cout<<a[i] << " ";
    cout <<endl;*/
    
    ll ans = 0, cc_idx = -1;
    for (int i = 0; i < s.size() - 1; i++) {
        string bc_check;
        bc_check += s[i];
        bc_check += s[i + 1];
        if (bc_check == "BC") {
            if (cc_idx == -1) ans += a[i];
            else ans += a[i] - a[cc_idx];
        }
        else if (bc_check == "AC" || bc_check == "CC" || bc_check == "BB") cc_idx = i + 1;
        else if (bc_check == "BA") cc_idx = i;
    }
    
    cout << ans << endl;
}




Measured memory_bytes: 2180
#include<iostream>
#include<math.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define lrep(i,n) for(long int i=0;i<(n);i++)
using namespace std;
int main(){
	double a;
	cin >>a;
	string b;
	cin >>b;
	unsigned long long int c=a,d=b[0]*100+b[2]*10+b[3]-111*'0';
	cout<<(c*d/100);
}

Measured memory_bytes: 3760
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var N = cin.ReadInt;
                var M = cin.ReadInt;

                var ans = (1900 * M + 100 * (N - M)) * (1 << M);
                WriteLine(ans);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


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

using namespace std;

#define INF 10000000

int main()
{
  int n,m,s,g1,g2;
  for(;cin>>n>>m>>s>>g1>>g2,n;)
    {
      int d[n][n];
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  if(i==j)
	    d[i][j]=0;
	  else
	    d[i][j]=INF;
      for(int i=0;i<m;i++)
	{
	  int b1,b2,c;
	  cin>>b1>>b2>>c;
	  d[b1-1][b2-1]=c;
	}
      
      for(int k=0;k<n;k++)
	for(int i=0;i<n;i++)
	  for(int j=0;j<n;j++)
	    {
	      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	    }
      int mins=d[s-1][g1-1]+d[s-1][g2-1];
      for(int k=0;k<n;k++)
	{
	  mins=min(mins,d[s-1][k]+d[k][g1-1]+d[k][g2-1]);
	}
      cout<<mins<<endl;
    }

}

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

int main(){
	int d;

	while ( cin >> d ){
		int n = 600 / d;
		long s = 0;
		for ( int i = 0 ; i < n; ++i ){
			s += d * ( d * i ) * ( d * i );
		}
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 0
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let xt :Vec<i32> = read_vec();
    let ans = if xt[0] - xt[1] >= 0 {
        xt[0] - xt[1]
    }else {
        0
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
import sys
import heapq
import bisect
import itertools

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    N,K = LI()
    H = LI()

    ans = 0
    for h in H:
        if h>=K:
            ans += 1
    return(ans)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 49904
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        char[] c = str.toCharArray();
        
        int originalPopcount = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] == '1') originalPopcount++;
        }
        
        int plusPopcount = originalPopcount + 1;
        int minusPopcount = originalPopcount - 1;
        
        long[] plusMod = new long[n+1];
        int digit = 1;
        int m = plusPopcount;
        for (int i = n - 1; i >= 0; i--) {
            long num = (c[i] - '0') * digit;
            num %= m;
            
            plusMod[i] = plusMod[i+1] + num;
            plusMod[i] %= m;
            
            digit *= 2;
            digit %= m;
        }
        
        long[] minusMod = new long[n+1];
        digit = 1;
        m = minusPopcount;
        if (m != 0) {
            for (int i = n - 1; i >= 0; i--) {
                long num = (c[i] - '0') * digit;
                num %= m;
                
                minusMod[i] = minusMod[i+1] + num;
                minusMod[i] %= m;
                
                digit *= 2;
                digit %= m;
            }
        }
        
        for (int i = 0; i < n; i++) {
            int count = 0;
            
            int f = 0;
            if (c[i] == '0') {
                f = (int)(plusMod[0] + modpow(2, n-1-i, plusPopcount));
                f %= plusPopcount;
                count++;
            } else {
                if (minusPopcount == 0) {
                    System.out.println(0);
                    continue;
                }
                
                f = (int)(minusMod[0] - modpow(2, n-1-i, minusPopcount));
                f %= minusPopcount;
                count++;
                if (f < 0) {
                    f += minusPopcount;
                }
            }
            // System.out.println(f);
            
            while (f > 0) {
                int popcount = Integer.bitCount(f);
                f %= popcount;
                count++;
            }
            System.out.println(count);
        }
    }
    
    public static long modpow(long num, long n, int mod) {
        // ex. 3^10
        // 3^10 = 3^(0b1010)
        // = 3^8が1個 * 3^4が0個 * 3^2が1個 * 3^1が0個
        // (次の桁の値は(前の桁)^2になる)
        
        long res = 1;
        long digit = num;
        
        while (n > 0) {
            long lsb = n & 1;
            if (lsb == 1) {
                res *= digit;
                res %= mod;
            }
            
            digit = digit * digit;
            digit %= mod;
            n = n >> 1;
        }
        
        return res;
    }
}


Measured memory_bytes: 62468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()
{
	char a,b;

	cin >>a>>b;
	if ((a == 'H' && b == 'H')|| (a == 'D' && b == 'D'))
	{
		cout << 'H' << endl;
	}
	if ((a == 'H' && b == 'D')|| (a == 'D' && b == 'H'))
	{
		cout << 'D' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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

		String[] n = stdIn.next().split("");
		String s = "";
		int cnt = 0;
		for(int i = 0; i < n.length; i++) {
			int a = Integer.parseInt(n[i]);
			cnt += a;
			s += n[i];
		}

		int b = Integer.parseInt(s);
		if(b%cnt==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}


}


Measured memory_bytes: 21716
from bisect import bisect_left

N = int(input())
L = list(map(lambda l: int(l)*(-1), input().split()))
L.sort()

result = 0
for i, a in enumerate(L[:-2:]):
    for ii, b in enumerate(L[i+1:-1:]):
        c_list = L[i+ii+2::]
        c_index = bisect_left(c_list, a-b)
        result += c_index

print(result)


Measured memory_bytes: 68572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		for(int i = 1 ; i <= n ; i++) {
			if( i % 3 == 0) {
				System.out.print(" " + i);
			}else {
				int x = i;
				while(x > 0) {
					if( x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				}
			}
		}
		System.out.println();
		scan.close();
	}

}



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

int main(void) {
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else if (s == "Rainy") cout << "Sunny" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int arr[100010];
int main() {
    //cout << fixed << setprecision(8);

    int N, M; cin >> N >> M;
    REP(i, N){
        cin >> arr[i];
    }
    UnionFind uf(100010);
    REP(i, M){
        int x, y; cin >> x >> y;
        uf.unite(x, y);
    }

    int cnt=0;
    REP(i, N){
        if(uf.same(arr[i], i+1)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

inline bool pd() {
	ll a, b, c, d;
	rd(a, b), rd(c, d);
	if (d < b) return 0;
	a -= b;
	if (a > c) {
		a -= (a - c) / b * b;
		if (a > c) a -= b;
	}
	while (a < 0) return 0;
	if (d == b) return 1;
	a += (c + 1 - a) / (d - b) * (d - b);
	while (a <= c) a += d - b;
	ll g = __gcd(d - b, b);
	a -= (a - c - 1) / g * g;
	while (a - g > c) a -= g;
	return a >= b;
}

int main() {
	int T;
	rd(T);
	while (T--) prints(pd() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
char a[128],b[128];
int main(){
	char t;
	for(int i=10,t='A';i<=15;i++,t++){
		b[t]=a[t]=i;
	}
	char x,y;
	while(scanf("%c %c",&x,&y)!=EOF){
		getchar();
		if(a[x]>b[y])printf(">\n");
		else if(a[x]==b[y])printf("=\n");
		else printf("<\n");
	}
	return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MaxN = 2e5 + 25;

int n, m;

struct segmentTree{
    long long tree[MaxN * 4];
    long long p[MaxN * 4];

    void clear()
    {
        memset(p, 0, sizeof(p));
        memset(tree, 0, sizeof(tree));
    }

    void up(int pref, int delta)
    {
        up(1, 0, n + 1, 0, pref, delta);
    }
    void upPos(int pos, long long delta)
    {
        up(1, 0, n + 1, pos, pos, delta);
    }
    void up(int x, int l, int r, int ll, int rr, long long delta)
    {
        if(l > rr || r < ll)
            return;
        if(l >= ll && r <= rr)
        {
            tree[x] += delta;
            p[x] += delta;
            return;
        }

        push(x);
        int mid = (l + r) / 2;

        up(x + x, l, mid, ll, rr, delta);
        up(x + x + 1, mid + 1, r, ll, rr, delta);

        tree[x] = min(tree[x + x], tree[x + x + 1]);
    }

    void push(int x)
    {
        if(p[x])
        {
            tree[x + x] += p[x];
            tree[x + x + 1] += p[x];
            p[x + x] += p[x];
            p[x + x + 1] += p[x];
            p[x] = 0;
        }
    }

    long long getMin()
    {
        return tree[1];
    }
} segmentTree;

vector<pair<int, int> > v[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    cin >> n >> m;

    long long sum = 0;

    for(int i = 1; i <= m; ++i)
    {
        int l, r, a;
        cin >> l >> r >> a;
        v[r].push_back(make_pair(l, a));

        sum += a;
    }

    for(int i = 1; i <= n + 1; ++i)
    {
        for(auto p : v[i - 1])
            segmentTree.up(p.first - 1, p.second);
        segmentTree.upPos(i, segmentTree.getMin());
    }

    cout << sum - segmentTree.getMin() << '\n';

    return 0;
}



Measured memory_bytes: 22912
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()

int kai(int x){
  ll a = 1;
  for(int i=1;i<=x;i++) a *= i;
  return a;
}
int main() {
  ll n;
  cin >> n;
  cout << (n-1)/2<< endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int min = 100;
    int max = -100;
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      min = Math.min(min, a[i]);
      max = Math.max(max, a[i]);
    }
    
    long ans = Long.MAX_VALUE;
    for (int i = min; i <= max; i++) {
      long sum = 0;
      for (int j = 0; j < N; j++) {
        sum += (a[j]-i)*(a[j]-i);
      }
      ans = Math.min(ans, sum);
    }
    
    System.out.println(ans);
  }
}

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

ll n;
ll ans = 0;

void loop(ll cur, int use) {
  if (cur > n) return;
  if (use == 0b111) ans++;
  // add 7
  loop(cur*10+7, use|0b100);

  // add 5
  loop(cur*10+5, use|0b010);
  
  // add 3
  loop(cur*10+3, use|0b001);
}

int main() {
  cin >> n;
  loop(0, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    int a[] = new int[2000001];
    for(int i = 0; i <= 2000000; i++){
      a[i] = i - 1000000;
    }
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    for(int j = 0; j < 2*k-1; j++){
      System.out.println(a[x-k+j+1000001]);
    }


  }
}

Measured memory_bytes: 29776
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

const debug = false

func (p *problem) solve() {
	l := p.NextInts()
	a, b, k := l[0], l[1], l[2]

	n := 0
	section := 1
	for i := a; i <= b; i++ {
		if n == k {
			if section == 1 {
				i = max(b-k+1, i)
				n = 0
				section = 2
			} else {
				return
			}
		}
		p.PrintInt(i)
		n++
	}

	// for i := a; i < a+k; i++ {
	// 	if i > b {
	// 		return
	// 	}
	// 	log.Printf("1 section: i=%v", i)
	// 	p.PrintInt(i)
	// }
	// var s int
	// if (a + k - 1) == (b - k + 1) {
	// 	s = b - k + 2
	// } else {
	// 	s = max(a+k-1, b-k+1)
	// }

	// log.Println("s=%v, max(a+k-1, b-k)=%v", s, a+k-1, b-k+1)
	// for i := s; i <= b; i++ {
	// 	log.Printf("2 section: i=%v", i)
	// 	p.PrintInt(i)
	// }
}

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

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include<stdio.h>
long long int a[1000000];
int mod=1e9+7;
int main()
{
	int n,i,j;
	long long int s=0,c,d=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	for(i=0;i<60;i++)
	{c=0;
	for(j=1;j<=n;j++)
	{   
		if(a[j]&1)
		c++; 
	    a[j]=a[j]>>1;
	}
		s=s+(c*(n-c)%mod)*d%mod;
		d=d*2%mod;
	}
	printf("%lld",s%mod);
	
	
	
	
 } 

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> a >> b;
  cin >> s;
  rep(i, 0, n)
  {
    if (s[i] == 'a' && count < a + b)
    {
      count++;
      cout << "Yes" << endl;
    }
    else if (s[i] == 'b' && count < a + b && ans < b)
    {
      count++;
      ans++;
      cout << "Yes" << endl;
    }
    else if (s[i] == 'c')
    {
      cout << "No" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 848
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int L,R;
    cin >> L >> R;
    if(R - L + 1 >= 2019){
        cout << 0 << endl;
        return 0;
    }
    ll mini = INF;
    rep(i,L,R+1)rep(j,i+1,R+1){
        mini = min(mini, (ll)i * j % 2019);
        //cout << i << " " << j << "," << i * j % 2019 << endl;
    }
    cout << mini << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int d;
    cin >> d;
    
    if (d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    else if (d == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if (d == 24){
        cout << "Christmas Eve" << endl;
    }
    else {
        cout << "Christmas" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    string S; cin >> S;
    bool can =false;
    rep(i,S.size()-1){
        if(S[i]=='A' && S[i+1]=='C')
        can = true;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
	int num4,a[4];
	scanf("%d",&num4);
	for(int i=0;i<4;i++){
		a[i]=num4%10;
		num4=num4/10;
	}
	if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]){
		printf("Bad");
	}else{
		printf("Good");
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 2020000;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)
int a[maxn];
void solve()
{
    int n;
    LL ans = 0;
    LL temp = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int l = 1, r = 0; l <= n; l++)
    {
        ans += (LL)(r - l + 1);
        for(int j = r + 1; j <= n; j++)
        {
            if((temp^a[j]) == temp + a[j])
            {
                temp ^= a[j];
                ans++;
                r++;
            }
            else break;
        }
        temp ^= a[l];
    }
    cout << ans << endl;
}

int main()
{
    int t = 1;
    while(t--)
    {
        solve();
    }
    int mark_EOF;
    if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}


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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
  
bool f[200000];
vector < int > ans1,ans2,ans3;
vector < int > s[200000],g[200000];
int t,n,m,i,x,y;
 
int p(int v)
 {
  vector < int > pos;
  for (int i=0;i<g[v].size();i++)
   if (!f[s[v][i]])
    {
     f[s[v][i]]=1;
     t=p(g[v][i]);
     if (t != 0)
      { ans1.push_back(v); ans2.push_back(g[v][i]); ans3.push_back(t); } else
      { pos.push_back(g[v][i]); }
    }
  for (int i=1;i<pos.size();i+=2)
   ans1.push_back(pos[i-1]),ans2.push_back(v),ans3.push_back(pos[i]);
  if (pos.size() % 2 == 1) return pos[pos.size()-1];
  return 0;
 }

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (m % 2) {
    cout << "-1\n";
    return 0;
  }
  vector <int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    int x = a[i], y = b[i];
    g[x].push_back(y);
    g[y].push_back(x);
    s[x].push_back(i);
    s[y].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    assert(p(i) == 0);
  }
  map <pair <int, int>, int> ord;
  for (int i = 0; i < (int) ans1.size(); i++) {
    ord[{ans1[i], ans2[i]}] = ord[{ans3[i], ans2[i]}] = 1;
  }
  for (int i = 0; i < m; i++) {
    if (!ord.count({a[i], b[i]})) {
      cout << a[i] << ' ' << b[i] << '\n';
    } else {
      cout << b[i] << ' ' << a[i] << '\n';
    }
  }
}


Measured memory_bytes: 32636
n,x = map(int, input().split())
list_a = list(map(int, input().split()))
list_sum = [list_a[0]]
for i in range(n-1):
    list_sum.append(list_a[i+1] + list_a[i])
list_sum.append(10**10)
count = 0
for i in range(n):
    if list_sum[i] > x:
        count += list_sum[i] - x
        list_sum[i+1] -= list_sum[i] - x
        list_sum[i] = x
print(count)


Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n);
    ll xr=0;
    REP(i,n){
        cin >> a[i];
        if(i>=2){
            xr=(xr^a[i]);
        }
    }
    ll x12=(a[0]^a[1]);
    if(x12==xr){
        cout << 0 << endl;
        return 0;
    }
    ll res=a[0]+a[1]-xr;
    if(res<0){
        cout << -1 << endl;
        return 0;
    }
    res/=2;
    ll num=xr;
    vector<int> s(60),t(60);
    int cnt=0;
    while(xr){
        s[cnt]=(xr&1?1:0);
        cnt++;xr/=2;
    }
    cnt=0;
    while(res){
        t[cnt]=(res&1?1:0);
        cnt++;res/=2;
    }
    ll ans=0;
    REP(i,60){
        if(s[i]&&t[i]){
            cout << -1 << endl;
            return 0;
        }
        if(t[i]){
            ans+=1LL<<i;
        }
    }
    if(ans>=a[0]){
        cout << -1 << endl;
        return 0;
    }
    REPR(i,60){
        if(s[i]&&!t[i]){
            if(ans+(1LL<<i)<a[0]){
                ans+=(1LL<<i);
            }
        }
    }
    ll p=((ans)^(a[0]+a[1]-ans));
    if(p!=num||ans==0){
        cout << -1 << endl;
        return 0;
    }
    cout << a[0]-ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    ll ans = 1;
    ll max_count = 0;
    ll count;
    for (int i = 1; i <= n; ++i) {
        int k = i;
        count = 0;
        for (int j = 0; j < 10; ++j) {
            if (k % 2 == 0 && k != 0) {
                count++;
                k = k / 2;
            }else{
                break;
            }
        }
        if(count > max_count){
            max_count = count;
            ans = i;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int x; int t;
    cin >> x >> t;
    if ( x <= t)
        cout << 0 << endl;
    else
        cout << x - t << endl;
}

Measured memory_bytes: 256
#95

#入力（1次元）
N, X = list(map(int, input().split()))
m = [int(input())  for i in range(0,N)]

m_min = 200000

for j in range(0,N):
    if(m[j]< m_min):
        m_min = m[j]

count = 0
for k in range(0,N):
    X = X - m[k]
    count += 1

while X >= 0 :
    X = X - m_min
    if(X >= 0):
        count += 1
    else :
        break

print(count)

Measured memory_bytes: 3064
from functools import reduce
M = 10**9 + 7
S = input()
ans = reduce(
    lambda t, s:
        (t[0], t[1] + t[0], t[2], t[3]) if s == 'A' else
        (t[0], t[1], t[1] + t[2], t[3]) if s == 'B' else
        (t[0], t[1], t[2], t[2] + t[3]) if s == 'C' else
        ((3 * t[0]) % M, (3 * t[1] + t[0]) % M, (3 * t[2] + t[1]) % M, (3 * t[3] + t[2]) % M),
    S,
    (1, 0, 0, 0)
)[3] % M
print(ans)


Measured memory_bytes: 3812
#include <iostream>
#include<string>
typedef long long ll;
using namespace std;

int main()
{
    int c=0;
    string  s1,s2;
    cin>>s1;
    cin>>s2;
    for(int i=0;i<s1.length();i++){
        if(s1[i]!=s2[i])c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
#define chmin(a,b) if(a>b)a=b
#define LL long long
const int N=407;

int n;
LL a[N];
LL dp[N][N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",a+i);
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		if(i!=j) dp[i][j]=1e18;
	for(int len=2;len<=n;len++)
	for(int i=1;i+len-1<=n;i++)
	for(int j=i;j<i+len-1;j++)
		chmin(dp[i][i+len-1],dp[i][j]+dp[j+1][i+len-1]+a[i+len-1]-a[i-1]);
	printf("%lld\n",dp[1][n]);
	
	return 0;
}

Measured memory_bytes: 1536