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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int p, q, cnt, min = n;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					p = x[i] - x[j];
					q = y[i] - y[j];
					cnt = n;
					for (int k = 0; k < n; k++) {
						for (int l = 0; l < n; l++) {
							if (x[k] - x[l] == p && y[k] - y[l] == q) {
								cnt--;
							}
						}
					}
					min = Math.min(min, cnt);
				}
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 22740
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if (1<=s1<=12) and (1<=s2<=12):
    print('AMBIGUOUS')
elif (1<=s2<=12)and(0<=s1<=99):
    print('YYMM')
elif (1<=s1<=12)and(0<=s2<=99):
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
# 新ステージでは、一度全部どんぐりに直してから換金を始めるとしてよい

def F(N, A, B):
  # N個のどんぐりを、Aで換金してからBに持っていく
  # Bでどんぐりに直す
  dp = [0] * (N+1)
  for n in range(N+1):
    x = n
    for j in range(3):
      if n >= A[j]:
        y = dp[n-A[j]] + B[j]
        if x < y:
          x = y
    dp[n] = x
  return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)

Measured memory_bytes: 230808
def prime(x):
    if x == 2:
        return 1
    if x < 2 or x % 2 == 0:
        return 0
    i = 3
    while (i**2 <= x):
        if x%i == 0:
            return 0
        i+=2
    return 1
def Isprime(x):
    sum = 0
    for i in x:
        sum += prime(i)
    return sum
n = int(input())
x = [int(input()) for i in range(n)]
print(Isprime(x))




Measured memory_bytes: 5984
N=int(input())
T=[list(map(int,input().split()))+[i] for i in range(N)]

E=[]

T.sort()
for i in range(1,N):
    E.append((T[i][0]-T[i-1][0],T[i-1][2],T[i][2]))

T.sort(key=lambda x:x[1])
for i in range(1,N):
    E.append((T[i][1]-T[i-1][1],T[i-1][2],T[i][2]))

# UnionFind

Group=[i for i in range(N)]# グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):# find(a)=find(b)のとき同じグループ
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  # xとyが同じグループになるよう更新
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))


E.sort()
ANS=0
for c,x,y in E:
    if find(x)!=find(y):
        Union(x,y)
        ANS+=c

print(ANS)

Measured memory_bytes: 50100
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

signed main(){
  int n,k; cin>>n>>k;
  vector<ll> a(n); rep(i,n) cin>>a[i]; sort(ALL(a));
  if(n==1){
    if(a[0]==k) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  ll g = a[0];
  rep(i,n-1) g=gcd(g,a[i+1]);
  if(k<=a[n-1]&&k%g==0) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	deque<char>S;
	rep(i, s.size()) {
		S.push_back(s[i]);
	}
	int ans = 0;
	while (S.size() > 1) {
		char f = S.front();
		char b = S.back();
		S.pop_front(); S.pop_back();
		if (f != b) {
			if (f == 'x') {
				ans++;
				S.push_back(b);
			}
			else if (b == 'x') {
				ans++;
				S.push_front(f);
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;

	return 0;
}

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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)

vector < ll > v;
int main()
{


    ll n , d ;
    cin >> n >> d;
     ll cnt = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        ll x , y;
        cin >> x >> y;
        if( sqrt( (x*x) + ( y*y)) <= d ){
            cnt++;
        }
    }
    cout << cnt << endl;





}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  float avg=0.0;
  for(int i=0;i<n;i++)
  {
      avg=avg+arr[i];
  }
  int avg1=int(avg/n);
  avg=ceil(avg/n);
  long long sum=0,sum1=0;
  for(int i=0;i<n;i++)
  {
      sum=sum+pow(abs(avg-arr[i]),2);
      sum1=sum1+pow(abs(avg1-arr[i]),2);
  }
  //cout<<sum<<" "<<sum1<<endl;
  cout<<min(sum,sum1);
}


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

void init() {
//#if __GLIBCXX__ == 20160609
#ifdef KEK
    freopen("a.in", "r", stdin);
    ///freopen("a.out", "w", stdout);
#else
    ///freopen(TASKNAME".in", "r", stdin);
    ///freopen(TASKNAME".out", "w", stdout);
#endif
}
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = (int)1e6 + 34;


void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
        cout << (s[i] == '1' ? '9' : '1');
    cout << "\n";
}

