akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
 
//krishrawat
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------

ll fast_expo(ll x, ll y){ll res=1;while(y>0){if(y&1){res*=x;}x*=x;y>>=1;}return res;}

vl grp[N];
vl vis(N,0);

ll dfs(ll x){
    ll k=0;
    for(auto i:grp[x]){
        if(!vis[i]){
            vis[i]=1;
            k+=1+dfs(i);
        }
    }
    return k;
}

//solution
void solve()
{   
    ll n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        grp[a].eb(b);
        grp[b].eb(a);
    }    
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            vis[i]=1;
            ans=max(ans,1+dfs(i));
        }
    }
    cout<<ans<<"\n";
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t; t=1;
    //cin>>t;
    while(t--) solve(); return 0;
}


Measured memory_bytes: 25016
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, k, a[200005] = {}, b, c = 0;
    cin >> n >> k;
    fr(n) cin >> b, a[b]++;
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    fr1(k) n -= a[i];
    cout << n;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		A[0] = sc.nextInt();
		int a = A[0];
		long s = 0;
		for(int i=1; i<N; i++) {
			A[i] = sc.nextInt();
			if(A[i]<=a) {
				s+=a-A[i];
			}else{
				a = A[i];
			}
		}
		sc.close();
		System.out.println(s);
	}

}

Measured memory_bytes: 59792
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[200005];

