akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod7 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define queries ll t;cin>>t;while(t--)
using namespace std;


int main(){

    fast

	ll n;
	cin>>n;
	map<string,ll>m;
	vector<string>v;
	for(ll i=0;i<n;i++){
		string s;
		cin>>s;
		v.push_back(s);
		m[s]++;
	}	
	ll max=m[v[0]];
	set<string>h;
	for(ll i=1;i<n;i++){
		if(m[v[i]]>=max){
			max=m[v[i]];
		}
	}
	for(ll i=0;i<n;i++){
		if(m[v[i]]==max){
			h.insert(v[i]);
		}
	}
	for(auto&i:h){
		cout<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 34800
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long sum = 0;
        for(int i=1;i<=N;i++)
        {
            if(i%3!=0) sum = sum + i;
            if(i%5!=0) sum = sum + i;
            if(i%15!=0) sum = sum - i;
            
        }
        System.out.println(sum);
    }
}


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

int main() {
	int n, all = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		all ^= a[i];
	}
	for (int i = 0; i < n; ++i) {
		cout << (all ^ a[i]) << ' ';
	}
	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll r = max(max(a * c, a * d), max(b * c, b * d));
  cout << r << '\n';
  return 0;
}


Measured memory_bytes: 3640
N=int(input())
*a,=map(int,input().split())

if N == 1:
  print(0)
  exit()

m = sum(a)

MIN=10**20
argmin=-1
for i in range(N):
  if MIN>abs(m-a[i]*N):
    MIN = abs(m-a[i]*N)
    argmin = i
print(argmin)

Measured memory_bytes: 9184
(input => {
  let arr = input.split('\n');
  let [A, B] = arr[0].split(' ').map(Number);
  let S = arr[1];
  let r = new RegExp(`^\\d{${A}}-\\d{${B}}$`);
  console.log(r.test(S) ? 'Yes' : 'No');
})(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int a,b,k;
  int cnt=0,sum=0;

  cin>>a>>b>>k;
  int e=min(a,b);

  for(int i=e;i>0;i--) {
    if(a%i==0&&b%i==0)
        {
            cnt++;
    }
    if(cnt==k)
        {
            sum=i;
           break;
    }
  }

  cout<<sum<<endl;

  return 0;
}


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

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

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let v: Vec<u32> = read_vec();
    if v[1] + v[2] > v[0] {
        println!("{}", v[1] + v[2] - v[0]);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int lt[n];
	for(int i=0; i<n; i++){
		scanf("%d", &lt[i]);
	}
	int c = n - k;
	for(int i=0; i<c; i++){
		if(lt[i]<lt[i+k]){
			puts("Yes");
		}
		else{
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 2392
# 入力部分を取得
# A, B, C = map(int,input().split())

# sumを取得
# sum([A,B,C])

# importするとき
# import math

# 配列に入れる
# b_list=list(map(int,input().split()))

# 一つ代入する(数値)
# e=int(input())

# 取得する
# e=input()

# 切り捨て
# math.floor((3*A + P)/2)

# stringからdatetimeへ変換
# 例1
# string_date_1 = '2017/07/01'
# atetime.datetime.strptime(string_date_1, '%Y/%m/%d')

# forの使い方
# for i in range(3):
#    print(haiku[i])
# for haiku in haikus:
#    print(haiku)

# 分割して受け取る
# haiku = haikus.split(",")

# 文字列の分割
# char_list = list(str)

# ソートする
# n = int(input())
# d = list(map(int, input().split()))
# list = sorted(d)
# print(d)


S_list = list(input())
l = len(S_list)
for i in range(l):
    if S_list[i] == "A":
        start = i
        break
for i in range(l):
    if S_list[i] == "Z":
        finish = i


print(finish - start + 1)


Measured memory_bytes: 4840
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int n; // 競技者数
    int m; // 優勝者の番号
    double p; // 控除率
    int sum; // 掛け金合計

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    m = sc.nextInt();
	    p = sc.nextDouble();
	    sum = 0;
	    if(n!=0){ // 1 <= N <= 100 より
		solve();
	    }
	}
    }

    void solve(){
	int[] t = new int[n+1];
	for(int i=1; i<t.length; i++){
	    t[i] = sc.nextInt();
	    sum += t[i];
	}

	sum = sum*100; // 掛け金合計
	sum -= sum*(p/100); // 控除済み
	//System.out.println(sum);
	int ans = 0;

	if(t[m]!=0){
	    ans = sum/t[m];
	}

	System.out.println(ans);
    }
}

Measured memory_bytes: 30180
N = int(input())
flag = 'Yes'
txy = [[0,0,0]]
for i in range(N):
    a = list(map(int,input().split()))
    txy.append(a)
    td = txy[i+1][0] - txy[i][0]
    xd = abs(txy[i+1][1] - txy[i][1])
    yd = abs(txy[i+1][2] - txy[i][2])
    if (td < xd + yd) or ((td-(xd+yd))%2 == 1):
        flag = 'No'
print(flag)

