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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  int n;
  cin >> n;
  vi p(n);
  rep(i, 0, n){
    int t;
    cin >> t;
    t--;
    p[t] = i;
  }

  vi a(n), b(n);
  rep(i, 0, n){
    a[i] = 20000*i+1+p[i];
    b[i] = 20000*(n-i-1)+1; 
  }

  rep(i, 0, n) cout << a[i] << " \n"[i==n-1];
  rep(i, 0, n) cout << b[i] << " \n"[i==n-1];

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
	vector<ll> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
	vector<string> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
	vector<double> a(n); \
	rep(i, n) { cin >> a[i]; }
#define in(a) \
	ll a;     \
	cin >> a;
#define ins(a) \
	string a;  \
	cin >> a;
#define ind(a) \
	double a;  \
	cin >> a;
template <class T>
inline void out(T a)
{
	cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x) (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
#define yes out("Yes")
#define no out("No")

int main()
{
	ins(s);
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi")
		yes;
	else
		no;
}

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

using namespace std;

int longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res;
    int res_length  = 0; 
  
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    return res_length; 
} 

int main() {
	int n;
	cin >> n;
    string s;
    cin >> s;
	cout << longestRepeatedSubstring(s) << endl;
}

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

int main() {
  int N, K, foo;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> foo;
  }
  cout << (N - 2) / (K - 1) + 1;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  long long N;
  cin >> N;
  cout << (long long)pow((long long)sqrt(N),2) << endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
    int H, W;

    cin >> H >> W;

    int c[10][10];

    rep(i, 10)rep(j, 10) {
        int tmp;
        cin >> tmp;
        c[i][j] = tmp;
    }

    rep(i, 10)rep(j, 10)rep(k, 10) {
        c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
    }

    int ans = 0;
    rep(i, H)rep(j, W) {
        int a;
        cin >> a;
        if (a != -1 && a != 1) {
            ans += c[a][1];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
m = 0
i = 0

for i in 0..N-2 do
  if A[i] > A[i+1]
    m += A[i] - A[i+1]
    A[i+1] = A[i]
  end
end

p m

Measured memory_bytes: 29984
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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 = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n;
    string s;
    cin >> n >> s;
    s.erase(unique(s.begin(),s.end()),s.end());
    PRINT(s.length());
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	am := make(map[int]int)
	var a int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&a)
		am[a-1]++
	}

	for i := 0; i < n; i++ {
		fmt.Println(am[i])
	}
}


Measured memory_bytes: 14984
N,K = map(int,input().split())
D = list(map(int,input().split()))

use = [i for i in range(10)] #使える数字
for i in range(K): use.remove(D[i])

ans = N
while True:
    flag = True
    for item in list(str(ans)):
        if not (int(item) in use):
            flag = False
    if flag:
        break
    else:
        ans += 1

print(ans)

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

struct Time {
  string time;
  int type; // 0 departure, 1 arrival

  /* Time(string _time, int _type){
     time = _time;
     type = _type;
     }*/

};

bool cmp(const Time &a, const Time &b){

  if(a.time == b.time)
    return b.type < a.type;
  else
    return a.time < b.time;

}

int main(){

  int n;

  while(cin>>n&&n){

    vector<Time> times(2*n);

    for(int i=0;i<2*n;++i){

      cin>>times[i].time;
      if(i%2==0)
        times[i].type = 0;
      else
        times[i].type = 1;

 //     cout<<times[i].time<<" "<<times[i].type<<endl;

    }

    sort(times.begin(), times.end(), cmp);
 /*   for(int i=0;i<2*n;++i){

      cout<<times[i].time<<" "<<times[i].type<<endl;

    }*/

    int cnt = 0, _max = 0;

    for(int i=0;i<2*n;++i){

      if(times[i].type == 0){
        ++cnt;
      }
      else{
        --cnt;
      }

      _max = max(_max, cnt);
    }

    cout<<_max<<endl;

  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 2396
#include <iostream>
using namespace std;
void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}

void sort(int *n1, int *n2, int *n3)
{
    if(*n1 > *n2) swap(n1, n2);
    if(*n2 > *n3) swap(n2, n3);
    if(*n1 > *n2) swap(n1, n2);
}


int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    sort(&a, &b, &c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}



Measured memory_bytes: 3080
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean yymm = true, mmyy = true;
		if(Integer.parseInt(S.substring(0,2)) > 12 || Integer.parseInt(S.substring(0,2)) <= 0)
			mmyy = false;
		if(Integer.parseInt(S.substring(2,4)) > 12 || Integer.parseInt(S.substring(2,4)) <= 0)
			yymm = false;
		if(mmyy)
			System.out.println(yymm ? "AMBIGUOUS" : "MMYY");
		else
			System.out.println(yymm ? "YYMM" : "NA");
	}

}

