akhauriyash/Code-Regression huggingface dataset:
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
//#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200005
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
		const ll N=1e5;
		ll i,j,k;
    		bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}
bool fun(string s,string t)
	{
		ll c=0;
		for(ll i=0;i<s.sz;i++)
		{
			if(c<t.sz && s[i]==t[c])c++;
			
		}
		return c==t.sz;
	}
//ll dp[64];
//ll ans=1;
// vector<ll> v[N+1];
 //vector<ll> l(N+1,0);
 //vector<ll>vis(N+1);
 ll cnt=0,cnt1=0;
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
void solve()
{
	ll r;
	cin>>r;
	double x=2*pi*r;
	cout<<fixed<<setprecision(12)<<x;
}

int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  ll n,m;cin>>n>>m;
  ll ans=0;
  for(ll i=0;i<m;i++){
    ll hoge;cin>>hoge;ans+=hoge;
  }
  ans=n-ans;
  if(ans<0)ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(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.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int mid = b[i];
    long long c1 = lower_bound(a.begin(), a.end(), mid) - a.begin();
    long long c2 = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
    ans += c1 * c2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2508>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

string alpha;
map<char,int> c2i;
void init(){
    for(int i = 0; i < 26;i++){
        char c = 'a'+i;
        alpha += c;
        c2i[c] = i;
    }
    for(int i = 0; i < 26;i++){
        char c = 'A'+i;
        alpha += c;
        c2i[c] = 26+i;
    }
    alpha += alpha;
    alpha += alpha;
}
string solve(ll n){
    string res;
    vector<int> key(n); for(auto& in:key) cin >> in;
    string s; cin >> s;
    for(int i = 0; i < s.length();i++){
        char c = s[i];
        res += (alpha[c2i[c]+52-key[i%n]]);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    init();
    int n;
    while(cin >> n,n){
        cout << solve(n) << endl;
    }
    return 0;
}



Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int tmp;
  tmp = max(a, max(b, c));
  int ans = 0;
  if(tmp == a){
    ans = b + c;
  } else if(tmp == b){
    ans = a + c;
  } else {
    ans = a + b;
  }

  for(int i = 0; i < k; ++i){
    tmp *= 2;
  }

  ans += tmp;
  cout << ans << endl;
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    ll a,b; cin >> a>>b;
    ll tmp = a;
    int ans = 0;
    while(tmp <= b){
        ans++;
        tmp *= 2;
    }

    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main(){
  int n;
  int ans=1;
  cin >> n;

  vector<char> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  for(int i=0;i<n-1;i++){
    if(!(s.at(i)==s.at(i+1))){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N = int(input())
t_li = []
for _ in range(N):
    t_li.append(int(input()))
if N > 1:
    ans = lcm(t_li[0], t_li[1])
    for i in range(2, N):
        ans = lcm(ans, t_li[i])
else:
    ans = t_li[0]
print(ans)


Measured memory_bytes: 62212
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//vll v[m + 1];
	ll n;
	ll m;
	cin >> n >> m;
	priority_queue<ll> pq[m + 1];
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a > m)
			continue;
		else
			pq[a].push(b);
	}

	ll sum = 0;
	ll maxrem = 0;
	priority_queue<ll> ans;
	for (int i = 1; i <= m; i++)
	{
		while (!pq[i].empty())
		{
			ans.push(pq[i].top());
			pq[i].pop();
		}
		if(ans.empty())
		continue;
		sum+=ans.top();
		ans.pop();
	}
	cout<<sum;
}

Measured memory_bytes: 6400
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repd(i,a) for( int i = (a); i >= 0; --i )

const int units[4] = { 20, 18, 20, 20 }, cycle = 13*20*20*20*18;

typedef long long ll;

bool isLeap( int y )
{
	return ( y % 4 == 0 && y % 100 ) || y % 400 == 0;
}

int dayOfMonth( int y, int m )
{
	switch( m )
	{
		case 2:
			if( isLeap( y ) )
				return 29;
			else
				return 28;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
		default:
			return 31;
	}
}

// y2/m2/d2 - y1/m1/d1
ll countD( int y1, int m1, int d1, int y2, int m2, int d2 )
{
	ll ret = 0;
	while( true )
	{
		if( y1 == y2 && m1 == m2 )
		{
			ret += d2-d1;
			break;
		}
		else if( y1 == y2 )
		{
			ret += dayOfMonth( y1, m1 )-d1+1;
			d1 = 1;
			++m1;
			if( m1 > 12 )
				m1 = 1, ++y1;
		}
		else if( y2-y1 > 1000 )
		{
			ret += (28+30*4+31*7)*1000;
			rep( i, 1000 )
				ret += isLeap( y1+i+1 );
			ret -= countD( y1, 1, 1, y1, m1, d1 );
			y1 += 1000;
			m1 = 1;
			d1 = 1;
		}
		else
		{
			ret += 28+30*4+31*7 + isLeap( y1 )-countD( y1, 1, 1, y1, m1, d1 );
			++y1; m1 = 1; d1 = 1;
		}
	}

	return ret;
}

void advD( int &y, int &m, int &d, ll days )
{
	while( true )
	{
		int lim = dayOfMonth( y, m )-d+1;
		if( days < lim )
		{
			d += days;
			break;
		}
		days -= lim;
		d = 1;
		++m;
		if( m > 12 )
			m = 1, ++y;
	}

	return;
}

int main()
{
	std::string s;
	while( std::cin >> s, s != "#" )
	{
		// y.m.d
		if( std::count( s.begin(), s.end(), '.' ) == 2 )
		{
			int y, m, d;
			sscanf( s.c_str(), "%d.%d.%d", &y, &m, &d );
			ll days = countD( 2012, 12, 21, y, m, d );

			days %= cycle;

			std::vector<ll> v;
			rep( i, 4 )
			{
				v.push_back( days % units[i] );
				days /= units[i];
			}
			v.push_back( days );
			repd( i, 4 )
				printf( "%lld%c", v[i], ".\n"[!i] );
		}
		// b.ka.t.w.ki
		else
		{
			int a[5];
			sscanf( s.c_str(), "%d.%d.%d.%d.%d", a, a+1, a+2, a+3, a+4 );
			int days = 0;
			repd( i, 5 )
			{
				days += a[4-i];
				if( i )
					days *= units[i-1];
			}
			int y = 2012, m = 12, d = 21;
			advD( y, m, d, days );
			printf( "%d.%d.%d\n", y, m, d );
		}
	}

	return 0;
}

Measured memory_bytes: 1268
import sys
import math
input = sys.stdin.readline
n,k = input().split()
n = int(n)
k = int(k)
ans = 0
if n < k:
    for i in range(1,n+1):
        s = math.log2(k / i)
        temp = (1 / 2) ** (math.ceil(s))
        ans += (temp / n)
else:
    for i in range(1,k+1):
        s = math.log2(k / i)
        temp = (1 / 2) ** (math.ceil(s))
        ans += (temp / n)
    ans += ((n - k) / n)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <ll> a;

ll calc(ll m){
    ll ret = 0;
    for(auto &i : a){
        if((i + m) % (n + 1) == n) return -1;
        ret += (i + m) / (n + 1);
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    ll s = 0;
    for(auto &i : a) s += i;
    for(ll i = max(0LL, s - 100000) ; i <= s + 100000 ; i++){
        if(calc(i) == i) finish(i);
    }
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m;
string s[10005];
int main(){
    r(n);r(m);
    for(int i=1;i<=n;i++)cin>>s[i];
    sort(s+1,s+1+n);
    for(int i=1;i<=n;i++)cout<<s[i];
    puts("");
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:96777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

struct min_segment_tree{
	int n,seg[1<<19-1];
	void init(int n_){
		n=1;
		while(n<n_)n*=2;
		rep(i,2*n-1)seg[i]=INF;
	}
	void upd(int k,int a){
		k+=n-1;
		seg[k]=a;
		while(k){
			k=(k-1)/2;
			seg[k]=min(seg[k*2+1],seg[k*2+2]);
		}
	}
	int que(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INF;
		if(a<=l&&r<=b)return seg[k];
		else{
			int vl=que(a,b,k*2+1,l,(l+r)/2);
			int vr=que(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
};
struct max_segment_tree{
	int n,seg[1<<19-1];
	void init(int n_){
		n=1;
		while(n<n_)n*=2;
		rep(i,2*n-1)seg[i]=-INF;
	}
	void upd(int k,int a){
		k+=n-1;
		seg[k]=a;
		while(k){
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	int que(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return -INF;
		if(a<=l&&r<=b)return seg[k];
		else{
			int vl=que(a,b,k*2+1,l,(l+r)/2);
			int vr=que(a,b,k*2+2,(l+r)/2,r);
			return max(vl,vr);
		}
	}
};
int main(){
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

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

struct vals {
int a, b;
vals(int v = 0, int y = 0) : a(v), b(y) {}
int operator () () const { return a + b; }
};

vals operator || (const vals &l, const vals &r) {
  if (l.a >= r.a) {
    return vals(l.a, max(l.b, r.a));
  } else {
    return vals(r.a, max(r.b, l.a));
  }
}

const int MAXN = 19;
int N;
vals A[1 << MAXN];
int main() {
scanf("%d", &N);
for (int i = 0; i < (1 << N); i++) {
int v; scanf("%d", &v); A[i] = vals(v);
}
for (int a = 0; a < N; a++) {
for (int i = 0; i < (1 << N); i++) {
if (i & (1 << a)) continue;
A[i | (1 << a)] = A[i | (1 << a)] || A[i];
}
}
for (int a = 0; a < (1 << N); a++) {
A[a] = vals(A[a]());
if (a & (a + 1)) {
A[a] = A[a] || A[(a & (a+1)) - 1];
}
}
for (int a = 1; a < (1 << N); a++) {
printf("%d\n", A[a].a);
}
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int r;
  cin>>r;
  cout<<r*r<<endl;
  return 0;
}


Measured memory_bytes: 256
from math import sqrt
dis = lambda x1,y1,x2,y2: sqrt((x1-x2)**2+(y1-y2)**2)
def heron(a,b,c):
    s = (a+b+c)*1.0/2
    return sqrt(s*(s-a)*(s-b)*(s-c))
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
        a,b,c = dis(x1,y1,x2,y2),dis(x1,y1,x3,y3),dis(x3,y3,x2,y2)
        d,e,f = dis(x1,y1,xp,yp),dis(xp,yp,x2,y2),dis(xp,yp,x3,y3)
        AnsS = heron(a,b,c)
        FakS = heron(a,e,d)+heron(e,c,f)+heron(d,b,f)
        q1,q2 = str(AnsS),str(FakS)
        Ans = "YES" if q1 == q2 else "NO"
        print Ans
    except EOFError: break

Measured memory_bytes: 4452
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

static const double pi = 3.141592653589793;

int main() {
	double A, B;
	cin >> A >> B;

	double H, M;
	cin >> H >> M;

	double theta1 = 30.0 * H + 0.5 * M;
	double theta2 = 6.0 * M;

	double dif = abs(theta2 - theta1);

	double ans = sqrt(A*A + B*B - 2.0*A*B*cos(dif * pi / 180.0));

	cout << fixed << setprecision(15) << ans << "\n";


	return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int hoge(int n) {
  if (n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}

int main() {
  int s;
  cin >> s;
  set<int> cont;
  cont.insert(s);
  int last = s;
  for (int i = 2;; ++i) {
    last = hoge(last);
    if (cont.find(last) == cont.end()) {
      cont.insert(last);
      continue;
    }
    cout << i << endl;
    break;
  }
}


Measured memory_bytes: 3640
from collections import deque
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)]
e_from = [[] for _ in range(N+1)]
e_to = [[] for _ in range(N+1)]
for a, b in AB:
    e_from[a].append(b)
    e_to[b].append(a)


add = np.zeros(N+1, dtype=int)
rank = [-1]*(N+1)

# まず根を探す
for i in range(1, N+1):
    add[i] = len(e_to[i])
    if len(e_to[i]) == 0:
        root = i

# BFS
rank[root] = 0
node = deque([root])
while node:
    s = node.popleft()
    add[e_from[s]] -= 1
    for t in e_from[s]:
        if add[t] == 0:
            rank[t] = s
            node.append(t)

print(*rank[1:], sep="\n")


Measured memory_bytes: 53084
# coding: utf-8

num = int(input())
str = input().split()
table = [int(i) for i in str]

table2 = sorted(table, reverse = True)
a_point = 0
b_point = 0

for i in range(num):
    if i % 2 == 0:
        a_point += table2[i]
    elif i % 2 == 1:
        b_point += table2[i]
print(a_point - b_point)

Measured memory_bytes: 9180
#include <stdio.h>
int main()
{
  int a,i;
  scanf("%d",&a);
  
  for(i=1;i<=a;i++){
    if(i%3==0)printf(" %d",i);
    else if(i%10==3 || i/10%10==3 || i/100%10==3 || i/1000%10==3 )printf(" %d",i);
  }

  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    int ans = INF;
    for(int s=0; s<(1<<D); s++){
        int solve = 0, score = 0;
        int partial = -1;
        for(int i=0; i<D; i++){
            // i番目のセットをすべて解く
            if(s & (1<<i)){
                solve += p[i];
                score += 100*(i+1)*p[i] + c[i];
            }else{
                // 余ったセットで最高点のもの
                partial = i;
            }
        }
        // G点に達するまで問題を解く
        int less = G-score;
        if(less > 0){
            int prob_score = 100*(partial+1);    // 1問の点数
            // 解き切っても足りないなら、その組み合わせは不適
            if(less > prob_score*p[partial]) continue;
            // floor(less/(1問あたりの点数)) と等価
            solve += min(p[partial], (less+(prob_score-1))/prob_score);
        }
        ans = min(ans, solve);
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N,0);
    for(int i = 0; i < N-1; ++i) {
        int a;
        cin >> a;
        ++A[a-1];
    }
    for(auto &p :A) {
        cout << p << endl;
    }
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<vector<int>> g(n);
    rep(i, 0, n - 1) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    int ans[n] = {};
    rep(i, 0, n) {
        queue<int> que;
        int dist[n] = {};
        rep(j, 0, n) dist[j] = -1;
        dist[i] = 0;
        que.push(i);
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (auto nv : g[v]) {
                if (dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        rep(j, i + 1, n) {
            ans[dist[j]]++;
        }
    }

    rep(i, 1, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
 
typedef long long 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>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<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 };
 
int main(){
  int n, m, k;
  cin >> n >> m >> k;
  int i,j;
  vii dp(n+1,vi(m+1));
  for(i=0;i<=n;i++){
    for(j=0;j<=m;j++){
      if(j==0){
	dp[i][j] = m*i;
      }else{
	dp[i][j] = dp[i][j-1] - i + (n - i);
      }
      if(dp[i][j]==k){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;


int main() {
#ifdef LOCAL
    // freopen("input", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    int n;
    cin >> n;
    int cnt4 = 0;
    int cnt2 = 0;
    int cnt1 = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 4 == 0)
            ++cnt4;
        else if (x % 2 == 0)
            ++cnt2;
        else
            ++cnt1;
    }
    if (cnt4 + 1 >= cnt1 + (cnt2 ? 1 : 0))
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

// Returns n divisors ORDER BY ASC.
vector<i64> getDivisors(i64 n) // {{{
{
    vector<i64> ret;
    i64 i = 1;
    for (i = 1; i * i < n; ++i) {
        if (n % i == 0) {
            ret.emplace_back(i);
            ret.emplace_back(n / i);
        }
    }
    if (i * i == n) ret.emplace_back(i);
    sort(begin(ret), end(ret));
    return ret;
} // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N;
    read(N);

    const auto ds = getDivisors(N);
    i64 ans = 0;
    for (const i64 e : ds) {
        const i64 m = e - 1;
        if (m > 0 && N / m == N % m) {
            ans += m;
        }
    }

    print(ans);

    return 0;
}


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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    int largest = b / k * k;
    if (largest >= a)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3596
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	vector<int> color(9,0) ;
	for(int i=0;i<n;i++){
		int a ; cin >> a ;
		if(a>=3200) color.at(8)++ ;
		else color.at(a/400) = 1 ;
	}
	int mn = 0 ;
	for(int i=0;i<8;i++) mn += color.at(i) ;
	if(mn==0){
		mn = 1 ; color.at(8)-- ;
	}
	cout << mn << " " << mn+color.at(8) << endl ;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    for(int i=1;i<=5;i++){
        int x; cin >> x;
        if(x==0){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>
#include <type_traits>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int k;
  cin >> k;

  ll ans = 0;
  repd(i, 1, k+1){
    repd(j, 1, k+1){
      int ab = gcd(i, j);
      repd(m, 1, k+1){
        ans += gcd(ab, m);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
#define inf 1000000000000ll
long long f ( long long b, long long n ) {
	if ( n < b ) return n;
	else return f ( b, n / b ) + n % b;
}
int main ( void ) {
	long long n, s;
	scanf ( "%lld%lld", &n, &s );
	if ( n < s ) {
		printf ( "-1" );
	} else if ( n == s ) {
		printf ( "%lld", n + 1 );
	} else {
		long long p = n - s, ans = inf;
		for ( int i = 1; 1ll * i * i <= p; i++ )
			if ( p % i == 0 ) {
				if ( f ( 1ll * i + 1, n ) == s && ans > i + 1 ) {
					ans = i + 1;
				}
				if ( f ( p / i + 1, n ) == s && ans > p / i + 1 ) {
					ans = p / i + 1;
				}
			}
		if ( ans != inf ) {
			printf ( "%lld", ans );
		} else {
			printf ( "-1" );
		}
	}
}


Measured memory_bytes: 128
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  int pt = 0, px = 0, py = 0;
  bool yes = true;

  for (int i = 0; i < N; i++) {
    int t, x, y;
    std::cin >> t >> x >> y;

    const int d = std::abs(x - px) + std::abs(y - py);
    const int td = t - pt;

    if (d <= td && d % 2 == td % 2) {
      // nop
    } else {
      yes = false;
    }

    pt = t, px = x, py = y;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000003, lg = 22;
int mul(long long a, long long b){
	return a * b % mod;
}
int pw(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a)) if(b&1) r = mul(r, a);
	return r;
}
int p[lg][2 * mod];
int main(){
	for(int i = 0; i < 2 * mod; i++) p[0][i] = mul(1, i);
	for(int i = 1; i < lg; i++){
		for(int j = 0; j + (1<<i) <= 2 * mod; j++){
			p[i][j] = mul(p[i - 1][j], p[i - 1][j + (1<<(i - 1))]);
		}
	}
	int q; cin >> q;
	while(q--){
		int x, d, n; cin >> x >> d >> n;
		if(d == 0) {
			cout << pw(x, n) << endl;
		} else if(n >= mod){
			cout << 0 << endl;
		} else {
			int ans = pw(d, n);
			int xd = mul(x, pw(d, mod - 2));
			for(int i = lg - 1; i >= 0; i--){
				if(n&(1<<i)){
					ans = mul(ans, p[i][xd]);
					xd += 1<<i;	
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}




Measured memory_bytes: 162688
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Balance
            int N = int.Parse(Console.ReadLine());
            var W = ReadLine();

            int s1 = 0;
            int s2 = W.Sum();
            int min = s2;

            for (int i = 0; i < N; i++)
            {
                s1 += W[i];
                s2 -= W[i];

                int diff = Math.Abs(s1 - s2);
                min = Math.Min(min, diff);
            }

            Console.WriteLine(min);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<set>

using namespace std;

int main(){
  set<char> s;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    char tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  if(s.size()==3){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  
  int n, pattern;
  int i, j, k, l;
  
  while(1) {
    pattern = 0;
    if (scanf("%d", &n) == EOF) break;
    for (i = 0; i <= 9; i++) {
      for (j = 0; j <= 9; j++) {
        for (k = 0; k <= 9; k++) {
          for (l = 0; l <= 9; l++) {
            if (i + j + k + l == n) {
              pattern++;
              //printf("%d + %d + %d + %d = %d\n", i, j, k, l, n);
            }
          } 
        }
      } 
    }
    
    printf("%d\n", pattern);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  long one = min(4 * Q, min(2 * H, S));
  long two = min(2 * one, D);
  cout << (N / 2) * two + (N % 2) * one << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
	int n,k,x,y,z,c=0;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0;i<n;i++)cin>>arr[i];
	z=(k-1)*(k)/2%modulo;
	for(int i=0;i<n;i++){
		x=0;
		y=0;
		for(int j=0;j<n;j++){
			if(arr[j]<arr[i])x++;
		}
		x=(x*z)%modulo;
		for(int j=i+1;j<n;j++){
			if(arr[i]>arr[j])y++;
		}
		y=y*k%modulo;
		c+=x+y;
		c%=modulo;
	}
	cout<<c;
}


Measured memory_bytes: 256
import fractions
n, k  = map(int, input().split())
l=[]



kou=fractions.gcd(n, k)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
    
l = prime_factorize(kou)

print(len(set(l))+1)


Measured memory_bytes: 5048
#include<string>
#include<iostream>
using namespace std;
int main(){
  string text,pattern;
  cin>>text>>pattern;
  int t=text.length();
   int p=pattern.length();
   int max=p,count,temp;
  for(int i=0;i<=t-p;i++){//
    temp=i;
    count=0;
    if(text.substr(i,i+p-1)==pattern){
      max=0;
      break;
    }
    else{
      for(int j=0;j<p;j++){
        if(text[temp++]!=pattern[j]){
          count++;
        }
      }
    if(count<=max)
      max=count;
    }
  }
 cout<<max;
  return 0;
}

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

int main () {
  int a , b , c , d ;
  string line ;
  cin >> line ;
  a = line[0] - '0' ;
  b = line[1] - '0' ;
  c = line[2] - '0' ;
  d = line[3] - '0' ;
  
  if( a+b+c+d==7 ) cout << a << '+' << b << '+' << c << '+' << d << '=' << 7 ;
  else if( a+b+c-d==7 ) cout << a << '+' << b << '+' << c << '-' << d << '=' << 7 ;
  else if( a+b-c+d==7 ) cout << a << '+' << b << '-' << c << '+' << d << '=' << 7 ;
  else if( a+b-c-d==7 ) cout << a << '+' << b << '-' << c << '-' << d << '=' << 7 ;
  else if( a-b+c+d==7 ) cout << a << '-' << b << '+' << c << '+' << d << '=' << 7 ;
  else if( a-b+c-d==7 ) cout << a << '-' << b << '+' << c << '-' << d << '=' << 7 ;
  else if( a-b-c+d==7 ) cout << a << '-' << b << '-' << c << '+' << d << '=' << 7 ;
  else if( a-b-c-d==7 ) cout << a << '-' << b << '-' << c << '-' << d << '=' << 7 ;
}

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

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s;
    t = s;

    while (true) {
        auto itr = adjacent_find(begin(t), end(t), [](auto a, auto b) { return a == '(' && b == ')'; });
        if (itr == end(t)) break;
        t.erase(itr, itr + 2);
    }

    int lb = count(begin(t), end(t), '('), rb = count(begin(t), end(t), ')');
    cout << string(rb, '(') << s << string(lb, ')') << endl;
}



Measured memory_bytes: 256
// Marcin Knapik
// before you read it
// make sure it's a good idea
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
using namespace std;

typedef long long         ll;
typedef unsigned long long      ull;
typedef pair< ll, ll >        pll;
typedef pair< int, int  >       ii;
typedef vector< int  >       vi;
typedef vector< ii >        vii;
typedef vector< vi >        vvi;
typedef vector< vector < ii > >   vvii;
typedef vector< ll >        vll;
typedef vector< pll >       vpll;
typedef long double         ld;

#define boost   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define szy     first
#define gi      second
#define sz(a)   (int)(a).size()
#define pb      push_back
#define all(c)    (c).begin(), (c).end()
#define rall(c)   (c).rbegin(), (c).rend()
#define REP(i, a, b) for (int i = (a); i <= (b); i++)
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define TRAV(i, n) for(auto&i:n)
#define beg(x) (*(x.begin()))
#define re(x) int x; cin >>x;   
#define f first
#define s second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> inline T sub(T a, T b, T mod) {return ((a%mod - b%mod)+mod)%mod;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

ld e = 2.7182818284590452353602874713526624;
ld PI = acos(-1);
ld eps = 1e-11;

const ll T = 1 << 19;
const ll INF = 1e9 + 7;
const ll MOD = 998244353;
const ll BIG_INF = 1e18 + 7;
const long long  N = 1e6 + 7;
const ll M = 2007;

int n, m, k;
string w;

void No(){
	cout << "No";
	exit(0);
}

void Yes(){
	cout << "Yes";
	exit(0);
}

int main(){
	boost;

	cin >> n;
	vi tab(n);
	cin >> tab;
	sort(all(tab));
	if(tab[0] == tab.back() && tab[0] == 0)
		Yes();
	if(n%3)
		No();
	int dl = n/3;
	for(int i = 0; i < dl - 1; i++){
		if(tab[i] != tab[i+1])
			No();
	}
	for(int i = 0 + dl; i < dl + dl - 1; i++){
		if(tab[i] != tab[i+1])
			No();
	}
	for(int i = 0 + dl + dl; i < dl + dl + dl - 1; i++){
		if(tab[i] != tab[i+1])
			No();
	}
	if((tab[0]^tab[dl] )== tab[dl+dl])
		Yes();
	No();

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit=100010;
int ssum[limit],tsum[limit];

int main(void){
	string s,t;
	cin >> s >> t;

	const int n=s.size(),m=t.size();
	
	rep(i,n) ssum[i+1]=(ssum[i]+(s[i]-'A'+1))%3;

	rep(i,m) tsum[i+1]=(tsum[i]+(t[i]-'A'+1))%3;

	int q;
	cin >> q;

	rep(loop,q){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--,c--;
		const int ab=(ssum[b]-ssum[a]+9)%3;
		const int cd=(tsum[d]-tsum[c]+9)%3;
		if(ab==cd)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        long N = long.Parse(ReadLine());

        var ans = new List<char>();
        long n = N;
        while (n > 0)
        {
            n--;
            ans.Add((char)('a' + n % 26));
            n /= 26;
        }
        ans.Reverse();
        WriteLine(string.Join("", ans));


    }
}


Measured memory_bytes: 27732
#include<iostream>
using namespace std;
int main(){
	int n,a=0,un=0;
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		if(str=="A")	a++;
		else	un++;
		if(un>a){
			cout << "NO\n";
			return 0;
		}
	}
	if(a==un)	cout << "YES\n";
	else	cout << "NO\n";
}


Measured memory_bytes: 3152
n,l = map(int,input().split())
i = 1-l
if 1<= i <= n:
  sum = n*(l-1)+ int(n*(n+1)/2)
else:
  if l>=0:
    sum = n*(l-1)+ int(n*(n+1)/2) -l
  else:
    sum = n*(l-1)+ int(n*(n+1)/2) - (l+n-1)
print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}


using namespace std;

signed main (){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0;i<n;i++){
		cin >> a.at(i);
	}
	int size = a.size();
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
	if(a.size()==size){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int x[10000];
    int y[10000];
    int i;
    int temp;
    int cnt=0;
    for(i=0;i<10000;i++){
        scanf("%d%d",&x[i],&y[i]);
        if(x[i]==0 && y[i]==0) break;
        if(y[i]>x[i]){
            temp=x[i];
            x[i]=y[i];
            y[i]=temp;
        }
        cnt++;
    }
    for(i=0;i<cnt;i++){
        printf("%d %d\n",y[i],x[i]);
    }
    return 0;
}


Measured memory_bytes: 2612
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod 998244353
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 1000005


// Driver code to test above functions
int32_t main()
{
  
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, ans = 0;
    cin >> n;
    map<int, int> mp;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin >> x;

        ans += mp[i-x];

        mp[i+x]++;
    }

    cout << ans;

    return 0;

} 


Measured memory_bytes: 26236
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){int n;cin>>n;vector<int>v(n),m(n);rep(i,n){int a;cin>>a;rep(j,a){int x,y;cin>>x>>y;x--;v[i]|=y<<x;m[i]|=1<<x;}}int ans=0;rep(i,(1<<n)){rep(j,n){bool bit=(i>>j)&1;if(bit){int check=(i^v[j])&m[j];if(check>0) break;}if(j==n-1)ans=max(ans,__builtin_popcount(i));}}cout << ans << endl;}


Measured memory_bytes: 3604
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
  input! {
    r: f64
  };
  let res = 2_f64 * std::f64::consts::PI * r;
  println!("{}", res);
}


Measured memory_bytes: 2184
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long X, long Y, long Z, long K, long[] A, long[] B, long[] C) {
    alias Vec3 = Tuple!(size_t, size_t, size_t);
    alias Cake = Tuple!(long, "value", Vec3, "pos");
    
    A = A.sort!"a > b".array;
    B = B.sort!"a > b".array;
    C = C.sort!"a > b".array;

    auto heap = make!(RedBlackTree!(Cake, "a > b"));
    auto done = make!(RedBlackTree!Vec3);
    
    heap.insert(Cake(A[0] + B[0] + C[0], Vec3(0, 0, 0)));
    done.insert(Vec3(0, 0, 0));

    long calcValue(Vec3 v) {
        return A[v[0]] + B[v[1]] + C[v[2]];
    }

    foreach (_; 0 .. K) {
        auto c = heap.front;
        heap.removeFront;
        writeln(c.value);

        auto na = tuple(c.pos[0] + 1, c.pos[1], c.pos[2]);
        if (c.pos[0] + 1 < X && !(na in done)) {
            heap.insert(Cake(calcValue(na), na));
            done.insert(na);
        }
        
        auto nb = tuple(c.pos[0], c.pos[1] + 1, c.pos[2]);
        if (c.pos[1] + 1 < X && !(nb in done)) {
            heap.insert(Cake(calcValue(nb), nb));
            done.insert(nb);
        }
        
        auto nc = tuple(c.pos[0], c.pos[1], c.pos[2] + 1);
        if (c.pos[2] + 1 < X && !(nc in done)) {
            heap.insert(Cake(calcValue(nc), nc));
            done.insert(nc);
        }
    }
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long X;
    X = input.front.to!long;
    input.popFront;

    long Y;
    Y = input.front.to!long;
    input.popFront;

    long Z;
    Z = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (X));
    foreach (i; 0 .. cast(size_t) (X)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    long[] B = new long[](cast(size_t) (Y));
    foreach (i; 0 .. cast(size_t) (Y)) {
        B[i] = input.front.to!long;
        input.popFront;
    }

    long[] C = new long[](cast(size_t) (Z));
    foreach (i; 0 .. cast(size_t) (Z)) {
        C[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(X, Y, Z, K, A, B, C);
    else
        solve(X, Y, Z, K, A, B, C).writeln;
}


Measured memory_bytes: 3324
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = abs(M - x - x)
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))


Measured memory_bytes: 24172
N = int(input())
a = list(map(int,input().split()))
ans = [0]*N
num_list = [list(map(lambda x: x-1,list(range(i+1,N+1,i+1)))) for i in range(N)]
for i in range(N)[::-1]:
  #print("num_list : {}".format(num_list[i]))
  before_num = sum([ans[i] for i in num_list[i]])
  #print("before_num%2 : {}".format(before_num%2))
  #print("a[i] : {}".format(a[i]))
  ans[i] = (before_num%2 + a[i])%2
  #print("ans[i] : {}".format(ans[i]))

if not (1 in ans):
  print(0)
else:
  print(ans.count(1))
  for i in range(N):
    if ans[i] == 1:
      print(i+1,end=" ")



Measured memory_bytes: 138468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int k,n,b;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(i==0){
            b=a[0]+(k-a[n-1]);
        }
        else{
            if(b<a[i]-a[i-1]){
                b=a[i]-a[i-1];
            }
        }
    }
    cout<<k-b;
}


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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      total += i;
    }
  }
  cout << total << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   long long g=gcd(a,b);
  return a/g*b;
}

int main(){
  int n;
  cin >> n;
  long long ans=1;
  for(int i=0;i<n;i++){
    long long t;
    cin >> t;
    ans = lcm(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604