akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	
	rep(i, S.size()) {
		S[i] = ((S[i]-'A') + N)%26 + 'A';
	}

	cout << S << endl;

	

}

Measured memory_bytes: 256
//-----------------------
// author : xyqkoala
// time : 2020-08-10
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


struct TriNode{
	unordered_map<char,int> t;
	bool f;
	unordered_map<char,TriNode *> children;
	TriNode(){
		f = false;
	}
};


struct Trie{
	TriNode *root;
	Trie(){
		root = new TriNode();
	}
};

void solve(){
	int n;
	cin>>n;
	vector<string> t(n);
	for(int i=0;i<n;i++) cin>>t[i];

	sort(t.begin(),t.end(),[](string &a,string &b){return a.size() < b.size();});
	vector<vector<int>> idx(n,vector<int>(26,MOD));
	for(int i=0;i<n;i++){
		int tn = t[i].size();
		for(int j=0;j<tn;j++){
			idx[i][t[i][j]-'a'] = min(idx[i][t[i][j]-'a'],j);
		}
	}

	auto tree = Trie();
	LL res = 0;
	for(int i=0;i<n;i++){
		int tn = t[i].size();
		auto cur = tree.root;
		for(int j=(tn-1);j>0;j--){
			for(auto item:cur->t){
					char cc = item.first;
					int cnt = item.second;
					if(idx[i][cc-'a']<=j){
						res += cnt;
					}
			}
			auto p = cur->children[t[i][j]];
			if(p==nullptr){
				cur->children[t[i][j]] = new TriNode();
				cur = cur->children[t[i][j]];
				continue;
			}else{
				cur = cur->children[t[i][j]];
			}
		}
		if(cur->children[t[i][0]] == nullptr){
				cur->children[t[i][0]] = new TriNode();
			}
			cur->t[t[i][0]]++;
	}

	cout<<res<<endl;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = INF;
	for (int i = -100; i <= 100; ++i) {
		ll cost = 0;
		rep(j, n) {
			cost += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//#include <math.h>

ll champ=0;
ll n,m,q;
vl a(50),b(50),c(50),d(50);
void calc(int i,int A[11]){

	if(i==n){
		ll sum=0;
		rep(k,0,q){
			if((A[b[k]-1]-A[a[k]-1])==c[k]) sum+=d[k];
		}
//		rep(p,0,n)cout<<A[p]<<endl;
//		cout<<"sum="<<sum<<endl;
		if(sum>champ) champ=sum;
		return;
	}
	else{
		rep(j,1,m+1){
			if(A[i-1]<=j){
				A[i]=j;
				calc(i+1,A);
			}
		}
	}
	return;
}

signed main(){
	acc_io;
	cin>>n>>m>>q;
	rep(i,0,q){
		cin>>a[i];
		cin>>b[i];
		cin>>c[i];
		cin>>d[i];
	}
	int tmp[11]={0};
	rep(i,1,m+1){
		tmp[0]=i;
		calc(1,tmp);
	}

	cout<<champ<<endl;
	return 0;
}


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

int main() {
	long long a, b, c, k;
	long long ans;

	cin >> a >> b >> c >> k;

	if (k % 2 == 0) {
		ans = a - b;
	}
	else {
		ans = b - a;
	}

	if (abs(ans) > 10e18) {
		cout << "Unfair" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

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

unsigned int dp[50001][20];

int main(void) {
  int n, m;
  cin >> n >> m;
  auto c = vector<int>(m);
  for (int i = 0; i < m; i++) cin >> c[i];
  sort(c.begin(), c.end());
  for (int i = 0; i < m; i++) dp[0][i] = 0;
  for (int i = 0; i <= n; i++) dp[i][0] = i;
  for (int i = 1; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      dp[j][i] = j >= c[i] ? min(dp[j-c[i]][i] + 1, dp[j][i-1]) : dp[j][i-1];
    }
  }
  cout << dp[n][m-1] << endl;
}



Measured memory_bytes: 7036
a = int(input())
A = []
for i in range(a):
    x,L = map(int,input().split())
    A.append([x+L,x,L])
A.sort()
# print(l)
res = 1
t = A[0]
for i in range(1,a):
    l = A[i]
    # print(t,l)
    if t[0] < l[0] :
        if l[1]-l[2]<t[0]<l[0]:continue
        else:
            res+=1
            t = l
    elif t[0] > l[0]: 
        if l[1]-l[2]<t[1]-t[2]<l[0]:continue
        else:
            res+=1
            t = l
print(res)


Measured memory_bytes: 23244
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define eps 1e-8
int n,k,a[200005];
int main()
{  cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   int ans=0;
   sort(a+1,a+1+n);
   for(int i=1;i<=k;i++)ans+=a[i];
   cout<<ans;
}

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

class WeightedUnionfind:

    __slots__ = ['nodes','diff_weight']

    def __init__(self, n):
        self.nodes = [-1]*n
        self.diff_weight = [0]*n

    def root(self, x):
        if self.nodes[x] < 0:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.diff_weight[x] += self.diff_weight[self.nodes[x]]
            self.nodes[x] = root_x
            return root_x

    def unite(self, x, y, w=0):
        w += self.weight(x); w -= self.weight(y)
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
        if rank_x < rank_y:
            x, y = y, x; w = -w
        if rank_x == rank_y:
            self.nodes[x] -= 1
        self.nodes[y] = x
        self.diff_weight[y] = w

    def weight(self, x):
        self.root(x)
        return self.diff_weight[x]

    def diff(self, x, y):
        return self.weight(y) - self.weight(x)

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def rank(self, x):
        return -self.nodes[self.root(x)]

N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]
wuf = WeightedUnionfind(N+1)
ans = "Yes"
for L,R,D in info:
    if wuf.same(L,R):
        if wuf.diff(L,R) != D:
            ans = "No"
        else:
            pass
    else:
        wuf.unite(L,R,D)
print(ans)

Measured memory_bytes: 57164
#include <string>
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
map<string, vector<pair<string,int> > >m; //no direction graph
vector<string> memo;

int dfs(string &now, string &goal, int d){
	vector<pair<string,int> >v=m[now];
	for(int i=0;i<v.size();i++){
		if(v[i].first==goal&&v[i].second!=d)return 1;
		if(find(memo.begin(),memo.end(),v[i].first)==memo.end()){
			memo.push_back(v[i].first);
			if(dfs(v[i].first,goal,d-v[i].second))return 1;
		}
	}
	return 0;
}

char b1[17],b2[17];
void main2(int n){
	m.clear();memo.clear();
	int d,e=0;
	for(;n;n--){
		scanf(" 1 %s = 10^%d %s",b1,&d,b2);
		if(!e){
			string s1=b1,s2=b2;
			memo.clear();
			if(dfs(s1,s2,d))e=1;
			m[s1].push_back(make_pair(s2,d));
			m[s2].push_back(make_pair(s1,-d));
		}
	}
	puts(e?"No":"Yes");
}
main(){int n;for(;scanf("%d",&n),n;)main2(n);}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll nc=1744;
bool check(vector<ll> v){
  for(int i=2;i<=9;i++){
    if(v[i]!=v[1]) return false;
  }
  for(int i=11;i<=12;i++){
    if(v[i]!=v[10]) return false;
  }
  for(int i=14;i<=15;i++){
    if(v[i]!=v[13]) return false;
  }
  for(int i=17;i<=18;i++){
    if(v[i]!=v[16]) return false;
  }
  for(int i=20;i<=21;i++){
    if(v[i]!=v[19]) return false;
  }
  for(int i=23;i<=30;i++){
    if(v[i]!=v[22]) return false;
  }
  return true;
}
vector<ll> v_change(vector<ll> v,ll f){
  vector<ll> ret=v;

  if(f==1){
    swap(ret[1],ret[24]);
    swap(ret[4],ret[27]);
    swap(ret[7],ret[30]);
    swap(ret[10],ret[21]);
    swap(ret[16],ret[18]);
  }
  else if(f==2){
    swap(ret[10],ret[12]);
    swap(ret[13],ret[18]);
    swap(ret[7],ret[22]);
    swap(ret[8],ret[23]);
    swap(ret[9],ret[24]);
  }
  else if(f==3){
    swap(ret[12],ret[19]);
    swap(ret[13],ret[15]);
    swap(ret[9],ret[28]);
    swap(ret[6],ret[25]);
    swap(ret[3],ret[22]);
  }
  else if(f==4){
    swap(ret[19],ret[21]);
    swap(ret[15],ret[16]);
    swap(ret[1],ret[28]);
    swap(ret[2],ret[29]);
    swap(ret[3],ret[30]);
  }
  return ret;
}
ll solve(vector<ll> v,ll num){
  if(check(v)) return num;
  if(num>=8) return 1744;
  if(num>=nc) return 1744;
  else{
    ll kans=1744;
    for(int i=1;i<=4;i++){
      vector<ll> kv=v_change(v,i);
      kans=min(kans,solve(kv,num+1));
      if(nc>kans){
        nc=kans;
        //cout<<"NC update:"<<nc<<endl;
      }
    }
    return kans;
  }
}

int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++){
    vector<ll> vec;
    vec.push_back(0);
    nc=1744;
    for(int j=0;j<30;j++){
      ll col;
      cin>>col;
      vec.push_back(col);
    }
    cout<<solve(vec,0)<<endl;
  }
}



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

int main(){
    int S;
    int h;
    int m;
    int s;
    cin >> S;
    s = S % 60;
    m = (S-s) % 3600/60;
    h = (S-S%3600)/3600;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	vi v(5);
	rep(i, 0, 5)
		cin>> v[i];
	rep(i, 0, 5)
		if(v[i] == 0)
			return cout<< i + 1<< "\n", 0;
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (auto i: v) cout << i << ' '
#define vin(v)  for (auto &i: v)    cin >> i

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

ll gcd(ll a, ll b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}

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

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

	ll h, w;
	cin >> h >> w >> k;

	vs v(h);
	vin(v);

	int rows = 1 << h;
	int columns = 1 << w;

	ll ans = 0;

	FOR (i, 0, rows) {
		FOR (j, 0, columns) {
			m = 0;
			FOR (r, 0, h) {
				FOR (c, 0, w) {
					if ((1 << c & j) == 0 && (1 << r & i) == 0) {
						if (v[r][c] == '#')	m++;
					}
				}
			}
			ans += m == k ? 1 : 0;
		}
	}

	print(ans);


    return 0;
}

Measured memory_bytes: 3668
A, B, C, D = map(int, list(input()))

if A-B-C-D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '-', B, '-', C, '-', D, '=7'))
elif A-B-C+D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '-', B, '-', C, '+', D, '=7'))
elif A-B+C-D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '-', B, '+', C, '-', D, '=7'))
elif A-B+C+D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '-', B, '+', C, '+', D, '=7'))
elif A+B-C-D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '+', B, '-', C, '-', D, '=7'))
elif A+B-C+D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '+', B, '-', C, '+', D, '=7'))
elif A+B+C-D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '+', B, '+', C, '-', D, '=7'))
elif A+B+C+D == 7:
    print('{}{}{}{}{}{}{}{}'.format(A, '+', B, '+', C, '+', D, '=7'))


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

