akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using v  = vector<int>;
using vv = vector<v>;

int main() {
	for (int n; (n = in());) {
		vv g = vv(n, v(n));

		for (int i = 1, x = n / 2, y = n / 2 + 1; i <= n * n; i++) {
			g[y++][x++] = i;
			auto shift = [&]() {if (y >= n) y = 0;};
			if (x >= n) x = 0;
			shift();
			if (g[y][x]) {
				x--, y++;
				if (x < 0) x = n - 1;
				shift();
			}
		}

		for (v y: g) {
			for (int x: y)
				printf("%4d", x);
			outl();
		}
	}
}


Measured memory_bytes: 2748
# AGC006B - Median Pyramid Easy
def main():
    N, X = map(int, input().split())
    if 1 < X < 2 * N - 1:
        print("Yes")
        ans = list(range(1, 2 * N))
        print("\n".join(map(str, ans[X - N :] + ans[: X - N])))
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 26584
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
	Scanner scn =new Scanner(System.in);
	int n = scn.nextInt();
	int m =scn.nextInt();
	ArrayList<ArrayList<Integer>>adj = new ArrayList<>();
	for(int i=0;i<=n;i++)
	{
		adj.add(new ArrayList<Integer>());
	}
	for(int i=0;i<m;i++)
	{
		int x = scn.nextInt();
		int y = scn.nextInt();
		adj.get(x).add(y);
	}
	boolean []visited = new boolean[n+1];
	int[]dp = new int[n+1];
	Arrays.fill(dp, -1);
	int max=0;
	for(int i=1;i<=n;i++)
	{
		if(!visited[i]) {
		int d= dfs(i,adj,visited,dp);
		  max=Math.max(max,d);
		}
	}
	System.out.println(max);
	
	
}
   public static int dfs(int v,ArrayList<ArrayList<Integer>>adj,boolean[]visited,int[]dp)
   {
	   if(dp[v]!=-1)
	   {
		   return dp[v];
	   }
	   visited[v]=true;
	   int max=0;
	   for(int nbr:adj.get(v))
	   {
		   if(!visited[nbr])
		   max=Math.max(max, 1+ dfs(nbr,adj,visited,dp)) ;
	   }
	   visited[v]=false;
	   dp[v]=max;
	   return max;
   }
}


Measured memory_bytes: 75344
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto numOdd = 0;
	auto num4 = 0;
	for (auto i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		if (a % 4 == 0)
		{
			++num4;
		}
		else if (a % 2 > 0)
		{
			++numOdd;
		}
	}

	if (numOdd == 0
		|| num4 >= numOdd
		|| (num4 == numOdd - 1 && num4 + numOdd == N))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
#include<map>
using namespace std;

typedef long long ll;

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> res;
  for ( ll i = 2; i * i <= n; i++ ) {
    while( n % i == 0 ) {
      ++res[i];
      n /= i;
    }
  }
  if ( n != 1 ) res[n] = 1;
  return res;
}