Measured memory_bytes: 27380
// C - Coloring Colorfully
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; cin>>S;
	int N = S.size();
	int a = 0, b = 0;
	for(int i=0; i<N; ++i){
		bool s = S[i]-'0';
		bool odd = i%2;
		if(odd!=s) ++a;
		if((!odd)!=s) ++b;
	}
	cout<< min(a, b) <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

#define int long long

signed main() {
    int k, s; cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x++) {
        for(int y = 0; y <= k; y++) {
            int z = s - x - y;
            if(0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
}


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

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

int solve( int n ) {
	if( n == 1 ) return 1;
	
	int cnt = 0;
	for( int i = n + 1; i <= 2 * n; i++ ) {
		if( i == 3 ) cnt++;
		else if( i % 2 != 0 ) {
			for( int j = 2; j <= sqrt( i ); j++ ) {
				if( i % j == 0 ) break;
				if( j == static_cast<int>( sqrt( i ) ) ) cnt++;
			}
		}
	}
	return cnt;
}

int main() {
	int n;

	while( 1 ) {
		cin >> n; if( n == 0 ) break;
		cout << solve( n ) << endl;

	}

}


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    int kazu;
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        kazu = sc.nextInt();
        System.out.println(kazu*kazu*kazu);
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17296
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main()
{   int N;
	cin >> N;
	vector<int> A(N), B(N), C(N - 1);
	rep(i, N) cin >> A.at(i);
	rep(i, N) cin >> B.at(i);
	rep(i, N-1) cin >> C.at(i);
	int count = 0;
	for (int i = 0; i <N; i++) {
		count += B.at(A.at(i) - 1);
		if (i>0 && A.at(i) == A.at(i - 1) + 1)count += C.at(A.at(i - 1)-1);
	}
	cout << count << endl;

}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll power, n, i, x, s = 0;
	cin >> power >> n;
	rep(i,0,n){
		cin >> x;
		s += x;
	}
	if(s >= power)cout << "Yes" << nl;
	else cout << "No" << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



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

int main(){
    string s;
    cin >> s;
    int count = 0;
    if (s[0] == '1')
    count++;
    if (s[1] == '1')
    count++;
    if (s[2] == '1')
    count++;
    cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getc() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

i64 D[13];
i64 E[13];
const i64 M = 1000000007;
signed main() {
	D[0] = 1;
	while(true) {
		char c = getc();
		if (c == '\n') {
			break;
		} else if (c == '?') {
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += D[(j - r + 13) * 9 % 13];
				}
				E[r] = s % M;
			}
		} else {
			i64 d = c - '0';
			/*
			REP(r, 13) {
				E[r] = D[(d - r + 13) * 9 % 13];
			}
			*/
			E[0] = D[d * 9 % 13];
			E[1] = D[(d + 12) * 9 % 13];
			E[2] = D[(d + 11) * 9 % 13];
			E[3] = D[(d + 10) * 9 % 13];
			E[4] = D[(d + 9) * 9 % 13];
			E[5] = D[(d + 8) * 9 % 13];
			E[6] = D[(d + 7) * 9 % 13];
			E[7] = D[(d + 6) * 9 % 13];
			E[8] = D[(d + 5) * 9 % 13];
			E[9] = D[(d + 4) * 9 % 13];
			E[10] = D[(d + 3) * 9 % 13];
			E[11] = D[(d + 2) * 9 % 13];
			E[12] = D[(d + 1) * 9 % 13];
		}
		swap(D, E);
	}
	printf("%d", D[5]);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

struct POINT{    
    int x;
    int y1;
    int y2;    //y軸方向の線分の上端のみに使う
    char iEvent;    //0:追加(線分左端)  1:交差(交点)  2:削除(線分右端)

};

bool operator<(const POINT &a, const POINT &b){    //イベントが起きる順番
    if (a.x == b.x && a.iEvent == b.iEvent){
        return a.y1 < b.y1;
    }
    if (a.x == b.x){
        return a.iEvent < b.iEvent;
    }
    return a.x < b.x;
} 

/*bool operator<(const xSEGMENT &zSeg1, const xSEGMENT &zSeg2){    //線分を並べる順
    if(zSeg1.y == zSeg2.y){    //問題の条件から起こらないはず
        return zSeg1.x1 < zSeg2.x1;
    }
    return zSeg1.y < zSeg2.y;
}*/



void INTERSECT(const set<int> &siSegment, const POINT &zPoint, int &nCount){
    std::set<int>::iterator it = siSegment.lower_bound(zPoint.y1);
    if((*it) < zPoint.y1){
        return;
    }
    while((*it) <= zPoint.y2 && it != siSegment.end()){
        it++;
        nCount++;
    }
//    printf("%d/n",nCount);
    return;
}

int main(){
    int n;
    scanf("%d", &n);
    vector<POINT> vzEventPoint;

    for(int i = 0; i < n; i++){
        int x1,x2,y1,y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        if(y1 == y2){
            if(x1 > x2){
                swap(x1, x2);
            }
            POINT zPointLeft,zPointRight;
            zPointLeft.x = x1;
            zPointLeft.y1 = y1;
            zPointLeft.y2 = y1;
            zPointLeft.iEvent = 0;
            zPointRight.x = x2;
            zPointRight.y1 = y1;
            zPointRight.y2 = y1;
            zPointRight.iEvent = 2;
            
            vzEventPoint.push_back(zPointLeft);
            vzEventPoint.push_back(zPointRight);
        }
        if(x1 == x2){
            if(y1 > y2){
                swap(y1, y2);
            }
            POINT zPoint;
            zPoint.x = x1;
            zPoint.y1 = y1;
            zPoint.y2 = y2;
            zPoint.iEvent = 1;
            vzEventPoint.push_back(zPoint);
        }
        
        
    }
    sort(vzEventPoint.begin(), vzEventPoint.end());
    
    set<int> siSegment;    //y座標だけ入れる
    int nCount = 0;
    for (int i = 0; i < vzEventPoint.size(); i++) {
        if (vzEventPoint[i].iEvent == 0) {    
            siSegment.insert(vzEventPoint[i].y1);
        } else if(vzEventPoint[i].iEvent == 2) {
            siSegment.erase(vzEventPoint[i].y1);
        } else {
            INTERSECT(siSegment, vzEventPoint[i], nCount);
        }
    }
    
    printf("%d\n",nCount);
    return 0;
}


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

int main(){
	int n,l,*ice,buf,pg,ov,sz,h=0;
	queue<int> q;
	
	cin >> n >> l;
	
	ice = new int[n+2];
	ice[0] = ice[n+1] = 0;
	for(int i = 1; i < n+1; i++){
		cin >> ice[i];
	}
	
	for(int i = 1; i < n+1; i++){
		if((ice[i] > ice[i-1]) && (ice[i] > ice[i+1])){
				q.push(i);
		}
	}
	
	while(1){
		buf = q.front();
		pg = (l - ice[buf]) > 0?(l - ice[buf]):0;
		
		sz = q.size();
		for(int i = 0; i < sz; i++){
			buf = q.front();
			q.pop();
			
			ice[buf] += pg;
			ov = (ice[buf] - l) >= 0?(ice[buf] - l):-1;
			
			if(ov != -1){
				ice[buf] = 0;
				
				if(ice[buf-1] > ice[buf-2]){
					ice[buf-1] += ov;
					q.push(buf-1);
				}
				if(ice[buf+1] > ice[buf+2]){
					ice[buf+1] += ov;
					q.push(buf+1);
				}
			}else{
				q.push(buf);
			}
		}
		h += pg;
		
		if(q.empty()){
			break;
		}
	}
	
	cout << h << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(been(a),greater<ll>());
    ll ans =a[0];
    int cnt = n-2;
    int now = 1;
    while(cnt>0){
        ans+=a[now]*min(2,cnt);
        cnt-=2;
        now++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
typedef pair<int, int> pii;

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(rbegin(ret), rend(ret));
  return (ret);
}

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    auto v = divisor(sum);
    rep(i, (int)v.size()){
        vector<pii> diff;
        int ofs = 0;
        rep(j,n){
            int q = a[j] / v[i];
            int ne = q*v[i] - a[j];
            int po = v[i]*(q + 1) - a[j];
            if(ne < 0) diff.push_back(make_pair(po, ne));
            ofs += ne;
        }
        if(diff.empty()){
            cout << v[i] << endl;
            return 0;
        }
        sort(ALL(diff));
        int cnt = -ofs / v[i];
        if(cnt > n) break;
        int num = 0;
        rep(i, cnt){
            num += diff[i].first;
        }
        if(num <= k){
            cout << v[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	int n, k;
	cin >> n >> k;
	long long int x[100001];
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	long long int ans = mod;
	for(int i = 0; i + k - 1 < n; i++){
		if(x[i] < 0){
			if(x[i + k - 1] < 0) ans = min(ans, -x[i]);
			else ans = min(ans, min(2 * -x[i] + x[i + k - 1], -x[i] + 2 * x[i + k - 1]));
		} else {
			ans = min(ans, x[i + k - 1]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#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 pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  string s;
  int k;
  cin >> s >> k;
  vector<string> d;
  rep(i, s.size()){
    string t = "";
    int a = min((int)s.size() - i, 5);
    rep(j, a){
      t += s[i+j];
      d.push_back(t);
    }
  }
  sort(ALL(d));
  string tmp = d[0];
  vector<string> v;
  for (int i = 1; i < d.size(); i++){
    if (d[i] != tmp){
      v.push_back(tmp);
      tmp = d[i];
    }
  }
  v.push_back(tmp);
  cout << v[k-1] << endl;
}

Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
int Array[100005] , dp[100005];

int main(){
    int N , i , Ans = 0;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d" , Array + i );

    dp[N] = 0;

    for( i = N - 1 ; i >= 1 ; --i ){
        if( Array[i] >= Array[i + 1] ) dp[i] = dp[i + 1] + 1;
        else dp[i] = 0;
        Ans = max( Ans , dp[i] ); 
    }

    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e10;
const int MOD = 1e9+7;

const int MAX_N = 100005;


int main(int argc, char *args[]) {
	int n, m; cin >> n >> m;
	if (m == n)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;
const pii four_Dir[4] = { //四方向
	{ 1 ,0 },{ 0 ,1 },{ 0,-1 },{ -1 ,0 }
};
char s [11];

ll func( int p, ll adsum, ll cursum) {
	if (s[p] == '\0') {
		return adsum + cursum;
	}
	ll sum = 0;
	sum += func(p+1, adsum*10 + ((s[p])-'0'),cursum);
	sum += func(p+1, 0, cursum + adsum);
	return sum;
}

int main() {
	scanf("%s", s);

	printf("%lld\n",func(0,0,0));

	return 0;
}

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

int main(){
int n,m,a,b,i,N,M;
while(cin>>n>>m){
a=1;
for(i=2;;i++){
N=n%i;
M=m%i;
if(N==0&&M==0){n/=i; m/=i; a*=i; i--;}
if(n<i||m<i)break;}
b=n*m*a;
cout<<a<<" "<<b<<endl;}}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
const int Q=1<<17;
int l[Q],r[Q],b[Q];
ll sm=0;
int n,lim;
struct dt{
    ll p1,p2;
}s[Q];
bool operator<(dt a,dt b)
{return a.p1>b.p1;}
bool Ch(ll used)
{
    int res=(used-1)%lim+1,num=(used-res)/lim;
    for(int i=1;i<=n;i++)
        s[i]=(dt){1LL*r[i]*lim-1LL*(r[i]-l[i])*b[i],max(1LL*l[i]*res,1LL*r[i]*res-1LL*(r[i]-l[i])*b[i])};
    nth_element(s+1,s+num,s+n+1);
    ll mn=1e18,als=0;
    for(int i=1;i<=num;i++){
        als+=s[i].p1;
        mn=min(mn,s[i].p1-s[i].p2);
    }
    ll mx1=-1e18,mx2=-1e18;
    for(int i=num+1;i<=n;i++){
        mx1=max(mx1,s[i].p1);
        mx2=max(mx2,s[i].p2);
    }
    return max(als+mx2,als+mx1-mn)>=sm;
}
int main()
{
    scanf("%d%d",&n,&lim);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d",&b[i],&l[i],&r[i]);
        sm+=1LL*b[i]*l[i];
    }
    ll L=0,R=1LL*n*lim;
    while(L<=R){
        ll MID=(L+R)>>1;
        if(Ch(MID))R=MID-1;
        else L=MID+1;
    }
    printf("%lld\n",L);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> luc(n+1);
  luc.at(0)=2;
  if(n>0) luc.at(1)=1;
  for(int i=2;i<n+1;i++){
    luc.at(i)=luc.at(i-1)+luc.at(i-2);
  }
  cout << luc.at(n) << endl;
}

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

using ll = long long;

signed main() {
  string s;
  ll k;
  cin >> s >> k;
  
  ll n = s.size();    // 元の文字列の長さ
  ll ans = 0;         // 必要な操作回数
  ll top = 0;         // 元の文字列で先頭で同じ文字が連続している数
  ll back = 0;        // 元の文字列で末尾で同じ文字が連続している数

  ll same_char_cnt;   // iから数えて連続する同じ文字の数

  // 元の文字列の中で同じ文字が連続する部分について数を数える
  for (ll i = 0; i < n; i += same_char_cnt) {
    same_char_cnt = 1;
    for (ll j = i + 1; j < n; j++) {
      if (s[i] == s[j])
        same_char_cnt++;
      else
        break;
    }

    // 先頭で連続する同じ文字数をtopに保存する. 先頭に対する操作回数はここでは数えない
    // 例えば元の文字列が、"aaabccdddaa" なら、先頭の"aaa"部分について3を格納する
    if (i == 0) {
      top = same_char_cnt;
      continue;
    }

    // 末尾で連続する同じ文字数をbackに保存する. 末尾に対する操作回数はここでは数えない
    // 例えば元の文字列が、"aaabccdddaa" なら、末尾の"aa"部分について2を格納する
    if (i + same_char_cnt >= n) {
      back = same_char_cnt;
      continue;
    }

    // 文字列の途中で連続する同じ文字に対する操作回数をansに加算する.
    // 例えば元の文字列が、"aaabccdddaa" なら、"b", "cc", "ddd" の3つの部分について計算を行う
    ans += same_char_cnt / 2;
  }

  

  if (top == n) {   // 元の文字列が1つの文字だけで構成される場合
    ans = (n * k) / 2;
  } else {
    // 元の文字列の途中部分に対する操作回数をk倍する
    ans *= k;

    if (s[0] == s[n - 1]) 
      // 先頭と末尾の文字が一致する場合、文字列の接点の操作回数を分けて考える必要がある
      // 先頭と末尾の文字が一致する場合の接点の操作回数は(top + back) / 2 回となる
      // "aaabccdddaa"+"aaabccdddaa"の接点は、"aaaaa"となるので、(3+2)/2 の2回操作する
      // 文字列の接点は、k-1 回あるので、接点の操作回数の和は、(top + back) / 2 * (k - 1) となる
      ans += (top + back) / 2 * (k - 1) + top / 2 + back / 2;
      
    else
      // 先頭と末尾の文字が一致しない場合は、先頭、末尾の操作回数は別々に考えればよい
      ans += k * (top / 2 + back / 2);
      
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N, L = map(int, raw_input().split())
taste = [L+i for i in range(N)]

apple_pi = sum(taste)

min_val = 0
idx = 0
for i in range(N):
    if i == 0:
        min_val = abs(taste[i])
        idx = i
    else:
        tmp = abs(taste[i])
        if min_val > tmp:
            min_val = tmp
            idx = i

print apple_pi - taste[idx]

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 10;
constexpr ll D_MAX = 10;
constexpr ll X_IJ_MAX = 20;

ll N, D;

inline bool isnatural(double x) { return abs(x - round(x)) < EPS; }

void input() {
	scanf("%lld%lld", &N, &D);
	vector<vector<ll>> a(N, vector<ll>(D, 0));
	rep(i,N)rep(j,D){
		cin>>a[i][j];
	}

	ll ans=0;
	rep(i,N)rep(j,N){
		if(i==j)continue;
		double t=0;
		rep(k,D){
			t+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
		}
		t=sqrt(t);
		if(isnatural(t))ans++;
	}
	


	printf("%lld\n", ans/2);
}

signed main() {
	input();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long long gcd(long long a,long long b){
  return b?gcd(b,a%b):a;
}
int main(){
  long long n,t,i;
  scanf("%lld%lld",&n,&t);
  long long ans=t;
  while(--n){
    scanf("%lld",&t);
    ans=(ans/gcd(ans,t))*t;
  }
  printf("%lld",ans);
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let a: Vec<Vec<usize>> = (0..n).map(|_| (0..m).map(|_| read()).collect()).collect();

    let mut cnt: Vec<usize> = vec![0; m];
    for i in 0..n {
        cnt[a[i][0]-1] += 1;
    }

    let mut ans = n;
    let mut num: Vec<usize> = vec![0; n];
    let mut ng: Vec<bool> = vec![false; m];
    for j in 0..m {
        let mut max_n = 0;
        for i in 0..m {
            if !ng[i] && cnt[max_n] < cnt[i] {
                max_n = i;
            }
        }
        ans = std::cmp::min(ans, cnt[max_n]);
        if j == m-1 {
            break;
        }
        ng[max_n] = true;
        for i in 0..m {
            cnt[i] = 0;
        }
        for i in 0..n {
            while ng[a[i][num[i]] - 1] {
                num[i] += 1;
            }
            cnt[a[i][num[i]]-1] += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
//abc135_b.cpp
//Sat Jul 27 20:50:30 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int p[n];
	int count = 0;
	for (int i=0;i<n;i++){
		cin >> p[i];
		if (p[i]!=i+1){
			count++;
		}
	}

	if (count > 2){
		cout << "NO" << endl;
	}else {
		cout << "YES" << endl;
	}
//	printf("%.4f\n",ans);
}

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

const char P = 'a' ^ 'b' ^ 'c';
const int mod = 998244353;

char s[200010];
queue <string> q;
set <string> all;
int dp[200010][3][3][2];

int main () {
	scanf("%s", s); int n = strlen(s);
	if (n <= 3) {
		q.push(s); all.insert(s);
		while (!q.empty()) {
			string x = q.front(); q.pop();
			for (int i = 0; i < n - 1; i++) {
				if (x[i] != x[i + 1]) {
					string nx = x;
					nx[i] = nx[i + 1] = P ^ nx[i] ^ nx[i + 1];
					if (!all.count(nx)) q.push(nx), all.insert(nx);
				}
			}
		}
		printf("%d\n", all.size());
		return 0;
	}
	int eq = 1;
	for (int i = 0; i < n; i++) {
		eq &= s[i] == s[0];
	}
	if (eq) {
		printf("1\n");
		return 0;
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += s[i] - 'a';
	}
	sum %= 3;
	dp[0][0][0][0] = dp[0][1][1][0] = dp[0][2][2][0] = 1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				for (int l = 0; l < 2; l++) {
					for (int x = 0; x < 3; x++) {
						(dp[i + 1][(j + x) % 3][x][l | (x == k)] += dp[i][j][k][l]) %= mod;
					}
				}
			}
		}
	}
	int pd = 1;
	for (int i = 0; i < n - 1; i++) {
		pd &= s[i] != s[i + 1];
	}
	printf("%d\n", ((pd + dp[n - 1][sum][0][1] + dp[n - 1][sum][1][1]) % mod + dp[n - 1][sum][2][1]) % mod);
	return 0;
}


Measured memory_bytes: 14464
#include<stdio.h>
int main(){
    int n,kazu,team[50000]={0},taisena[50000]={0},taisenb[50000]={0},tena[50000]={0},tenb[50000]={0},i,juni[50000]={0};
    int x,y,z,z1,j,saidai1=1000000,k,cnt=0,cnts=0,ab=0,saidai=0;
    scanf("%d",&n);
    kazu = n * (n - 1) / 2;
    for(i=1;i<=kazu;i++){
        scanf("%d %d %d %d",&taisena[i],&taisenb[i],&tena[i],&tenb[i]);
        if(tena[i]>tenb[i]){
            x=taisena[i];
            team[x]+=3;
        }
        if(tenb[i]>tena[i]){
            y=taisenb[i];
            team[y]+=3;
        }
        if(tena[i]==tenb[i]){
            z=taisena[i];
            z1=taisenb[i];
            team[z]+=1;
            team[z1]+=1;
        }
        x=0;y=0;z=0;z1=0;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
        if(saidai<=team[j]&&team[j]<saidai1){
            juni[j]=i;
            saidai=team[j];
        }
        }
        saidai1=saidai;
        saidai=0;
    }
    for(i=1;i<110;i++){
        for(j=1;j<110;j++){
            if(juni[j]==i)cnt++;
        }
        if(cnt!=0&&cnt!=1){
            for(k=1;k<110;k++){
                if(juni[k]>i)juni[k]+=(cnt-1);
            }
        }
        cnt=0;
    }
    for(i=1;i<=100;i++){
        if(juni[i]!=0)printf("%d\n",juni[i]);
    }
    return 0;
}

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

 int ans[81];
  int k=0;
  
  REP(i,1,10){
  REP(j,1,10){ans[k]=i*j;
           k++; }}
  
  int n; cin>>n; int ha=0;
  rep(l,81){
    if(n==ans[l]){ha=1;break;}}
  
  if(ha==1){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}

Measured memory_bytes: 3632
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
P p[2020];
ll dp[2020][2020];
ll solve(){
    rep(i,n){
        int a;
        cin>>a;
        p[i]=P(a,i);
    }
    sort(p,p+n);
    reverse(p,p+n);
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    rep(i,n){
        ll cur=p[i].first;
        int ix=p[i].second;
        rep(x,i+1){
            int y=i-x;
            chmax(dp[x+1][y],dp[x][y]+abs(ix-x)*cur);
            chmax(dp[x][y+1],dp[x][y]+abs(ix-(n-1-y))*cur);
        }
    }
    ll ans=-1;
    rep(x,n+1)chmax(ans,dp[x][n-x]);
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 35556
#include<bits/stdc++.h>
#define M 1001001

struct qvalue{
    std::string name;
    int time;
};

class queue{
public:
    std::vector<qvalue> value;
    int head, tail;


    queue(){
        value.resize(M);
        head = 0;
        tail = 0;
        /*
        tot = 0;
        */
    }

    void enqueue(std::string a, int b){
        if(tail == M){
            tail = 0;
        }
        value[tail].name = a;
        value[tail].time = b;
        tail++;
    }

    qvalue dequeue(void){
        if(head == M){
            head = 0;
        }

        head++;
        return value[head - 1];
    }

    bool isEmpty(){
        if(head == tail){
            return true;
        }
        return false;
    }
};

int main(void){ 
    int n, q, t;
    int time = 0;
    std::string na;
    std::cin >> n >> q;
    queue qu;
    for(int i = 0; i < n; i++){
        std::cin >> na >> t;
        qu.enqueue(na, t);
    }
    while(!qu.isEmpty()){
        qvalue x;
        x = qu.dequeue();
        if(x.time > q){
            qu.enqueue(x.name, x.time - q);
            time += q;
        }else{
            time += x.time;
            std::cout << x.name << " " << time << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 20848
def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    res = 0
    for i in range(1, N):
        A = set(S[:i])
        B = set(S[i:])

        res = max(res, len(A & B))

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
import sys


def main():
    n, t = map(int, input().split())

    ans = 10**5

    for i in range(n):
        ci, ti = map(int, input().split())
        if ti > t:
            continue
        ans = min(ans, ci)

    if ans == 10**5:
        print('TLE')
        return

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, k = 0;
	cin >> n >> k;
	vector<lli> a(n);
	for (auto &i : a)
		cin >> i;
	lli l = 0ll, r = lim, mid = 0ll;
	while (r - l > 1ll)
	{
		mid = (l + r) / 2ll;
		lli sum = 0ll;
		for (auto &i : a)
			sum += (i - 1ll) / mid;
		if (sum <= k)
			r = mid;
		else
			l = mid;
	}
	cout << r << endl;
}

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

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << (s < t ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
s = gets.to_i
dp = []
dp[0] = 1
dp[1] = 0
dp[2] = 0
(3..s).each do |i|
  (0..i-3).each do |j|
    dp[i] ||= 0
    dp[i] += dp[j]
    dp[i] %= 10**9+7
  end
end
puts dp[s]


Measured memory_bytes: 14396
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

double dot(cdouble a, cdouble b) {
	return (a * b.conj).re;
}

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.chomp.split(",").map!(to!double);
		cdouble[2] l;

		l[0] = x[0] + x[1] * 1i;
		l[1] = x[2] + x[3] * 1i;
		auto p = x[4] + x[5] * 1i;
		auto a = p - l[0];
		auto b = l[1] - l[0];
		auto q = 2 * (l[0] + dot(a, b) / (abs(b)^^2) * b) - p;
		writefln("%.8f %.8f", q.re, q.im);
	}
}

Measured memory_bytes: 1268
from math import ceil, floor
from statistics import mean

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

upper = ceil(mean(A))
lower = floor(mean(A))
if abs(upper - mean(A)) > abs(lower - mean(A)) :
    indicator = lower
else :
    indicator = upper

ans = 0
for i in A :
    ans += (i - indicator)**2
print(ans)


Measured memory_bytes: 5392
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
const li inf = 1e14;
// 12
void _main(int tc) {
  int n, W, sumV = 0;
  cin >> n >> W;
  vector<int> w(n), v(n);
  rep(i, n) {
    cin >> w[i] >> v[i];
    sumV += v[i];
  }
  // ********* Recursive ************
  // vector<vector<li>> mem(n, vector<li>(sumV + 1, -1));

  // function<li(int, int)> F = [&](int i, int V) -> li {
  //   if (V == 0) return 0;
  //   if (i == n && V != 0) return inf;
  //   if (mem[i][V] != -1) return mem[i][V];
  //   if (V - v[i] >= 0)
  //     mem[i][V] = min(w[i] + F(i + 1, V - v[i]), F(i + 1, V));
  //   else
  //     mem[i][V] = F(i + 1, V);
  //   return mem[i][V];
  // };

  // rrep(i, sumV + 1) {
  //   if (F(0, i) <= W) {
  //     cout << i << endl;
  //     break;
  //   }
  // }
  // ********* End Recursive ************

  vector<vector<li>> mem(n + 1, vector<li>(sumV + 1, inf));

  rep(i, n + 1) mem[i][0] = 0;

  rrep(i, n) {
    rep(V, sumV + 1) {
      if (V - v[i] >= 0)
        mem[i][V] = min(w[i] + mem[i + 1][V - v[i]], mem[i + 1][V]);
      else
        mem[i][V] = mem[i + 1][V];
    }
  }

  rrep(i, sumV + 1) {
    if (mem[0][i] <= W) {
      cout << i << endl;
      break;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> ls(N);
  int total = 0;
  for(int i = 0; i < N; ++i) {
    cin >> ls[i];
    total += ls[i];
  }
  for(auto l : ls) {
    if(l >= total - l) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    //A:一回の値段
    //B:所持金
    //C:満足する回数
    int ans = 0;
    ans = B / A;
    ans = min(ans, C);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long k,_min,_max,x_y,x[2],fib[2],a,i;double mid;
#define MOD 1000000007
int dp[3];
int main(){
    cin>>k;
    a=sqrt(k)/16;
    x_y=(long long)(2*sqrtl(k-a-0.01))-1;
    _max=(x_y+2)*(x_y+2)/4;
    _min=(x_y+1)*(x_y+1)/4+1;
    mid=1.0*(_max+_min)/2;
    if(k<=mid){x[1]=(k-_min)*2;}
    else{x[1]=(_max-k)*2+1;}
    x[0]=x_y-x[1];
    
    for(int h=0;h<2;h++){
    if(x[h]<3){
        fib[h]=x[h]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[h];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[h]=dp[x[h]%3];
    }
    }
    
    /*if(x[1]<3)
    {
        fib[1]=x[1]+1;
    }
    else{
        dp[0]=1;
        dp[1]=2;
        dp[2]=3;
 
        for(i=3;i<=x[1];i+=3)
        {
            dp[0]=(dp[1]+dp[2])%MOD;
            dp[1]=(dp[2]+dp[0])%MOD;
            dp[2]=(dp[0]+dp[1])%MOD;
        }
 
        fib[1]=dp[x[1]%3];
    }*/
 
    cout<<(fib[0] * fib[1])%MOD<<endl;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,num[1005][5],ans,sum;
vector<long long> v;
int main(){
	cin>>n>>m;
	for (i=1;i<=n;i++){
		for (j=1;j<=3;j++){
			cin>>num[i][j];
		}
	}
	v.clear();
	for (i=1;i<=n;i++){
		v.push_back((+num[i][1])+num[i][2]+num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)v.push_back((+num[i][1])+num[i][2]-num[i][3]);
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++)sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((+num[i][1])-num[i][2]+num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((+num[i][1])-num[i][2]-num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((-num[i][1])+num[i][2]+num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((-num[i][1])+num[i][2]-num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++)
	{
		//cerr<<v[i]<<' ';
		sum+=v[i];
	}
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((-num[i][1])-num[i][2]+num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	v.clear();
	for (i=1;i<=n;i++)
	{
		v.push_back((-num[i][1])-num[i][2]-num[i][3]);
	}
	sum=0;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (i=0;i<m;i++) sum+=v[i];
	ans=max(ans,sum);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, table[101][101];
    int W, H;

    while (cin >> N) {
        if (!N) { break; }
        cin >> W >> H;

        fill(table[0], table[101], 0);

        for (int i = 0; i < N; i++) {
            int x, y;
            cin >> x >> y;
            table[x-1][y-1] = 1;
        }

        int S, T, ans = 0;
        cin >> S >> T;

        for (int x = 0; x <= W-S; x++) {
            for (int y = 0; y <= H-T; y++) {
                int t = 0;
                for (int i = 0; i < S; i++) {
                    for (int j = 0; j < T; j++) {
                        if (table[i+x][j+y]) { t++; }
                    }
                }
                ans = max(ans, t);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3008
import sys
input = sys.stdin.readline
from collections import *

class BIT:
    #n:要素数
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    #i番目(0-indexed)の値にxを足す
    def add(self, i, x):
        i += 1
        
        while i<=self.n:
            self.bit[i] = (x+self.bit[i])%MOD
            i += i&(-i)

    #sum[0:i)
    def acc(self, i):
        s = 0
        
        while i>0:
            s = (s+self.bit[i])%MOD
            i -= i&(-i)
        
        return s

N, K = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(K)]
MOD = 998244353
bit = BIT(N)
bit.add(0, 1)
bit.add(1, -1)

for i in range(N):
    now = bit.acc(i+1)
    #print(i, now)
    
    for L, R in LR:
        if i+L<N:
            bit.add(i+L, now)
        
        if i+R<N:
            bit.add(i+R+1, -now)

print(bit.acc(N))

Measured memory_bytes: 70448
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;


int main(){
    int n;
    cin >> n;
    vector<int> nums;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        nums.push_back(x);
    }
    double sum = 0;
    for(int i = 0; i < nums.size(); ++i){
        sum = sum + 1 / (double)nums[i];
    }
    cout << 1 / sum << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d%d%d',$A,$B,$K);
if($A==$B){
   echo $A;
  echo "\n";
}elseif($A+$K-1<$B-$K+1){
  for ($i=$A; $i <=$A+$K-1 ; $i++) {
    // code...
    echo $i;
    echo "\n";
  }
  for ($i=$B-$K+1; $i <=$B ; $i++) {
    // code...
    echo $i;
    echo "\n";
  }
}else{
  for ($i=$A; $i <=$B ; $i++) {
    // code...
    echo $i;
    echo "\n";
  }
}



 ?>


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main()
{
  ll X;
  cin >> X;
  ll a, b;
  a = X / 500;
  b = (X - a * 500) / 5;
  cout << 1000 * a + 5 * b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a=0,b=0,c,i;
scanf("%d",&c);
for(i=0;i<24;i++){
if(c>=3600){
c-=3600;
a+=1;
}
}
for(i=0;i<60;i++){
if(c>=60){
c-=60;
b+=1;
}
}
printf("%d:%d:%d\n",a,b,c);
return 0;
}

Measured memory_bytes: 592
X,N = map(int,input().split())
a = []
if N != 0:
  a = list(map(int,input().split()))
if a == []:
  print(X)
else:
  for i in range(200):
    if X-i not in a:
      print(X-i)
      break
    if X+i not in a:
      print(X+i)
      break

Measured memory_bytes: 9176
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    vector<long long> table(105);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> table[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n-2; i++){
        for(int j = i+1; j <= n-1; j++){
            for(int k = j+1; k <= n; k++){
                if(table[i] == table[j] || table[j] == table[k] ||
                 table[i] == table[k]) continue;
                if(table[i] < table[j] && table[j] > table[k]){
                    if(table[j] < table[i] + table[k]) cnt++;
                }
                else if(table[i] < table[k] && table[k] > table[j]){
                    if(table[k] < table[i] + table[j]) cnt++;
                }else{
                    if(table[i] < table[k] + table[j]) cnt++;
                }    
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
// #define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

string s[110000];

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


    cout << 0 << endl;
    cin >> s[0];
    if(s[0] == "Vacant") return 0;

    cout << n-1 << endl;
    cin >> s[n-1];
    if(s[n-1] == "Vacant") return 0;

    ll l = 0, r = n-1;

    while(r-l > 1){
        ll h = (l+r)/2;
        cout << h << endl;
        cin >> s[h];
        if(s[h] == "Vacant") return 0;
        if((h-l)%2 == 0){
            if(s[l] != s[h]) r = h;
            else l = h;
        }else{
            if(s[l] == s[h]) r = h;
            else l = h;
        }
    }


    return 0;
}
 
 


Measured memory_bytes: 7028
N = int(input())
C = [] #最遅入り時間
for i in range(N):
    a, b = map(int, input().split())
    C.append((a, b, i))
C.sort(key=lambda x:x[1])

t = 0
ans = 'Yes'
for i in range(N):
    if C[i][1] - C[i][0] < t:
        ans = 'No'
        break
    t += C[i][0]

print(ans)



Measured memory_bytes: 85976
from functools import reduce
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
lcm %= MOD

coef = sum(pow(a, MOD-2, MOD) for a in A)
ans = lcm * coef % MOD

print(ans)

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

using namespace std;

const int maxN = 1e5+10;
int N, K, A[maxN];

int gcd(int x, int y)
{
    if (x == 0) return y;
    return gcd(y%x, x);
}

int main()
{
    cin >> N >> K;
    for (int i=0; i < N; i++) cin >> A[i];
    int valmax = A[0], valgcd = A[0];
    for (int i=1; i < N; i++)
    {
        valmax = max(valmax, A[i]);
        valgcd = gcd(valgcd, A[i]);
    }
    puts((K <= valmax && K%valgcd == 0) ? "POSSIBLE" : "IMPOSSIBLE");
}


Measured memory_bytes: 640