Measured memory_bytes: 21712
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int n, l;
int icicles[100005];
ll memo[100005];

int life (int i )
{
	if (memo[i] != -1LL ) return memo[i];

	int res = l - icicles[i];
	// i 番目のつららが一番大きい
	if (icicles[i-1] < icicles[i] && icicles[i] > icicles[i+1] ){
		return memo[i] = res;
	}else	// 前のつららが大きく、後ろのつららが小さい
	if (icicles[i-1] > icicles[i] && icicles[i] > icicles[i+1] ){
		return memo[i] = (life (i-1) + res );
	}else	// 前のつららが小さく、後ろのつららが大きい
	if (icicles[i-1] < icicles[i] && icicles[i] < icicles[i+1] ){
		return memo[i] = (life (i+1) + res );
	}else{	// i 番目のつららが一番小さい
		return memo[i] = (max (life (i-1), life (i+1) ) + res );
	} // end if
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.icicles6", "r", stdin );
	while (scanf ("%d %d", &n, &l ) != EOF ){
		memset (icicles, 0, sizeof (icicles ) );
		memset (memo, -1LL, sizeof (memo ) );

		for (int i = 1; i <= n; i++ ){
			scanf ("%d", &icicles[i] );
		} // end rep
		
		int res = 0;
		for (int i = 1; i <= n; i++ ){
			int curr = life (i );
			res = max (res, curr );
		} // end for

		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 4708
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let sum: u64 = a.iter().sum();
    let mut sum = sum / 2;
    for i in 0..(n - 1) {
        if i % 2 == 0 {
            sum -= a[i];
        }
    }
    let mut ans = vec![0; n];
    ans[0] = a[n - 1] - sum;
    for i in 1..n {
        ans[i] = a[(i + n - 1) % n] - ans[i - 1];
    }

    for ans in ans.into_iter() {
        print!("{} ", ans * 2);
    }
    println!();
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 7420
N,K=map(int,input().split())
if 0<=K<=((N-1)*(N-2))//2:
    #possible
    X=[]
    for i in range(1,N):
        X.append((0,i))
    T=((N-1)*(N-2))//2
    for i in range(1,N):
        for j in range(1,N):
            if T>K and i<j:
                X.append((i,j))
                T-=1
    print(len(X))
    for seq in X:
        a,b=seq
        print(a+1,b+1)
else:
    #impossible
    print(-1)


Measured memory_bytes: 3992
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n-1):
    if p[i-1] <= p[i]:
        if p[i] < p[i+1]:
            cnt += 1
    else:
        if p[i] >= p[i+1]:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

typedef pair<int, int> P;

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

	int N;
	cin >> N;

	map<int, int> m1, m2;
	m1[-1] = 0;
	m2[-1] = 0;
	rep(i, N) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			m1[v]++;
		}
		else {
			m2[v]++;
		}
	}

	vector<P> v1, v2;
	for (auto p : m1) {
		v1.push_back(make_pair(p.second, p.first));
	}
	for (auto p : m2) {
		v2.push_back(make_pair(p.second, p.first));
	}

	sort(v1.begin(), v1.end(), greater<P>());
	sort(v2.begin(), v2.end(), greater<P>());

	int v1max = v1[0].first;
	int v2max = v2[0].first;

	if (v1[0].second == v2[0].second) {
		if ((v1[0].first - v1[1].first) < (v2[0].first - v2[1].first)) {
			v1max = v1[1].first;
		}
		else {
			v2max = v2[1].first;
		}
	}

	cout << N - v1max - v2max << endl;

	return 0;
}