vector<ll> divisor(ll n) {
  vector<ll> res;
  for ( ll i = 1; i * i <= n; i++ ) {
    if ( n % i == 0 ) {
      res.push_back(i);
      if( i != n / i ) res.push_back(n/i);
    }
  }
  return res;
}


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

  vector<ll> re2 = divisor(N);
  int ans = 100;
  for ( int i = 0; i < re2.size(); i++ ) {
    ll tmp = N;
    ll tmp2 = tmp /re2[i];
    ll tmp3 = re2[i];
    int keta1 = 0,keta2 = 0;
    while(tmp2>0) {
      tmp2 /= 10;
      keta1++;
    }
    while(tmp3>0) {
      tmp3 /= 10;
      keta2++;
    }
    int keta = max(keta1,keta2);
    ans = min(ans,keta);
    //    cout << re2[i] << endl;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

#define DEBUG 1

int main() {

	int n;
	cin >> n;
	vector<int> x(n), y(n);

	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}

	map<pii, int> mp;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i == j) {
				continue;
			}
			mp[pii(x[i] - x[j], y[i] - y[j])]++;
		}
	}

	int maxi = 0;

	for (auto itr : mp) {

		maxi = max(maxi, itr.second);
	}

	cout << n - maxi << endl;



	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if( ((a+b)%2) == 0){
    ans = (a+b)/2;
    cout << ans << endl;
  }
  else{
    ans = (a+b)/2 + 1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    string s;
    cin >> s;
    if(s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define SZ(x) ((int)(x).size())
#define prts(x) return puts(x),0
#define pirtf(x) return printf("%d\n",x),0
#define re return
typedef long long LL;
typedef double ld;
typedef pair<int,int> pii;
inline int Gcd(int X,int Y){return Y?Gcd(Y,X%Y):X;}
inline LL Gcd(LL X,LL Y){return Y?Gcd(Y,X%Y):X;}
inline int Pow(int B,LL E,int M){if(!(B%=M))return 0;int A=1;for(;E;E>>=1,B=(LL)B*B%M)E&1?A=(LL)A*B%M:0;return A;}
inline LL Pow(LL B,LL E,LL M){if(!(B%=M))return 0;LL A=1;for(;E;E>>=1,B=B*B%M)E&1?A=A*B%M:0;return A;}
const int INF=0x3f3f3f3f;

map<int,int> mp;
set<int> st;

int n,q,m,k;
int a[300005],b[300005];
int f[300005],g[300005];
int M[3005][3005];
char str[300005];

int h[300005],nxt[600005],to[600005],tot;
inline void ins(int x,int y){nxt[++tot]=h[x];to[tot]=y;h[x]=tot;}

LL Ans[300005];

int main(){
	scanf("%d%d",&n,&m);
	F(i,1,m) scanf("%d%d",a+i,b+i), f[i]=i;
	sort(f+1,f+m+1,[](int i,int j){return b[i]<b[j];});
	F(i,1,m){
		int id=f[i];
		Ans[id]=a[id]*1000000ll+(++g[a[id]]);
	}F(i,1,m) printf("%012lld\n",Ans[i]);
	return 0;
}

Measured memory_bytes: 6784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	int h, x, w;
	FOR(i, 1, 3501){
		FOR(j, 1, 3501){
			if((4 * i * j) > (n * (i + j)) && ((n * i * j) % (4 * i * j - n * (i + j)) == 0)){
				h = i;
				x = j;
				w = (n * i * j) / (4 * i * j - n * (i + j));
			}
		}
	}
	cout << h << " " << x << " " << w << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main()
{
  int n, m;
  cin >> n >> m;

  int ac = 0, wa = 0;
  vector<bool> is_ac(n);
  vi wa_count(n);

  rep(i, m)
  {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC")
    {
      // 初めてAC
      if (!is_ac[p])
      {
        is_ac[p] = true;
        ac++;
      }
    } else {
      if (!is_ac[p])
      {
        wa_count[p]++;
      }
    }
  }

  rep(i, n) {
    if (is_ac[i]) {
      wa += wa_count[i];
    }
  }

  cout << ac << " " << wa << endl;
}


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

int main() {
  int x;

  cin >> x;

  for (int a = -1000; a < 1000; a++) {
    for (int b = -1000; b < 1000; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

string a, b;
int n, ans, dl[2005], dr[2005];

int main() {
	ans = 100000;
	cin >> a >> b;
	n = a.length();

	bool z = 1;
	for (int i = 0; i < n; ++i)
		if (b[i] == '1')
			z = 0;
	bool y = 1;
	for (int i = 0; i < n; ++i)
		if (a[i] == '1')
			y = 0;
	if (z == 1 && y == 0) {
		cout << "-1" << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i)
		dl[i] = dr[i] = 10000;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			if (b[(i+j)%n] == '1')
				dr[i] = min(dr[i], j);
		}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			if (b[(i+n-j)%n] == '1')
				dl[i] = min(dl[i], j);
		}

	for (int k = 0; k <= 2*n; ++k) {
		string g;
		for (int j = 0; j < n; ++j)
			g += b[(j+k)%n];
		//want a[i] = g[i] for all i
		int ct = 0;
		vector<pii> v;

		for (int j = 0; j < n; ++j) {
			if (a[j] != g[j]) {
				ct++;
				v.push_back(pii(dl[j], dr[j]));
				//max dr for some dl
			}
		}

		sort(v.begin(), v.end());
		int maxi = k;
		int pt = v.size();

		for (int j = n-1; j >= 0; --j) {
			//go left by j
			while (pt != 0 && v[pt-1].first > j) {
				pt--;
				maxi = max(maxi, v[pt].second);
			}

			ans = min(ans, ct + 2*maxi + 2*j - k);
		}
	}

	for (int i = 0; i < n/2; ++i) {
		swap(b[i], b[n-1-i]);
		swap(a[i], a[n-1-i]);
	}

	for (int i = 0; i < n; ++i)
		dl[i] = dr[i] = 10000;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			if (b[(i+j)%n] == '1')
				dr[i] = min(dr[i], j);
		}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			if (b[(i+n-j)%n] == '1')
				dl[i] = min(dl[i], j);
		}

	for (int k = 0; k <= 2*n; ++k) {
		string g;
		for (int j = 0; j < n; ++j)
			g += b[(j+k)%n];
		//want a[i] = g[i] for all i
		int ct = 0;
		vector<pii> v;

		for (int j = 0; j < n; ++j) {
			if (a[j] != g[j]) {
				ct++;
				v.push_back(pii(dl[j], dr[j]));
				//max dr for some dl
			}
		}

		sort(v.begin(), v.end());
		int maxi = k;
		int pt = v.size();

		for (int j = n-1; j >= 0; --j) {
			//go left by j
			while (pt != 0 && v[pt-1].first > j) {
				pt--;
				maxi = max(maxi, v[pt].second);
			}

			ans = min(ans, ct + 2*maxi + 2*j - k);
		}
	}
	
	cout << ans << endl;	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define ll long long 
using namespace std;
const int mod=998244353;
const int inv2=499122177;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;	
}
int n,u;
ll g[1<<18],f[1<<18],all;
ll qp(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		k>>=1,x=x*x%mod;
	}
	return res;
}
void fwt(ll *tmp,int tp){
	for(re int mid=1;mid<=u;mid<<=1){
		for(re int i=0;i<=u;i+=(mid<<1)){
			inc(j,0,mid-1){
				ll x=tmp[i+j],y=tmp[i+j+mid];
				tmp[i+j]=(x+y)%mod;
				tmp[i+j+mid]=(x-y+mod)%mod;
				if(tp==-1) tmp[i+j]=tmp[i+j]*inv2%mod,tmp[i+j+mid]=tmp[i+j+mid]*inv2%mod;
			}
		}
	}
}
int main(){
	n=read();u=(1<<n)-1;
	inc(i,0,u) f[i]=read(),all+=f[i];
	all=qp(all,mod-2);
	inc(i,0,u) f[i]=f[i]*all%mod;
	g[0]=u;inc(i,1,u) g[i]=mod-1;
	f[0]=(f[0]+mod-1)%mod;
	fwt(f,1),fwt(g,1);
	inc(i,0,u) f[i]=g[i]*qp(f[i],mod-2)%mod;
	fwt(f,-1);
	inc(i,1,u) f[i]=(f[i]-f[0]+mod)%mod;
	puts("0");
	inc(i,1,u) printf("%lld\n",f[i]);
}
/*
2 
1 1 1 1
*/

