akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int main(){
	long long w = 0, cnt = 0;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'W'){
			cnt += i;
			w++;
		}
	}
	w = cnt - w*(w-1)/2;
	printf("%lld\n", w);
}

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

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

  int a, b, c;
  cin >> a >> b >> c;

  if (b - a == c - b) cout << "YES\n";
  else cout << "NO\n";

  return (0);
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define debug(x) cerr << #x << ": " << x << endl;
using namespace std;

int main(){

  int n;
  cin >> n;

  if(n<4){
    cout << "No" << endl;
    return 0;
  }
  if(n%4==0){
    cout << "Yes" << endl;
    return 0;
  }
  if(n%7==0){
    cout << "Yes" << endl;
    return 0;
  }
  while(n!=0){
    if(n%4==0){
      cout << "Yes" << endl;
      return 0;
    }
    if(n%7==0){
      cout << "Yes" << endl;
      return 0;
    }
    if(n>4){
      n -= 7;
    }
    if(n<4){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int n,a,b;
    cin>>n>>a>>b;
    /*if(b-a==1)
        cout<<"Borys"<<"\n";*/
    if((b-a)%2==0)
        cout<<"Alice"<<"\n";
    else if((b-a)%2!=0)
        cout<<"Borys"<<"\n";
}

Measured memory_bytes: 256
n = gets.to_i
a = gets
b = gets
c = gets
count = 0
re = 0

n.times do |i|
    unless a[i] == b[i] then
        count += 1
    end
    unless c[i] == b[i] then
        count += 1 
    end
    unless a[i] == c[i] then
        count += 1
    end
    count -= 1 unless count == 0
    re += count
    count = 0
end
puts re
    


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;string s;
    cin >> n >> s;
    int x=0;
    int d=0,a;
    for(int i = 0; i < n; i++) {
        if(s[i]=='(') d++;
        else d--;
        x=min(x,d);
    }

    for(int i = 0; i < -x; i++) {
        cout << '(';
    }
    cout << s;

    for(int i = 0; i < d-x; i++) {
        cout << ')';
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;
int a[N], test[N];
string s[N];
bool b[N];

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

    int n, m, ac=0, wa=0;
    cin >> n >> m;
    for(int i = 0;i<m;i++){
        cin >> a[i] >> s[i];
        if(s[i] == "AC"){
            if(b[a[i]] == false){
                b[a[i]] = true;
                ac++;
            }
        }
        if(b[a[i]] == true){
            if(test[a[i]] != 0){
                wa += test[a[i]];
                test[a[i]] = 0;
            }
        }
        else if (s[i] == "WA"){
            if(b[a[i]] == false){
                test[a[i]]++;
            }
        }
    }
    cout << ac << " " << wa;
    return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int a, b;
   cin>>a>>b;
   cout<<lcm(a,b);
}


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

int main() {
  int n; cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    m[a]++;
  }
  int ans = 0;
  for (pair<int, int> p : m) {
    if (p.first < p.second) ans += p.second - p.first;
    else if (p.first > p.second) ans += p.second;
  }
  cout << ans << endl;
}

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define Hardmode usleep(1.5 * 1000000);
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i = N;true;i++){
        if(i == 111 || i == 222 || i == 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999){
            cout << i << endl;
            ED
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010;
ll a[N],d[N],vis[N];
ll n,k,t,p,f,r,s,period;
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	p=1;d[0]=1;
	while(1){
		if(vis[p]){
			f=p;
			break;
		}
		vis[p]=1;
		d[t++]=p;
		p=a[p];
	}
	for(int i=0;i<=t;++i){
		if(d[i]==p){
			s=i;
			break;
		}
	}
	period=t-s;
	//printf("s=%lld\nt=%lld\nperiod=%lld\n",s,t,period);
	if(k<=s) printf("%lld\n",d[k]);
	else printf("%lld\n",d[(k-s)%period+s]);
	return 0;
}

Measured memory_bytes: 8396
#include <stdio.h>
#include <math.h>

int main(){
	float x1, x2, x3, x4;
	float y1, y2, y3, y4;
	int n, i;

	scanf("%d", &n);

	for(i=0;i<n;i++){
		scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

		if((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 616
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	long int NN,MM;
	cin >> NN >> MM;
	long int a[NN];
	vector <long int> b;
	b.push_back(0);
	rep(i,NN){
		cin  >> a[i];
		if(i == 0) b.push_back(a[i]%MM);
		else b.push_back((a[i]+b[i])%MM);
	}
	sort(b.begin(),b.end());
	long ans = 0;
	long count = 1;
	long temp = 0;
	Rep(i,1,NN+1){
		if(b[i] == temp) count ++;
		else {
			ans = ans + count * (count - 1) /2; 
			count = 1;
			temp = b[i];
		}
	}
	ans = ans + count * ( count - 1 ) /2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1912
import sys
def input():return sys.stdin.readline().strip()

def main():
    N, H = map(int, input().split())
    info = [tuple(map(int, input().split())) for _ in range(N)]
    A_MAX = max(a for a, _ in info)
    Bs = [b for _, b in info if b > A_MAX]

    Bs.sort(reverse=True)
    ans = 0
    for b in Bs:
        if H <= 0:
            break
        ans += 1
        H -= b

    if H > 0:
        ans += (H + A_MAX-1)//A_MAX
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 23208
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
/* constexpr ll MOD = ll(1e9) + 7LL; */
/* constexpr ll MOD = 998244353LL; */
ll MOD = 200003LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < (int)v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    REP(i, n) {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    REP(i, q) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            fw.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


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

int n;
int x[115],y[115],h[115];

int main(){
	cin>>n;
	rep(i,n)cin>>x[i]>>y[i]>>h[i];
	rep(i,101){
		rep(j,101){
			int d=-1;
			int ma=1100000000;
			rep(k,n){
				
				if(d==-1){
					if(h[k]==0)ma=min(ma,abs(i-x[k])+abs(j-y[k]));
					else d=h[k]+(abs(i-x[k])+abs(j-y[k]));
				}
				else{
					if(h[k]==0)ma=min(ma,abs(i-x[k])+abs(j-y[k]));
					else if(d!=h[k]+(abs(i-x[k])+abs(j-y[k])))goto age;
				}
				if(ma<d)goto age;
			}
			cout<<i<<" "<<j<<" "<<d<<endl;
			return 0;
			age:;
		}
	}
	
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s){
		ll ans1=0, ans2=0;
		rep(i, s.size()-2){
			string sub = s.substr(i, 3);
			if (sub=="JOI") ans1++;
			if (sub=="IOI") ans2++;
		}
		cout << ans1 << endl;
		cout << ans2 << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
typedef long long  LL;
const int N=100010;
struct edge{int s,t,n;}e[2*N];
int n,m,len,h[N],s[N],col[N],fa[N],ufs[N],inC[N],a[N];
LL ans;
 
int find(int x){return ufs[x]==x?x:ufs[x]=find(ufs[x]);}
 
void dfs(int x,int f)
{
	col[x]=-col[f],s[x]=col[x],fa[x]=f;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=f)  dfs(y,x),s[x]+=s[y];
}
 
void work()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=n; i++)  ufs[i]=i;
	int x=1,y;
	for (int i=1,u,v,tot=0; i<=m; i++)
		{
			scanf("%d %d",&u,&v);
			if (find(u)!=find(v))
				{
					e[++tot]=(edge){u,v,h[u]},h[u]=tot;
					e[++tot]=(edge){v,u,h[v]},h[v]=tot;
					ufs[find(u)]=find(v);
				}else  x=u,y=v;
		}
	col[0]=-1,dfs(x,0);
	if (m==n-1)
		{
			if (s[1])  puts("-1"),exit(0);
			for (int i=1; i<=n; i++)  ans+=fabs(s[i]);
		}else
		{
			for (int i=y; i; inC[i]^=1,a[++len]=s[i],i=fa[i]);
			if (len&1)
				{
					if (s[x]&1)  puts("-1"),exit(0);
					for (int i=1; i<=n; i++)
						if (inC[i])  ans+=fabs(s[i]-s[x]/2);
						else  ans+=fabs(s[i]);
				}else
				{
					if (s[x])  puts("-1"),exit(0);
					sort(a+1,a+len+1);
					for (int i=1; i<=n; i++)
						if (inC[i])  ans+=fabs(s[i]-a[len/2]);
						else  ans+=fabs(s[i]);
				}
		}
	printf("%lld",ans);
}
 
int main()
{
	work();
	return 0;
}

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

int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	int n;
	cin >> n;
	int b = max(h,w);
	int a = h + w - b;
	int cnt = 0;
	int ans = 0;
	while(1){
		ans += b;
		cnt++;
		if(ans >= n) break;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input().rstrip())
red = []
white = []
stones = input().rstrip()
for idx, stone in enumerate(stones):
  if stone == "R":
    red.append(idx)
  if stone == "W":
    white.append(idx)
red_len = len(red)
white_len = len(white)
cnt = 0
for i in range(min(red_len, white_len)):
  red_idx = red[-1-i]
  white_idx = white[i]
  if red_idx> white_idx:
    cnt += 1
  else:
    break
print(cnt)

Measured memory_bytes: 17292
#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 bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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 namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B; cin >> A >> B;

    cout << A * B / __gcd(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using S = int;

S op(S x, S y) {
	return max(x, y);
}

S e() {
	return S{0};
}

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	segtree<int, op, e> st(300001);
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		st.set(a, st.prod(max(0, a-k), min(300001, a+k+1))+1);
	}
	cout << st.all_prod() << "\n";
	return 0;
}

Measured memory_bytes: 8512
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(404);
int64_t sp[N], dp[N][N];
int n;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> sp[i];
        sp[i] += sp[i - 1];
    }
    for (int j = 2; j <= n; ++j)
        for (int i = j - 1; i > 0; --i) {
            dp[i][j] = 1e18;
            for (int k = i; k < j; ++k)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sp[j] - sp[i - 1]);
        }
    cout << dp[1][n];
    PLEC
}


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

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(q),r(q),vec(n);
  for(int i = 0; i < q; i++){
    cin >> l.at(i) >> r.at(i);
  }
  for(int i = 1; i < n; i++){
    if((s[i-1]=='A')&&(s[i]=='C')) vec.at(i) = vec.at(i-1)+1;
    else vec.at(i) = vec.at(i-1);
  }
  for(int i = 0; i < q; i++) cout << vec.at(r.at(i)-1)-vec.at(l.at(i)-1) << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n;
    cin >> n;
    map<int, bool> m;
    rep(i, n) {
        int a;
        cin >> a;
        if(m[a]) {cout << "NO" << endl; END;}
        m[a] = true;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include<iostream> 
using namespace std;
int v[101];
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	v[a]++, v[b]++, v[c]++;
	int ans = 0;
	for (int i = 1; i <= 100; i++) {
		if (v[i] > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int x , a , b;

int main()
{
	cin >> x >> a >> b;
	a = a-x;
	if(a < 0)
	{
		a = -a;
	}
	b = b-x;
	if(b < 0)
	{
		b = -b;
	}
	if(a < b)
	{
		cout << "A" << endl;
	}
	else
	{
		cout  << "B" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

# print(L)

ans=0
for a_idx in range(len(L)):
    a = L[a_idx]
    for b_idx in range(a_idx+1,len(L)):
        b = L[b_idx]
        c_low = b - a
        c_up = a + b - 1
        
        c_low_idx = bisect.bisect(L,c_low)
        c_up_idx = bisect.bisect(L,c_up)
        
#         print('=====')
#         print(a,b)
#         print(c_low_idx,c_up_idx)
        
        c_low_idx = max(b_idx,c_low_idx)
        
        ans += max(0,c_up_idx-c_low_idx-1)
#         print(ans,c_low_idx,c_up_idx)
print(ans)

Measured memory_bytes: 75040
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(K: int, S: int):
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S-x-y <= K:
                ans += 1

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


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

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

  vector<bool> flags(8);
  fill(flags.begin(), flags.end(), false);

  int fcnt = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;

    int idx = a / 400;
    if (idx >= 8) {
      fcnt++;
      continue;
    }

    flags[idx] = true;
  }

  int ccnt = 0;
  for (int i = 0; i < flags.size(); i++) {
    if (flags[i]) {
      ccnt++;
    }
  }

  cout << max(ccnt, 1) << ' ' << ccnt + fcnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    string S; cin >> S;
    ll sum = 0;
    rep(i, S.size()){
        ll x = S.at(i) - '0';
        sum += x;
    }
    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <boost/math/common_factor.hpp> 
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int N = 1e5 + 10;
int main() 
{  ll a,b,c;
cin>>a>>b;
c=boost::math::lcm(a,b);
    cout<<c; 
         
    return 0; 
} 

Measured memory_bytes: 256
N, Y = gets.chomp.split(" ").map(&:to_i)
flag = 0

for i in 0..N do
  for j in 0..(N - i) do
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y
      puts "#{i} #{j} #{N - i - j}"
      flag = 1
      exit
    end
  end
end

if flag == 0
  puts "-1 -1 -1"
end


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	for (int i=0; i<3; i++) {
		string S;
		cin >>S;
		cout <<S.at(i);
	}
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256
renga = int(input())

rengaList = input().split()
nowSearchRenga=1
cnt = 0
for i in range(renga):
  if int(rengaList[i]) == nowSearchRenga:
    nowSearchRenga=nowSearchRenga+1
    continue
  else:
    cnt=cnt+1
    
if i+1 == cnt:
  print(-1)
else:
  print(cnt)


Measured memory_bytes: 73600
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def calcTwoPointDistance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, D = il()
    XY = [il() for _ in range(N)]

    ret = 0
    for x, y in itertools.combinations(XY, 2):
        tmp = 0
        for d in zip(x, y):
            tmp += abs(d[0] - d[1])**2

        if (tmp ** 0.5).is_integer():
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10432
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] array= new int[n];

        for(int i= 0; i < n;i++){
            array[i] = scan.nextInt();
        }

        int ans = 0;
        for(int i= 0; i <= n-3 ;i++){

            if( array[i] < array[i+1] && array[i+1] < array[i+2]){

                ans++;

            }else if(array[i] > array[i+1] && array[i+1] > array[i+2]) {

                ans++;
            }
        }

        System.out.println(ans);




        return;

    }
}

Measured memory_bytes: 23636
def solve
    n = gets.to_i
    a = gets.split.map!(&:to_i)
    ans = [0]*n

    (0..(a.length - 1)).each do |j|
        ans[a[j]-1] += 1     
    end

    (0..n-1).each do |i|
        p ans[i]         
    end

end
solve

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w_cap;
    cin >> n >> w_cap;
    VI w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    VVL dp(n + 1, VL(w_cap + 10, 0));
    
    FOR(i, 1, n)REP(j, w_cap + 1) {
        if(j - w[i - 1] < 0) dp[i][j] = dp[i - 1][j];
        else dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
    }
    
    cout << *max_element(ALL(dp[n])) << ln;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool flg = true;
  for(int i; i < s.length(); i++){
    if(i%2 == 0){ //奇
      if(s.at(i) == 'L'){
        flg=false;
      }
    } else { //偶
      if(s.at(i) == 'R'){
        flg=false;
      }
    }
  }
  if(flg == true) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var nm = Input3();
            var n = nm[0];
            var m = nm[1];
            var h = Input3();
            var ans = 0;
            var bad = new bool[n];

            for(int i = 0; i < m; i++)
            {
                var ab = Input3();
                var a = ab[0]-1;
                var b = ab[1]-1;
                if (h[a] > h[b]) bad[b] = true;
                else if (h[b] > h[a]) bad[a] = true;
                else
                {
                    bad[a] = true;
                    bad[b] = true;
                }
            }

            for(int j = 0; j < n; j++)
            {
                if (!bad[j]) ans++;
            }
            

            
            
            
            Console.WriteLine(ans);



        }






    





        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 48780
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    int h,a,cnt=0;
    cin>>h>>a;
 if(h%a==0)
 {
     cnt=h/a;
 }
 else
    cnt=h/a+1;
  cout<<cnt<<endl;


    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value
