akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e5+20;
int n, a[MAXN], d[MAXN][20];
int res = 0;
inline int read(void){int x=0,f=1;char c=cin.get();while(!isdigit(c)){f=c=='-'?-1:1;c=cin.get();}while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=cin.get();}return x * f;}
signed main(signed argc, char *argv[])
{
	n=read();
	for(int i = 1; i <= n; i++)
		a[i]=read();
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < 20; j++) {
			d[i][j] = d[i - 1][j] + ((a[i] >> j) & 1);
		}
	}
	for(int i = 1; i <= n; i++) {
		int l = i, r = n, ans = i;
		while(l <= r) {
			int mid = (l + r) >> 1;
			int ok = 1;
			for(int j = 0; j < 20; j++) {
				if(d[mid][j] - d[i - 1][j] > 1) {
					ok = 0;
					break;
				}
			}
			if(ok)ans = mid, l = mid + 1;else r = mid - 1;
		}
		res += ans - i + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 33024
#include<stdio.h>

int main(void)
{
  int i,j,n,ans=0;
  
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
  for(i=0;i<n;i++)
    {
      while(a[i] % 2 == 0)
	{
	  ans++;
	  a[i] /= 2;
	}
    }

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

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right
n,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
S=list(accumulate(A))
i=bisect_right(S,x)
if i!=n:
    print(i)
else:
    if S[-1]==x:
        print(n)
    else:
        print(n-1)

Measured memory_bytes: 3060
#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,string>;

int main() {
int n;
string s;
cin >> n >> s;
int x = 0;
int ans = 0;
rep(i,n){
  if(s.at(i) == 'I') x++;
  else x--;
  ans = max(ans,x);
}
cout << ans << endl;
}


Measured memory_bytes: 3600
from math import ceil,log2

def main():
    N = int(input())
    UVW = [list(map(int,input().split())) for _ in range(N - 1)]
    edge = [[] for _ in range(N + 1)]
    dis = {}
    for u,v,w in UVW:
        edge[u].append(v)
        edge[v].append(u)
        dis[(u,v)] = w
        dis[(v,u)] = w
    cnt = 0
    queue = [1]
    gone = {1:0}
    while cnt < N:
        node = queue[cnt]
        for e in edge[node]:
            if e not in gone:
                if dis[(node,e)]%2 == 1:
                    gone[e] = (gone[node] + 1)%2
                else:
                    gone[e] = gone[node]
                queue.append(e)
        cnt += 1
    for i in range(1,N + 1):
        print(gone[i])
    return
if __name__ == "__main__":
    main()

Measured memory_bytes: 75416
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int K = sc.nextInt();
   int[] hi = new int[N];
   for(int i=0;i<N;i++ )
   {
     hi[i] = sc.nextInt(); 
   }
   
   int count = 0;
 for(int i=0;i<N;i++ )
   {
     if(hi[i] >= K) count++;
   }
   System.out.println(count);
   
 }
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N, A, B, C, a, b, c, MM=200000000, M, g1, g2, g3;
    cin >> N >> A >> B >> C;
    vector <string> S, St;
    string s, s1;
    char ch;
    St.push_back("");
    int L[N];
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    for (int i = 0; i < St.size(); i++)
    {
        s = St[i];
        if (s.length() == N)
        {
            S.push_back(s);
        }
        else if (s.length() < N)
        {
            for (int y = 0; y < 4; y++)
            {
                ch = '0' + y;
                s1 = s + ch;
                St.push_back(s1);
            }
        }
    }
    for (int i = 0; i < S.size(); i++)
    {
        s = S[i];
        a = 0;
        b = 0;
        c = 0;
        M = -30;
        g1 = 0;
        g2 = 0;
        g3 = 0;
        for (int y = 0; y < N; y++)
        {
            if (s[y] == '1')
            {
                a += L[y];
                M += 10;
                g1 = 1;
            }
            else if (s[y] == '2')
            {
                b += L[y];
                M += 10;
                g2 = 1;
            }
            else if (s[y] == '3')
            {
                c += L[y];
                M += 10;
                g3 = 1;
            }
        }
        M += fabs(a - A);
        M += fabs(b - B);
        M += fabs(c - C);
        if (M < MM && g1 == 1 && g2 == 1 && g3 == 1)
            MM = min(M, MM);
    }
    cout << MM;
    return 0;
}