Measured memory_bytes: 7868
// ABC135-D Digits Parade

#include <bits/stdc++.h>
using namespace std;

#define MOD (1000000007)

void add(long long &a, long long b);

signed  main() {
    string s;
    cin >> s;
    vector<vector<long long>> dp(s.size()+1, vector<long long>(13, 0));

    dp[0][0] = 1;
    for (int i=0 ;i<s.size() ;i++ ) {
        for(int j=0 ;j<13 ;j++ ) {
            if (s[i] == '?') {
                for (int k=0 ;k<10 ;k++ ) {
                    add(dp[i+1][(j*10+k)%13], dp[i][j]);
                }
            }
            else {
                int k = s[i] - '0';
                add(dp[i+1][(j*10+k)%13], dp[i][j]);
            }
        }
    }

    cout << dp[s.size()][5] << '\n';

    return (0);
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

Measured memory_bytes: 16740
#include <bits/stdc++.h>
using namespace std;
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }

class Solver {
  public:
    int price(double p, double x) {
        return floor(p * (100 + x) / 100.0);
    }
    bool solve() {
        int x, y, s; cin >> x >> y >> s;
        if(x == 0) return false;
        int ans = -1;
        repeat(a, 1, s - 1) repeat(b, 1, s - 1) {
            if(price(a, x) + price(b, x) == s) {
                set_max(ans, price(a, y) + price(b, y));
            }
        }
        cout << ans << endl;
        return true;
    }
};

int main() {
    while(Solver().solve());
    return 0;
}

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

