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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.substr(i, 3) == "ABC") {
      ans++;
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


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

int main()
{
   int i,j,t,n,m,a,b,c;
   cin >> n ;
   int arr[n+1],brr[n+1],crr[n+1];
   for(int i = 0 ;i < n ;i++)
   cin >> arr[i] >> brr[i] >> crr[i];
   
   int dp[n+1][3];
   for(int i = 0 ; i<n ;i++)
   {
       for(int j = 0 ;j < 3 ;j++)
       {
           if(i == 0)
           {
               if(j == 0)
               dp[i][j] = arr[i];
               else if(j == 1)
               dp[i][j] = brr[i];
               else
               dp[i][j] = crr[i];
           } 
           else
           {
                if(j == 0)
                dp[i][j] = max((arr[i] + dp[i-1][j+1]),(arr[i] + dp[i-1][j+2]));
                else if(j == 1)
                dp[i][j] = max(brr[i] + dp[i-1][j-1],brr[i] + dp[i-1][j+1]);
                else
                dp[i][j] = max(crr[i] + dp[i-1][j-1],crr[i] + dp[i-1][j-2]);
           }
       }
   }
   int max1 = 0;
   for(int i = 0 ;i < n; i++)
   {
       for(int j = 0 ;j < 3 ;j++)
       {
           if(max1 < dp[i][j])
           max1 = dp[i][j];
       }
   }
   cout<<max1<<endl;
   return 0;
}


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

typedef long long ll;

using namespace std;
int main() {
	int S, Y, M;
	cin >> S;

	Y = S / 100;
	M = S % 100;
	//cout << Y << " " << M << endl;

	if (Y > 12 && M > 12 || Y > 12 && M == 0 || Y == 0 && M > 12 || Y == 0 && M == 0) {
		cout << "NA" << endl;
	}
	else if (M > 0 && Y > 0 && M < 13 && Y < 13) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (M < 13 && 0 < M) {
		cout << "YYMM" << endl;
	}
	else if (Y < 13 && 0 < Y) {
		cout << "MMYY" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d) {
        println("Left");
    }
    else if (a + b == c + d) {
        println("Balanced");
    }
    else {
        println("Right");
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cmath>

using namespace std;

int main() {
 
  int n,sum;
  cin>>n;
  int a[n];
  int b[n];
  int c[n];
  sum = 0;
  for(int i=0;i<n;i++){
        cin >> a[i];
  }
  for(int i=0;i<n;i++){
        cin >> b[i];
    }
  for(int i=0;i<n-1;i++){
        cin >> c[i];
    }
  for(int i=0;i<n;i++){
    sum +=b[i] ;
  }
 for(int i=0;i<n;i++){
    if(a[i]==a[i+1]-1){
      sum +=c[a[i]-1];
    }
 }
    cout<< sum <<endl;
   return 0;
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s[-1]=='s':
    print(s+'es')
else:
    print(s+'s')


Measured memory_bytes: 61784
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(13)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
int dn[4]={-1,1,0,0};
int dm[4]={0,0,-1,1};
ll longinf=(1ll<<60);

int keta(ll n){
      int ret=0;
      while(n>0){
            n/=10;
            ret++;
      }
      return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
      ll N,M;
      cin>>N>>M;
      ll P[M+1],Y[M+1];
      ll cnt[N+1];
      fill(cnt,cnt+N+1,0ll);
      rep0(i,M){
            cin>>P[i]>>Y[i];
      }
      pair<int,int> pr[M];
      rep0(i,M){
            pr[i].first=Y[i];
            pr[i].second=P[i];
      }
      sort(pr,pr+M);
      map<ll,ll> citynum;
      rep0(i,M){
            ll y,p;
            y=pr[i].first;
            p=pr[i].second;
            cnt[p]++;
            citynum[y]=1000000*p+cnt[p];
      }
      rep0(i,M){
            string hoge={};
            for(int j=keta(citynum[Y[i]]);j<12;j++){
                  hoge+='0';
            }
            cout<<hoge<<citynum[Y[i]]<<"\n";
      }

      return 0;
}


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

int main(){
    string s , t;
    cin >> s >> t;
    int ansfin = 0;
    for(int i = 0;i < (t.size()-1);i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            ansfin++;
            break;
        }
    }
    if(t.size() - s.size() == 1 && ansfin == 0)cout << "Yes" << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
    double l;
    cin >> l;
    double volume;
    double a,b,c;
    volume=pow(l/3,3);
    long volumeLong = (long)volume;
    long digit = volumeLong/10+1;
    //long small = (long)((volume-volumeLong)*pow(10,12));
    cout <<fixed<<  setprecision(12) << volume  << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    s = input().split()
    if s[1] == "?":
        break
    if s[1] == "+":
        print(int(s[0])+int(s[2]))
    elif s[1] == "-":
        print(int(s[0])-int(s[2]))
    elif s[1] == "*":
        print(int(s[0])*int(s[2]))
    else:
        print(int(s[0])//int(s[2]))


Measured memory_bytes: 5600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static java.lang.Math.*;


public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Point> list = IntStream.range(0, n)
            .mapToObj(i -> new Point(scanner.nextInt(), scanner.nextInt()))
            .collect(Collectors.toList());

        final List<Long> zList = list.stream()
            .map(p -> p.x + p.y)
            .sorted(Comparator.reverseOrder())
            .collect(Collectors.toList());

        final List<Long> wList = list.stream()
            .map(p -> p.x - p.y)
            .sorted(Comparator.reverseOrder())
            .collect(Collectors.toList());

        System.out.println(max(zList.get(0) - zList.get(zList.size() - 1), wList.get(0) - wList.get(wList.size() - 1)));
    }

    private static class Point {
        final long x;
        final long y;

        Point(final int x, final int y) {
            this.x = x;
            this.y = y;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 79356
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];

    }
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            a[i]--;
        }
        else if(a[i]<a[i-1]){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout << "Yes"<<endl;
    return 0;
}



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

int main()
{
	string s;
	cin >> s;
	int K;
	cin >> K;
	int N = s.size();
	for (int i = 0; i < N; ++i)
	{
		string temp = "";
		for (int j = i; ((j < N) & (j <= i + 4)); ++j)
		{
			temp += s[j];
			subs.insert(temp);
		}
	}

	auto it = subs.begin();
	/*
	while(it != subs.end())
	{
		cout << *it << " ";
		it++;
	}
	cout << endl;
	it = subs.begin();
	*/
	rep(i,K-1)
	{
		it++;
	}
	cout << *it << endl;
	return 0;
}

Measured memory_bytes: 4732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		
		for ( int i = 0; i < a.length() ; i++) {
			if((char)a.charAt(i)=='7') {
				System.out.println("Yes");
				break;
			}
			if(i == a.length() - 1) {
				System.out.println("No");
			}
		}
		
	}
	
}


Measured memory_bytes: 26996
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x1 = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            x1 += a
        else:
            x1 -= a
    x_list = [x1]
    for a in A[:-1]:
        x_list.append(2 * a - x_list[-1])
    print(' '.join([str(x) for x in x_list]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99832
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=n-1;i>0;i--)
  {
      if(a[i]<a[i-1]-1)
        return cout<<"No",0;
      else
        if(a[i]==a[i-1]-1)
          a[i-1]--;
  }
  return cout<<"Yes",0;
}

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

int main()
{
	for(int n;cin>>n&&n;){
		vector<int> a(n);
		for(int& x:a) cin>>x;
		map<int,int> f;
		for(int x:a) f[x]++;

		vector<int> edges;
		for(int i=0;i<2;i++){
			int edge=0;
			for(auto p:f)
				if(p.second>=2)
					edge=p.first;
			edges.push_back(edge);
			f[edge]-=2;
		}
		cout<<(long long)edges[0]*edges[1]<<endl;
	}
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<ll> a(N);

  for(int i=0;i<N;i++) cin >> a[i];

  ll ns,nc;

  ns=0;nc=1000;
  for(int i=0;i<N-1;i++){
    if(a[i+1]<a[i]){
      nc+=a[i]*ns;
      ns=0;
    }else{
      ns+=nc/a[i];
      nc%=a[i];
    }
  }

  cout << ns*a[N-1]+nc << endl;


  return 0;
}


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

int main() {
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max(0,((h2-h1)*60+m2)-m1-k) << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    ll x;
    cin>>x;
    for(ll a=-200;a<=200;a++){
        for(ll b=-200;b<=200;b++){
            if(pow(a,5)-pow(b,5)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
const ll inf=1e12;


string s;
int h[26];
int main(){
    cin>>s;
    ll ans=1;
    for(int i=0;i<s.length();i++){
        h[s[i]-'a']++;
        ans+=i+1-h[s[i]-'a'];
    }
    cout<<ans;
}


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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

lli maxSubsetSum(vl v)
{
	lli max_so_far=LLONG_MIN,max_ending_here=0;
	for(lli i=0;i<(lli)v.size();i++)
	{
		max_ending_here+=v[i];
		if(max_so_far<max_ending_here)
		max_so_far=max_ending_here;
		if(max_ending_here<0)
		max_ending_here=0;
	}
	return max_so_far;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    if(s.length()+1!=t.length())
    {
		cout<<"No\n";
		return 0;
	}
    lli i=0;
    for(i=0;i<s.length();i++)
    {
		if(s[i]!=t[i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	
	
	
return 0;
}


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

#define int long long

vector<int> adj[2000005];
bool visited[2000005];
int maxi = 0;

int dfs(int u)
{
  int ans = 0;
  if (!visited[u])
  {
    visited[u] = true;
    ans++;
    for (auto v : adj[u])
    {
      ans += dfs(v);
    }
  }
  return ans;
}

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  memset(visited, false, sizeof(visited));
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 0; i < n; i++)
  {
    if (!visited[i])
    {
      maxi = max(maxi, dfs(i));
    }
  }
  cout << maxi;
  return 0;
}

Measured memory_bytes: 64488
n, m = [int(i) for i in input().split()]
a= [int(i)%m for i in input().split()]

s = [0]*(n+1)
d = {0:1}
for i in range(len(a)):
    s[i+1]=(s[i]+a[i])%m
    if s[i+1] in d:
        d[s[i+1]] +=1
    else:
        d[s[i+1]] = 1

def calc(n):
    return int(n*(n-1)/2)

ans = 0
for i in d:
    ans += calc(d[i])

print(ans)

Measured memory_bytes: 62848
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		String s = scanner.nextLine();
		char[] cs = s.toCharArray();
		
		for (int i = 0; i < cs.length; i++) {
			if (i%2==1) {
				cs[i] = ' ';
			}
		}
		
		String ans = new String(cs);
		System.out.println(ans.replace(" ", ""));
		
		scanner.close();
	}

}

Measured memory_bytes: 30524
fun main(args: Array<String>) {
    val (k, n) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }
    val diffList = (0 until (n - 1)).map { list[it + 1] - list[it] }.plus((list[0] + k) - list[n - 1])
    val maxLength = diffList.max()!!
    val result = k - maxLength
    println(result)
}

Measured memory_bytes: 83096
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();

    return __ret;
}

fn xcube(n: i32) -> i32 {
    return n * n * n;
}

fn main() {
    let line = getline();
    let num = line.trim().parse::<i32>().unwrap();
    println!("{}", xcube(num));
}



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

int main() {
    int k, a, b; cin >> k >> a >> b;
        
    long long ans = k + 1;
    
    k -= (a + 1);

    if(k < 0) {
        cout << ans << "\n";
        return 0;
    }

    long long temp = (b + 1LL * (k / 2) * (b - a) + k % 2);
    ans = max(ans, temp);

    cout << ans << "\n";
}

Measured memory_bytes: 256
s = input()
index_A = float('inf')
index_Z = float('inf')
for i in range(len(s)):
    if s[i] == 'A':
        index_A = i
        break

for i in range(len(s) - 1, -1, -1):
    if s[i] == 'Z':
        index_Z = i
        break
print(len(s[index_A:index_Z + 1]))

Measured memory_bytes: 3512
s = int(input())
cou = 1
tmp = 0
flag = 0
List = [s]
while(flag == 0):
  if(cou == 1):
    if(s % 2 == 0):
      tmp = s / 2
      List.append(tmp)
    else:
      tmp = 3 * s + 1
      List.append(tmp)
    cou += 1
  else:
    if(List.count(tmp) == 2):
      print(str(cou))
      break
    if(tmp % 2 == 0):
      tmp = tmp / 2
      List.append(tmp)
    else:
      tmp = 3 * tmp + 1
      List.append(tmp)
    cou += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
const int Mod=1e9+7;
int main()
{
	int n,k;
	while(~sf("%d %d",&n,&k))
	{
		vector<ll>vec,neg,pos;
		for(int i=0;i<n;i++)
		{
			ll x;
			sf("%lld",&x);
			vec.push_back(x);
			if(x<0)neg.push_back(x);
			else pos.push_back(x);
		}

		sort(all(vec));
		if(k==n)
		{
			ll ans=1;
			for(int i=0;i<n;i++)
			{
				ans=(ans*(vec[i]+Mod)%Mod)%Mod;
			}
			pf("%lld\n",ans);
		}
		else if(sz(pos)==0)
		{
			if(k%2)
			{
				sort(rall(neg));
				ll ans=1;
				for(int i=0;i<k;i++)
				{
					ans=(ans*(neg[i]+Mod)%Mod)%Mod;		
				}
				pf("%lld\n",ans);
			}
			else
			{
				sort(all(neg));
				ll ans=1;
				for(int i=0;i<k;i++)
				{
					ans=(ans*(neg[i]+Mod)%Mod)%Mod;		
				}
				pf("%lld\n",ans);
			}
		}	
		else
		{
			sort(rall(pos));
			sort(all(neg));
			int nPos=min(sz(pos),k);
			int nNeg=k-nPos;
			if(nNeg%2)
			{
				nNeg++;
				nPos--;
			}
			
			while(nNeg+1<sz(neg) && nPos-2>=0 && neg[nNeg]*neg[nNeg+1]>=pos[nPos-1]*pos[nPos-2])
			{
				nNeg+=2;
				nPos-=2;
			}
			
			ll ans=1;
			for(int i=0;i<nNeg;i++)ans=(ans*(neg[i]+Mod)%Mod)%Mod;
			for(int i=0;i<nPos;i++)ans=(ans*pos[i])%Mod;
			pf("%lld\n",ans);
		}
	}
    return 0;
}



































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

int main(){
    bool cards[4][14] = {{false}};
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        string mark;
        int num;
        cin >> mark >> num;
        if(mark == "S") cards[0][num] = true;
        else if(mark == "H")cards[1][num] = true;
        else if(mark == "C") cards[2][num] = true;
        else cards[3][num] = true;
    }
    
    for(int i = 0;i < 4;i++){
        for (int j = 1;j <= 13;j++){
            if(cards[i][j] ==  false){
                if(i == 0) cout << "S " << j << endl;
                else if(i == 1) cout << "H " << j << endl;
                else if(i == 2) cout << "C " << j << endl;
                else cout << "D " << j << endl;
            }
        }
    }
}



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

int main()
{
 int n;
  cin >> n;
  set<long long> s;
  for (int i = 0;i < n;i++)
  {
   long long tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  if (s.size() == n)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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


void solve(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0; i<n; ++i) cin>>vec[i];
    ll cnt = 0;
    for(int i=0; i<n-2; ++i){
        for(int j=i+1; j<n-1; ++j){
            for(int k=j+1; k<n; ++k){
                if(vec[i] != vec[j] && vec[j] != vec[k] && vec[i] != vec[k]){
                    if(vec[i] + vec[j] > vec[k] && vec[k] + vec[j] > vec[i] && vec[i] + vec[k] > vec[j] ) cnt++;
                }
            }
        }
    }
    cout << cnt << endl;


}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q;
    q=1;
    // cin>>q;
    while(q--) solve();


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,i;
    cin>>n;
    x=1;
    for(i=1;i<=n;i++)
    {
        x=(x*i)%(1000000007);
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3588
R = []

C  = 0
C1 = 0
C2 = 0

for j in range(3):
	R.append(list(map(int, input().split())))

for i in range(1,5):
	for j in range(3):
		if (i == R[j][0]) or (i == R[j][1]):
			C += 1
	if C == 1:
		C1 += 1
	if C == 2:
		C2 += 1
	C = 0

if C1 == 2 and C2 == 2:
	print("YES")
else:
	print("NO")


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

int main()
{
	string S; cin>>S; char arr[3]; arr[0]=S[0]; arr[1]=S[1]; arr[2]=S[2];
	if(arr[0]=='R')
	{
		if(arr[1]=='R')
		{
			if(arr[2]=='R')
			cout<<3<<endl;
			else
			cout<<2<<endl;
		}
		else
		cout<<1<<endl;
		
	}
	else
	{
		if(arr[1]=='R')
		{
			if(arr[2]=='R')
			cout<<2<<endl;
			else
			cout<<1<<endl;
		}
		else
		{
			if(arr[2]=='R')
			cout<<1<<endl;
			else
			cout<<0<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[300],ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	while(1){
		bool flag = true;
		for(int i = 0;i < n;i++){
			if(a[i] % 2) flag = false;
		}
		if(!flag) break;
		ans++;
		for(int i = 0;i < n;i++) a[i] /= 2;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;

    long long mx = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        mx = max(mx, x);
        ans += (mx - x);
    }

    cout << ans;

}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3644
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL vmax(vi v, LL n) {
	int MAX = 0;
	f(i, 0, n) {
		MAX = max(MAX, v[i]);
	}
	return MAX;
}

LL vmin(vi v, LL n) {
	int MIN = LL_INF;
	f(i, 0, n) {
		MIN = min(MIN, v[i]);
	}
	return MIN;
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
bool contain(int mask, int pos) {
	if ((mask&(1 << pos)) != 0) {
		return true;
	}
	return false;
}
signed main(void) {
	st s;
	cin >> s;
	int n = size(s) - 1;
	int sum = 0;
	f(mask, 0, 1 << n) {
		int l = 0;
		int tmp = 0;
		int r;
		for (r = 0; r < n; r++) {
			if (contain(mask, r)) {
				st t = s.substr(l, r - l + 1);
				int num = stoll(t);
				tmp += num;
				l = r + 1;
			}
		}
		st t = s.substr(l, r - l + 1);
		int num = stoll(t);
		tmp += num;
		sum += tmp;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;



int main() {
    ll n;
    cin >> n;
    if(n % 2) {
        puts("0");
        return 0;
    }
    ll ans = 0;
    ll d = 10;
    while(n / d > 0) {
        ans += n / d;
        d *= 5;
    }
    cout << ans << endl;

    return 0;
}


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

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

using namespace std;

struct edge {
    typedef size_t weight_type;

    size_t m_to;

    edge(size_t to) : m_to(to) { }

    inline size_t to() const { return m_to; }

    inline weight_type weight() const { return 1; }

    friend std::ostream& operator<<(std::ostream &os, const edge &e) {
        os << "{ to: " << e.m_to << " }";
        return os;
    }
};

template <class Edge>
struct graph {
    typedef Edge edge_type;

    size_t m_n_vertices;
    std::vector<std::vector<edge_type>> m_edges;

    graph(size_t n_vertices) : m_n_vertices(n_vertices), m_edges(n_vertices) { }

    inline size_t n_vertices() const { return m_n_vertices; }

    inline void make_edge(size_t from, size_t to, typename edge_type::weight_type weight) {
        m_edges[from].emplace_back(edge_type(to, weight));
    }

    inline void make_edge(size_t from, size_t to) {
        m_edges[from].emplace_back(edge(to));
    }

    inline void make_edge(size_t from, const edge_type &e) {
        m_edges[from].emplace_back(e);
    }

    inline std::vector<edge_type> edges_from(size_t v) const {
        return m_edges[v];
    }
};

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

    using Graph = graph<edge>;

    int N;
    cin >> N;
    Graph g(N);
    REP(i, N) {
        string S;
        cin >> S;
        REP(j, N) {
            if (S[j] == '1') {
                g.make_edge(i, j);
            }
        }
    }

    function<int(int)> f = [&](int root) {
        queue<int> q;
        vector<int> depth(N, -1);

        depth[root] = 1;
        q.push(root);

        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (auto e: g.edges_from(u)) {
                int v = e.to();
                if (depth[v] == -1) {
                    depth[v] = depth[u] + 1;
                    q.push(v);
                } else if (abs(depth[v] - depth[u]) != 1) {
                    return -1;
                }
            }
        }

        return *max_element(all(depth));
    };

    int result = -1;

    REP(i, N) result = max(result, f(i));

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 640
module aoj;
import std.conv;
import std.stdio;
import std.string;

int getInt() { return to!int(chomp(readln())); }

void main() {
  int n;
  while ((n = getInt()) != 0) {
    int sum = 0;
    foreach (i; 0 .. n/4) {
      sum += getInt();
    }
    writeln(sum);
  }
}

Measured memory_bytes: 964
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    V<char> a(q),b(q);
    for(int i=0;i<q;i++)cin>>a[i]>>b[i];
    int l=-1,r=n;//rを場外用に開区間にしておく
    while(r-l>1){
        int mid=(l+r)/2;
        int now=mid;
        for(int i=0;i<q;i++){
            if(now<0||now>=n)break;
            if(s[now]!=a[i])continue;
            if(b[i]=='L')now--;
            else now++;
        }
        if(now<0)l=mid;
        else r=mid;
    }
    int L=r;
    l=-1,r=n;//lを場外用に開区間にしておく
     while(r-l>1){
        int mid=(l+r)/2;
        int now=mid;
        for(int i=0;i<q;i++){
            if(now<0||now>=n)break;
            if(s[now]!=a[i])continue;
            if(b[i]=='L')now--;
            else now++;
        }
        if(now>=n)r=mid;
        else l=mid;
    }
    cout<<max(0,l-L+1)<<"\n";
}

Measured memory_bytes: 976
#include <iostream>
#define rep(i, N) for(int i = 0; i < N; ++i)
using namespace std;

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

    ll sum = 0;
    for(ll i = 1; i <= n; i++)
    {
        if((i % 3 != 0) && (i % 5 != 0))
        {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
int main()
{
 string s;
 cin>>s;

 sort(s.begin(),s.end());
 if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
     cout<<"Yes\n";
 else
    cout<<"No\n";
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    rep(i, n + 1) {
        if (i == 0) continue;
        ans *= i;
        ans %= mod;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    lint C;
    cin >> N >> C;

    VEC(lint) X(N), V(N);
    VEC(lint) S(N + 1, 0LL);

    FOR(i, 0, N) {
        cin >> X[i] >> V[i];
        S[i + 1] = S[i] + V[i];
    }

    lint ret = 0;
    FOR(i, 1, N + 1) {
        // go clockwise.
        lint dist = X[i - 1], eat = S[i];
        ret = max(ret, eat - dist);

        // go counter-clockwise.
        dist = C - X[i - 1];
        eat = S[N] - S[i - 1];
        ret = max(ret, eat - dist);
    }

    VEC(lint) eb(N + 1), ef(N + 1);
    eb[0] = ef[0] = 0;
    FOR(i, 1, N + 1) {
        ef[i] = max(ef[i - 1], S[i] - X[i - 1]);
        eb[i] = max(eb[i - 1], S[N] - S[N - i] - (C - X[N - i]));
    }

    FOR(i, 1, N) {
        ret = max(ret, ef[i] - X[i - 1] + eb[N - i]);
        ret = max(ret, eb[i] - (C - X[N - i]) + ef[N - i]);
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 4224
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10000000)
n=int(input())
a=list(map(int,input().split()))
edge=[[]for _ in range(n)]
for x,y in[list(map(int,input().split()))for _ in range(n-1)]:
  edge[x-1].append(y-1)
  edge[y-1].append(x-1)
def bfs(r,v):
  for i in edge[v]:
    if(r!=i)and(a[v]>a[i])and(not(bfs(v,i))):return True
  return False
print(*[i+1 for i in range(n)if bfs(-1,i)])

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
// string t="coffee";
cin>>s;
if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
n, x =gets.strip.split.map{ |num| num.to_i}
grams = []
base_gram = 0
for i in 1..n
  gram = 0
  gram = gets.to_i
  base_gram += gram
  grams << gram
end

x = x - base_gram
min_gram = grams.sort[0]
puts n + x/min_gram

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

int main()
{
  i64 n, k;
  cin >> n >> k;
  vector<double> p(n + 1);
  for (i64 i = 0; i < n; i++)
  {
    i64 t;
    cin >> t;
    p[i + 1] = (double)(t + 1) / 2;
  }
  for (i64 i = 1; i <= n; i++)
    p[i] += p[i - 1];
  double ans = 0;
  for (i64 i = 0; i < n - k + 1; i++)
    ans = max(ans, p[i + k] - p[i]);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
n = int(input())
l = {}
for i in range(n):
  a = int(input())
  if a in l:
    l[a] +=1
  else:
    l[a] = 1
ans = 0
for i in l.values():
    if i % 2 == 1:
        ans += 1
print(ans)

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

ll gcd (ll n, ll k) {
	ll mod = n % k;
	if (mod == 0)
		return k;
	else
		return gcd(k, mod);
}

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

	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	rep (i, 0, n)
		cin >> a[i];

	int max_v = *max_element(a.begin(), a.end());

	int gcd_v = a[0];
	rep (i, 1, n) {
		gcd_v = gcd(a[i], gcd_v);
	}

	if (k <= max_v && k % gcd_v == 0)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 640
L = int(input())
v = 1
edges = []
n = 2
cost = 1
while n<=L:
    edges.append((v,v+1,0))
    edges.append((v,v+1,cost))
    cost *=2
    v += 1
    n *=2
goal = v
n//=2
N = n
L -=N
while L>0:
    if L>=n:
        edges.append((v,goal,N))
        L-=n
        N+=n
    n//=2
    v-=1
print(goal,len(edges))
for e in edges:
    print(*e)

Measured memory_bytes: 62232
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>
using namespace std;

int main()
{
	int a;
	deque<int> b;
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == n % 2) {
			b.push_back(a);
		}
		else {
			b.push_front(a);
		}
	}

	for (int i : b) {
		cout << i << " ";
	}

	return 0;
	
}

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

int main() {
	 int n;
	  string s;
	  cin >> n >> s;
	  int count = 0;
	  if(s.length() % 2 == 0){
	  for(int i = 0; i < n / 2; i++) {
	    if(s[i] == s[i + (n / 2)]) {
	      count++;
	    }
	  }
	  if(count == n / 2) {
	    cout << "Yes" << endl;
	  }else {
	    cout << "No" << endl;
	  }
	  }else {
		  cout << "No" << endl;
	  }
	return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0; i < n; ++i){ cin >> s[i]; }
	int answer = 0;
	for(int i = 0; i < n; ++i){
		bool accept = true;
		for(int y = 0; y < n; ++y){
			for(int x = y; x < n; ++x){
				const int y0 = y, x0 = (x + i) % n;
				const int y1 = x, x1 = (y + i) % n;
				if(s[y0][x0] != s[y1][x1]){ accept = false; }
			}
		}
		if(accept){ answer += n; }
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
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);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll c1 = b/c - (a-1)/c;
    ll d1 = b/d -(a-1)/d;
    ll l = lcm(c,d);
    ll l1 = b/l - (a-1)/l;
    ll res = b-a-(c1+d1-l1)+1;
    ct(res);
}


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


int main()
{

ll a,b, c, d;
cin>>a>>b>>c>>d;

ll x= a*c;
ll y= a*d;

ll z= b*c;

ll w= b*d;

ll e= max(x,y);

ll f= max(z,w);

cout<<max(e,f)<<endl;

     return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  
 string S;
  cin >>S;
  ll x=S.size();
  ll count1=0;
  ll count2=0;
  
  rep(i,x) {
    if(S.at(i)=='0') {
      count1++;
    }
    if(S.at(i)=='1') {
      count2++;
    }
  }
  
  ll z=min(count1, count2);
  cout<<z*2<<endl;
}
  
  
  

Measured memory_bytes: 512
use std::fmt::Debug;
fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_multi_line<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for i in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.parse().ok().expect("Can't Parse"));
    }
    vec
}

macro_rules! ignore {
    ($id:ident) => {};
}
macro_rules! assign {
    (let $($id:ident),* = $value:expr) => {
        let ($($id), *) = {
            let mut iter = $value.into_iter();
            ($({ignore!($id); iter.next().unwrap()}), *)
        }
    };
}
fn inspect<T: Debug>(vec: &Vec<T>) -> () {
    if let Some(first) = vec.first() {
        println!("Vec({:?}", first);
        for i in 1..vec.len() {
            println!(", {:?}", vec[i]);
        }
        println!(")");
    }else {
        println!("Vec()");
    }
}
fn sum(n: i64) -> i64 {
    n * (n + 1) / 2
}
fn main() {
    let n = read_value::<i64>();
    println!("{}", sum(n) - sum(n / 3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15);
}


Measured memory_bytes: 2148
w,h,n=map(int,input().split())
xmax=w
ymax=h
xmin=0
ymin=0

for i in range(n):
  x,y,a=map(int,input().split())
  if a==1 and xmin<x:
    xmin=x
  if a==2 and xmax>x:
    xmax=x
  if a==3 and ymin<y:
    ymin=y
  if a==4 and ymax>y:
    ymax=y

if (xmax-xmin)>0 and (ymax-ymin)>0:
  print((xmax-xmin)*(ymax-ymin))
else:
  print(0)
    


Measured memory_bytes: 3064
a = int(input())
b = [int(i) for i in input().split()]

ans =1
b = sorted(b)
for I in b:
  ans = ans*I
  if b[0] == 0:
      ans = 0
      print(0)
      break
  elif ans > 10**18:
    print('-1')
    ans = -1
    break
if ans >=1:
    print(ans)
      
    





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

int main() {
int K,N;
  cin >> K >> N ;
  vector<int> lake(N+1);
  cin >> lake[0];
  int ans = 0;
  for(int i = 1; i < N; i++){
  	cin >> lake[i];
    ans = max(ans, lake[i]-lake[i-1]);
  }
  lake[N] = K + lake[0];
  ans = max(ans, lake[N]-lake[N-1]);
  cout << K - ans << endl;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  ll N,H;cin>>N>>H;
  vector<ll> as(N);
  vector<ll> bs(N);

  REP(i,N) cin>>as[i]>>bs[i];
  sort(ALL(as));
  sort(ALL(bs));
  // a最大より大きなbを持つ剣を最後に全部投げる（a最大の剣も含む）
  // その後もし足りなければa最大で攻撃し続ける

  // bsの逆側からの累積和
  vector<ll> rev_accum_bs(N);
  rev_accum_bs[N-1] = bs[N-1];
  for (int i=N-2;i>=0;i--) {
    rev_accum_bs[i] = rev_accum_bs[i+1]+bs[i];
  }

  // DUMP(bs);
  // DUMP(rev_accum_bs);

  ll max_a = as.back();

  // a最大がb最大以上の場合
  if (max_a>=bs.back()) {
    if (H%max_a==0) {
      OUT(H/max_a);
    } else {
      OUT(H/max_a+1);
    }
    return 0;
  }

  // bsのうち、aより大きい箇所のidx
  int b_idx = lower_bound(ALL(bs),max_a+1)-bs.begin();

  // 投擲だけで倒せる場合
  if (rev_accum_bs[b_idx]>=H) {
    reverse(ALL(rev_accum_bs));
    OUT(lower_bound(ALL(rev_accum_bs),H)-rev_accum_bs.begin()+1);
    return 0;
  }

  // 残りライフ
  int rest = H-rev_accum_bs[b_idx];
  // 投擲回数
  ll throw_cnt = N-b_idx;
  // 残りライフをa最大で削る
  (rest%max_a==0) ? OUT(throw_cnt+rest/max_a) : OUT(throw_cnt+rest/max_a+1);

  return 0;
}

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

 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
 
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        v.push_back(c);
    }

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

    int num1, num2, media;
    num1 = v[n/2 - 1];
    num2 = v[n/2];
    media = (num1 + num2)/2;
    int ans = (media - num1) + (num2 - media);

    cout << ans << endl;
    
}

Measured memory_bytes: 892