akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint dp[41][1<<5][1<<7][1<<5] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,X,Y,Z;
    cin >> N >> X >> Y >> Z;
    dp[0][1<<(X-1)][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int A=0;A<(1<<X);A++) for(int B=0;B<(1<<Y);B++) for(int C=0;C<(1<<Z);C++){
            for(int k=1;k<=10;k++){
                if(C>>(k-1)&1) continue;
                int nA = A>>k,nB = B>>k,nC = C>>k;
                if(B>>(k-1)&1){
                    nC |= 1<<(Z-1);
                }
                if(A>>(k-1)&1){
                    nB |= 1<<(Y-1);
                }
                nA |= 1<<(X-1);
                dp[i+1][nA][nB][nC] += dp[i][A][B][C];
            }
        }
    }
    mint ans = 1;
    for(int i=0;i<N;i++) ans *= 10;
    for(int A=0;A<(1<<X);A++) for(int B=0;B<(1<<Y);B++) for(int C=0;C<(1<<Z);C++) ans -= dp[N][A][B][C];
    cout << ans << "\n";
}

Measured memory_bytes: 45632
package main

import (
	"fmt"
)

func main() {
	var (
		n   int
		cnt int
	)
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	flag := true
	for flag {
		for j := 0; j < n; j++ {
			if nums[j]%2 == 0 {
				nums[j] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct compare{
    bool operator()(pair<int,int>&p1,pair<int,int>&p2){
        
        return p1.first>p2.first;
        
    }
};



int main()
{
   int n;
   
   cin>>n;
   
   vector<int>v(n);
   
   long long int sum=0;
   int maxx=INT_MIN;
   for(int i=0;i<n;i++){
       cin>>v[i];
   }
   
   for(int i=0;i<n;i++){
       if(v[i]>maxx){
           maxx=v[i];
       }
       else{
           sum+=1LL*(maxx-v[i]);
       }
   }
   
   cout<<sum;
}


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

using namespace std;

struct UnionFind {
    vector<int> r;

    UnionFind(int N){
        r = vector<int>(N,-1);
    }

    int root(int x){
        if(r.at(x) < 0) return x;
        return r.at(x) = root(r.at(x));
    }

    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if(r.at(x) > r.at(y)) swap(x,y);
        r.at(x) += r.at(y);
        r.at(y) = x;
        return true;
    }
    int size(int x){
        return -r.at(root(x));
    }
};

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

    UnionFind UF(N);
    for(int i=0;i<M;i++){
        int A,B;
        cin >> A >> B;
        A -= 1; B -=1;
        UF.unite(A,B);
    }

    int ans = 0;
    for(int i=0;i<N;i++){
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int t = N;
  int c;
  
  while (t > 0) {
    c += t % 10;
    t = t / 10;
  }
  
  if (N % c == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


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

int main(){
	int ans=0,n,l[1000],r[1000];

	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i]>>r[i];

	for(int i=0;i<n;i++)
		ans+=r[i]-l[i]+1;

	cout<<ans<<endl;
}


Measured memory_bytes: 256
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

#define INT_MAX 2147483647

int checkaround(int H,int W,vector<vector<int>> M,pair<int,int> now,vector<vector<int>> &cost,vector<vector<int>> &arrival){
    int tate=now.first;
    int yoko=now.second;
    if(M[tate][yoko]==-1){
        return 0;
    }
    arrival[tate][yoko]=1;
    //上について処理
    if(tate>=1&&M[tate-1][yoko]!=-1){
        if(cost[tate-1][yoko]>cost[tate][yoko]+1){
            cost[tate-1][yoko]=cost[tate][yoko]+1;
        }
    }
    //下についての処理
    if(H-tate-1>=1&&M[tate+1][yoko]!=-1){
        if(cost[tate+1][yoko]>cost[tate][yoko]+1){
            cost[tate+1][yoko]=cost[tate][yoko]+1;
        }
    }
    //左についての処理
    if(yoko>=1&&M[tate][yoko-1]!=-1){
        if(cost[tate][yoko-1]>cost[tate][yoko]+1){
        cost[tate][yoko-1]=cost[tate][yoko]+1;
        }
    }
    //右についての処理
    if(W-yoko-1>=1&&M[tate][yoko+1]!=-1){
        if(cost[tate][yoko+1]>cost[tate][yoko]+1){
            cost[tate][yoko+1]=cost[tate][yoko]+1;
        }
    }
    int costmin=INT_MAX;
    pair<int,int> Nextp;
    REP(i,H){
        REP(j,W){
            if(arrival[i][j]!=1&&M[i][j]!=-1){
                if(costmin>cost[i][j]){
                    costmin=cost[i][j];
                    Nextp=make_pair(i,j);
                }
            }
        }
    }
    if(costmin!=INT_MAX){
        checkaround(H,W,M,Nextp,cost,arrival);
    }
    return 0;
}

int STpath(int H,int W,vector<vector<int>> M,pair<int,int> S,pair<int,int> &T){
    vector<vector<int>> cost(H,vector<int> (W,INT_MAX));
    vector<vector<int>> arrival(H,vector<int> (W,-1));
    cost[S.first][S.second]=0;
    checkaround(H,W,M,S,cost,arrival);
    int costmax=0;
    REP(i,H){
        REP(j,W){
            if(costmax<cost[i][j]&&cost[i][j]!=INT_MAX){
                costmax=cost[i][j];
                T.first=i;
                T.second=j;
                            }
        }
    }
    return costmax;
}

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<int>> M(H,vector<int> (W));
    REP(i,H){
        REP(j,W){
            char S;
            cin>>S;
            if(S=='.'){
                M[i][j]=1;
            }else if(S=='#'){
                M[i][j]=-1;
            }
        }
    }
    int maxcost=0;
    pair<int,int> search;
    REP(i,H){
        REP(j,W){
            if(M[i][j]==1)
                search.first=i;
                search.second=j;
        }
    }
    pair<int,int> find;
    int cost=STpath(H,W,M,search,find);
    REP(i,H){
        REP(j,W){
            int cost=STpath(H,W,M,make_pair(i,j),find);
            if(cost>maxcost){
                    maxcost=cost;
                    }
                }
            }
    
    cout<<maxcost<<endl;
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.next().split("");
        int length = str.length;
        HashSet<String> set = new HashSet<>();
        HashMap<String, String> map = new HashMap<>();
        map.put("A", "A");
        map.put("C", "C");
        map.put("G", "G");
        map.put("T", "T");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            if (map.containsValue(str[i])) {
                sb.append(str[i]);
            } else {
                set.add(sb.toString());
                sb.setLength(0);
            }
            if (i == length -1) {
                set.add(sb.toString());
                sb.setLength(0);
            }
        }
        int max = 0;
        for (String tmp : set) {
            if (max < tmp.length()) max = tmp.length();
        }
        System.out.println(max);
    }
}

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

using namespace std;
// typedef unsigned long long ull;


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

    int ans = 0;
    for (int Z = 0; Z <= min(K, S); Z++) {
        if (S - Z <= K) {
            ans += S - Z + 1;
        } else if (S - Z <= K*2) {
            ans += K*2 - S + Z + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.append(0)
now = 0
d = 0
for e in A[:-1]:
    d += abs(now-e)
    now = e
d += abs(now)

ans = []
prev = 0

for k in range(N):
    if prev <= A[k] <= A[k+1] or A[k+1] <= A[k] <= prev:
        ans.append(d)
    elif A[k] < prev < A[k+1] or A[k+1] < prev < A[k]:
        ans.append(d-2*abs(A[k]-prev))
    else:
        ans.append(d-2*abs(A[k]-A[k+1]))

    prev = A[k]

for e in ans:
    print(e)


Measured memory_bytes: 14176
#include<iostream>
using namespace std;
int main()
{
	char s[10];
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;



int atcoder(){
    //入力
    int n;
    cin >> n;
    vector<ll> v;
    v.push_back(0);
    REP(i,n){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    v.push_back(0);
    ll ans[110000] = {};
    
    //処理
    ll sum = 0;
    for(int i=0; i<=n; ++i){
        sum += abs(v[i]-v[i+1]);
    }
    for(int i=1; i<=n; ++i){
        ans[i] = sum - abs(v[i-1]-v[i]) - abs(v[i]-v[i+1]) + abs(v[i-1]-v[i+1]);
    }
    
    //出力
    REP(i,n) cout << ans[i+1] <<ENT;
    return 0;
}

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


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>


const int maxn = 4e5 + 10, INF = 0x3f3f3f3f;
const ll MOD = 1000000007LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll a[maxn];
ll p[maxn];

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ll n; cin>>n;
    bool flg = false;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        if (i == 0) continue;
        if (a[i] - a[i - 1] > 1) flg = true;
    }
    if (flg || a[0]) puts("-1");
    else {
        ll res = 0;
        ll r = 0;
        ll g = 0;
        for (ll i = n - 1; i >= 0; i--) {
            if (a[i]) {
                if (g < a[i]) {
                    res += a[i];
                    g = a[i] - 1;
                } else g = a[i] - 1;
            }
        }
        cout<<res<<endl;
    }


//45454645
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
using namespace std;
int main(){
  int n, x;
  int m;
  int min = 1000;
  cin >> n >> x;
  int cnt = n;
  for(int i=0; i<n; i++){
    cin >> m;
    x = x-m;
    if(min > m){
      min = m;
    }
  }
  cnt = cnt + (x/min);

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if K > a[-1]:
    print('IMPOSSIBLE')
    exit()

def gcd(ga, b):
    if b == 0:
        return ga
    return gcd(b, ga%b)

gc = a[0]
for x in a:
    gc = gcd(gc, x)
if K % gc == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14224
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;

int main(){
  ll ans=0;
  cin >> n >> m;
  

  vi a(n),b(n),c(n),d(n+1);

  ll l=0;
  ll r=1;
  ll acnt=0;
  for(ll i=0;i<m;i+=2){
    a[l]=1+i;
    a[r]=1+i;
    l=(l-1+n)%n;
    r=(r+1)%n;
    acnt++;
  }
  ll al=(l+1)%n;
  ll ar=r;

  l=0;
  r=2;
  ll bcnt=0;
  for(ll i=1;i<m;i+=2){
    b[l]=1+i;
    b[r]=1+i;
    l=(l-1+n)%n;
    r=(r+1)%n;
    bcnt++;
  }
  ll bl=(l+1)%n;
  ll br=r;


  ll cw=0;
  for(ll i=0;i<acnt*2;i++){
    c[cw]=a[al];
    cw=(cw+1)%n;
    al=(al+1)%n;
  }
  
  for(ll i=0;i<bcnt*2+1;i++){
    c[cw]=b[bl];
    cw=(cw+1)%n;
    bl=(bl+1)%n;
  }



/*
  for(ll j=0;j<n;j++){
    cout<<a[j]<<" ";
  }
  cout<<endl;
  
  for(ll j=0;j<n;j++){
    cout<<b[j]<<" ";
  }
  cout<<endl;
*/

/*
  for(ll j=0;j<n;j++){
    cout<<c[j]<<" ";
  }
  cout<<endl;
  */
 for(ll i=0;i<n;i++){
   if (c[i]!=0){
    if (d[c[i]]!=0){
      d[c[i]]+=(i+1)*200000;
    }else{
      d[c[i]]=i+1;
    }
   }
 }


 for(ll i=1;i<=m;i++){
   ans=d[i];
   cout<<(ans%200000)<<" "<<(ans/200000)<<endl;
 }


  return 0;
}




Measured memory_bytes: 8588
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

string s[105], t[105];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) cin >> s[i];
  int m;
  cin >> m;
  REP(i, m) cin >> t[i];

  int ret = 0;
  REP(i, n) {
    int tmp = 0;
    REP(j, n) if(s[i]==s[j]) tmp++;
    REP(j, m) if(s[i]==t[j]) tmp--;
    chmax(ret, tmp);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N],B[N];
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++) cin>>B[i];
  for(int i=1;i<N;i++) A[i]+=A[i-1];
  for(int i=0;i<N;i++) B[i]+=max(A[i],B[i-1]);
  cout<<B[N-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M;
  cin >> N >> M;

  vector<int> in(N, 0);
  vector<vector<int>> graph(N+M-1);
  REP(i, N+M-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    in[v]++;
  }

  int root = 0;
  REP(i, N){
    if(in[i] == 0) root = i;
  }

  queue<int> q;
  q.push(root);

  vector<int> ans(N);
  ans[root] = 0;
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(int v : graph[p]){
      in[v]--;
      if(in[v] == 0){
        q.push(v);
        ans[v] = p+1;
      }
    }
  }

  REP(i, N){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
     string s;
     cin>>s;
     if(s[0]>='A'&&s[0]<='Z')
        cout<<'A';
     else
        cout<<'a';
}


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

int main() {
  ll x;
  cin >> x;
  ll ans = x / 11LL * 2LL + (x%11LL + 5LL) / 6LL;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int temp[2];
    map<int, int> count1, count2;

    for(int i = 0; i < n / 2; i++){
        cin >> temp[0] >> temp[1];
        count1[temp[0]]++;
        count2[temp[1]]++;
    }
  
    vector<pair<int, int>> pairs1, pairs2;
    for(auto i = count1.begin(); i != count1.end(); ++i){
        pairs1.push_back(make_pair(i->second, i->first));
    }
    for(auto i = count2.begin(); i != count2.end(); ++i){
        pairs2.push_back(make_pair(i->second, i->first));
    }
    sort(pairs1.begin(), pairs1.end());
    sort(pairs2.begin(), pairs2.end());
    reverse(pairs1.begin(), pairs1.end());
    reverse(pairs2.begin(), pairs2.end());

    int ans;
    
    if(pairs1[0].second == pairs2[0].second){
        ans = max(pairs1[0].first + pairs2[1].first, pairs1[1].first + pairs2[0].first);
        ans = n - ans;
    }else{
        ans = pairs1[0].first + pairs2[0].first;
        ans = n - ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int N;
int main() {
	cin>>N;
	int cnt =0;
	if(N%2 == 0){
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N+1){
				cnt++;
				//cout<<i<<' '<<j<<endl;
			}
		}
	}
	else{
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N){
				cnt++;
				//cout<<i<<' '<<j<<endl;
			}
		}
	}
	cout<<cnt<<endl;

	if(N%2 == 0){
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N+1){
				//cnt++;
				cout<<i<<' '<<j<<endl;
			}
		}
	}
	else{
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N){
				//cnt++;
				cout<<i<<' '<<j<<endl;
			}
		}
	}

}