int N;
int A[100010];

void solve() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int ans[3];
	ans[0] = A[1];
	ans[1] = A[0];
	ans[2] = gcd(A[0],A[1]);
	for (int i = 2; i < N; i++) {
		ans[0] = max(gcd(ans[0], A[i]), gcd(ans[1], A[i]));
		ans[1] = ans[2];
		ans[2] = gcd(ans[2], A[i]);
	}

	sort(ans, ans + 3);

	cout << ans[2] << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 640
mod=998244353
n,s=map(int,input().split())
ar=list(map(int,input().split()))
dp=[0 for y in range(s+1)]
dp[0]=1
for i in range(n):
    for j in range(s,-1,-1):
        if j+ar[i]<=s:
            dp[j+ar[i]]=(dp[j]+dp[j+ar[i]])%mod
        dp[j]=(dp[j]*2)%mod
print(dp[s])


Measured memory_bytes: 68748
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll Q, H, S, D; cin >> Q >> H >> S >> D;
  ll N; cin >> N; N *= 4;
  vector<pair<ll, ll> > syohin = {{1, Q}, {2, H}, {4, S}, {8, D}};
  vector<pair<ll, int> > tanka = {{8*Q, 0}, {4*H, 1}, {2*S, 2}, {D, 3}};
  sort(tanka.begin(), tanka.end());
  
  ll ans = 0;
  REP(i, 4){
    ans += N / syohin[tanka[i].second].first * syohin[tanka[i].second].second;
    N = N % syohin[tanka[i].second].first;
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n), dp(n);
    for(int i=0; i<n; i++) cin >> h[i];
    dp[1] = abs(h[0] - h[1]);
    for(int i=2; i<n; i++) dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int cnt[N], a[N], num[N], is[N];