Measured memory_bytes: 6004
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
        else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
        else if ( b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
        else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
        else if ( c <= a && a <= b )
        cout << c << " " << a << " " << b << endl;


 

}
 


Measured memory_bytes: 3044
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s,t;

	cin >> s >> t;

	bool	f;
	for(i=s.size()-t.size();i>=0;i--) {
		f = true;
		for(j=0;j<t.size();j++) {
			if (s[i+j]!='?' && s[i+j]!=t[j]) f = false; 
		}
		if (f) {
			for(j=0;j<t.size();j++) {
				if (s[i+j]=='?') s[i+j]=t[j]; 
			}
			break;
		}
	}
	if (f == false) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for(i=0;i<s.size();i++) {
		if (s[i]=='?') s[i] = 'a';
	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << s << endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n*3);
  for(int i = 0 ; i < n*3; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  long long sum = 0;
  for( int i = 0; i < 2*n; ++i ){
    if(i % 2 != 0) sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

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

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

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

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


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

    ll n;
    cin >> n;
    ll d[n];
    F0R(i,n) cin >> d[i];
    sort(d,d+n);
    ll ans = 0;
    FOR(i,d[n/2-1]+1,d[n/2]+1)
      ++ans;
    cout << ans << endl;

    return 0;
}

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


Measured memory_bytes: 1024
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*



fun solve() {
    val N = rd.readInt()
    val A = IntArray(N); val B = IntArray(N)
    for (i in 0 until N) {
        val (a, b) = rd.readIntArray()
        A[i] = a; B[i] = b
    }

    val L = A.sorted()
    val R = B.sorted()

    fun med2(asc: List<Int>): Int {
        return if (N%2==0) asc[(N-1)/2] + asc[(N-1)/2 + 1]
               else asc[(N-1)/2]*2
    }

    val medL = med2(L)
    val medR = med2(R)

    val ans = if (N%2==0) (medR-medL+1) else medR/2 - medL/2 + 1
    print(ans)
}


//val rd = debug.Reader("abc", "169", "e", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 
#define NMAX 
#define MMAX 

using namespace std;

int n, k, a, b, mn = 1000000000;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	long long ans = 0, mul = 0;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a >> b;
		ans += a;
		if(a != b) mul = 1;
		if(a > b)
			mn = min(mn, b);
	}
	cout << (ans - 1LL * mn) * mul << '\n';
}

Measured memory_bytes: 256
from math import floor
def sum(x):
    return int(x *(x+1)/2)
N = int(input())

S = sum(N)

fizz = floor(N/3)
buzz = floor(N/5)
fizzbuzz = floor(N/15)
print(S - 3 * sum(fizz) - 5*sum(buzz) + 15 * sum(fizzbuzz))

Measured memory_bytes: 9092
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        List<Integer> inputs = Stream.of(scanner.nextLine().split(" "))
                .map(Integer::parseInt)
                .collect(Collectors.toList());
        int cnt = 0;
        System.out.println(reduce(inputs, cnt));
    }

    private static int reduce(List<Integer> list, int cnt) {
        if (isEven(list)) {
            cnt++;
            return reduce(division(list), cnt);
        } else {
            return cnt;
        }
    }

    private static List<Integer> division(List<Integer> list) {
        return list.stream()
                .map(num -> num / 2)
                .collect(Collectors.toList());
    }

    private static boolean isEven(List<Integer> list) {
        return list.stream()
                .filter(s -> s % 2 != 0)
                .count() == 0;
    }
}

Measured memory_bytes: 36960
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const int N=200005;
const int mod=1e9+7;
using namespace std;