Measured memory_bytes: 256
# A = [list(map(int, input().split())) for _ in range(3)]
X = int(input())
# B = [int(input()) for _ in range(n)]
# A = list(map(int, input().split()))
# a, b = map(int, input().split())
ans = 0
ans += X//500*1000
ans += (X % 500)//5*5
print(ans)



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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
LL a, b;
LL h[N];

bool check(LL x)
{
	LL cnt = 0LL;
	for (int i = 1; i <= n; i ++ )
	{
		LL t = max(0LL, h[i] - b * x);
		if (t > 0) cnt += (t + a - b - 1LL) / (a - b);
	}
	return cnt <= x;
}

int main()
{
	scanf("%d%lld%lld", &n, &a, &b);
	for (int i = 1; i <= n; i ++ ) scanf("%lld", &h[i]);
	
	int l = 0, r = 0x3f3f3f3f;
	while (l < r)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	
	printf("%d\n", r);
    return 0;
}

Measured memory_bytes: 4540
S = input()
a = len(str(S))-1
 
for i in range(2**a):  
    temp = str(S)[0]  
    for j in range(a):
        if i & (1<<j):
            temp += "+"
        else:
            temp += "-"
        temp+=str(S)[j+1]
    
    if eval(temp) == 7:
        print("{}=7".format(temp))
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll h[n+5];
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		cin>>h[i];
		if (h[i]>=k)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  string O, E;
  cin >> O >> E;
  int oi = 0;
  int ei = 0;
  FOR(i,0,max(O.length(), E.length())){
    if(oi < O.length()) cout << O[oi];
    if(ei < E.length()) cout << E[ei];
    oi++;
    ei++;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    double a = stdin.nextDouble();
    double b = stdin.nextDouble();
    double rad = Math.toRadians(stdin.nextInt());
    double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(rad));
    double S = a * b / 2 * Math.sin(rad);
    double L = a + b + c;
    double h = 2 * S / a;
    System.out.printf("%f%n%f%n%f%n", S, L, h);
  }

}