ll extgcd(ll a,ll b,ll& x,ll& y){
    ll d=a;
    if(b!=0LL){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
    e=0;
    if(n==0)return 1;
    ll res=mod_fact(n/p,p,e);
    e+=n/p;
    if(n/p%2!=0){
        return res*(p-fact[n%p])%p;
    }
    return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
    if(n<0 || k<0 || n<k)return 0;
    ll e1,e2,e3;
    ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
    if(e1>e2+e3)return 0;
    return a1*mod_inverse(a2*a3%p,p)%p;
}

int b,w;

int main(void){
    fact[0]=1;
    for(int i=1;i<=200000;i++){
        fact[i]=(ll)fact[i-1]*i%MOD;
    }
    scanf("%d%d",&b,&w);
    ll twomod=mod_inverse(2,MOD);
    ll tp=twomod;
    ll pi=0,qi=0;
    for(int i=0;i<b+w;i++){
        printf("%lld\n",(qi+(((1LL-pi-qi)+MOD*2LL)%MOD)*twomod)%MOD);
        if(i>=b-1){
            pi+=mod_comb(i,b-1,MOD)*tp%MOD;
            pi%=MOD;
        }
        if(i>=w-1){
            qi+=mod_comb(i,w-1,MOD)*tp%MOD;
            qi%=MOD;
        }
        tp=tp*twomod%MOD;
    }
    return 0;
}




Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int A, B, C;
	cin >> A >> B;
	A *= B;
	if ((A * 1) % 2 == 1)
		cout << "Yes" << endl;
	else if ((A * 3) % 2 == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {

int n;
cin >>n;

int kosuk[100001]={};//奇数部分の数え上げ
int kosug[100001]={};//偶数部分の数え上げ

int v;

for(int i=0;i<n/2;i++){
cin >>v;
kosuk[v]=kosuk[v]+1;

cin >>v;
kosug[v]=kosug[v]+1;}

int maxk=0;//奇数部分最頻値
int valk;//最頻値をとる値

for(int i=1;i<=100000;i++){
if(kosuk[i]>=maxk){maxk=kosuk[i]; valk=i;}
}

int seck=0;//奇数部分二番目に大きな値

for(int i=1;i<=100000;i++){
if(i!=valk && kosuk[i]>=seck){seck=kosuk[i];}
}

int maxg=0;//偶数部分最頻値
int valg;//最頻値をとる値

for(int i=1;i<=100000;i++){
if(kosug[i]>=maxg){maxg=kosug[i]; valg=i;}
}

int secg=0;//偶数部分二番目に大きな値

for(int i=1;i<=100000;i++){
if(i!=valg && kosug[i]>=secg){secg=kosug[i];}
}

int ans;

if(valk==valg){ans=min(n-maxk-secg,n-maxg-seck);}
else{ans=n-maxk-maxg;}

cout <<ans;


}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

vvll pariti(3, vll());
vll val(2e5 + 3);
void dfs(ll n, vvll& g, ll cur, ll v, ll pre){
        val[cur] = v;
        pariti[v].push_back(cur);
        for(auto nex:g[cur]){
                if(nex != pre){
                        dfs(n, g, nex, (v+1)%2, cur);
                }
        }
}

ll f(ll n, ll cur){
        cur += 3;
        if(cur > n){
                if(cur % 3 == 1){
                        cur = 3;
                }else if(cur % 3 == 0){
                        cur = 2;
                }
        }
        return cur;
}

int main(){
        ll n;
        cin >> n;
        vvll g(n + 1, vll());
        REP(i,1,n-1){
                ll a,b;
                cin >> a >> b;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        if(n == 2){
                cout << 1 << " " << 2 << endl;
                return 0;
        }
        val[1] = 1;
        dfs(n,g,1,0,-1);
        vll ans(n+1);
        set<ll> st;
        if(pariti[0].size() <= n / 3){
                REP(i,0,SIZE(pariti[0])-1){
                        ans[pariti[0][i]] = 3 * (i+1);
                        st.insert(3*(i+1));
                }
                ll tmp = 1;
                for(auto x:pariti[1]){
                        while(st.find(tmp) != st.end()){
                                tmp++;
                        }
                        ans[x] = tmp;
                        tmp++;
                }

        }
        else if(pariti[1].size() <= n / 3){
                REP(i,0,SIZE(pariti[1])-1){
                        ans[pariti[1][i]] = 3 * (i+1);
                        st.insert(3*(i+1));
                }
                ll tmp = 1;
                for(auto x:pariti[0]){
                        while(st.find(tmp) != st.end()){
                                tmp++;
                        }
                        ans[x] = tmp;
                        tmp++;
                }
        }
        else{
                ll tmp = 1;
                for(auto x:pariti[0]){
                        ans[x] = tmp;
                        tmp = f(n, tmp);
                }
                for(auto x:pariti[1]){
                        ans[x] = tmp;
                        tmp = f(n, tmp);
                }
        }
        REP(i,1,n){
                cout << ans[i];
                if(i < n){
                        cout << " ";
                }
        }
        cout << endl;
}

Measured memory_bytes: 25708
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

  int A,B;

  cin >> A >> B;

  for(int i = 1;i <=3;++i ) if(A != i && B != i) cout << i << endl;

  return 0;

}

Measured memory_bytes: 256
S = input()
T = input()

f_S = {}
f_T = {}


for i in range(len(S)):
    if S[i] not in f_S:
        f_S[S[i]] = T[i]
    elif f_S[S[i]] != T[i]:
        print('No')
        exit()
      
for i in range(len(T)):
    if T[i] not in f_T:
        f_T[T[i]] = S[i]
    elif f_T[T[i]] != S[i]:
        print('No')
        exit()
      
print('Yes')
          
        

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second                            
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 


 
void c_p_c() {
  ios_base::sync_with_stdio(0); 
  cin.tie(0); 
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
// int gcd (int a, int b) {
//   if (b == 0) return a;
//   else return gcd (b, a % b);
// }
// int gcd(int a, int b, int& x, int& y) {
//   if (b == 0) {
//     x = 1;
//     y = 0;
//     return a;
//   }
//   int x1, y1;
//   int d = gcd(b, a % b, x1, y1);
//   x = y1;
//   y = x1 - y1 * (a / b);
//   return d;
// }
// int lcm (int a, int b)  {
//   return a / gcd(a, b) * b;
// }
// int fact(int n){
//   if(n==0) return 1 ;
//   else return n*fact(n-1); 
// }
void solve() {
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.length()) cout << s;
  else {
    for (int i = 0; i < k; ++i) cout << s[i];
    cout << "...";  
  }
}  
int32_t main() {
 //c_p_c();
 //w(x) 
 solve();
 return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(all(a));
  int ans = 0;
  for(int i = 0; i + 1 < n; i++) {
    for(int j = i + 1; j < n ; j++) {
      int l = lower_bound(all(a) , a[i] + a[j]) - a.begin();
      ans += l - j - 1;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

const int mod = 1000000007;

int N,K;
vector<int> v[100005];
bool visited[100005];


int bfs(int s){
    int ret=K;
    queue<int> que;
    que.push(s);
    while(que.size()){
        int c=que.front();
        que.pop();
        visited[c]=true;
        for(int i=0,j=0;i<v[c].size();++i){
            if(visited[v[c][i]])continue;
            if(c==s)ret*=(K-j-1);
            else ret*=(K-j-2);
            ret%=mod;
            que.push(v[c][i]);
            j++;
        }
    }
    return ret;
}

signed main(){
    cin>>N>>K;
    for(int i=0;i<N-1;++i){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cout<<bfs(0)<<endl;
}


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

int gcd(int64_t m, int64_t n){

  if (m % n){
    return gcd(n, m % n);
  }
  else{
    return n;
  }
}

int main() {
  int64_t N, K, M, g, f = 0;
  cin >> N >> K;
  
  vector<int64_t> A(N);
  
  for(int i = 0; i < N; i++){
    cin >>  A.at(i);
  }
  sort(A.begin(), A.end());
  M = A.at(N-1);
  
  g = A.at(0);
  for(int i = 1; i < N; i++){
    g = gcd(g, A.at(i));
  }
  
  while (M - g >= 0){
    if (M == K){
      cout << "POSSIBLE" << endl;
      f = 1;
      break;
    }
    M = M - g;
  }
  if (f == 0){
    cout << "IMPOSSIBLE" << endl;
  }
}

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

using namespace std;
const int N = 5e5 + 100;
inline int read() {
	int q=0,w=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
	while(isdigit(c))q=q*10+c-'0',c=getchar();
	return w*q;
}

struct node {
	int l, r, id, bel;
	inline bool operator < (const node &b) const {
		if(bel == b.bel) return r < b.r;
		return l < b.l;
	}
}Q[N];
int n, m, block, col[N], cnt[N], Ans[N];

int main() {
	n = read(); m = read(); block = sqrt(n);
	for(int i = 1;i <= n; ++i) col[i] = read();
	for(int i = 1;i <= m; ++i) {
		Q[i].l = read();
		Q[i].r = read();
		Q[i].id = i;
		Q[i].bel = (Q[i].l + 1) / block;
	}
	sort(Q + 1, Q + 1 + m);
	int l = 1, r = 0, ans = 0;
	for(int i = 1;i <= m; ++i) {
		int ql = Q[i].l, qr = Q[i].r;
        while(l < ql) ans -= !--cnt[col[l++]];
        while(l > ql) ans += !cnt[col[--l]]++;
        while(r < qr) ans += !cnt[col[++r]]++;
        while(r > qr) ans -= !--cnt[col[r--]];
        Ans[Q[i].id] = ans;
	}
	for(int i = 1;i <= m; ++i) 
		printf("%d\n", Ans[i]);
	return 0;
}

Measured memory_bytes: 17412
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S=[input() for i in range(N)]
S.sort()
M=[]
c=1
m=0
s=S[0]
for i in range(1,N):
    if S[i]==s:
        c+=1
    else:
        if c>m:
            M=[s]
            m=c
        elif c==m:
            M.append(s)
        c=1
        s=S[i]
if c>m:
    M=[s]
elif c==m:
    M.append(s)
print(*M,sep="\n")

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  vector<int> x(n);rep(i,n)cin>>x[i];
  int ans=1000000,sum;
  rep2(i,1,1000){
    sum=0;
    rep(j,n)sum+=pow(x[j]-i,2);
    if(ans>sum)ans=sum;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	c := make([]int, len(s)+1)
	t := 0
	for i, e := range s {
		c[i] = t
		if e == '<' {
			t++
		} else {
			t = 0
		}
	}
	c[len(s)] = t
	t = 0
	ans := 0
	for i := len(s) - 1; i >= 0; i-- {
		c[i+1] = max(c[i+1], t)
		ans += c[i+1]
		if s[i] == '>' {
			t++
		} else {
			t = 0
		}
	}
	c[0] = max(c[0], t)
	ans += t
	fmt.Fprintln(wr, ans)

}


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

int main(){
    int i, j, k;
    int n, t, m;
    string s;
    cin >> s;
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
        puts("Yes");
    }
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;
int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
      a--;
      b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); 
  // 全頂点を「未訪問」に初期化
  vector<int> root(N,-1);
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
  root[0]=0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
          root[nv]=v;
            que.push(nv);
        }
    }
  cout<<"Yes"<<endl;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 1; v < N; ++v) cout << root[v]+1<< endl;
}

Measured memory_bytes: 10584
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		int l = ni();

		String s[] = new String[n];

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

		Arrays.sort(s);

		for (String ss : s) {
			outn(ss);
		}
		out("");

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 22100
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
return 0;
}


Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
    int i=0;
    while(1) {
        if(s.substr(i,11)=="dreameraser") {
            i+=11;
        }
        else if(s.substr(i,10)=="dreamerase") {
            i+=10;
        }
        else if(s.substr(i,7)=="dreamer") {
            i+=7;
        }
        else if(s.substr(i,5)=="dream") {
            i+=5;
        }
        else if(s.substr(i,6)=="eraser") {
            i+=6;
        }
        else if(s.substr(i,5)=="erase") {
            i+=5;
        }
        else {
            cout<<"NO"<<endl;
            return 0;
        }
        if(i>=n) break;
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
const int MAX_N = 1e6;
vector<bool> isp(MAX_N+1,true);
vector<int> primeNumbers;

void sieve(){
	isp[0] = false;
	isp[1] = false;
	for(int i = 2; i*i <= MAX_N; i++){
		if( isp[i] == true){
			for(int j = 2; i*j <= MAX_N; j++){
				isp[i*j] = false;
			}
		}
	}
	for(int i = 2; i <= MAX_N; i++){
		if(isp[i] == true) primeNumbers.push_back(i);
	}
}

bool isPrime(int num){
	if( num == 0 || num == 1) return false;
	int n = primeNumbers.size();
	for(int i = 0; primeNumbers[i]*primeNumbers[i] <= num; i++){
		if( num == primeNumbers[i]) return true;
		if( num % primeNumbers[i] == 0) return false;
	}
	return true;
}

int gcd(int a,int b){
	if( a < b) return gcd(b,a);
	int r;
	while((r = a%b)){
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	sieve();
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i = 0 ; i < n; i++){
		cin>>A[i];
	}

	set<int> factorList;
	bool isPairWise = true;

	for(int i = 0; i < n; i++){
		if(isPrime(A[i]) == true){
			if( factorList.count(A[i]) != 0){
				isPairWise = false;
				break;
			}else{
				factorList.insert(A[i]);
			}
		}else{
			for(auto iter = primeNumbers.begin(); iter != primeNumbers.end() && (*iter) <= A[i] ; iter++){
				if( A[i] % *iter == 0){
					if( factorList.count(*iter) == 0){
						factorList.insert(*iter);
					}else{
						isPairWise = false;
						break;
					}
				}
			}
		}
	}
	
	int cumProduct = gcd(A[0],A[1]);
	for(int i = 2; i < n; i++){
		cumProduct = gcd(cumProduct,A[i]);
	}
	bool isSetWise;
	if(cumProduct == 1){
		isSetWise = true;
	}else{
		isSetWise = false;
	}
	if( isPairWise == true){
		cout<<"pairwise coprime"<<endl;
	}else if( isSetWise == true){
		cout<<"setwise coprime"<<endl;
	}else{
		cout<<"not coprime"<<endl;
	}
	return 0;
}



Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long N,K,ans;
	cin >> N >> K;
	vector<pair<int,int>> ab(N);
	for(int i=0;i<N;i++){
		cin >> ab[i].first >> ab[i].second;
	}
	sort(ALL(ab));
	for(int i=0;i<N;i++){
		if(K){
			K-=ab[i].second;
		}
		if(K<=0){
			ans = ab[i].first;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[105][100005];
mint cum[105][100005];

int main(){
  int n,K;
  cin >> n >> K;
  int a[n];
  rep(i,n)cin >> a[i];
  dp[0][0]=1;
  // for(int i=1;i<=n;i++){
  //   rep(j,K+1){
  //     rep(k,a[i-1]+1){
  //       if(j-k>=0)dp[i][j]+=dp[i-1][j-k];
  //     }
  //   }
  // }
  for(int i=1;i<=n;i++){
    rrep(j,K+1)cum[i][j]=cum[i][j-1]+dp[i-1][j-1];
    rep(j,K+1)dp[i][j]=cum[i][j+1]-cum[i][max(0,j-a[i-1])];
  }
  // rep(i,n+1){
  //   rep(j,K+1){
  //     cout << dp[i][j];
  //   }
  //   cout << endl;
  // }
  cout << dp[n][K] << endl;
}

Measured memory_bytes: 164352
# AtCoder Beginner Contest 174
# C - Repsept

K=int(input())

modsevens=[7]

if K==7 or K==1:
    print(1)
    exit()
else:
    pass

for i in range (1,K+2):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Measured memory_bytes: 48528
#include<bits/stdc++.h>
#define re register
int a[110],p[1010],pl[110],pr[110];
bool bl[110];
int main()
{
	re int n=0,k,mx=0,mm=0,mk=0;
	scanf("%d",&k);
	for(re int i=1;i<=k;i++)scanf("%d",&a[i]),n+=a[i],mx=std::max(mx,a[i]),pl[i]=k,pr[i]=i;
	for(re int i=1;i<=k;i++)if(a[i]*2<mx){puts("-1");return 0;}
	for(re int i=1;i<=n;i++)
	{
		re int j=1;
		for(;j<=k;j++)
		{
			if(bl[j])continue;
			re bool bb=1;mx=0;
			for(re int i=1;i<=k;i++)mx=std::max(mx,a[i]);
			for(re int i1=1;i1<=pl[j];i1++)if(!bl[pr[i1]])a[pr[i1]]--;
			for(re int i=1;i<=k;i++)if(a[i]*2+2<mx){bb=0;break;}
			if(a[j]*2+1<mx)bb=0;
			for(re int i1=1;i1<=pl[j];i1++)if(!bl[pr[i1]])a[pr[i1]]++;
			if(bb)break;
		}
		assert(j<=k);
		bl[j]=1;p[i]=j;a[j]--;mm++;mk=std::max(mk,pl[j]);
		if(i>=k&&(i==k||mm==mk))
		{
			for(re int j=1;j<=k;j++)bl[j]=0,pl[p[i-k+j]]=j,pr[j]=p[i-k+j];mm=mk=0;
		}
	}
	for(re int i=1;i<=n;i++)printf("%d ",p[i]);
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans = N / (A+B) * A;
    if(N % (A+B) - A < 0){
        cout << ans + N % (A+B) << endl;
        return 0;
    }
    cout << ans + A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define MAX 2000

int main(){
  int n, i, j, a[20], dp[MAX+1], in;

  memset(dp,0,sizeof(dp));

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }

  dp[0] = 1;
  for(i = 0 ; i < n ; i++){
    for(j = MAX ; j >= 0 ; j--){
      if(dp[j] && j + a[i] <= MAX){
        dp[j + a[i]] = 1;
      }
    }
  }
  
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,&in);
    if(dp[in]){
      puts("yes");
    }else{
      puts("no");
    }
  }

  return 0;
}


Measured memory_bytes: 2076
def compress(n, s)
  list = []
  
  obj = [s[0].to_i, 0]
  
  n.times do |i|
    if obj[0] != s[i].to_i then
      list.push(obj.dup)
      
      obj[0] = s[i].to_i
      obj[1] = 1
    else
      obj[1] += 1
    end
  end
  
  list.push(obj.dup)
  
  return list
end

def main(argv)
  (n, k) = gets.chomp.split(' ').map(&:to_i)
  s = gets.chomp
  
  list = compress(n, s)
  
  cumsum = [0] * (list.size + 1)
  list.size.times do |i|
    cumsum[i + 1] = cumsum[i] + list[i][1]
  end
  
  if (list[0][0] == 0) && (list.size < (k + 2)) then
    puts cumsum[list.size].to_s
  elsif (list[0][0] == 1) && (list.size < (k + 3)) then
    puts cumsum[list.size].to_s
  else
    max = 0
    
    i = 0
    while i < list.size do
      m = -1
      if list[i][0] == 0 then
        m = [list.size, (k + (k + 0)) + i].min
      else # list[i][0] == 1
        m = [list.size, (k + (k + 1)) + i].min
      end
      
      max = [max, cumsum[m] - cumsum[i]].max
      
      i += 1
    end
    
    puts max.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 10876
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    int d=gi();

        //System.out.println();
        if (Math.abs(a-c)<=d || (Math.abs(a-b)<=d && Math.abs(b-c)<=d)) {
        	System.out.print("Yes");
        }else {
        	System.out.print("No");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int count = 1;
	int num = a[0];
	int out = 0;
	rep(i, n - 1){
		if(a[i] == a[i + 1]) count++;
		else{
			if(count < num) out += count;
			else out += count - num;
			num = a[i + 1];
			count = 1;
		}
	}
	if(count < num) out += count;
	else out += count - num;
	cout << out << endl;
}


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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	vector<int> x(n),y(n),dir(n);
	rep(i,n){
		char c; scanf("%d%d %c",&x[i],&y[i],&c);
		if(c=='R') dir[i]=0;
		if(c=='U') dir[i]=1;
		if(c=='L') dir[i]=2;
		if(c=='D') dir[i]=3;
	}

	int ans=INF;
	map<pair<int,int>,set<int>> X,Y;
	rep(i,n){
		int dir2=(dir[i]+2)%4;
		if(dir[i]==0){
			auto it=X[{y[i],dir2}].lower_bound(x[i]);
			if(it!=X[{y[i],dir2}].end()){
				ans=min(ans,5*(*it-x[i]));
			}
			X[{y[i],dir[i]}].emplace(x[i]);
		}
		else if(dir[i]==2){
			auto it=X[{y[i],dir2}].lower_bound(x[i]);
			if(it!=X[{y[i],dir2}].begin()){
				ans=min(ans,5*(x[i]-*prev(it)));
			}
			X[{y[i],dir[i]}].emplace(x[i]);
		}
		else if(dir[i]==1){
			auto it=Y[{x[i],dir2}].lower_bound(y[i]);
			if(it!=Y[{x[i],dir2}].end()){
				ans=min(ans,5*(*it-y[i]));
			}
			Y[{x[i],dir[i]}].emplace(y[i]);
		}
		else{
			auto it=Y[{x[i],dir2}].lower_bound(y[i]);
			if(it!=Y[{x[i],dir2}].begin()){
				ans=min(ans,5*(y[i]-*prev(it)));
			}
			Y[{x[i],dir[i]}].emplace(y[i]);
		}
	}

	map<int,set<int>> D1,D2,D3,D4;
	rep(i,n){
		if(dir[i]==1){
			D1[x[i]-y[i]].emplace(x[i]);
			D3[x[i]+y[i]].emplace(x[i]);
		}
		else if(dir[i]==3){
			D2[x[i]-y[i]].emplace(x[i]);
			D4[x[i]+y[i]].emplace(x[i]);
		}
	}
	rep(i,n){
		if(dir[i]==0){
			auto it=D2[x[i]-y[i]].lower_bound(x[i]);
			if(it!=D2[x[i]-y[i]].end()) ans=min(ans,10*(*it-x[i]));
			it=D3[x[i]+y[i]].lower_bound(x[i]);
			if(it!=D3[x[i]+y[i]].end()) ans=min(ans,10*(*it-x[i]));
		}
		else if(dir[i]==2){
			auto it=D1[x[i]-y[i]].lower_bound(x[i]);
			if(it!=D1[x[i]-y[i]].begin()) ans=min(ans,10*(x[i]-*prev(it)));
			it=D4[x[i]+y[i]].lower_bound(x[i]);
			if(it!=D4[x[i]+y[i]].begin()) ans=min(ans,10*(x[i]-*prev(it)));
		}
	}

	if(ans<INF) printf("%d\n",ans);
	else        puts("SAFE");

	return 0;
}


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

