akhauriyash/Code-Regression huggingface dataset:
from sys import stdin


def EuclideanAlgorithm(a, b):
    if (a < b):
        a, b = b, a

    if b > 0:
        return EuclideanAlgorithm(b, a % b)
    else:
        return a


N, X = [int(a) for a in stdin.readline().rstrip().split()]
x = [int(a) for a in stdin.readline().rstrip().split()]

if len(x) == 1:
    print(abs(X - x[0]))
else:
    for i in range(len(x)):
        x[i] = abs(X - x[i])

    ans = EuclideanAlgorithm(x[0], x[1])
    for i in range(2, len(x)):
        ans = EuclideanAlgorithm(ans, x[i])

    print(ans)


Measured memory_bytes: 14480
# -*- coding: utf-8 -*-
N = int(input())
c = str(input())

w_pos = 0
r_pos = N - 1
w_flag = False
r_flag = False
ans = 0
for i in range(N):
    if w_pos >= r_pos:
        break
    if c[w_pos] == "W":
        w_flag = True
    else:
        w_flag = False
        w_pos += 1
    if c[r_pos] == "R":
        r_flag = True
    else:
        r_flag = False
        r_pos -= 1
    if w_flag and r_flag:
        ans += 1
        w_pos += 1
        r_pos -= 1

print(ans)

Measured memory_bytes: 9496
import java.util.*;

public class Main {
	// from: "プログラミングコンテストチャレンジブック[第2版]"(http://amzn.asia/3MkgFHb) p155
	// Random minimum Query implementation by segment tree.
	/*
	 * メモ
	 * 親ノードへのアクセス (n-1)/2
	 * 子ノードへのアクセス 2*n+1, 2*n+2
	 * もとの配列のインデックスiからセグメント木へのインデックスn+i-1
	 */ 
	static long INITIAL_VALUE = (1<<31)-1;
	static int n; // number of elements
	static int MAX_N = 100000*10-1;
	static long[] dat = new long[MAX_N];
	
	static void init() {
		Arrays.fill(dat, INITIAL_VALUE);
	}
	
	// int[]aで初期化したいとき
	static void init(int[] a) {
		assert a.length == n;
		init();
		for(int i=0; i<n; i++) {
			update(i, a[i]);
		}
	}
	
	// k番目の値をaに変更
	static void update(int k, int a) {
		k += n-1;
		dat[k] = a;
		while(k>0) {
			k = (k-1)/2;
			dat[k] = Math.min(dat[k*2+1], dat[k*2+2]);
		}
	}
	
	// minimum query [s, t)
	static long find(int s, int t) {
		return find(s, t, 0, 0, n);
	}
	
	// kは注目している節点の番号、l, rはその接点が[l, r)に対応づいていることを表す
	static long find(int a, int b, int k, int l, int r) {
		// [a, b) と[l, r)が交差しないとき
		if(r<=a || b <= l) return INITIAL_VALUE;
		if(a<=l && r <= b) return dat[k];
		else {
			long vl = find(a, b, k*2+1, l, (l+r)/2);
			long vr = find(a, b, k*2+2, (l+r)/2, r);
			return Math.min(vl, vr);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int tmpn = sc.nextInt(); int q  = sc.nextInt();
		ArrayList<Long> ans = new ArrayList<>();
		n=1;
		while(n<tmpn) {
			n *= 2;
		}
		init();
		for(int i=0; i<q; i++) {
			int com = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(com==0) {
				update(x, y);
			} else {
				ans.add(find(x, y+1, 0, 0, n));
			}
		}
		for(int i=0; i<ans.size(); i++) System.out.println(ans.get(i));
	}
	
}



Measured memory_bytes: 116208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  int k = 0;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N,-1);
  for(int a = 0;a < N;a++)cin >> A[a];
  
  for(int a = N;a >= 1;a--){
    k = 0;
   for(int b = a * (N / a);b >= 1;b -= a){
    if(b <= a){
     B[a-1] = (k - A[a-1] + 1000000000) % 2; 
    }else{
     k += B[b-1]; 
    }
   }
  }
  k = 0;
for(int a = 0;a < N;a++){
  if(B[a] == 1)k++;
}
  cout << k << endl;
  for(int a = 0;a < N;a++){
    if(B[a] == 1)cout << a+1 << " ";
    
  }
}

Measured memory_bytes: 4744
/*
created by 1010101010101010101
*/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
  	cout << (b - a) / 2 << '\n';
  	return 0;
	}
	long long mn = min(n - b, a - 1);
	++mn;
	--b;
	cout << mn + (b - a) / 2 << '\n';
  return 0;
}




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

//#define scanf scanf_s
#define LL long long
#define maxn 5010

LL p[maxn], c[maxn], t[maxn], d[maxn], mid[maxn];