Measured memory_bytes: 19216
<?php
$N=[];
while(1){
  $n=trim(fgets(STDIN));
  if(!$n) break;
  $N[]=explode(' ',trim(fgets(STDIN)),$n);
}
foreach($N as $Np){
  $x=0;
  $n=count($Np);
  foreach($Np as $np) $x+=$np;
  $m=$x/$n;
  $y=0;
  foreach($Np as $np) $y+=pow($np-$m,2);

  echo sqrt($y/$n),PHP_EOL;
}

Measured memory_bytes: 15640
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

bool isOK(ll a, ll b){
  ll tmp;
  if(b % a == 0){
    tmp = b/a - 1;
  }else
    tmp = b/a;
  if(a <= tmp)
    return false;
  else
    return true;
}

ll cpair(ll a,ll b){
  if(b % a == 0){
    return b/a - 1;
  }else
    return b/a;
}

ll binary_search(ll key) {
    ll ng = -1; 
    ll ok = 10E10; 

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ng;
}

int main()
{
  ll a,b,res,tmp,d=0,Q,A[101],B[101];
  cin >> Q;
  REP(i,Q){
    cin >> A[i] >> B[i];
  }
  REP(i,Q){
    a = A[i];b = B[i];
    d = 0;
    if(a == 1 && b==1){
      cout << "0" << endl;
      continue;
    }
    res = binary_search(a*b);
    tmp = cpair(res,a*b);
    if(tmp == res){
      d++;
    }
    if(a <= res || b <= res)d++;
    cout << 2*binary_search(a*b) - d << endl;
  }
  return 0;
}