int n;

void Edge(int a, int b) {
  printf("%d %d\n", a, b);
}

void Con(void) {
  Edge(1, 2);
  Edge(2, 3);
  Edge(3, n + 1);
  Edge(n + 1, n + 2);
  Edge(n + 2, n + 3);
  for (int t = 4; t < n; t += 2) {
    Edge(n + 1, t);
    Edge(t, t + 1);
    Edge(n + 1, n + t + 1);
    Edge(n + t + 1, n + t);
  }
}

int main(void) {
  scanf("%d", &n);
  if ((n & -n) == n) {
    puts("No");
    return 0;
  }
  puts("Yes");
  Con();
  if (~n & 1) {
    int k = 0;
    while ((1 << k + 1) < n) {
      ++k;
    }
    Edge(n, 1 << k);
    if (n - (1 << k) == 2) {
      Edge(2 * n, 3);
    } else {
      Edge(2 * n, 2 * n - (1 << k) + 1);
    }
  }
  return 0;
}


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

const int M = 998244353;
const int N = 1e5+7;
const long long B = 1000000000000000000;
typedef long long LL;

LL pb[N];
void pre() {
    pb[0] = 1;
    LL b = B%M;
    for (int i=1; i<N; i++)
        pb[i] = (pb[i-1]*b)%M;
}