/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
int calc(int a,int b)
{
	int ans=1,tmp=a;
	while (b)
	{
		if (b&1) ans=(ll)ans*tmp%mod;
		tmp=(ll)tmp*tmp%mod,b>>=1;
	}
	return ans;
}
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
int main()
{
	#ifdef Kay
		//freopen ("code.in","r",stdin);
		//freopen ("code.out","w",stdout);
	#endif
	int i;ll n;
	for (i=0,n=1;i<=11;i++,n*=10)
	{
		printf ("? %lld\n",n);fflush(stdout);
		char c;scanf ("\n%c",&c);
		if (c=='N') break;
	}
	if (i==12)
	{
		for (i=1,n=10;i<=11;i++,n*=10)
		{
			printf ("? %lld\n",n+1);fflush(stdout);
			char c;scanf ("\n%c",&c);
			if (c=='Y') break;
		}
		if (i==1)
		{
			printf ("? 9\n");fflush(stdout);
			char c;scanf ("\n%c",&c);
			if (c=='Y') puts("! 1");
			else puts("! 10");
			fflush(stdout);
		}
		else printf ("! %lld\n",n);fflush(stdout);
		return 0;
	}
	i--;
	ll lb=1;
	while (i--) lb*=10;
	ll rb=lb*10,mid;lb--;
	while (lb<rb-1)
	{
		mid=lb+rb>>1;
		printf ("? %lld\n",mid*10);fflush(stdout);
		char c;scanf ("\n%c",&c);
		if (c=='N') lb=mid;
		else rb=mid;
	}
	printf ("! %lld\n",rb);fflush(stdout);
	return 0;
}