Measured memory_bytes: 8948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int N,L;
    cin>>N>>L;
    vector<int> A(N);
    int minu=100100;
    int ans=0;
    rep(i,N){
        A[i]=L+i;
        ans+=A[i];
        if(abs(minu)>=abs(A[i])){
            minu = A[i];
        }
    }
    cout<<ans-minu<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    S = 0
    min_ = 10**9 + 1
    neg = 0
    for a in A:
        if a < 0:
            neg += 1
            S += -a
            min_ = min(min_, -a)
        else:
            S += a
            min_ = min(min_, a)

    if neg % 2 == 0:
        return S
    else:
        return S - 2 * min_


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


Measured memory_bytes: 14236
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

signed main() {
    int n;cin >> n;
    vl a(n), b(n);
    rep(i, n-1) cin >> b[i];
    a[0] = b[0];
    rep(i,n-2) a[i+1] = min(b[i+1], b[i]);
    a[n-1] = b[n-2];
    ll sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int i,j,count=0;
    int ans = 0;
    vector<int> A(N);
    vector<vector<int>> x(N);
    vector<vector<int>> y(N);
    for(i=0;i<N;i++){
        cin >> A.at(i);
        for(j=0;j<A.at(i);j++){
            int a,b;
            cin >> a >> b;
            x.at(i).push_back(a);
            y.at(i).push_back(b);
        }
    }
    bool flag = true;
    for(int bit=0;bit<(1<<N);bit++){
        flag = true;
        count = 0;
        for(i=0;i<N;i++){
            if(bit & (1<<i)){
                for(j=0;j<A.at(i);j++){
                    if(bit & (1<<x.at(i).at(j)-1)){
                        if(y.at(i).at(j) == 0){
                            flag = false;
                            break;
                        }
                    }
                    if(!(bit & (1<<x.at(i).at(j)-1))){
                        if(y.at(i).at(j) == 1){
                            flag = false;
                            break;
                        }
                    }
                }
                count ++;
            }
            if(!flag){
                break;
            }
        }
        if(flag){
            ans = max(count,ans);
        }
    }
    
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

bool solve(int n1, int n2, int n4) {
  if(n1 > n4 + 1) {
    return false;
  }else if(n1 == n4 + 1) {
    return (n2 == 0);
  }else{
    return true;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];

  int n1 = 0;
  int n2 = 0;
  int n4 = 0;
  REP(i,N) {
    if(a[i] % 4 == 0) ++n4;
    else if(a[i] % 2 == 0) ++n2;
    else ++n1;
  }

  cout << (solve(n1, n2, n4) ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
        int n,l;
        cin >> n >> l;
        if(l <= 0 && l + n - 1 >= 0){
                cout << (l + l + n - 1) * n / 2 << endl;
        }else if(l > 0){
                cout << (l + l + n - 1) * n / 2 - l << endl;
        }else{
                cout << (l + l + n - 1) * n / 2 - l - n + 1 << endl;
        }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	int n;
	cin>>n;
	map<string,int>mp;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		mp[s]++;
	} 
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}


int main(){
    int n;
    cin>>n;
    ll a[n],l[n],r[n];
    rep(i,n) cin>>a[i];

    l[0]=a[0];
    for(int i=1;i<n;i++) l[i]=gcd(a[i],l[i-1]);
    r[0]=a[n-1];
    for(int i=n-2;i>=0;i--) r[n-i-1]=gcd(a[i],r[n-i-2]);
    ll ans=1;

    for(int i=1;i<=n-2;i++){
        ll tmp=gcd(l[i-1],r[n-i-2]);
        ans=max(ans,tmp);
    }
    ans=max(ans,l[n-2]);
    ans=max(ans,r[n-2]);

    cout<<ans<<endl;
}




Measured memory_bytes: 2560
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
gcds = 0
r = [0]
l = [0]
for N in range(n):
	r.append(fractions.gcd(r[N],a[N]))
	l.append(fractions.gcd(l[N],a[n - N - 1]))
for i in range(n):
	gcds = max(gcds,(fractions.gcd(r[i],l[n - i - 1])))
print(gcds)

Measured memory_bytes: 16144
main=do
 [n,k]<-map(read::String->Integer).words<$>getLine
 a<-map(read::String->Integer).words<$>getLine
 let mo=10^9+7::Integer
 let kk=k*(k-1)`div`2`mod`mo
 print$(`mod`mo)$sum[mod(kk*cnt+t*k)mo|(b,i)<-zip a[0..],let cnt=toInteger$length$filter(>b)a,let t=toInteger$length$filter(>b)$take i a]

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

int main() {
  int sum;
  sum = 0;
  string N;
  cin >> N;
  for(int i=0;i<N.size();i++){
    sum += (int)N[i];
  }
  sum -= N.size()*48;
  if(stoi(N) % sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define max(a,b) a>b?a:b
inline void read(int &x)
{
    x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
}
char s[20];
int main()
{
    scanf("%s",s);
    if(s[3]!='9') s[3]=s[3]+1;
    int l=3;while(s[l]=='9'){s[l]=0;s[l-1]=s[l-1]+1;}
    printf("%s",s);
}

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

bool Check(char s){
    
    if(48 <= (int)s && (int)s <= 57) return true;
    else return false;
}
int main(void){
  
  int A,B;
  string S;
  cin >> A >> B >> S;

  if(S[A] != '-'){
      cout << "No" << endl; 
  } 
  else
  {
    int len = S.size();
      
    for(int i=0;i<len;i++){
        if(i != A && Check(S[i]) == false){
            cout  << "No" << endl; 
            return 0;
        }
    }
      
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3624
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	N := list[0]
	D := list[1]
	Xlist := make([][]int, N)
	for i := 0; i < N; i++ {
		X := getStdinIntArr()
		Xlist[i] = make([]int, D)
		for n := 0; n < D; n++ {
			Xlist[i][n] = X[n]
		}
	}

	cnt := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}

			num := 0
			for n := 0; n < D; n++ {
				num += (Xlist[i][n] - Xlist[j][n]) * (Xlist[i][n] - Xlist[j][n])
			}
			dist := math.Sqrt(float64(num))
			diff := dist - float64(int(math.Floor(dist)))
			if diff < 0.000005 {
				cnt++
			}
		}
	}
	fmt.Printf("%d\n", cnt/2)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1800
def selectionSort(matrix, N):
  count = 0
  for i in range(N):
    minj = i
    for j in range(i, N):
      if A[j] < A[minj]:
        minj = j
    if A[i] != A[minj]:
      A[i], A[minj] = A[minj], A[i]
      count += 1
  return count

n = int(input())
A = list(map(int, input().split()))
count = selectionSort(A, n)
print(" ".join(map(str, A)))
print(count)



Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


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

int main(){
    long double a,b,x;
    cin >> a >> b >> x;

    long double s = x / a;

    if (s >= a * b / 2){
        long double h = (a * b - s) * 2 / a;
        cout << setprecision(10) << atan2(h,a) * 180 / M_PI << endl;
    }
    else{
        long double w = 2 * s / b;
        cout << setprecision(10) << atan2(b,w) * 180 / M_PI << endl;
    }
    return 0;
    
}

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

int main(){
    int N, M=0;
    bool can = true;
    cin >> N;
    for (int i = 0; i< N; ++i){
        int h;
        cin >> h;
        if (M - h > 1) {
            can = false;
            break;
        }
        M = max(M, h);
    }
    cout << (can ? "Yes" : "No") << endl;

}

Measured memory_bytes: 256
/*
I am not somebody you can put inside a box
And I am not somebody who will let you take my spot
It's written on my face I'm somebody who never stop
I do it because I gotta I don't do it for you props
Nah, you can keep those
I'm aiming way higher than planes in Heathrow
And I'm sorry to say but my game can't be sold
And look to be honest either you got it or don't
But if you got a dream and a vision
Put it in your mind that you gotta go out and get it
People try to stop you it's so hard in the beginning
But you said that you a winner so keep going ain't no quiting
I'm giving you the words that out me in this posotion
Some people hear and some people listen
Wanna be the best then you gotta learn the difference
*/
#include <bits/stdc++.h>                                           
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int long long	
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define ll long long
#define vi vector < int >
#define pii pair < int, int > 
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()                                                                    
#define pb push_back   
#define ppb pop_back
#define mp make_pair
#define s second
#define f first                                               
	
   
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;   
   
const int N = 2e5 + 13, inf = 1e9, mod = 1e9 + 7, block = 444;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const ll INF = 1e18;
//fucking constants
 

int n, x, t; 
 
main () {
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int r = int.Parse(Console.ReadLine());
        if (r < 1200) Console.WriteLine("ABC");
        else if (r >= 1200 && r < 2800) Console.WriteLine("ARC");
        else Console.WriteLine("AGC");
    }
}

Measured memory_bytes: 13140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
rest = 0

if a[0] + a[1] - b[0] >= 0:
    count += b[0]
    if a[0] <= b[0]:
        rest = a[0] + a[1] - b[0]
    else:
        rest = a[1]    
else:
    count += a[0] + a[1]


for i in range(1,n):
    han = rest + a[i+1] - b[i]
    if han >= 0:
        count += b[i]
        if rest <= b[i]:
            rest = han
        else:
            rest = a[i+1]
    else:
        count += rest + a[i+1]
        rest = 0

print(count)

Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112345;
const int mod = 1e9 + 7;
int n, d;
int di[MAXN];
bool seen[111][MAXN];
int dp[111][MAXN];
int sol(int i, int t, int r) {
    if (i < 0) return r == 0;
    if (seen[r][i] && t == 0) return dp[r][i];
    int ans = 0;
    for (int j = 0, k = t ? di[i] : 9; j<=k; ++j) {
        ans += sol(i-1, j == k && t, (j+r)%d);
        if (ans >= mod) ans -= mod;
    }
    seen[r][i] = t == 0;
    return t ? ans : dp[r][i] = ans;
}

int main() {
    int m, k;
    string s;
    cin >> s >> d;
    reverse(s.begin(), s.end());
    n = s.size();
    for (int i = 0; i<n; ++i) {
        di[i] = s[i] - '0';
    }
    int ans = sol(n-1, 1, 0) - 1;
    if (ans < 0) ans += mod;
    cout << ans << '\n';
}


Measured memory_bytes: 56576
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
A = {}

for i in range(N):
    s = input()
    if s in A:
        A[s] += 1
    else:
        A[s] = 1
        
j = max(A.values())

maxalist = [kv[0] for kv in A.items() if kv[1] == j]
maxalist.sort()
for i in maxalist:
    print(i)


Measured memory_bytes: 94680
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int main(){
	ll n;
	cin >> n;
	vector<bool> isdone(n,false);
	vector<ll> ans(n+1,0);
	for (ll i = 1; i <= n; ++i)
	{
		for (ll j = i; j <= n; j += i)
		{
			ans[j]++;
		}
	}
	ll f = 0;
	for (ll i = 1; i < ans.size(); ++i)
	{
		f += ans[i] * i;
	}
	cout << f << endl;
	return 0;
}

Measured memory_bytes: 82664
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int q;
	cin >> s >> q;

	int t, r=1;
	string fr, bc;
	for(int i=0; i<q; ++i){
		cin >> t;
		if(t==1){
			r*=-1;
			swap(fr,bc);
		}else{
			int f;
			char c;
			cin >> f >> c;
			if(f==1){
				fr+=c;
			}else{
				bc+=c;
			}
		}
	}

	reverse(fr.begin(),fr.end());
	if(r==-1) reverse(s.begin(),s.end());
	cout << fr+s+bc << endl;
}