vector<int> bfs(vector<vector<int>>adj) {
    int n = adj.size()-1;
    vector<int> col(n+1, N);

    vector<bool> vis(n);
    for (int i=n; i>0; i--) {
        for (int v: adj[i]) {
            if (v > i)    vis[col[v]] = 1;
        }

        for (int ii=0; ii<=n; ii++)
            if (!vis[ii]) {
                col[i] = ii;
                break;
            }

        for (int v: adj[i]) {
            if (v > i)    vis[col[v]] = 0;
        }
    }
    return col;
}

int m[3];
vector<vector<int>> adj[3];
vector<int> dis[3];
vector<LL> con[3];

LL power(LL a, LL p) {
    if (p == 0) return 1;
    LL ans = power(a, p/2);
    ans = (ans * ans)%M;
    if (p%2)    ans = (ans * a)%M;
    return ans;
}

void FWHT(vector< LL >&p, bool inverse) {
    int n = p.size();
    assert((n&(n-1))==0);

    for (int len = 1; 2*len <= n; len <<= 1) {
        for (int i = 0; i < n; i += len+len) {
            for (int j = 0; j < len; j++) {
                LL u = p[i+j];
                LL v = p[i+len+j];
                p[i+j] = u+v;
                if (p[i+j] >= M)    p[i+j] -= M;
                p[i+len+j] = u-v;
                if (p[i+len+j] < 0) p[i+len+j] += M;
            }
        }
    }
    if (inverse) {
        LL inv = power(n, M-2);
        for (int i = 0; i < n; i++) {
            p[i] = (p[i] * inv)%M;
        }
    }
}

