akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int total =  0;
		
		for (int i = 0 ; i < n ; i++) {
			if (i < k) total += x;
			else if (i >= k) total += y;
		}
		System.out.println(total); 
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    double a,b,c,C;
    cin>>a>>b>>C;
    double pi=acos(-1);
    double rad=C*pi/180;
    double S,L,h;
    S=a*b*sin(rad)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
    h=2*S/a;
    #include<iostream>
    printf("%.4f\n%.4f\n%.4f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 3372
#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;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> b(n-1);
    vector <ll> ans(n,LLONG_MAX);
    for (int z=0;z<n-1;z++){
        cin  >> b[z];
    }
    for (int z=0;z<n-1;z++){
        ans[z] = min(ans[z],b[z]);
        ans[z+1] = min(ans[z+1],b[z]);
    }
    ll s = 0;
    for (ll i : ans){
        s += i;
    }
    cout << s << endl;
}

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

int main(){
    int r;
    cin >> r;
    if(r<1200) {
        cout << "ABC";
    }
    else if (r>=1200 && r<2800) {
        cout << "ARC";
    }
    else {
        cout << "AGC";
    }
}


Measured memory_bytes: 256
use strict;
use warnings;

chomp(my $s = <>);

my $cnt = 0;

$s =~ s/BC/D/g;

my @list = split /[BC]/, $s;
foreach my $item (@list) {
	
	next if $item eq "";
	#print $item, "\n";
	
	my $str = $item;
	while ($str =~ m/AD/) {
		$str =~ s/(.*?)A/A/;
		$str =~ s/(A+)(D+)/$1/;
		my $add = (length $1) * (length $2);
		$cnt += $add;
	}
}

print $cnt, "\n";


Measured memory_bytes: 18048
#include<cstdio>
long long cnt[100005];

int main(){
    int n;
    scanf("%d",&n);
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        cnt[u]++;
        sum += u;
    }
    int q;
    scanf("%d",&q);
    while(q--){
        long long a,b;
        scanf("%lld%lld",&a,&b);
        sum -= cnt[a]*a;
        sum += cnt[a]*b;
        cnt[b] += cnt[a];
        cnt[a] = 0;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2512
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #define f(i,l,r) for(int i=l;i<=r;i++)
    #define rf(i,r,l) for(int i=r;i>=l;i--)    

    #define bp __builtin_popcountll
    #define inf 3e18
    
    const int N=1e5+5; 
    const int M=1e9;
    #define pi 3.14159265359
    void solve()
    {
    	int n;
    	cin>>n;
    	int a[n+1]={0};
    	f(i,2,n)
    	{
    		int t1;
    		cin>>t1;
    		a[t1]++;
    		a[i]++;
    	}
    	a[1]++;
    	f(i,1,n)
    	{
    		cout<<a[i]-1<<endl;
    	}
    }
      signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        for(int tc=1;tc<=t;tc++)
        {
    		// cout<<"Case #"<<tc<<": ";
    		solve();
        }
    }