Measured memory_bytes: 1348
package main

import (
	"fmt"
)

var (
	h, w, d int
	posMap = make(map[int][2]int)
	x int
	q int
	l, r int
	lr = make([][2]int, 0, q)
	cost = make(map[int]int)
)

//type pos struct {
//	x int
//	y int
//	num int
//}
//
func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

func main() {
	/*
	R-LがDの倍数であることが保証されているので、実技試験の任意のルートは
	そのスタートとゴールの数字についてDで割った余りによってD種類に分類できる。
	よって全ての整数の位置について固有の魔法量を割り当てることができる。
	*/
	fmt.Scan(&h, &w, &d)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			fmt.Scan(&x)
			posMap[x] = [2]int{i + 1, j + 1}
		}
	}
	// fmt.Println("posMap:", posMap)

	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		fmt.Scanln(&l, &r)
		lr = append(lr, [2]int{l, r})
	}

	// fmt.Println("start-goal:", lr)

	for i := 1; i <= d; i++ {
		cost[i] = 0
	}
	for i := d + 1; i <= h*w; i++ {
		cost[i] = cost[i-d] +
			abs(posMap[i][0]-posMap[i-d][0]) + abs(posMap[i][1]-posMap[i-d][1])
	}

	// fmt.Println("cost:", cost)

	for _, v := range lr {
		fmt.Println(cost[v[1]] - cost[v[0]], )
	}
}
//　R-LがDの倍数でないとき
//func cal (s int, g int, d int) int {
//	var startPos, nextPos, goalPos pos
//	search := func(num int) pos {
//		for i := 0; i < h*w; i++ {
//			if lpos[i].num == num {
//				return lpos[i]
//				break
//			}
//		}
//		return pos{x: -1, y: -1, num: -1}
//	}
//	startPos = search(s)
//	nextPos = search(s)
//	goalPos = search(g)
//	rtn := 0
//	for ; nextPos != goalPos; {
//		nextPos = search(startPos.num + d)
//		// fmt.Println("nextPos:", nextPos)
//		rtn += abs(startPos.x-nextPos.x) + abs(startPos.y-nextPos.y)
//		startPos = nextPos
//	}
//	return rtn
//}
//
//
//	var lpos []pos
//	var h, w, d, index int
//
//func main() {
//	fmt.Scan(&h, &w, &d)
//	lpos = make([]pos, h*w)
//	for i := 1; i < h+1; i++ {
//		for j := 1; j < w+1; j++ {
//			var num int
//			fmt.Scan(&num)
//			lpos[index] = pos{x:i, y:j, num:num}
//			index++
//		}
//	}
//	var q int
//	fmt.Scan(&q)
//
//	for i := 0; i < q; i++ {
//		var startNum, goalNum int
//		fmt.Scan(&startNum, &goalNum)
//
//
//		fmt.Println(cal(startNum, goalNum, d))
//	}
//}


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

