akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long iso0 = 0;
		long iso = 0;
		for(int i=0;i<N;i++) if(E[i].Count == 0) iso0++;
		iso = iso0 * N * 2 - (iso0 * iso0);
		long bi = 0;
		long nbi = 0;
		
		int[] used = new int[N];
		for(int i=0;i<N;i++){
			if(used[i] != 0) continue;
			used[i] = 1;
			Queue<int> Q = new Queue<int>();
			Q.Enqueue(i);
			bool chk = true;
			while(Q.Count>0){
				var now = Q.Dequeue();
				foreach(var nxt in E[now]){
					if(used[nxt] == 0){
						used[nxt] = 3 - used[now];
						Q.Enqueue(nxt);
					} else {
						if(used[nxt] == 3 - used[now]) continue;
						chk = false;
					}
				}
			}
			if(chk){
				bi++;
			}else{
				nbi++;
			}
			//Console.WriteLine(String.Join(" ",used));
		}
		//Console.WriteLine("{0} {1}",bi,nbi);
		
		bi -= iso0;
		long bb = 2 * bi * bi;
		long bn = bi * nbi;
		long nb = nbi * bi;
		long nn = nbi * nbi;
		Console.WriteLine(iso + bb + bn + nb + nn);
		
	}
	int N,M;
	List<int>[] E;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=0;i<M;i++){
			d = ria();
			E[d[0]-1].Add(d[1]-1);
			E[d[1]-1].Add(d[0]-1);
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 28132
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    int n = s.length();
    int sum = 0;
    rep(i,n) {
        sum += (s[i]-'0');
    }

    if (sum % 9 == 0) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3676
n,k = map(int,input().split())
h = []

for _ in range(n):
    tmp = int(input())
    h.append(tmp)

h.sort()

ans = []
for i in range(n-k+1):
    tmp = h[i+k-1] - h[i]
    ans.append(tmp)
print(min(ans))

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

int main() {
  int num =0;
  vector<char> ans(10);
  string vec;
  
  cin >> vec;
  
  
  for(int i=0;i<vec.size();i++){
    if(vec.at(i)=='0'){
      ans.at(num)='0';
      num++;
    }
    if(vec.at(i)=='1'){
      ans.at(num)='1';
      num++;
    }
    if(vec.at(i)=='B'){
      ans.pop_back();
      if(num!=0){
         num--;
      }
    }
  }
  for(int i=0;i<num;i++){
    cout << ans.at(i);
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,d[200],r,x;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){cin>>d[i];x+=d[i];}
	for(int i=0;i<n;i++)r+=d[i]*(x-d[i]);
	cout<<r/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=1e5+5,mod=1e9+7;
int n,ans=1;
int a[maxn],d[maxn],vis[maxn],len[maxn],q[maxn],cnt[maxn],f[maxn];
void solve(int n,int m){
	int now=1+(n>1&&(n&1));
	f[0]=1;
	f[1]=now;
	rep(i,2,m)f[i]=(1ll*now*f[i-1]%mod+1ll*(i-1)*n%mod*f[i-2]%mod)%mod;
	ans=1ll*ans*f[m]%mod;
}
int main(){
	read(n);
	rep(i,1,n)read(a[i]),d[a[i]]++;
	rep(i,1,n)if(d[i]>2)ans=0;
	rep(i,1,n)if(!d[i]){
		int j=i,l=0;
		for(;d[j]<2;j=a[j],l++)vis[j]=1;
		len[j]=l;
	}
	rep(i,1,n)if(!vis[i]){
		int tot=0,j;
		for(j=i;!vis[j];j=a[j])vis[j]=1,q[++tot]=j;
		if(j!=i)ans=0;
		int cir=1;
		rep(j,1,tot)if(len[q[j]])cir=0;
		if(cir)cnt[tot]++;
		else{
			int maxl=1;
			per(j,tot,1)
				if(!len[q[j]])maxl++;
				else break;
			rep(j,1,tot)
				if(len[q[j]]){
					if(len[q[j]]<maxl)ans=2ll*ans%mod;
					if(len[q[j]]>maxl)ans=0;
					maxl=1;
				}else maxl++;
		}
	}
	rep(i,1,n)if(cnt[i])solve(i,cnt[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

unsigned long long su=1;;
int isu;
	
	cin >> isu;
	rep(i,isu)
		su *= isu - i;
	cout << su << endl;
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int width = sc.nextInt();
		int height = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		int min_x = x - r;
		int min_y = y - r;
		int max_x = x + r;
		int max_y = y + r;
		
		if (min_x < 0 || min_y < 0 || max_x > width || max_y > height) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

#define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

signed main(void) {
  int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  num = numeric_limits<int>::max(); // min
  // int N;
  // int M;
  // array<int, 10000> A;
  // string S;
  // string T;

  int D, G;
  array<int, 10> P;
  array<int, 10> C;

  cin >> D >> G;
  for (int i = 0; i < D; ++i) {
    cin >> P[i] >> C[i];
  }

  for (int i = 0; i < pow(2, D); ++i) {
    int score = 0;
    int tmp = 0;
    bitset<10> bs(i);
    
    for (int j = 0; j < D; ++j) {

      if (bs.test(j)) {
        tmp += P[j];
        score += P[j] * (j + 1) * 100 + C[j];
      }

      if (score >= G) {
        num = min(num, tmp);
        break;
      };
    }

    for (int j = D - 1; 0 <= j; --j) {

      if (score >= G) {
        num = min(num, tmp);
        break;
      }

      if(bs[j] == 0) {
        int k = 0;
        while (k < P[j] && score < G) {
          score+= (j + 1) * 100;
          tmp += 1;
          k += 1;
        }
      }
    }
    // cout << bs << endl;
    // cout << score << endl;
    num = min(num, tmp);

  }
  
  cout << num << endl;
  // cout << fixed << setprecision(10) << num << endl;
  return 0;
}


Measured memory_bytes: 512
n, m= map(int, input().split())
tenbou=[1]*n

h = list(map(int,input().split()))
for i in range(1,m+1):
  ab = list(map(int,input().split()))
  if (h[ab[0]-1] > h[ab[1]-1]):
    tenbou[ab[1]-1]=0
  if (h[ab[0]-1] < h[ab[1]-1]):
    tenbou[ab[0]-1]=0
  if (h[ab[0]-1] == h[ab[1]-1]):
    tenbou[ab[0]-1]=0
    tenbou[ab[1]-1]=0   
#  print (ab, tenbou)

print(tenbou.count(1))


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

int main(){
    ll n;
    cin >> n;
    int a = 0;
    for(int i = 1;i <= sqrt(n);i++){
        if(n%i == 0) a = max(a,i);
    }
    int d = floor(log10(n/a)) + 1;
    //cout << a << endl;
    cout << d << endl;
}


Measured memory_bytes: 3828
/*Inversion Sum*/ 
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long 
#define mod 1000000007
int f[3010][3010]; 
int g[3010][3010];
int inv2;
int quickpow(int x,int y){
	int ans = 1;
	while(y){
		if(y & 1)	ans = (1ll * ans * x) % mod;
		x = (1ll * x * x) % mod;
		y >>= 1;
	}
	return ans;
}
int a[3010];
int main()
{
	int n,q;
	cin >> n >> q;
	inv2 = quickpow(2,mod-2) ;
	for(int i = 1; i <= n; ++i)
		scanf("%d",&a[i]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j){
			if(a[i] > a[j])		f[i][j] = g[i][j] = 1;
		}
	for(int i = 1; i <= q; ++i){
		int l,r;
		scanf("%d%d",&l,&r);
		f[l][r] = f[r][l] = ((1ll * g[l][r]+g[r][l])%mod * 1ll * inv2) % mod;
		for(int k = 1; k <= n; ++k)
			if(k != l && k != r){
				f[k][r] = f[k][l] = ((1ll * g[k][l] + g[k][r])%mod * 1ll * inv2) % mod;
				f[l][k] = f[r][k] = ((1ll * g[l][k] + g[r][k])%mod * 1ll * inv2) % mod;
			}
		for(int k = 1; k <= n; ++k)
			g[k][l] = g[k][r] = f[k][l],g[l][k] = g[r][k] = f[l][k];
		g[l][r] = g[r][l] = f[l][r];
	}
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = i+1; j <= n; ++j)
			ans = (1ll * ans + f[i][j]) % mod;
	ans = (1ll * ans * quickpow(2,q)) % mod;
	printf("%d\n",ans);
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  cout << t+s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
	cout<<"Possible";
	else
	cout<<"Impossible";
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include<iomanip>

#define int long long int
using namespace std;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
int mod(int x)
{
    return (((x)%1000000007)+1000000007)%1000000007;
}

int solve()
{
   int n;
   cin>>n;
   int a[n],b[n];
   bool flag=false;
   for(int i=0;i<n;i++)
   {
       cin>>a[i]>>b[i];
    }
    for(int i=0;i<=n-3;i++)
    {
        if(a[i]==b[i])
        {
            if(a[i+1]==b[i+1])
            {
                if(a[i+2]==b[i+2])
                {
                    flag=true;
                    break;
                }
            }
        }
    }
    if(flag)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
   return 0; 
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	int t;
	//cin >> t;
	t=1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    float l;
    cin >> l;
    float ans = (l*l*l)/27;
    printf("%.8lf\n",ans);
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll y;
    cin >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j+i<=n;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    long long int a;
    cin>>a;

    long long int x=a+a*a+a*a*a;
    cout<<x;
    
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int A, B;
bool flag=false;

int main()
{
	cin>>A>>B;
	
	for(int i=min(A,B); i<=max(A,B); i++)
	{
		if((A*B*i) % 2 == 1)
		{
			cout<<"Yes\n";
			flag = true;
			break;
		}
	}
	
	if(!flag) cout<<"No\n";
	
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        rest = x- (i*500 + j*100)
        # print(i,j,rest//50,rest)
        if 0<=rest and rest//50 <=c:
            count+=1

print(count)

Measured memory_bytes: 3064
import java.io.*
import java.util.*
import kotlin.collections.*

object FastReader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    private var st: StringTokenizer = StringTokenizer(br.readLine())

    fun next(): String {
        if (!st.hasMoreElements() ) {
            try {
                st = StringTokenizer(br.readLine());
            } catch (e: IOException) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    fun nextInt() = next().toInt()

    fun nextLong() = next().toLong()

    fun nextDouble() = next().toDouble()
}


fun main(args: Array<String>) {
    FastReader.nextInt()
    val a = FastReader.nextInt()
    val b = FastReader.nextInt()
    val s = FastReader.next()!!

    var c1 = 0
    var c2 = 0
    val ans = mutableListOf<String>()
    for (c in s) {
        if ((c == 'a') && (c1 < a+b)) {
            ans.add("Yes")
            c1++
        } else if ((c == 'b') && (c1 < a+b) && (c2 < b)) {
            ans.add("Yes")
            c1++
            c2++
        } else {
            ans.add("No")
        }
    }
  
  	println(ans.joinToString("\n"))
}


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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0))
    printf("YES\n");
    else printf("NO\n");
}

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(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    char a;
    cin >> a;

    a++;
    cout << a << endl;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
template <typename T>
void dump_stack(std::stack<T>& stack) {
  std::stack<T> temp;
  while (!stack.empty()) {
    T top = stack.top(); stack.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.top(); temp.pop();
    stack.push(top);
  }
}
template <typename T>
void dump_queue(std::queue<T>& queue) {
  std::queue<T> temp;
  while (!queue.empty()) {
    T top = queue.front(); queue.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.front(); temp.pop();
    queue.push(top);
  }
}

typedef long long ll;


int n,q;
int a[30];
bool rec(int i,int m){
  if(m==0) return true;
  if(i>=n) return false;
  return rec(i+1,m)||rec(i+1,m-a[i]);
}

int main(){
  cin>> n;
  rep(i,n) cin >> a[i];
  cin >> q;
  int num;
  rep(i,q) {
    cin >> num;
    if(rec(0,num)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3120
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

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

using namespace std;

int main(int argc, char* argv[]){
  double R;
  cin >> R;
  double ans;
  const double PI=3.14159265358979;
  ans = 2 * R * PI;
  cout << ans << endl;
  return 0;
}



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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N;

    cin >> N;

    int P[N];

    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }

    /* ------- 計算 ------- */

    int min = P[0];
    int count = 0;

    for (int i = 0; i < N; i++)
    {
        if (P[i] <= min)
        {
            count++;
            min = P[i];
        }
    }

    cout << count << endl;

    return 0;
}


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

ll dp[200010][3];
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    for(ll i=1; i<=n; i++){
        cin >> a.at(i);
    }
    if(n==2){
        cout << max(a.at(1),a.at(2)) << endl;
        return 0;
    }
    dp[0][0]=0;
    dp[1][0]=a.at(1);
    dp[1][1]=a.at(2);
    dp[1][2]=a.at(3);
    for(ll i=2; i<=n/2; i++){
        dp[i][0]=dp[i-1][0]+a.at(i+i-1);
        dp[i][1]=max(dp[i-1][1]+a.at(i+i),dp[i-1][0]+a.at(i+i));
        if(n%2==1){
            dp[i][2]=max(max(dp[i-1][0],dp[i-1][1]),dp[i-1][2])+a.at(i+i+1);
        }
    }
    ll ans;
    if(n%2==0) ans=max(dp[n/2][0],dp[n/2][1]);
    else ans=max(max(dp[n/2][0],dp[n/2][1]),dp[n/2][2]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7212
N = int(input())
act = []
for i in range(N):
    a,b,c = map(int,input().split())
    act.append([a,b,c])

INF = 10**10
dp = []
for i in range(N):
    dp.append([0,0,0])

dp[0] = act[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1] + act[i][0],dp[i-1][2] + act[i][0])
    dp[i][1] = max(dp[i-1][0] + act[i][1],dp[i-1][2] + act[i][1])
    dp[i][2] = max(dp[i-1][0] + act[i][2],dp[i-1][1] + act[i][2])

print(max(dp[N-1]))

Measured memory_bytes: 75352
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int x=0,y=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      x+=1;}
   else{y+=1;}
  }
  if(x==0||y==0){
    cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 3576
import Data.Bool

main = do
  [h,w,n] <- map read.words<$>getLine
  [sr,sc] <- map read.words<$>getLine
  s <- getLine
  t <- getLine
  putStrLn $ bool "NO" "YES" $ solve h w n sr sc s t

solve h w n sr sc s t = eval $ go s t where
  eval Nothing = False
  eval (Just (l,r,u,d))
    = l<=sc && sc<=r && u<=sr && sr<=d
  go [] [] = Just (1,w,1,h)
  go (s:ss) (t:tt) = go ss tt >>= g t >>= f s
  mov (dl,dr,du,dd) (l0,r0,u0,d0)
    | l > r || u > d = Nothing
    | otherwise = Just (max 1 l, min w r, max 1 u, min h d)
    where (l,r,u,d) = (l0+dl,r0+dr,u0+du,d0+dd)
  f 'L' = mov ( 1, 0, 0, 0)
  f 'R' = mov ( 0,-1, 0, 0)
  f 'U' = mov ( 0, 0, 1, 0)
  f 'D' = mov ( 0, 0, 0,-1)
  g 'L' = mov ( 0, 1, 0, 0)
  g 'R' = mov (-1, 0, 0, 0)
  g 'U' = mov ( 0, 0, 0, 1)
  g 'D' = mov ( 0, 0,-1, 0)

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

using namespace std;


int main()
{
  int D, N, B, X[10], Y[10];

  cin >> D >> N >> B;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  double ret = 1e9;
  for(int i = 1; i <= B + 1; i++) {
    double bound = 1.0 * D / i;
    ret = min(ret, [&]()
    {
      double angle = 0.0;
      for(int j = 0; j < N; j++) {
        double xx = fmod(X[j], bound);
        double vx = sqrt((xx * bound - xx * xx) / 2.0 / Y[j]);
        angle = max(angle, atan2(bound / 2.0 / vx, vx));
      }
      angle = max(angle, acos(-1) * .25);
      return (sqrt(D / 2.0 / sin(angle) / cos(angle) / i));
    }());
  }
  cout << fixed << setprecision(10) << ret << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
ll nc2(ll x){
  return x*(x-1)/2;
}
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),d(n);
  rep(i,n) {
    cin>>a[i];
    a[i]--;
  }
  ll sum=0;
  rep(i,n){
    d[a[i]]++;
  }
  rep(i,n){
    sum+=nc2(d[i]);
  }
  rep(i,n){
    ll ans=sum;
    ans-=nc2(d[a[i]]);
    ans+=nc2(d[a[i]]-1);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 4096
package main

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

func main() {
	N := ReadInt()
	S := ReadString()
	max := 0
	x := 0
	for i := 0; i < N; i++ {
		if S[i] == 'I' {
			x++
		} else {
			x--
		}
		max = Max(max, x)
	}
	fmt.Println(max)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1848
n=int(input())
t=[0]*n
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())
  
al=sum(t)
for i in range(m):
  print(al-t[p[i]-1]+x[i])

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

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   map<string, int> freq;

   int N;
   cin >> N;
   REP(i, N) {
      string S;
      cin >> S;
      ++freq[S];
   }

   int mx = 0;
   for (auto it : freq) {
      mx = max(mx, it.second);
   }

   for (auto it : freq)
      if (it.second == mx)
         cout << it.first << '\n';

   return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
ll n,k;
int arr[200001];
bool ok(int m){
    int cnt=0;
    for(int i=0;i<n;i++){
        //if(arr[i]<=m) continue;
        if(arr[i]%m==0) cnt+=arr[i]/m-1;
        else cnt+=arr[i]/m;
    }

    return(cnt<=k);
}
int bsearch(int l,int r){
    if(l==r) return(l);
    if(l+1==r){
        if(ok(l)) return(l);
        return(r);
    }
    int mid=r-(r-l)/2;
    if(ok(mid)) return(bsearch(l,mid));
    else return(bsearch(mid+1,r));
}
void solve(){
    cin>>n>>k;
    int l=1,r=0;
    for(int i=0;i<n;i++) {cin>>arr[i];r=max(r,arr[i]);}
    int ans=bsearch(l,r);
    cout<<ans;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


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

int main(){
  string s;
  cin >> s;
  if(s.find("RRR")!=string::npos){
    cout << 3 << endl;
  } else if(s.find("RR")!=string::npos){
    cout << 2 << endl;
  } else if(s.find("R")!=string::npos){
    cout << 1 << endl;
  } else {
    cout << 0 <<endl;
  }
}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

struct ST{
	int a;
	int b;
	int c;

	int an;
};

int reset(int, int */*[100 + 10]*/);

int main()
{
	int ans[1000 + 10];

	ST res[1000 + 10];

	int an, bn, cn, n;

	int ml;

	int ln;

	int i, j;
	int af, bf, cf;

	while (cin >> an >> bn >> cn, an != 0 && bn != 0 && cn != 0)
	{
		cin >> n;

		ln = n;

		ml = an + bn + cn;

		reset(ml, ans);

		for (i = 1; i <= ln; i++)
		{
			cin >> res[i].a >> res[i].b >> res[i].c >> res[i].an;

			if (res[i].an == 1)
			{
				ans[res[i].a] = 1;
				ans[res[i].b] = 1;
				ans[res[i].c] = 1;

				i--;
				ln--;
			}
		}

		for (i = 1; i <= ln; i++)
		{
			af = bf = cf = 0;

			if (ans[res[i].a] == 1) af = 1;
			if (ans[res[i].b] == 1) bf = 1;
			if (ans[res[i].c] == 1) cf = 1;

			if (af + bf + cf == 2)
			{
				if (af == 0)
				{
					ans[res[i].a] = 0;
				}
				if (bf == 0)
				{
					ans[res[i].b] = 0;
				}
				if (cf == 0)
				{
					ans[res[i].c] = 0;
				}
			}
		}

		for (i = 1; i <= ml; i++)
		{
			cout << ans[i] << endl;
		}
	}

	return 0;
}

int reset(int n,int *le)
{
	int i;
	for (i = 0; i < n; i++)
	{
		le[i] = 2;
	}
	return 0;
}

Measured memory_bytes: 3000
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

struct point {
	double x, y;
}A, B, C;

struct circle {
	double r;
	point cen;
}cir;

//求三角形外接&#22278;&#22278;心坐&#26631;及半径
//&#36755;入三角形三点坐&#26631; 
void solve(point A, point B, point C) {
	double tmp1 = A.x * A.x - B.x * B.x + A.y * A.y - B.y * B.y;
	double tmp2 = A.x * A.x - C.x * C.x + A.y * A.y - C.y * C.y;   //外接&#22278;&#22278;心坐&#26631;公式 
	cir.cen.x = (tmp1 * (A.y - C.y) - tmp2 * (A.y - B.y)) / (2 * (A.y - C.y) * (A.x - B.x) - 2 * (A.y - B.y) * (A.x - C.x));
	cir.cen.y = (tmp1 * (A.x - C.x) - tmp2 * (A.x - B.x)) / (2 * (A.y - B.y) * (A.x - C.x) - 2 * (A.y - C.y) * (A.x - B.x));
	double la = sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y)); //三角形三&#36793;&#38271; 
	double lb = sqrt((B.x - C.x) * (B.x - C.x) + (B.y - C.y) * (B.y - C.y));
	double lc = sqrt((C.x - A.x) * (C.x - A.x) + (C.y - A.y) * (C.y - A.y));
	double p = (la + lb + lc) / 2.0;
	double s = sqrt(p * (p - la) * (p - lb) * (p - lc)); //三角形面&#31215; 
	cir.r = la * lb * lc / (4 * s); //外接&#22278;半径公式 
}

int main() {
	int t;
	scanf ("%d", &t);
	while (t--) {
		scanf ("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
		solve(A, B, C);
		printf ("%.3lf %.3lf %.3lf\n",cir.cen.x, cir.cen.y, cir.r);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int main()
{
	char a[27];
	int i, j, n;
	gets(a);
	n = strlen(a);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i == j && a[i] == a[j])
				continue;
			else 
				if (a[i] == a[j]) {
					printf("no\n");
					goto fun;
				} 
		}
	}
	fun:;
	if (i == n && j == n)
		printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,char>;

int main(){

ll X,Y,A,B,C;
cin>>X>>Y>>A>>B>>C;
vector<ll> p(A,0);
vector<ll> q(B,0);
vector<ll> r(C,0);
vector<P> all;
for(ll i=0;i<A;i++){cin>>p[i];all.emplace_back(P(p[i],'p'))
;}
for(ll i=0;i<B;i++){cin>>q[i];all.emplace_back(P(q[i],'q'))
;}
for(ll i=0;i<C;i++){cin>>r[i];all.emplace_back(P(r[i],'r'))
;}
sort(all.begin(), all.end());
reverse(all.begin(), all.end());
ll Ans,counter,counter_p_maxX,counter_q_maxY,i;
Ans=0;counter_p_maxX=0;counter_q_maxY=0;i=0;counter=0;
while(counter<X+Y){
     if(counter_p_maxX>=X&&all[i].second=='p'){i++;}
     else if(counter_q_maxY>=Y&&all[i].second=='q'){i++;}
     else{
         Ans+=all[i].first;
         if(all[i].second=='p'){
             counter_p_maxX++;
         }
         if(all[i].second=='q'){
             counter_q_maxY++;
         }
         counter++;
         i++;
     }
}
cout<<Ans<<endl;

return 0;

}  



Measured memory_bytes: 12140
from collections import deque
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
dist = [[-1 for _ in range(W)] for _ in range(H)]
que = deque([(0,0,0)])
dist[0][0] = 0
while que:
    i,j,d = que.popleft()
    if j+1<W and S[i][j+1]=="." and dist[i][j+1]<0:
        dist[i][j+1] = d+1
        que.append((i,j+1,d+1))
    if i-1>=0 and S[i-1][j]=="." and dist[i-1][j]<0:
        dist[i-1][j]=d+1
        que.append((i-1,j,d+1))
    if j-1>=0 and S[i][j-1]=="." and dist[i][j-1]<0:
        dist[i][j-1]=d+1
        que.append((i,j-1,d+1))
    if i+1<H and S[i+1][j]=="." and dist[i+1][j]<0:
        dist[i+1][j]=d+1
        que.append((i+1,j,d+1))
dmin = dist[H-1][W-1]
if dmin<0:
    print(-1)
else:
    B = H*W-dmin-1
    cnt = 0
    for i in range(H):
        for j in range(W):
            if S[i][j]=="#":
                cnt += 1
    print(B-cnt)

Measured memory_bytes: 74012
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

void solve()
{
    string s;string t;cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==t[i])
        ans++;
    }
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3636
#include <iostream>

int main(){
	int i,count=0;//,countmax=0;
	char s[4];
	
	std::cin>>s;
	
	for(i=0;i<3;i++){
		if(s[i]=='R')
			count++;
	}
	if(s[1]=='S'&&count==2)
		count=1;
		
	std::cout<<count<<std::endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	int r;
	cin >> r;
	puts(3 * r*r);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int n, m;

int main(){
  cin >> n >> m;
  vector<vector<int>> v(n);
  int ans_1[100000];
  int year[100000];
  rep(i, m){
    cin >> ans_1[i];
    int tmp;
    cin >> year[i];
    v[ans_1[i]-1].push_back(year[i]);
  }
  rep(i, n) sort(all(v[i]));;
  rep(i, m){
    printf("%06d", ans_1[i]);
    int itr = distance(v[ans_1[i]-1].begin(),lower_bound(all(v[ans_1[i] - 1]), year[i]));
    printf("%06d\n", itr+1);
  }
}



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

int main()
{
		int i = 0; 			//???????????????????????°
		int x[10000] = {0};	//??\?????´??°

		for (i = 0; i < 10000; i++) {
				//??\?????´??°????¨????
				cin >> x[i];

				if (x[i] == 0) {
						break;
				} else {
						cout << "Case " << i+1 << ':'
								<< ' ' << x[i] << '\n';
				}
		}
		return 0;
}

Measured memory_bytes: 3124
/*
 * @Author       : nonameless
 * @Date         : 2020-09-13 20:40:53
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-13 21:26:04
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

template<class T>
inline void read(T &x){
    x = 0;
    int f = 1;
    char c = getchar();
    while(c < '0' || c > '9') if(c == '-') { f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    x = x * f;
}

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }

const int N = 2e3 + 10;

const int mod = 1e9 + 7;

int f[N / 3][N];

int main(){

    int s; read(s);
    if(s <= 2) { puts("0"); return 0; }

    map<int, int> mp;

    for(int i = 1; i <= s; i ++) 
        for(int j = i; j <= s; j ++)
            mp[j - i] ++;

    ll ans = 1;
    memset(f, 0, sizeof f);
    for(int i = 3; i <= s; i ++) f[1][i] = 1;
    for(int i = 3; i <= s; i ++) f[1][i] = f[1][i] + f[1][i - 1];
    for(int i = 2; i <= s / 3; i ++){
        for(int j = 3; j <= s; j ++){
            f[i][j] = (f[i][j] + f[i - 1][j - 3]) % mod;
            ans = (ans + f[i][s]) % mod;
        }
            
        for(int j = 1; j <= s; j ++) f[i][j] = (f[i][j] + f[i][j - 1]) % mod;
    }

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


Measured memory_bytes: 8960
#include <cstdio>
#define MAX 26
#define NIL -1

struct Node { int p, l, r; };
Node T[MAX];

void preOrder(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preOrder(T[u].l);
  preOrder(T[u].r);
}

void inOrder(int u) {
  if (u == NIL) return;
  inOrder(T[u].l);
  printf(" %d", u);
  inOrder(T[u].r);
}

void postOrder(int u) {
  if (u == NIL) return;
  postOrder(T[u].l);
  postOrder(T[u].r);
  printf(" %d", u);
}

int main() {
  int root, i, n, v, l, r;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].p = NIL;

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;

  printf("Preorder\n");
  preOrder(root);
  printf("\n");
  printf("Inorder\n");
  inOrder(root);
  printf("\n");
  printf("Postorder\n");
  postOrder(root);
  printf("\n");

  return 0;
}

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

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	int t = 100000;
	while(n --) {
		t = t + t / 20;
		int r = t % 1000;
		t = t - r + (r > 0 ? 1000 : 0);
	}
	cout << t << '\n';
	return 0;
}

Measured memory_bytes: 3140
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    string S;
    cin >> S;

    bool flag = true;
    int pos = 0;
    while(pos<S.size())
    {
        if (pos+1>=S.size()) 
        {
            flag = false; 
            break;
        }
        if (S[pos] == 'h' and S[pos+1] == 'i')
            pos += 2;
        else
        {
            flag = false;
            break;
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    string S;
    cin >> S;
    ll i=0;
    while(i<S.size()){
        if(i>=S.size()-4){
            cout << "NO" <<endl;
            return 0;
        }
        if(S.substr(i,5)=="erase"){
            i+=5;
            if(i<S.size()&&S[i]=='r')i++;
        }else if(S.substr(i,5)=="dream"){
            i+=5;
            if(i+2==S.size()||S[i+2]!='a'){
                if(S.substr(i,2)=="er")i+=2;
            }
        }else {
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout << "YES"<<endl;
    return 0;
}


Measured memory_bytes: 512
//file_name:ABC76_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,k;
    scanf("%d%d",&n,&k);


    ll ans = 1;
    rep(i,n){
        if(ans<k){
            ans *= 2;
        }else{
            ans += k;
        }
    }

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



Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N=int(input())
    ret=0
    if N==2:
        ret=1
    else:
        div=make_divisors(N)
        div=div+make_divisors(N-1)
        div.append(N)
        div.append(N-1)
        for k in div:
            n=N
            while n%k==0:
                n=n//k
            ret += n%k==1
        if N==2:
            ret = 1
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e6;
const int inf=1e9;
class union_find{//union by rank
public:
	vector<int> par;
	union_find(int n):par(n){
		rep(i,0,n) par[i]=i;
	}
	int root(int v){
		if(par[v]==v) return v;
		else{ par[v]=root(par[v]); return par[v]; }
	}
	void unite(int x,int y){
		int a=root(x);
		int b=root(y); 
		if(a!=b) par[a]=b;
		return;
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
};
int main(){
	int N,M;cin>>N>>M;
	union_find id(N),vl(N);
	int P[N];
	rep(i,0,N){ cin>>P[i]; P[i]--; }
	int x,y;
	rep(i,0,M){
		cin>>x>>y; x--; y--;
		id.unite(x,y);
		vl.unite(P[x],P[y]);
	}
	int cnt=0;
	rep(i,0,N){
		if(P[id.root(i)] == vl.root(i)) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1408
N = int(input())
jobs = []
for _ in range(N):
    jobs.append(list(map(int, input().split())))

jobs = sorted(jobs, key = lambda x:x[1])
now = 0
for time, deadline in jobs:
    now += time
    if now > deadline:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 55256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,m,a[100010]={},dp[100010]={},mod=1e9+7;

void init(){
	cin>>n>>m;
	rep(i,m){
		int b;
		cin>>b;
		a[b]=1;
	}
}

int main(void){
	init();
	dp[0]=1;
	reg(i,1,n){
		if(a[i]==0){
			dp[i]+=dp[i-1];
			if(i>=2)dp[i]+=dp[i-2];
			dp[i]%=mod;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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


void solve (long long H, long long W, long long h, long long w) {
    long long ans;
    ans = H * W - h * W - w * H + h * w;
    cout << ans << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

vector<int> solve(int N, int n){
    vector<int> sm(N+1, -1);
    sm[N] = 1;
    for(int i=N-n; i>=0; i-=n)
        sm[i] = sm[i+n] + 1;

    for(int i=0; i<n; i++){
        if(sm[i] != -1) continue;
        sm[i] = 0;
        for(int j=i+n; j<N; j+=n)
            sm[j] = sm[j-n] - 1;
    }

    vector<int> vec(N, 0);
    for(int i=0; i<N; i++) vec[i] = sm[i+1] - sm[i];

    return vec;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(H % h == 0 && W % w == 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    vector<int> vec;
    if(W % w != 0) vec = solve(W, w);
    else vec = solve(H, h);

    if(W % w != 0){
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++)
                cout << vec[j] << " ";
            cout << endl;
        }
    }else{
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++)
                cout << vec[i] << " ";
            cout << endl;
        }
    }
    return 0;
}


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

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

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

  int count = 0;
  for(int i=1;i<N;i++){
    if(a[i] == a[i-1]){
      count++;
      a[i] = 1000+i;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1000000000

int a[100001];
bool used[100001];
 
int main(){
    int n;
    scanf("%d",&n);
    REP(i,n){
        scanf("%d",a+i);
        a[i]--;
        used[i] = false;
    }
    int c = 0;
    REP( i,n){
        if(!used[i] && a[a[i]]==i){
            c++;
            used[i] = used[a[i]] = true;
        }
    }
    printf("%d\n",c);

    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	lli n;
	cin>>n;
	lli k;
	cin>>k;
	lli q;
	cin>>q;
	lli freq[n+1]={0};
	for(lli i=1;i<=q;i++)
	{
		lli x;
		cin>>x;
		freq[x]++;
	}
	lli x=q-k+1;
	for(lli i=1;i<=n;i++)
	{
		if(freq[i]>=x)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 1408