Measured memory_bytes: 5224
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            double x = Double.parseDouble(br.readLine());
            double h = Double.parseDouble(br.readLine());
            
            if(x == 0 && h == 0) break;

            double surface = x * x + 2 * x * Math.sqrt(x*x/4 + h*h);

            System.out.printf("%.6f\n",surface);
        }
    }
}


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

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

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

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  int mode; //0:<= 1:>= 2:=
  int count=0;
  rep(i,n){
    while(i+1<n&&a.at(i+1)==a.at(i)) i++;
    if(i+1<n&&a.at(i+1)>=a.at(i)) mode=0;
    else if(i+1<n&&a.at(i+1)<=a.at(i)) mode=1;
    
    //mode:0
    if(mode==0) {while(i+1<n&&a.at(i+1)>=a.at(i)) i++;}
    if(mode==1) {while(i+1<n&&a.at(i+1)<=a.at(i)) i++;}

    count++;
    //cout << i << endl;
  }

  cout << count;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main() 
{
    FIO
    int p,n; cin>>p>>n;
    int arr[n];
    int maxx = 0;
    REP(i,0,n) {
    	cin>>arr[i];
    }

    REP(i,1,n) {
    	maxx = max(maxx, arr[i]-arr[i-1]);
    }

    maxx = max(maxx, arr[0]+p-arr[n-1]);

    cout<<p - maxx;


    return 0;
}

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

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> P(A);
  for (int i = 0; i < A; i++) cin >> P.at(i);
  vector<int> Q(B);
  for (int i = 0; i < B; i++) cin >> Q.at(i);
  vector<int> R(C);
  for (int i = 0; i < C; i++) cin >> R.at(i);
  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  for (int i = 0; i < X; i++) {
    R.push_back(P.at(i));
  }
  for (int i = 0; i < Y; i++) {
    R.push_back(Q.at(i));
  }
  sort(R.rbegin(), R.rend());
  long ans = 0;
  for (int i = 0; i < X + Y; i++) {
    ans += R.at(i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 5592
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.equals("A")){
      System.out.println("T");
    }else if(s.equals("T")){
      System.out.println("A");
    }else if(s.equals("G")){
      System.out.println("C");
    }else{
      System.out.println("G");
    }
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        long[] A = new long[n], B = new long[n];
        long[] C = new long[m], D = new long[m];
        for (int i = 0; i < n; ++i) {
            A[i] = sc.nextLong();
            B[i] = sc.nextLong();
        }
        for (int i = 0; i < m; ++i) {
            C[i] = sc.nextLong();
            D[i] = sc.nextLong();
        }
        for (int i = 0; i < n; ++i) {
            long a = A[i], b = B[i];
            int res = 0;
            long max = Long.MAX_VALUE;
            for (int j = 0; j < m; ++j) {
                long c = C[j], d = D[j];
                long dist = Math.abs(a - c) + Math.abs(b - d);
                if (dist < max) {
                    res = j + 1;
                    max = dist;
                }
            }
            System.out.println(res);
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 1000000007
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}


void solve()
{		
	int n;
	cin>>n;
	vector<long double> inp(n);
	for (auto &x:inp) cin>>x;
	// dp[i][j] -> j heads using i coins
	vector<vector<long double>> dp(n,vector<long double>(n+1));
	dp[0][1] = inp[0];
	dp[0][0] = 1-inp[0];
	for (int i=1;i<n;i++){
		for (int j=0;j<=n;j++){
			if (j==0){
				dp[i][j] = dp[i-1][j]*(1-inp[i]);
			} else {
				dp[i][j] = max(dp[i][j], dp[i-1][j]*(1-inp[i])+dp[i-1][j-1]*inp[i]);
			}
		}
	}
	long double answer = 0;
	for (int i=0;i<=n/2;i++){
		answer+=dp[n-1][n-i];
	}
	cout<<setprecision(12)<< answer<<endl;
}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}
	

Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int a, b;
    cin >> a >> b;
    if(a%2 == 1 && b%2 == 1){cout << "Yes" << endl;}
    else{cout << "No" << endl;}

    return 0;
}


Measured memory_bytes: 764
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
#if defined(ONLINE_JUDGE)
#include "E:\shara\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    s ss,dd="";
    cin>>ss;
    ll n=(ll)ss.size();
    for(ll i=0;i<n;i++){
        if(!(i&1)){dd+=ss[i];}
    }
    cout<<dd<<endl;




















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/




Measured memory_bytes: 592
s = input()