int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

using namespace std;

const int max_n = 100011, inf = 1000111222;

int n, m, forb, used[max_n];
vector<int> g[max_n], v4;

bool dfs(int v, int p) {
    used[v] = 1;
    for (int to : g[v]) {
        if (to == forb || to == p) {
            continue;
        }
        if (used[to] == 1) {
            return true;
        } else if (used[to] == 0 && dfs(to, v)) {
            return true;
        }
    }
    used[v] = 2;
    return false;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < n; ++i) {
        if (g[i].size() % 2) {
            puts("No");
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (g[i].size() >= 6) {
            puts("Yes");
            return 0;
        }
        if (g[i].size() == 4) {
            v4.push_back(i);
        }
    }
    if (v4.size() >= 500) {
        puts("Yes");
        return 0;
    }
    for (int v : v4) {
        forb = v;
        memset(used, 0, sizeof(used));
        for (int i = 0; i < n; ++i) {
            if (i == forb) {
                continue;
            }
            if (!used[i]) {
                if (dfs(i, -1)) {
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
    return 0;
}


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

int main(){
  int n, k;
  string s;
  cin>>n>>k;
  cin>>s;
  if(s[k-1]=='A') s[k-1] = 'a';
  else if(s[k-1]=='B') s[k-1] = 'b';
  else s[k-1] = 'c';
  cout<<s<<"\n";
  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, n, m);
  vector<pair<ll, ll>> ab(n);
  rep(i, n) cin >> ab[i].first >> ab[i].second;
  sort(all(ab));
  ll ans = 0;
  for (int i = 0; m > 0; ++i) {
    ll dm = min(m, ab[i].second);
    ans += ab[i].first * dm;
    m -= dm;
  }
  out(ans);
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
// #define 	ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
    string s,t;
    cin >> s >> t;
    int mn = INT_MAX, change;
    for(int i = 0; i <= s.length()-t.length(); ++i){
    	change = 0;
    	for(int j = i; j < i+t.length(); ++j){
    		if(s[j]!=t[j-i]){
    			change++;
    		}
    	}
    	mn = min(mn, change);
    }
    cout << mn << '\n';
}

int main(){
    // boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3632
from collections import Counter
from functools import reduce


def main():
    n = int(input())
    s = input()

    c = Counter(s)
    ans = reduce(lambda x, y: x * y, map(lambda x: x + 1, c.values())) - 1
    print(ans % (10**9+7))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3812
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int [] input = new int[n];
		for (int i = 0; i < n; i++) {
			input[i] = sc.nextInt();
		}
		sc.close();
		
		isnectionSort(input, n);

	}

	private static void isnectionSort(int[] A, int N) {

		show(A, " ");
		
		for (int i = 1; i < N; i++) {
			int v = A[i];
			int j = i - 1;
			
			while(j >= 0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			
			show(A, " ");
			
		}
	}

	private static void show(int[] a, String joiner) {

		String line = Arrays.stream(a)
				.mapToObj(String::valueOf)
				.collect(Collectors.joining(joiner));
		
		System.out.println(line);
		
	}
}

Measured memory_bytes: 33464
var m,index;

function partition(a,p,r){
    var x = a[r];
    var i = p - 1;
    for(var j = p;j < r;j++){
        if(a[j] <= x){
            i++;
            var b = a[i];
            a[i] = a[j];
            a[j] = b;
            var b = m[i];
            m[i] = m[j];
            m[j] = b;
            var b = index[i];
            index[i] = index[j];
            index[j] = b;            
        }
    }
    b = a[i + 1];
    a[i + 1] = a[r];
    a[r] = b;
    b = m[i + 1];
    m[i + 1] = m[r];
    m[r] = b;
    b = index[i + 1];
    index[i + 1] = index[r];
    index[r] = b;
    return i + 1;
}

function qsort(a,p,r){
    if(p < r){
        var q = partition(a,p,r);
        qsort(a,p,q - 1);
        qsort(a,q + 1,r);
    }
}

function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);
    for(var i = 1;i <= n;i++)
        input[i] = input[i].split(" ");
    var a = new Array(n);m = new Array(n);index = new Array(n);
    for(var i = 0;i < n;i++){
        m[i] = input[i + 1][0];
        a[i] = parseInt(input[i + 1][1],10);
        index[i] = i;
    }

    var j = qsort(a,0,n - 1);var k = true;
    for(var i = 0;i < n - 1;i++)
        if(a[i] == a[i + 1] && index[i] > index[i + 1]){
            k = false;break;
        }
    if(k)
        console.log("Stable");
    else
        console.log("Not stable");
    for(var i = 0;i < n;i++)
        console.log(m[i] + " " + a[i]);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 67436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  int x=1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (x<K) {
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 384
#include <iostream>

int main(int argc, char ** argv) {
    int n, q;
    
    std::cin >> n;
    int S[n];
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }
    
    std::cin >> q;
    int count = 0;
    for (int i = 0; i < q; i++) {
        int val;
        std::cin >> val;
        for (int j = 0; j < n; j++) {
            if (S[j] == val) {
                count++;
                break;
            }
        }
    }

    std::cout << count << std::endl;
}



Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();

		int r = 0;
		if (a > b) {
			r += a--;
		} else {
			r += b--;
		}
		if (a > b) {
			r += a--;
		} else {
			r += b--;
		}
		System.out.println(r);
	}

}


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