int main(){
    ll fib[45];
    fib[0] = fib[1] = 1;
    int n;
    cin >> n;
    for(int i=2;i<=n;i++){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
    fasterthanlight;
    int n;
    cin >> n;
    int arr[n];
    int final = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        final = final ^ arr[i];
    }
    for (int i = 0; i < n; i++)
    {
        int x = final ^ arr[i];
        cout << x << " ";
    }

    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    vi x(5);
    rep (i, 5) {
        cin >> x[i];
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }   
}

Measured memory_bytes: 3616
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    cout.precision(10);
    if (d == 0) {
        cout << (double)(m-1) / (double)n << endl;
    } else {
        cout << (double)(m-1) * 2.0 * (double)(n - d) / (double)(n * n);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<double,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>one(60,0);
    vector<ll>zero(60,0);
    rep(i,n){
        rep(j,60){
            if(a[i]%2==1){
                one[j]++;
                a[i]/=2;
            }
            else{
                zero[j]++;
                a[i]/=2;
            }
        }
    }
    mint ans = 0;
    rep(i,60){
        mint now = one[i]*zero[i];
        ans += now * pow(2,i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a;
    cin >> a;

    if(a <= 999){
        cout << "ABC" << endl;
    }
    else{
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	cout << (A * (A - 1) / 2) + (B * (B - 1) / 2) << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;

  sort(s.begin(),s.end());

  if(s=="abc"){out("Yes");}
  else out("No");


  return 0;
}


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

int main(void){
  int n;
  cin >> n;
  int n1 = n/10;
  int n2 = n%10;
  if(n1 == 9){
    cout << "Yes" << '\n';
  }
  else{
    if(n2 == 9){
      cout << "Yes" << '\n';
    }
    else{
      cout << "No" << '\n';
    }
  }
}


Measured memory_bytes: 256
from collections import deque
import sys
buf = sys.stdin.buffer

h, w = map(int, buf.readline().split())
map = ""
for _ in range(h):
    map += input() + "#"
#print(map)

n = h * (w + 1)
periods = [[] for _ in range(n)]
dir = [-w - 1, 1, -1, w + 1]
for i in range(n):
    if map[i] == "#":
        continue
    for d in dir:
        next_i = i + d
        if next_i < 0 or next_i >= n or map[next_i] == "#":
            continue
        periods[i].append(next_i)
#print(periods)

q = deque()
def bfs(now_i):
    for next_i in periods[now_i]:
        if con_cnt[next_i] == -1:
            con_cnt[next_i] = con_cnt[now_i] + 1
            q.append(next_i)
    #まだスタックが残っている場合、左から抜き出す
    if q:
        bfs(q.popleft())

start_points = [i for i, j in enumerate(periods) if len(j) > 0]
ans = 0
for start_point in start_points:
    con_cnt = [-1] * n
    con_cnt[start_point] = 0
    bfs(start_point)
    #print(con_cnt)
    ans = max(ans, max(con_cnt))

print(ans)


Measured memory_bytes: 3572
n, m = map(int, input().split())
ablis = []
for i in range(m):
    a, b = map(int, input().split())
    ablis.append((a, b))

ablis.sort(key=lambda x: x[1])

cnt = 0
last = 0

for item in ablis:
    if item[0] >= last:
        cnt += 1
        last = item[1]

print(cnt)


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

int main() {
    int N;
    std::string S;
    std::cin >> N >> S;
    
    int w[N] = {0};
    int e[N] = {0};
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            if (S[i] == 'E') {
                e[i] = 1;
            } else {
                w[i] = 1;
            }
        } else {
            if (S[i] == 'E') {
                e[i] = e[i-1] + 1;
                w[i] = w[i-1];
            } else {
                e[i] = e[i-1];
                w[i] = w[i-1] + 1;
            }
        }
    }

    int min = INT32_MAX;
    for (int i = 0; i < N; ++i) {
        int cnt = 0;
        if (i == 0) {
            cnt = e[N-1] - e[0]; 
        } else {
            cnt = w[i-1] + e[N-1] - e[i];
        }

        min = std::min(min, cnt);
    }

    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 2948
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True):
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 del phL[0]
 del phL[-1]
 ph = phU + phL
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

Measured memory_bytes: 33136
package main

import (
	"fmt"
)

func main() {
	var a1, a2, a3 int
	fmt.Scanf("%d %d %d", &a1, &a2, &a3)

	if (a1 + a2 + a3) >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int n,a=0;
    cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin>>p[i];
    q=p;
    sort(p.begin(),p.end());
    rep(i,n){
        if(p[i]!=q[i]) a++;
    }
    cout<<(a<=2? "YES": "NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include<set>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef unsigned long long ull;
const ull b = 1145148931919LL;


int main(){
	const int N = 333333;
	vector<ull> hash(N);
	vector<ull> pow(N);
	
	int n,m;
	string s;
	cin>>n>>m>>s;
	
	pow[0]=1;
	rep(i,n){
		pow[i+1]=pow[i]*b;
		hash[i+1]=hash[i]+s[i]*pow[i];
	}
	
	int left = 0;
	int right = 0;
	
	set<ull> visit;
	rep(i,m){
		string q;
		cin>>q;
		
		if(q=="L++")left++;
		if(q=="L--")left--;
		if(q=="R++")right++;
		if(q=="R--")right--;
		
		ull val = (hash[right+1] - hash[left])*pow[n-left];
		visit.insert(val);
	}
	
	cout<<visit.size()<<endl;
}

Measured memory_bytes: 20752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);



	ll r;
	cin>>r;
	cout<<3*r*r;

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int a=1;
  for (int i=0; i < N; i++) {
    if (a < K) 
      a += a;
    else 
      a += K;
  }
  cout << a << endl;
}


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


ll dp[1LL<<12];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,m;
    cin>>n>>m;
    ll a[m];
    ll c[m]={};
    for(int i=0;i<m;i++){
        int b;
        cin>>a[i]>>b;
        for(int j=0;j<b;j++){
            ll t;
            cin>>t;
            t--;
            c[i] += (1<<t);
        }
    }
    ll INF = 1e15;

    for(int j=0;j<(1LL<<n);j++){
        dp[j] = INF;
    }
    
    dp[0]=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<(1LL<<n);j++){
            dp[j|c[i]] =min(dp[j|c[i]],dp[j]+a[i]);
        }
    }
    ll ans = dp[(1<<n)-1];
    if(ans>=INF){
        cout << -1 << endl;
        return 0;
    }
    cout << ans <<endl;





}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
bool judge(vector<int>const& a,int key,int k){
  int n=a.size();
  lint sm=0;
  if(key==0)return false;
  rep(i,n){
    int buf=(a[i]-1)/key;
    sm+=buf;
    //cout<<sm<<"\n";
  }
  //if(sm>0)cout<<sm<<"\n";
  return sm<=k;
}
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int low=0;int up=inf;
  while(up-low>1){
    int mid=(up+low)/2;
    if(judge(a,mid,k)){
      up=mid;
    }
    else low=mid;
  }
  cout<<up<<"\n";
  return 0;
}


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