int main() {
    init();
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>

#define MAX 92

using namespace std;

static const int di[] = {-1,0,1,0};
static const int dj[] = {0,1,0,-1};

int dfs(bool vis[][MAX], char M[][MAX], int sti, int stj, int depth, int &ret)
{
  ret = max( ret, depth );
  for(int i = 0; i < sizeof(di)/sizeof(*di); ++i){
    int ti = sti+di[i];
    int tj = stj+dj[i];
    if( M[ ti ][ tj ] == 1 && !vis[ ti ][ tj ] ){
      vis[ ti ][ tj ] = true;
      dfs( vis, M, ti, tj, depth + 1, ret );
      vis[ ti ][ tj ] = false;
    }
  }
}

int main()
{
  while(true){

    int ans = 0;
    int n,m;
    bool vis[MAX][MAX]={{false,},};
    char M[MAX][MAX];

    cin >> m >> n;
    if( m == 0 && n == 0 ) break;
    for(int i = 0; i < MAX; ++i){
      for(int j = 0; j < MAX; ++j){
	M[i][j] = -1;
      }
    }

    for(int i = 0; i < n; ++i){
      for(int j = 0; j < m; ++j){
	int d;
	cin >> d;
	M[i+1][j+1] = d;
      }
    }

    for(int i = 0; i < n; ++i){
      for(int j = 0; j < m; ++j){
	if( M[i][j] == 1 ){
	  int cnt = 0;
	  for(int k = 0; k < 4; ++k){
	    int ti = i + di[k];
	    int tj = j + dj[k];
	    if( M[ti][tj] == 1 ){
	      ++cnt;
	    }
	  }
	  if( cnt == 1 ){
	    dfs( vis, M, i, j, 1, ans );
	  }
	}
      }
    }

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

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int a,b,x,max,k,i,j,sum;
	max=40001;
	sum=0;
	scanf("%d %d %d",&a,&b,&x);
		for(i=0;i<=400;i++){
			for(j=0;j<=200;j++){
				sum=1000*i+500*j;
				if(sum>=x){
	               k=a*i+b*j;
				if(k<max){
					max=k;
				}
				}
			}
		}
		printf("%d\n",max);
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n;cin>>n;
        if(n==0)return 0;
        int a[n];
        rep(i,0,n)cin>>a[i];
        sort(a,a+n);
        int sum=0;
        rep(i,1,n-1)sum+=a[i];
        sum/=(n-2);
        cout<<sum<<endl;
    }
}










Measured memory_bytes: 3116
s = input()
n = len(s)

for i in range(n-1):
    if s[i+1] == s[i]:
        a = i+1
        b = i+2
        print(*[a, b])
        exit()

for i in range(n-2):
    if s[i+2] == s[i]:
        a = i+1
        b = i+3
        print(*[a, b])
        exit()

print(*[-1, -1])

Measured memory_bytes: 80036
import sys
sys.setrecursionlimit(10 ** 6)
N, K = map(int, input().split())
mod = 10 ** 9 + 7
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)


def dfs(K, u, p):
    if p == -1:
        can_use_color_num = K - 1
    else:
        can_use_color_num = K - 2

    # if K < len(edges[u]):
    #     return 0
    # else:
    case_num = 1
    for e in edges[u]:
        if e == p:
            continue
        case_num *= can_use_color_num
        can_use_color_num -= 1
        case_num %= mod
    for e in edges[u]:
        if e == p:
            continue
        case_num *= dfs(K, e, u)
        case_num %= mod
    return case_num

ans = K * dfs(K, 0, -1)
ans %= mod
print(ans)

Measured memory_bytes: 87368
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> A >> B;
  vector<int>P(3,0);
  rep(i,0,N){
    cin >> C;
    if(C<A+1)P[0]++;
    else if(C>A&&C<B+1)P[1]++;
    else P[2]++;
  }
  Sort(P);
  Out(P[0]);
}

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

int N;
int map[2][101];


main(){
    cin>>N;
    for(int i=0; i<N; i++)
	cin>>map[0][i];
    for(int i=0; i<N; i++)
	cin>>map[1][i];

    int cntup[N], cntdn[N];
    cntup[0]=map[0][0];
    for(int i=1; i<N; i++){
        cntup[i]=cntup[i-1]+map[0][i];
    }
    cntdn[N-1]=map[1][N-1];
    for(int i=N-2; i>=0; i--){
        cntdn[i]=cntdn[i+1]+map[1][i];
    }

    int ans=0;
    for(int i=0; i<N; i++){
        ans=max(ans,cntup[i]+cntdn[i]);
    }

    cout<<ans<<endl;
}


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