int main(){
    int N,M,C; cin >> N >> M >> C;
    vector<int> B(M);
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

    int ans = 0;
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
            sum += B[j]*A[i][j];
        }
        if(sum + C > 0){
            ans += 1;
        }
    }

    cout << ans << endl;

}


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

using namespace std;

static map<long long, long long> calc_prime_factor (
    long long num)
{
    map<long long, long long> prime_factor;
    for ( long long i=2; i*i<=num; i++ ) {
        while ( num % i == 0 ) {
            prime_factor[i]++;
            num /= i;
        }
    }
    if ( num != 1 )
        prime_factor[num]++;
    return prime_factor;
}

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

    map<long long, long long> prime_factor;
    prime_factor = calc_prime_factor(N);

    long long N_ = N;
    long long ans = 0;
    for ( auto itr : prime_factor ) {
        long long n = itr.first;
        while ( N_ % n == 0 ) {
            ans++;
            N_ /= n;
            n *= itr.first;
        }
    }

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



Measured memory_bytes: 3640
s = input()
t = 0
for i in range(len(s)):
    if (i+1)%2==1:
        if s[i] in ['R','U','D']:
            continue
        else:
            t = 1
            break
    else:
        if s[i] in ['L','U','D']:
            continue
        else:
            t = 1
            break