int main() {
    ll k;
    ll count = 0;
    ll amount = 0;
    ll ans = -1;
    cin>>k;
    if(k%2==0){
        cout<<ans<<endl;
    }
    else{
        rep(i,1e7){
            amount *= 10;
            amount += 7;
            count++;
            if(amount%k == 0){
                ans = count;
                break;
            }else{
                amount = amount%k;
            }
        }
        cout<<ans<<endl;
    }
}

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

int main(){
  long N;
  scanf("%ld",&N);
  long ans=0;
  for(long i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0) ans+=i;
  }
  printf("%ld",ans);
}


Measured memory_bytes: 3856
N=int(input())
N_num=len(str(N))
ans=0

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

for i in range(3,N_num+1):#i桁についての3進数演算
    for j in range(3**i):
        num=Base_10_to_n(j,3).zfill(i).replace('0','3').replace('1','5').replace('2','7')
        if set(list(num))==set(['3','5','7']) and int(num)<=N:
            ans+=1
print(ans)






Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}

int counter(int x){
    if(x==0) return 0;
    return counter(x>>1)+(x&1);
}
int main(){
    fast_io

    int n;
    cin>>n;
    int A[20];
    int x[20][20];
    int y[20][20];
    
    for(int i=1;i<=n;i++){
        cin>>A[i];
        for(int j=1;j<=A[i];j++){
            cin>>x[i][j]>>y[i][j];
        }
    }
    int ans=0;
    for(int bits=1;bits<(1<<n);bits++){
        bool ok=true;
        bitset<18> bs(bits);
        for(int i=1;i<=n;i++){
            if(!bs[i-1])continue;
            for(int j=1;j<=A[i];j++){
                if((bs[x[i][j]-1])^y[i][j]) ok=false;
            }
        }
        if(ok) ans=max(ans, counter(bits));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		for(int i=1;i<6;i++)
		{
			if(input[i-1]=="0")
			{
				Console.WriteLine(i);
				return;
			}
		}
		

	}
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(V),v.end()));
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