Measured memory_bytes: 684
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    vector<ll> a;
    vector<bool> bl;

    char now = s[0];
    ll count = 1;
    for(ll i=1;i<s.size();++i){
        if(now == s[i]){
            count++;
        }else{
            a.push_back(count);
            if(now == '<'){
                bl.push_back(false);
            }else{
                bl.push_back(true);
            }
            now = s[i];
            count = 1;
        }
    }
    a.push_back(count);
    if(now == '<'){
        bl.push_back(false);
    }else{
        bl.push_back(true);
    }

    ll fir = 0;
    ll n = a.size();
    ll ans = 0;
    bool flag;
    for(ll i=0;i<n;++i){
        if(bl[i] == true){
            ans += max(fir, a[i]);
            //cout<<max(fir, a[i])<<endl;
            for(ll j=a[i]-1;j>=1;--j){
                ans += j;
                //cout<<j<<endl;
            }
            fir = 0;
            flag = true;
        }if(bl[i] == false){
            for(ll j=1;j<=a[i];++j){
                //cout<<max(fir+j-1, (ll)0)<<endl;
                ans += max(fir + j - 1, (ll)0);
            }
            fir = fir + a[i];
            flag = false;
        }
    }
    if(flag == false){
        ans += fir;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6068
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<pll> p;
    for (int i = 0; i < n; ++i) {
        int pp;
        cin >> pp;
        p.emplace_back(pp, i);
    }
    sort(p.begin(), p.end(), greater<pll>());
    multiset<ll> nums;
    nums.insert(-1);
    nums.insert(-1);
    nums.insert(n);
    nums.insert(n);
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        auto it = nums.lower_bound(p[i].second);
        ret += p[i].first * (*next(it) - *it) * (p[i].second - *prev(it));
        ret += p[i].first * (*it - p[i].second) * (*prev(it) - *prev(it, 2));
        nums.insert(p[i].second);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 6512
#include<stdio.h>
int main(void){
 	int a=0;
  	int b=0;
  	int h=0;
  	int result=0;
  
  	scanf("%d",&a);
  	scanf("%d",&b);
  	scanf("%d",&h);
    result=(a+b)*h/2;
    printf("%d",result);
}


Measured memory_bytes: 128
def resolve():
	# N: 足場の個数, K: 1回で右にジャンプできる足場の数
	N, K = map(int, input().split())
	# h: 各足場の高さ
	h = list(map(int, input().split()))
	# dpテーブル宣言: dp[今いる足場の番号-1]=最小コスト
	dp = [float('inf')] * N
	dp[0] = 0
	dp[1] = abs(h[0] - h[1])

	# k個左の足場からジャンプして来た時の最小コストを調べる
	for n in range(2, N):
		height_current = h[n]
		dp[n] = min(
			[
				abs( height_current - h[i] ) + dp[i]
				for i in range(max(0, n-K), n)
			]
		)
	print(dp[N-1])

resolve()

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const ll INF = 4e18 + 9;
const int B = 1e9 + 7;

ll n, a, b;
ll s[N];
ll d[N][2];

ll t[N];

ll g(int l, int r) {
    ll ans = INF;
    for (l += n - 1, r += n - 1; l <= r; l >>= 1, r >>= 1) {
        if (l % 2 == 1) ans = min(ans, t[l++]);
        if (r % 2 == 0) ans = min(ans, t[r--]);
    }
    return ans;
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> a >> b;
    forn(i, 1, n)
        cin >> s[i];
    forn(i, 1, n)
        t[i + n - 1] = s[i + 1] - s[i];
    for1(i, n - 1, 1)
        t[i] = min(t[i * 2], t[i * 2 + 1]);

    d[0][0] = 1;
    s[0] = -INF;
    forn(i, 1, n) {
        if (s[i] - s[i - 1] >= a)
            d[i][0] = (d[i - 1][0] + d[i - 1][1]) % B;
        else {
            int l = 0, r = i - 2;
            while (l < r) {
                int m = (l + r + 1) / 2;
                if (s[i] - s[m] < a) r = m - 1;
                else l = m;
            }
            if (l == i - 2 || g(l + 1, i - 2) >= b) d[i][0] = d[l + 1][1];
            //int j = i - 2;
            //ll mn = INF;
            //for (; s[i] - s[j] < a; --j)
            //    mn = min(mn, s[j + 1] - s[j]);
            //if (mn >= b) d[i][0] = d[j + 1][1];
        }
        if (s[i] - s[i - 1] >= b)
            d[i][1] = (d[i - 1][0] + d[i - 1][1]) % B;
        else {
            int l = 0, r = i - 2;
            while (l < r) {
                int m = (l + r + 1) / 2;
                if (s[i] - s[m] < b) r = m - 1;
                else l = m;
            }
            if (l == i - 2 || g(l + 1, i - 2) >= a) d[i][1] = d[l + 1][0];
//            int j = i - 2;
//            ll mn = INF;
//            for (; s[i] - s[j] < b; --j)
//                mn = min(mn, s[j + 1] - s[j]);
//            if (mn >= a) d[i][1] = d[j + 1][0];
        }
        //cerr << i << ": " << d[i][0] << " " << d[i][1] << "\n";
    }
    cout << (d[n][0] + d[n][1]) % B << "\n";

    return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n,k;
	cin >> n >> k;

	vector<ll> to(n);
	rep(i,n){
		ll v; cin >> v;
		to[i] = --v;
	}

	if(k <= n + 5){
		ll res = 0;
		rep(i,k) res = to[res];
		cout << res + 1 << endl;
		return 0;
	}





	vector<bool> checked(n, false);
	ll now = 0;
	ll t = 0;
	// cycleの開始点を探す
	rep(i,n){
		checked[now] = true;
		if(checked[to[now]]) break;
		now = to[now];
		t++;
	}
	ll cycleini = now;
	

	// cycleの長さを求める
	ll cyclelen = 0;
	now = cycleini;
	while(true){
		now = to[now];
		cyclelen++;
		if(now == cycleini) break;
	}

	
	k -= t;
	k %= cyclelen;

	ll res = cycleini;
	rep(i,k) res = to[res];

	cout << res + 1 << endl;
	
	return 0;
}

int main(){

	return mainsolve();
}


Measured memory_bytes: 4840
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(len(a)):
    count = 0
    while a[i]%2 == 0:
        a[i] = a[i]/2
        count += 1
    if a[i]%2 == 1:
        ans.append(count)
print(min(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <stdio.h>
using namespace std;
typedef long long ll;

double val=0;
double lastqiwang=0;
double maxans=0;
double func_qiwang(int n){
    double nn=n;
    nn=(1+nn)/2;
    return nn;
}
double qiwang[2000005];
int N,K;
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cin>>N>>K;
    for (int i=0;i<N;i++) {
        int a;
        cin>>a;
        qiwang[i]=func_qiwang(a);
    }
    for(int i=0;i<K;i++){
        val+=qiwang[i];
    }
    maxans=val;
    for(int i=K;i<N;i++){
        val-=qiwang[i-K];
        val+=qiwang[i];
        maxans=maxans<val?val:maxans;
    }
    printf("%.7lf\n",maxans);


}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    sc.close(); 

    int max = A + B;

    max = Math.max(max,A-B);

    max = Math.max(max, A * B);

    System.out.println(max);
  
  }

}

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

const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};

