akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){

    string N;
    cin >> N;
    int sum = 0;

    for(int i = 0; i < N.size(); ++i){
        int tmp = N[i] - '0';
        sum += tmp;
    }

    if(sum%9 == 0){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3756
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
import numpy as np
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

start = time.time()

D = ni()
c = na()
s = [na() for _ in range(D)]
#out = [ni() for _ in range(D)]
sat = 0
last = [0] * 26
t = []
for d in range(D):
    li = []
    for k in range(26):
        last_t = last.copy()
        sat_t = sat
        j = k
        last_t[j] = d + 1
        for i in range(26):
            sat_t -= (d + 1 - last_t[i]) * c[i]
        sat_t += s[d][j]
        li.append(sat_t)
    sat = max(li)
    day = np.argmax(li)
    last[day] = d + 1
    #print(day+1, sat)
    t.append(day+1)

now = sat
while time.time() - start < 1.86:
    d = random.randint(1, D)
    q = random.randint(1, 26)
    if t[d - 1] == q:
        continue
    old = t[d-1]
    t[d-1] = q
    sat = 0
    last = [0] * 26
    for k in range(D):
        j = t[k] - 1
        last[j] = k + 1
        for i in range(26):
            sat -= (k + 1 - last[i]) * c[i]
        sat += s[k][j]
    if now > sat:
        t[d-1] = old
    else:
        now = sat
for i in range(D):
    print(t[i])


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b==3) cout << 3 << endl;
    else if(a+b==4) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

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

int main() {
	int n; 
	while (cin >> n, n) {
		map<char, char>mp;
		rep(i, n) {
			char c, d; cin >> c >> d;
			mp[c] = d;
		}
		int m; cin >> m;
		string s = "";
		rep(i, m) {
			char c; cin >> c;
			if (mp[c] == 0)s += c;
			else s += mp[c];
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	static class Dice {
		// 回転方向上にある4つの面の添え字、対応する右の面の添え字
		enum Direction {
			Roll			(new int[] { 0, 1, 5, 4 }, 2),
			Pitch			(new int[] { 0, 3, 5, 2 }, 1),
			Yaw				(new int[] { 4, 2, 1, 3 }, 5),
			ReverseRoll	(new int[] { 0, 4, 5, 1 }, 3),
			ReversePitch	(new int[] { 0, 2, 5, 3 }, 4),
			ReverseYaw		(new int[] { 4, 3, 1, 2 }, 0);

			// 回転軸方向の4つの面
			private int[] nextRotat;
			// 回転軸方向に対応する右の面
			private int rightNum;

			Direction(int[] nums, int num) {
				this.nextRotat = nums;
				this.rightNum = num;
			}
		}

		// ラベル
		int[] label;

		// コンストラクタ
		Dice(int[] label) {
			this.label = label;
		}

		int[] getCorrespondingAspects(int num) {
			for (Direction dir : Direction.values()) {
				if (dir.rightNum == num) {
					return dir.nextRotat;
				}
			}
			return null;
		}

		int[] getCorrespondingAspectsLabel(int num) {
			int[] pointers = getCorrespondingAspects(num);
			int[] CorrespondingAspectsLabel = new int[pointers.length];
			for (int i = 0; i < CorrespondingAspectsLabel.length; i++) {
				CorrespondingAspectsLabel[i] = this.label[pointers[i]];
			}
			return CorrespondingAspectsLabel;

		}

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// ラベル入力・ダイスの生成
		Dice dice1 = new Dice(CreateIntLabel(sc.nextLine().split("[\\s]+")));

		Dice dice2 = new Dice(CreateIntLabel(sc.nextLine().split("[\\s]+")));

		if (DiceComparison(dice1, dice2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	// ラベル配列の生成
	public static int[] CreateIntLabel(String[] input) {
		int[] label = new int[input.length];
		for (int i = 0; i < input.length; i++) {
			label[i] = Integer.parseInt(input[i]);
		}
		return label;
	}

	public static boolean DiceComparison(Dice dice1, Dice dice2) {
		for (int i = 0; i < dice2.label.length; i++) {
			if (dice1.label[0] == dice2.label[i]) {

				if (ComparisonNumberSequence(dice1.getCorrespondingAspectsLabel(0),
						dice2.getCorrespondingAspectsLabel(i))) {
					return true;
				}
			}
		}
		return false;

	}

	public static boolean ComparisonNumberSequence(int[] array1, int[] array2) {
		while (array1[0] != array2[0]) {
			int work = array2[0];
			for (int i = 1; i < array2.length; i++) {
				array2[i - 1] = array2[i];
			}
			array2[array2.length - 1] = work;
		}

		for (int i = 0; i < array1.length; i++) {
			if (array1[i] != array2[i]) {
				return false;
			}
		}

		return true;

	}

}



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

int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int i = 0, j = s.length()-1, cnt = 0;
    while(i < j)
    {
        if(s[i] == 'W' and s[j] == 'R')
        {
            swap(s[i],s[j]);
            ++cnt;
            ++i;
            --j;
        }
        else if(s[i] == 'R')
            ++i;
        else if(s[i] == 'W')
            --j;
        // cout<<s<<cnt<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, p;
    string s;
    cin >> n;
    vector<tuple<string, int, int>>arr;
    for(int i = 0; i < n; i++) {
        cin >> s >> p;
        arr.push_back(make_tuple(s, p, i+1));
    }
    sort(arr.begin(), arr.end(), [](tuple<string, int, int> a, tuple<string, int, int> b) {
        if (get<0>(a) == get<0>(b)) {
            return get<1>(a) > get<1>(b);
        } else {
            return get<0>(a) < get<0>(b);
        }
    });
    for(int i = 0; i < n; i++) {
        cout << get<2>(arr[i]) << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
	int h,w;
	while(scanf("%d%d",&h,&w)!=EOF)
	{
		int n;
		scanf("%d",&n);
		for(int i=1; i<=n; ++i)
			scanf("%d",&a[i]);
		int cnt=1;
		for(int i=1; i<=h; ++i)
		{
			if(i%2 == 1)
			{
				for(int j=1; j<=w; ++j)
				{
					if(a[cnt]>0)
					{
						G[i][j]=cnt;
						--a[cnt];
					}
					else if(a[cnt]==0)
					{
						++cnt;
						G[i][j]=cnt;
						--a[cnt];
					}
				}
			}
			else
			{
				for(int j=w; j>=1; --j)
				{
					if(a[cnt]>0)
					{
						G[i][j]=cnt;
						--a[cnt];
					}
					else if(a[cnt]==0)
					{
						++cnt;
						G[i][j]=cnt;
						--a[cnt];
					}
				}
			}
		}
		for(int i=1; i<=h; ++i)
		{
			for(int j=1; j<=w; ++j)
			{
				if(j!=w) printf("%d ",G[i][j]);
				else printf("%d\n",G[i][j]);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a,b,k,cnt = 0;
  scanf("%d %d %d",&a,&b,&k);
  for(int i = a;cnt < k;i--){
    if(a % i < 1 && b % i < 1){
      cnt++;
      if(cnt == k){
        printf("%d",i);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

# input
n = int(input())

edges = [[] for i in range(n)]
for i in range(n-1):
    a ,b = map(int, list(input().split()))
    edges[a-1].append((b-1, i))

# process
ans = [0]*(n-1)

def f(a, c):
    color = 1
    for b, i in edges[a]:
        if color == c: color += 1
        ans[i] = color 
        f(b, color)
        color += 1

f(0, 0)

# output
print(max(ans))
for i in ans:
    print(i)


Measured memory_bytes: 69096
#include<iostream>
#include<cmath>
using namespace std;
int func(int y, int v){
  return v * (100 + y) / 100;
}
int main(){
  int x, y, s;
  while(true){
    cin >> x >> y >> s;
    if((x|y|s) == 0){
      break;
    }
    int pre_s = s * 100 / (100 + x);
    int ans = -1;
    for(int v1 = 0; v1 <= pre_s; ++v1){
      for(int v2 = 0; v2 <= pre_s; ++v2){
        if(func(x, v1) + func(x, v2) == s){
          int v_s = func(y, v1) + func(y, v2);
          ans = ans > v_s ? ans : v_s;
        }
      }
    }
    cout << ans << endl;
  }  
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int t[N + 1] = {0};
    rep(i, N-1){
        if(S[i] =='A' && S[i+1]== 'C') t[i + 1] = t[i] + 1;
        else t[i+1] = t[i];
    }
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        cout << t[r - 1] - t[l -1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<math.h>
#include<string>
using namespace std;
int main(void){
	int n,i,j;
	cin >> n;
	string s[n];
	int p[n];
	int rank[n];
	string tmp;
	for(i=0;i<n;i++){
		rank[i] = i+1;
		cin >> s[i] >> p[i];
	}
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(s[j]<s[j-1]){
				swap(s[j],s[j-1]);
				swap(p[j],p[j-1]);
				swap(rank[j],rank[j-1]);
			}else if(s[j]==s[j-1]){
				if(p[j]>p[j-1]){
					swap(s[j],s[j-1]);
					swap(p[j],p[j-1]);
					swap(rank[j],rank[j-1]);

				}
			}
		}
	}
	for(i=0;i<n;i++){
		cout << rank[i] << endl;
	}
	return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	char A;
	cin >> A;
	string ans = "A";
	if ('a' <= A && A <= 'z') ans = "a";

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100010;
int a[maxn];
int main(){
	int N;
	int num=0;
	long long sum=0;
	long long fu=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<N;i++){
		int temp;
		scanf("%d",&temp);
		a[i]=a[i]-temp;
		sum+=a[i];
		if(a[i]<0){
			num++;
			fu+=a[i];
		}
	}
	if(num==0){
		printf("0");
		return 0;
	}
	if(sum<0){
		printf("-1");
		return 0;
	}
	sort(a,a+N);
	int count=0;
	for(int i=N-1;i>=0;i--){
		fu+=a[i];
		if(fu>=0){
			count=N-i;
			break;
		}
	}
	printf("%d",count+num);
	return 0;
}

Measured memory_bytes: 512
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B, C = sc.nextInt()
    val nums = List(A, B, C).sorted(Ordering.Int.reverse)
    println(nums.head * 10 + nums.tail.sum)
  }

}


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

int main(){
  string S;
  cin >> S;
  if ((S[1] == S[0] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])){
     cout << "Yes" << endl;
    
  }
    else {
      cout << "No" << endl;
    }
  
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i =1;
    while(++i<=n) {
        int x = i;
        if (x % 3 == 0) {
            System.out.print(" " + i);
        } else
            while (x != 0) {
                if (x % 10 == 3) {
                    System.out.print(" " + i);
                    break;
                }
                x /= 10;
            }
        }
        System.out.println();

    }
}




Measured memory_bytes: 28636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	bool bl = true;
	int n; cin >> n;
	for(int i = 0; i < n; ++ i){
		int x; cin >> x;
		if(~x & 1){
			if(x % 3 && x % 5) bl = false;
		}
	}
	bl ? cout << "APPROVED\n" : cout << "DENIED\n";
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
l =deque(sorted([list(map(int,input().split())) for i in range(n)]))
money = 0
while m!=0:
  a,b = l.popleft()
  t = min(b,m) 
  m -= t
  money += a*t
print(money)

Measured memory_bytes: 28880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, a[N], p;
bool z[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  int ans = 0;
  while(p!=1){
    if(z[p]){
      cout << -1 << endl;
      return 0;
    }
    z[p] = true;
    p = a[p]-1;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n_ = 3 * 10**5
mod = 998244353
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod


def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod

n, m, k = nm()
ans = 0
tbl = [1]*(n+1)
for i in range(n):
    tbl[i+1] = tbl[i] * (m - 1) % mod
for x in range(k+1):
    cnt = nCr(n-1, x) * m * tbl[n - x - 1] % mod
    ans = (ans + cnt) % mod
print(ans)


Measured memory_bytes: 40480
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main()
{
	int n;
	cin >> n;
	int u, v;
	cin >> u >> v;
	u--;
	v--;
	vector<vector<int>> graph(n);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	vector<int> distu = bfs(graph, u);
	vector<int> distv = bfs(graph, v);
	int ans = 0;
	rep(i, n)
	{
		if(distu[i] < distv[i])
			ans = max(ans, distv[i]);
	}
	ans--;
	cout << ans << endl;

	return 0;
}

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

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

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

    if(N[0] == N[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
		       #include <map>
		     using                    namespace
		  std;                              typedef
	    long	         long ll;                  int main(){
	  int                 n;ll a                     [212345];

	               a[0] = 0; cin >>
	                     n;     map
	                     <ll    ,ll
	                     >     mp;
	                     mp
	                    [0]
                     
	              =1;
	       for(int i
	             =1
	     ;i<=n;i++){cin
	    >>      a[i];       a[  i]+=a[i - 1];mp
	           [a [i]]      ++              ;}
	          ll  res =0     ;             for
	      (auto   i:         mp)          res
	    +=        i.         second       *(i.
	second        -1          )/2;       cout
	              <<           res<<endl;return
	             0;}
             

Measured memory_bytes: 14336
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

struct weightedUnionFind{

    vector<int> par, rank, wei;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        wei.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            int r = root(par[x]);
            wei[x] += wei[par[x]];
            return par[x] = r;
        }
    }

    void unite(int x, int y, int w){
        w = -w;
        w += weight(x);
        w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if(rank[rx] < rank[ry]){
            swap(rx, ry);
            w = -w;
        }
        if(rank[rx] == rank[ry]){
            rank[rx]++;
        }
        par[ry] = rx;
        wei[ry] = w;
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int weight(int x){
        root(x);
        return wei[x];
    }

    int diff(int x, int y){
        return weight(x) - weight(y);
    }

};

bool solve(void){
    int n, m;
    cin >> n >> m;
    weightedUnionFind wuf;
    wuf.init(n);
    rep(i, m){
        int l, r;
        lint d;
        cin >> l >> r >> d;
        l--;
        r--;
        if(wuf.same(l, r)){
            int dif = wuf.diff(l, r);
            if(dif != d){
                return false;
            }
        }else{
            wuf.unite(l, r, d);
        }
    }
    return true;
}

int main(){
    if(solve()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

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

    int s = 0, ma = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s += a;
        if (a > ma) {
            ma = a;
        }
    }

    cout << s - ma / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()
    val c = readString()

    var numR = 0
    var numW = 0
    c.forEach {
        when(it) {
            'R' -> numR++
            'W' -> numW++
        }
    }

    var ans = 0
    for (i in 0 until numR) {
        if (c[i] == 'W') ans++
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()

Measured memory_bytes: 39028
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll x;

ll pangkat(ll xx, ll yy){
	if(yy == 0){
		return 1;
	}
	ll temp = pangkat(xx, yy / 2);
	if(yy % 2 == 1){
		return xx * temp * temp;
	}
	else{
		return temp * temp;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	
	cin >> x;
	for(ll i = -1000; i <= 1000; i++){
		for(ll j = -1000; j <= 1000; j++){
			ll temp = pangkat(i, 5) - pangkat(j, 5);
			if(temp == x){
				cout << i << " " << j << '\n';
				return 0;
			}
		}
	}		
}


Measured memory_bytes: 3580
S = input()
L = len(S)

ans = None
for i in range(1,L):
  if (L - i) % 2 != 0:
    continue
  ns = S[:-i]
  h = (L - i) // 2
  m = ns[:h] + ns[:h]
  if ns == m:
    ans = ns
    break
    
print(len(ans))


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m, q;
  cin >> n >> m >> q;
  using T = tuple<int, int, int, int>;
  vector<T> v;
  rep(qi, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, b--;
    v.emplace_back(a, b, c, d);
  }
  int ans = 0;
  vi32 now;
  auto rec = [&](auto rec) {
    if (sz(now) == n) {
      int sum = 0;
      rep(qi, q) {
        int a, b, c, d;
        tie(a, b, c, d) = v[qi];
        if (now[b] - now[a] == c) {
          sum += d;
        }
      }
      amax(ans, sum);
      return;
    }
    repic(i, (sz(now) > 0 ? now.back() : 1), m) {
      now.push_back(i);
      rec(rec);
      now.pop_back();
    }
  };
  rec(rec);
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long sum = 0;
        for (int i=0;i<n;i++){
            int A = sc.nextInt();
            a[i]=A;
            if (i%2==0)sum+=A;
            else sum-=A;
        }
        System.out.print(sum+" ");
        long ins = sum/2;
        for (int i=1;i<n;i++){
            ins = a[i-1]-ins;
            System.out.print(2*ins+" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 60888
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef pair<int,int> pll;
const int maxn= 2e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;
LL a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,n;
    cin >>k >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    LL sum=k-(a[n]-a[1]);
    for(int i=2;i<=n;i++)
    {
        LL ans=a[i]-a[i-1];
        sum=max(sum,ans);
    }
    cout << k-sum << endl;
    return 0;
}



Measured memory_bytes: 1792
class segtree:
  def __init__(self, initArr, segfunc, idele):
    n = len(initArr)
    stn = 2**((n - 1).bit_length() + 1) - 1
    arr =  [idele for i in range(stn)]
    arr[stn//2:stn//2+n] = initArr
    for i in range(stn-1, 1, -2):
      arr[(i-1)//2] = segfunc(arr[i-1], arr[i])
  
    self.arr = arr
    self.segfunc = segfunc
    self.idele = idele
  
  def update(self, idx, val):
    idx += len(self.arr)//2
    self.arr[idx] = val
    while idx > 0:
      idx = (idx-1)//2
      self.arr[idx] = self.segfunc(self.arr[idx*2+1], self.arr[idx*2+2])
    return None

  def query(self, x, y, i=0, l=0, r=-1): # [x, y)の半開区間を探索
    if r < 0: r = len(self.arr)//2 + 1
    if r <= x or y <= l: return self.idele
    if x <= l and r <= y: return self.arr[i]
    return self.segfunc(
      self.query(x, y, 2*i+1, l, (l+r)//2),
      self.query(x, y, 2*i+2, (l+r)//2, r)
    )
N, Q = map(int, input().split())
st = segtree(list([2**31-1]*N), min, 2**31-1)

for q in range(Q):
  com, x, y = map(int, input().split())
  if com:
    print(st.query(x, y+1))
  else:
    st.update(x, y)


Measured memory_bytes: 9468
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while (true) {
int H = sc.nextInt();
int W = sc.nextInt();
if (H == 0 && W == 0) {
break;
}for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
    System.out.printf("#");
    }
    System.out.printf("\n");
}
System.out.printf("\n");
}
}
}


Measured memory_bytes: 62716
import java.util.*;
import java.math.*;
public class Main {
	static int r; 
	static int c;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int r = s.length() - 1;
		String ans = "Yes";
		if(isPal(s.substring(0, ((r - 1) / 2) + 1)) == false) ans = "No";
		if(isPal(s.substring((r + 3) / 2, r + 1)) == false) ans = "No";
		if(isPal(s) == false) ans = "No";
		System.out.println(ans);
	}
	public static boolean isPal(String s) {
		int l = 0;
		int r = s.length() - 1;
		while(l <= r) {
			if(s.charAt(l) != s.charAt(r)) return false;
			l += 1;
			r -= 1;
		}
		return true;
	}
} 


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];

    map<int, int> cnt;
    cnt[0] = 1;
    ll ans = 0, sm = 0;
    rep(i, 0, N) {
        sm += A[i];
        ans += cnt[sm%M];
        cnt[sm%M]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
let nameChars n =
    let rec nameCharsRev lst n =
        let n = n - 1L
        match n / 26L, n % 26L with
        | 0L, rem -> rem :: lst
        | q, rem -> nameCharsRev (rem :: lst) q

    nameCharsRev [] n |> List.rev

stdin.ReadLine()
|> int64
|> nameChars
|> List.toArray
|> Array.rev
|> Array.map (fun num -> char (num + 97L))
|> System.String.Concat
|> printfn "%s"


Measured memory_bytes: 29692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int k;
  cin >> k;
  int ans = 0;
  if (k%2 == 0 || k%5 == 0){
    cout << -1 << endl;
    return 0;
  }
  else{
    rep(i,k){
      ans = ((ans*10) + 7)%k;
      if (ans == 0){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int n,k;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin>>n>>k;
	if(n % 2)
		n = n/2+1;
	else
		n /= 2;
	if(n >= k)
	{
		cout<<"YES"<<endl;
	}
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n, m;
ll vs[100000+10];
ll ts[100000+10];


ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a%b);
}

inline ll lcm(ll a, ll b) {
  return a/gcd(a,b)*b;
}


ll solve(void) {
  REP(i, n) {
    while(vs[i] % 2 == 0) {
      ts[i]++;
      vs[i] /= 2;
    }
  }
  REP(i, n) {
    if(ts[0] != ts[i]) {
      return 0;
    }
  }
  ll llcm = 1;
  REP(i, ts[0]) {
    llcm *= 2;
  }
  REP(i, n) {
    llcm = lcm(llcm, vs[i]);
    if(llcm > m) {
      return 0;
    }
  }
  return (m / llcm + 1) / 2;
}

int main(void) {
  scanf("%d%d", &n, &m);
  REP(i, n) {
    scanf("%lld", &vs[i]);
    vs[i] /= 2;
  }

  ll res = solve();
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 60
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXN],c[MAXN][MAXN]; 
int n;
int main(){
    SF("%d",&n);
    for(int i=0;i<=n;i++)
        for(int j=0;j<=i;j++){
            if(j==0)
                c[i][j]=1;
            else
                c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
        }
    dp[1][n]=1;
    dp[1][n-1]=1;
    for(int i=1;i<n;i++)
        for(int j=-i;j<=i;j++){
            for(int sum=max(1,abs(j));sum<=n;sum++){
                if(i+sum>n||(sum+j)%2)
                    continue;
                for(int pos=0;pos<=sum;pos++){
                    int t=sum-pos;
                    int val=(j+pos-t)/2;
                    if(val<-n||val>n)
                        continue;
                    dp[i+sum][val+n]+=dp[i][j+n]*c[i+sum][sum]%MOD*c[sum][pos]%MOD;
                    dp[i+sum][val+n]%=MOD;
                }
            }
        }
    PF("%lld\n",dp[n][n]);
}

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

int N, A, B, P[105];

int C[3];

int main(void) {

	cin >> N >> A >> B;

	for (int i = 1; i <= N; i++) {
		cin >> P[i];
	}

	for (int i = 1; i <= N; i++) {
		if (P[i] <= A) { C[0]++; }
		else if (P[i] <= B) { C[1]++; }
		else { C[2]++; }
	}

	int ans = 99999;
	for (int i = 0; i <= 2; i++) { ans = min(ans, C[i]); }
	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 100020;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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



	int N; cin >> N;
	vector<int>v(N);
	REP(i, N)cin >> v[i];

	COMinit();
	int cnt = 0;
	ll ans = 1;
	REP(i, N) {
		if (v[i] >= 2 * cnt + 1) {
			cnt++;
		}
		else {
			ans *= (cnt + 1);
			ans %= MOD;
		}
	}
	ans *= fac[cnt];
	ans %= MOD;
	print(ans);
}



Measured memory_bytes: 3328
#include <cstdio>

using namespace std;

int main() {
    int n, i;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++) {
        int x = i * 1.08;
        
        if (x == n) {
            printf("%d\n", i);
            
            return 0;
        }
    }
    
    puts(":(");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
    string str;
    cin>>str;
    
    bool bb=true;
    
    for(int i=0; i<26; i++){
        int t=str.find('a'+i);
        
        if(t==-1){
            bb=false;
            cout<<(char)('a'+i)<<endl;
            break;
        }
    }
    
    if(bb){
        cout<<"None"<<endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B;
    cin >> A >> B;
    int N = A.size();
    if(count(B.begin(),B.end(),'1')==0){
        cout << (count(A.begin(),A.end(),'1')==0? 0:-1) << "\n";
        return 0;
    }
    vec<int> L(N),R(N);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) if(B[(i+j)%N]=='1'){
            R[i] = j;
            break;
        }
        for(int j=0;j<N;j++) if(B[(i-j+N)%N]=='1'){
            L[i] = j;
            break;
        }
    }

    int inf = 1e9;
    auto calc = [&](vec<int>& l,vec<int>& r,int br){
        map<int,int> ml,mr;
        int n = l.size();
        if(!n) return br;
        for(int i=0;i<n;i++){
            if(ml.count(l[i])) ml[l[i]] = max(ml[l[i]],r[i]);
            else ml[l[i]] = r[i];
        }
        int ans = br-ml.begin()->first;
        int rmax = br;
        for(auto& [a,b]:ml){
            ans = min(ans,rmax-a);
            rmax = max(rmax,b);
        }
        return ans;
    };

    int ans = inf;
    for(int j=0;j<=2*N;j++){
        int now = j;
        vec<int> l,r;
        for(int i=0;i<N;i++){
            if(A[i]!=B[(i+j)%N]){
                now++;
                if(L[i]>0 && j<R[i]){
                    l.push_back(-L[i]);
                    r.push_back(R[i]);
                }
            }
        }
        now += 2*(calc(l,r,j)-j);
        ans = min(ans,now);
    }

    for(int j=0;j<=2*N;j++){
        int now = j;
        vec<int> l,r;
        for(int i=0;i<N;i++){
            if(A[i]!=B[(i-j+2*N)%N]){
                now++;
                if(j<L[i] && R[i]>0){
                    l.push_back(-R[i]);
                    r.push_back(L[i]);
                }
            }
        }
        now += 2*(calc(l,r,j)-j);
        ans = min(ans,now);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3748
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

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

ll N,X;
    ll dp[2][52];

ll eat(ll x,ll n){
    if(n==0){
        if(x>=1){
            return 1;
        }
        else{
            return 0;
        }
    }
    if(x>=dp[0][n]){
        return dp[1][n];
    }
    else if(x<=dp[0][n-1]+1LL){
        return eat(x-1LL,n-1LL);
    }
    else if(x==dp[0][n-1]+2LL){
        return dp[1][n-1]+1LL;
    }
    else{
        return dp[1][n-1]+1LL+eat(x-dp[0][n-1]-2LL,n-1LL);
    }
}

int main() {
	
    cin>>N>>X;
    
    dp[0][0]=1,dp[1][0]=1;
    FOR(i,1,N+1){
        dp[0][i]=dp[0][i-1]*2+3;
        dp[1][i]=dp[1][i-1]*2+1;
    }

    ll ans=eat(X,N);
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#define SIZE 100005
#define MOD 1000000007

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

int A[SIZE];
int S[SIZE],T[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&S[i]);
	for(int i=0;i<n;i++) scanf("%d",&T[i]);
	if(S[n-1]!=T[0])
	{
		puts("0");
		return 0;
	}
	memset(A,-1,sizeof(A));
	A[0]=S[0],A[n-1]=T[n-1];
	for(int i=1;i<n;i++)
	{
		if(S[i]>S[i-1])
		{
			if(A[i]>=0&&A[i]!=S[i])
			{
				puts("0");
				return 0;
			}
			A[i]=S[i];
		}
	}
	for(int i=n-2;i>=0;i--)
	{
		if(T[i]>T[i+1])
		{
			if(A[i]>=0&&A[i]!=T[i])
			{
				puts("0");
				return 0;
			}
			A[i]=T[i];
		}
	}
	ll ret=1;
	for(int i=0;i<n;i++)
	{
		if(A[i]==-1)
		{
			ret*=(ll) min(S[i],T[i]);
			ret%=MOD;
		}
		else if(A[i]>min(S[i],T[i]))
		{
			puts("0");
			return 0;
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2005;


int main(){
	int N,M;
	cin>>N>>M;
	char B[MAX][MAX];
	rep1(i,N)rep1(j,M)cin>>B[i][j];
	rep1(i,N)B[i][M+1]='#';
	rep1(j,M)B[N+1][j]='#';
	
	int ch[MAX][MAX];
	rep1(i,N){
		ch[i][0]=0;
		int ind=1;
		int cons=0;
		rep1(j,M+1){
			if(B[i][j]=='.'){
				cons++;
			}
			if(B[i][j]=='#'){
				ch[i][j]=0;
				for(int p=ind; p<j; p++)ch[i][p]=cons;
				cons=0;
				ind=j+1;
			}
		}
	}
	int cw[MAX][MAX];
	rep1(j,M){
		ch[0][j]=0;
		int ind=1;
		int cons=0;
		rep1(i,N+1){
			if(B[i][j]=='.'){
				cons++;
			}
			if(B[i][j]=='#'){
				cw[i][j]=0;
				for(int p=ind; p<i; p++)cw[p][j]=cons;
				cons=0;
				ind=i+1;
			}
		}
    }
	int ans=0;
	rep1(i,N)rep1(j,M){
		ans=max(ans, ch[i][j]+cw[i][j]-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35584
def resolve():
    n,T=map(int,input().split())
    ans=10000
    for i in range(n):
        c,t=map(int,input().split())
        if t<=T:
            ans=min(ans,c)
    if ans==10000:
        print('TLE')
    else:
        print(ans)
    
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<time.h>
#include<sstream>
#define MINN -1e8 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=0x3f3f3f3f3f3f;
const int P=1e9+7;
const int MAXN=32000;
const double pi=atan(1)*4;
//const int MINN=-1e8;
const ll mod=1000000007;

//map<string,ll> m;
//map<ll,ll> m;

//set<ll> s;

//vector<ll> v;

//scanf("%lld",&t);
double a,b,x;
int main()
{
	cin>>a>>b>>x;
	if(2*x<=a*a*b)
	{
		double ans=atan2(b,2*x/(a*b));
		ans=ans*180/pi;
		printf("%.10f",ans);
	}
	else
	{
		x=a*a*b-x;
		double ans=atan2(2*x/(a*a),a);
		ans=ans*180/pi;
		printf("%.10f",ans);
	}
	return 0;
}
//ll n,m,t,a,x,ans,res;
//ll powmod(ll a,ll b)     //快速幂 
//{
//	ll tmp=a%mod;
//	ll ans=1;
//	while(b)
//	{
//		if(b&1)ans=ans*tmp%mod;
//		tmp=tmp*tmp%mod;
//		b>>=1;
//	}
//	return ans%mod;
//}


//bool is_prime(ll a)     //判断素数 
//{
//	if(a==2)return 1;
//	else if(a==1||a%2==0)return 0;
//	else
//	{
//		for(ll i=3;i*i<=a;++i)
//		{
//			if(a%i==0)return 0;
//		}
//	}
//	return 1;
//}


Measured memory_bytes: 384
n, m = map(int, input().split())
h = [[] for _ in range(n)]
v = input().split()

for i in range(len(v)):
  h[i].append(int(v[i]))

for i in range(m):
  a,b = map(int, input().split())
  h[a-1].append(h[b-1][0])
  h[b-1].append(h[a-1][0])


ans = 0

for i in range(len(h)):
  
  if len(h[i][1:]) == 0:
    ans += 1
    continue

  if h[i][0] > max(h[i][1:]):
    ans += 1

print(ans)

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
    nfs;
    int m,d;
    cin >> m >> d;
    int i;
    int ans = 0;
    int count=0;

    for(i=1;i<=m;i++)
    {

        int j;
        for(j=22;j<=d;j++)
        {

            if(j%10<2)
            {

                continue;
            }
            int k = (j%10) * (j/10);
            if(k==i)
            {

                count++;
            }
        }
    }
    cout << count << endl;

    return 0;

}


Measured memory_bytes: 256
ans = 0

s = input()
l = []
for i in s:
  l.append(i)
  l.append('x')
l.pop()

n = len(s)

def solve(k):
  global ans, n, l
  if k >= n+n-2:
    cur = ''
    for i in range(len(l)):
      if i % 2 == 1 and l[i] == '+':
        ans += int(cur)
        cur = ''
      elif i % 2 == 0:
        cur += l[i]
    ans += int(cur)
    return
  
  l[k] = '+'
  solve(k+2)
  l[k] = 'x'
  solve(k+2)

solve(1)

print(ans)

Measured memory_bytes: 3064
line = gets.chomp.split(" ").map(&:to_i)
if line[0] <= line[2]
    begin_a = line[0]
    end_a   = line[1]
    begin_b = line[2]
    end_b   = line[3]
else
    begin_a = line[2]
    end_a   = line[3]
    begin_b = line[0]
    end_b   = line[1]
end

if end_a < begin_b
    time = 0
elsif end_a < end_b
    time = end_a - begin_b
else
    time = end_b - begin_b
end

puts time

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int data[3];
	int a,b,c;
	cin>>a;
	cin>>b;
	if(a>b){
		int temp=a;
		a=b;
		b=temp;
	}
	cin>>c;
	if(a>c){
		cout<<(a-c)+(b-a)<<endl;
	}else if(b>c){
		cout<<(c-a)+(b-c)<<endl;
	}else{
		cout<<(b-a)+(c-b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256