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();
		String str = sc.next();
		if (str.length() == 1) {
			System.out.println(str);
			return;
		}
		int s, g, idx;
		int[] a = new int[str.length() - 1];
		String bin;
		long ans = 0;
		for (int i = 0; i < Math.pow(2, str.length() - 1); i++) {
			bin = Integer.toBinaryString(i);
			for (int j = 0; j < bin.length(); j++) {
				a[j] = bin.charAt(bin.length() - j - 1) - '0';
			}
			idx = 0;
			for (int j = 0; j < str.length() - 1; j++) {
				if (a[j] == 1) {
					s = j;
					ans += Integer.valueOf(str.substring(idx, s + 1));
					idx = s + 1;
				}

			}
			ans += Long.valueOf(str.substring(idx, str.length()));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll mod = 1e9+7;

struct UnionFind {
    vll par;
    vll _size;

    UnionFind(ll N) : par(N), _size(N, 1) {
        rep(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        _size[ry] += _size[rx];
        _size[rx] = 0;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x) {
        return _size[root(x)];
    }
};

ll modinv(ll a, ll m) {
    ll x = a, y = m, u = 1, v = 0;
    while (y) {
        ll div = x / y;
        x -= div * y; swap(x, y);
        u -= div * v; swap(u, v);
    }
    return (u % m + m) % m;
}

ll comb(ll n, ll k) {
    ll dividend = 1, divisor = 1;
    rep(i, k) {
        dividend = (dividend * (n - i)) % mod;
        divisor = (divisor * modinv(i + 1, mod)) % mod;
    }
    return (dividend * divisor) % mod;
}

int main()
{
    ll N, M; cin >> N >> M;
    UnionFind uf(N);
    vll A(M), B(M);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    vll ans(M, 0);
    ll origin = N * (N - 1) / 2;
    for (ll i = M - 1; i >= 0; i--) {
        ll a = A[i], b = B[i];
        ans[i] = origin;
        if (!uf.same(a, b)) origin -= uf.size(a) * uf.size(b);
        uf.unite(a, b);
    }

    for (auto elem : ans) {
        cout << elem << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
     while(n>0) {
         int a = n % 10;
         if(a == 7){
             cout << "Yes" << endl;
             return 0;
         }
         n = n / 10;
     }
     cout << "No" << endl;
    return 0;
}

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

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

    int ans = 9999;
    rep(i, S.length()-2){
        string T = S.substr(i,3);
        int A = (T[0]-'0')*100+(T[1]-'0')*10+T[2]-'0';
        ans = min(abs(753-A), ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
template<typename T> T power(T a,T b){T r=1;while(b){if(b&1)r*=a;b/=2;a*=a;}return r;}

int main()
{
  fastio;
 
  
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,c*b,b*d});

}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e5+10;
int n;
struct node{
	int val,idx;
	bool operator<(const node &t){
		return val<t.val;
	}
}a[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].val);
		a[i].idx=i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		printf("%d ",a[i].idx);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, ans ;
string s;
queue<string> a, b, c, d;
int main() {
	cin >> n;
	REP(i, n) {
		string now;
		cin >> now;
		if (now[0] == 'B' and now[now.size() - 1] == 'A')c.push(now);
		else if (now[0] == 'B')b.push(now);
		else if (now[now.size() - 1] == 'A') a.push(now);
		else d.push(now);
	}
	while (!d.empty()) {
		s += d.front();
		d.pop();
	}
	if (!a.empty()) {
		s += a.front();
		a.pop();
	}
	while (!c.empty()) {
		s += c.front();
		c.pop();
	}
	if (!b.empty()) {
		s += b.front();
		b.pop();
	}
	while (!a.empty() or !b.empty()) {
		if (!a.empty()) {
			s += a.front();
			a.pop();
		}
		if (!b.empty()) {
			s += b.front();
			b.pop();
		}
	}
	REP(i, s.size() - 1) {
		if (s[i] == 'A' and s[i + 1] == 'B')ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 896
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 262144

char s[N];

int f(int k)
{
    int res = 0;
    while(k)
    {
        k = k % __builtin_popcount(k);
        ++res;
    }
    return res;
}

int ans[N];

int main()
{
    int n;
    scanf("%d%s", &n, s);
    int cnt = 0, ca, cb;
    int rma=0, rmb=0;
    int ta=1, tb=1;
    for(int i=0;i<n;++i) cnt += s[i] - '0';
    ca = cnt+1, cb = cnt-1;
    cb += !cb; //mod 0
    for(int i=n-1;i>=0;--i)
    {
        if(s[i] == '1') rma = (rma+ta) % ca, rmb = (rmb+tb) % cb;
        ta = (ta<<1) % ca, tb = (tb<<1) % cb;
    }
    ta = 1, tb = 1;
    for(int i=n-1;i>=0;--i)
    {
        int k, res;
        if(s[i] == '0')
        {
            k = (rma + ta) % ca;
            res = f(k) + 1;
        }
        else
        {
            if(cnt == 1)
            {
                res = 0;
            }
            else
            {
                k = (rmb + cnt-1 - tb) % cb;
                res = f(k) + 1;
            }
        }
        ans[i] = res;
        ta = (ta<<1) % ca, tb = (tb<<1) % cb;
    }
    for(int i=0;i<n;++i) printf("%d\n", ans[i]);
    return 0;
}


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

int main(){
	int H, N;
	cin >> H >> N;
	int damage = 0;
	rep(i, N) {
		int A;
		cin >> A;
		damage += A;
	}
	cout << (damage >= H ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{
    FLASH
    ll k,a,b;
    cin >> k >> a >> b;
    bool ok = false;
    int i =k;
    k =0;
    while(k <= b)
    {
        k+=i;
        if(k >= a && k <= b)
        {
            ok =true;
            break;
        }

    }
    if(ok)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}



Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	// if n == 2 {
	// 	fmt.Println(abs(a[0] - a[1]))
	// 	return
	// }

	left := make([]int, n+1)
	left[0] = 0
	for i := 0; i < n; i++ {
		left[i+1] = a[i] + left[i]
	}
	right := make([]int, n+1)
	right[0] = 0
	for i := 0; i < n; i++ {
		right[i+1] = a[n-1-i] + right[i]
	}

	// fmt.Println(left)
	// fmt.Println(right)
	min := math.Inf(1)

	for i := 1; i < n; i++ {
		x := left[i]
		y := right[n-i]
		// fmt.Printf("x=%d, y=%d\n", x, y)

		rec := float64(abs(x - y))
		if min > rec {
			// fmt.Printf("x=%d, y=%d\n", x, y)

			min = rec
		}
	}

	fmt.Println(int(min))

}

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


Measured memory_bytes: 6912
#include <stdio.h>
#include <string.h>

int main(){
	int i, N;
	char str[20];
	scanf("%s", str);

	N =strlen(str);
	for(i=N-1; i>=0; --i){
		printf("%c", str[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
#define INF 1<<20


struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
for (int i = 0;i < graph[pos].size();i++) {
	int to = graph[pos][i].to;
	int cost = graph[pos][i].cost;
	if (d[pos] + cost < d[to]) {
		d[to] = d[pos] + cost;
		q.push(Node(to, d[to]));
	}

}
	}
	cout << d[TO] << endl;
}
int partition(int A[], int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[], int n, int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >= 0) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n, int* v, int* ww) {
	int W[101][10001];
	for (int j = 0;j <= w;j++) {
		W[0][j] = 0;
	}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++) {
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n + 1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n + 1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x > 2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int gnc(int a, int b) {
	while (b%a != 0) {
		if (a > b) swap(a, b);
		else {
			b = b%a;
		}
	}
	return a;
}
int calc(int a, long long int b, long long int m) {
	if (b == 0) return 1;
	else if (b % 2 == 0) {
		long long int d = calc(a, b / 2, m);
		return (d*d) % m;
	}
	else {
		long long int d = calc(a, b -1, m);
		return (d*a) % m;
	}
}
vector<pair<int, int> > b(100000);
vector<int> src(100000);

int main() {
	int N;
	string S;
	int max=0;
	int x = 0;
	cin >>N ;
	cin >> S;
	for (int i = 0;i < N;i++) {		
		if (S[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		if (x > max) {
			max = x;
		}
	}
	cout << max << endl;
	return 0;
	}




Measured memory_bytes: 1408
using System;

namespace A___Duplex_Printing
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            if (n % 2 == 1)
                Console.WriteLine (n / 2 + 1);

            else
                Console.WriteLine (n / 2);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
	public static void main (String args[]) {
		Scanner lector= new Scanner (System.in);
		double N=lector.nextDouble();
		double M=lector.nextDouble();
		if (N==M) {
			System.out.println ("Yes");
		}
		else {
			System.out.println ("No");
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

ll f(ll x){
    if(x == 0) return 0;
    return f(x%__builtin_popcountll(x))+1;
}

int main(){
    ll n; string s; cin >> n >> s;
    ll cnt = 0;
    rep(i,n) cnt += s[i] - '0';
    vector<ll> ans(n,0);
    rep(i, 2){
        ll tmp = cnt + (i == 0 ? 1 : -1);
        if(tmp <= 0) continue;
        ll r = 0;
        rep(j, n){
            r = (r*2)%tmp;
            r += s[j] - '0';
        }
        ll t = 1;
        for(ll j = n-1; j >= 0; --j){
            if(s[j]-'0' == i){
                ll u = r;
                if(i == 0) u = (u+t)%tmp;
                else u = (u-t+tmp)%tmp;
                ans[j] = f(u)+1;
            }
            t = (t*2)%tmp;
        }
    }
    for(auto i : ans){
        cout << i << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int l, r;
  int ml = 0, mr = INT_MAX;
  int ans;

  cin >> n >> m;
  
  for(int i = 0;i < m;i++){
    cin >> l >> r;
    ml = max(l, ml);
    mr = min(r, mr);
  }

  if(mr >= ml){
    cout << mr - ml + 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	ll n;
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		vector<ll> a(n); for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
		sort(a.begin(), a.end());
		ll sum = 0;
		for (ll i = 1; i < n - 1; i++) sum += a[i];
		sum /= (n - 2);
		printf("%lld\n", sum);
	}
	return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int B[N-1];
    for(int i=0; i<N-1; i++){
        cin >> B[i];
    }
    int ans=0;
    for(int i=0; i<N-2; i++){
        ans+=min(B[i],B[i+1]);
    }
    ans+=(B[0]+B[N-2]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a;
  cin >> a;
  int ans=0;
  for(int i=1; i<35; i++){
    for(int j=2; j<35; j++){
      if(pow(i,j)>a){break;}
      ans = max(ans,(int)pow(i,j));
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int > s(m);
    vector<int > c(m);
    REP(i,m) cin >> s[i] >> c[i];

    // 条件なし
    if(m==0){
        if(n==1){
            cout << 0 << endl;
        }else if(n==2){
            cout << 10 << endl;
        }else{
            cout << 100 << endl;
        }
        return 0;
    }

    // 条件埋め
    vector<int > res(3);
    REP(i,3) res[i] = -1; // -1で初期化
    int error = 0; // 条件不整合エラーフラグ

    REP(i,m){
        // 正常(-1が入っている)または(同じ条件)
        if( (res[s[i]-1] == -1) || (res[s[i]-1] == c[i]) ){
            res[s[i]-1] = c[i];
        }else{
            error = 1;
        }
    }
    // エラー処理
      // 条件不整合エラー
    if(error){
        cout << -1 << endl;
        return 0;
    }
      // 2桁以上なのに0始まりエラー
    if(n>=2 && res[0] == 0){
        cout << -1 << endl;
        return 0;
    }

    // 未確定桁の決定処理
    if(n>=2 && res[0] == -1){
        res[0] = 1;
    }else if(res[0] == -1){
        res[0] = 0;
    }
    if(res[1] == -1){
        res[1] = 0;
    }
    if(res[2] == -1){
        res[2] = 0;
    }

    // 出力
    REP(i,n){
        cout << res[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while(N > 0){
        ans++;
        N /= K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b)printf("a < b\n");
	if(a==b)printf("a == b\n");
	if(a>b)printf("a > b\n");
	return 0;
	}

Measured memory_bytes: 580
# -*- coding: utf-8 -*-
import math

N = int(input())
an = map(int, input().split())

d = {}
for a in an:
    d[a] = d.get(a, 0) + 1

count = 0
for i, v in d.items():
    if v < i:
        count += v
    elif v > i:
        count += v - i

print(count)

Measured memory_bytes: 23412
using System;
using System.Collections;
using System.Linq;

public class MainApp
{
    static public void Main(string[] args)
    {
        var read = Console.ReadLine();
        int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int max =0;
        int min = 1000;
        for (int c = 0; c < x.Length; c++)
        {
            if (x[c] > max) max = x[c];
            if (x[c] < min) min = x[c];
        }
        Console.WriteLine(max - min);

    }


}

Measured memory_bytes: 13268
let quick_sort (a : (int * char * int) array) cmp =
  let partition p r =
    let x = a.(r) in
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec doit i j =
      if j >= r then i
      else begin
        if cmp a.(j) x <= 0 then (swap (i + 1) j; doit (i + 1) (j + 1))
        else doit i (j + 1)
      end
    in
    let i = doit (p - 1) p in
    swap (i + 1) r;
    i + 1
  in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end
  in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let p (xi, _, xd) (yi, _, yd) = xd = yd && xi > yi
  in
  let rec doit i =
    if i = n - 1 then true
    else if p a.(i) a.(i + 1) then false
    else doit (i + 1)
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.init n (fun i -> Scanf.scanf "%c %d\n" (fun c d -> (i, c, d))) in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8920
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

int n, i, dp[maxN], a[maxN];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (i = 2; i < n; i++){
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}



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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  char curr = s[0];
  for(int i = 1; i < s.length(); i++) {
    if(s[i] != curr) count++;
    curr = s[i];
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;


int main()
{
  int i;
  cin>>i;
  for(;i--;)
    {

      double xa,ya,ra,xb,yb,rb;     
      int ans;
      cin>>xa>>ya>>ra>>xb>>yb>>rb;
      double d = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
      if(d  > ((ra+rb)*(ra+rb)))
	ans = 0;
      else if (d < ((ra-rb)*(ra-rb)) && ra>rb)
	ans = 2;
      else if (d  < ((rb-ra)*(rb-ra)) && rb>ra)
	ans =-2;
      else
	ans =1;
      cout<<ans<<endl;

    }

}

Measured memory_bytes: 1232
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		String s=sc.next();
		if(a>=3200) {
			System.out.println(s);
		}
		else {
			System.out.println("red");
		}
	}
}

Measured memory_bytes: 22868
import itertools
n, m, q = map(int, input().split())

array = []
for i in range(q):
    a = list(map(int, input().split()))
    array.append(a)

comb = list(itertools.combinations_with_replacement(range(1, m+1), n))

ans = 0
for i in comb:
    score = 0
    for a, b, c, d in array:
        if i[b-1] - i[a-1] == c:
            score += d
        ans = max(ans, score)
print(ans)

Measured memory_bytes: 21488
#include <iostream>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

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

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

	int ans;
	ans = 180*(N-2);

	cout << ans << endl;


}


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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

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

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

long long gcd(long long x, long long y, long long &a, long long &b) {
	// debug(x, y);
	if(y == 0) {
		a = 1;
		b = 0;
		return x;
	}

	long long g = gcd(y, x % y, a, b);
	long long tmp = a;
	a = b;
	b = tmp - (x / y) * b;
	return g;
}

long long inv(long long x, long long y) {
	// inverse of x wrt y

	// debug(x, y);

	long long a, b;
	long long g = gcd(x, y, a, b);
	assert(g == 1);
	a %= y;
	if(a < 0)
		a += y;
	return a;
}

void solve() {
	long long n;
	cin >> n;
	long long res;
	if(n % 2 == 1)
		res = n;
	else
		res = n - 1;
	n *= 2;
	vector<pair<long long, long long>> fac;
	for(long long i = 2; i * i <= n; i++) {
		int cnt = 0;
		long long num = 1;
		while(n % i == 0) {
			cnt++;
			num *= i;
			n /= i;
		}
		if(cnt > 0)
			fac.push_back({i, num});
	}

	if(n > 1)
		fac.push_back({n, n});

	// for(auto pp : fac) {
	// 	cout << pp.fs << ' ' << pp.sd << '\n';
	// }
	// cout << '\n';

	int m = fac.size();
	
	for(int i = 0; i < (1 << m); i++) {
		long long x = 1, y = 1;
		for(int j = 0; j < m; j++) {
			if((i & (1LL << j)))
				x *= fac[j].second;
			else
				y *= fac[j].second;
		}

		if(x == 1 || y == 1) {
			// res = min(res, n);
			continue;
		}

		long long inv1 = inv(x, y);
		assert((inv1 * x - 1) % y == 0);
		res = min(res, inv1 * x - 1);

		debug(x, y, inv1, inv1 * x - 1);

		long long inv2 = (-inv1) % y;
		if(inv2 < 0)
			inv2 += y;
		assert((inv2 * x + 1) % y == 0);
		res = min(res, inv2 * x);
		debug(x, y, inv2, inv2 * x);

	}

	cout << res << '\n';

}

int main() {
	// cout << (1 << 16) << '\n';
	// cout << inv(18, 13) << '\n';
	// int t;
	// cin >> t;
	// while(t--)
		solve();
}


Measured memory_bytes: 3572
from numpy import *
N = int(input())
A = fromiter(map(int, input().split()), int64)
x = bitwise_xor.reduce(A)
A &= ~x
r = 0
while any(A):
    a = A.max()
    m = 1 << int(a).bit_length() - 1
    A[A&m>0] ^= a
    r ^= a * (not r & m)
print(x+r+r)

Measured memory_bytes: 22812
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       while(true){
           int n = Integer.parseInt(sc.nextLine());
           if(n == 0) break;
           int[] kouho = new int[26];
           for(int i=0;i<26;i++) {
                 kouho[i] = 0;
            }
           int[] current = new int[26];
           String[] vote = new String[n];
           boolean flag = false;
           
           vote = sc.nextLine().split(" ");
           loop: for(int i=0;i<n;i++){
               int d = vote[i].charAt(0) - 'A';
               kouho[d]++;
               for(int j=0;j<26;j++){
                   current[j] = kouho[j];
               }
               Arrays.sort(current);
               if(current[24] + (n-(i+1)) < current[25]){
                   int k = 0;
                   for(k=0;k<26;k++){
                       if(kouho[k] == current[25]) break;
                   }
                   System.out.printf("%c %d\n", k+'A', i+1);
                   flag = true;
                   break loop;
               }
           }
           if(!flag) System.out.println("TIE");
       }
    }
}



Measured memory_bytes: 47360
using System;

namespace AtCoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int a = int.Parse(x[0]);
            int b = int.Parse(x[1]);

            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		int[] d = {a, b, c};
		Arrays.sort(d);
		while(d[2] - 1 > d[1]) {
			ans++;
			d[1] += 2;
		}
		while(d[2] - 1 > d[0]) {
			ans++;
			d[0] += 2;
		}
		if(d[2] == d[1] && d[2] == d[0]) {
			System.out.println(ans);
		} else if(d[1] == d[0] && d[1] != d[2]) {
			System.out.println(ans + 1);
		} else {
			System.out.println(ans + 2);
		}
	}
}


Measured memory_bytes: 24916
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		long ans = 0;
		for (int i = 1; i < n; i++) {
			ans += a[i - 1] / 2;
			a[i - 1] %= 2;
			if (a[i - 1] > 0 && a[i] > 0) {
				a[i - 1]--;
				a[i]--;
				ans++;
			}
		}
		ans += a[n - 1] / 2;
		
		out.println(ans);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 9428
#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>;

#define INF 1e18

int main() {
  int n, m;
  cin >> n >> m;
  vector< vector<ll> > G(n, vector<ll>(n,INF));
  rep(i,m) {
    int s, t, d;
    cin >> s >> t >> d;
    G[s][t] = d;
  }
  rep(i,n) G[i][i] = 0;

  rep(k,n) rep(i,n) rep(j,n) {
    if (G[i][k] == INF || G[k][j] == INF) continue;
    G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
  }

  rep(i,n) if (G[i][i] < 0) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  rep(i,n) {
    rep(j,n) {
      if (j) cout << " ";
      if (G[i][j]==INF) cout << "INF";
      else cout << G[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(l,r,i) for(int i=l;i<r;i++)
#define P pair<int,int>
#define ll long long 

typedef string::const_iterator State;
class ParseError{};

int number(State &begin);
int factor(State &begin);
int term(State &begin);
int expression(State &begin);


int number(State &begin){
    int ret=0;

    while(isdigit(*begin)){
        ret*=10;
        ret+=*begin-'0';
        begin++;
    }

    return ret;
}

int factor(State &begin){
    int ret=0;

    if(*begin=='('){
        begin++;
        ret=expression(begin);
        begin++;
    }
    else{
        ret=number(begin);
    }
    return ret;
}

int term(State &begin){
    int ret=factor(begin);

    for(;;){
        if(*begin=='*'){
            begin++;
            ret*=factor(begin);
        }
        else if(*begin=='/'){
            begin++;
            ret/=factor(begin);
        }
        else{
            break;
        }
    }
    return ret;
}



int expression(State &begin){
    int ret=term(begin);

    for(;;){
        if(*begin=='+'){
            begin++;
            ret+=term(begin);
        }
        else if(*begin=='-'){
            begin++;
            ret-=term(begin);
        }
        else{
            break;
        }
    }
    return ret;
}

int main(){

    int n;
    cin>>n;
    cin.ignore();
    for(int i=0;i<n;i++){
        string s;
        getline(cin,s);
        State begin=s.begin();
        cout<<expression(begin)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int in[3];
int main() {
	scanf("%d %d %d", &in[0], &in[1], &in[2]);
	int K;
	scanf("%d", &K);
	sort(in, in + 3);

	int ans = in[0] + in[1] + (in[2] << K);
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
/*input
1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    ll n;
    cin>>n;
    int len=1;
    ll x=0;
    ll cur=26;
    while(x<n){
        x+=cur;
        cur*=26;
        len++;
    }
    x-=(cur/26);
    n-=x;
    --len;
    --n;
    string ans="";
    REP(i,len){
        ans+=(char)(n%26+'a');
        n/=26;
    }
    reverse(ALL(ans));
    cout<<ans;
}

Measured memory_bytes: 3652
import java.io.*;
public class Main {
	
	static String letters;
	public static void main (String[] args) throws Exception
	{
		//Scanner sc = new Scanner(System.in);
		//letters=sc.next();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		letters = br.readLine();
		
		System.out.println (finder(letters));
	}
	
	
	
	static String finder (String str)
	{
		int count ;
		for(int i = 0; i<26;i++)
		{
			count = 0;
			for (int j = 0; j <letters.length() ;j++)
			{
				if (letters.charAt(j)==('a'+i))
					count++;
			}	
			if (count==0)
				return((char)('a'+i) +"");
		}
		return ("None");
	}
}

Measured memory_bytes: 36884
import java.util.Scanner;


public class Main {
	
	public static int cal(int cur, int raw, int n, int m){
		int ret = 0;
		
		if(cur > m){
			return 0;
		}else if(!(cur < n)){
			ret += 1;
		}
		
		switch(raw){
		case 2:
			ret += cal(cur*2, 2, n, m);
		case 3:
			ret += cal(cur*3, 3, n, m);
		case 5:
			ret += cal(cur*5, 5, n, m);
		}
		
		return ret;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			final int m = sc.nextInt();
			
			System.out.println(cal(1,2,n,m));
		}
		
	}

}

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

int main()
{
  string w,t;
  cin>>w;
  int ans=0;
  while(true)
  {
    cin>>t;
    if(t=="END_OF_TEXT") break;
    for (int i = 0; i < t.size(); ++i)
    {
      if(t[i]>='A' && t[i]<='Z') t[i]+=32;
    }
    if(w==t) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

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

#define scan1(a) scanf("%d", &a)
#define scan2(a,b) scanf("%d%d", &a,&b)
#define scan3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define print1(a) printf("%d\n", a)
#define print2(a,b) printf("%d%d\n", a,b)
#define print3(a,b,c) printf("%d%d%d\n", a,b,c)
#define print4(a,b,c,d) printf("%d%d%d%d\n", a,b,c,d)

int main(void){
    int a,b;
    scan2(a,b);
    
    print1(max(a+b,max(a-b,a*b)));
    
}


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

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll ans;
  if(a+b >= c-1) ans = b+c;
  else{
    ans = b+(a+b+1); 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import queue
q = queue.Queue()

a = int(input())

for x in range(9):
  q.put(x+1)

for x in range(a-1):
  tmp = q.get()
  if tmp%10 != 0:
    q.put(tmp*10+tmp%10-1)
  q.put(tmp*10+tmp%10)
  if tmp%10 != 9:
    q.put(tmp*10+tmp%10+1)
print(q.get())

Measured memory_bytes: 12452
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=list(int(input()) for i in range(n))

bingo="No"

for k in range(n):
  for i in range(3):
    for j in range(3):
      if b[k]==a[i][j]:
        a[i][j]=0
        
for i in range(3):
  if a[i]==[0,0,0]:bingo="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:bingo="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:bingo="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:bingo="Yes"

print(bingo)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

string ans;

class board{
public:
  int h,c;
  string s;
  board(int x,int y,string z){ h=x; c=y; s=z;}
  const bool operator<(const board x)const{return h+c>x.h+x.c; }
};

int score(string s){
  int res=0,m;
  for(int i=0;i<25;i++){
    if(s[i]!='x' && s[i]!='o'){
      for(int j=0;j<25;j++){
	if(s[i]==ans[j]){
	  m = abs(i/5-j/5) + abs(i%5-j%5);
	  //cout << s[i] << " " << m << endl;
	  break;
	}
      }
      res += m;
    }
  }
  return res;
}

char trans(int x){
  if(!x)return 'o';
  else return 'a'+x-1;
}

int main(){
  string s;
  ans = "xxoxxxabcxdefghxijkxxxoxx";
  int tmp,cost;

  for(;;){
    cin >> tmp;
    if(tmp<0)break;

    s = "xx";
    s += trans(tmp);
    s += "xxx";
    for(int i=0;i<3;i++){
      cin >> tmp;
      s += trans(tmp);
    }
    s += "x";
    for(int i=0;i<5;i++){
      cin >> tmp;
      s += trans(tmp);
    }
    s += "x";
    for(int i=0;i<3;i++){
      cin >> tmp;
      s+= trans(tmp);
    }
    s += "xxx";
    cin >> tmp;
    s += trans(tmp);
    s += "xx";

    priority_queue<board> q;
    q.push(board(score(s),0,s));

    map<string,bool> m;
    m[s] = 0;
    while(q.size()){
      board p = q.top();q.pop();
      int dx[] = {-5,1,5,-1};
      /*
      cout << p.h << " " << p.c;
      for(int i=0;i<25;i++){
	if(!(i%5))cout << endl;
	cout << p.s[i] << " ";
      }
      cout << endl;
      */
      cost = p.c;
      if(p.s == ans)break;
      if(p.h+cost>20){
	cost = 21;
	break;
      }
      m[p.s] = true;
      for(int i=0;i<25;i++){
	if(p.s[i]=='o'){
	  for(int j=0;j<4;j++){
	    int sx = i + dx[j];
	    string str = p.s;
	    if(sx<0 || 25<=sx)continue;
	    if(str[sx] == 'x' || str[sx] == 'o')continue;
	    swap(str[i],str[sx]);
	    if(!m[str])q.push(board(score(str),cost+1,str));
	  }
	}
      }
    }



    if(cost>20)cout << "NA\n";
    else cout << cost << endl;
    //score(s);
  }
}

Measured memory_bytes: 0
n,q = map(int,input().split())
s = input()
ac = [0 for i in range(n+1)]
ans = []
for i in range(len(s)-1):
    if s[i:i+2]=="AC":
        ac[i+1] = ac[i] + 1
    else:
        ac[i+1] = ac[i]

for i in range(q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])

Measured memory_bytes: 50976
import math

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'

input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d, x) if d else x;
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print('not' if d > 1 else r, 'coprime')


Measured memory_bytes: 162392
sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]
    for j in range(m + 1):
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")

Measured memory_bytes: 9084
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(C: str):
    print(chr(ord(C)+1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    C = next(tokens)  # type: str
    solve(C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  ll n;
  cin >>n ;
  vector< string> s(n) ;
  rep(i,n)cin>> s[i] ;
  sort(s.begin(),s.end()) ;
  ll ans=1 ;
  
  rep(i,n-1){
      if(s[i]!=s[i+1])
      ans++ ;
  }
   cout<<ans <<endl;
    return 0;
}






Measured memory_bytes: 9612
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B;
  cin >> A >> B;

  if (A % 2 == 1 && B % 2 == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
// UnionFind

#define MAXN 200010
ll par[MAXN]; // 親
ll deep[MAXN]; // 深さ

// in要素で初期化
ll init(ll in){
  for(int i=0;i<=in;i++){
    par[i]=i;
    deep[i]=0;
  }
}

// 木の根を求める
ll find(ll x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

// xとyの集合を併合
void unite(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(deep[x]<deep[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(deep[x]==deep[y]) deep[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(ll x,ll y){
  return find(x)==find(y);
}
int main(){
  int n,k;cin>>n>>k;
  init(n);
  rep(i,k){
    int x,y,z;cin>>x>>y>>z;
    unite(x-1,y-1);
  }
  set<int> s;
  rep(i,n){
    s.insert(find(i));
  }
  cout<<s.size();
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  int n,x,y;
  cin >>n>>x>>y;
  vi C(n);
  
  for(int i=1;i<n;i++){
	for(int j=i+1;j<=n;j++){
      int ans = min(j-i,abs(i-x)+1+abs(j-y));
      C[ans]++;
    }
  }
                    
  for(int i=1;i<n;i++) cout <<C[i]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<30;

int main(){
	int n,k;
  	cin >> n >> k;
  	cout << n-k+1 << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    map<int, int> mp;
    int n;
    cin >> n;
    while (n--) {
        int x;
        cin >> x;
        ++mp[x];
    }
    int ans = 0;
    for (pii i : mp) {
        if (i.fs < i.se) ans += i.se - i.fs;
        if (i.fs > i.se) ans += i.se;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4736
N = int(input())
a_ch = [chr(ch) for ch in range(ord('a'), ord('j') + 1)]

def DFS(s, mx):
  if len(s) == N:
    print(s)
  else:
    for i in range(mx + 1):
      if i == mx:
        DFS(s + a_ch[i], mx + 1)
      else:
        DFS(s + a_ch[i], mx)

DFS('', 0)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}
signed main(){start();
    int n,q;
    cin>>n;
    Vi a(n);
    REP(i,0,n){
        cin>>a[i];
        if(a[i]%2==1){cout<<"first";return 0;}
    }
    cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 1024