int main() {
	int n, k, i, now, cnt;
	LL mx = -1000000000, val;
	scanf("%d%d", &n, &k);
	for (i = 1; i <= n; i++)
		scanf("%lld", &p[i]);
	for (i = 1; i <= n; i++)
		scanf("%lld", &c[i]);
	for (i = 1; i <= n; i++) {
		now = p[i];
		d[i] = c[now];
		t[i] = 1;
		mid[i] = -1000000000;
		mid[i] = max(d[i], mid[i]);
		while (1) {
			if (now == i)break;
			t[i]++;
			now = p[now];
			d[i] += c[now];
			mid[i] = max(d[i], mid[i]);
		}
	}
	for (i = 1; i <= n; i++) {
		if (k / t[i] > 0) {
			mx = max(mx, mid[i]);
			if (k % t[i] == 0) {
				mx = max(mx, (k / t[i] - 1) * d[i] + mid[i]);
				continue; 
			}
		}
		val = k / t[i] * d[i];
		now = p[i];
		val += c[now];
		mx = max(mx, val);
		cnt = 1;
		while (1) {
			if (k % t[i] == cnt)break;
			cnt++;
			now = p[now]; val += c[now];
			mx = max(mx, val);
		}
	}
	printf("%lld\n", mx);
	return 0;
}

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

using namespace std;

