akhauriyash/Code-Regression huggingface dataset:
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, C);
    IN(ll, K);
    AIN(ll, T, N);
    SORT(T);
    ll x = C;
    ll t = 0;
    ll ans = 0;
    REP(i, N)
    {
        if (x < C and T[i] <= t + K)
        {
            ++x;
        }
        else
        {
            ++ans;
            x = 1;
            t = T[i];
        }
    }
    OUT(ans);
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define SEKAI_NO_OWARI return 0;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void solve() {
	string s;
	int k;
	priority_queue<int> que;

	for (;;) {
		cin >> s;
		if (s[0] == 'e' && s[1] == 'n') break;

		if (s[0] == 'i') {
			cin >> k;
			que.push(k);
		}
		else {
			cout << que.top() << "\n";
			que.pop();
		}
	}
}

int main(void) {
	//INIT
	solve();
	SEKAI_NO_OWARI
}


Measured memory_bytes: 6884
#include <cstdio>
#include <algorithm>

int value(int p, int x)
{
  return (p * (100 + x)) / 100;
}

int main(void)
{
  int x, y, s;

  for( ; ; ){
    scanf("%d %d %d", &x, &y, &s);
    if(x + y + s == 0) break;

    int ans = 0;
    for(int i = 1;i <= s; i++){
      for(int j = 1;i + j <= s; j++){
        if(value(i, x) + value(j, x) == s)
          ans = std::max(ans, value(i, y) + value(j, y));
      }
    }

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


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

struct UnionFind {
  vector< int > data;
 //全要素を-1で初期化
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y]; //date[x] = -(rank)
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> X(M),Y(M),Z(M);
    UnionFind uf(N);
    for(int i=0;i<M;++i){
        cin >> X[i] >> Y[i] >> Z[i];
        uf.unite(X[i]-1,Y[i]-1);
    }
    set<ll> st;
    for(int i=0;i<N;++i){
        st.insert(uf.find(i));
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 7680
#include "stdio.h"
#include "math.h"

int main(){
 long int n;
  scanf("%ld",&n);
  for(int i=0;i<(int)sqrt(n);i++){
   if(n%((int)sqrt(n)-i)==0){
     printf("%ld",(int)sqrt(n)-i+n/((int)sqrt(n)-i)-2);
     break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
t = gets.chomp.split("")

maxfit = [0]
s.length.times do |si|
  tempcnt = 0
  break if s.length < si + t.length
  t.length.times do |ti|
    break if si >= s.length
    if s[si] == t[ti]
      tempcnt += 1
    end
    si += 1
  end
  maxfit.push(tempcnt)
end
p t.length - maxfit.max

Measured memory_bytes: 14188
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));

	ll ans = 1;
	ld m = 1;
	rep(i, n){
		ans *= a[i];
		m *= a[i];
		if(m > 2e18){
			co(-1);
			return 0;
		}
	}

	if (ans > 1000000000000000000) co(-1);
	else
		co(ans);

	return 0;
}


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

int main(void){
    int N, D, Xbuf, Ybuf;
    cin >> N >> D;
    int res = 0;
    for(int i=0; i<N; i++){
        cin >> Xbuf >> Ybuf;
        if((long long)Xbuf * Xbuf + (long long)Ybuf * Ybuf <= (long long)D * D)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#abc131d
import sys

n=int(raw_input())
ab=[]
for i in xrange(n):
 a,b=map(int,raw_input().split())
 ab.append([a,b])
ab=sorted(ab,key=lambda x:x[1])
acm=0
for i in xrange(n):
 acm+=ab[i][0]
 if acm>ab[i][1]:
  print 'No'
  sys.exit()
print 'Yes'


Measured memory_bytes: 41912
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] dimensions = new int[n+1];
        dimensions[0] = in.nextInt();
        for (int i = 1; i < n; i++) {
            dimensions[i] = in.nextInt();
            in.nextInt();
        }
        dimensions[n] = in.nextInt();
        in.close();

        int[][] costs = new int[n][n];

        for (int lenMinusOne = 1; lenMinusOne < n; lenMinusOne++) {
            for (int i = 0; i < n - lenMinusOne; i++) {
                int j = i + lenMinusOne;
                costs[i][j] = Integer.MAX_VALUE;
                for (int k = i; k < j; k++) {
                    int cost = costs[i][k] + costs[k+1][j] + dimensions[i]*dimensions[k+1]*dimensions[j+1];
                    if (cost < costs[i][j]) {
                        costs[i][j] = cost;
                    }
                }
            }
        }
        System.out.println(costs[0][costs[0].length-1]);
    }
}


Measured memory_bytes: 26416
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

X,A = map(int,input().split())
if X < A:
    ans = 0
else:
    ans = 10

print(ans)


Measured memory_bytes: 7872
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m,type;
int x[100005],y[100005];
bitset<50005>can[50005],cmp;
bool reach[50005];
char res[100005];
void solve1(){
	for(int i=1;i<=n;i++)can[i].set(i),cmp.set(i);
	for(int i=1;i<=m;i++){
		can[x[i]]|=can[y[i]];
		can[y[i]]|=can[x[i]];
	}
	int ans=-1;
	for(int i=1;i<=n;i++){
		if(can[i]==cmp){
			ans=i;
		}
	}
	cerr<<ans<<endl;
	if(ans==-1){
		puts("-1");
		return;
	}
	reach[ans]=1;
	for(int i=m;i>=1;i--){
		if(reach[x[i]]){
			reach[y[i]]=1;
			res[i]='^';
		}else{
			if(reach[y[i]])reach[x[i]]=1;
			res[i]='v';
		}
	}
	for(int i=1;i<=m;i++)cout<<res[i];
}
struct state{
	pair<int,int>p;int lst;int single;
	void next(int x,int y,int id){
		if(make_pair(x,y)==p){
			res[lst]='^';
			lst=id;
			return;
		}
		if(p.first==x||p.first==y){
			res[lst]='v';
			lst=id;
			p=make_pair(x,y);single=6-x-y;
		}else{
			res[lst]='^';
			lst=id;
			p=make_pair(x,y);single=6-x-y;
		}
	}
}S;
void solve2(){
	if(n==2&&m){
		puts("-1");
		return;
	}
	for(int i=1;i<=m;i++){
		if(y[i]<=3){
			res[i]='?';
		}else{
			res[i]='^';
		}
	}
	for(int i=1;i<=m;i++){
		if(y[i]<=3){
			S.next(x[i],y[i],i);
		}
	}
	for(int i=1;i<=m;i++){
		if(res[i]=='?')res[i]='^';
		cout<<res[i];
	}
}
int main(){
	cin>>n>>m>>type;
	for(int i=1;i<=m;i++)cin>>x[i]>>y[i];
	if(type==1){
		solve1();
	}else{
		solve2(); 
	}
	return 0;
}

Measured memory_bytes: 306816
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    REP(i,k,n) {
        if (a[i] > a[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4840
S = gets.chomp!
count = 0
S.each_char.with_index do |c, i|
  if c == 'R'
    count = 1 if count.zero?
      temp_count = 1
      while S[i+1] == 'R'
        temp_count += 1
        i += 1
      end

    if count < temp_count
      count = temp_count
    end
  end
end

puts count


Measured memory_bytes: 14276
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	int A[100000], B[100000], C[100000];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	for(int i = 0; i < N; i++){
		cin >> B[i];
	}
	for(int i = 0; i < N; i++){
		cin >> C[i];
	}
	sort(A, A + N); sort(B, B + N); sort(C, C + N);
	ll ans = 0;
	for(int i = 0; i < N; i++){
		int* mid = lower_bound(A, A + N, B[i]);
		ll idx = distance(A, mid);
		int* mid_ = upper_bound(C, C + N, B[i]);
		ll idx_ = distance(C, mid_);
		ans += idx * (N - idx_);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define LL long long
#define bin(i) ((LL)1LL<<(i))
using namespace std;
const LL N = 200010;
inline LL read()
{
  LL p=0; LL f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}
LL a[N]; LL b[N]; LL n; LL c[N],d[N]; LL ans = 0;
int main()
{
  n=read(); for(LL i=1;i<=n;i++) a[i] = read();
  for(LL i=1;i<=n;i++) b[i] = read();

  for(LL i=0;i<=29;i++)
  {
    for(LL j=0;j<4;j++) c[j] = d[j] = 0;
    for(LL j=1;j<=n;j++) c[j] = a[j] % bin(i+1);
    for(LL j=1;j<=n;j++) d[j] = b[j] % bin(i+1);
    sort(c+1,c+n+1); sort(d+1,d+n+1); LL s = 0;
    for(LL j=1;j<=n;j++)
    {
      LL x = c[j]; LL ss = 0; LL l,r;
      if(x<bin(i+1))
      {
        l = lower_bound(d+1,d+n+1,bin(i) - x) - d;
        r = upper_bound(d+1,d+n+1,bin(i+1) - 1 - x) - (d+1);
        ss += r-l+1;
      }

      l = lower_bound(d+1,d+n+1,bin(i) + bin(i+1) - x) - d;
      r = upper_bound(d+1,d+n+1,bin(i+2) - 1 -x) - (d+1);

      ss += r-l+1;
      if(ss&1) s=(s+1)&1;
    }
    ans += s * bin(i);
  }
  return printf("%lld\n",ans),0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") puts("No");
    else puts("Yes");
    return 0;
}

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

int main(){
  long n;
  string s;
  cin >> n >> s;
  if(n%2==1)cout << "No";
  else{
  	if(s.substr(0,n/2)==s.substr(n/2))cout << "Yes";
    else cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
/*
 * 归并排序
 */

#include <cstdio>
using namespace std;
#define  MAX 500000
#define  SENTINEl 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n, int left ,int mid, int right){//merge负责整合
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++) L[i] = A[left + i];
    for(int i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEl;
    int i =0, j =0 ;
    for(int k= left; k<right; k++){
        cnt++;
        if(L[i] <= R[j]) A[k] = L[i++];
        else A[k] = R[j++];
    }
}


void mergeSort(int A[],int n, int left, int right){//merfeSort负责分割
    if(left+1<right){
        int mid = (left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}



int main()
{
    int A[MAX],n,i;
    cnt =0 ;
    scanf("%d",&n);
    for( i=0; i<n;i++) scanf("%d",&A[i]);

    mergeSort(A,n,0,n);

    for(i=0;i<n; i++){
        if(i)  printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);
    return 0;
}








Measured memory_bytes: 6580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>

using namespace std;

struct Point
{
	int x, y, i;
};

bool cmpX(Point& p1, Point& p2)
{
    return p1.x < p2.x;
}

bool cmpY(Point& p1, Point& p2)
{
	return p1.y < p2.y;
}

vector<int> visited;
vector<Point> points, points2;
vector< vector< pair<int, int> > > graph;
priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > pq;

int main()
{
    int N;
    cin >> N;
	points.resize(N);
	visited.assign(N, 0);
	graph.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> points[i].x >> points[i].y;
        points[i].i = i;
    }

    points2 = points;
    sort(points2.begin(), points2.end(), cmpX);
    for (int i = 1; i < points2.size(); ++i) {
		int dist = points2[i].x - points2[i-1].x;
		graph[ points2[i].i ].push_back(make_pair(dist, points2[i-1].i));
		graph[ points2[i-1].i ].push_back(make_pair(dist, points2[i].i));
    }

    points2 = points;
    sort(points2.begin(), points2.end(), cmpY);
    for (int i = 1; i < points2.size(); ++i) {
		int dist = points2[i].y - points2[i-1].y;
		graph[ points2[i].i ].push_back(make_pair(dist, points2[i-1].i));
		graph[ points2[i-1].i ].push_back(make_pair(dist, points2[i].i));
    }

    long long ans = 0;
    pq.push(make_pair(0, 0));
    while (!pq.empty()) {
        pair<int, int> edge = pq.top();
//        cout << edge.first << ' ' << edge.second << endl;
        pq.pop();


		int u = edge.second;
		if (visited[u]) continue;
		visited[u] = 1;
        ans += edge.first;


		for (int i = 0; i < graph[u].size(); ++i) {
			pair<int, int> p = graph[u][i];
            pq.push(p);
		}
    }

    cout << ans << endl;
}


Measured memory_bytes: 13560
#include<stdio.h>

int main(){
int  n,i;
long M=0,A=0,R=0,C=0,H=0;
long long ans=0;
char na[100000][11];
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%s",na[i]);
for(i=0;i<n;i++){
switch(na[i][0]){
case 'M':M++;break;
case 'A':A++;break;
case 'R':R++;break;
case 'C':C++;break;
case 'H':H++;break;
}
}
ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
printf("%lld\n",ans);
return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    vector<i64> A(N);
    vector<char> op(N);
    op[0]='+';
    cin >> A[0];
    rep(i,1,N) cin >> op[i] >> A[i];

    static i64 memo[100001][3];
    static bool done[100001][3];
    fill_n((i64*)memo,100001*3,-inf64);
    fill_n((bool*)done,100001*3,false);
    function<i64(int,int)> rec=[&](int i,int j){
        auto &res=memo[i][j];
        if(done[i][j]) return res;
        done[i][j]=true;
        if(i==N) return res=0;
        int s=op[i]=='-';
        rep(j_,0,j+1){
            res=max(res,((j_+s)%2==0?1:-1)*A[i]+rec(i+1,j_));
            if(s) res=max(res,((j_+s)%2==0?1:-1)*A[i]+rec(i+1,(j_+1==3?1:j_+1)));
        }
        return res;
    };
    cout << rec(0,0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
struct point
{
  double x, y, val;
  point() {}
  point(double x, double y, double val) : x(x), y(y), val(val){};
  point(double x, double y) : x(x), y(y), val(0){};
};
struct vec
{
  double x, y;
  vec() {}
  vec(double x, double y) : x(x), y(y){};
  vec(point a, point b) : x(b.x - a.x), y(b.y - a.y){};
  double size() { return sqrt(x * x + y * y); };
};
vector<point> circle_intersection(point c1,double r1,point c2,double r2){
  vector<point> res;
  if(r1+r2==vec(c1,c2).size()||fabs(r1-r2)==vec(c1,c2).size()){
    point p(vec(c1,c2).x*r1/vec(c1,c2).size()+c1.x,vec(c1,c2).y*r1/vec(c1,c2).size()+c1.y);
    res.push_back(p);
  }
  else if(r1+r2>vec(c1,c2).size()&&fabs(r1-r2)<vec(c1,c2).size()){
    double di=vec(c1,c2).size()*vec(c1,c2).size();
    double li=(di+r1*r1-r2*r2)/2;
    point p1(c1.x+(li*(-c1.x+c2.x)+(-c1.y+c2.y)*sqrt(di*r1*r1-li*li))/di,c1.y+(li*(-c1.y+c2.y)-(-c1.x+c2.x)*sqrt(di*r1*r1-li*li))/di);
    res.push_back(p1);
    point p2(c1.x+(li*(-c1.x+c2.x)-(-c1.y+c2.y)*sqrt(di*r1*r1-li*li))/di,c1.y+(li*(-c1.y+c2.y)+(-c1.x+c2.x)*sqrt(di*r1*r1-li*li))/di);
    res.push_back(p2);
  }
  return res;
}
int main()
{
double a , b , c ;
cin >> a >> b >> c ;
double d , e , f ;
cin >> d >> e >> f ;
point p(a,b);
point q(d,e);

auto r=circle_intersection(p,c,q,f);
if(r.size()==1)cout <<fixed<<setprecision(12)<< r[0].x << ' ' <<r[0].y<<' '<< r[0].x << ' ' <<r[0].y<<endl;
else {
  if(r[0].x>r[1].x)swap(r[0],r[1]);
  if(r[0].x==r[1].x&&r[0].y>r[1].y)swap(r[0],r[1]);
  cout <<fixed<<setprecision(12)<< r[0].x << ' ' <<r[0].y <<' ' << r[1].x << ' ' <<r[1].y<<endl;
}
return 0;
}


Measured memory_bytes: 3296
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  ll n,p;
  string s;
  cin>>n>>p>>s;
 
  if(p==2){
    vector<ll>two(n);
    ll ans=0;
    rep(i,n){
      
      if((s[i]-'0')%2==0)ans+=i+1;
    }
    cout<<ans<<endl;
    return 0;
  }
  if(p==5){
     ll ans=0;
    rep(i,n){
     
      if((s[i]-'0')%5==0)ans+=i+1;
    }
    cout<<ans<<endl;
    return 0;
  }
  vector<ll>ten(n);
  ten[0]=1;
  for(ll i=1;i<n;i++){
    ten[i]=ten[i-1]*10%p;
  }
  vector<ll>MOD(n);
  MOD[0]=(s[n-1]-'0')%p;
  for(ll i=1;i<n;i++){
    MOD[i]=(ten[i]*(s[n-1-i]-'0')+MOD[i-1])%p;
  }
  vector<ll>vec(p);
  for(ll i=0;i<n;i++){
    vec[MOD[i]]++;
  }
  ll ans=0;
  ans+=vec[0];
  for(ll i=0;i<p;i++){
    if(vec[i]==0)continue;
    else ans+=vec[i]*(vec[i]-1)/2;
  }
  cout<<ans<<endl;
}
           

  
  
      


Measured memory_bytes: 3716
X = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)

Measured memory_bytes: 9184
#include <stdio.h>

int main(void) {
    int a,b,t,ans=0;
    scanf("%d%d%d",&a,&b,&t);
    for (int i=1; i<=t; i++) {
        if (i%a==0) {
            ans+=b;
        }
    }
    printf("%d\n",ans);
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

    int N;
    string S;
    cin >> N;
    cin >> S;

    ll count[26];
    REP(i, 26) count[i] = 0;
    REP(i, N) {
        count[S[i] - 'a']++;
    }
    ll result = 1;
    REP(i, 26) {
        result = (result * (count[i] + 1)) % MOD;
    }
    result--;
    cout << result << endl;
    


    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
int main(){
    int n;
    long long sum = 0;
    int i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int max=a[0];
    int min=a[0];
    for(i=0;i<n;i++){
        if(max<a[i]){
            max=a[i];
        }
        if(min>a[i]){
            min=a[i];
        }
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;
int main(){
    int x1,y1,x2,y2;
    cin >>x1 >> y1 >> x2 >> y2;
    int gapx = x2 - x1;
    int gapy = y2 - y1;
    cout << x2-gapy << " " << y2+gapx << " " << x1-gapy << " " << y1+gapx; 
}


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

int main(){
  int a, sum = 0;
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;

  for (int i=0; cin >> ch; i++){
    if (ch == '\\') S1.push(i);
    else if (ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      a = i - j;
      while (S2.size() > 0 && S2.top().first > j){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while(S2.size() > 0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();

  for (int i=0; i<ans.size(); i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s, t;
map<char, char> mpa, mpb;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s >> t;

  bool f = true;
  REP(i, s.size()) {
    auto ita = mpa.find(t[i]);
    auto itb = mpb.find(s[i]);
    if(ita != mpa.end()) {
      if(ita->second != s[i]) {
        f = false;
        break;
      }
    } else {
      mpa[t[i]] = s[i];
    }

    if(itb != mpb.end()) {
      if(itb->second != t[i]) {
        f = false;
        break;
      }
    } else {
      mpb[s[i]] = t[i];
    }
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*d,a*c,b*c,b*d})<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main(){
    	int a, b;
    	scanf("%d %d", &a, &b);
    	int cur = 0;
    	if (b == 1){
			puts("0");
			return 0;
    	}
    	for (int i = 1; i <= 20; i++){
			cur += a;
			if (cur >= b){
				printf("%d\n", i);
				return 0;
			}
			cur--;
    	}
    	return 0;
    }


Measured memory_bytes: 256
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R

k = inn()
s = ins()
n = len(s)
factinit(n+k,R)
sm = 0
for m in range(n,n+k+1):
    x = comb(m-1,n-1,R)
    y = pow(25,m-n,R)
    z = pow(26,n+k-m,R)
    sm = (sm+x*y*z)%R
    #ddprint(f"{x=} {y=} {z=} {sm=}")
print(sm)


Measured memory_bytes: 101700
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    char ch;
    cin>>ch;
    if(ch=='A')
        cout<<"T"<<endl;
   else if(ch=='T')
        cout<<"A"<<endl;
   else  if(ch=='C')
        cout<<"G"<<endl;
 else  if(ch=='G')
        cout<<"C"<<endl;
    return 0;
}


Measured memory_bytes: 3568
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
 
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
 
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
 
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]

    def compare(self, label):
        for op in 'EEENEEENEEESEEESEEENEEEN':
            if self.get_label() == label:
                return True
            self.roll(op)
        else:
            return False
  
if __name__=='__main__':
    n = int(input())
    L = []
    for i in range(n):
        label = list(map(int,input().split()))
        for d in L:
            if d.compare(label): break
        else:
            L.append(dice(label))
            continue
        print('No')
        break
    else:
        print('Yes')

Measured memory_bytes: 7796
T = input()
S = [int(x) for x in list(str(T))]

if len(S) == 1:
    print(0)
elif len(S) == 2:
    print(1 - (S[0] + S[1]) % 2)
else:
    n = len(S)
    S_1 = [0] + S
    S_2 = [1] + S
    num_1 = 0
    num_2 = 0

    for i in range(n):
        if int(S_1[i]) == int(S_1[i+1]) == 0:
            S_1[i+1] = 1
            num_1 += 1
        elif S_1[i] == S_1[i+1] == 1:
            S_1[i+1] = 0
            num_1 += 1
    
    for i in range(n):
        if S_2[i] == S_2[i+1] == 0:
            S_2[i+1] = 1
            num_2 += 1
        elif S_2[i] == S_2[i+1] == 1:
            S_2[i+1] = 0
            num_2 += 1       
    print(min(num_1, num_2))

Measured memory_bytes: 5484
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,sum1,sum2,a[110];
int main(){
	scanf("%d",&n);
	sum1=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum1+=a[i];
	}
	scanf("%d",&m);
	sum2=sum1;
	while(m--){
		int p,x;
		scanf("%d%d",&p,&x);
		if(x>=a[p-1]) sum1+=x-a[p-1];
		else sum1-=a[p-1]-x;
		printf("%d\n",sum1);
		sum1=sum2;
	}
	return 0;
}

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

n, a, b, c = map(int, input().split())
count = {
    'A': a,
    'B': b,
    'C': c
}
queries = []
for _ in range(n):
    query = tuple(input().replace('\n', ''))
    queries.append(query)


def solve(plus, minus):
    count[plus] += 1
    count[minus] -= 1
    ans.append(plus)


ans = []
for idx, (x, y) in enumerate(queries):
    if count[x] == count[y] == 0:
        print('No')
        exit()

    if count[x] == count[y] == 1:
        if idx == n-1:
            solve(x, y)
            break

        nex = queries[idx+1]
        if x in nex:
            solve(x, y)
        else:
            solve(y, x)

    elif count[x] >= count[y]:
        solve(y, x)

    else:
        solve(x, y)

print('Yes')
for c in ans:
    print(c)


Measured memory_bytes: 16984
S=input()
p=S[0]
q=S[1]
r=S[2]

if p == 'R' and q=='R' and r=='R':
    print(3)
elif (p=='R' and q=='R') or  (q=='R' and r=='R') :
    print(2)
elif p=='R'or q=='R' or r=='R':
    print(1)
else:
    print(0)

Measured memory_bytes: 9076
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  // val a = new Array[Int](N)

  // 
  // val a, b = in.next().toInt
  // val s = in.next()

  val N = in.next().toLong


  //
  val M = N-1
  val ans = (M * (M+1)) / 2
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

#define ll long long
ll mod = 1e9+7;

int main() {
	ll NumSum = 0;
  
  	ll N, k;
  	cin >> N >> k;
  	//cout << N << " " << k <<endl;
  	
  	for(ll i=k;i<=N+1;i++){
      	ll a = ((N+N-(i-1))*i/2);
        ll b = (((0+i-1)*i/2));
      	//cout << a << " " << b << " " << i << endl;
    	NumSum += a - b + 1;
        NumSum %= mod;
      	//cout << NumSum << endl;
    }
  	cout << NumSum << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == (b + c) || b == (c + a) || c == (a + b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second
#define pb push_back
#define sz(x) ((int)(x).size())

inline int in(){ int x, y; y = scanf("%d", &x); return x; }

const int N = 100*1000 + 5;

int d[N], cnt[N];
vector <int> adj[N];

int main(){
	int n = in(), m = in();
	for (int i = 0; i < m; i++){
		int u = in()-1, v = in()-1;
		adj[u].pb(v);
		adj[v].pb(u);
		d[u]++;
		d[v]++;
	}
	for (int i = 0; i < n; i++){
		if (d[i] == 0 || d[i]%2 == 1)
			return (cout << "No\n"), 0;
		cnt[d[i]]++;
	}
	if (cnt[2] + cnt[4] == n && cnt[4] <= 2){
		if (cnt[4] == 2){
			int u, v;
			for (u = 0; d[u] != 4; u++);
			for (v = 0; d[v] != 4 || v == u; v++);
			for (auto w : adj[u]){
				int x = w, par = u;
				while (x != u && x != v){
					for (auto nei : adj[x])
						if (nei != par){
							par = x;
							x = nei;
							break;
						}
				}
				if (x == u)
					return (cout << "Yes\n"), 0;
			}
		}
		return (cout << "No\n"), 0;
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 6144
def salesman(T, now_v, dp, graph, v):
    if dp[T][now_v] >= 0:
        return dp[T][now_v]
    if T == (1 << v) - 1 and now_v == 0:
        dp[T][now_v] = 0
        return dp[T][now_v]
    res = 10 ** 7
    for i in range(v):
        if not ((T >> i) & 1):
            res = min(res, salesman(T | (1 << i), i, dp, graph, v) + graph[now_v][i])
    dp[T][now_v] = res
    return dp[T][now_v]


def main():
    v, e = map(int, input().split())
    INF = 10 ** 7
    graph = [[INF for i in range(v)] for j in range(v)]
    for i in range(e):
        s, t, d = map(int, input().split())
        graph[s][t] = d
    dp = []
    for i in range(1 << v):
        dp.append([])
        for j in range(v):
            dp[i].append(-1)
    salesman(0, 0, dp, graph, v)
    if dp[0][0] >= INF:
        print(-1)
    else:
        print(dp[0][0])
    
    




if __name__ == '__main__':
    main()



Measured memory_bytes: 15704
while true
  h, w = gets.chomp.split(/\s/).map(&:to_i)
  break if h == 0 && w == 0
  pattern = %w(# .)
  h.times do |i|
    puts (pattern * (w / 2 + 1))[0...w].join("")
    pattern.reverse!
  end
  puts ""
end

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

int main() {
    ll a, b, k;
    
    cin >> a >> b >> k;
    /*
    rep(i, k){
        if(a > 0){
            a--;
        } else if(b > 0){
            b--;
        } else{

        }
    }*/
    
    if(a-k > 0){
        cout << a-k << " " << b;
    } else if(b- (k-a) > 0){
        cout << 0 << " " << b-(k-a);
    } else {
        cout << 0 << " " << 0;
    }
    
    //cout << a << " " << b;
    
    return 0;
}




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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n, m;
char a[1001][1001];
int ds[1001][1001];
queue < pair < int , int > > q;
vector < pair < int, int > > to;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            ds[i][j] = 1e9;
            if(a[i][j] == '#'){
                ds[i][j] = 0;
                q.push({i, j});
            }
        }
    }
    to.push_back({1, 0});
    to.push_back({-1, 0});
    to.push_back({0, 1});
    to.push_back({0, -1});
    while(!q.empty()){
        int v1 = q.front().first, v2 = q.front().second;
        q.pop();
        for(pair < int , int > i : to){
            int x = v1 + i.first, y = v2 + i.second;
            if(1 <= x && x <= n){
                if(1 <= y && y <= m){
                    if(ds[x][y] > ds[v1][v2] + 1){
                        ds[x][y] = ds[v1][v2] + 1;
                        q.push({x, y});
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            ans = max(ans, ds[i][j]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 112;
const double pi = 3.14159265359;
const double eps = 0.00000001;

int w[MAXN], v[MAXN];
ll dp[112345];

int main() {
    int n, S;
    scanf("%d %d", &n, &S);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &w[i], &v[i]);
    }
    memset(dp, -1, sizeof dp);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = S; j >= w[i]; --j) if (dp[j - w[i]] != -1) {
            dp[j] = max(dp[j], dp[j - w[i]] + (ll)v[i]);
        }
    }
    ll ans = 0;
    for (int i = 1; i <= S; ++i) {
        ans = max(ans, dp[i]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1152
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let N = read int
    let A = reada int
    let mutable ok = false
    let memo = SortedDictionary<int, int>()
    for a in A do
        if memo.ContainsKey(a) then memo.[a] <- memo.[a] + 1 else memo.Add(a, 1)

    if memo.Count = 3 && N%3=0 then 
        let ok1 = 
            memo
            |> Seq.forall (fun x -> x.Value = N/3)

        let ok2 = 
            memo
            |> Seq.map (fun kv -> kv.Key)
            |> Seq.reduce (^^^)
            |> fun x -> x = 0
        ok <- ok1 && ok2
    else if memo.Count = 2 && N%3=0 then 
        let a = Array.ofSeq memo |> Array.sortBy (fun x -> x.Key)
        if a.[0].Key = 0 && a.[0].Value = N/3 && a.[1].Value = N/3*2 then ok <- true
    else if memo.Count = 1 && memo.ContainsKey(0) then ok <- true

    if ok then "Yes" else "No"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 23904
#include<stdio.h>

int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}

int mem[524288]={0};
int f(int x){
  if(x==0){return 0;}
  if(mem[x]!=0){return mem[x];}
  int pc=dsumb(x,2);
  mem[x]=f(x%pc)+1;
  return mem[x];
}

int main(){
  int l,i,j,c=0,pl,mi,kpl,kmi;
  int res[524288];
  char s[524288];
  scanf("%d%s",&l,s);
  for(i=0;i<l;i++){
    if(s[i]=='1'){c++;}
  }
  pl=0;mi=0;
  kpl=1;kmi=1;
  for(i=l-1;i>=0;i--){
    pl+=(s[i]-'0')*kpl;pl%=(c+1);
    kpl*=2;kpl%=(c+1);
    if(c>1){
      mi+=(s[i]-'0')*kmi;mi%=(c-1);
      kmi*=2;kmi%=(c-1);
    }
  }
  kpl=1;kmi=1;
  for(i=l-1;i>=0;i--){
    if(s[i]=='0'){
      res[i]=f((pl+kpl)%(c+1))+1;
    }
    else{
      if(c==1){res[i]=0;}
      else{res[i]=f(((c-1)+mi-kmi)%(c-1))+1;}
    }
    kpl*=2;kpl%=(c+1);
    if(c>1){
      kmi*=2;kmi%=(c-1);
    }
  }
  for(i=0;i<l;i++){
    printf("%d\n",res[i]);
  }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool ch1(string s) {
    string t = s;
    reverse(ALL(t));
    return (s == t);
}

bool ch2(string s) {
    int n = s.size();
    string t = s.substr(0, (n - 1) / 2);
    string t2 = t;
    reverse(ALL(t2));
    return (t == t2);
}

bool ch3(string s) {
    int n = s.size();
    string t = s.substr((n + 3) / 2 - 1, (n - 1) / 2);
    string t2 = t;
    reverse(ALL(t2));
    return (t == t2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ok = ch1(s) && ch2(s) && ch3(s);
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int digit(int num){
	int i = 1;
	while(num){
		num /=10;
		i *= 10;
	}
	return i;
}
int main(){
	int a,b,c,tmp;
	cin>>a>>b;
	c = a*digit(b)+b;
	tmp = sqrt(c);
	if(c==tmp*tmp) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    for(int i=0;i<B-1;i++){
        if(A%B*(i+1)%B==C){cout<<"YES"<<endl;exit(0);}
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,y;cin>>n>>y;
  bool ok=true;
  rep(i,0,n+1){
    rep(j,0,n-i+1){
      if(10000*i+5000*j+1000*(n-i-j)==y){
        ok=false;
        cout<<i<<" "<<j<<" "<<n-i-j<<endl;
        break;
      }
    }
    if(!ok){break;}
  }
  if(ok){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }
}







Measured memory_bytes: 3648
#abc112b

N,T=map(int,raw_input().split())
ct=[]
for i in xrange(N):
 c,t=map(int,raw_input().split())
 if t<=T:
  ct.append(c)
ct.sort()
if ct==[]:
 print 'TLE'
else:
 print ct[0]


Measured memory_bytes: 2568