int main(){
 
  char S[4];
  cin >> S;
  int count=0;
  
  
  
  
  
  
  
  
  
  for(int i = 0 ; i<3; i++){
    
   	if(S[i]==S[i+1]) 
        count++;
     
  }
  
  if(count){
        cout << "Bad";  
  }
  else{
        cout << "Good";
  }
  
  
}

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

using namespace std;


int main() {
    int n;
    scanf("%d",&n);
    int a[100002]={};
    while(n --){
        int l,r;
        scanf("%d%d",&l,&r);
        for(int i=l;i<=r;i++){
            a[i]=1;
        }
    }
    long long sum=0;
    for(int i=0;i<100002;i++){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    long long N,M,i,j,mod;
    mod=1e9+7;
    cin>>N>>M;
    long long a[N+1],b[N+1];
    for(i=0;i<N+1;i++){
        a[i]=1;
    }
    for(i=0;i<M;i++){
        cin>>j;
        a[j]=0;
    }
    b[0]=1;b[1]=a[1];
    for(i=2;i<N+1;i++){
        b[i]=((b[i-2]+b[i-1])*a[i])%mod;
    }
    cout<<b[N]<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
template <typename Monoid>
struct RMQ {
  RMQ(int sz, const Monoid &UNITY) : UNITY(UNITY) {
    init(sz);
    dat.assign((n << 1) - 1, UNITY);
  }

  RMQ(const vector<Monoid> &a, const Monoid &UNITY) : UNITY(UNITY) {
    int a_sz = a.size();
    init(a_sz);
    dat.resize((n << 1) - 1);
    REP(i, a_sz) dat[n - 1 + i] = a[i];
    for (int i = n - 2; i >= 0; --i) dat[i] = max(dat[(i << 1) + 1], dat[(i << 1) + 2]);
  }

  void update(int node, const Monoid &value) {
    node += n - 1;
    dat[node] = value;
    while (node > 0) {
      node = (node - 1) >> 1;
      dat[node] = max(dat[(node << 1) + 1], dat[(node << 1) + 2]);
    }
  }

  Monoid query(int a, int b) { return query(a, b, 0, 0, n); }

  int find(int a, int b, const Monoid &value) { return find(a, b, value, 0, 0, n); }

  Monoid operator[](const int idx) const { return dat[idx + n - 1]; }

private:
  int n = 1;
  const Monoid UNITY;
  vector<Monoid> dat;

  void init(int sz) { while (n < sz) n <<= 1; }

  Monoid query(int a, int b, int node, int left, int right) {
    if (right <= a || b <= left) return UNITY;
    if (a <= left && right <= b) return dat[node];
    return max(query(a, b, (node << 1) + 1, left, (left + right) >> 1), query(a, b, (node << 1) + 2, (left + right) >> 1, right));
  }

  int find(int a, int b, const Monoid &value, int node, int left, int right) {
    if (dat[node] < value || right <= a || b <= left) return -1;
    if (right - left == 1) return node - (n - 1);
    int res_l = find(a, b, value, (node << 1) + 1, left, (left + right) >> 1);
    if (res_l != -1) return res_l;
    return find(a, b, value, (node << 1) + 2, (left + right) >> 1, right);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> h(n), a(n);
  REP(i, n) cin >> h[i];
  REP(i, n) cin >> a[i];
  RMQ<long long> rmq(n + 1, -INF);
  rmq.update(0, 0);
  REP(i, n) rmq.update(h[i], rmq.query(0, h[i]) + a[i]);
  cout << rmq.query(0, n + 1) << '\n';
  return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[21];
	int min[3];
	int i,j;
	int cnt;
	cin>>n;
	for(i=1;i<=n;i++)	cin>>box[i];
	cnt=0;
	for(i=2;i<n;i++){
		min[0]=box[i-1];
		min[1]=box[i];
		min[2]=box[i+1];
		sort(min,min+3);
		if(min[1]==box[i])	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {

            string str = Console.ReadLine();
            if (str == "-") { break; }
            string temp;
            int count = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; i++)
            {
                int ct = int.Parse(Console.ReadLine());
                temp = str.Substring(0, ct);
                str = str.Remove(0, ct);
                str = str + temp;


            }
            Console.WriteLine(str);
            Console.ReadKey();

        }
    }
}



Measured memory_bytes: 15916
#include "bits/stdc++.h"
using namespace std;

int x,a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>x>>a>>b;
	if(abs(x-a) < abs(x-b))
		cout<<"A";
	else
		cout<<"B";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
	ll N;
	cin >> N;
	vector<long double> a(N);
	REP(i, N){
		cin >> a[i];
	}
	vector<long double> gyaku(N);
	REP(i, N){
		gyaku[i] = 1 / a[i];
	}
	long double sum = 0;
	REP(i, N){
		sum += gyaku[i];
	}
	long double ans = 1/sum;
	cout << ans<< endl;
}

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

int main ()
{
    int n;
    cin >> n;
    double x[n], y[n];
    for (int i = 0;i < n;i++) cin >> x[i];
    for (int i = 0;i < n;i++) cin >> y[i];
    
    double p1 = 0, p2 = 0, p3 = 0, p = 0;
    for (int i = 0;i < n;i++)
    {
        double num = fabs(x[i] - y[i]);
        p1 += num;
        p2 += pow(num,2.0);
        p3 += pow(num,3.0);
        if (num > p) p = num;
    }
    p2 = pow(p2,1/2.0);
    p3 = pow(p3,1/3.0);
    
    cout << setprecision(10) << p1 << endl;
    cout << setprecision(10) << p2 << endl;
    cout << setprecision(10) << p3 << endl;
    cout << setprecision(10) << p  << endl;
    
    return 0;
}


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

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

	int H, W;
	char tmp;

	scanf("%d %d", &H, &W);
	scanf("%c", &tmp);

	vector<vector<int>> S(H, vector<int>(W));
	vector<vector<pair<int, bool>>> d(
	    H, vector<pair<int, bool>>(W, make_pair(H + W + 100, false)));

	int count = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%c", &tmp);
			if (tmp == '.') {
				S[i][j] = 1;
				// d[i][j].second = false;
				count++;
			} else {
				S[i][j] = 0;
				d[i][j].second = true;  // check不要
			}
		}
		scanf("%c", &tmp);
	}
	// printf("count = %d\n", count);

	pair<int, int> check_pos = make_pair(0, 0);
	d[0][0].first = 1;
	int d_pl;
	while (true) {
		// printf("check (%d,%d)\n", check_pos.first, check_pos.second);
		d[check_pos.first][check_pos.second].second = true;
		if (check_pos.first == H - 1 && check_pos.second == W - 1) {
			break;
		}
		d_pl = d[check_pos.first][check_pos.second].first + 1;
		for (auto i : {make_pair(check_pos.first, check_pos.second - 1),
		               make_pair(check_pos.first, check_pos.second + 1),
		               make_pair(check_pos.first - 1, check_pos.second),
		               make_pair(check_pos.first + 1, check_pos.second)}) {
			// printf("(%d, %d) check\n", i.first, i.second);
			if (i.first < 0 || i.first >= H || i.second < 0 || i.second >= W) {
				// printf("out of range\n");
				continue;
			}
			if (d[i.first][i.second].second == true) {
				// printf("already check\n");
				continue;
			}
			// printf("min(%d,%d)\n", d[i.first][i.second].first, d_pl);
			d[i.first][i.second].first = min(d[i.first][i.second].first, d_pl);
		}

		int min_d = H + W + 100;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				// printf("(%d, %d)\n", i, j);
				if (d[i][j].second == true) {
					// printf("(%d, %d) true\n", i, j);
					continue;
				}
				if (d[i][j].first < min_d) {
					min_d = d[i][j].first;
					check_pos = make_pair(i, j);
					// printf("change (%d,%d)\n", check_pos.first,
					//    check_pos.second);
				}
			}
		}
		if (min_d == H + W + 100) {
			printf("-1");
			return 0;
		}
	}

	// printf("retult = %d\n", d[H - 1][W - 1].first);

	printf("%d", count - d[H - 1][W - 1].first);

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = LI()
cnt = 0
for i in range(n):
    if L[L[i] - 1] == i + 1:
        cnt += 1