bool mark[N];
deque <pii> v;

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		is[a[i]] = i;
		mark[a[i]] = true;
		v.pb({a[i], i});
	}	
	for(int i = 1; i <= n; i++)
		num[i] = n;
	sort(v.begin(), v.end());
	vector <int> t;
	for(int i = 1; i <= n * n; i++) {
		if(cnt[i] != 0) {
			if(num[cnt[i]] != 0)
				t.pb(cnt[i]);
			continue;
		}
		if((int)v.size() > 0) {
			while(cnt[i] == 0 && (int)v.size()) {
				pii p = v.front();
				num[p.ss]--;
				v.pop_front();
				if(num[p.ss] == n - p.ss) {
					if(p.ff == i) 
						if(num[p.ss])
							t.pb(p.ss);
					cnt[p.ff] = p.ss;
				}
				else {
					cnt[i] = p.ss;
					v.push_front(p);
					break;
				}
			}
		}
		if(cnt[i] == 0) {
			if((int)t.size() == 0)
				return cout << "No" << endl, 0;
			int h = t.back();
			if(num[h] == 1)
				t.pop_back();
			num[h]--;
			cnt[i] = h;
		}
		if(mark[i] && is[i] != cnt[i])
			return cout << "No" << endl, 0;
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= n * n; i++)
		cout << cnt[i] << " ";
	cout << endl;
    return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 7248