int main(){
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> dist(h, vector<int>(w, -1));
    deque<pair<int, int>> que;
    dist[ch][cw] = 0;
    que.push_front(pair<int, int>(ch, cw));
    while(!que.empty()){
        auto v = que.front();
        que.pop_front();
        int y = v.first, x = v.second; 
        for(int dir = 0; dir < 4; dir++){
            int ny = y + dy[dir], nx = x + dx[dir];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s[ny][nx] == '#') continue;
            if(dist[ny][nx] == -1){
                dist[ny][nx] = dist[y][x];
                que.push_front(pair<int, int>(ny, nx));
            }
            else if(dist[ny][nx] > dist[y][x]) {
                dist[ny][nx] = dist[y][x];
                que.push_front(pair<int, int>(ny, nx));
            }
        }
        for(int ny = y-2; ny <= y+2; ny++){
            for(int nx = x-2; nx <= x+2; nx++){
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(s[ny][nx] == '#') continue;
                if(dist[ny][nx] == -1){
                    dist[ny][nx] = dist[y][x] + 1;
                    que.push_back(pair<int, int>(ny, nx));
                }
                else if(dist[ny][nx] > dist[y][x]+1) {
                    dist[ny][nx] = dist[y][x]+1;
                    que.push_front(pair<int, int>(ny, nx));
                }
            }
        }
    }
    cout << dist[dh][dw] << endl;
    return 0; 
}

Measured memory_bytes: 9568
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<ll> H(N);
    ll pre = -INF_I;
    rep(i, N) cin >> H[i];
    //
    //--H[0];
    rep(i, N-1)
    {
        if (H[i] < H[i + 1])
        {
            --H[i+1];
        }
    }
    bool okay = true;
    rep(i, N - 1)
    {
        if (H[i] > H[i + 1])
        {
            okay = false;
        }
    }
    yes(okay);
    //
    return 0;
}