if t==1:
    print('No')
else:
    print('Yes')

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

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
   // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int h, w, k; cin >> h >> w >> k;
    char gd[7][7];
    for(int i = 0; i < h; i++){
        for(int j = 0; j<w; j++){
            cin>>gd[i][j];
        }
    }
    int ns = 0;
    for(int combx = 0; combx < (1<<h); combx++){
        for(int comby = 0; comby < (1<<w); comby++){
            int cnt = 0;
            for(int x = 0; x < h; x++){
                for(int y = 0; y < w; y++){
                    if(!(combx&(1<<x)) && !(comby&(1<<y)) && gd[x][y] == '#')
                        cnt++;
                }
            }
            if(cnt == k){
                ns++;
            }
        }
    }
    cout << ns << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void) {
   int N;
   int Q;
   scanf("%d%d", &N, &Q);
   char S[100001];
   int accumulate[100001] = {0};
   scanf("%s", S);
   int cnt = 0;
   for (int i = 0; i < N; i++) {
      if (S[i] == 'A' && S[i+1] == 'C') {
         cnt++;
      }
      accumulate[i+1] = cnt;
   }

   for (int i = 0; i < Q; i++) {
      int l1;
      int l2;
      scanf("%d%d", &l1, &l2);
      printf("%d\n",accumulate[l2 - 1] - accumulate[l1 - 1]);
   }
}