#include<bits/stdc++.h>
using namespace std;
int main(){
    string x,y="CODEFESTIVAL2016";
    cin>>x;
    int s=16;
    for(int i=0;i<y.size();i++){
        if(x[i]==y[i])
        --s;
    }
    cout<<s;
    return 0;
}

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

typedef long long ll;
static const int INF=1e9;
static const int MAX_N=210;
ll dist[MAX_N][MAX_N];

void init(int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            dist[i][j]=INF;
            dist[i][i]=0; //同じ地点を訪れる場合距離０
        }
    }
}

void warshall_floyd(int n){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
            }
        }
    }
}

int main(){
    int n,m,R;
    cin >> n >> m >> R;
    int r[R];
    for(int i=0;i<R;i++){
        cin >> r[i];
        r[i]--;
    }
    sort(r,r+R); //next_permutationを使用するため
    init(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    warshall_floyd(n);
    ll res=INF;
    do{
        long long tmp=0;
        for(int i=1;i<R;i++){
            tmp+=dist[r[i]][r[i-1]];
        }
        res=min(res,tmp);
    }while(next_permutation(r,r+R));

    cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
long long compute(string s, int i){
// 	cout << i << endl;

	long long sum = 0;
	long long tmp = s[0] - '0';
	for(int j = 1; j < s.length();j++){
		int num = s[j] - '0';
		if(i & (1 << (j-1))){
			sum += tmp;
			tmp=num;
		}else{
			tmp*=10;
			tmp+=num;
		}
	}
	sum+=tmp;
	return sum;
}

long long solve(string s){
	long long res = 0;
	for(int i = 0; i < (1 << (s.length() - 1)); i++){
// 		cout << compute(s,i) << endl;
		res += compute(s,i);
	}
	return res;
}

int main(){
	string s;
	cin >> s;
	cout << solve(s) << endl;
}



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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if ( A >= K ) {
    cout << K << endl;
  }
  else if ( A + B >= K ) {
    cout << A << endl;
  }
  else {
    cout << A - ( K - A - B ) << endl;
  }
    

}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	long long n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	long long ss=a+b;
	long long ans=n/ss;
	if(n%ss<a){
		printf("%lld",ans*a+n%ss);
	}else{
		printf("%lld",ans*a+a); 
	}
} 