Measured memory_bytes: 3960
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	char c;
	rd(c);
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')wrln("vowel");
	else wrln("consonant");

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll n, t, a, ans = 100000;
	float temp;
	float ans_temp = 100000;
	cin >> n >> t >> a;
	ll h;
	repz(i, n) {
		cin >> h;
		temp = t - h * 0.006;
		//cout << "ans_temp = " << ans_temp << ", temp = " << temp << endl;
		if (abs(a - temp) < abs(a - ans_temp)) {
			//cout << "入れ替え ans_temp = " << ans_temp << " , temp = " << temp << endl;
			ans_temp = temp;
			ans = i + 1;
		}
	}

		cout << ans << endl;
		system("pause");
		return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      string s,ss,sss;
      cin>>s>>ss>>sss;
      transform(s.begin(),s.end(),s.begin(),::toupper);
      transform(ss.begin(),ss.end(),ss.begin(),::toupper);
      transform(sss.begin(),sss.end(),sss.begin(),::toupper);
      cout<<s[0]<<ss[0]<<sss[0]<<"\n";
     

       
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+ 5;
ll arr[maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n, k; cin >> n >> k;
    double sum = 0, maxi = 0;
    for (int i = 0; i < n; ++i) cin >> arr[i];
    for (int i = 0; i < k; ++i) {
        sum += arr[i] * (arr[i] + 1) / (double)(2 * arr[i]);
    }
    maxi = sum;
    for (int i = k; i < n; ++i) {
        sum -= arr[i - k] * (arr[i - k] + 1) / (double)(2 * arr[i - k]);
        sum += arr[i] * (arr[i] + 1) / (double)(2 * arr[i]);
        maxi = max(maxi, sum);
    }
    cout << fixed << setprecision(10) << maxi << '\n';
    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

X, Y = mi()

l = [0, 300000, 200000, 100000]

for i in range(205):
    l.append(0)
    
ans = l[X] + l[Y]
if X==Y==1:
    print(ans + 400000)
else:
    print(ans)

Measured memory_bytes: 3064
n = int(input())
s = str(input())

number_i = list(range(10))
ans = 0

for i in range(n-2):
    if int(s[i]) in number_i:
        number_i.remove(int(s[i]))
        number_j = list(range(10))
        #print(number_i)

        for j in range(i+1,n-1):
            if int(s[j]) in number_j:
                number_j.remove(int(s[j]))
                number_k = list(range(10))

                for k in range(j+1,n):
                    if int(s[k]) in number_k:
                        number_k.remove(int(s[k]))
                        ans += 1
                        #print(int(s[i])*100+int(s[j])*10+int(s[k]))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
int t;
int a[mx];
int b[mx];
int n,m;
int main(){
	string s;
	cin>>t;
	cin>>s;
	if(t<3200){
		cout<<"red"<<endl;
	} else{
		cout<<s<<endl;
	}

	return 0;
}




Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

bool hantei(char s){
    if (s == 'A' || s == 'T' || s == 'G' || s == 'C') return true;
    else return false;
}

int main(){
    string str;
    cin >> str;
    int ans = 0;
    int x = 0;
    REP(i, str.size()){
        if (hantei(str[i])){
            x++;
            if (i == str.size() - 1) ans = max(ans, x);
        }else {
            ans = max(ans, x);
            x = 0;
        }
    }
    if (x == str.size()) ans = x;
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  for(int i=0;i<N-1;i++){
    sum+=p[i];
  }
  sum+=p[N-1]/2;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    if((b-a)==(c-b))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def func(N, mod):
    F = [1]
    for i in range(1, N + 1):
        F.append(F[-1] * i % mod)
    return F


def inv(a, mod):
    return pow(a, mod - 2, mod)


def C(F, a, b, mod):
    return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod


def main():
    mod = 10 ** 9 + 7
    N, K = read_values()
    A = sorted(read_list())
    F = func(N, mod)
    res = 0
    t = N - 1
    c = C(F, N - 1, K - 1, mod)
    for i in range(N - K + 1):
        res += (A[- i - 1] - A[i]) * c % mod
        res %= mod
        c *= (t - K + 1) * inv(t, mod)
        c %= mod
        t -= 1

    print(res)

if __name__ == "__main__":
    main()



Measured memory_bytes: 14168
#include<cstdio>
using namespace std;
int main(){
	double matrix[4],ans[2];
	while(scanf("%lf %lf %lf %lf %lf %lf",&matrix[0],&matrix[1],&ans[0],&matrix[2],&matrix[3],&ans[1]) != EOF){
		double t = matrix[0]*matrix[3]-matrix[1]*matrix[2];
		printf("%.3lf %.3lf\n",matrix[3]*ans[0]/t-matrix[1]*ans[1]/t,matrix[0]*ans[1]/t-matrix[2]*ans[0]/t);
	}
	return 0;
}

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

using namespace std;

const int INF = 1e9;

int min_mp(vector<int>& A, vector<int>& B, int H){
  int N = A.size();
  vector<int> mp(H + 1, INF);
  
  mp[0] = 0;
  for(int cur = 0; cur < H; cur++){
    for(int i = 0; i < N; i++){
      int next = min(cur + A[i], H);
      mp[next] = min(mp[cur] + B[i], mp[next]);
    }
  }
  
  return mp[H];
}

int main(){
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  
  cout << min_mp(A, B, H) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007,m;
ll dist(pair<ll,ll> a,pair<ll,ll> b)
{
    ll res;
    res=(a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
    return res;
}
int main(){

   ll n,m,mm;
   cin>>m>>n;
   ll sum=0;
   for(ll i=0;i<n;i++)
   {
       cin>>mm;
       sum+=mm;
   }
   if(sum>=m)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll x;
    cin>>x;
    ll k=0,ans=0;
    rep(0,i,(ll)1e7){
        k+=x;
        if(k%360==0){
            ans=i+1;
            cout<<ans;
            return 0;
        }
    }
}

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

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

  string ans = "No";
  if (N[0] == N[1] && N[1] == N[2]) {
    ans = "Yes";
  }
  if (N[1] == N[2] && N[2] == N[3]) {
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
  	int a, b, c;
  	cin >> a >> b >> c;
  	if (a != b && b != c && c != a) cout << 3;
  	else if ((a == b && b != c) || (a == c && b != c) || (b == c && c != a)) cout << 2;
  	else cout << 1;
 	return 0; 
}

Measured memory_bytes: 256
n = int(input())
def f(n):
    cal_result = {}

    # 初期値の設定
    cal_result[0] = 0
    cal_result[1] = 0
    cal_result[2] = 0
    cal_result[3] = 1
    cal_result[4] = 1
    cal_result[5] = 1

    if n<3:
        return 0
    elif n<6:
        return 1
    elif n==6:
        return 2

    else:
        for i in range(7,n+1):


            # 初期値の設定
            cal_result[0] = 0
            cal_result[1] = 0
            cal_result[2] = 0
            cal_result[3] = 1
            cal_result[4] = 1
            cal_result[5] = 1
            cal_result[6] = 2
            list1 = list(cal_result.values())
            list2 = list1[3:i-2]
            cal_result[i] = sum(list2) + 1

        return cal_result[n]


print(f(n)% (10**9+7))



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k, ans =0;
	
	cin >>n >>k;
	string s;
	while(n >0){
		s += to_string(n%k);
		n /= k;
	}
	cout <<sz(s) <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N 500


int N;
vector<int> edges[MAX_N];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	double log2 = log(2);
	double logN = log(N);

	int maxlevel = (int)ceil(logN/log2);
	
	FOR(i,N) {
		edges[i].resize(N);
	// 	FOR(j,N) {
	// 		edges[i][j] = -1;
	// 	}
	}

	FOR(i,N) {
		FOR(j,N) {
			if(i==j) {
				continue;
			}
			if(edges[i][j]>0) {
				continue;
			}
			int exor = i^j;
			for(int level = 0; level<maxlevel; level++) {
				if ((0x01<<level) & exor) {
					edges[i][j] = level+1;
					edges[j][i] = level+1;
					break;
				}
			}
		}
	}

	FOR(i,N) {
		for(int j=i+1; j<N; j++) {
			cout << edges[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}




Measured memory_bytes: 1536
#include<bits/stdc++.h>
typedef long long ll;
int x,n,y;
int ans[2010];
int dis(int a,int b)
{
	return std::max(a,b)-std::min(a,b);
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans[ std::min(dis(i,j),1+std::min(dis(i,x)+dis(y,j),dis(i,y)+dis(x,j))) ]++;
		}
	}
	for(int i=1;i<n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const ll mod = 1e9+7;
const int inf = 1e18;
const int maxn = 1e6+5;
ll dp[maxn];//n  la_num;
int vis[maxn];
int main(){
	ll n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	memset(vis,1,sizeof(vis));
	for(int i=3;i<=n;i++){
		dp[i]=1;
	}
	for(int i=3;i<=n;i++){
		for(int j=3;j+i<=n;j++){
			dp[i+j]=(dp[i+j]+dp[i])%mod;
		}
	}
	cout<<dp[n]<<endl;
	return 0 ;
}



Measured memory_bytes: 14840
#include <iostream>
#include <vector>
#include <string>
using namespace std;

typedef struct{
  int width;
  int height;
}CAKE;

int main() {
  int n,w,d;
  while( cin >> n >> w >> d, n || w || d ) {
    vector<CAKE> cake;
    int p,s;
    CAKE tmp = {w,d};
    cake.push_back(tmp);
    while( n-- ) {
      cin >> p >> s;
      p--;
      int cnt = 0;
      pair< CAKE,CAKE > P;
      while(true) {
	if ( s - cake[p].width <= 0 ) break;
	s -= cake[p].width;
	cnt++;

	if ( s- cake[p].height <= 0 ) break;
	s -= cake[p].height;
	cnt++;

      }

      cnt %= 4;

      if ( cnt % 2 == 0 ) {
	CAKE tmp = {s,cake[p].height};
	P.first = tmp;
	tmp.width = cake[p].width - s;
	P.second = tmp;
      } else {
	CAKE tmp = {cake[p].width,s};
	P.first = tmp;
	tmp.height = cake[p].height - s;
	P.second = tmp;
      }

      if ( P.first.width * P.first.height < P.second.width * P.second.height ) {
	cake.push_back( P.first );
	cake.push_back( P.second );
	cake.erase( cake.begin()+p );
      } else {
	cake.push_back( P.second );
	cake.push_back( P.first );
	cake.erase( cake.begin()+p );
      }
    
    }
      for ( int i = 0; i < cake.size(); i++ ) {
	for ( int j = 0; j < cake.size()-1; j++ ) {
	  if ( cake[j].height * cake[j].width > cake[j+1].height * cake[j+1].width ) swap( cake[j],cake[j+1] );
	}
      }

      for ( int i = 0; i < cake.size()-1; i++ ) {
	cout << cake[i].height * cake[i].width << " ";
      }
      cout << cake[cake.size()-1].height * cake[cake.size()-1].width << endl;

    
  }
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,j,l,n,k;
  cin >> n >> k;
  if((n-1)*(n-2)/2<k){
    cout << -1 << endl;
    return 0;
  }
  int x[110][110];
  for(i=0;i<n;i++){
    for(j-0;j<n;j++){
      x[i][j]=0;
    }
  }
  for(i=1;i<n;i++){
    x[0][i]=1;
  }
  k=(n-1)*(n-2)/2-k;
  cout << k+n-1 << endl;
  for(i=0;i<k;i++){
    int res=0;
    for(j=0;j<n;j++){
      for(l=j+1;l<n;l++){
        if(x[j][l]==0){
          x[j][l]=1,res=1;
          break;
        }
      }
      if(res==1){
        break;
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(x[i][j]==1){
        cout << i+1 << ' ' << j+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 3628
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int head[10011],nxt[100011],to[100011],cap[100011],tot=1;
void addedge(int x,int y,int c)
{
//	cout<<"addedge:"<<x<<"-"<<y<<" "<<c<<endl;
	nxt[++tot]=head[x];
	head[x]=tot;
	to[tot]=y;
	cap[tot]=c;
	nxt[++tot]=head[y];
	head[y]=tot;
	to[tot]=x;
	cap[tot]=c;
}
int dis[10011];
int q[10011],qn;
void bfs(int S)
{
	memset(dis,-1,sizeof(dis));
	qn=0;
	q[qn++]=S;
	dis[S]=0;
	for(int i=0;i<qn;i++)
	{
		int u=q[i];
		for(int j=head[u];j;j=nxt[j])
		{
			if(cap[j]&&dis[to[j]]==-1)
			{
				dis[to[j]]=dis[u]+1;
				q[qn++]=to[j];
			}
		}
	}
}
int it[10011];
int dfs(int x,int T,int f)
{
	if(x==T)return f;
	for(int &i=it[x];i;i=nxt[i])
	{
		if(dis[to[i]]==dis[x]+1&&cap[i])
		{
			int d=dfs(to[i],T,min(f,cap[i]));
			if(d)
			{
				cap[i]-=d;
				cap[i^1]+=d;
				return d;
			}
		}
	}
	return 0;
}
int maxflow(int S,int T)
{
	int ans=0;
	while(true)
	{
		bfs(S);
		if(dis[T]==-1)return ans;
		for(int i=0;i<10011;i++)it[i]=head[i];
		int f;
		while(f=dfs(S,T,mod))ans+=f;
	}
}
int n,m;
int Sx,Sy,Tx,Ty;
char s[111][111];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='S')
			{
				Sx=i;Sy=j;
			}
			else if(s[i][j]=='T')
			{
				Tx=i;Ty=j;
			}
		}
	}
	if(Sx==Tx||Sy==Ty)
	{
		puts("-1");
		return 0;
	}
	s[Sx][Sy]=s[Tx][Ty]='o';
	int S=n+m+1,T=n+m+2;
	addedge(S,Sx,233333);
	addedge(S,n+Sy,233333);
	addedge(Tx,T,233333);
	addedge(n+Ty,T,233333);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='o')
			{
				addedge(i,n+j,1);
//				addedge(n+j,i,1);
			}
		}
	}
	cout<<maxflow(S,T)<<endl;
	return 0;
}

Measured memory_bytes: 640
import math
a,b,x = map(int,input().split())
if x > (a**2)*b/2:
  atan1 = math.degrees(math.atan(2*((a**2)*b-x)/a**3))
  print(atan1)

else:
  atan1 = math.degrees(math.atan(a*(b**2)/(2*x)))
  print(atan1)


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

int getSum(int N);

int main(void) {

    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;

    for(int i = 1; i <= n; i++){
        int tmp = getSum(i);
        if(tmp<=b && tmp >= a){
            ans += i;
        }
    }

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

int getSum(int N){
    int ans = 0;
    int n = N;
    for(int i = 1; i < 6; i++){
        ans += n%10;
        n = n/10;
    }
    return ans;
}

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

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

  int cnt  = 0;
  bool res = true;
  while (true) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 1 || a[i] == 0) {
        res = false;
        break;
      } else {
        a[i] /= 2;
      }
    }
    if (!res) break;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>

typedef unsigned long long ull;

const int MAXN = 2 * 1e5;

int main() {
    int n;
    std::scanf("%d", &n);
    static int arr[MAXN + 5];
    for (int i = 1; i <= n; i++) {
        std::scanf("%d", &arr[i]);
    }

    ull cnt = 0;
    for (int i = 2; i <= n; i++) {
        if (arr[i] < arr[i - 1]) {
            cnt += arr[i - 1] - arr[i];
            arr[i] = arr[i - 1];
        }
    }

    std::printf("%llu\n", cnt);

    return 0;
}


Measured memory_bytes: 4004