if 1 <= int(s[0:2]) < 13:
	if 1 <= int(s[2:4]) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= int(s[2:4]) < 13:
		print("YYMM")
	else:
		print("NA")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int choose[110];
    F0R(i, 110) {
        choose[i] = i*(i-1)/2;
    }

    int N, K; cin >> N >> K;
    if (K > choose[N-1]) {
        cout << -1 << endl; return 0;
    }

    if (K == 0) {
        cout << N*(N-1)/2 << endl;
        F0R(i, N) {
            FOR(j, i+1, N) {
                cout << i+1 << " " << j+1 << endl;
            }
        }

        return 0;
    }

    int chooseCount = 0;
    FOR(i, 2, 101) {
        if (K >= choose[i] && K < choose[i+1]) {
            chooseCount = i;
            break;
        }
    }

    int offStar = chooseCount;
    int starSize = N - offStar;
    K -= choose[chooseCount];
    if (K > 0) {
        starSize--;
    }

    int count = starSize * (starSize-1) / 2;
    count += starSize * offStar;
    if (K > 0) count += N-K-1;
    cout << count << endl;

    F0R(i, starSize) {
        FOR(j, i+1, starSize+offStar) {
            cout << (i+1) << " " << (j+1) << endl;
        }
    }

    if (K > 0) {

        F0R(i, N-K-1) {
            cout << (i+1) <<" " <<  N << endl;
        }
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
/*
  テヲツ卍ョテゥツ?堙」ツ?ォテ・ツ?ィテヲツ篠「テァツエツ「テ」ツ?凖」ツつ凝」ツ?ィテヲツ篠「テァツエツ「テァツゥツコテゥツ鳴禿」ツ?古ヲツ慊?ヲツつェ2^30テ」ツ?ォテ」ツ?ェテ」ツ?」テ」ツ?ヲテヲツュツサテ」ツ?ャテ」ツ?ョテ」ツ?ァテ」ツ??
  [T-E, T+E]テ」ツ?ョテ、ツクツュテ」ツ?ォ[R, L]テ」ツ?古」ツ?づ」ツつ凝・ツ?エテ・ツ青暗」ツ?ィ,
  [T-E, T+E]テ」ツ?ョテ・ツ、ツ姪」ツ?ォ[R, L]テ」ツ?古」ツ?づ」ツつ凝・ツ?エテ・ツ青暗」ツ?ョ2テゥツ?堙」ツつ甘」ツ?ァテヲツ楪敕・ツ按暗」ツつ甘ヲツ篠「テァツエツ「テ」ツ??
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
 
const double eps = 1e-11;
 
int K, R, L;
double P, E, T;
 
bool equals(double a, double b) {
  return abs(a-b) < eps;
}
 
double rec(double r, double l, int k) {
  // テヲツ楪敕・ツ按暗」ツつ?
  if( (equals(T-E, r) || T-E < r) &&
      (equals(l, T+E) || l < T+E) ) {
    return 1.0;
  }

  // テヲツ楪敕・ツ按暗」ツつ?
  if( (!equals(l, T-E) && l < T-E) ||
      (!equals(T+E, r) && T+E < r) ) {
    return 0.0;
  }
 
  if(k == 0) {
    double t = (r+l)/2.0;
    double diff = abs(T-t);
    return (equals(diff, E) || diff < E) ? 1.0 : 0.0;
  }

  double h = (r+l)/2.0;
  if(equals(h, T) || h > T) {
    return (1-P)*rec(r,h,k-1) + P*rec(h,l,k-1);
  } else {
    return (1-P)*rec(h,l,k-1) + P*rec(r,h,k-1);
  }
}
 
int main() {
  cin >> K >> R >> L;
  cin >> P;
  cin >> E;
  cin >> T;
  printf("%.10f\n", rec(R, L, K));
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 300005;

/* ...o(^-^)o... */

void solve(vector<bool> used){
    for(int k=1; k<=30000; k++){
        if(used[k]) outs(k);
    }
    out("");
}

int main(){
    int n; cin>>n;
    vector<bool> used(30005);
    used[2]=true; used[5]=true; used[63]=true;
    if(n==3){
        solve(used); return 0;
    }
    used[20]=true;
    if(n==4){
        solve(used);
        return 0;
    }
    used[30]=true;
    if(n==5){
        solve(used);
        return 0;
    }
    
    fill(all(used), false); int sum = 0, last;
    for(int k = 2; k <= 30000; k++){
        if(n==0 || k%6==1 || k%6==5) continue;
        used[k] = true; sum += k; last = k;
        n--;
    } last++;

    if(sum%6==2){
        used[8] = false;
        while(last%6!=0) last++;
        used[last] = true;
    }
    else if(sum%6==3){
        used[9] = false;
        while(last%6!=0) last++;
        used[last] = true;
    }
    else if(sum%6==5){
        used[9] = false;
        while(last%6!=4) last++;
        used[last] = true;
    }
    solve(used);
}


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

int main()
{
    int n;
    cin >> n;
    unordered_map<string, int> ht;
    string s;
    int maxcount = 0;
    for (int i = 0; i < n; i++) {
        cin >> s;
        ht[s]++;
        if (ht[s] > maxcount) {
            maxcount = ht[s];
        }
    }
    vector<string> ans;
    for (auto p : ht) {
        if (p.second == maxcount) {
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(), ans.end());
    for (auto s : ans) {
        cout << s << endl;
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    vector<pair<int, int>> query;
    for(int i = 0; i < N; ++i) {
        string S; cin >> S;
        query.emplace_back(S[0] - 'A', S[1] - 'A');
    }
    vector<int> ans, tmp;
    auto dfs = [&](auto &&dfs, int i) {
        if(!ans.empty() or A[0] < 0 or A[1] < 0 or A[2] < 0) return;
        if(i == N) { ans = tmp; return; }
        auto push = [&](int x, int y) { tmp.push_back(x); A[x]++, A[y]--; };
        auto pop = [&](int x, int y) { tmp.pop_back(); A[x]--, A[y]++; };
        auto[x, y] = query[i];
        push(x, y); dfs(dfs, i + 1); pop(x, y);
        push(y, x); dfs(dfs, i + 1); pop(y, x);
    };
    dfs(dfs, 0);
    if(!ans.empty()) {
        cout << "Yes" << '\n';
        for(int i = 0; i < N; ++i) cout << "ABC"[ans[i]] << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 14352
S = input()
wk1 = (S[0]==S[1]) and (S[2]==S[3]) and (S[0]!=S[2])
wk2 = (S[0]==S[3]) and (S[1]==S[2]) and (S[0]!=S[1])
wk3 = (S[0]==S[2]) and (S[1]==S[3]) and (S[0]!=S[1])
if wk1 or wk2 or wk3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias TOWN = Tuple!(long, "x", long, "y");

void main()
{
    auto n = lread();
    auto a = aryread();
    long cost = INF;
    foreach(i; iota(-200, 200))
    {
        cost = min(cost, getcost(a, i));
    }
    cost.writeln();
}

auto getcost(long[] a, long change)
{
    long cost;
    foreach(e; a)
    {
        cost += (e - change) ^^ 2;
    }
    return cost;
}
T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
bool A,B;
int main()
{
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	if(a=='A' || b=='A' || c=='A') A=1;
	if(a=='B' || b=='B' || c=='B') B=1;
	if(A==1 && B==1)
	{
		printf("Yes");
		return 0;
	}
	else printf("No");
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


/*
int main(){
    ll n,k; cin >> n >> k;

    if(k%2 != 0){
        ll num = 0;
        
        for(ll i=1 ; i<=n ; i++) if(i%k == 0) num++;
        cout << pow(num, 3) << endl;
    }else{
        ll c = 0; ll t = 0;
        for(ll i=1 ; i<=n ; i++) {
            if(i%k == 0) c++;
            if(i%k == k/2) t++;
        }
        cout << pow(c,3)+pow(t,3) << endl;
    }
    
}*/
int main(void) {
    ll N, K; cin >> N >> K;
    if(K%2!=0){
        ll cnt=0;
        for(ll i=1; i<=N; ++i){
            if(i%K==0) cnt++;
        }
        cout << cnt*cnt*cnt << endl;
    }else{
        ll mid = K/2;
        ll c=0, t=0;
        for(ll i=1; i<=N; ++i){
            if(i%K==0) c++;
            if(i%K==mid) t++;
        }
        cout << c*c*c+t*t*t << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10 ** 7)


def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    inf = 10 ** 9

    # memo = [inf for _ in range(n)]
    # memo[0] = 0
    # for kk in range(1, min(k, n - 1) + 1):
    #     memo[kk] = abs(h[kk] - h[0])
    #
    # def dp(n):
    #     if n == 0:
    #         return 0
    #     elif memo[n] != inf:
    #         return memo[n]
    #     else:
    #         memo[n] = min([dp(n - kk) + abs(h[n] - h[n - kk]) for kk in range(1, k + 1)])
    #         return memo[n]
    #
    # print(dp(n - 1))

    ans = [inf for _ in range(n)]
    ans[0] = 0

    if n < k:
        k = n - 1

    for kk in range(1, k + 1):
        ans[kk] = abs(h[kk] - h[0])

    for i in range(1, n):
        for kk in range(1, k + 1):
            if i + kk < n:
                ans[i + kk] = min(ans[i + kk], ans[i] + abs(h[i + kk] - h[i]))

    print(ans[-1])

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 3
10 30 40 50 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 1
10 20 10"""
        output = """20"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2 100
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """10 4
40 10 20 70 80 10 20 70 80 60"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 67676
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m,a[N],tot;
char s[N],b[N];
bool check(int k,int op)
{
	for (int i=1;i<=m;i++)
	if (b[i]==s[k])
	{
		if (a[i]==0) k--;
		else k++;
		if (k==0)
		{
			if (op==0) return 1;
			else return 0;
		}
		if (k==n+1)
		{
			if (op==1) return 1;
			else return 0;
		}
	}
	return 0;
}
signed main()
{
	tot=n=read(),m=read();
	scanf("%s",s+1);
	for (int i=1;i<=m;i++)
	{
		b[i]=getc();a[i]=getc()=='R';
	}
	int l=1,r=n,ans=0;
	while (l<=r)
	{
		int mid=l+r>>1;
		if (check(mid,0)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	tot-=ans;
	l=1,r=n;ans=n+1;
	while (l<=r)
	{
		int mid=l+r>>1;
		if (check(mid,1)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	tot-=n+1-ans;
	cout<<tot;
	return 0;
	//NOTICE LONG LONG!!!!!
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int a;
    cin>>a;
    set<int> ha;
    int co=0;
    while(1){
        if(ha.find(a)!=ha.end()){
            cout<<co+1;
            break;
        }
        else ha.insert(a);
        if(a&1)a=(3*a)+1;
        else a=a/2;
        co++;
    }
    return 0;
}


Measured memory_bytes: 256
import math
A,B = input().split()
A_i = int(A)
B_i = int(B)
C = []
for i in range(1100):
    if math.floor(i * 0.08) == A_i and math.floor(i *0.1) == B_i:
        C.append(i)
    else:
        pass
if not C:
    print(-1)
else:
    print(C[0])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define int long long
#define PII pair<int,int>
#define maxn 1000005
#define ll long long 
#define fi first
#define int ll
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std; 
int n,m;
int du[maxn];

signed main()
{ rep(i,1,3)
  {int x,y; cin>>x>>y; du[x]++;du[y]++;
  }
 int num=0;
 rep(i,1,4) if(du[i]%2==1) num++;
 if(num==2) puts("YES");
 else       puts("NO");	
	
 } 

Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
lld p1=1e9 + 7,p2=998244353;

void judge(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
}

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }


lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;

void solve()

{  
    lld p1 = 1e9 +7;
    vector<lld> v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);

    }
    ans =0 ;
    x =v[n-1] ;
    for(i=n-2;i>=0;i--)
    {
        ans+= (x*v[i])%p1;
        x+= v[i];
        x%=p1;
        ans%=p1;
    }
    cout<<ans;
}

int main()
{
    // judge();
    fastio();
    lld t=1;
    // cin>>t;
    // lld p1 = 1e9 + 7;
    // getfac(p1);
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        // cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1e9 + 7;

int main(){
	int N, L, sum = 0, min = 100000000; cin >> N >> L;
	for(int i=0; i<N; i++){
		sum += L+i;
		if(abs(L+i) < abs(min)) min = L+i;
	}
	sum -= min;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int K;
	cin >> K;
	int cnt = 0;
	int digit = 1;
	long long ans = -1;
	while (cnt < K) {
		for (int j = 1; j <= 9; ++j) {
			int mul = 1;
			for (int k = 0; k < digit - 1; ++k) {
				mul *= 3;
			}
			vector<long long> v;
			for (int k = 0; k < mul; ++k) {
				int cur = j, x = k; long long num = 0;
				for (int l = 0; l < digit; ++l) {
					num = num * 10 + cur;
					if (x % 3 == 0) ++cur;
					if (x % 3 == 2) --cur;
					if (l != digit - 1 && (cur < 0 || 9 < cur)) {
						num = -1;
						break;
					}
					x /= 3;
				}
				if (num != -1) {
					v.push_back(num);
				}
			}
			sort(v.begin(), v.end());
			if (cnt + v.size() >= K) {
				ans = v[K - cnt - 1];
				cnt += v.size();
				break;
			}
			cnt += v.size();
		}
		++digit;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n,x; cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  
  int ans = 0;
  for (auto y : a) {
    if (y <= x) {
    	ans++;
      	x -= y;
    }
  }
  if (x > 0 && ans == n) --ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL gcd(LL a, LL b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<typename T>
std::map<T, int> prime_factorize(T x) {
  std::map<T, int> primes;
  for (T factor = 2; factor * factor <= x; factor++) {
    if (x % factor == 0) {
      T count = 0;
      while (x % factor == 0) {
          count++;
          x /= factor;
      }
      primes[factor] = count;
    }
  }
  if (x != 1) primes[x] = 1;
  return primes;
}

int main() {
  LL A, B; cin >> A >> B;
  LL C = gcd(A, B);
  auto p = prime_factorize(C);
  cout << p.size() + 1 << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n), bs(n);
    cin >> as >> bs;
    int ans = 0;
    for(int i = 28; i >= 0; i--){
        for(auto& a : as){ a &= (2 << i) - 1; }
        for(auto& b : bs){ b &= (2 << i) - 1; }
        sort(as.begin(), as.end());
        sort(bs.begin(), bs.end());
        int num = 0;
        for(auto& a : as){
            auto xx = lower_bound(bs.begin(), bs.end(), (1 << i) - a);
            auto yy = lower_bound(xx, bs.end(), (2 << i) - a);
            auto zz = lower_bound(yy, bs.end(), (3 << i) - a);
            int x = xx - bs.begin();
            int y = yy - bs.begin();
            int z = zz - bs.begin();
            // int x = lower_bound(bs.begin(), bs.end(), (1 << i) - a) - bs.begin();
            // int y = lower_bound(bs.begin(), bs.end(), (2 << i) - a) - bs.begin();
            // int z = lower_bound(bs.begin(), bs.end(), (3 << i) - a) - bs.begin();
            num += y - x + n - z;
        }
        ans |= num & 1 ? 1 << i : 0;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(double x){
  printf("%.15f",x);
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N, T[100], V[100], mx[50000];
int main(){
  double res=0;
  int all, i, j;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(T[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<N;KL2GvlyY++){
      rd(V[KL2GvlyY]);
    }
  }
  all = 0;
  for(i=0;i<N;i++){
    mx[all] = 2*V[i];
    if(i){
      chmin(mx[all], 2*V[i-1]);
    }
    all++;
    for(j=1;j<2*T[i];j++){
      mx[all++] = 2*V[i];
    }
  }
  mx[0] = mx[all] = 0;
  for(i=1;i<all;i++){
    chmin(mx[i], mx[i-1]+1);
  }
  for(i=all-1;i;i--){
    chmin(mx[i], mx[i+1]+1);
  }
  for(i=1;i<all+1;i++){
    res += mx[i-1]+mx[i];
  }
  res /= 8;
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20171023-1 [beta]

// --- original code ---
// int N, T[100], V[100];
// int mx[50000];
// {
//   int i, j, all;
//   double res = 0;
//   
//   rd(N,T(N),V(N));
// 
//   all = 0;
//   rep(i,N){
//     mx[all] = 2V[i];
//     if(i) mx[all] <?= 2V[i-1];
//     all++;
//     rep(j,1,2T[i]) mx[all++] = 2V[i];
//   }
//   mx[0] = mx[all] = 0;
// 
//   rep(i,1,all) mx[i] <?= mx[i-1]+1;
//   for(i=all-1;i;i--) mx[i] <?= mx[i+1]+1;
// 
//   REP(i,1,all+1) res += mx[i-1]+mx[i];
//   res /= 8;
//   wt(res);
// }


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll n,k,ans;
vector<ll> a;
ll dp[100][100][105];
ll solve(ll ss,ll se,ll cnt)
{
   if(cnt>k)
    return -1e18;
   if(cnt==k||ss>se)
      return 0;
   if(dp[ss][se][cnt]!=-1)
    return dp[ss][se][cnt];
   ll val=0;
   val=max(val,a[ss]+solve(ss+1,se,cnt+1));
   val=max(val,solve(ss+1,se,cnt+2));
   val=max(val,a[se]+solve(ss,se-1,cnt+1));
   val=max(val,solve(ss,se-1,cnt+2));
   dp[ss][se][cnt]=val;  
   return val;
}
int main()
{
  IOS
  cin>>n>>k;
  ll i,x;
  for(i=0;i<n;i++)
  {
    cin>>x;
    a.pb(x);
  }
  memset(dp,-1,sizeof(dp));
  cout<<max(0LL,solve(0,n-1,0));
 // cout<<ans;
//  cout<<ans;
  return 0;
}

Measured memory_bytes: 8576
import sys

YES = "Yes"
NO = "No"


def solve(N: int, H: "List[int]"):
    hmax = H[0]
    for h in H:
        if h <= hmax - 2:
            return NO
        hmax = max(hmax, h)
    return YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, H)
    if ans is not None:
        print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const int N = 2e5+10;
const int INF = 0x3f3f3f3f;

int main(void)
{
	int a;
	string s;
	cin >> a >> s;
	if(a >= 3200) cout <<s << endl;
	else cout << "red" << endl;
	return 0;
 } 


Measured memory_bytes: 256
import fractions

a,b,c,d = map(int, input().split())

c_min = (a-1) // c
c_max = b // c
c_count = c_max - c_min

d_min = (a-1) // d
d_max = b // d
d_count = d_max - d_min

cd_min = (a-1) // (c * d // fractions.gcd(c, d))
cd_max = b // (c * d // fractions.gcd(c, d))
cd_count = cd_max - cd_min

print(b - (a-1) - c_count - d_count + cd_count)


Measured memory_bytes: 5076
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

vector<P> ans;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];

    int ma = -1, j = -1;
    REP(k,n){
        if (abs(a[k]) > ma){
            ma = abs(a[k]);
            j = k;
        }
    }

    if (ma == 0){
        cout << 0 << endl;
        return 0;
    }

    if (a[j] > 0){
        FOR(i,1,n-1){
            if (i < j){
                ans.push_back(P(j,j));
                ans.push_back(P(j,i));
            }else if (i > j){
                ans.push_back(P(j,j));
                ans.push_back(P(j,i));
                j = i;
            }
        }
        ans.push_back(P(n-1,n-1));
    }else{
        FORR(i,n-2,0){
            if (i > j){
                ans.push_back(P(j,j));
                ans.push_back(P(j,i));
            }else if (i < j){
                ans.push_back(P(j,j));
                ans.push_back(P(j,i));
                j = i;
            }
        }
        ans.push_back(P(0,0));
    }

    cout << ans.size() << endl;
    REP(i,ans.size()) cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;

    // REP(i,ans.size()){
    //     a[ans[i].second] += a[ans[i].first];
    // }

    // REP(i,n) cout << a[i] << " ";
    // cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL N,X,ans;
int main()
{
	scanf("%lld%lld",&N,&X);
	ans+=N;N=N-X;
	while(N&&X)
	{
		if(X>N) swap(X,N);
		ans+=N/X*X*2;N%=X;
		if(!N) ans-=X;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int x = 0,y = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'A'){
      x = i;
      break;
    }
  }
  for(int i = 0;i < s.size();i++){
    if(s[s.size() - i - 1] == 'Z'){
      y = s.size() - i - 1;
      break;
    }
  }
  cout << y - x + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=2005;
const int MOD=1000000007;

int n,k,f[N][N],jc[N*N+N*2],ny[N*N+N*2];

void updata(int &x,int y)
{
	x+=y,x-=x>=MOD?MOD:0;
}

int C(int n,int m)
{
	return (LL)jc[n]*ny[m]%MOD*ny[n-m]%MOD;
}

int main()
{
	scanf("%d%d",&n,&k);k--;
	if (!k) {puts("1");return 0;}
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n*k+n+k;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=n*k+n+k;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
	f[0][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=i;j<=n;j++)
		{
			if (i) updata(f[i][j],f[i-1][j]);
			if (j) updata(f[i][j],(LL)f[i][j-1]*C(i+(j-1)*k+k-1,k-1)%MOD);
		}
	printf("%d",(LL)f[n][n]*jc[n]%MOD);
	return 0;
}

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

int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  bool ok=true;
  sort(a.begin(),a.end());
  rep(i,n-1){
    if(a.at(i)==a.at(i+1)){
      ok=false;
      break;
    }
  }
  if(ok){
    cout<<"YES"<<endl;
  }
  else{cout<<"NO"<<endl;}
}




 





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s;
	cin >> s;
	ll n = s.size();

	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = i; j < n; j++) {
			ll m = stoll(s.substr(i, j - i + 1));
			ll l = i, r = n - 1 - j;
			if (l == 0) l = 1;
			else l = pow(2, l - 1);
			if (r == 0) r = 1;
			else r = pow(2, r - 1);
			ans += m * l * r;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	int m[200];
	rep(i, 200) m[i] = 0;
	int mv = 0;
	for (int a; cin >> a; ) mv = max(mv, ++m[a]);
	REP(i, 1, 100) if (m[i] == mv) cout << i << endl;
	
	return 0;
}

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

using namespace std;

int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	int x;
	cin>>x;
	cout<<360 / gcd(x, 360)<<endl;
	return 0;
}

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

signed main(){
    int n;
    cin >> n;
  	int a[n], ans = 0;
	for(int i = 0; i < n; ++i)
      	cin >> a[i];
  	sort(a, a + n, greater<int>());
  	
 	ans = a[0];
  	for(int i = 2, j = 1; i < n; ++i){
    	ans += a[j];
      	if(i&1)
          ++j;
    }
  	cout << ans << endl; 
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

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

    iota(ord.begin(), ord.end(), 0);

    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return a[i] < a[j];
    });

    REP(i, n) cout << ord[i] + 1 << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0)
	{
		cout<<a-b;
	}
	else
	{
		cout<<b-a;
	}
}


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

bool hantei(int64_t x){
	for(int i=2; i*i<=x; i++){
		if(x%i==0) return 0;
	}
	return x>1;
}

int main() {
	
	int n; cin >> n;
	int cnt{};
	for(int i=0; i<n; i++){
		int c; cin>>c;
		cnt+=hantei(c);
	}
	cout << cnt<<endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cstdlib>


using namespace std;


long long solver(bool pre_is_posi, long long a[], long long n)
{
  long long total=0, ans=0;

  for (int i=0; i<n; i++){
    total += a[i];
    if (pre_is_posi && total >= 0){
      ans += abs(total)+1;
      total = -1;
    } else if (!(pre_is_posi) && total <= 0){
      ans += abs(total)+1;
      total = 1;
    }
    pre_is_posi = (total > 0);
  }
  return ans;
}


int main()
{
  long long n, a[100000];

  cin >> n;
  for (int i=0; i<n; i++) cin >> a[i];
  cout << min(solver(true, a, n), solver(false, a, n)) << endl;
  
  return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int N, M;
int A[100010];
int B[100010];
int C[100010];

int main(){

    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++){
        cin >>B[i] >> C[i];
    }
    priority_queue<pii> pq;
    for(int i = 0; i < N; i++){
        pq.push(pii(A[i], 1));
    }
    for(int i = 0; i < M; i++){
        pq.push(pii(C[i], B[i]));
    }
    ll ans = 0;
    int cnt = N;
    while(pq.size() && cnt > 0){
        pii p = pq.top(); pq.pop();
        int sub = min(p.second, cnt);
        cnt -= sub;
        ans += (ll)sub * p.first;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
import java.util.*;
public class Main {
    public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      String str = sc.next();
      char[] array = str.toCharArray();
      Arrays.sort(array);
      String ans = "Yes";
      char[] abc = {'a','b','c'};
      for (int i=0; i<3; i++) {
        if (array[i] != abc[i])
          ans = "No";
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 35536
#include <bits/stdc++.h>
using namespace std;
int a[10],b[10];

double f(int x1,int y1,int x2,int y2){
	return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
	}
	double sum = 0.00;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			sum += f(a[i],b[i],a[j],b[j]);
		}
	}
	sum = sum * 2.00 / n;
	printf("%.10lf",sum);
    return 0;
}

Measured memory_bytes: 256