akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  VI u(n + 1, 0);
  int carry = 1;
  rep(i, n) {
    u[n - i - 1] = (u[n - i] + ((s[n - 1 - i] - '0') * carry)) % p;
    carry = carry * 10 % p;
  }
  ll ans = 0;
  if(p == 2 || p == 5) {
    rep(i, n) {
      if((s[n - 1 - i] - '0') % p == 0) {
        ans += n - i;
      }
    }
  }
  else {
    map<int, int> mp;
    rep(i, n + 1) {
      ans += mp[u[n - i]];
      mp[u[n - i]]++;
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 1684
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.Stack;


public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (998244353);
	static List<Integer>[] edges ;
	//static long[] dp;
	
	final static int MAX = Integer.MAX_VALUE/10 ;

	public static void main(String[] args) {
		  
		int n = sc.nextInt();
		int m = sc.nextInt();
        int[][] tab = new int[n+1][m+1];
        for(int i=1;i<=n;++i) {
        	char[] s = sc.next().toCharArray();
        	for(int j=1;j<=m;++j) {
        		if(s[j-1] == '#') tab[i][j] = 1;
        	}
        }
        int[][] dp = new int[n+1][m+1]; // min number of contigous block of black cells
        for(int i=1;i<=n;++i) dp[i][0] = MAX;
        for(int j=1;j<=m;++j) dp[0][j] = MAX;
       
        dp[1][1] = tab[1][1];
        
        for(int i=1;i<=n;++i) {
            for(int j=1;j<=m;++j) {
                if(i==1 && j==1) continue;
                int up = dp[i-1][j];
                int down = dp[i][j-1];
                if(tab[i][j]!=0 && tab[i-1][j] == 0) up++;
                if(tab[i][j]!=0 && tab[i][j-1] == 0) down++;
                dp[i][j] = Math.min(up,down);
            }
        }
       out.print(dp[n][m]);
	out.close();
}
	
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	cout << 1000 * ((N+999)/1000) - N << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3656
#Ice Tea Store
Q,H,S,D = list(map(int, input().split()))
N = int(input())*4

import numpy as np

s = [1,2,4,8]
p = [Q,H,S,D]
cp = np.array([p[i]/s[i] for i in range(4)]).argsort()
#print(s,"\n", p,"\n",cp)

n = N
c = 0

for i in cp:
    ni = n//s[i]
    #print(ni)
    n -= s[i] * ni
    c += p[i] * ni
print(c)

Measured memory_bytes: 14168
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

#define MAX_N 100000



int main(){

    long H;
    cin >> H;

    long iatt = 0;
    while( H > 0 ){
        iatt++;
        if( H == 1 ){
            H = 0;
        }
        H = H/2;
    }

    long tot_att = 0;
    for( int i = 0 ; i < iatt ; i++ ){
        tot_att += pow( 2, i );
    }

    cout << tot_att << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

const int MAX { 1000010 };
const ll MOD { 1000000007 };
const double PI = acos(-1.0);

int main(){
	ios::sync_with_stdio(false);
    map<int, ii> c;
    for(int i=0; i<3; ++i)
        for(int j=0; j<3; ++j){
            int aux;
            cin >> aux;
            c[aux] = make_pair(i, j);
        }

    int N;
    cin >> N;
    int cart[3][3] = {};
    while(N--){
        int aux;
        cin >> aux;
        if (c.find(aux) != c.end()){
            ii v = c[aux];
            cart[v.first][v.second] = 1;
        }
    }

    for(int i=0; i<3; ++i){
        int aux_i = 0, aux_j = 0;
        for(int j=0; j<3; ++j){
            aux_i += cart[i][j];
            aux_j += cart[j][i];
        }

        if(aux_i == 3 || aux_j == 3){
            cout << "Yes\n";
            return 0;
        }
    }

    int aux_dig_i = cart[0][0] + cart[1][1] + cart[2][2];
    int aux_dig_j = cart[2][0] + cart[1][1] + cart[0][2];
    if(aux_dig_i == 3 || aux_dig_j == 3){
        cout << "Yes\n";
        return 0;
    }   

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3628
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

    in_or_not = [0 for _ in range(n+1)]
    for i in range(n, 0, -1):
        count = 0
        for j in range(2 * i, n+1, i):
            count += in_or_not[j]
        if a[i] == 1:
            if count % 2 == 0:
                in_or_not[i] = 1
        else:
            if count % 2 == 1:
                in_or_not[i] = 1
    

    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')




if __name__ == "__main__":
    main()


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

using namespace std;

vector<vector<int>> speakLanguages;
vector<vector<int>> languageSpeakers;

void RegisterNewLanguage(int newLanguage, vector<bool>& visitedLanguages,
                         vector<bool>& visitedSpeakers) {
  visitedLanguages[newLanguage] = true;

  for (int speaker : languageSpeakers[newLanguage]) {
    if (visitedSpeakers[speaker]) continue;
    visitedSpeakers[speaker] = true;

    for (int language : speakLanguages[speaker]) {
      if (visitedLanguages[language]) continue;
      RegisterNewLanguage(language, visitedLanguages, visitedSpeakers);
    }
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  speakLanguages.resize(N);
  languageSpeakers.resize(M);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int language;
      cin >> language;
      language--;
      languageSpeakers[language].push_back(i);
      speakLanguages[i].push_back(language);
    }
  }

  vector<bool> visitedLanguage(M, false);
  vector<bool> visitedSpeakers(N, false);
  RegisterNewLanguage(speakLanguages[0][0], visitedLanguage, visitedSpeakers);

  int count = accumulate(visitedSpeakers.begin(), visitedSpeakers.end(), 0);

  if (count == N) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


Measured memory_bytes: 8440
n,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(n)]
time = 0
flag = 1
while len(A) > 0:
    if int(A[0][1]) <= q: #プロセスが完了する場合
        time += int(A[0][1])
        print(A[0][0],time)
        del A[0]
    else: #プロセスが完了しない場合
        time += q
        A[0][1] = str(int(A[0][1])-q)
        A.append(A[0])
        del A[0]


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 MOD = 1e9+7;

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

    reverse(S.begin(), S.end());
    S += '0';
    ll N = S.size();

    ll ans = 0;
    vector<ll> add(N+100, 0);
    REP(i,N){
        int x = S[i] - '0';
        x += add[i];
        if(x > 5){
            x = 10 - x;
            add[i+1]++;
        }
        else if(x == 5){
            int next = S[i+1] - '0';
            if(next > 4){
                x = 10 - x;
                add[i+1]++;
            }
        }
        //S[i] = x + '0';
        ans += x;
    }

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


Measured memory_bytes: 9220
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-21 19:54:06
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e5+10;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	LL s;cin >> s;
	LL x = sqrt(s);
	LL yu = (x+1)*(x+1)-s;
	LL x1 = x+1,y2 = x+1;
	LL y = 1;
	for(LL i = sqrt(yu);i >= 1;i--){
		if(yu%i == 0 && i != yu/i){
			y = i;break;
		}
	}
	LL x2 = y,y1 = yu/y;
	if(s == 1e18) cout << 0 << " " << 1000000000 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 0 << endl;
	else cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << 0 << " " << 0 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

int main(){
	
	int N;
	cin>>N;
	vector<long long> A(N);
	
	for(int i=0;i<N;i++)cin>>A[i];
	
	long long t = 0LL;
	for(int i=2;i<N;i++)t ^= A[i];
	map<pair<int,int>,priority_queue<long long>> mp;	
	{
		for(int i=0;i<(1<<20);i++){
			long long a = A[0],b = A[1];
			a &= (1<<20)-1;
			b &= (1<<20)-1;
			int f0 = 0,f1 = 0;
			if(a<i){
				f0 = 1;
				a += 1<<20;
			}
			a -= i;
			b += i;
			if(b>= (1<<20)){
				f1 = 1;
				b -= 1<<20;
			}
			if((a^b)==(t&((1LL<<20)-1))){
				pair<int,int> P(f0,f1);
				if(!mp.count(P)){
					mp[P].push(i);
					if(mp[P].size()>2)mp[P].pop();
				}
			}
		}
	}

	long long ans = Inf;
	//A[0] >>= 20,A[1] >>= 20;
	t >>= 20;
	
	for(long long i=0;i<(1<<20);i++){
		long long a,b;
		for(auto x:mp){
			a = (A[0]>>20)-x.first.first;
			b = (A[1]>>20)+x.first.second;
			if(a<0||b<0)continue;
			if(a<i)continue;
			a -= i;
			b += i;
			auto P = x.second;
			while(P.size()!=0){
				long long tt = P.top();
				P.pop();
				if(tt + (i<<20) >= A[0])continue;
				if((a^b)==t){
					ans = min(ans,tt + (i<<20));
				}
			}
		}
	}
	
	if(ans==Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
			
			
	
	return 0;
}

Measured memory_bytes: 3544
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)            {dbg,args; cerr<<endl;}
#else
#define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
	template<typename T> debugger& operator , (const T& v)
	{
		cerr<<v<<" ";
		return *this;
	}
} dbg;
#define MAXN 100000
int c[MAXN+10];
bool b[MAXN+10];
void solve(long long N, vector<vector<long long>> a){
	int r[2]={0,0},f[2]={0,0};
	for(int i=0; i<N; ++i) {
		c[i]=a[1][i]/3+1;
		if (c[i]%2==i%2) throw 2;
		if (a[0][i]==c[i]*3-2 && a[1][i]==c[i]*3-1 && a[2][i]==c[i]*3) {
		} else if (a[0][i]==c[i]*3 && a[1][i]==c[i]*3-1 && a[2][i]==c[i]*3-2) {
			r[(i+1)&1]^=1;
		} else {
			throw 1;
		}
	}
	memset(b,true,sizeof(b));
	for(int i=1; i<=N; ++i) {
		if (b[i]) {
			int x=c[i-1];
			while(x!=i) {
				debug(x);
				b[x]=false;
				f[i&1]^=1;
				x=c[x-1];
			}
		}
	}
	debug(f[0],f[1]);
	debug(r[0],r[1]);
	if (f[0]!=r[1] || f[1]!=r[0]) throw 3;
	puts("Yes");
}

int main(){
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<vector<long long>> a(3-1+1,vector<long long>(N-1+1));
	for(int i = 0 ; i <= 3-1 ; i++){
		for(int j = 0 ; j <= N-1 ; j++){
			scanf("%lld",&a[i][j]);
		}
	}
	try {
		solve(N, a);
	} catch(int err) {
		puts("No");
		debug(err);
	}
	return 0;
}



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

string s, t;

int main() {

	FAST;

	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	int ans = m;
	for (int i = 0; i < n - m + 1; i ++) {
		string k = s.substr(i, m);
		// cout << k << '\n';
		int cur = 0;
		for (int j = 0; j < m; j ++) {
			cur += (k[j] != t[j]);
		}
		ans = min(ans, cur);
	}	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3644
a, b, x = gets.chomp.split.map(&:to_i)
x = (x / 500.0).ceil

dp1 = [0]
1.upto(x){|y|
    if y <= 2
        dp1[y] = a
    else
        dp1[y] = dp1[y - 2] + a
    end
}

dp2 = [0]
1.upto(x){|y|
    if y <= 1
        dp2[y] = [dp1[y], b].min
    else
        dp2[y] = [dp1[y], dp2[y - 1] + b].min 
    end
}
puts dp2[x]



Measured memory_bytes: 6876
#include<stdio.h>

main()
{
    long long int N,A[200000],i,hat=0;
    scanf("%lld",&N);

    for(i=0; i<N; i++)
    {
        scanf("%lld",&A[i]);
        hat^=A[i];
    }

    if(hat==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 896
def l():
    print("WA")
    exit()
s = input()
if s[0] != "A": l()
c = 0
for i in s[2:-1]:
    if i == "C":
        c += 1
if c != 1: l()
print("AC") if s[1].islower() and s[-1].islower() else l()


Measured memory_bytes: 3060
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans='No'
if a[1]-a[0]==b[1]-b[0]==c[1]-c[0] and a[2]-a[1]==b[2]-b[1]==c[2]-c[1]:
  if b[0]-a[0]==b[1]-a[1]==b[2]-a[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
    ans='Yes'
print(ans)


Measured memory_bytes: 9148
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int NONE = -1;
int h, w;
int str, stc, skr, skc;
bool T[51][51];

void input() {
    cin >> stc >> str >> skc >> skr;
    stc --;
    str --;
    skc --;
    skr --;
    for ( int i = 0; i < h; ++ i ) {
        for ( int j = 0; j < w; ++ j ) {
            int t;
            cin >> t;
            T[i][j] = t ? true : false;
        }
    }
}

bool check( int r, int c ) {
    if ( r < 0 || r >= h || c < 0 || c >= w ) return false;
    return ! T[r][c];
}

typedef pair <II, II> POS;
typedef pair <int, POS> NODE;
typedef priority_queue <NODE, vector<NODE>, greater<NODE> > QUEUE;
const int dr[4] = { 0, 0, 1, -1 };
const int dc[4] = { 1, -1, 0, 0 };
int MC[51][51][51][51];

int solve() {
    QUEUE Q;
    Q.push( NODE( 0, POS( II( str, stc ), II( skr, skc ) ) ) );
    fill( (int*)MC, (int*)MC+51*51*51*51, INT_MAX );
    MC[str][stc][skr][skc] = 0;

    while ( ! Q.empty() ) {
        NODE node = Q.top();
        Q.pop();

        int steps = node.first;
        int tr = node.second.first.first;
        int tc = node.second.first.second;
        int kr = node.second.second.first;
        int kc = node.second.second.second;

        if ( steps >= 100 ) return NONE;
        if ( kr == tr && kc == tc ) return steps;

        for ( int i = 0; i < 4; ++ i ) {
            int nSteps = steps + 1;
            int ntr = tr + dr[i];
            int ntc = tc + dc[i];
            int nkr = kr + dr[i] * -1;
            int nkc = kc + dc[i] * -1;
            if ( ! check( ntr, ntc ) ) {
                ntr = tr;
                ntc = tc;
            }
            if ( ! check( nkr, nkc ) ) {
                nkr = kr;
                nkc = kc;
            }
            if ( nSteps >= MC[ntr][ntc][nkr][nkc] ) continue;
            MC[ntr][ntc][nkr][nkc] = nSteps;
            Q.push( NODE( nSteps, POS( II( ntr, ntc ), II( nkr, nkc ) ) ) );
        }
    }
    
    return NONE;
}

int main() {
    while ( cin >> w >> h && w ) {
        input();
        int ret = solve();
        if ( ret == NONE ) {
            cout << "NA" << endl;
        } else {
            cout << ret << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27000
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

def combi(n,k)
  k = n-k if 2 * k > n
  return 1 if k == 0
  ((n - k + 1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

N, K = gets_i_list

n_list  = (0..N).to_a
rn_list = n_list.reverse
total_count = 0

min = (K * (K-1)) / 2
max = rn_list[0,K].sum

K.upto(n_list.size) do |k|
  total_count += max - min + 1
  min += k
  max += N - k
end

puts total_count % (10**9 + 7)


Measured memory_bytes: 17948
N = int(input())
H = [list(map(int, input().split())) for _ in range(N)]
dp = [[0,0,0] for _ in range(N)]
dp[0] = H[0]
for i in range(1,N):
    dp[i][0] = H[i][0] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = H[i][1] + max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = H[i][2] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))

Measured memory_bytes: 76888
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
	string S,S1,S2;
	cin >> S;
	int i;
	while (S.empty() == 0) {
		S.pop_back();S.pop_back();
		S1.erase(S1.begin(), S1.end());
		S2.erase(S2.begin(), S2.end());
		for (i = 0; i < S.size()/2; i++) {
			S1.push_back(S[i]);
			S2.push_back(S[i + S.size()/2]);
		}
		if (S1 == S2) { 
			cout << S.size() << endl; 
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#define LL long long
#define M 100020
using namespace std;
int read(){
	int nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
int n,m,cnt,A,B,q[M],hd,tl,D,X[M],Y[M];
LL ans;
bool vis[M];
vector<int> t[M<<1],f[M<<1];
map<int,int> ID1,ID2;
int fd(int kd,int x){return f[kd][x]==x?x:f[kd][x]=fd(kd,f[kd][x]);}
bool cmp(int x,int y){return X[x]<X[y];}
void gtin(int x){
	int tar; X[x]=read(),Y[x]=read();
	if(ID1.count(X[x]+Y[x])) tar=ID1[X[x]+Y[x]];
	else cnt++,tar=ID1[X[x]+Y[x]]=cnt,f[tar].push_back(0);
	t[tar].push_back(x),f[tar].push_back(f[tar].size());
	if(ID2.count(X[x]-Y[x])) tar=ID2[X[x]-Y[x]];
	else cnt++,tar=ID2[X[x]-Y[x]]=cnt,f[tar].push_back(0);
	t[tar].push_back(x),f[tar].push_back(f[tar].size());
}
int getpos(int kd,int minx){
	int l=0,r=t[kd].size(),fin=0,md;
	while(l<=r){
		md=((l+r)>>1);
		if(md<t[kd].size()&&X[t[kd][md]]<minx) l=md+1;
		else fin=md,r=md-1;
	} return fin;
}
void del(int x){
	vis[x]=true; q[tl++]=x;
	int kd=ID1[X[x]+Y[x]],fin; fin=getpos(kd,X[x]);
	f[kd][fin]=fd(kd,fin+1),kd=ID2[X[x]-Y[x]];
	fin=getpos(kd,X[x]),f[kd][fin]=fd(kd,fin+1);
}
void calc(int kd,int lx,int rx,bool down){
	int t1=getpos(kd,lx),t2=getpos(kd,rx),tot=t[kd].size();
	if(down&&t1<tot&&X[t[kd][t1]]<=lx) t1++;
	if(down&&t2<tot&&X[t[kd][t2]]<=rx) t2++; ans+=t2-t1;
	for(t1=fd(kd,t1);t1<t2&&t1<tot;t1=fd(kd,t1+1)) del(t[kd][t1]);
	
}
void getans(int x){
	if(ID2.count(X[x]-Y[x]-D)) calc(ID2[X[x]-Y[x]-D],X[x]-D,X[x],false);
	if(ID1.count(X[x]+Y[x]+D)) calc(ID1[X[x]+Y[x]+D],X[x],X[x]+D,false);
	if(ID1.count(X[x]+Y[x]-D)) calc(ID1[X[x]+Y[x]-D],X[x]-D,X[x],true);
	if(ID2.count(X[x]-Y[x]+D)) calc(ID2[X[x]-Y[x]+D],X[x],X[x]+D,true);
}
void solve(){
	del(A),del(B),D=abs(X[A]-X[B])+abs(Y[A]-Y[B]);
	while(hd<tl){int now=q[hd++];getans(now);}
}
int main(){
	n=read(),A=read(),B=read();
	for(int i=1;i<=n;i++) gtin(i);
	for(int i=1;i<=cnt;i++) sort(t[i].begin(),t[i].end(),cmp);
	solve(),printf("%lld\n",ans/2); return 0;
}

Measured memory_bytes: 29824
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
#include <atcoder/all>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)
using namespace atcoder;

int main()
{
    int t; cin >> t;
    rep(i, t)
    {
        _LL n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m , a, b) << endl;
    }
    return 0;    
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  string s,t ;
  cin >> s >> t ;
  sort(s.begin() ,s.end());
  sort(t.begin() ,t.end(),greater<int>()) ;
  string S,T ;
  for(int i=0;i<s.size() ;i++)
    S += s[i] ;
  for(int i=0;i<t.size() ; i++)
    T += t[i] ;
  if(S < T)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  

Measured memory_bytes: 256
# 上底の長さが a、下底の長さが b、高さが hの台形があります。
# この台形の面積を求めてください。

# 制約
# 1 ≦ a ≦ 100
# 1 ≦ b ≦ 100
# 1 ≦ h ≦ 100
# 入力で与えられる値はすべて整数
# hは偶数

# 標準入力から a, b, h の値を取得する。
input_a = int(input())
input_b = int(input())
input_h = int(input())

# 台形の計算をし、結果を出力する
result = int((input_a + input_b) * input_h / 2)
print(result)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
目的地が深い人優先で配置
とちゅう追い抜きが必要かどうか。
追い抜ける場所があるか
...があれば追い抜き可能
CかD+1のちかいほうまでで抜けること。
#.C.は可能
遠いほうまでで、岩が2個並んでいないこと。
1WA
11 1 3 8 7  
...#.#...##
これか
あれ、別のがWAに
開始位置か
*/
int main(){
  ll N,A,B,C,D; cin>>N>>A>>B>>C>>D;
  string S; cin>>S;
  ll start1=min(A,B);
  ll start2=max(A,B);
  ll goal1=min(C,D);
  ll goal2=max(C,D);
  bool overtake=false;
  if((A-B)*(C-D)<0)
    overtake=true;
  for(int i=start1-1; i<goal2-1; i++){
    if(S[i]=='#' && S[i+1]=='#'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(overtake){
    for(int i=start2-1; i<=goal1-1; i++){
      if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.') break;
      if(i==goal1-1){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int A_pensils=0; int B_pensils=0;
        int A_price=0; int B_price=0;
        while(A_pensils<n){
            A_pensils+=a;
            A_price+=b;
        }
        while(B_pensils<n){
            B_pensils+=c;
            B_price+=d;
        }

        if(A_price<=B_price){ System.out.println(A_price); }
        else{ System.out.println(B_price); }
    }
}


Measured memory_bytes: 26384
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w = map(int,input().split()) #n:頂点数　w:辺の数

d = [[float("inf")]*n for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
x = [0]*w
y = [0]*w
z = [0]*w
for i in range(w):
    x[i],y[i],z[i] = map(int,input().split())
    d[x[i]-1][y[i]-1] = z[i]
    d[y[i]-1][x[i]-1] = z[i]
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
d = warshall_floyd(d)

res = 0
for i in range(w):
    if z[i] > d[x[i]-1][y[i]-1]:
        res += 1
print(res)

Measured memory_bytes: 3416
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*NIL;

//add this function
struct Node *find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  struct Node *t;
  int n,i,x;
  char tmp[1000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",tmp);
    if(strcmp(tmp,"find")==0){
      scanf("%d",&x);
      t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(tmp,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(tmp,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 20468
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

d, n = list(map(int, sys.stdin.buffer.readline().split()))

if n == 100:
    n += 1
ans = 100 ** d * n
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n=kbd.nextInt();
   int d=kbd.nextInt();
   int num=0;
   for(int i=0;i<n;i++){
   long x=kbd.nextInt();
   long y=kbd.nextInt();
   if(Math.sqrt(x*x+y*y)<=d){
   num++;
 }
}
 System.out.println(num);
}
}


Measured memory_bytes: 59132
#ITP1_10-D Distance2
n = int(input())
x = [float(x) for x in input().split(" ")]
y = [float(x) for x in input().split(" ")]

d1=0.0
for i in range(n):
    d1 += abs(x[i]-y[i])
print(d1)

d2=0.0
for i in range(n):
    d2 += (x[i]-y[i])**2
print(d2**(1/2))

d3=0.0
for i in range(n):
    d3 += abs((x[i]-y[i])**3)
print(d3**(1/3))

d_inf=0.0
for i in range(n):
    if abs(x[i]-y[i])>d_inf:
        d_inf = abs(x[i]-y[i])
print(d_inf)

Measured memory_bytes: 7784
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  map<char, int> m;
  string ans = "yes";
  for (char c = 'a'; c <= 'z'; c++) {
    m[c] = 0;
    for (int i = 0; i < s.size(); i++) {
      if (c == s[i]) m[c]++;
      if (m[c] >= 2) ans = "no";
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, a;
	vector<ll> v;

	cin >> n;

	REP(i, n) {
		cin >> a;

		v.push_back(a);
	}

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



	cout << v[v.size() - 1] - v[0] << endl;
}


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

int main()
{
	int N;
	std::vector<int> Vs;
	std::vector<int> Cs;

	std::cin >> N;

	for (int i = 0; i < N; ++i) {
		int V;
		std::cin >> V;
		Vs.push_back(V);
	}

	for (int i = 0; i < N; ++i) {
		int C;
		std::cin >> C;
		Cs.push_back(C);
	}

	int result_sum = 0;
	for (int i = 0; i < N; ++i) {
		int result = Vs[i] - Cs[i];
		if (result > 0) {
			result_sum += result;
		}
	}
	std::cout << result_sum;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int outlet = 1;
		int sum = 0;
		while(outlet < B) {
			outlet = outlet + A - 1;
			sum ++;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23508
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}


signed main() {
	int n,a=0,b=0,c=0,t;
	string s;
	cin >> n >> s;
	rep(i, n) {
		if (s[i] == 'R') {
			a++;
		}
		if (s[i] == 'G') {
			b++;
		}
		if (s[i] == 'B') {
			c++;
		}
	}
	t = a * b * c;
	for (int i = 1; i <= (n - 1) / 2; i++) {
		for (int j = 0; j < n - i * 2; j++) {
			if (s[j] != s[j + i] && s[j + i] != s[j + i * 2] && s[j] != s[j + i * 2]) {
				t--;
			}
		}
	}
	cout << t << endl;
}





Measured memory_bytes: 3640
n = input()
n = n.replace('9', 'x').replace('1', '9').replace('x', '1')
print(n)

'''
n = list(input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    elif n[i] == '9':
        n[i] = '1'
print("".join(n))
'''


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e5 + 10;

int n, m, E = 1, tot, ban;
int fir[N], nex[N << 1], arr[N << 1];
int incircle[N], pnt[N];
LL dp[N];

inline void Add_Edge(int x, int y) {
	nex[++E] = fir[x];
	fir[x] = E; arr[E] = y;
}

namespace Subtask_tree {
	LL sum = 0;
	
	void dfs(int x, int dep, int fa) {
		dp[x] += (dep & 1) ? 1 : -1;
		for (int i = fir[x]; i; i = nex[i]) {
			if (arr[i] == fa || (i >> 1) == (ban >> 1)) continue;
			dfs(arr[i], dep + 1, x);
			dp[x] += dp[arr[i]];
		}
		sum += abs(dp[x]);
	}
	
	int main() {
		dfs(1, 1, 0);
		if (dp[1] != 0) puts("-1");
		else printf("%lld\n", sum);
		return 0;
	}
}

namespace circle_init {
	int top, vis[N], st[N], instack[N];
	
	void getcircle(int x, int fa) {
		st[++top] = x;
		instack[x] = 1;
		vis[x] = 1;
		for (int i = fir[x]; i; i = nex[i]) {
			if (arr[i] == fa) continue;
			if (instack[arr[i]]) {
				incircle[arr[i]] = 1;
				pnt[++tot] = arr[i];
				for (int j = top; st[j] != arr[i]; --j) {
					incircle[st[j]] = 1;
					pnt[++tot] = st[j];
				}	
			}
			else if (!vis[arr[i]]) getcircle(arr[i], x);
		}
		--top;
		instack[x] = 0;
	}

	void getvalue(int x, int dep, int fa) {
		dp[x] = (dep & 1) ? 1 : -1;
		for (int i = fir[x]; i; i = nex[i]) {
			if (arr[i] == fa || incircle[arr[i]]) continue;
			getvalue(arr[i], dep + 1, x);
			dp[x] += dp[arr[i]];
		}
	}
	
	void debug() {
		for (int i = 1; i <= tot; ++i)
			cout << pnt[i] << ' ';
		puts("");
		for (int i = 1; i <= n; ++i)
			cout << dp[i] << ' ';
		puts("");
		for (int i = 1; i <= n; ++i)
			cout << incircle[i] << ' ';
		puts("");
	}
}

namespace Subtask_even {
	LL res = 0, del[N]; // xi = x1 + del[i]

	
	int main() {
		int tmp = 0;
		for (int i = 1; i <= n; ++i) {
			if (!incircle[i]) res += abs(dp[i]);
			else tmp += dp[i];
		}
		if (tmp != 0) return 0 * puts("-1");
		for (int i = 2; i <= tot; ++i) {
			del[i] = del[i - 1] + dp[pnt[i]];
		}
		sort(del + 1, del + tot + 1);
		int mid = del[tot >> 1];
		for (int i = 1; i <= tot; ++i) {
			res += abs(del[i] - mid);
		}
		cout << res << endl;
		return 0;
	}
}

namespace Subtask_odd {
	int tmp, to;

	int main() {
		for (int i = fir[pnt[1]]; i; i = nex[i]) {
			if (incircle[arr[i]]) {
				ban = i;
				break;
			}
		}
		for (int i = 1; i <= tot; ++i)
			tmp += dp[pnt[i]];
		if (tmp & 1) return 0 * puts("-1");
		memset(dp, 0, sizeof dp);
		dp[pnt[1]] -= tmp / 2;
		dp[arr[ban]] -= tmp / 2;
		Subtask_tree::dfs(pnt[1], 1, 0);
		cout << Subtask_tree::sum + abs(tmp / 2) << endl;
		return 0;
 	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		Add_Edge(x, y);
		Add_Edge(y, x);
	}
	if (m == n - 1) return Subtask_tree::main();
	circle_init::getcircle(1, 0);
	for (int i = 1; i <= tot; ++i) {
		circle_init::getvalue(pnt[i], i & 1, 0);
	}
//	circle_init::debug();
	if (~tot & 1) return Subtask_even::main();
	else return Subtask_odd::main();
}


Measured memory_bytes: 10368
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x

# y軸
def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]

# y軸
answer += G()
# 逆順
map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)


Measured memory_bytes: 141856
<?php
list($n,$a,$b)=explode(" ",trim(fgets(STDIN)));
if(($b-$a)%2==0){
  echo ($b-$a)/2;
}elseif($n-$a<$b-1){
  $ans=$n-$b+1;
  echo $ans+($n-$a-$ans)/2;
}else{
  $ans=$a;
  echo $ans+($b-$ans-1)/2;
}

Measured memory_bytes: 4728
#include <iostream>

using namespace std;

long long N;
string ans;

int main()
{
	cin >> N;
	N--;
	for (; N >= 26; (N /= 26)--)
		ans = static_cast<char>('a' + N % 26) + ans;
	ans = static_cast<char>('a' + N % 26) + ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int sum = 0;
		int min = Integer.MAX_VALUE;
		int[] m = new int[n];
		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			sum += m[i];
			min = Math.min(min, m[i]);
		}
		System.out.println((x-sum)/min + n);
		sc.close();
	}
}

Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 100000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define T long long
#define mat vector<vector<T>>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;
const int N = 2005;
int h,w;
bool col[N][N];

bool bad(int i, int j){
	return (col[i][j] ^ col[i+1][j] ^ col[i][j+1] ^ col[i+1][j+1]);
}

int main(){
	scanf("%d %d",&h,&w);
	cu(i,0,h){
		cu(j,0,w){
			char c;
			scanf(" %c",&c);
			col[i][j] = c == '.';
		}
	}

	int a[h+1][w+1] = {};
	cu(i,1,h){
		cu(j,1,w){
			a[i][j] = !bad(i-1, j-1);
		}
	}

	int l[w] = {};
	
	int ans = max(w,h);
	stack<pii> s;
	cu(i,1,h){
		cu(j,1,w){
			if(a[i][j] != 0)a[i][j] += a[i-1][j];
		}
		s.push({0,0});
		cu(j,1,w){
			int best = j;
			while(s.top().F > a[i][j]){
				best = s.top().S;
				s.pop();
			}
			if(s.top().F != a[i][j])s.push({a[i][j], best});
			else best = s.top().S;
			l[j] = best;
		}
		while(s.size() > 1)s.pop();
		cd(j,w,1){
			int best = j;
			while(s.top().F > a[i][j]){
				best = s.top().S;
				s.pop();
			}
			if(s.top().F != a[i][j])s.push({a[i][j], best});
			else best = s.top().S;
			gmax(ans, (a[i][j] + 1) * (best - l[j] + 1 + 1));
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 19840
#include "bits/stdc++.h"

using namespace std;

string calc(string s,string t){
    int a=0,b=0;
    int k=1;
    for(int i=0;i<(int)s.length();i++){
        if(s[i]=='m'){a+=k*1000;k=1;}
        else if(s[i]=='c'){a+=k*100;k=1;}
        else if(s[i]=='x'){a+=k*10;k=1;}
        else if(s[i]=='i'){a+=k;k=1;}
        else k=s[i]-'0';
    }
    for(int i=0;i<(int)t.length();i++){
        if(t[i]=='m'){b+=k*1000;k=1;}
        else if(t[i]=='c'){b+=k*100;k=1;}
        else if(t[i]=='x'){b+=k*10;k=1;}
        else if(t[i]=='i'){b+=k;k=1;}
        else k=t[i]-'0';
    }
    //cout<<a<<" "<<b<<endl;
    int su=a+b;
    string ret="";
    int tmp=su/1000;
    if(tmp==1) ret+="m";
    else if(tmp>1) ret=ret+to_string(tmp)+"m";
    su%=1000;
    tmp=su/100;
    if(tmp==1) ret+="c";
    else if(tmp>1) ret=ret+to_string(tmp)+"c";
    su%=100;
    tmp=su/10;
    if(tmp==1) ret+="x";
    else if(tmp>1) ret=ret+to_string(tmp)+"x";
    su%=10;
    tmp=su;
    if(tmp==1) ret+="i";
    else if(tmp>1) ret=ret+to_string(tmp)+"i";

    return ret;
}

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

    int n;cin>>n;
    for(int i=0;i<n;i++){
        string s,t;cin>>s>>t;
        cout<<calc(s,t)<<endl;
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<char> ent(N);
  int count_a = 0;
  int count_b = 0;
  for (int i = 0; i < N; i++) {
    cin >> ent.at(i);
    if (ent.at(i) == 'a') {
      if (count_a + count_b < A + B) {
        cout << "Yes" << endl;
        count_a++;
      } else {
        cout << "No" << endl;
      }
    }
    else if (ent.at(i) == 'b') {
      if (count_a + count_b < A + B && count_b < B) {
        cout << "Yes" << endl;
        count_b++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

int n;
ll suma, sumb;
int a[MAXN], b[MAXN];
vector <int> vp, vs;
ll k;
int sol;

int main(){

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        suma += a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
        sumb += b[i];
        if (a[i] < b[i]) vp.pb(b[i]-a[i]);
        else vs.pb(a[i]-b[i]);
    }
    if (suma < sumb){
        cout << -1;
        return 0;
    }

    for (int i = 0; i < vp.size(); i++){
        k += vp[i];
        sol++;
    }

    sort(vs.begin(), vs.end());
    for (int i = vs.size()-1; i >= 0; i--){
        if (k <= 0) continue;
        k -= vs[i];
        sol++;
    }

    cout << sol;

    return 0;

}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	bool OK = false;
	for (int ii = A; ii <= B; ++ii){
		if (ii % K == 0){
			OK = true;
			break;
		}
	}


	if (OK){
	cout << "OK" << "\n";
	} else {
	cout << "NG" << "\n";		
	}

	return 0;
}


Measured memory_bytes: 3640
const main = function(input) {
    const ipt = input.split("\n");
    const H = ipt[0], W = ipt[1], N = ipt[2];
    const bigger = Math.max(H, W);
    console.log(Math.ceil(N / bigger));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;
public class Main{
 
   
  public static void main(String[] args)
  {
     
   Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int arr[][]=new int[n][3];
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<3;j++)
    	{
    		arr[i][j]=s.nextInt();
    	}
    }
    
    for(int i=1;i<n;i++)
    {
    	arr[i][0]=arr[i][0]+Math.max(arr[i-1][1], arr[i-1][2]);
    	arr[i][1]=arr[i][1]+Math.max(arr[i-1][0], arr[i-1][2]);
    	arr[i][2]=arr[i][2]+Math.max(arr[i-1][1], arr[i-1][0]);
    }
    
    System.out.println(Math.max(arr[n-1][0], Math.max(arr[n-1][1], arr[n-1][2])));
    s.close();
    
  }
}

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

int main(void){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    rep(i,n) cout << s[i] << t[i];
    putchar('\n');

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
typedef long long ll;

int main() {
    ll n, w; 
    cin >> n >> w; 
    vector<ll> values(n);
    vector<ll> weights(n);
    for(int i=0; i < n; i++) {
        cin >> weights[i] >> values[i];
    }

    vector<ll> dp(w + 1, INT_MIN);
    dp[0] = 0;
    for(int it=0; it < n; it++) {
        ll value = values[it];
        ll weight = weights[it];
        // cout << value << " " << weight << endl;
        for(int i=w; i >= weight; i--) { 
            // cout << "wat" << endl;
            dp[i] = max(dp[i], dp[i-weight] + value); 
        }
    }
    ll res = INT_MIN;

    for(int i=0; i <= w; i++) {
        res = max(res, dp[i]);
        // cout << dp[i] << endl;
    }
    cout << res << endl;
}


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

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

int chk[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, q, i, tot = 0, b, c;
    cin >> n;
    vector<int> a(n);
    for(i = 0; i < n; i++){
        cin >> a[i];
        chk[a[i]]++;
        tot += a[i];
    }
    cin >> q;
    while(q--){
        cin >> b >> c;
        tot += chk[b]*(c-b);
        chk[c] += chk[b];
        chk[b] = 0;
        cout << tot << endl;
    }
}

Measured memory_bytes: 3944
#include <iostream>
int main() {
    int N;
    int K;
    int buf;
    int sum = 0;
    std::cin >> N >> K;
    for(int i = 0; i < N; i++){
        std::cin >> buf;
        if(buf >= K)
            sum++;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[13]={2,3,4,5,6,7,8,9,10,11,12,13,1};
int main(){
	//freopen("in.txt","r",stdin);
    int a,b;
    while(cin>>a>>b){
    	int st,en;
    	for(int i=0;i<13;i++){
    		if(num[i]==a) st=i;
    		if(num[i]==b) en=i;
		}
		if(st<en) cout<<"Bob"<<endl;
		else if(st==en) cout<<"Draw"<<endl;
		else cout<<"Alice"<<endl;
	}
}

Measured memory_bytes: 256