int main()
{
    int n, t, a;
    cin >> n >> t >> a;

    vector<pair<int, int>> diff(n);
    rep (i, n)
    {
        int h;
        cin >> h;
        diff[i].first = abs(a * 1000 - (t * 1000 - h * 6));
        diff[i].second = i + 1;
    }

    sort(diff.begin(), diff.end());
    cout << diff[0].second << endl;
    return 0;
}


Measured memory_bytes: 3604
from decimal import Decimal
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(input())
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = int(Decimal(input())*10**9)
    p,q = waru(a,2)-9-50,waru(a,5)-9-50
    num[p][q] += 1
    lis[i] = [p,q]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(99,-1,-1):
    for j in range(99,-1,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    p,q = lis[i]
    x,y = p+50,q+50
    p = -x-50
    q = -y-50
    ans += cum2[p][q]
    if x>=0 and y>=0:
      ans -= 1
  return ans//2
print(solve())

Measured memory_bytes: 276464
#include<stdio.h>

int main(void)
{
    long k,a,b;
    long ans = 1;
    scanf("%ld%ld%ld",&k,&a,&b);

    if(k <= a || b - a < 3)
    {
        printf("%ld",ans+k);
        return 0;
    }

    ans = a;
    k -= a - 1;
    ans += k % 2;
    k /= 2;
    ans += (b - a) * k;
    
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN = 100000;
const int MAXN = 100000;

char s[MAXLEN + 1]; int len;
int n;
int l[MAXN], r[MAXN];

set<int> opt[MAXLEN + 1];
int optid[MAXLEN + 1];
int sub[MAXLEN + 1];

int merge(int a, int b) {
	if (SZ(opt[a]) < SZ(opt[b])) swap(a, b);
	for (auto it = opt[b].begin(); it != opt[b].end(); ++it) opt[a].insert(*it);
	return a;
}

bool solve() {
	int hlen = len / 2;
	REPE(i, len) optid[i] = i, sub[i] = 0;
	REP(i, n) {
		if (len - r[i] - 1 == l[i]) continue;
		if (l[i] > len - l[i] - 1) l[i] = len - l[i] - 1, r[i] = len - r[i] - 1, swap(l[i], r[i]);
		else if (r[i] >= len - r[i] - 1 && l[i] < len - r[i] - 1) r[i] = len - r[i] - 1 - 1;
		else if (r[i] >= len - r[i] - 1) l[i] = l[i] - 1, r[i] = len - r[i] - 1, swap(l[i], r[i]);
		opt[l[i]].insert(r[i] + 1);
		//printf("%d: %d..%d\n", i, l[i], r[i]);
	}
	//REPE(i, len) { printf("%d:", i); for (auto it = opt[i].begin(); it != opt[i].end(); ++it) printf(" %d", *it); puts(""); }

	int cnt = 0;
	REP(i, hlen) {
		int x = (s[i] - 'a' + cnt) % 26, y = s[len - i - 1] - 'a', need = (y - x + 26) % 26;
		if (SZ(opt[optid[i]]) == 0) {
			if (need != 0) return false;
		} else {
			auto it = opt[optid[i]].begin(); int cr = *it; opt[optid[i]].erase(it);
			cnt += need; sub[cr] += need;
			optid[cr] = merge(optid[i], optid[cr]);
		}
		cnt = ((cnt - sub[i + 1]) % 26 + 26) % 26;
	}
	assert(cnt == 0);
	return true;
}

void run() {
	scanf("%s", s); len = strlen(s);
	scanf("%d", &n); REP(i, n) scanf("%d%d", &l[i], &r[i]), --l[i], --r[i];

	printf("%s\n", solve() ? "YES" : "NO");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
bool f() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    vector<int> idx(n);
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&](int i, int j) {
        return b[i] < b[j];
    });
    vector<int> old_a = a, old_b = b;
    for (int i = 0; i < n; ++i) {
        a[i] = old_a[idx[i]];
        b[i] = old_b[idx[i]];
    }
    for (int i = 0; i < n; ++i) cerr << idx[i] << ' ';
    cerr << endl;
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
    for (int i = 0; i < n; ++i) cerr << b[i] << ' ';
    cerr << endl;
    vector<int> sorted_a = a;
    sort(begin(sorted_a), end(sorted_a));
    for (int i = 0; i < n; ++i) {
        if (sorted_a[i] > b[i]) {
            cerr << "sorted_a[i] > b[i]" << endl;
            return false;
        }
    }
    for (int i = 0; i < n - 1; ++i) {
        if (sorted_a[i + 1] <= b[i]) {
            cerr << "sorted_a[i + 1] <= b[i]" << endl;
            return true;
        }
        
    }
    map<int, int> mp;
  int c=0;
    for (int x : sorted_a) {
        mp[x] = c++;
    }
    assert(mp.size() == n);
    vector<bool> vis(n);
    for (int i = 0, cnt = 0; cnt < n; ++cnt) {
        cerr << i << '\n';
        if (vis[i]) {
            cerr << "not single cycle" << endl;
            return true;
        }
        vis[i] = true;
        i = mp[a[i]];
    }
    cerr << "single cycle" << endl;
    return false;
}
int main() {
    cout << (f() ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
	int K; cin >> K;
	long long ans = 0;
	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			for (int	k = 1; k <= K; k++)
			{
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

string s;
char c[] = {'-','+'};
ll A,B,C,D;

int main() {
    cin >> s;
    A = (ll)s[0]-(ll)'0';
    B = (ll)s[1]-(ll)'0';
    C = (ll)s[2]-(ll)'0';
    D = (ll)s[3]-(ll)'0';
    rep(i,1<<3){
        ll temp = A;
        char p1,p2,p3;
        if (i & 1) {
            temp += B;
            p1 = '+';
        }
        else {
            temp-=B;
            p1 = '-';
        }
        if (i & 1<<1) {
            temp += C;
            p2 = '+';
        }
        else {
            temp-=C;
            p2 = '-';
        }
        if (i & 1<<2) {
            temp += D;
            p3 = '+';
        }
        else {
            temp-=D;
            p3 = '-';
        }
        if (temp == 7){
            cout << A << p1 << B << p2 << C << p3 << D << '=' << 7 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    string O, E;
    cin >> O >> E;

    REP(i, E.length()) {
        cout << O[i] << E[i];
    }
    if(O.length() > E.length()) {
        cout << O[O.length() - 1];
    }
    cout << endl;

    return 0;
}

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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define ss second
#define ff first
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()

#ifndef ONLINE_JUDGE
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#else
#define trace(args...) { }
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;


ll f(ll n) 
{ 
  ll val = (n & 3);
  if(val == 0)
    return n;
  else if(val == 1)
    return 1;
  else if(val == 2)
    return n + 1;
  else
    return 0;
} 

int main()
{
  IOS;
  ll a, b;
  cin >> a >> b;
  if(a != 0 && b != 0) cout << (f(a - 1) ^ f(b)) << '\n';
  else if(a == 0 && b == 0) cout << 0 << '\n';
  else if(a == 0 && b > 0) cout << f(b) << '\n';
  return 0;
}

Measured memory_bytes: 256
from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

Measured memory_bytes: 3064
//abc141_a.cpp
//Sun Sep 15 20:57:40 2019

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

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

	if (s=="Sunny"){
		cout << "Cloudy" << endl;
	}else if (s=="Cloudy"){
		cout << "Rainy" << endl;
	}else {
		cout << "Sunny" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define pb push_back
#define I insert
int main()
{
  
  ll N;
  cin>>N;
  string S;
  cin>>S;
  ll count=0;
  ll i;
  for(i=0;i<S.size()-2;i++)
  {
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
      count++;
  }
  cout<<count<<"\n";
  return 0 ;
}

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

#include <cassert>
using namespace std;

int n;
vector<int> a;

void Solve() {
    long long l = 2;
    long long r = 2;
    for (int i = (int) a.size() - 1; i >= 0; --i) {
        int x = a[i];
        if (l % x != 0) {
            l += (x - (l % x));
        }
        if (r % x != 0) {
            r -= (r % x);
        }
        if (l > r) {
            cout << -1 << endl;
            return;
        }
        r += x - 1;
    }
    cout << l << " " << r << endl;
}

bool Read() {
    if (!(cin >> n)) {
        return false;
    }
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    return true;
}

int main() {
    // freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<int,int>
int A, B;
char ans[110][110];
int D[3] = { 1,0,-1 };
int main() {
	std::cin >> A >> B;
	A--;
	B--;
	for (int i = 1; i <= 50; i++)
		for (int j = 1; j <= 100; j++)
			ans[i][j] = '#';
	for (int i = 51; i <= 100; i++)
		for (int j = 1; j <= 100; j++)
			ans[i][j] = '.';
	for (int i = 2; i <= 100; i += 2) {
		for (int j = 2; j <= 100; j += 2) {
			if (A == 0)break;
			ans[i][j] = '.';
			A--;
		}
	}
	for (int i = 52; i <= 100; i += 2) {
		for (int j = 2; j <= 100; j += 2) {
			if (B == 0)break;
			ans[i][j] = '#';
			B--;
		}
	}
	std::cout << 100 << " " << 100 << std::endl;
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			std::cout << ans[i][j];
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	if(a>0&&b>0)
	{
		cout<<"Positive"<<endl;;
		return 0;
	}
	if(a<0&&b<0)
	{
		for(int i=a;i<=b;i++)
			sum++;
		if(sum%2!=0)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
		return 0;
	}
	if(a<=0&&b>=0)
	{
		cout<<"Zero"<<endl;;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
import sys
input = sys.stdin.readline


class Heap():
    def __init__(self, ):
        self.h = []

    def heapify(self, h):
        self.h = h
        heapify(self.h)

    def heappop(self,):
        return heappop(self.h)

    def heappush(self, x):
        heappush(self.h, x)


N, M, S = map(int, input().split())
INF = 10**100
G = [[] for _ in [0]*N]
C = []

for _ in [0]*M:
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G[v].append((u, a, b))
    G[u].append((v, a, b))

for i in range(N):
    a, b = map(int, input().split())
    C.append((a, b))


def push(t, s, v):
    if s < 0:
        return
    if s >= MAX:
        s = MAX-1
    if dp[v][s] <= t:
        return
    dp[v][s] = t
    heappush(q, (t, s, v))


MAX = 2500
S = min(S, MAX)
dp = [[INF]*MAX for _ in [0]*N]

q = []
push(0, S, 0)

while q:
    t, s, v = heappop(q)
    if dp[v][s] != t:
        continue

    c, d = C[v]
    push(t+d, s+c, v)

    for u, a, b in G[v]:
        push(t+b, s-a, u)

for d in dp[1:]:
    ans = INF
    for s in range(MAX):
        if ans > d[s]:
            ans = d[s]
    print(ans)


Measured memory_bytes: 24500
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const ll INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

#define all(c) (c).begin(), (c).end()

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


int main(){
  int n, m, q;
  cin >> n >> m >> q;
  int imos[500];
  int start[500];
  int end[500];
  int rui[500];
  int data[500][500];
  memset(data, 0, sizeof(data));
  REP(i, 500){
    imos[i] = start[i] = end[i] = rui[i] = 0;
  }
  REP(i, m){
    int l, r;
    cin >> l >> r;
    l--;
    imos[l]++;
    imos[r]--;
    rui[l]++;
    start[l]++;
    data[l][r - l - 1]++;
  }
  REP(i, 499){
    REP(j, 499){
      data[i+1][j] += data[i][j+1];
    }
  }
  REP(i, 500){
    REP(j, 499){
      data[i][j+1] +=data[i][j];
    }
  }
  REP(i, 499){
    imos[i + 1] += imos[i];
  }
  REP(i, 499){
    rui[i + 1] += rui[i];
  }
  /*
  REP(i, n){
    cout << imos[i] << endl;
  }
  cout << endl;
  REP(i, n){
    cout << start[i] << endl;
  }
  cout << endl;
  REP(i, n){
    cout << rui[i] << endl;
  }
  cout << endl;
  */
  REP(i, q){
    int l, r;
    cin >> l >> r;
    l--; r--;
    if(l == 0 && r == n - 1){
      cout << rui[r] << endl;
    }else if(l == 0){
      cout << rui[r] - (imos[r + 1] - start[r + 1]) << endl;
    }else if(r == n - 1){
      cout << rui[r] - rui[l - 1] << endl;
    }else{
      cout << rui[r] - (imos[r + 1] - start[r + 1]) - rui[l - 1] + data[l-1][499] - data[l-1][r-l+1] << endl;
    }
  }
  /*
  REP(i, n){
    REP(j, n){
      cout << data[i][499] - data[i][j - 1];
    }
  }
  */
}

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

#define ll long long

using namespace std;

const ll mod = 1000000007;

int n, k;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &k);
    ll res = 0;
    for (int i = k; i <= n + 1; ++i) {
        ll min = (ll) i * (i - 1) / 2;
        ll max = (ll) (n - i + 1 + n) * i / 2;
//        cout << i << " " << min << " " << max << "\n";
        res = (res + max - min + 1) % mod;
    }
    cout << res << "\n";
}


Measured memory_bytes: 3688
n = int(input())
a=[]
b=[]
for i in range(n):
    h,m=list(map(int,input().split()))
    a.append(h)
    b.append(m)
a.sort()
b.sort()

if n%2:
    k=(n-1)//2
    
        
    print(b[k]-a[k]+1)
else:
    k=n//2
    

    
    print(b[k]+b[k-1]-(a[k]+a[k-1])+1)



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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

template <typename T1, typename T2>
ostream& operator<< (ostream& os, const pair<T1,T2>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<vector<int>> nc(10, vector<int>(10));

  auto cntIJ = [&](ll i, ll j) -> ll {
    ll k = 0;
    for (ll base = 1; true; base *= 10) {
      ll x = ((i+1) * base - 1) * 10 + j;
      if (N < x) {
	for (ll p = 0; p < base; p++) {
	  if ((i * base + p) * 10 + j > N) {
	    DLOG("cntIJ", i, j, k);
	    return k;
	  }
	  k++;
	}
      }
      k += base;
    }
  };

  auto cntI = [&](ll i) -> ll {
    ll x;
    if (N < i) x = 0;
    else       x = cntIJ(i,i) + 1;
    DLOG("cntI", i, x);
    return x;
  };

  for (ll i = 1; i <= 9; i++) {
    for (ll j = 1; j <= 9; j++) {
      if (i == j) {
	nc.at(i).at(i) = cntI(i);
      }else {
	nc.at(i).at(j) = cntIJ(i, j);
      }
    }
  }


  ll cnt = 0;
  for (ll i = 1; i <= 9; i++) {
    for (ll j = 1; j <= 9; j++) {
      cnt += nc.at(i).at(j) * nc.at(j).at(i);
    }
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int ans = 0;
        HashMap<Long,Long> map = new HashMap<>();
        for(int i=0;i<n;i++){
            long x = sc.nextLong();
            long l= sc.nextLong();
            if(map.containsKey(x+l)&&l==0)ans++;
            if(map.containsKey(x+l)){
               // System.out.println("conflict");
               // System.out.println(Math.max(x-l,map.get(x+l)));
                map.put(x+l,Math.max(x-l,map.get(x+l)));
                //System.out.println(map.get(x+l));
            }else {
                map.put(x + l, x - l);
            }
        }

        Set<Long> key =map.keySet();
        List<Long> list = new ArrayList<>(key);
        list.sort(Long::compareTo);


        long now = Long.MIN_VALUE;
        for(Long i : list){
            // System.out.println(i+" "+map.get(i));
            if(map.get(i)>=now){
                ans++;
                now = i;
            }

        }

       System.out.println(ans);

    }
}


Measured memory_bytes: 99912
def main():
    i = int(input())
    if i == 0:
        print(0)
        exit()

    ans = ""
    while i:
        p, q = divmod(i, 2)
        if q:
            ans = "1" + ans
        else:
            ans = "0" + ans
        i = -p

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
 int N,K;cin>>N>>K;
 vector<bool> ans(N,false);
 vector<vector<int>> a(K,vector<int>(0));
 int res=0;
 for(int i=0;i<K;i++){
     int b;cin>>b;
     for(int j=0;j<b;j++){
         int s;cin>>s;s--;
         ans[s]=true;
     }

     }
     for(int i=0;i<N;i++){
         if(ans[i]==false)res++;
     }
     cout<<res<<endl;
 }


 
    
        






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

using namespace std;

int main() {
int A, B, C;
	cin >> A >> B >> C;
	int it = 0;
	while (A%2==0 && B%2==0 && C%2==0) {
		int a = A/2, b = B/2, c = C/2;
		A = b+c;
		B = a+c;
		C = a+b;
		++it;
		if (it > 1000000) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << it << endl;

}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	vector<pair<int,int>> a(n);
	fo(i,n)
	{
		cin>>a[i].F>>a[i].S;
		a[i].F-=a[i].S;
		a[i].S=a[i].F+2*a[i].S;
	}
	sort(all(a));
	
	// cerr<<a<<'\n';
	
	int ans=0;
	int ma=-INF;
	fo(i,n)
	{
		if(ma>a[i].F)
		{
			ans++;
			ma=min(ma,a[i].S);
		}
		else
		{
			ma=max(a[i].S,ma);
		}
	}
	cout<<n-ans<<'\n';
	printclock;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    string S; cin >> S;
    string ans = "";
  ans += S.at(0);
  ans += S.at(1);
  ans += S.at(2);
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
typedef struct{
  char mark;
  int value;
  int order;
}t;
  
int main(){
  int N,minj,f=0;
  t C1[36],C2[36],a;
  cin>>N;
 
  if(N>0 && N<37){
    for(int i=0;i<=N-1;i++){
      while(1){
      cin>>C1[i].mark;
      if(C1[i].mark!='D'&&C1[i].mark!='C'&&C1[i].mark!='S'&&C1[i].mark!='H')continue;	
      cin>>C1[i].value;
      break;
      }
      C1[i].order=i+1;
      C2[i]=C1[i];
    }
  
    for(int i=0;i<=N-1;i++)
      for(int j=N-1;j>=i+1;j--)
	if(C1[j].value < C1[j-1].value){
	  a=C1[j];
	  C1[j]=C1[j-1];
	  C1[j-1]=a;
	}	
  
    for(int i=0;i<N-1;i++) cout<<C1[i].mark<<C1[i].value<<' ';
    cout<<C1[N-1].mark<<C1[N-1].value<<endl;
  
    for(int i=0;i<=N-1;i++)
      if(C1[i].value==C1[i-1].value && C1[i].order-C1[i-1].order<0)f=1;
  
  if(f==0) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  f=0;
  
  for(int i=0;i<=N-1;i++){
    minj=i;
    for(int j=i;j<=N-1;j++)
      if(C2[j].value < C2[minj].value)minj=j;
    a=C2[i];
    C2[i]=C2[minj];
    C2[minj]=a;
  }
  for(int i=0;i<N-1;i++)cout<<C2[i].mark<<C2[i].value<<' ';
  cout<<C2[N-1].mark<<C2[N-1].value<<endl;
  for(int i=1;i<N;i++)
    if(C2[i].value==C2[i-1].value && C2[i].order-C2[i-1].order<0)f=1;
  if(f==0)cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = ['No'] * (N - K)
    for i in range(N - K):
        tmp = A[K + i] / A[i]
        if 1 < tmp:
            ans[i] = 'Yes'
    print("\n".join(ans))


if __name__ == "__main__":
    main()


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

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

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

template<class T> struct Seg { 
	const T ID = 0; // comb(ID,b) must equal b
	T combine(T a, T b) { return a+b; } 
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID);}

	void update(int p, T value) {	// set value at position p
		seg[p += n] = value;
		for (p /= 2; p; p /= 2) seg[p] = combine(seg[2*p], seg[2*p+1]);
	}
    
	T query(int l, int r) {	 // sum on interval [l, r]
		T ra = ID, rb = ID; 
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = combine(ra,seg[l++]);
			if (r&1) rb = combine(seg[--r],rb);
		}
		return combine(ra,rb);
	}
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vll arr (N);
	F0R(i, N) {
		cin >> arr[i]; arr[i] -= K;
	}

	Seg<ll> seg; seg.init(N+1);

	set<ll> sums; sums.insert(0);
	ll curSum = 0;
	
	F0R(i, N) {
		curSum += arr[i];
		sums.insert(curSum);
	}

	vll inds;
	for (ll x : sums) inds.push_back(x);

	ll ans = 0;
	seg.update(lower_bound(inds.begin(), inds.end(), 0) - inds.begin(), 1);

	curSum = 0;
	F0R(i, N) {
		curSum += arr[i];
		int pos = lower_bound(inds.begin(), inds.end(), curSum) - inds.begin();
		ans += seg.query(0, pos);
		seg.update(pos, seg.seg[pos + N + 1] + 1);
	}
	print(ans);
}

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

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

    vector<pair<int, int>> p(n);
    for (auto i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        p[i] = {a, b};
    }
    sort(p.begin(), p.end());

    int64_t sum = 0;
    for (auto i = 0; i < n; i++) {
        sum += p[i].second;
        if(sum >= k) {
            cout << p[i].first << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

using int64 = long long;

int Max(const vector<int>& xs) {
  int value = INT32_MIN;
  for (int x : xs) value = max(x, value);
  return value;
}

int Min(const vector<int>& xs) {
  int value = INT32_MAX;
  for (int x : xs) value = min(x, value);
  return value;
}

bool Solve() {
  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  int max = Max(xs);
  int min = Min(xs);
  if (max - min >= 2) return false;

  if (max == min) {
    int x = max;
    return x == n - 1 || 2 * x <= n;
  } else {
    int c = max;
    int k = 0;
    for (int x : xs) if (x == c - 1) k++;
    return c - k >= 1 && 2 * (c - k) <= n - k;
  }
}

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

  if (Solve()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin>>N;
  if(N==0)cout<<2;
  else if(N==1)cout<<1;
  else{
    int64_t L0,L1,L2;
    L1=2;L2=1;
    for(int i=1;i<N;i++){
      L0=L1;
      L1=L2;
      L2=L0+L1;
    }
    cout<<L2;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e5+10;

struct dwl{
	int flag,col,idx,len;
};

int sum[maxn],dist[maxn],len[maxn],ans[maxn];
int n,q;
vector <pair<int,pair<int,int> > > g[maxn];
vector <dwl> dw[maxn];

int parent[20][maxn],dep[maxn];
 
void dfs(int x,int p,int d){
	parent[0][x]=p;
	dep[x]=d;
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].fst;
		if(to==p) continue;
		dfs(to,x,d+1);
	}
}
 
void build_lca(){
	for(int k=0;k+1<20;k++){
		for(int i=0;i<n;i++){
			if(parent[k][i]==-1) parent[k+1][i]=-1;
			else parent[k+1][i]=parent[k][parent[k][i]]; 
		}
	}	
}
 
int get_lca(int u,int v){
	if(dep[u]>dep[v]) swap(u,v);
	for(int k=0;k<20;k++){
		if((dep[u]-dep[v])>>k&1){
			v=parent[k][v];
		}
	}
	if(u==v) return u;
	for(int k=19;k>=0;k--){
		if(parent[k][u]!=parent[k][v]){
			u=parent[k][u];
			v=parent[k][v];
		}
	}
	return parent[0][u];
}

void dfs(int x,int p){
	for(int i=0;i<dw[x].size();i++){
		if(dw[x][i].flag==1){
			ans[dw[x][i].idx]-=dist[x]*2;
			ans[dw[x][i].idx]+=len[dw[x][i].col]*2;
			ans[dw[x][i].idx]-=sum[dw[x][i].col]*dw[x][i].len*2;
		}
		else{
			ans[dw[x][i].idx]+=dist[x];
		//	cout<<dw[x][i].idx<<" "<<x<<" "<<dist[x]<<endl;
			ans[dw[x][i].idx]-=len[dw[x][i].col];			
			ans[dw[x][i].idx]+=sum[dw[x][i].col]*dw[x][i].len;
		//	cout<<ans[dw[x][i].idx]<<endl;
		}
	}
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].fst,c=g[x][i].snd.fst,l=g[x][i].snd.snd;
		if(to==p) continue;
		dist[to]=dist[x]+l;
		sum[c]+=1; len[c]+=l;
		dfs(to,x);
		sum[c]-=1; len[c]-=l;
	}
}

int main(){
	for(int d=0;d<20;d++) for(int i=0;i<maxn;i++) parent[d][i]=0;
	scanf("%d%d",&n,&q);
	for(int i=0;i<n-1;i++){
		int u,v,c,l;
		scanf("%d%d%d%d",&u,&v,&c,&l);
		u--; v--; c--;
		g[u].pb(mp(v,mp(c,l)));
		g[v].pb(mp(u,mp(c,l)));
	}
	dfs(0,-1,0);
	build_lca();
	for(int i=0;i<q;i++){
		int c,l,u,v;
		scanf("%d%d%d%d",&c,&l,&u,&v);
		u--; v--; c--;
		int lca=get_lca(u,v);
		dwl now;
		now.flag=0; now.col=c; now.len=l; now.idx=i;
		dw[u].pb(now); dw[v].pb(now);
		now.flag=1;
		dw[lca].pb(now);
	}
	for(int i=0;i<maxn;i++) ans[i]=0;
	dfs(0,-1);
	for(int i=0;i<q;i++) printf("%d\n",ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 32372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  int sum=n*(l-1)+n*(n+1)/2;
  vector<int>a(n+1);
  
  for(int i=0;i<=n;i++){
    a[i]=l+i-1;
  }
  if(a[n]<0){
    cout<<sum-a[n]<<endl;
  }else if(a[n]>=0 && a[1]<=0){
    cout<<sum<<endl;
  }else{
    cout<<sum-a[1]<<endl;
  }
}









  



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

int main(){
	int k,a,b;
	cin >> k;
	cin >> a >> b;
	bool ok = false;
	for(int i=a; i<=b; i++){
		if(i%k==0)ok=true;
	}
	if(ok){cout << "OK" << endl;}else{cout << "NG" << endl;}
	
	return 0;
}

Measured memory_bytes: 3636
N,Y = map(int,input().split())
for yukichi in range(N+1):
        for ichiyo in range(N+1):
            hideyo = N-yukichi-ichiyo
            if(10000*yukichi+5000*ichiyo+1000*hideyo == Y and hideyo >= 0):
                print(yukichi,ichiyo,hideyo)
                exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
n = int(input())
s = input()

ans = 0
for i in range(n-1):
    n_list = []
    x = s[:i+1]
    y = s[i+1:]
    for j in range(i):
        if x[j] in y:
            n_list.append(x[j])
    for j in range(n-1-i):
        if y[j] in x:
            n_list.append((y[j]))
    if len(set(n_list)) > ans:
        ans = len(set(n_list))

print(ans)


Measured memory_bytes: 3064