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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    lli mx = 0;
    for (lli i = 0; i * i <= n; ++i) {
      mx = i;
    }
    cout << mx * mx << endl;
  }
  
  return 0;
}


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

int main(){
    string n;
    cin >> n;
    if(n.at(0)=='7' || n.at(1) == '7' || n.at(2) == '7') cout << "Yes" <<endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	out := []rune{}
	for n > 0 {
		n--
		offset := n % 26
		out = append(out, 'a' + rune(offset))
		n /= 26
	}
	l := 0
	r := len(out) - 1
	for l < r {
		out[l], out[r] = out[r], out[l]
		l++
		r--
	}
	printf("%s\n", string(out))
}


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

signed main(){

  string s;
  cin>>s;

  auto solve = [](string const& s){
    auto chmax = [](auto& a,auto b){if(a<b)a=b;};
    int n = s.size();
    vector<vector<int>> dp(n,vector<int>(2));
    dp[0][0]=1;
    for(int i=1;i<n;++i){
      if(s[i-1]!=s[i]){
        chmax(dp[i][0],dp[i-1][0]+1);
      }
      chmax(dp[i][0],dp[i-1][1]+1);
      if(i>=2){
        chmax(dp[i][1],dp[i-2][0]+1);
        chmax(dp[i][1],dp[i-2][1]+1);
      }
    }
    return max(dp.back()[0],dp.back()[1]);
  };
  int ans = solve(s);
  reverse(begin(s),end(s));
  ans = max(ans,solve(s));
  cout<<(ans)<<endl;

}