Measured memory_bytes: 128
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

const ll mod = 1e9+7;
int solve()
{
	ll n,k;cin>>n>>k;
	ll ans=0;
	rep(i,k,n+2)
	{
		ll mn = (i*(i-1))/2;
		ll mx = n*i - (i*(i-1))/2;

		ans+=mx-mn+1;
		ans%=mod;
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3652
#include   <bits/stdc++.h>
#include   <stdlib.h>
#include   <stdio.h>
#define    pb push_back
#define    mp make_pair
#define    ii   int
#define    ll  long long
#define    pii  pair<ii,ii>
#define    pll  pair<ll,ll>
#define    vcii   vector<ii>
#define    vcll   vector<ll>
#define    vcd     vector<double>
#define    vpii   vector<pair>
#define    scll(x)  scanf("%lld",x)
#define    pfll(x) printf("%lld\n",x)
#define    scd(x) scanf("%llf",x)
#define    pfd(x) prinf("%0.5llf\n",x)
#define pie acos(-1)

using namespace std;
ll Bigmod(ll a,ll b,ll m);
vector<ii> sieve(int n);
void divisor(int n);
void coprime(ll n);
ll gcd(ll a,ll b);
int p[10000],m[1000];

int main()
{

    ll n,a,b,m;
    cin>>(a);
     cout<<fixed<<setprecision(20)<<2*pie*a<<endl;

    return 0;
}


/*void divisor(int n)
{
      vcii divi[n+1];

      for(int i=1;i<=n;i++)
      {
        for(int j=i;j<=n;j+=i)
        {
          divi[j].pb(i);
        }
      }
    for(int i=1;i<=n;i++)
    {
       for(int j=0;j<divi[i].size();j++)
       {
         cout<<divi[i][j]<<" ";
       }
       cout<<endl;
    }
}
*/

/*vector<ii> sieve(int n)
{
    vci prime;
    map<int,bool>mm;
    int i,j;
    for(i=4; i<=n; i+=2)
        mm[i]=true;
    prime.pb(2);
    for(i=3; i<=n; i+=2)
    {
        if(!mm[i])
        {
            prime.pb(i);

            if(i<=sqrt(n)+2)
            {
                for(j=i*i; j<=n; j+=(i*2))

                {
                    mm[j]=true;

                }
            }
        }
    }
    return prime;
}*/
/*
ll gcd(ll a ,ll b)
{
    if(a==0) return b;

    return gcd(b%a,a);


}
*/
/*

void coprime(ll n)
{
    ll i,j;

    ll p[n+1];
    map<ll,bool>m;
    for(i=1;i<=n;i++)p[i]=i;
    for(i=2;i<=n;i+=2)
    {
        if(i!=2)
        {
            m[i]=1;

        }
        p[i]=p[i]/2;
    }
    p[1]=1;
    m[1]=1;
    for(i=3;i<=n;i+=2)
    {
        if(!m[i])
        {
            p[i]=p[i]-1;
            for(j=i*2;j<=n;j+=i)
            {
                m[j]=1;
                p[j]=p[j]/i*(i-1);
            }

        }
    }

    for(i=1;i<=n;i++)
    {
        cout<<p[i]<<"\n";
    }



}

*/
/*
ll Bigmod(ll a,ll b,ll m)
{
    if(b==0) return 1%m;

    ll x=Bigmod(a,b/2,m);
    x=(x*x)%m;

    if(b%2==1)  x=(x*a)%m;

    return x;
}

*/


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

using namespace std;

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


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int k;
	scanf("%d",&k);
	if(k % 2 == 0){printf("-1\n"); return 0;}
	int tot = 0;
	for(int i=0;i<90000000;i++){
		tot *= 10;
		tot %= k;
		tot += 7;
		tot %= k;
		if(tot == 0){printf("%d\n",i+1); return 0;}
	}
	printf("%d\n",-1);
	
	return 0;
};

Measured memory_bytes: 3800
#include <fstream>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <cassert>
#include <deque>
#include <set>
#include <map>
#include <vector>
#include <regex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

ll a[(int)1e5 + 1];
ll b[(int)1e5 + 1];

//#define LOCAL_DEBUG
int main() {
#ifdef LOCAL_DEBUG
	freopen("input1.txt","r", stdin);
#endif
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		cin >> b[i];
	}

	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		int t = (a[i] + ans) % b[i];
		if (t != 0) ans += b[i] - t;
	}

	cout << ans << endl;

 	return 0;
}


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