using namespace std;

int main() {   
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    cout << s[i];
  }
  cout << " ";
  for (int i = 4; i < s.size(); i++) {
    cout << s[i];
  }      
  cout << "\n";
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

    int n;
    cin >> n;
    string s = to_string(n);
    bool is = false;
    rep(i, 0, s.size()) {
        if (s[i] == '7')
            is = true;
    }
    if (is)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3740
#include <stdio.h>

int main()
{
	int x, n, min, max;
	long w;
	scanf("%d", &n);
	x = min = max = NULL;
	w = 0;
	for (int i = 0; i<n; i++)
	{
		scanf("%d", &x);
		if (i == 0){ max = x; min = x; }

		if (x<min)min = x;
		if (x>max)max = x;
		w = w + (long)x;
		x = 0;
	}
	printf("%d %d %ld\n", min, max, w);
	return 0;
}

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

int main(void) {
    char input[102];
    scanf("%s", input);
    int len = strlen(input);
    int cnt = 0;

    for (int i = 0; i <= len/2 - 1; i++) {
        if (input[i] != input[len-1-i]) cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m;cin>>n>>m&&n|m;){
		vl xs(n),ys(n),zs(n);
		rep(i,n) cin>>xs[i]>>ys[i]>>zs[i];

		ll res=0;
		rep(b,8){
			vi cs={1,1,1};
			rep(i,3) if(b>>i&1) cs[i]*=-1;
			vi is(n); iota(all(is),0);
			sort(all(is),[&](int i,int j){
				return cs[0]*xs[i]+cs[1]*ys[i]+cs[2]*zs[i]>cs[0]*xs[j]+cs[1]*ys[j]+cs[2]*zs[j];
			});
			ll sum=0;
			rep(i,m){
				int j=is[i];
				sum+=cs[0]*xs[j];
				sum+=cs[1]*ys[j];
				sum+=cs[2]*zs[j];
			}
			chmax(res,sum);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S,ans=0;
  cin>>K>>S;
  for(int i=0;i<=K;i++)
    for(int j=0;j<=K;j++)
      if(i+j<=S && i+j+K>=S)ans++;
  cout<<ans<<endl;
}

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

int main()
{
    ll n;
    cin >> n;
    ll arr[n] = {0};
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        ll j = 1;
        ll a = i * j;
        while (a <= n)
        {
            arr[a - 1]++;
            j++;
            a = i * j;
        }
    }
    for (ll i = 0; i < n; i++)
    {
        ans += (arr[i] * (i + 1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 81672
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }

template <typename UnaryPredicate>
int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) {
    assert (l <= r);
    -- l;
    while (r - l > 1) {
        int64_t m = l + (r - l) / 2;
        (p(m) ? r : l) = m;
    }
    return r;
}


struct desc_t {
    array<ll, 2> incr, decr, fixed;
};

desc_t describe(int n, const vector<ll> & x, const vector<char> & d, char incr, char decr) {
    desc_t a = {
        {{ LLONG_MAX / 3, LLONG_MIN / 3 }},
        {{ LLONG_MAX / 3, LLONG_MIN / 3 }},
        {{ LLONG_MAX / 3, LLONG_MIN / 3 }},
    };
    REP (i, n) {
        if (d[i] == incr) {
            chmin(a.incr[0], x[i]);
            chmax(a.incr[1], x[i]);
        } else if (d[i] == decr) {
            chmin(a.decr[0], x[i]);
            chmax(a.decr[1], x[i]);
        } else {
            chmin(a.fixed[0], x[i]);
            chmax(a.fixed[1], x[i]);
        }
    }
    return a;
}

ll get_doubled_length(const desc_t & a, ll t2) {
    ll l = min(2 * a.incr[0] + t2, min(2 * a.decr[0] - t2, 2 * a.fixed[0]));
    ll r = max(2 * a.incr[1] + t2, max(2 * a.decr[1] - t2, 2 * a.fixed[1]));
    return r - l;
}

long double get_area(const desc_t & ax, const desc_t & ay, ll t2) {
    return get_doubled_length(ax, t2) * get_doubled_length(ay, t2) / 4.l;
}

vector<ll> list_boundaries(const desc_t & a) {
    constexpr ll limit = 1e9;
    vector<ll> b;
    b.push_back(0);
    while (b.back() != limit) {
        ll l = b.back();
        ll c = get_doubled_length(a, l);
        ll d = get_doubled_length(a, l + 1) - get_doubled_length(a, l);
        ll r = binsearch(l, limit, [&](ll t) {
            return get_doubled_length(a, t) != c + d * (t - l);
        });
        b.push_back(r);
    }
    return b;
}

long double solve(int n, const vector<ll> & x, const vector<ll> & y, const vector<char> & d) {
    desc_t ax = describe(n, x, d, 'R', 'L');
    desc_t ay = describe(n, y, d, 'U', 'D');

    vector<ll> bx = list_boundaries(ax);
    vector<ll> by = list_boundaries(ay);
    vector<ll> b;
    copy(ALL(bx), back_inserter(b));
    copy(ALL(by), back_inserter(b));
    sort(ALL(b));
    b.erase(unique(ALL(b)), b.end());

    long double ans = INFINITY;
    REP (i, b.size() - 1) {
        ll l = b[i];
        ll r = b[i + 1];
        chmin(ans, get_area(ax, ay, l));
        chmin(ans, get_area(ax, ay, r));
        binsearch(l, r, [&](ll t) {
            chmin(ans, get_area(ax, ay, t));
            chmin(ans, get_area(ax, ay, t + 1));
            return get_area(ax, ay, t + 1) >= get_area(ax, ay, t);
        });
    }
    return ans;
}

int main() {
    int n; cin >> n;
    vector<ll> x(n), y(n);
    vector<char> d(n);
    REP (i, n) {
        cin >> x[i] >> y[i] >> d[i];
    }
    cout << setprecision(18) << solve(n, x, y, d) << endl;
    return 0;
}


Measured memory_bytes: 1920
n = int(input())
s = input()
r = []
g = []
b = []

ans = s.count("R")*s.count("G")*s.count("B")

for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k>=n:
          break
        ans -= s[k] != s[i] != s[j] != s[k]

print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<(x)<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q;
ll x[500005],y[500005],z[500005];
ll s[500005],t[500005];
bool flag,dame;

void solve(ll x[],ll y[],ll k){
	//p(k);
	if(k == 0){
		p(a);
		for(i=0;i<n-1;i++){
			p(a + s[x[i]]);
			a = a + s[x[i]];
		}
		return;
	}else if(k % 2 == 1){
		for(i=0;i<n-1;i++){
			x[i] = y[x[i]];
		}
		solve(x,y,k-1);
	}else{
		for(i=0;i<n-1;i++){
			z[i] = y[y[i]];
		}
		for(i=0;i<n-1;i++){
			y[i] = z[i];
		}
		solve(x,y,k/2);
	}
}


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

	for(i=0;i<n-1;i++){
		x[i] = i;
		s[i] = s[i+1] - s[i];
	}
	cin >> m >> k;
	for(i=0;i<n-1;i++){
		y[i] = i;
	}
	for(i=0;i<m;i++){
		cin >> b;
		swap(y[b-2],y[b-1]);
	}

	solve(x,y,k);


	return 0;
}

Measured memory_bytes: 42240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int k, a, b;
  cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if (i % k == 0) {
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";




  
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
	while(1){
		int i,j,H,W;
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			if(i%2==0){
				for(j=0;j<W;j++){
					if(j%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}else{
				for(j=0;j<W;j++){
					if(j%2==1){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

const int mod = 1e9 + 7; 
long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}
signed main(void)
{
	ll n, K, ans, mn, mx;
	cin >> n >> K;
	ans = 0;
	mx = n * (n + 1) / 2 - (n - K) * (n - K + 1) / 2;
	mn = K * (K - 1) / 2; 
	for (int k = K; k <= n + 1; k++)
	{
		ans += mx - mn + 1; 
		ans %= mod;
		mx += n - k;
		mn += k;
	}
	cout << ans << endl;
	return 0;
}


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

#define MAX 25

int jewelry[MAX], lim[MAX];
int n;

void bubbleSort() {
  for(int i = 0; i < n; i++) {
    for(int j = n-1; j>i; j--) {
      if(lim[j-1] > lim[j]) {
	swap(lim[j-1], lim[j]);
	swap(jewelry[j-1], jewelry[j]);
      }
    }
  }  
}

int main() {
  bool success;
  int cur;

  while(cin >> n && n) {
    for(int i = 0; i < n; i++) {
      cin >> jewelry[i] >> lim[i];
    }
    bubbleSort();
    success = true;
    cur = 0;
    for(int i = 0; i < n && success; i++) {
      cur += jewelry[i];
      if(lim[i] < cur) success = false;
    }
    if(success) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}

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

int main() {
  string S;
  string T;
  cin >> S >> T;
  
  int x=0;
  
    if (S.at(0)==T.at(0)){
     x=x+1;
   }
  
   if (S.at(1)==T.at(1)){
     x=x+1;
   }
  
   if (S.at(2)==T.at(2)){
     x=x+1;
   }

 
  cout << x << endl;
}


Measured memory_bytes: 256
import math
import itertools as it

w = int(input())
p = input()
q = input()

pc = 1
qc = 1

r = list(range(1,w+1))
perm = list(it.permutations(r,w))

for i in range(0, math.factorial(w)-1):
    pl = p.split(' ')
    pln = list([int(n) for n in pl])
    if list(perm[i]) == pln:
        break
    else:pc += 1

for i in range(0, math.factorial(w)-1):
    ql = q.split(' ')
    qln = list([int(n) for n in ql])
    
    if list(perm[i]) == qln:
        break
    else:qc += 1

    
print(abs(pc - qc))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,b;
  list<int>a;
  cin>>n;
  string s;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        list<int>::iterator it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  list<int>::iterator it=a.begin();
  for(int i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}

Measured memory_bytes: 34348
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

for i in range(n - 1):
    a, b = getList()
    vtxs[a-1].append(b -1)
    vtxs[b-1].append(a - 1)

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)


Measured memory_bytes: 251316