int main () {
    int n = 0, m = 0;
    cin >> n >> m;
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    for (int i=0; i<m; i++) {
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    vector<int> delta(m-1);
    for (int i=0; i<m-1; i++) {
        delta.at(i) = x.at(i+1) - x.at(i);
    }
    sort(delta.begin(), delta.end());
    reverse(delta.begin(), delta.end());
    long long l_sum = 0;
    for (int i=0; i<n-1; i++) {
        l_sum += delta.at(i);
    }
    cout << x.at(m-1) - x.at(0) - l_sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())

phi = 0 if N & 1 else 1
print(N * (N - 1) // 2 - N // 2)
for i in range(N):
    for j in range(i+1, N):
        k, l = i+1, j+1
        if l != N - k + phi:
            print(k, l)


Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			var n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
//writeMap(Map));		
		Queue<int>[] Q=new Queue<int>[2];
		Q[0]=new Queue<int>();
		Q[1]=new Queue<int>();
		HashSet<int> H=new HashSet<int>();
		
		int cnt=0;
		Q[0].Enqueue(Map);
		
		while(Q[cnt%2].Count>0){
//if(cnt==2)return;
			while(Q[cnt%2].Count>0){
//Console.WriteLine("cnt={0},Q[{0}].Count={1}",cnt,Q[cnt%2].Count);
				int m=Q[cnt%2].Dequeue();
//writeMap(m);
//Console.WriteLine("masks are:");
				if(m==0){
					String S="";
					for(int i=0;i<cnt;i++)S+="myon";
					Console.WriteLine(S);
					return;
				}
				
				int x=m&-m;
				int idx=bitCnt(x-1);
				int cMax=idx;
				for(;cMax<(idx/N+1)*N;cMax++){
					//if(((m>>cMax)&0x1)==0)break;
				}
				cMax=cMax-idx;
				
				int rMax=idx;
				for(;rMax<N*N;rMax+=N){
					//if(((m>>rMax)&0x1)==0)break;
				}
				rMax=(rMax-idx)/N;
//Console.WriteLine("x={2},idx={3},cMax={0},rMax={1}",cMax,rMax,x,idx);
//bool chk=true;if(chk)return;
				for(int i=0;i<=rMax;i++){
					for(int j=0;j<=cMax;j++){
						int mask=0;
						for(int ii=0;ii<i;ii++){
							for(int jj=0;jj<j;jj++){
								mask=mask|x<<(ii*N+jj);
							}
						}
						if(mask==0)continue;
//writeMap(mask);
						if(!H.Contains(m^mask)){
							Q[(cnt+1)%2].Enqueue(m^mask);
							H.Add(m^mask);
//writeMap(m);
//writeMap(m^mask);
						}
					}
				}
			}
			cnt++;
		}
		
		
	}
	
	static int bitCnt(int x){
		x=(x&0x55555555)+((x>>1)&0x55555555);
		x=(x&0x33333333)+((x>>2)&0x33333333);
		x=(x&0x0F0F0F0F)+((x>>4)&0x0F0F0F0F);
		x=(x&0x00FF00FF)+((x>>8)&0x00FF00FF);
		x=(x&0x0000FFFF)+((x>>16)&0x0000FFFF);
		return x;
	}
	
	void writeMap(int x){
		List<char> L=new List<char>();
 		while(true){
			L.Add((char)('0'+(x&0x1)));
			x=x>>1;
			if(x==0)break;
		}
		
		char[] C=new char[N*N];
		for(int i=0;i<N*N;i++)C[i]='0';
		for(int i=0;i<L.Count;i++){
			C[N*N-1-i]=L[i];
		}
		String s=new String(C);
		for(int i=0;i<N;i++){
			Console.WriteLine(s.Substring(i*N,N));
		} 
		
		Console.WriteLine("");
	}

	int N;
	int Map;
	public Sol(int n_){
		N=n_;
		Map=0;
		for(int i=0;i<N;i++){
			var d=ria();
			for(int j=0;j<N;j++){
				//左上が最下位bit
				Map=Map|(d[j]<<i*N+j);
				//Console.WriteLine(Map);
			}
		}
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

int main(){
    double n, m;
    cin >> n >> m;
    double sum=0;
    int ans=0;
    vector<double> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i=0; i<n; i++){
        sum+=a[i];
    }
    for(int i=0; i<m; i++){
        double b=a[i]/sum;
        double c=1/(4*m);
    //    cout << b << " " << c << endl;
        if(b<c){cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/


vector<array<ll,2>> weight;
int N,M,s,t;
priority_queue<array<ll,2>> q;
map <ll,vector<array<int,3>>> lines;

int search(int n, ll w_0, int Pass){
  int t;
  ll w;
  for (size_t i = 0; i < lines[n].size(); i++) {
    t = lines[n][i][0];
    w = w_0 + lines[n][i][Pass];
    if (weight[t][Pass-1]==-1 || weight[t][Pass-1] > w) {
      q.push({-w,t});
      weight[t][Pass-1] = w;
    }
  }
  return 0;
}

int min(ll a,ll b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}


int main(void) {
  cin >> N >> M >> s >> t;
  s--,t--;
  weight.resize(N);
  for (int i = 0; i < N; i++){weight[i]={-1,-1};}

/* 辺の情報のinput(linse)*/
  int a,b,c_y,c_s;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c_y >> c_s;
    a--,b--;
    lines[a].push_back({b,c_y,c_s});
    lines[b].push_back({a,c_y,c_s});
  }

/* 実行部分(queueを回す)*/
  array<ll,2> queue;
  ll wq; int nq;

/* 円コスト(1)*/
  q.push({0,s});  /*スタート地点*/
  weight[s][0] = 0;
  while (!q.empty()) {
      queue = q.top();
      wq = -queue[0], nq = queue[1];
      search(nq,wq,1);
      q.pop();
  }

/* すぬーくコスト(2)*/
  q.push({0,t});  /*スタート地点*/
  weight[t][1] = 0;
  while (!q.empty()) {
      queue = q.top();
      wq = -queue[0], nq = queue[1];
      search(nq,wq,2);
      q.pop();
  }

  ll ans,nowans;
  vector<ll> ans_ar;
  for (int i = N-1; i >= 0; i--) {
    nowans = weight[i][0] + weight[i][1];
    if(i==N-1){
      ans = nowans;
    }else{
      if(ans>nowans){ans = nowans;}
    }
    ans_ar.push_back(ans);
  }

  ll tmp = 1e15;
  for (int i = N-1; i >= 0; i--) {
    cout << tmp - ans_ar[i] << endl;
  }


  return 0;
}


Measured memory_bytes: 16628
#include <stdio.h>
#include <string.h>
//https://www.khanacademy.org/computing/computer-science/algorithms
//http://www.toi2015.sat.psu.ac.th/files/news/?¢???????¢????????????????-TOI11.pdf

int main(){
	int a;
	scanf("%d",&a);
	printf("%d:",a/3600);
	printf("%d:",(a%3600-a%60)/60);
	printf("%d\n",a%60);
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
char c[MC];

int main(){
	cin >> N;
	int x = 1 , y = N;
	string s;
	cout << 0 << endl;
	cin >> s;
	c[0] = c[N] = s[0];
	while(s[0] != 'V'){
		int z = (x+y)/2;
		cout << z << endl;
		cin >> s;
		c[z] = s[0];
		if((c[x-1] == c[z] && (z-x)%2==0) || (c[x-1] != c[z] && (z-x)%2==1)){
			y = z;
		} else {
			x = z+1;
		}
	}
	return 0;
}


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

int main() {
string s1, s2, s3;
  cin >>s1>>s2>>s3;
  char c1, c2, c3;
  c1 = s1.at(0);
  c2 = s2.at(0);
  c3 = s3.at(0);
  char dif = 'A'-'a';
  cout << (char)(c1+dif) << (char)(c2+dif) << (char)(c3+dif) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int n;
    double total=0;

    cin>>n;

    vector<double> a(n+1);
    FOR(i,1,n){
        cin>>a[i];
        total+=1/a[i];
    }
    printf("%.10lf",1/total);
}


Measured memory_bytes: 256
#include <stdio.h>          // putchar(), fgets()
#include <stdlib.h>         // strtol()

const char NUL = '\0';
const char *code[91] = 
{
	[' '] = "101", ['\''] = "000000", [','] = "000011", ['-'] = "10010001", ['.'] = "010001", ['?'] = "000001", ['A'] = "100101", ['B'] = "10011010",
	['C'] = "0101", ['D'] = "0001", ['E'] = "110", ['F'] = "01001", ['G'] = "10011011", ['H'] = "010000", ['I'] = "0111", ['J'] = "10011000",
	['K'] = "0110", ['L'] = "00100", ['M'] = "10011001", ['N'] = "10011110", ['O'] = "00101", ['P'] = "111", ['Q'] = "10011111", ['R'] = "1000",
	['S'] = "00110", ['T'] = "00111", ['U'] = "10011100", ['V'] = "10011101", ['W'] = "000010", ['X'] = "10010010", ['Y'] = "10010011", ['Z'] = "10010000"
};

const char chara[32] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?";

int
main(int argc, char **argv)
{
	char line[101];
	char trans[801];  /* 8 * 100 + 1 */
	char bina[906]; /* 800 + 159 + 1 */
	const char *s, *t;
	char *u;
	char *nextp = NULL;
	int i;

	while (fgets(line, sizeof(line), stdin) != NULL)
	{
		int ix = 0;
		s = line;
		for (; *s != '\n' && *s != NUL; ++s)
		{
			for (t = code[(int)*s]; *t != NUL; ++t)
				trans[ix++] = *t;

		}

		trans[ix] = NUL;
		s = trans;
		u = bina;
		while (*s != NUL)
		{
			if (s != trans)
				*u++ = ' ';

			for (i = 0; i < 5; ++i)
			{
				if (*s == NUL)
					*u++ = '0';
				else
					*u++ = *s++;
			}
		}

		*u = NUL;		
		s = bina;
		while (*s != NUL)
		{
			putchar(chara[strtol(s, &nextp, 2)]);
			s = nextp;
		}

		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
 
int main()
{
	//input
	string s;
	cin >> s;
	string outp;
	//processing
	string weather[3] = { "Sunny","Cloudy","Rainy" };
	int index;
	for (int i = 0; i < 3; i++) {
		if (s == weather[i]) {
			index = i;
			break;
		}
	}
	index = index + 1;
	if (index == 3) {
		index = 0;
	}
	outp = weather[index];


	//output
	cout << outp << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", a%b == 0 ? 0LL : 1LL);
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll md = 1e9+7;
const int mx = 1e5+3;
vector<int> adj[mx];
ll black[mx];
ll white[mx];


void dfs(int v, int p)
{
	ll b = 1, w = 1;
	for (int a : adj[v])
	{
		if (a != p)
		{
			dfs(a, v);
			b = (b * white[a]) % md;
			w = (w * ((black[a] + white[a])%md)) % md;
		}
	}
	black[v] = b;
	white[v] = w;
}

int main()
{
	int n;
	cin >> n;
	for (int q = 0; q < n-1; q++)
	{
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1, 0);
	cout << (black[1] + white[1]) % md << "\n";
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
  int main() {
  int a;
  int b;
  
  cin >> a;
  cin >> b;
  
  if (a*500 >= b) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  
  return 0;
}

Measured memory_bytes: 3512
def main():
    _ = int(input())
    a = [int(s) for s in input().split()]
    print(*solve(a))

def solve(a):
    s = set()
    t = 0
    f = 0

    for x in a:
        y = x // 400
        if x >= 3200:
            t += 1
            f = 1
        else:
            s.add(y)
    
    mi = max(len(s), f)
    ma = len(s) + t
    return mi, ma

main()


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

int main(){
    long long  h;
    cin >> h;
    if(h==1){
        cout <<1 <<endl;
        return 0;
    }
    long long ex = 0;
    while(h>1){
        h/=2;
        ex++;
    }
    long long ans =1;
    for(long long i = 0;i<ex;++i){
        ans*=2;
    }
    cout << ans*2-1 <<endl;
}

Measured memory_bytes: 256
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let () =
  let n = scan_int() in
  let d = scan_array n scan_int in
  let ans = ref 0 in
  let _ =
    for i = 0 to n-2 do
      for j = i+1 to n-1 do
        ans := !ans + d.(i) * d.(j)
      done
    done in
  print_int !ans


Measured memory_bytes: 2432
#include<stdio.h>

int hantei2(int i, int a[], int n, int m) {
	int i1, i2;
	if (m == 0)
	{
		return 1;
	}
	else if (m < 0 || i >= n)
	{
		return 0;
	}
	
	
	i1 = hantei2(i + 1, a, n, m - a[i]);
	i2 = hantei2(i + 1, a, n, m);

	if (i1 == 1 || i2 == 1) return 1;
}


int hantei(int a[], int n, int m) {
	int i = 0;
	return hantei2(i, a, n, m);
}

int main(void) {
	int a[20], n, m, q, i, h;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &m);
		h = hantei(a, n, m);
		if (h == 1)
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
	
	return 0;
}

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

int n;
int arr[100001];
int dp[100001];
int solve(int cur){
    if(dp[cur] != -1) return dp[cur];
    if(cur == 1) return dp[cur] = 0;
    int p1 = 1e9;
    if(cur - 1 >= 0)
        p1 = abs(arr[cur] - arr[cur-1]) + solve(cur-1);
    int p2 = 1e9;
    if(cur - 2 >= 0)
        p2 = abs(arr[cur] - arr[cur-2]) + solve(cur-2);
    return dp[cur] = min(p1, p2);
}
int main(){
    memset(dp, -1, sizeof dp);
    cin>>n;
    for(int x=1;x<=n;x++)
        cin>>arr[x];


    cout<<solve(n);

}


Measured memory_bytes: 9036
using System;
using System.Linq;

public class ITP1_10_C{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split().Select(double.Parse);
        var y = Console.ReadLine().Split().Select(double.Parse);
        
        var diff = x.Zip(y, (x_i, y_i) => Math.Abs(x_i - y_i));
        
        var man = diff.Sum();
        var euc = Math.Sqrt(diff.Select(v => v * v).Sum());
        var p3 = Math.Pow(diff.Select(v => Math.Pow(v, 3)).Sum(), 1.0 / 3);
        var chb = diff.Max();
        
        Console.WriteLine($"{man}\n{euc}\n{p3}\n{chb}");
    }
}



Measured memory_bytes: 20596
N,M,X,Y = map(int, input().split())
x = list(set(map(int, input().split())))
y = list(set(map(int, input().split())))
x.sort(), y.sort()
Z = min(y)

fl = True
for i in range(N):
    if x[i] < Z and (X<Z<=Y):
        continue
    else:
        fl = False
print('No War') if fl else print('War')


Measured memory_bytes: 3060
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
    
def p_num(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<= 1+a[n-1]: #このレベルのバーガーで終了するとき
        return p_num(n-1,x-1)
    else:
        return p[n-1] + 1 + p_num(n-1,x-2-a[n-1])
print(p_num(N,X))

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  printf(n==m?"Yes":"No");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3852
N, S = int(input()), input()
bl = [0] * N
for i in range(N):
    if S[i] == "#":
        bl[i] += 1
bl_sum = [0] * N
for i in range(N):
    if i == 0:
        bl_sum[i] = bl[i]
    else:
        bl_sum[i] = bl_sum[i-1] + bl[i]

ans = N - bl_sum[N-1]

for i in range(N):
    ans = min(ans, bl_sum[i] + (N-i-1)-(bl_sum[N-1]-bl_sum[i]))

print(ans)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  float ans;
  if(n%2 == 0){
    ans = n/(2.0*n);
  }
  else {
    ans = (n+1)/(2.0*n);
  }
  
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

const int nax = 1e5;


struct bit
{
	int n;
	vector<int> B;
	void begun(int a) {
		n = a + 1;
		int i;
		for (i = 0; i < n + 5; i++) {
			B.pb(0);
		}
	}
	void update(int idx, int val) {
		for (; idx < n; idx = idx | (idx + 1))
			B[idx] = max(B[idx], val);
	}
	int getmax(int r) {
		int ret = 0;
		for (; r >= 0; r = (r & (r + 1)) - 1)
			ret = max(ret, B[r]);
		return ret;
	}
};


signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n, ans=0;
	cin >> n;	
	int h[n], v[n];
	for(int i=0; i<n; i++)cin >> h[i];
	for(int i=0; i<n; i++)cin >> v[i];
	bit tree;
	tree.begun(n+1);
	int dp[n];
	for(int i=0; i<n; i++){
		int a = tree.getmax(h[i]);
		dp[i] = a+v[i];
		ans=max(ans, dp[i]);
		tree.update(h[i], dp[i]);
	}
	cout << ans << endl;
 
	return 0;
}  

Measured memory_bytes: 9476
n, m = map(int, input().split())
alst = list(map(int, input().split()))
blst = []
for _ in range(m):
    b, c = map(int, input().split())
    blst.append([c, b])

alst.sort(reverse = True)
blst.sort(reverse = True)
blst.append([0, 0])
ans = 0
apos = 0
bpos = 0
b_total = 0
for _ in range(n):
    if alst[apos] >= blst[bpos][0]:
        ans += alst[apos]
        apos += 1
    else:
        ans += blst[bpos][0]
        b_total += 1
        if b_total == blst[bpos][1]:
            bpos += 1
            b_total = 0
print(ans)
    

Measured memory_bytes: 28248
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>

typedef unsigned long long int ull;

using namespace std;


int main(){
	int N;
	int x;
	cin >> N >> x;
	int a[4016];
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		a[N+i] = a[i];
	}
	int nextMin[4016];
	for (int i = 0; i < 2*N; ++i) {
		int c = i + 1;
		while (c < 2*N && a[c] >= a[i]) {
			++c;
		}
		if (c == 2*N) {
			nextMin[i] = i;
		} else {
			nextMin[i] = c;
		}
	}
	ull ans = (ull)1e9*1e9;
	for (int i = 0; i < N; ++i) {
		ull cur_ans = x*i;
		int cur_min = 0;
		for (int j = 0; j < N; ++j) {
			if (cur_min < j) {
				cur_min = j;
			}
			while (nextMin[cur_min] != cur_min && nextMin[cur_min] <= j + i) {
				cur_min = nextMin[cur_min];
			}
			cur_ans += a[cur_min];
		}
		ans = min(ans, cur_ans);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ディスカバリーチャンネルb
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long sum = 0;
            for(int i = 0; i< N;i++){
                sum += A[i];
            }
            long half_f = 0;
            long half_b = 0;
            long min_half = long.MaxValue;
            for(int i = 0; i<N;i++){
                half_f += A[i];
                half_b = sum - half_f;
                
                if(Math.Abs(half_f-half_b)<min_half){
                    min_half = Math.Abs(half_f-half_b);
                }
            }
            Console.WriteLine(min_half);
        }
    }
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  while ( cin >> s, s != "#" ) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;

    bool dat[9][9] = {{0}};
    int h = 1, w = 0;
    {
      int y = 0, x = 0;
      for ( int i = 0; i < (int)s.size(); i++ ) {
	if ( s[i] == 'b' ) {
	  if ( !y ) w++;	  
	  dat[y][x] = 1;
	  x++;
	} else if ( s[i] == '/' ) {
	  h++;
	  x = 0;
	  y++;
	} else {
	  if ( !y ) w += s[i]-'0';	  
	  x += s[i]-'0';	  
	}
      }
    }

    swap(dat[a][b], dat[c][d]);
    for ( int i = 0; i < h; i++ ) {
      int cnt = 0;
      for ( int j = 0; j < w; j++ ) {
	if ( dat[i][j] ) {
	  if ( cnt ) cout << cnt;
	  cout << 'b';
	  cnt = 0;
	} else {
	  cnt++;
	}
      }
      if ( cnt ) cout << cnt;
      if ( i < h-1 ) cout << '/';      
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if(abs(a-b)%2==0){
        cout<<abs(a-b)/2<<endl;
    }
    else{
        ll left=min(a, b) + (max(a, b)-min(a, b)-1)/2;
        ll right=n-max(a, b)+1 + (n-(min(a, b)+n-max(a, b)+1))/2;
        cout<<min(left, right)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <string> 
#define ll long long int
#define ld long double
using namespace std;

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }
    return result;
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string s,t;
    cin>>s>>t;
    ll x,y;
    x=s.length();
    y=t.length();
    if(y==(x+1))
    {
        if(s.compare(t.substr(0,x))==0)
        cout<<"Yes"<<"\n";
        else
        cout<<"No"<<"\n";
    }
    else
    cout<<"No"<<"\n";  

   
    
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

char s[MAXN];

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

    scanf("%s", s);
    int n = strlen(s);
    int k = 1;
    bool p = 0;
    FOR(i,1,n){
        if(p || s[i] != s[i-1]) k++, p = 0;
        else if(i < n-1) k++, i++, p = 1;
    }
    printf("%d\n", k);

    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>

typedef long long ll;

// i枚目まで確認、合計がj、選択した枚数がk の時の通り数
const ll MAX_A = 50;
const ll MAX_N = 50;
ll dp[MAX_N+10][MAX_A*MAX_N+10][MAX_N+10];

int main(int argc, char* argv[])
{
  ll N, A;
  std::cin >> N >> A;

  std::vector< ll > vx(N, 0);
  std::vector< ll >::iterator it;

  for (ll i = 0; i < N; i++) {
    std::cin >> vx[i];
  }

  // Initialize
  for (ll i = 0; i <= N; i++) {
    dp[i][0][0] = 1;
  }
  for (ll i = 1; i <= N; i++) {
    for (ll j = 0; j <= i * MAX_A; j++) {
      for (ll k = 1; k <= i; k++) {
	// 選択するケース
	if (j-vx[i-1] >=0) {
	  dp[i][j][k] += dp[i-1][j-vx[i-1]][k-1];
	}
	// 選択しないケース
	dp[i][j][k] += dp[i-1][j][k];
	//std::cout << i << " " << j << " " << k << " " << dp[i][j][k] << std::endl;
      }
    }
  }

  ll ans = 0;
  for (ll j = 0; j <= N * MAX_A; j++) {
    for (ll k = 1; k <= N; k++) {
      if (j == A * k) {
	//std::cout << "ans: " << N << " " << j << " " << k << " " << dp[N][j][k] << std::endl;
	ans += dp[N][j][k];
      }
    }
  }

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


Measured memory_bytes: 59648
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    v = LI()
    ans = -float("inf")
    for l in range(min(k,n)+1):
        vl = v[:l]
        for r in range(min(k,n)+1-l):
            vr = v[n-r:]
            s = max(0,k-l-r)
            nv = vl+vr
            nv.sort(reverse = True)
            while s > 0 and nv and nv[-1] < 0:
                nv.pop()
                s -= 1
            su = sum(nv)
            if ans < su:
                ans = su
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 41580
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, m, p, correct = 0, penalty = 0;
   string s;
   cin >> n >> m;
   bool isAC[n] = {};
   int numWA[n] = {};
   FOR(i, 0, m)
   {
      cin >> p >> s;
      if (!isAC[p - 1])
      {
         if (s == "AC")
         {
            correct++;
            penalty += numWA[p - 1];
            isAC[p - 1] = true;
         }
         else
         {
            numWA[p - 1]++;
         }
      }
   }
   printf("%d %d\n", correct, penalty);
   return 0;
}


Measured memory_bytes: 768
from bisect import bisect_left,bisect_right
n = int(input())
a = sorted(list(int(i) for i in input().split()))
b = sorted(list(int(i) for i in input().split()))
c = sorted(list(int(i) for i in input().split()))
ans = 0

for j in range(n):
  a1 = bisect_left(a,b[j])
  a2 = bisect_right(c,b[j])
  ans += a1 *(n-a2)
print(ans)

Measured memory_bytes: 23232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
#define out(a) printf("%lld ",a)
using namespace std;
int n;
int num;
ll ans;
int a[200050];
int read() 
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	  a[i]=read(),a[i]-=i;
	sort(a+1,a+n+1);
	if (n&1) num=a[n/2+1];
	else num=a[n/2];
	for (int i=1;i<=n;i++)
	  ans+=abs(a[i]-num);
	out(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define ep emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


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

	map<int, int> m;
	rep( i, N )
	{
		int K;
		cin >> K;

		rep( j, K )
		{
			int tmp;
			cin >> tmp;
			m[tmp]++;
		}
	}

	long counter = 0;
	for ( auto &&it : m )
	{
		if ( it.second >= N )
		{
			counter++;
		}
	}

	cout << counter << endl;

	return ( 0 );
}


Measured memory_bytes: 256
N=int(input())
D=[0]+[int(i) for i in input().split()]

line=[0]*13
clock = [0]*24
tag=0
ans=25
ansL=[]

for i in D:
    line[i%13]+=1

if(line[0]>=2 or line[12]>=2):
    ans=0
else:
    #lineを円周上の時計に置き換える
    for i in range(len(line)):
        if (line[i] > 2):#線上に３人以上 ->どうやっても同時刻に２人以上存在することになるのでans=0
            ans = 0
            break
        elif (line[i] == 2): #線上に２人
            clock[i] = 1
            clock[24 - i] = 1
        elif (line[i] == 1):#線上に１人 ー＞交互に
            if (tag % 2 == 0):
                clock[i] = 1
            else:
                clock[24 - i] = 1
            tag += 1

    #one-hotベクトルに変換
    for i in range(len(clock)):
        if(clock[i]==1):
            ansL.append(i)

    ansL.reverse()
    before = 24
    for i in range(len(ansL)):
        if (ans > before - ansL[i]):
            ans = before - ansL[i]
        before=ansL[i]

print(ans)

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s;
    cin >> s;
    ll ans = 0;
    for(int i = 0; i < s.size(); i++) {
        ans += (ll)(s[i]-'0');
    }
    if(ans%9) {
        cout << "No\n";
    }
    else
        cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3712
h,w,k=map(int,input().split())
c=[[]]*h
for i in range(h):
    tmp =list(input())
    c[i] = [1 if x=='#' else 0 for x in tmp]

# print(c)
from itertools import product

aans=0

for i in product([0,1],repeat=h):
    for j in product([0,1],repeat=w):
        ans=0
        for hh in range(h):
            for ww in range(w):
                if i[hh] == 1 and j[ww] == 1:
                    if c[hh][ww] == 1:
                        # print(i,j)
                        ans += 1
        if ans == k:
            aans +=1

print(aans)

Measured memory_bytes: 9092
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int main() {
	int n, t;
	scanf("%d %d", &n, &t);

	int a, b;
	int mav = 1e9;
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &a, &b);
		if(b <= t) mav = min(mav, a);
	}
	if (mav > 1e8) printf("TLE");
	else printf("%d", mav);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
using namespace std;
const int MX = 1007;
const int LIM = 2e5+3;
const int MLOG = 25;
int arr[LIM+3];
std::vector<int> V[LIM+3];
int main(){
    int n,m;cin >> n >> m;
    for(int i = 0;i<n;i++)
    {
        int x,y;scanf("%d %d",&x,&y);
        V[x].push_back(y);
    }
    multiset<int>S;
    ll Ans = 0;
    for(int i = 1;i<=m;i++)
    {
        for(int j=0;j<V[i].size();j++)
            S.insert(V[i][j]);
        if(S.empty())continue;
        auto it = S.end();
        it--;
        Ans += *it;
        S.erase(it);
    }
    cout << Ans << endl;
}

Measured memory_bytes: 10112
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll a, b;
    cin >> a >> b;

    cout << a * b<< "\n";


    return 0;
}


Measured memory_bytes: 3652
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

answer = 0
for i in range(2 ** (H + W)):
    s = [list(ss) for ss in S]
    for h in range(H):
        if i >> h & 1:
            for w in range(W):
                s[h][w] = "."
    for w in range(H, H + W):
        if i >> w & 1:
            for h in range(H):
                s[h][w - H] = "."
    cnt = 0
    for h in range(H):
        for w in range(W):
            if s[h][w] == "#":
                cnt += 1
    if cnt == K:
        answer += 1

print(answer)

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

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string a, b;
  cin >> a >> b;
  
  if(a.size() > b.size()) {
    cout << "GREATER" << "\n";
    return 0;
  }
  
  if(a.size() < b.size()) {
    cout << "LESS" << "\n";
    return 0;
  }
  
  for(int i = 0; i < a.size(); i++) {
    int A = a[i] - '0';
    int B = b[i] - '0';
    if(A > B) {
      cout << "GREATER" << "\n";
      return 0;
    }
    if(A < B) {
      cout << "LESS" << "\n";
      return 0;
    }
  }
  cout << "EQUAL" << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll N, M;
	cin >> N >> M;
	if (N == 1 && M == 1) {
		cout << 1 << endl;
		return 0;
	}
	else if (N == 1) {
		cout << max(0LL, M - 2) << endl;
		return 0;
	}
	else if (M == 1) {
		cout << max(0LL, N - 2) << endl;
		return 0;
	}
	else {
		cout << max(0LL, (M - 2) * (N - 2)) << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
arg = input()

isOk = True

for i in range(len(arg)):
    
    if i % 2 == 0:

        if arg[i] == 'L':
            isOk = False
    else:
        if arg[i] == 'R':
            isOk = False

msg = ''

if (isOk):
    msg = 'Yes'
else:
    msg = 'No'

print(msg)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>M;
    vector<vector<bool> > vecs(M,vector<bool>(10,false));
    int s;
    rep(i,M){
        cin>>K;
        rep(j,K) {
            cin>>s;
            vecs.at(i).at(s-1) = true;
        }
    }
    vector<int> p(M,0);
    rep(i,M) cin>>p.at(i);
    int one_ofN = 1;
    rep(i,N) one_ofN *= 2;
    int onoff;
    vector<int> nowswitch(N,0);
    int temp, ans = 0;
    bool flash = false;
    int tempi;
    rep(i,one_ofN){
        flash = true;
        tempi = i;
        rep(x,N){
            onoff = tempi&1;
            nowswitch.at(x) = onoff;
            tempi >>= 1;
        }
        rep(j,M){
            temp = 0;
            rep(k,10) {
                if(vecs.at(j).at(k)) temp += nowswitch.at(k);
            }
            temp = (temp+2)%2;
            if(temp != p.at(j)){
                flash = false;
                break;
            }
            tempi <<= N;
        }
        if(flash) {
            ans++;
            //cout << i << endl;
        }
    }
    
    //if(flash) cout<<one_ofN-1<<endl;
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

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

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

    int loop = 1;
    int cnt = 0;
    vector<int> b;
    vector<int> check(n+1, -1);
    while(check[loop] == -1){
        check[loop] = cnt;
        b.push_back(loop);
        cnt++;
        loop = a[loop];
    }


    if(k < check[loop]){
        cout << b[k] << "\n";
    }else{
        int dif = check[loop];
        k -= dif;
        k %= (b.size() - check[loop]);
        //cout << dif <<  " " << cnt << " " << k<< "\n";
        cout << b[k+dif] << "\n";
    }


    return 0;
}


Measured memory_bytes: 5812
/* 
 * Project: AtCoder Beginners Contest 134 C - Exception Handling
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/16
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
using namespace std;

uint64_t n;
vector<uint64_t> a;

void solve() {

    vector<uint64_t> sorted_a(n);
    copy(a.begin(), a.end(), sorted_a.begin());
    sort(sorted_a.begin(), sorted_a.end());
    for (auto i : a) {
        if (i == sorted_a[n-1]) {
            printf("%lld\n", sorted_a[n-2]);
        } else {
            printf("%lld\n", sorted_a[n-1]);
        }
    }
}

int main() {

    scanf("%lld", &n);
    a.resize(n);
    for (int i=0;i<n;i++) {
        scanf("%lld", &a[i]);
    }

    solve();
}

Measured memory_bytes: 6048