print(cnt // 2)


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

int main() {
  int N;
  char s;
  bool a=0;
  cin >> N;
  char color[N];
  
  for(int i=0;i<N;i++){
    cin >> color[i];
  }
  for(int i=0;i<N;i++){
    if(color[i]=='Y')
      a += 1;
    else
      a += 0;
  }

  switch(a){
	case 0:cout << "Three" << endl;
      break;
      
    case 1:cout << "Four" << endl;
      break;
  }
  
}


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

int main() {
  int k,x; cin >> k >> x;
  if(k*500>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define ll long long
#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    ll P = 0, W = 0, G = 0, Y = 0;
    ll count = 0;
    char temp;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        cin >> temp;
        switch (temp)
        {
            case 'P':
            P += 1;
            break;
            case 'W':
            W += 1;
            break;
            case 'G':
            G += 1;
            break;
            case 'Y':
            Y += 1;
            break;
        }
    }
    if(P > 0) count += 1;
    if(W > 0) count += 1;
    if(G > 0) count += 1;
    if(Y > 0) count += 1;
    if(count == 3) puts("Three");
    else if(count == 4) puts("Four");
    return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let _: usize = read();
  let a: Vec<u64> = read_vec();
  let ans = a.into_iter().fold(0, |acc, i| divide2(i) + acc);
  println!("{}", ans)
}

fn divide2(n: u64) -> u64 {
  let mut count = 0;
  let mut tmp = n.clone();
  while tmp % 2 == 0 {
    count += 1;
    tmp /= 2;
  }

  return count;
}


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

using namespace std;

int main(){

    long long n,soma=0,num=0,total=0;
    long long i,j,k,l,a,b;

    cin >> n >> a >> b;
    
    for(i=0;i<=9;i++){
        for(j=0;j<=9;j++){
            for(k=0;k<=9;k++){
                for(l=0;l<=9;l++){
                    soma=0;
                    num=0;
                    num=(i*1000)+(j*100)+(k*10)+(l*1);
                    if(num<=n){    
                        soma=i+j+k+l;
                        if((soma>=a)&&(soma<=b)){
                            total+=num;
                        }
                    }
                }
            }
        }
    }
    
    if(n==10000){
        soma=1;
        if((soma>=a)&&(soma<=b)){
            total+=10000;
        }
    }

    cout << total << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define Mod 1000000007

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, K;
	long long A[100001];
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	if (K == 1) {
		printf("0\n");
		fflush(stdout);
		return 0;
	}
	merge_sort(A, N);
	
	long long ans = 0, fact[100001] = {}, comb;
	for (i = 1, fact[0] = 1; i < N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = 0; i < N; i++) {
		if (i >= K - 1) comb = div_mod(div_mod(fact[i], fact[K-1], Mod), fact[i-K+1], Mod);
		else comb = 0;
		if (N - i - 1 >= K - 1) comb -= div_mod(div_mod(fact[N-i-1], fact[K-1], Mod), fact[N-i-K], Mod);
		ans = (ans + A[i] * comb) % Mod;
	}
	printf("%lld\n", (ans >= 0)? ans: ans + Mod);
	fflush(stdout);
	return 0;
}

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

int main(){
	string SA,SB,SC,S;
    cin>>SA>>SB>>SC;
    S=SA;
    char C='a';
    for(int i=0;i<1000;i++){
    	if(C=='a'){
    		if(SA.size()>0){
              C=SA.at(0);
              SA.erase(SA.begin()+0);
              S=SA;
              continue;
              
    		}
    		if(SA.size()==0){
    			cout<<'A'<<endl;
    			break;
    		}
    	}
    	if(C=='b'){
    		if(SB.size()>0){
              C=SB.at(0);
              SB.erase(SB.begin()+0);
              S=SB;
              continue;
              
    		}
    		if(SB.size()==0){
    			cout<<'B'<<endl;
    			break;
    		}
    	}
    	if(C=='c'){
    		if(SC.size()>0){
              C=SC.at(0);
              SC.erase(SC.begin()+0);
              S=SC;
              continue;
              
    		}
    		if(SC.size()==0){
    			cout<<'C'<<endl;
    			break;
    		}
    	}
    }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    string s; cin >> s;
    vec ec(N+1, 0), wc(N+1, 0);
    rep(i, N){
        if(s[i] == 'E'){
            ec[i+1] = ec[i] + 1;
            wc[i+1] = wc[i];
        }else{
            ec[i+1] = ec[i];
            wc[i+1] = wc[i] + 1;
        }
    }
    ll res = INF;
    rep(i, N){
        res = min(res, (ll)wc[i] + (ec[N]-ec[i+1]));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main()
{
	char s[10];
	scanf("%s",s);
	if(strcmp(s,"Sunny")==0)	printf("Cloudy\n");
	else if(strcmp(s,"Cloudy")==0)	printf("Rainy\n");
	else if(strcmp(s,"Rainy")==0)	printf("Sunny\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
int main(){
  int n;
  std::cin >> n;
  int A[n];
  for(int i=0; i<n; i++) std::cin >> A[i];
  for(int i=0,j,key; i<n; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key) A[j+1] = A[j], A[--j+1] = key;
    for(int k=0; k<n; k++) std::cout << A[k] << (k != n-1 ? ' ' : '\n');
  }
  return 0;
}

Measured memory_bytes: 3084
import math
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
def count(U):
    S = sorted(U)
    C = 1
    for i,j in enumerate(U):
        c = 0
        for u,v in enumerate(S):
            if v == j:
                del S[u]
                break
            else:
                c += 1
        C += (math.factorial(N-i-1))*c
    return C
print(abs(count(P)-count(Q)))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	int cnt = 0;
	for(int i = 0; i < 3; i ++) {
		if(str[i]=='R') {
			if(str[i+1] == 'R') {
				if(str[i+2]=='R') {
					cnt = 3;
				} else {
					cnt = 2;
				}
			} else {
				cnt = 1;
			}
			break; 
		}
	}
	cout << cnt << endl;
	return 0;

}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int n,a[200005];
bool check(int mid){
	for (int i=0;i<n-1;i++){
		int s0=0,s1=0;
		if (a[n-i]>=mid&&a[n-i-1]>=mid) s1++;
		if (a[n-i]<mid&&a[n-i-1]<mid) s0++;
		if (a[n+i]>=mid&&a[n+i+1]>=mid) s1++;
		if (a[n+i]<mid&&a[n+i+1]<mid) s0++;
		if (s1) return 1;
		if (s0) return 0;
	}
	return a[1]>=mid;
}
int main(){
	//freopen("mid.in","r",stdin);
	//freopen("mid.out","w",stdout);
	scanf("%d",&n);
	For(i,1,2*n-1) scanf("%d",&a[i]);
	int l=2,r=2*n-1,ans=1;
	while (l<=r){
		int mid=(l+r)/2;
		if (check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d",ans);
}

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll len = 1;
    ll t = n;
    ll sum = 26, p = 26;
    ll q = n;
    while(t > sum){
    	q = n - sum;
    	p = p * 26;
    	sum = sum + p;
    	len++;
    }
    q--;
    // err2(q,p);
    p = p / 26;
    string s;
    while(len--){
    	s += (q / p + 'a');
    	q = q % p;
    	p = p / 26;
    	// err2(q,p);
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3652
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
x,y = map(int,input().split())
a = (x+y)//3
if (x+y)%3:
    print(0)
elif x < a or y < a:
    print(0)
else:
    b = min(x-a,y-a)
    if b:
        print(cmb(a,b,mod))
    else:
        print(1)


Measured memory_bytes: 122056
def main():
    a = [0 for i in range(5)]

    for i in range(3):
        x, y = map(int, input().split())
        a[x] += 1
        a[y] += 1

    flg = 1
    odd_flg = 0
    for i in range(1, 5):
        if a[i] == 0:
            flg = 0
        if a[i] % 2 == 1:
            odd_flg += 1

    if odd_flg > 2:
        flg = 0

    if flg:
        print('YES')
    else:
        print('NO')





if __name__ == '__main__':
    main()

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  printf("%d\n", n / 3);

  return 0;
}


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

#define fastio ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
#define maxn 200002

const int mod = 1e9+7 ;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

ll fac[maxn];

long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return (res * res % mod) * a % mod;
    else
        return (res * res % mod);
}

void kt()
{
	fac[0] = 1;
	fac[1] = 1;
	for (int i = 2; i <  maxn; i++)
	{
		fac[i] = fac[i-1] * i;
		fac[i] %= mod;
	}
}

ll c(ll k, ll n)
{
	assert(n >= k);
	return ((fac[n]) *  binpow((fac[k] * fac[n-k]) % mod, mod - 2)) % mod;
}

signed main()
{
	fastio;
	ll h, w, a, b;	cin >> h >> w >> a >> b;
	kt();
	ll ans = c(h-1, h+w-2);
//	cout << ans << endl;
	for (ll i = 1; i <= a; i++)
	{
		ll temp1 = c(b-1, b + h - i - 1);	// b * (h - i + 1)
		ll temp2 = c(i-1, i + w - b - 2);	// i * (w - b)
		ans = (ans - (temp1 * temp2 % mod) + mod) % mod;
	}
	cout << ans;
}




Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int res;
  rep(i,5) {
    int a; cin >> a;
    if(a == 0) res = i + 1;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double q;
  while(cin >>q,q!=-1){
    double ans = q/2;
    for(;;){
      ans = ans-((ans*ans*ans)-q)/(3*ans*ans);
      if(ans*ans*ans-q<q*0.00001 && -q*0.00001<ans*ans*ans-q) break;
    }
    printf("%.6lf\n",ans);
  }
  return 0;
}

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

using namespace std;

int main()
{
	int x;
	cin >> x;
	if(x<1200)
		cout << "ABC" << endl;
	else if(x<2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    double m=max(100.0/8.0*a,10.0*b);
    double M=min(100.0/8.0*(a+1),10.0*(b+1));
    if(m>=M) cout<<-1<<endl;
    else{
        for(int i=1;true;i++){
            if(i>=m){
                cout<<i<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return(x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  string s;
  cin>>s;
  int64_t N=s.size();
  int64_t ans=0; int64_t a=1;
  for(int64_t i=0;i<N;i++){
  if(s.at(i)=='1'){int64_t b=f(3,N-1-i); ans=(ans+b*a)%mod; a=(a*2)%mod;}
   }ans=(ans+a)%mod;
  cout<<ans<<endl;
  return 0;
}

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

class Program
{
    internal static void Main(string[] args)
    {
        var X = int.Parse(ReadLine());
        var A = int.Parse(ReadLine());
        var B = int.Parse(ReadLine());

        WriteLine((X - A) % B);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

//
int main() {
	int N; cin >> N;
	bool ok = true;
	REP(i, N) {
		int a; cin >> a;
		if (a % 2 != 0) {
			ok = false;
		}
	}
	if (ok)cout << "second" << endl;
	else cout << "first" << endl;
	
	return 0;
}

Measured memory_bytes: 256
module Main where

main :: IO ()
main = do 
  { [a,b] <- map read `fmap` (words `fmap` getLine) :: IO [Int]
  ; let ans = case compare a b of
          LT -> "a < b"
          EQ -> "a == b"
          GT -> "a > b"
  ; putStrLn ans
  }

Measured memory_bytes: 3568
# encoding: utf-8
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]

# used = [[0] * W for i in range(H)]
acts = []
for step in range(H * W - 1):
    i = step // W
    j = (step) % W
    # print(step, (i, j), a)
    if a[i][j] % 2:
        if i == H - 1:
            a[i][j] -= 1
            a[i][j + 1] += 1
            acts.append((i, j, i, j + 1))
        else:
            a[i][j] -= 1
            a[i + 1][j] += 1
            acts.append((i, j, i + 1, j))
    else:
        continue

# output format error ?
# print(len(acts))
# for act in acts:
#     for item in act:
#         print(item + 1, end=" ")
#     print("")
print(len(acts))
for act in acts:
    for i, item in enumerate(act):
        if i > 0: print(" ", sep="", end="")
        print(item + 1, sep="", end="")
    print("", sep="", end="\n")

Measured memory_bytes: 26132
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<cctype>
#include<time.h>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(){
   long long a, b;
   cin >> a >> b;
   cout << ((a*b)&1 ? "Odd" : "Even") << endl;
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;

vector<ll> dp;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m+5, 0);
    for(ll i = 0; i < m; i++){
        cin >> a[i];
    }
    dp.resize(n+5, 0);
    dp[0] = 1;
    int j = 0;
    for(ll i = 1; i <= n; i++){
        if(a[j] == i) {
            if(j != m-1) j++;
            if(i != n) continue;
            else break;
        }
        if(i == 1) dp[i] = dp[i-1];
        if(i > 1) dp[i] = (dp[i-1] + dp[i-2]) % mod;
        // cout << "i: " << i << endl;
        // cout << "dp: " << dp[i] << endl;
    }

    cout << dp[n]%mod << endl;
    return 0;
}

Measured memory_bytes: 4616
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int inf=1e9;
int a[101];
int main()
{
    int mins=inf;
    int  ans;
    int x,n;
    cin>>x>>n;
    int k;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        a[k]=inf;
    }
    for(int i=0;i<=101;i++)
    {
        if(a[i]==inf)
        {
            continue;
        }
        else
        {
            a[i]=abs(x-i);
        }
    }
    for(int i=0;i<=101;i++)
    {
        if(a[i]<mins)
        {
            ans=i;
            mins=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584