Measured memory_bytes: 11396
/* In the name of Allah
   The most beneficent,
   The most merciful
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define ck puts("ok")
#define reset(a,d) memset(a,d,sizeof(a))
#define CASE(i) printf("Case %lld: ", i)
#define pb(a,b) a.push_back(b)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define DIST(x1,y1, x2, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define ALL(x) (x).begin(),(x).end()
#define LLA(x) x.rbegin(), x.rend()
#define SORT(v) sort(ALL(v))
#define inf   1<<30
#define mod   1000000007
#define PI acos(-1.0)
string sss="0123456789ABCDEF";
//-----------------------------------------------------------//
int main()
{
    ll n,i,x;
    vector<ll>v;
    cin>>n;
    for(i=0;i<n*3;i++)
    {
        cin>>x;
        pb(v,x);
    }
    x=0;
    sort(ALL(v));
    //for(i=0;i<n*3;i++)cout<<v[i]<<" ";
    for(i=3*n-2;n--;i-=2)
    {
        x+=v[i];
    }
    cout<<x<<endl;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
bool win[100005];
int n, k, v[105];
int main() {
    DAU
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> v[i];
    for (int i = 1; i <= k; ++i)
        for (int j = 1; j <= n; ++j)
            if (i - v[j] >= 0 && !win[i - v[j]])
                win[i] = true;
    if (win[k])
        cout << "First";
    else cout << "Second";
    PLEC
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define PI 3.14159265358979

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    if(x * 2 > a*a*b) {
        double h = b * (1.0 - (x/(a * a * b + 0.0)));
        cout << fixed << setprecision(12) << 90.0 - atan2(a, 2 * h) * 180.0 / PI << endl;
    } else {
        double h = 2 * x/(a * a * b + 0.0) * a;
        cout << fixed << setprecision(12) <<  atan2(b, h) * 180.0 / PI << endl;
    }


    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    
         
    static FastReader in;
    static StringBuilder out;

    public  static void main(String[] args) {
        
        in = new FastReader();
        out=new StringBuilder();
        int k=in.nextInt(),n=in.nextInt();
        int dis[]=new int[n];
        for(int i=0;i<n;i++){
            dis[i]=in.nextInt();
        }
        Arrays.sort(dis);
        int ans=Math.min(Math.abs(dis[dis.length-1]-dis[0]),k-Math.abs(dis[1]-dis[0]));
        for(int i=1;i<n;i++){
            int clk=0,aclk=0;
            clk=k-Math.abs(dis[i]-dis[i-1]);
            if(i==n-1){
                aclk=Math.abs(dis[n-1]-dis[0]);
            }else{
                aclk=k-Math.abs(dis[i+1]-dis[i]);
            }
            ans=Math.min(Math.min(clk, aclk),ans);
        }
        System.out.println(ans);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
     
    
}

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

bool calc(string &s, int n, string &ops, int pre_val){
  if(n==0) {
    if(pre_val - (s.at(0)-'0') == 0) {
      return true;
    }
    return false;
  }
  if(calc(s, n-1, ops, pre_val-(s.at(n)-'0'))) {
    ops += "+";
    return true;
  }
  if(calc(s, n-1, ops, pre_val+(s.at(n)-'0'))){
    ops += "-";
    return true;
  }
  return false;
}

int main(){
  string s;
  cin >> s;
  string ops;
  calc(s, 3, ops, 7);
  ops += "=";
  string ans;
  rep(i, 4){
    ans += s.at(i);
    ans += ops.at(i);
  }
  ans += "7";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p and q and r) {
        cout << 3 << endl;
    } else if ((p and q) or (q and r)) {
        cout << 2 << endl;
    } else if (p or q or r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(void){
    int n,x=0,a;
    scanf("%d",&n);
    a=n;
    while(a>0){
        x+=a%10;
        a/=10;
    }
    if(n%x==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
H,W = map(int,input().split())
a = [input() for i in range(H)]
DP = [[0 for i in range(W)] for i in range(H)]
DP[0][0] = 1
Mod = 10**9+7
for i in range(H):
    for j in range(W):
        if a[i][j] == '.':
            if i != 0:
                DP[i][j] += DP[i-1][j]
            if j != 0:
                DP[i][j] += DP[i][j-1]
        DP[i][j] %= Mod
print(DP[-1][-1])

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


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

    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> T(N, 0);
    for (int i = 1; i < N; i++) {
        T[i] += T[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') T[i]++;
    }

    int l, r;
    rep(_, Q) {
        cin >> l >> r;
        cout << T[r - 1] - T[l - 1] << '\n';
    }

    return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;
#define MOD 1000000007

int main(void)
{
    IOS
    string s;
    cin >> s;

    int l = s.size();

    INT64 dp1 = 1;
    INT64 dp2 = 2;

    FOR(i,1,l){
        if (s[i] == '1') {
            dp1 = (dp1 * 3 + dp2) % MOD;
            dp2 = dp2 * 2 % MOD;
        } else {
            dp1 = (dp1 * 3) % MOD;
        }
    }

    cout << (dp1 + dp2) % MOD << endl;

    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	vector<int>B(N); rep(i, 0, N) { cin >> B[i]; }

	priority_queue < pii, vector<pii>, less<pii >> pq;
	rep(i, 0, N) {
		pq.emplace(B[i], i);
	}
	int ans = 0;
	while (pq.size()) {
		dump(B);

		pii p = pq.top();
		pq.pop();
		if (p.first != B[p.second])continue;

		int b = p.first;
		int a = B[(p.second - 1 + N) % N];
		int c = B[(p.second + 1 + N) % N];

		if (b == A[p.second])continue;
		if (b <= a + c) {
			cout << -1 << endl;
			return 0;
		}

		if ((b - A[p.second]) % (a + c) == 0) {
			B[p.second] = A[p.second];
			ans += (b - A[p.second]) / (a + c);
		}
		else {
			int d = a + c;
			int q = b;
			int a = (q + d - 1) / d;
			a--;
			b -= a * d;
			B[p.second] = b;
			pq.emplace(b, p.second);
			ans += a;
			if (a == 0 or A[p.second] > B[p.second]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9456
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
char s1[205],s2[205];
int main()
{
    for(;;)
    {
        scanf("%s",s1);
        if(s1[0]=='.')break;
        scanf("%s",s2);
        int len1=strlen(s1);
        int len2=strlen(s2);
        int t1=0,t2=0;
        for(int i=0;i<len1;i++)if(s1[i]=='\"')t1++;
        for(int i=0;i<len2;i++)if(s2[i]=='\"')t2++;
        if(t1!=t2)cout<<"DIFFERENT"<<endl;
        else
        {
            int t1=0,t2=0;
            int flag=0,flag1=0;
            while(t1<len1&&t2<len2)
            {
                while(s1[t1]=='\"'&&t1<len1&&s2[t2]=='\"'&&t2<len2)
                    {
                        t1++;
                        t2++;
                        flag1++;
                    }
                if(t1==len1||t2==len2)break;
                if(flag1%2==0)
                {
                    if(s1[t1]!=s2[t2]){flag=2;break;}
                    while(s1[t1]!='\"'&&s2[t2]!='\"'&&t1<len1&&t2<len2)
                    {
                        if(s1[t1]!=s2[t2]){flag=2;break;}
                        else {t1++;t2++;}
                    }
                }
                else if(flag1%2!=0)
                {
                    while((s1[t1]!='\"'||s2[t2]!='\"')&&t1<len1&&t2<len2)
                    {
                        if(s1[t1]!=s2[t2])
                            {
                                flag++;
                                while(s1[t1]!='\"'&&t1<len1)t1++;
                                while(s2[t2]!='\"'&&t2<len2)t2++;
                                break;
                            }
                        else {t1++;t2++;}
                    }
                }
                if(flag==2)break;
            }
            if(flag==2)cout<<"DIFFERENT"<<endl;
            else if(flag==1)cout<<"CLOSE"<<endl;
            else if(flag==0)cout<<"IDENTICAL"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b;
  cin >> a >> b;
  if(a > 0 && b > 0)cout << "Positive" << endl;
  else if(a <= 0 && 0 <= b)cout << "Zero" << endl;
  else cout << ((b - a + 1) % 2 == 0?"Positive":"Negative");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define INF 9999999
#define NIL -1
#define BLACK 1
#define WHITE 0

int n;
int G[100][100];
int d[100];
int pi[100];
int color[100];


void prim(int r){
  int i,u,mincost;

  for(i=0;i<n;i++){
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }
  d[r] = 0;

  while(1){
    mincost = INF;
    for(i=0;i<n;i++){
      if((color[i]!=BLACK)&&(d[i]<mincost)){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF)
      break;

    color[u] = BLACK;

    for(i=0;i<n;i++){
      if(G[u][i]!= -1)
	if((color[i] != BLACK)&&(G[u][i]<d[i])){
	    pi[i] = u;
	    d[i] = G[u][i];
	  }    
    
    }
  }
}





int main(){

  int i,j,sum=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
     for(j=0;j<n;j++){
       scanf("%d",&G[i][j]);
     }
  }

  prim(0);

  for(i=0;i<n;i++){
    sum += d[i];
  }

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



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int n;
    cin >> n;
    ll ans = 0;
    ll mapping[n+1];
    fill_n(mapping,n+1,0);
    int a[n];
    rep(i,n) cin >> a[i];
    rep(i,n) mapping[a[i]]++;
    rep(i,n+1) ans+=((mapping[i]*(mapping[i]-1))/2);
    //cout << ans << endl;
    rep(i,n) cout << ans-mapping[a[i]]+1 << endl;

}

Measured memory_bytes: 4864
def gcd(x, y):
    if x < y:
        tmp = y
        y = x
        x = tmp
    while y != 0:
        x = x % y
        temp = y
        y = x
        x = temp
    return int(x)

def lcm(x, y):
    return int(x * y / gcd(x, y))

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

x = lcm(c, d)

A = a-1 - (a - 1) // c - (a - 1) // d + (a - 1) // x
B = b - b // c - b // d + b // x

print(int(B - A))


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

main(){
  int n;
  cin >> n;
  int s[n],a[n];
  int x=0;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(s[i]%10!=0){
      a[x]=s[i];
      x++;
    }
    ans+=s[i];
  }

  sort(a,a+x);

  if(ans%10!=0){
    cout << ans <<endl;
  }else if(x!=0){
    cout << ans-a[0] <<endl;
  }else{
    cout << 0 <<endl;
  }


}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define MOD 998244353LL
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // aint entries it as true. A value in prime[i] wiint
    // finainty be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
  
  
    if(a==0){
    	if(b==0){
    		cout << "NA" << endl;
    		return 0;
    	}
    	else if( b > 12){
    		cout << "NA" << endl;
    		return 0;
    	}
    	else{
    		cout << "YYMM" << endl;
    		return 0;
    	}
    }

    else if(b==0){
    	 if( a > 12){
    		cout << "NA" << endl;
    		return 0;
    	}
    	else{
    		cout << "MMYY" << endl;
    		return 0;
    	}
    }


    if(a > 12  && b >12){
    	cout << "NA" << endl;
    	return 0;
    }

    if(a <= 12 && b<=12){
    	cout << "AMBIGUOUS" << endl;
    	return 0;
    }

    if(a <= 12){
    	if(b > 12){
    		cout << "MMYY" << endl;

    	}

    }
    else if(b <= 12){
    	cout << "YYMM" << endl;
    }
}

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

const int MAXN = 2.1e5;
int N;
char S[MAXN];
int dp[MAXN][3];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> S;
	N = int(strlen(S));
	memset(dp, -1, sizeof(dp));
	dp[0][1] = dp[0][2] = 0;
	for (int i = 1; i <= N; i++) {
		if (i >= 2) {
			if (dp[i-2][1] != -1) {
				dp[i][2] = max(dp[i][2], dp[i-2][1] + 1);
			}
			if (dp[i-2][2] != -1) {
				if (i >= 4 && S[i-1] == S[i-3] && S[i-2] == S[i-4]) {
					// collision
				} else {
					dp[i][2] = max(dp[i][2], dp[i-2][2] + 1);
				}
			}
		}
		if (dp[i-1][2] != -1) {
			dp[i][1] = max(dp[i][1], dp[i-1][2] + 1);
		}
		if (dp[i-1][1] != -1) {
			if (i >= 2 && S[i-1] == S[i-2]) {
				// collision
			} else {
				dp[i][1] = max(dp[i][1], dp[i-1][1] + 1);
			}
		}
	}

	cout << max(dp[N][1], dp[N][2]) << '\n';

	return 0;
}


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

int func(int n){
	if(n % 2) return 3 * n + 1;
	else return n / 2;
}

int main(){
	int s;
	scanf("%d", &s);
	int ans = 0;
	set<int> coll;
	coll.insert(s);
	while(true) {
		ans++;
		s = func(s);
		if(coll.count(s)) break;
		coll.insert(s);
	}
	printf("%d\n", ans + 1);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 1000000;
long long CNT = 0;

void InsertionSort(int* A, int n, int g) {
  for (int i = g; i < n; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j = j - g;
      CNT++;
    }
    A[j + g] = v;
  }
}

void ShellSort(int* A, int n) {
  int cnt = 0;
  vector<int> G;
  int h = 1;
  while (true) {
    if (h > n) break;
    G.push_back(h);
    h = 3 * h + 1;
  }
  reverse(G.begin(), G.end());

  cout << G.size() << endl;
  for (int i = 0; i < G.size() - 1; i++)
    cout << G[i] << " ";
  cout << G[G.size() - 1] << endl;
  for (int i = 0; i < G.size(); i++)
    InsertionSort(A, n, G[i]);
  cout << CNT << endl;

  for (int i = 0; i < n; i++)
    cout << A[i] << endl;
}

int main() {
  int n;
  int A[MAX];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  ShellSort(A, n);

  return 0;
}


Measured memory_bytes: 7016
h, w = list(map(int, input().split()))


def France():
    """
    ABC
    ABC
    ABC
    """
    d, m = divmod(w, 3)
    if m == 0:
        return 0
    return h

def Germany():
    """
    AAA
    BBB
    CCC
    """
    d, m = divmod(h, 3)
    if m == 0:
        return 0
    return w

def Chile():
    """
    AB
    AB
    CC
    """
    hd, hm = divmod(h, 3)
    wd, wm = divmod(w, 2)
    found = w*h
    for i in range(2*hd, 2*hd+3):
        for j in range(wd, wd+3):
            A = i * j 
            B = i * (w - j)
            C = (h - i) * w
            D = max(A, B, C) - min(A, B, C)
            found = min(found, D)
    return found

def Madagascar():
    """
    ABB
    ACC
    """
    hd, hm = divmod(h, 2)
    wd, wm = divmod(w, 3)
    found = w*h
    for i in range(wd, wd+3):
        for j in range(hd, hd+3):
            A = i * h
            B = (w - i) * j
            C = (h - j) * (w - i)
            D = max(A, B, C) - min(A, B, C)
            found = min(found, D)
    return found

print(min(France(), Germany(), Chile(), Madagascar()))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

typedef complex<double> CD;
double gosa = 0.0000001;

//直行判定
bool Check_orth(CD p1, CD p2, CD q1, CD q2) {
	double a1 = arg(p1 - p2), a2 = arg(q1 - q2);
	if (a1 > a2)swap(a1, a2);	//a1<a2
	return abs((a2 - a1) - pi / 2.) < gosa || abs((a2 - a1) - (pi / 2. * 3.)) < gosa;
}

int main() {
	double a, b, c, d, e, f, g, h;
	while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		CD p1(a, b), p2(c, d), p3(e, f), p4(g, h);
		puts(Check_orth(p1, p2, p3, p4) ? "YES" : "NO");
	}
}


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

using namespace std;

#define fi first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define pq priority_queue

typedef long long ll;
typedef unsigned long long ull;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {

	string s, t, u;
	int n1, n2;

	ios_base :: sync_with_stdio(false);

	cin >> s >> t >> n1 >> n2 >> u;

	if(u == s) --n1;
	else --n2;

	cout << n1 << ' ' << n2 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,l[210];
  cin>>n;
  rep(i,n*2)cin>>l[i];
  sort(l,l+n*2);reverse(l,l+n*2);
  int ans=0;
  for(int i=0;i<n*2;i++)if(i%2==1)ans+=l[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    map<int,int> map;
    //vint a(n); rep(i,n) cin >> a[i];
    //sort(all(a));
    int sum=0;
    rep(i,n){
        int a; cin >> a;
        map[a]++;
        sum+=a;
    }
    int q; cin >> q;
    rep(i,q){
        int b,c; cin >> b >> c;
        if(map[b]==0) {
            cout<<sum<<endl;
            continue;
         
        }
        map[c]+=map[b];
        sum=sum-map[b]*b+map[b]*c;
        map[b]=0;
        
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N;
int P[22][22];
ll mod = 1e9 + 7;
ll dp[2500000];

ll keisan(int A) {
	if (dp[A] != -1) return dp[A];
	if (A == 0) return 1;
	int B[22] = {};
	int M = 0;
	rep(i, N) if (A >> i & 1) {
		B[i + 1] = 1;
		M++;
	}

	ll ret = 0;
	rep(i, N) if (B[i + 1] && P[M][i + 1]) {
		ret = (ret + keisan(A - (1 << i))) % mod;
	}
	dp[A] = ret;
	return dp[A];
}



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


	cin >> N;
	rep1(i, N) rep1(j, N) cin >> P[i][j];

	rep(i, 2500000) dp[i] = -1;

	co(keisan((1 << N) - 1));

	Would you please return 0;
}

Measured memory_bytes: 19840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = new int[n+1];
			for (int i = 1; i < n+1; i++) {
				a[i] = in.nextInt();
			}

			boolean[] visited = new boolean[n+1];

			int ans = 0;
			int cur = 1;
			while (true) {
				if (cur == 2) {
					break;
				}

				if (visited[cur]) {
					ans = -1;
					break;
				}

				visited[cur] = true;
				cur = a[cur];
				ans++;
			}

			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 36112
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define mod 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
/*void input(vector<int>& v,int n){ int i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<char,int>  frequency(string v){ int i; map<char,int> m; rep (i,v.length()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
ld dist(ld a,ld b) {
	return sqrt(a*a + b*b);
}
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	long c = 0;
	cin>>n;
	ld d,a,b;
	cin>>d;
	while (n--) {
		cin>>a>>b;
		if (dist(a,b)<=d)
			c++;
	}
	cout<<c<<endl;
}



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

struct vec{
	long long x,y;
};

vec cc(vec a){
	vec ans;
	ans.x=-a.y;
	ans.y=a.x;
	return ans;
}

vec add(vec a,vec b){
	a.x+=b.x;
	a.y+=b.y;
	return a;
}

int main(){
	vec a,b,v,cur;
	cin>>a.x>>a.y>>b.x>>b.y;
	cur=b;
	v.x=b.x-a.x;
	v.y=b.y-a.y;
	v=cc(v);
	cur=add(cur,v);
	cout<<cur.x<<" "<<cur.y<<" ";
	v=cc(v);
	cur=add(cur,v);
	cout<<cur.x<<" "<<cur.y;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

L_largest = 0
R_min = N
for m in range(M):
    L, R = map(int, input().split())
    if L >= L_largest:
        L_largest = L
    if R <= R_min:
        R_min = R

print(max(0, R_min - L_largest + 1))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int dp[3010][6010];
P D[3010];
int main()
{
	int N, T;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> D[i].first >> D[i].second;
	}
	sort(D, D + N);
	for (int i = 0; i < T; i++) {
		dp[0][i] = 0;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < T; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j + D[i].first] = max(dp[i + 1][j + D[i].first], dp[i][j] + D[i].second);
			dp[i + 1][j + D[i].first] = max(dp[i + 1][j + D[i].first], dp[i][j + D[i].first]);
			ans = max({ ans,dp[i + 1][j],dp[i + 1][j + D[i].first] });
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 70656
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        for(int i = 0; i < n-1; i++){
            sum += x[i];
        }
        String ans = "No";
        if(sum > x[n-1]){
            ans = "Yes";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
N = int(input())
array = []
for i in range(N):
  x,y = list(map(int,input().split()))
  array.append([x,y])
sum = 0
for j in range(N):
  for k in range(N):
    if j >= k:
      continue
    else:
      length = ((array[j][0]-array[k][0])**2 + (array[j][1]-array[k][1])**2)**(1/2)
      sum += length
print((2*sum)/N)


Measured memory_bytes: 3188
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
r += sorted(p)[-x:]
r += sorted(q)[-y:]
ans = sum(sorted(r)[-(x+y):])
print(ans)

Measured memory_bytes: 22560
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def main():
    N,M=MI()
    AB=LLIN_(M)
    matrix = [[0]*N for _ in range(N)]

    def dfs(matrix):
        stack = [0]
        visited = set([0])
        while stack:
            u = stack.pop()
            for i,v in enumerate(matrix[u]):
                if v and i not in visited:
                    stack.append(i)
                    visited.add(i)
        return len(visited)!=len(matrix) #非連結になった
    
    for i,(a,b) in enumerate(AB):
        matrix[a][b] = 1
        matrix[b][a] = 1
    ans = 0
    for i,(a,b) in enumerate(AB):
        matrix[a][b] = 0
        matrix[b][a] = 0
        ans += dfs(matrix)
        matrix[a][b] = 1
        matrix[b][a] = 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 39280
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;

int main(){
  int k,x;
  cin >>k>>x;
  int start = x-k+1;
 for(int i = 0;i<2*k-1;i++){
   if(start<=1000000 || start >=-1000000){
   cout << start <<" ";
    start++;
   }
 }
 cout <<endl;
  return 0;
}

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

#define N 110

int n, m, a[N][N];

int prv[N], vis[N];
vector<int> g[N][N];

int ans[N][N];

int bpm(int x) {
	for (int i = 1; i <= n; i ++) if (!g[x][i].empty()) {
		if (vis[i]) continue;
		vis[i] = 1;
		if (!prv[i] || (prv[i] && bpm(prv[i]))) {
			prv[i] = x; return 1;
		}
	}
	return 0;
}



int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			int x = (a[i][j] - 1) / m + 1;
			g[i][x].push_back(a[i][j]);
		}
	}
	for (int i = 1; i <= m; i ++) {
		memset(prv, 0, sizeof prv);
		for (int j = 1; j <= n; j ++) {
			memset(vis, 0, sizeof vis);
			bpm(j);
		}
		for (int j = 1; j <= n; j ++) {
			vector<int> &cur = g[prv[j]][j];
			ans[i][prv[j]] = cur.back();
			cur.pop_back();
		}
	}
	for (int j = 1; j <= n; j ++) {
		for (int i = 1; i <= m; i ++) {
			printf("%d%c", ans[i][j], (i<m?' ':'\n'));
		}
	}
	for (int i = 1; i <= m; i ++) sort(ans[i] + 1, ans[i] + n + 1);
	for (int j = 1; j <= n; j ++) {
		for (int i = 1; i <= m; i ++) {
			printf("%d%c", ans[i][j], (i<m?' ':'\n'));
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

typedef long long li;


template <class Iterator>
long long inversion_number(Iterator from, Iterator to) {
    if (to - from < 2) {
        return 0;
    }
    const auto mid = from + (to - from) / 2;
    long long ans = 0;
    ans += inversion_number(from, mid);
    ans += inversion_number(mid, to);
    auto fp = from;
    auto sp = mid;
    while (fp < mid && sp < to) {
        if (*sp < *fp) {
            ans += mid - fp;
            sp++;
        } else {
            fp++;
        }
    }
    sort(from, to);
    return ans;
}

template <class T>
long long inversion_number(const vector<T>& arr) {
    vector<T> copy(arr);
    return inversion_number(copy.begin(), copy.end());
}

map<char, vector<int>> groupbychar(const string& s) {
    map<char, vector<int>> ans;
    for (int i = 0; i < s.size(); ++i) {
        ans[s[i]].push_back(i);
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    const li n = s.size();

    map<char, li> cnt;
    for (auto &&c : s) {
        cnt[c] += 1;
    }

    li odd_cnt = 0;
    for (auto &&item : cnt) {
        if (item.second & 1) {
            odd_cnt += 1;
        }
    }
    if (odd_cnt > 1) {
        cout << -1 << endl;
        return 0;
    }

    string front, back;
    map<char, li> front_cnt;
    li prep_cost = 0;
    for (li i = 0; i < n; ++i) {
        const char c = s[i];
        if ((front_cnt[c] + 1) * 2 <= cnt[c]) {
            prep_cost += i - front.size();
            front.push_back(c);
            front_cnt[c] += 1;
        } else if (front_cnt[c] * 2 + 1 == cnt[c]) {
            prep_cost += back.size();
            front_cnt[c] += 1;
        } else {
            back.push_back(c);
        }
    }
    reverse(back.begin(), back.end());
//    cerr << prep_cost << endl;
//    cerr << front << endl;
//    cerr << back << endl;

    auto front_pos = groupbychar(front);
    auto back_pos = groupbychar(back);

    vector<int> perm(front.size());
    for (char c = 'a'; c <= 'z'; c++) {
        auto front_idx = front_pos[c];
        auto back_idx = back_pos[c];
        for (int j = 0; j < front_idx.size(); ++j) {
            perm[back_idx[j]] = front_idx[j];
        }
    }
    li ans = prep_cost + inversion_number(perm);

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

Measured memory_bytes: 2816
import bisect

a,b,q = map(int, input().split())

S = [-float('inf')]+[int(input()) for _ in range(a)]+[float('inf')]
T = [-float('inf')]+[int(input()) for _ in range(b)]+[float('inf')]
X = [int(input()) for _ in range(q)]

for x_i in X:
  pos_s = bisect.bisect_right(S, x_i)
  pos_t = bisect.bisect_right(T, x_i)
  
  s1 = S[pos_s-1]
  s2 = S[pos_s]
  t1 = T[pos_t-1]
  t2 = T[pos_t]
  
  ans1 = x_i - min(s1, t1)
  ans2 = max(s2, t2) - x_i
  ans3 = s2 - t1 + min(s2-x_i, x_i-t1)
  ans4 = t2 - s1 + min(t2-x_i, x_i-s1)
  print(min(ans1, ans2, ans3, ans4))

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

int N;
vector<long long> A;

void solve() {
    vector<long long> plus, minus;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<long long>());
    sort(minus.begin(), minus.end());
    if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();

    vector<pair<long long, long long> > res;
    long long cur = minus[0];
    for (int i = 0; i+1 < plus.size(); ++i) {
        res.push_back({cur, plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(), cur});
    cur = plus.back() - cur;

    for (int i = 1; i < minus.size(); ++i) {
        res.push_back({cur, minus[i]});
        cur -= minus[i];
    }

    cout << cur << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
}

int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    solve();
}



Measured memory_bytes: 5872
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ss=s.size();
    rep(i,ss){
        s[i]+=n;
        if(s[i]>90){
            s[i]=(s[i]-90)+64;
        }
        cout<<s[i];
    }
    cout<<endl;
}


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

int main() {
  int N;
  int x=0;
  cin >> N;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++){
  	
    int l,r;
    cin >> l >> r;
    x += (r - l) + 1;
  }
  
  cout << x;
  
}






Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,x;
    int r,b;
    cin>>s>>t;
    cin>>r>>b;
    cin>>x;
    if(x==s)
    {
        r--;
    }
    else if(x==t)
    {
        b--;
    }
    cout<<r<<" "<<b;

}


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

int main(){
	lint n;
	cin>>n;
	vector<lint> a(n);
	rep(i,n)cin>>a.at(i);
	sort(a.begin(),a.end());
	rep(i,n-1){
		if(a.at(i)==a.at(i+1)){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}


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

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

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll w;
	string s;
	string ans = "";

	cin >> s >> w;

	for (int i = 0; i < s.size(); i += w) {
		ans += s[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256