typedef long long ll;
using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << n*(n + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  for(int i=0; i<1000; i++){
    c=c-b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a=a-d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3596
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <climits>
#include <limits>
#include <queue>
#include <utility>

using namespace std;



#define ll long long

	int main() {
			
		char letter;
		cin >> letter;
		if (letter >= 'a' && letter <= 'z')
			cout << "a" << endl;
		if (letter >= 'A' && letter <= 'Z')
			cout << "A" << endl;

		return 0;
	}




Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 2e5 + 5;

int n,a[N],cnt[N][35],tot[35];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		int id=0;
		while(x>0){
			cnt[i][++id]=x&1;
			tot[id]+=cnt[i][id];
			x>>=1;
		}
	}
	for(int i=1;i<=n;i++){
		ll ans=0;
		for(int j=1;j<=32;j++){
			if((tot[j]-cnt[i][j])&1) ans+=(1ll<<(j-1));
		}
		cout<<ans<<" \n"[i==n];
	}
	return 0;
}

Measured memory_bytes: 30892
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class S implements Comparable<S> {
		String key;
		int value;

		S(String key, int value) {
			this.key = key;
			this.value = value;
		}

		public int compareTo(S t) {
			return value - t.value;
		}

	}

	String sed(String input, String alpha, String beta) {
		String ret = "";
		for (;;) {
			if (input.indexOf(alpha) < 0) {
				ret += input;
				break;
			}
			int ind = input.indexOf(alpha);
			ret += input.substring(0, ind);
			ret += beta;
			input = input.substring(ind + alpha.length());

		}
//		System.err.println(input2+" "+alpha+" "+beta + " "+ret);
		return ret;

	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if(n==0){
				break;
			}
			String a[] = new String[n];
			String b[] = new String[n];

			for (int i = 0; i < n; i++) {
				a[i] = sc.next();
				b[i] = sc.next();
			}

			String start = sc.next();
			String end = sc.next();

			PriorityQueue<S> q = new PriorityQueue<S>();

			q.add(new S(start, 0));

			HashSet<String> hs = new HashSet<String>();

			for (;;) {
				if (q.isEmpty()) {
					System.out.println(-1);
					break;
				}
				S s = q.poll();
//				System.out.println(s.key+" "+s.value);
				if (s.key.equals(end)) {
					System.out.println(s.value);
					break;
				}

				if (s.key.length() >= end.length()) {
					continue;
				}

				if (hs.contains(s.key)) {
					continue;
				}
				hs.add(s.key);

				for (int i = 0; i < n; i++) {
					String next = sed(s.key, a[i], b[i]);
					if (hs.contains(next)) {
						continue;
					}
					q.add(new S(next, s.value + 1));
				}

			}

		}
	}

	public static void main(String[] a) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n,m;