using namespace std;

int main() {
	long n;
	long ans = 0;
	long min = 1000000000000000;
	cin >> n;
	vector<long> city(6,0);
	vector<long> move(5);
	for (int i = 0;i < 5; i++){
		cin >> move.at(i);
		if (min > move.at(i)){
			min = move.at(i);
		}
	}
	//cout << "dbg min " << min << endl;
	if (n % min){
		ans = n / min + 1 + 4;
	} else {
		ans = n / min + 4;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
//sort(y,y+j, greater<int>());
ll x[1000000],y[1000000],a[1000000];
int main()
{ ll b,c,d,e,f,i,j,n,p;
   in>>n;
    for(i=0;i<n;i++)
    {
        in>>a[i];
    }
    ll  count = 0;
    for ( i = 1; i < n; i++)
    {

        if (a[i] < a[i - 1])
        {
             p = (a[i - 1] - a[i])  ;

            count += p;
            a[i] += p ;
        }
    }
    out<<count<<nl;
}


Measured memory_bytes: 5124
N = int(input())
D = {}
for _ in range(N):
    s = input()
    D[s] = D.get(s, 0) + 1

L = [(D[d], d) for d in D] + [(0, "*")]
L.sort(key=lambda x: x[1])
L.sort(key=lambda x: x[0], reverse=True)

i = 0
while L[0][0] == L[i][0]:
    print(L[i][1])
    i += 1


Measured memory_bytes: 46932
#include <stdio.h>

int main(void){
	int N,i;
	scanf("%d",&N);
	int d[N];
	int flag[101];
	for(i=1;i<=100;i++){flag[i]=0;}
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
		flag[d[i]] = 1;
	}
	int ans = 0;
	for(i=1;i<=100;i++){ans += flag[i];}
	printf("%d",ans);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<ll> a(n);
    bool zero = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) zero = true;
    }
    ll ma = (zero ? 0 : 1);
    for (int i = 0; i < n; i++) {
        if (a[i] != 0 && ma > HIGHINF / a[i]) {
            cout << -1 << '\n';
            return 0;
        }
        ma *= a[i];
    }
    cout << ma << '\n';
    return 0;
}


