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

using namespace std;

#define run_forest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);


int n, m, q, x, y, k;
int dp[100001];

int main()
{                   
	run_forest_run;
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}	
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	dp[2] = min(dp[1] + abs(a[2]-a[1]), abs(a[2]-a[0]));
	for (int i = 3; 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];



}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 3e5 + 3;
ll n;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    cout<<n * n * n;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	const MX = 10000
	sieve := make([]int, MX)
	primes := make([]int, 0, MX)
	for i := 2; i < MX; i++ {
		if sieve[i] != 0 {
			continue
		}
		primes = append(primes, i)
		for j := i + i; j < MX; j += i {
			sieve[j] = i
		}
	}

	var n int
	fmt.Scan(&n)
	ans := 0
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		ans++
		for j := 0; j < len(primes); j++ {
			if x > primes[j] && x%primes[j] == 0 {
				ans--
				break
			}
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1824
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> cnt(N, 0);
    REP(i, N) {
        int A;
        cin >> A;
        cnt[A - 1]++;
    }
    int M = 0;
    for (auto x : cnt) {
        if (x > 0) {
            M++;
        }
    }
    SORT(cnt);
    int res = 0, i = 0;
    for (auto x : cnt) {
        if (i >= M - K) {
            break;
        } else if (x > 0) {
            res += x;
            i++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n;
string s[2000];
int a;
int a2;
int b;
lint ans;

int main(){
  cin >> a >> b;
  cout << a-b+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int cnt=0;
	sort(a,a+n);
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			int val=a[i]+a[j];
			int p=lower_bound(a,a+n,val)-a;
			cnt+=p-j-1;
		}
	}
	cout<<cnt<<endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double v[] = new double[N];

		for (int i = 0; i < N; i++) {
			v[i] = sc.nextDouble();
		}

		Arrays.sort(v);
		double answer = v[0];

		for (int i = 0; i < N - 1; i++) {
			answer = (answer + v[i + 1]) / 2;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23380
import fractions
N = int(input())
A = list(map(int,input().split()))

L = [0]*N
R = [0]*N

for i in range(N-1):
	L[i+1] = fractions.gcd(L[i],A[i])
	R[-i-2] = fractions.gcd(R[-i-1],A[-i-1])

gcd = 1
for i in range(N):
	gcd = max(gcd,fractions.gcd(L[i],R[i]))

print(gcd)


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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a.at(i);
    }

    int all_xor = 0;
    for ( int i = 0; i < N; i++ ) {
        all_xor ^= a.at(i);
    }

    for ( int i = 0; i < N; i++ ) {
        int ans = all_xor ^ a.at(i);
        cout << ans;
        if ( i != N-1 ) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n,m;
    while(cin >> n >> m, n||m){
        int a[1005], ans = 0;
        rep(i,n) cin >> a[i];
        sort(a, a + n, greater<int>());
        rep(i,n){
            if(i % m != m - 1) ans+=a[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1180
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int a[50], b[50], c[50], d[50];
	rep(i, n) cin >> a[i] >> b[i];
	rep(j, m) cin >> c[j] >> d[j];
	for (int i = 0; i < n; ++i) {
		int tmp = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		int ans = 1;
		for (int j = 1; j < m; ++j) {
			int Manhattan = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (tmp > Manhattan) {
				tmp = Manhattan;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int  main()
{
	int a,b; cin >> a >> b;

	double ans = (double)(a+b) / 2;
	cout << ceil(ans) << endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
a, b = 0, 0
if(K%2 == 0):
  for i in range(1, N+1):
    if(i%K == 0):
      a += 1
    elif(i%K == K//2):
      b += 1
else:
  for i in range(1, N+1):
    if(i%K == 0):
      a += 1
print(a**3 + b**3)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int lim = (N-1)*(N-2)/2;
    if (lim < K) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> edge, V;
    REP(i, 1, N) {
        edge.push_back(make_pair(1, i+1));
    }

    int i = 2, j = i;
    while (lim > K) {
        j++, lim--;
        edge.push_back(make_pair(i, j));
        if (j == N) i++, j = i;
    }

    cout << edge.size() << endl;
    rep(i, edge.size()) {
        printf("%d %d\n", edge[i].first, edge[i].second);
    }

    return 0;
}

Measured memory_bytes: 384
import sys
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

if P == Q:
    print(0)
    sys.exit()

perm = list(permutations(P))
perm.sort()
p, q = -1, -1
for i, pm in enumerate(perm):
    if pm == P:
        p = i
    if pm == Q:
        q = i
print(abs(p - q))


Measured memory_bytes: 13836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct tri{
  ll f,s,t;
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;ll K;cin >> N >> K;
  vector<PII> v(N);
  vector<int> w(N);
  ll b;
  b = K+2*N-1;
  int index = 0;
  if(2*K-1>N){
    cout << -1 << endl;
    return 0;
  }
  repp(x,K,K+N){
    if((x&1)==0)continue;
    v[index].first = x+b;
    v[index].second = x;
    w[index] = x;
    ++index;
    --b;
  }
  repp(x,K,K+N){
    if(x&1)continue;
    v[index].first = x+b;
    v[index].second = x;
    w[index] = x;
    ++index;
    --b;
  }

  sort(all(v));
  sort(all(w));
  ll c = K+2*N;
  queue<tri> que;
  rep(i,N){
    que.push({v[i].second,v[i].first-v[i].second,c});
    ++c;
  }
  while(!que.empty()){
    tri t = que.front();que.pop();
    cout << t.f SP t.s SP t.t << endl;
  }
  return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

vector<int> arr;
int TRY(int x){

      int cost = 0;
      for(auto y : arr){
            cost += (x - y) * (x - y);
      }

      return cost;
}

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin >> n;
      for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            arr.pb(x);
      }
      int ans = INF;
      for(int i = 1; i < 100; i++){
            ans = min(ans, TRY(i));
      } 
      cout << ans;
}


Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split(' ');
            var A = int.Parse(AB[0]);
            var B = int.Parse(AB[1]);

            if(B%A==0)
            {
                Console.WriteLine(A + B);
                return;
            }
            Console.WriteLine(B - A);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    str S;cin>>S;
      int cnt =0;
    for(int i=0;i<3;i++){
      if(S[i]=='1')cnt++;
    }


    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ribhav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AConsecutiveIntegers solver = new AConsecutiveIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class AConsecutiveIntegers {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int k = s.nextInt();
            out.println(n - k + 1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23124
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,y = mi()

if (4*x-y)%2 == 0 and (4*x-y)>=0 and (y-2*x)>=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int count = 0;
			int cmax = 0;
			String clen = null;
			int stmax = 0;
			String stlen = null;
			String str = sc.nextLine();
			String[] sta = str.split(" ");
			for(int i = 0 ; i < sta.length ; i++){
				if(stmax < sta[i].length()){
					stmax = sta[i].length();
					stlen = sta[i];
				}
			}
			for(int j = 0 ; j < sta.length ; j++){
				count = 0;
				for(int k = 0 ; k < sta.length ; k++){
					if(sta[j].equalsIgnoreCase(sta[k])){
						count++;
						if(cmax < count){
							cmax = count ;
							clen = sta[j];
						}
					}
				}
				
			}
			System.out.println(clen + " " + stlen);
		}
		sc.close();
		
	}

}

Measured memory_bytes: 17300
n = gets.to_i
l = gets.split.map(&:to_i).sort
ans = 0
n.times do |i|
    ((i+1)...n).each do |j|
        ((j+1)...n).each do |k|
            ans += 1 if l[i] != l[j] && l[j] != l[k] && l[i]+l[j] > l[k]
        end
    end
end
puts ans

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

int n,l,arr[400],sum;

int main(){
	scanf("%d%d",&n,&l);
	for(int i =1;i<=n;i++){
		arr[i-1] = i+l-1;
		sum+=arr[i-1];
	}
	sort(arr,arr+n);
	if(arr[0]<0 && arr[n-1]<0) printf("%d\n",sum-arr[n-1]);
	else if(arr[0]>0 && arr[n-1]>0) printf("%d\n",sum-arr[0]);
	else printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int q = read.to!int;
	
	X[] xs;
	foreach(i; 0 .. n){
		xs ~= new X(read.to!long, read.to!long, read.to!long);
	}
	
	xs.sort!"a.x>b.x"();
	
	long[] ds;
	foreach(k; 0 .. q) ds ~= read.to!long;
	ds ~= 2_000_000_000;
	// dsは初めからソートされている
	print!1("ds:", ds);
	
	SegTree seg = new SegTree(0, q + 1);
	seg.setValue(0, q + 1, -1);
	print!1("seg:", seg);
	
	foreach(x; xs){
		long l = x.s - x.x;
		long r = x.t - x.x;
		
		int il = uplimit(0, q, (int i) => ds[i] < l) + 1;
		int ir = uplimit(0, q, (int i) => ds[i] < r) + 1;
		
		seg.setValue(il, ir, x.x);
		print!1("x:", [x.s, x.t, x.x], " l:", l, " r:", r, " il:", il, " ir:", ir, " seg:", seg);
	}
	
	foreach(k; 0 .. q) seg.getValue(k).writeln;
	
}

class X{
	long s, t, x;
	this(long s, long t, long x){
		this.s = s;
		this.t = t;
		this.x = x;
	}
}


/*
座圧してセグメント木



*/

// 区分木(区間への書き込み、1点の読み出し)
class SegTree{
	long value;
	SegTree left, right; // 左の子(a <= x < c)、右の子(c <= x < b)
	bool hasValue;
	bool isTerminal;
	SegTree parent;
	int a, b; // a <= x < b を担当する
	this(int a, int b){
		this.a = a, this.b = b;
		if(b - a == 1){
			this.isTerminal = 1;
		}
		else{
			int c = (a + b) / 2;
			this.left = new SegTree(a, c);
			this.right = new SegTree(c, b);
		}
	}
	
	// [a, b) に値を設定する ※[a, b) はこのノードの担当区間とかぶっていなくてもよい
	void setValue(int a, int b, long value){
		if(b <= this.a || this.b <= a) return;
		if(a <= this.a && this.b <= b){
			this.hasValue = 1;
			this.value = value;
		}
		else{
			if(this.hasValue){
				this.hasValue = 0;
				this.left.hasValue = 1, this.left.value = this.value;
				this.right.hasValue = 1, this.right.value = this.value;
			}
			this.left.setValue(a, b, value);
			this.right.setValue(a, b, value);
		}
	}
	
	// iにおける値 ※iは必ずこのノードの担当区間内である前提
	long getValue(int i){
		if(this.hasValue) return this.value;
		if(i < left.b) return left.getValue(i);
		else return right.getValue(i);
	}
	
	long[] array(){
		if(this.hasValue){
			long[] res;
			foreach(i; a .. b) res ~= this.value;
			return res;
		}
		else return this.left.array ~ this.right.array;
	}
	
	override string toString(){
		return this.array.to!string;
	}
}

// a <= x <=  c の中でfをみたす最大(二分探索; binary search) ※テンプレート版
T uplimit(T)(T a, T c, bool delegate(T) f){
	if(f(c)) return c;
	if(! f(a)) return a - 1;
	while(a + 1 < c){
		T b = (a + c) / 2;
		if(f(b)) a = b;
		else c = b;
	}
	return a;
}


Measured memory_bytes: 45052
n = int(input())
l = [int(_) for _ in input().split()]
if n < 3:
    print(0)
    exit()
ans = 0
l.sort()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a, b, c = l[i], l[j], l[k]
            if not (a == b or b == c or c == a):
                if a + b > c:
                    ans += 1
                    #print(i+1, j+1, k+1)
print(ans)

Measured memory_bytes: 68080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
vector<int>prime(200000);
int main(){
  prime[0] = prime[1] = 1;
  REP(i, 2, 100000){
    if(prime[i] == 0){
      for(int j = 2*i; 2*j < 200000; j+=i) prime[j] = 1;
    }
  }
  int n, p;
  while(scanf("%d%d", &n, &p) && (n != -1 || p != -1)){
    vector<int>bprime;
    for(int i = n+1, c = 0; c < p; i++){
      if(prime[i] == 0){
	bprime.push_back(i);
	c++;
      }
    }

    vector<int>sum;
    rep(i, p) REP(j, i, p) sum.push_back(bprime[i] + bprime[j]);
    sort(sum.begin(), sum.end());
    printf("%d\n", sum[p-1]);
  }
  return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w[10]={},k[10]={};
  int i;
  for(i=0;i<10;i++) cin >> w[i];
  for(i=0;i<10;i++) cin >> k[i];
  sort(w,w+10);
  sort(k,k+10);
  cout << w[7]+w[8]+w[9] << " " << k[7]+k[8]+k[9] << endl;
  return 0;
}

Measured memory_bytes: 1180
using System;
using System.Collections.Generic;
public class Test{
    public static void Main(){
        int h,w,ii,jj;
        string[] tmp;
        List<int> hl,wl;

        tmp = Console.ReadLine().Split(' ');
        
        h = int.Parse(tmp[0]);
        w = int.Parse(tmp[1]);
        
        string[] a,b;
        a = new string[h];
        b = new string[h];
        //Console.WriteLine(h);

        for(ii=0;ii<h;ii++){
            a[ii] = Console.ReadLine();
        }

        hl = new List<int>();
        wl = new List<int>();
        for(ii=0;ii<h;ii++){
            for(jj=0;jj<w;jj++){
                if(a[ii][jj] == '.'){
                    
                }
                else{
                    break;
                }
            }
            if(jj==w){
                hl.Add(ii);
                //Console.WriteLine("yes" + a[ii]);
            }
        }

        for(ii=0;ii<w;ii++){
            for(jj=0;jj<h;jj++){
                if(a[jj][ii] == '.'){

                }
                else{
                    break;
                }
            }
            if(jj==h){
                //Console.WriteLine("yes" + a[ii]);
                wl.Add(ii);
            }
        }

        for(ii=0;ii<h;ii++){
            for(jj=0;jj<w;jj++){
                if(!hl.Contains(ii) && !wl.Contains(jj)){
                    Console.Write(a[ii][jj]);
                }
            }
            if(!hl.Contains(ii)){
                Console.WriteLine();
            }
        }

    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  sort(H.begin(),H.end());
  long long ans=0;
  for(int i=0;i<N-K;i++){
    ans+=H.at(i);
  }
  cout<<ans<<endl;
}

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

int main()
{
	string s;
    cin >> s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='?')
        {
            s[i]='D';
        }
    }
    cout << s << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dob double
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if (a+b+c >= 22){
		cout<<"bust";
	}
	else{
		cout<<"win";
	}
	return 0;
}


Measured memory_bytes: 3612
import sys
from collections import deque

def main():
    A = deque()
    input()
    for e in sys.stdin:
        if e[0]=='i': #insert xxx
            A.appendleft(e[7:-1])
        else:
            if e[6]==' ': #delete xxx
                m = e[7:-1]
                if m in A: 
                    A.remove(m)
            elif e[6]=='F':
                A.popleft()
            else:
                A.pop()
    print(' '.join(A))

if __name__=='__main__':
    main()


Measured memory_bytes: 69732
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    cout << 180 * (N - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
//#include <unordered_set>
//#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
//using ll = long long;

const int INF = 1001001001;

int main()
{
    int x(0), y(0), z(0), ans(0);
    cin>>x>>y>>z;
	repi(i, x, y+1)
	    if(z%i==0)ans++;
	cout<<ans<<endl;
}


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

const int MAX=100005;
int N;

int score[MAX],state[MAX],now[MAX];
vector<pair<int,int>> T[MAX];
stack<pair<int,int>> S;
bool DFS(){
    bool check=true;
    for(int i=0;i<N;i++){
            S.push(make_pair(i,score[i]));
            state[i]=1;
        while(S.size()){
            int a=S.top().first;
            int b=S.top().second;
            int j;
            for(j=now[a];j<T[a].size();j++){
                int c=T[a][j].first;
                int d=T[a][j].second;
                if(state[c]==0){
                    score[c]=b+d;
                    state[c]=1;
                    S.push(make_pair(c,score[c]));
                    now[a]=j;
                    break;
                }
                else if(state[c]==1){
                    if(score[c]!=b+d){
                        check=false;
                    }
                }
            }
            if(T[a].size()==0||j==T[a].size()) S.pop();
        }
    }
    return check;
    
}

int main(){
    
    int M;cin>>N>>M;
    for(int i=0;i<N;i++){
        state[i]=0;
        score[i]=0;
    }
    for(int i=0;i<M;i++){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        T[a].push_back(make_pair(b,c));
        T[b].push_back(make_pair(a,-c));
    }
    for(int i=0;i<N;i++){
        sort(T[i].begin(),T[i].end());
    }
    if(DFS()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 10496
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

#define sz(x) (int)(x).size()
typedef long long ll;
using namespace std;

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

    int n;
    cin >> n;
    while(n--) {
        cout << "ACL";
    }

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n+1),ans;
  vector<bool> flag(n+1,false);
  rep(i,n) cin>>a[i+1];
  for(int i=n;i>=1;i--){
    int num=0;
    for(int j=i;j<=n;j+=i){
      if(flag[j]) num++;
    }
    if(num%2!=a[i]){
      flag[i]=true;
      ans.push_back(i);
    }
  }
  cout<<ans.size()<<endl;
  cout<<ans<<endl;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define LINF 10000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<LP, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};


int main(){
	int n;
	cin >> n;
	vector<llong> a(n);
	vector<llong> dp(n, LINF);
	REP(i ,n)
		cin >> a[i];
	FOR(i, 0, n)
		*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
	cout << lower_bound(dp.begin(), dp.end(), LINF) -dp.begin() << endl;
	return 0;
}


Measured memory_bytes: 4364
n = int(raw_input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().split())
    print "YES" if abs(((y2-y1)*(x4-x3) - (x2-x1)*(y4-y3))) < 1e-10 else "NO"

Measured memory_bytes: 4660
N=int(input())
T,A=map(int,input().split())
h=list(map(int,input().split()))
t=[]
for i in range(N):
  tmp=T-h[i]*0.006
  t.append(abs(tmp-A))
val=min(t)
for i in range(N):
  if t[i]==val:
    ans=i+1
  else:
    pass
print(ans)

Measured memory_bytes: 38256
s = input()
t = input()

if s == t:
    print("Yes")
    exit()

else:
    for i in range(1, len(s)):
        tmp = "".join(s[i::]) + "".join(s[:i:])
        if tmp == t:
            print("Yes")
            exit()

        if i == len(s) - 1:
            print("No")


Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class DReplacing {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;in>>n;
	    map<int,int> a;
	    ll sum =0;
	    rep(i,n){
	        int t;in>>t;
	        a[t]++;
	        sum+=t;
	    }
	    int q;in>>q;
	    vector<int> b(q), c(q);
	    rep(i,q){
	        in>>b[i]>>c[i];

	    }

	    rep(i,q){
	        sum+=-(b[i]*a[b[i]])+(c[i]*a[b[i]]);
            a[c[i]]+=a[b[i]];
	        a[b[i]]=0;
	        out<<sum<<endl;
	    }


	}
};


int main() {
	DReplacing solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8004
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    S = [str(c) for c in input().strip()]

    dp = [0] * N
    for i in range(1, N):
        s = S[i-1] + S[i]
        if s == 'AC':
            dp[i] += 1
    
    DP = list(accumulate(dp))

    for _ in range(Q):
        l, r = map(int, input().split())
        print(DP[r-1] - DP[l-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9440
def c_traveling(N, P):
    t = x = y = 0  # 初期時刻には原点にいる
    for t_next, x_next, y_next in P:
        dt = t_next - t
        dd = abs(x_next - x) + abs(y_next - y)
        if dt >= dd and dt % 2 == dd % 2:
            # 制限時間は次の座標へのマンハッタン距離以上持っていないとたどり着けない
            # 制限時間と距離の偶奇が一致していないと次の座標で止まることができない
            t, x, y = t_next, x_next, y_next
        else:
            return 'No'
    return 'Yes'

N = int(input())
P = [[int(i) for i in input().split()] for j in range(N)]
print(c_traveling(N, P))

Measured memory_bytes: 21052
n,k = map(int,input().split())

h = list(map(int,input().split()))

h.sort(reverse=True)

if k == 0 :
    print(sum(h))
elif k <= n :
    for i in range(k):
        h[i] = 0
    print(sum(h))
else :
    print(0)


Measured memory_bytes: 31552
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
    int a,b,c,x;
    scanf("%d %d",&a, &b);
    if(b==100){
        c = 1000*a + b;
    } else if(b/10 == 0){
        c = 10*a + b;
    } else{
        c = 100*a + b;
    }
    x = sqrt(c);
    
    puts(x*x==c?"Yes":"No");
    return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

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

    string s;
    int K;
    cin >> s >> K;

    vector<string> cand;
    for (int i = 0; i < s.size(); i++) {
        for (int l = 1; l <= K; l++) {
            if (i + l <= s.size())
                cand.push_back(s.substr(i, l));
        }
    }

    sort(all(cand));
    cand.erase(unique(all(cand)), cand.end());
    cout << cand[K - 1] << "\n";

    return 0;
}



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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3000005;


void solve()
{
	int n;
	cin >> n;

	string s;
	cin >> s;

	int r = 0, w = n - 1;
	int cnt = 0;
	while (r < w)
	{
		while (s[r] == 'R')r++;
		while (s[w] == 'W')w--;
		if (r < w)
		{
			cnt++;
			s[r] = 'R';
			s[w] = 'W';
			r++;
			w--;
		}

	}
	cout << cnt << endl;
	return;

}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt",  "r",  stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  queue<int> b;
  for(int&x: a) cin >> x;
  sort(a.begin(),a.end());
  while(m--) {
    if(!a.empty() &&
       (b.empty() || a.back() > b.front())) {
      b.push(a.back()/2);
      a.pop_back();
    } else {
      b.push(b.front()/2);
      b.pop();
    }
  }
  LL answer = 0ll;
  for(int x:a) answer += x;
  while(!b.empty()) {
    answer += b.front();
    b.pop();
  }
  cout << answer << endl;
  return 0;
}


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int routeNum, time;
    cin >> routeNum >> time;
    
    
    int route[routeNum][2];
    for(int i = 0; i < routeNum; i++){
        cin >> route[i][0];
        cin >> route[i][1];
    }
    
    int tmp = 1001;
    for(int i = 0; i < routeNum; i++){
        if(route[i][1] > time) continue;
        if(route[i][0] <= tmp) tmp = route[i][0];
    }
    
    tmp == 1001 ? cout << "TLE" : cout << tmp;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin >> h >> w;
  char data[2*h][w];
  for(int i=0;i<2*h;i+=2){
    for(int j=0;j<w;j++){
      cin >> data[i][j];
      data[i+1][j]=data[i][j];
    }
  }
  for(int i=0;i<2*h;i++){
    for(int j=0;j<w;j++){
      cout << data[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
package main

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

var (
	s = bufio.NewScanner(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	n = 0
	a = []int{}
)

func main() {
	n = nextInt(s)
	a = atoi(s)
	_ = nextInt(s)
	m := atoi(s)

	for _, v := range m {
		i := 0
		if solve(i, v) {
			fmt.Fprintln(w, "yes")
			continue
		}
		fmt.Fprintln(w, "no")
	}
	w.Flush()
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	r, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return r
}

func atoi(s *bufio.Scanner) []int {
	s.Scan()
	a := strings.Fields(s.Text())
	i := []int{}

	for _, v := range a {
		j, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		i = append(i, j)
	}
	return i
}

func solve(i, m int) bool {
	if m == 0 {
		return true
	} else if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-a[i])
}



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

//  2進数ならば baseNumber を  2 とする
// 10進数ならば baseNumber を 10 とする
ll GetDigitsCount(ll targetNumber, ll baseNumber) {
	ll digitsCount = 0;
	while (targetNumber != 0) {
		digitsCount++;
		targetNumber /= baseNumber;
	}
	return digitsCount;
}

int main() {

	ll n, k; cin >> n >> k;
	cout << GetDigitsCount(n, k) << endl;
    return 0;
}

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

int main(){
  double dist=0;
  long long num=1;
  int N;
  cin >> N;
  for(int i=1; i<=N; i++){
    num*=i;
  }
  vector<int> v;
  for(int i=1; i<=N; i++){
    v.push_back(i);
  }
  vector<pair<int, int> >p;
  for(int i=0; i<N; i++){
    int x, y;
    cin >> x >> y;
    p.push_back(make_pair(x,y));
  }
  double ans=0;
  do{
    double dist=0;
    dist+=sqrt(pow(p[v[0]-1].first-p[v[1]-1].first,2)+pow(p[v[0]-1].second-p[v[1]-1].second,2));
    for(int i=1; i<N-1; i++){
      dist+=sqrt(pow(p[v[i]-1].first-p[v[i+1]-1].first,2)+pow(p[v[i]-1].second-p[v[i+1]-1].second,2));
    }
    ans+=dist;
  }while(next_permutation(v.begin(),v.end()));
  ans /= num;
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int f[][] = new int[n][10];
		int p[][] = new int[n][11];
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<10;j++) {
				f[i][j] = fs.nextInt();
			}
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<11;j++) {
				p[i][j] = fs.nextInt();
			}
		}
		long res = -Long.MAX_VALUE/2;
		for(int i=1;i<(1<<10);i++) {
			long ans = 0;
			int cnt[] = new int[n];
			for(int j=0;j<10;j++) {
				if((i>>j&1)==1) {
					for(int k=0;k<n;k++) {
						if(f[k][j]==1) {
							cnt[k]++;
						}
					}
				}
			}
			int max = -Integer.MAX_VALUE/2;
			boolean ok = false;
			for(int j=0;j<n;j++) {
				int now = p[j][cnt[j]];
				ans+=now;
			}
			res = Math.max(res, ans);
		}
		System.out.println(res);
	}
}

class UnionFind{
	int parent[];
	UnionFind(int N){
		parent = new int[N];
		Arrays.fill(parent, -1);
	}
	
	boolean same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x) {
		if(parent[x]<0)return x;
		return parent[x] = root(parent[x]);
	}
	int size(int x) {
		return -parent[root(x)];
	}
	void unite(int x, int y) {
		if(size(x)<size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)return;
		parent[rx] += parent[ry];
		parent[ry] = rx;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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

Measured memory_bytes: 21972
input1 = input()
Alphabets = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
index = 0
for Alphabet in Alphabets:
  if Alphabet == input1:
    print(Alphabets[index + 1])
    break
  else:
    index += 1

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    // Here your code !
    int i,n,m,k,l,p,min;
    int t[50001]={};
    int tn[50001][20]={};
    int c[20];
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&c[i]);
    }
    for(k=1;k<=n;k++){
      for(l=0;l<m;l++){
        if(k==c[l]){
            t[k]=1;
        } else if(k>c[l]){
            tn[k][l]=t[k-c[l]]+1;
        }
      }
      min=tn[k][0];
      for(p=1;p<m;p++){
          if(min>tn[k][p]&&tn[k][p]!=0){
              min=tn[k][p];
          }
      }
      if(t[k]==0){
      t[k]=min;
      }
    }
    
    printf("%d\n",t[n]);
    return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  vector<string> SS(N);
  for(int i = 0; i < N; i++){
    SS.at(i) = S.at(i).substr(1, N-1) + S.at(i);
  }
  ll NN = 2*N-1;

  auto isok = [&](int x){
    bool flag = true;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        if(SS.at(i).at(j+x) != SS.at(j).at(i+x)) flag = false;
      }
    }
    return flag;
  };
  int ans = 0;
  for(int i = 0; i <= N-1; i++){
    if(isok(i)) ans++;
  }
  cout << ans * N << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

int n;
int l,r;

int main()
{
    cin>>n;
    l = n/100;
    r = n%100;
    l = (l>0 && l<=12);
    r = (r>0 && r<=12);
    if (l && r)
        cout<<"AMBIGUOUS"<<endl;
    if (!l && !r)
        cout<<"NA"<<endl;
    if (!l && r)
        cout<<"YYMM"<<endl;
    if (l && !r)
        cout<<"MMYY"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int a[3];
	int i;
	int tag5 = 0, tag7 = 0;
	for(i = 0; i < 3; i++)
		scanf("%d", &a[i]);
		for(i = 0; i < 3; i++)
		{
			if(a[i] == 5)
				tag5++;
				if(a[i] == 7)
					tag7++;
		}
		if(tag5 == 2 && tag7 == 1)
			printf("YES\n");
			else
				printf("NO\n");
				return 0;


}

Measured memory_bytes: 256