int main() {
    pre();

    int n;
    cin>>n;
    const int MX = 1<<17;

    for (int g=0; g<3; g++) {
        cin>>m[g];
        adj[g].resize(n+1);
        for (int i=0; i<m[g]; i++) {
            int u, v;
            cin>>u>>v;
            adj[g][u].push_back(v);
            adj[g][v].push_back(u);
        }
        dis[g] = bfs(adj[g]);

        con[g].resize(MX);
        for (int i=1; i<=n; i++) {
            con[g][dis[g][i]] = (con[g][dis[g][i]] + pb[i])%M;
        }
    }

    vector<LL> ans(MX,1);
    for (int g=0; g<3; g++) {
        FWHT(con[g], false);
        for (int i=0; i<MX; i++)
            ans[i] = (ans[i] * con[g][i])%M;
    }

    FWHT(ans, true);
    cout<<ans[0]<<endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string s, t;
    int q;
    cin >> s >> t >> q;
    int lens = (int)s.size(), lent = (int)t.size();

    vector<int> cnts(lens+1), cntt(lens+1);
    for (int i=1; i<lens+1; ++i) {
        if (s.at(i-1) == 'A') cnts.at(i) = cnts.at(i-1) + 1;
        else cnts.at(i) = cnts.at(i-1) + 2;
    }
    for (int i=1; i<lent+1; ++i) {
        if (t.at(i-1) == 'A') cntt.at(i) = cntt.at(i-1) + 1;
        else cntt.at(i) = cntt.at(i-1) + 2;
    }

    vector<bool> res(q);
    for (int i=0; i<q; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int sv = cnts.at(b) - cnts.at(a-1), tv = cntt.at(d) - cntt.at(c-1);
        if (sv%3 == tv%3) res.at(i) = true;
        else res.at(i) = false;
    }
    for (auto b : res) {
        if (b) cout << "YES" << '\n';
        else cout << "NO" << '\n';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 1744
import numpy as np
input()
a = np.array(list(map(int, input().split())))
a = np.delete(a, np.where(a%2==1))
cont = 0
while len(a) > 0:
    cont += 1
    a[0] /= 2
    if a[0] % 2 == 1:
        a = np.delete(a, 0)
print(cont)


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

int main() {
  string s, ans = "Yes";
  cin >> s;
  for( int i = 0; i < s.size(); i++){
  if((i % 2 == 0 && s.at(i) =='L') || (i % 2 && s.at(i) =='R')){
    ans = "No";
  }
  }
  cout << ans << endl;
}

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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    int x, n;
    int p[100];
    cin >> x >> n;
    rep(i, n) cin >> p[i];
    int res;
    res = x;

    bool pflag = false;
    bool nflag = false;
    for (int i = 0; i < 1000; ++i) {
        for (int j = 0; j < n; ++j) {
            if (res - i == p[j]) {
                nflag = true;
            }
            if (res + i == p[j]) {
                pflag = true;
            }
        }
        if (!nflag) {
            res = res - i;
            break;
        } else if(!pflag){
            res = res + i;
            break;
        }
        pflag = false;
        nflag = false;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static long mod = 1000000007;
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int M = s.nextInt();
	int[] A = new int[M];
	int[] B = new int[M];
	
	for(int i = 0; i < M; i++){
		A[i] = s.nextInt()-1;
	    B[i] = s.nextInt()-1;
	}
	
	List<List<Integer>> list = new ArrayList<>();
	for(int i = 0; i < N; i++){
		list.add(new ArrayList<Integer>());
	}

	for(int i = 0; i < M; i++){
		list.get(A[i]).add(B[i]);
		list.get(B[i]).add(A[i]);
	}

	Queue<Integer> queue = new ArrayDeque<Integer>();
	int maxCount = 0;
	boolean[] isVisit = new boolean[N]; 
	for(int i = 0; i < N; i++){
		if(isVisit[i]) continue;
		int count = 0;
		isVisit[i] = true;
		queue.add(i);
		while(queue.peek() != null){
			int v = queue.poll();
			count++;
			for(int j = 0; j < list.get(v).size(); j++){
				if(!isVisit[list.get(v).get(j)]){
					isVisit[list.get(v).get(j)] = true;
					queue.add(list.get(v).get(j));
				}
			}
		}
		maxCount = Math.max(count, maxCount);
	}


	System.out.println(maxCount);

    
  }
}

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

vi normalize(vi v){
	vi ret(4,1e9);
	rep(i,4){
		chmin(ret,v);
		rotate(v.begin(),v.begin()+1,v.end());
	}
	return ret;
}

int calc(vi v){
	int ret = 0;
	vi vc = v;
	rep(i,4){
		if(v == vc)ret++;
		rotate(v.begin(), v.begin()+1, v.end());
	}
	return ret;
}

vi fs[500];
map<vi, P> cnt1;
map<vi, int> cnt2;

signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n){
		vi v(4);
		rep(j,4)cin >> v[j];
		fs[i] = normalize(v);
		int t = calc(fs[i]);
		cnt1[fs[i]].fi++;
		cnt1[fs[i]].se = t;
	}
	
	int ans = 0;
	rep(i,n)rep(j,n){
		if(i == j)continue;
		rep(k,4){
			vi bot = fs[i], top = fs[j];
			cnt2[bot]++;cnt2[top]++;
			rotate(top.begin(), top.begin()+k, top.end());
			int tmp = 1;
			rep(l,4){
				vi side = {bot[0], top[1], top[0], bot[1]};
				side = normalize(side);
				//if(cnt2[side]+1 > cnt1[side].fi)tmp = 0;
				tmp *= cnt1[side].se*(cnt1[side].fi-cnt2[side]);
				cnt2[side]++;
				rotate(top.begin(), top.begin()+1, top.end());
				rotate(bot.begin(), bot.begin()+3, bot.end());
			}
			ans += tmp;
			cnt2.clear();
		}
	}
	printf("%lld\n", ans/6);
	return 0;
}




Measured memory_bytes: 159872
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff

int n,a[200010];

bool check()
{
    for (int i=2;i<=n;i++)
        if (a[i]==a[i-1]) return false;
    return true;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    if (check()) puts("YES");
    else puts("NO");
    return 0;
}

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

#define ll long long

using namespace std;


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

}

Measured memory_bytes: 256