Measured memory_bytes: 3992
n=int(input())

a=[]
b=[]
for i in range(n):
  s,p=list(input().split())
  a.append([s,int(p)])
  b.append([s,int(p)])
  
a.sort(key=lambda x:x[1],reverse=True)
a.sort(key=lambda x:x[0])

for i in a:
  print(b.index(i)+1)
  
  

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

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

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

using namespace std;

const int N = 200'009;

int t[N];
int r[N];
int o[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", t + i, r + i);
    o[i] = i;
  }
  sort(o, o + n, [](int i, int j) {
    return r[i] < r[j];
  });
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    pos += t[o[i]];
    if (pos > r[o[i]]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 2560
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 1e19

"""
abcdef
f +4(f-e) + 9+(e-d) + 16(d-c) + ...
= 5f + 5e + 7d + 9c + 11b + 13a
"""
mul = [5] + [5 + 2*i for i in range(N)]
#print(mul)

CX = [0] * (N+1)

#cum_sum
for i in range(N):
  CX[i+1] = CX[i] + A[i]
  
for k in range(1,N+1): # Number of robots (this loop will be ended early)
  cost = N*X + k*X # pickup and throw costs(fixed with k)
  
  # partial point answer (not using cumulative sum)
  # for i in range(1,N+1):
  #  cost += A[N-i] * mul[(i-1)//k]
  ix = N
  loopc = 0
  while ix > 0:
    if ix-k > 0:
      cost += (CX[ix] - CX[ix-k]) * mul[loopc]
    else:
      cost += (CX[ix]) * mul[loopc]
    loopc += 1
    ix -= k
  
  #print(k,cost)
  ans = min(ans,cost)
  if N//k <= 1: # early stopping (after mul is 5 for all A's, cost is monotonicaly increasing)
    print(ans)
    exit(0)
    
#print(ans)
  
  

Measured memory_bytes: 100944
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

#define GRAPH_SIZE 100001

enum status_t {
  WHITE,
  BLACK,
};

static vector<uint32_t> tree[GRAPH_SIZE];
static uint32_t distance_from1[GRAPH_SIZE];
static uint32_t distance_fromN[GRAPH_SIZE];
static status_t status[GRAPH_SIZE];

static void dist(uint32_t index, uint32_t d, void (*callback)(uint32_t i, uint32_t dist))
{
  status[index] = BLACK;
  callback(index, d);
  for (uint32_t i = 0; i < tree[index].size(); i++) {
    int32_t to = tree[index][i];
    if (status[to] != BLACK) {
      dist(to, d + 1, callback);
    }
  }
}

static void callback1(uint32_t i, uint32_t dist)
{
  distance_from1[i] = dist;
}

static void callbackN(uint32_t i, uint32_t dist)
{
  distance_fromN[i] = dist;
}

int32_t main()
{
  uint32_t num;
  cin >> num;

  for (uint32_t i = 1; i < num; i++) {
    uint32_t a, b;
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  for (uint32_t i = 1; i <= num; i++) {
    status[i] = WHITE;
    distance_from1[i] = 0;
  }
  dist(1, 0, callback1);

  for (uint32_t i = 1; i <= num; i++) {
    status[i] = WHITE;
    distance_fromN[i] = 0;
  }
  dist(num, 0, callbackN);

  uint32_t black = 0, white = 0;
  for (uint32_t i = 1; i <= num; i++) {
    if (distance_from1[i] <= distance_fromN[i]) {
      black++;
    } else {
      white++;
    }
  }

  if (white < black) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }

  return 0;
}


Measured memory_bytes: 11520