Measured memory_bytes: 1280
#文字列を並び替えて辞書順になるかどうか
s = list(input())
s.sort()
t = list(input())
t.sort()
t = t[::-1]
        
for i in range(min(len(s), len(t))):
    if s[i] == t[i]:
        pass
    elif s[i] < t[i]:
        print("Yes")
        break
    elif s[i] > t[i]:
        print("No")
        break
else:
    if len(s) == len(t):
        print("No")
    elif len(s) < len(t):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[3 * n];
  for(int i = 0; i < 3 * n; i++) cin >> a[i];
  sort(a, a + 3 * n, greater<int>());
  long long sum = 0;
  for(int i = 0; i < n; i++) {sum += a[2 * i + 1];}
  cout << sum << endl;
}

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

int main(){
  int n;
  cin>>n;
  int cur=0;
  while(n>=500){
    n=n-500;
    cur+=1000;
  }
  while(n>=5){
    n=n-5;
    cur+=5;
  }
  cout<<cur<<endl;
  cin.get();
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    s = input().strip().split()

    tmp = list(s[0][0] + s[1][0] + s[2][0])

    for i in range(3):
        tmp[i] = chr(ord(tmp[i]) + ord("A") - ord("a"))
    
    print("".join(tmp))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	bool maybe=false;
	int p=0;
	for(int i=101;i>=0;i--)
	{
		if(p==k)
		{
			cout<<i+1;
			return 0;
		}
		if(a%i==0&&b%i==0)
		{
			p++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/03/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}

vector<ll> fact, invfact;

void buildFact(int n){
    fact = vector<ll>(n + 1, 1);
    invfact = vector<ll>(n + 1, 1);
    for(int i = 1; i <= n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[n] = inv(fact[n]);
    for(int i = n - 1; i >= 1; i--){
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
}

ll bcomb(int n, int k){
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

mti e;
vl chn, tmp;

void dfs(int x, int p){
    chn[x] = 0;
    tmp[x] = 1;
    for(auto &nx: e[x]){
        if(nx == p) continue;
        dfs(nx, x);
        chn[x] += chn[nx];
        tmp[x] = tmp[x] * tmp[nx] % MOD * bcomb(chn[x], chn[nx]) % MOD;
    }
    chn[x]++;
}

void dfs2(int x, int p, ll num, ll aa){
    for(auto &nx: e[x]){
        if(nx == p) continue;
        dfs2(nx, x, num + chn[x] - chn[nx],
             tmp[x] * inv(tmp[nx] * bcomb(chn[x] - 1, chn[nx]) % MOD) % MOD * aa % MOD *
             bcomb(chn[x] - chn[nx] - 1 + num, num) % MOD);
    }
    tmp[x] = tmp[x] * aa % MOD * bcomb(chn[x] - 1 + num, num) % MOD;
}

int main(){
    //CFS;
    int n;
    cin >> n;
    e = mti(n);
    buildFact(n + 1);
    rep(i, n - 1){
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    chn = vl(n), tmp = vl(n);
    dfs(0, 0);
    dfs2(0, 0, 0, 1);
    rep(i, n) cout << tmp[i] << endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int a[n+1];
  bool b[n+1];
  for(int i=1;i<n+1;i++) {
    cin >> a[i];
    b[i] = false;
  }
  int index = 1, count = 0;
  while(true) {
    b[index] = true;
    int next = a[index];
    if(index == 2) {
      cout << count << endl;
      return 0;
    }
    if(b[next]) {
      cout << -1 << endl;
      return 0;
    } else {
      count++;
      b[next] = true;
      index = next; 
    }
  }
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	sum+=a[n-1];
	int j=2,count=2;
	while(1){
		if(j>=n)break;
		sum+=a[n-count];
		j++;
		if(j>=n)break;
		sum+=a[n-count];
		j++;
		if(j>=n)break;
		count++;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;

    if(t.substr(0,s.size())==s)
    {
        cout<<"Yes\n";
    }

    else
    {
        cout<<"No\n";
    }
    exit(0);
}


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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

int main() {
  int d[10] = {0};
  for(int i = 0; i < 6; i++) {
    int z;
    scanf("%d", &z);
    d[z]++;
  }
  if(d[1] <= 2 && d[2] <= 2 && d[3] <= 2 && d[4] <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int A,B;cin >> A >> B;
    cout << max({A*B,A+B,A-B}) << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2010;
int N;
int A[MC];
bitset<MC*MC> B;

int main(){
	cin >> N;
	repp(i,0,N) cin >> A[i];
	if(N==1) return cout << A[0] << endl , 0;
	B[0] = 1;
	int S = 0;
	repp(i,0,N){
		B |= (B<<A[i]);
		S += A[i];
	}
	repp(i,(S-1)/2+1,S+1){
		if(B[i]) return cout << i << endl , 0;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000001
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;

int isACGT(char);

int main()
{
  string S;
  cin >> S;
  

  int mx = 0;
  int cnt = 0;
  
  
  REP(i,SIZ(S))
    {
      if( isACGT(S[i]) )
	{
	  ++ cnt;
	  
	}
      else
	{
	  if( cnt > mx )
	    {
	      mx = cnt;
	      
	    }

	  cnt = 0;
	  
	}
      
    }

  if( cnt > mx )
    {
      mx = cnt;
	      
    }
  
  cout << mx << endl;
  

}

int isACGT(char ch)
{
  if( ch == 'A' or ch == 'G' or ch == 'C' or ch == 'T'  )
    {
      return 1;
      
    }
  else
    {
      return 0;
      
    }
}


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

int main(){
  int N;
  double sum;
  cin >> N;
  vector<int> v(N);
  
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  sum = v.at(0);
  for(int i=1;i<N;i++){
    sum = (sum + v.at(i))/2;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256