string S;
int k=0,a[100010],now=0,ans=0;
struct dsa
{
	int l,r,val;
}c[200010];
int main()
{
	cin>>n>>m;
	cin>>S;
	for (int i=0;i<n;i++)
	  a[i+1]=int(S[i]-48);
	for (int i=1;i<=n;i++)
	{
	   if (a[i]!=a[i-1]||i==1)
	   {
          c[++k].l=i;
          c[k].r=i;
          c[k].val=a[i];
       }
       else c[k].r++;
    }
    if (c[1].val==0)
    	ans=c[min(k,2*m)].r;
    for (int i=1;i<=k;i++)
      if (c[i].val)
      {
      	if (!now) now=i;
      	while (now+2<=k&&(now-i)/2<=m) now+=2;
      	if ((now-i)/2>m) now-=2;
		int x=now;
      	if ((now-i)/2<m&&now<k) x=now+1;
        ans=max(c[x].r-c[i].l+1,ans);
      }
    cout<<ans;
    return 0;
}
	 
       

Measured memory_bytes: 2048
#include<bits/stdc++.h>;
using namespace std;
//#define LOCAL
typedef long long ll;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)

int main(){
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
     //freopen("out.txt", "w", stdout);
#else
 fastIO;
#endif
//***************************//**************************//******************************

int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);
int sum=0;
for(int i=0;i<k;i++){
    sum+=a[i];
}
cout<<sum<<endl;
}



Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, K;

int main() {
    cin >> N >> K;
    cout << N - K + 1<< endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  priority_queue<long long> point_add;
  long long sumA = 0;
  rep(i, N)
  {
    long long A, B;
    cin >> A >> B;
    point_add.push(A + B);
    sumA += A;
  }
  long long ans = sumA;
  bool turn_is_takahashi = true;
  while (point_add.size())
  {
    if (!turn_is_takahashi)
      ans -= point_add.top();
    turn_is_takahashi = !turn_is_takahashi;
    point_add.pop();
  }
  cout << ans << endl;
  return 0;
}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

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

    string S; cin >> S;
    for (auto& c : S) {
        if (c == '?') c = 'D';
    }
    cout << S;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
const ll MOD =  1e9 + 7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define pos(v) ((v) << 1)
#define neg(v) (pos(v) ^ 1)
#define db(v) (cout<<v<<" ** "<<endl)
template <class T> inline void dbv(T a) { for(auto x : a){ cout<<x<<" ** " ;} cout<<endl;}
void output()
{
    string s;
    ll k;
    cin>>s>>k;
    set<string> sub;
    ll n = s.size();
    FOR(i,1,min(n+1,15ll))
    {
        FOR(j,0,n-i+1)
        {
            string temp="";
            FOR(k,j,j+i)
            {
                temp = temp + s[k];
            }
            sub.insert(temp);
        }
    }
    vector<string> temp;
    for(string x : sub)
    {
        temp.pb(x);
    }
    sort(temp.begin(),temp.end());
    // dbv(temp);
    cout<<temp[k-1]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1  ;
    // cin>>t ;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

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


int n, query;
vector<int> v[202020];
i64 d[202020], ans[202020];
bool used[202020];

int main(){
	cin >> n >> query;
	for(int i = 1; i < n; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i = 0; i < query; i++){
		int a,b;
		cin >> a >> b;
		d[a] += b;
	}
	
	queue<P> q;
	q.push(P(1, 0));
	while(!q.empty()){
		P p = q.front();
		q.pop();
		if(used[p.first]) continue;
		ans[p.first] = p.second + d[p.first];
		used[p.first] = 1;
		for(int i = 0; i < v[p.first].size(); i++){
			q.push(P(v[p.first][i], ans[p.first]));
		}
	}
	for(int i = 1; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << ans[n] << endl;
	
	return 0;
}

Measured memory_bytes: 20468
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long N;
    cin >> N;

    vector<long long> ryuka(N+1);
    ryuka={2,1};

    for(int i=2; i<=N; i++)
        ryuka[i] = ryuka[i-1]+ryuka[i-2];

    cout << ryuka[N] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
string S, T;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  cin >> S >> T;

  for (int i = 0; i < N; i++) {
    cout << S[i] << T[i];
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 256