akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC128
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

void solve(void){
  
  int N, M;
  
  cin >> N >> M;
  
  vector<bitset<10>> S(N,0);
  
  vector<int> P(M,0);
  
  REP(i,M){
    int K;
    cin >> K;
    int L;
    REP(j, K){
      cin >> L;
      L--;
      S[i].set(L);
    }
  }
  REP(i,M){
    cin >> P[i];
  }
  
  
  
  int t=0;
  
  REP(i, 1<<N){
    bool flag=true;
    REP(j,M){
      bitset<10> tmp=S[j] & bitset<10>(i);      
//      cout << bitset<10>(i) << "/" << bitset<10>(tmp) << " " << tmp.count()%2 << ":" << P[j] << endl;     
      if(tmp.count()%2==P[j]){
        continue;
      }
      else
      {
        flag=false;
        break;
      }
    }
    if(flag) t++;
  }
      
  cout << t << endl;
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {

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

    REP(i,TESTCASES){
      solve();
    }
 
    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);
		String s = stdIn.next();
		if(s.equals("SUN")) {
			System.out.println(7);
			System.exit(0);
		}
		if(s.equals("MON")) {
			System.out.println(6);
			System.exit(0);
		}
		if(s.equals("TUE")) {
			System.out.println(5);
			System.exit(0);
		}
		if(s.equals("WED")) {
			System.out.println(4);
			System.exit(0);
		}
		if(s.equals("THU")) {
			System.out.println(3);
			System.exit(0);
		}
		if(s.equals("FRI")) {
			System.out.println(2);
			System.exit(0);
		}
		if(s.equals("SAT")) {
			System.out.println(1);
			System.exit(0);
		}
		
	}

}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<map<int, int>> s(m);

  for (int i = 0; i < m; ++i) {
    int k; cin >> k;
    for (int j = 0; j < k; ++j) {
      int si; cin >> si;
      s[i][si - 1] = 1;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }

  int cnt = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      int on_switch = 0;
      for (int k = 0; k < n; ++k) {
        if (i & (1 << k)) {
          on_switch += s[j][k];
        }
      }
      if (on_switch % 2 != p[j]) ok = false;
    }
    if (ok) ++cnt;
  }
  cout << cnt << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; map<string,ll> mp; string s;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] <<"\n";
    cout << "WA x " << mp["WA"] <<"\n";
    cout << "TLE x " << mp["TLE"] <<"\n";
    cout << "RE x " << mp["RE"] <<"\n";
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  

int main()
{
int N[3];
  rep(i, 3){
    cin >> N[i];
  }
  cout << fixed << N[2] << " " << N[0] << " " << N[1] << endl;
  return 0;
}

Measured memory_bytes: 256
from math import log

n = float(input())
a = log(n, 26)

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
out = []
while (n):
    n-=1
    out.append(alphabet[int(n%26)])
    n //= 26
out.reverse()

print("".join(out))


Measured memory_bytes: 9160
from collections import defaultdict
from collections import OrderedDict
N = int(input())
s = [input()for i in range(N)]
k = {}
for w in s:
    k[w] = 1 if k.get(w) == None else k[w] + 1
groupedByValue = defaultdict(list)
for key, value in sorted(k.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Measured memory_bytes: 46832
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long int
using namespace std;

int32_t main(){
	int n,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if((int)log10(i)%2==0){
			c++;
		}
	}
	cout<<c;
}


Measured memory_bytes: 512
import numpy as np 
import collections

N = int(input())
a_list = list(map(int, input().split()))

a_array = np.array(a_list)
mod4_array = a_array % 4
mod4_list = mod4_array.tolist()

counter = collections.Counter(mod4_array)

odd_num = counter[1] + counter[3]
div_2 = counter[2]
div_4 = counter[0]

#一番低燃費な並べ方でやってしまえば良い

if odd_num == 0:
    print('Yes')
else: #奇数が1つ以上入っている
    if odd_num <= div_4:
        print('Yes')
    elif odd_num == div_4 + 1:
        if div_2 == 0: 
            print('Yes')
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 23108
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N, A, B; cin >> N >> A >> B;
  if (!(abs(A - B) % 2)) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int x, b, e, f, a, c, d;
	
	scanf("%lld", &x);
	a=x/500;
	b=a*1000;
    c=x-a*500;
	d=c/5;
	e=d*5;
	f=b+e;
	printf("%lld\n", f);
	return 0;
 }

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

int main()
{
	int i=0,k=0;
	int w,n;
	int work;
	int data[30];
	int a[30];
	int b[30];
	scanf("%d", &w);
	for(i=0; i<w; i++){
		data[i]=i+1;
	}
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d,%d", &a[i], &b[i]);
		work=data[a[i]-1];
		data[a[i]-1]=data[b[i]-1];
		data[b[i]-1]=work;
	}
	for(i=0; i<w; i++){
		printf("%d\n", data[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
double preprocess(vector<int>& v,int k)
{
    double answer=0;
    for(int i=0;i<k;i++)
    {
        answer+=(v[i]*1.0+1)/2;
     //   cout<<answer<<endl;
    }
    return answer;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int >v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    double answer=preprocess(v,k);
    double temp=answer;
    for(int i=k;i<n;i++)
    {
        temp=temp-(v[i-k]*1.0+1)/2;
        temp+=(v[i]*1.0+1)/2;
      //  cout<<i<<" "<<(v[i-k]*1.0+1)/2<<" "<<(v[i]*1.0+1)/2<<"  "<<temp<<endl;
        answer=max(answer,temp);
    }
    printf("%.11f\n",answer);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define fre freopen("C:\\in.txt", "r", stdin)
#define _for(i,a,b) for(int i=a; i< b; i++)
#define _rep(i,a,b) for(int i=a; i<=b; i++)
#define lowbit(a) ((a)&-(a))
#define inf 0x3f3f3f3f
#define endl "\n"
using namespace std;
typedef long long ll;
template <class T>
void read(T &x)
{
    char c; bool op=0;
    while(c=getchar(), c<'0'||c>'9') if(c=='-') op=1;
    x=c-'0';
    while(c=getchar(), c>='0'&&c<='9') x=x*10+c-'0';
    if(op) x=-x;
}

const int maxn=5e5+5;
int T, n, m, a[maxn];
int res, num[1000005], ans[maxn];
struct Node{
    int l, r, idx;
}q[maxn];
int block;

bool cmp(Node x, Node y){
    return (x.l/block)^(y.l/block)? x.l<y.l : (((x.l/block)&1)? x.r<y.r : x.r>y.r);
}

void add(int x){
    if(!num[a[x]]) res++;
    num[a[x]]++;
}

void del(int x){
    num[a[x]]--;
    if(!num[a[x]]) res--;
}

int main()
{
    //read(T);
    T=1;
    while(T--)
    {
        read(n); read(m);
        memset(num, 0, sizeof(num));
        res=0;
        _rep(i, 1, n) read(a[i]);

        _rep(i, 1, m) read(q[i].l), read(q[i].r), q[i].idx=i;
        block=n/sqrt(m*2/3);
        sort(q+1, q+1+m, cmp);
        int l=0, r=0;
        _rep(i, 1, m){
            int ql=q[i].l, qr=q[i].r;
            while(l<ql) del(l++);
            while(l>ql) add(--l);
            while(r<qr) add(++r);
            while(r>qr) del(r--);
            ans[q[i].idx]=res;
        }
        _rep(i, 1, m) printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 17368
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int a,b, c;
    cin >> a >> b >> c;
    cout << (a <= c && c <= b ? "Yes" : "No") << endl;
}


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

int main() {
	string data;

	while (getline(cin, data) && data[0] != '.') {
		stack <char> S;
		int i = 0;
		bool ans = true;

		while (data[i] != '.') {
			if (data[i] == '(') {
				S.push('(');
			}
			else if (data[i] == '[') {
				S.push('[');
			}
			
			if (data[i] == ')') {
				if (S.empty()) {
					ans = false;
				} else if (S.top() != '(') {
					ans = false;
				}
				else {
					S.pop();
				}
			}
			else if (data[i] == ']') {
				if (S.empty()) {
					ans = false;
				} else if (S.top() != '[') {
					ans = false;
				}
				else {
					S.pop();
				}
			}
			i++;
		}

		if (!S.empty()) {
			ans = false;
		}

		if (ans) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
#define maxn 100010
int s[3],f[maxn][3];
char t[maxn];
int max(int a,int b){
	if(a>b)return a;
	else return b;
}
int chk(char ch,int x){
	if(ch=='r'){
		if(x==2)return s[2];
		else return 0;
	}
	else if(ch=='s'){
		if(x==0)return s[0];
		else return 0;
	}
	else{
		if(x==1)return s[1];
		else return 0;
	}
}
void solve(){
	int n,K;
	scanf("%d%d",&n,&K);
	scanf("%d%d%d",&s[0],&s[1],&s[2]);
	scanf("%s",t+1);
	int i,j,k;
	for(i=1;i<=n;++i){
		if(i<=K){
			f[i][0]=chk(t[i],0);
			f[i][1]=chk(t[i],1);
			f[i][2]=chk(t[i],2);
		}
		for(j=0;j<3;++j){
			for(k=0;k<3;++k){
				if(j==k)continue;
				if(i+K>n)continue;
				f[i+K][j]=max(f[i+K][j],f[i][k]+chk(t[i+K],j));
			}
		}
	}
	int ans=0;
	for(i=n;i>n-K;--i){
		ans+=max(max(f[i][0],f[i][1]),f[i][2]);
	}
	printf("%d\n",ans);
}
int main() {
	solve();
	
	return 0; 
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#define space putchar(' ')
#define enter putchar('\n')
typedef long long ll;
using namespace std;
template <class T>
void read(T &x){
    char c;
    bool op = 0;
    while(c = getchar(), c < '0' || c > '9')
        if(c == '-') op = 1;
    x = c - '0';
    while(c = getchar(), c >= '0' && c <= '9')
        x = x * 10 + c - '0';
    if(op) x = -x;
}
template <class T>
void write(T x){
    if(x < 0) putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar('0' + x % 10);
}

const int N = 20;
int n, dp[N][2], a[N];
ll x;

int dfs(int cur, bool big){
    if(!cur) return 0;
    if(dp[cur][big]) return dp[cur][big];
    int lim = big ? a[cur] : 9;
    for(int j = 0; j <= lim; j++)
        dp[cur][big] = max(dp[cur][big], dfs(cur - 1, big & (j == lim)) + j);
    return dp[cur][big];
}

int main(){

    read(x);
    while(x) a[++n] = x % 10, x /= 10;
    write(dfs(n, 1)), enter;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  int ans = n * 2;
  for (int i = 0; i < n; i++) {
    if(s.substr(i) == t.substr(0,n-i)){
      ans = n + i;
      break;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n;
int a[100005];
int b[100005];
int sum;
int main()
{
	cin >> n;
	a[0] = a[n + 1] = 0;
	REP(i, 0, n) {
		cin >> a[i + 1];
		sum += abs(a[i + 1] - a[i]);
	}
	sum += abs(a[n] - a[n + 1]);

	REP(i, 1, n + 1) {
		if (a[i - 1]<a[i] && a[i]>a[i + 1]) cout << sum - 2 * min(a[i] - a[i - 1], a[i] - a[i + 1]) << endl;
		else if (a[i - 1] > a[i] && a[i] < a[i + 1]) cout << sum - 2 * min(a[i - 1] - a[i], a[i + 1] - a[i]) << endl;
		else cout << sum << endl;
	}
	return 0;
}

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

int main()
{
string s;
cin >> s;
ll len=(int)(s.length());
ll dp[len][4]={};
ll a=0,c=0,q=0;
rep(i,len){
    if(s[i]=='C')c++;
    if(s[i]=='?')q++;
}
dp[0][2]=c;
dp[0][3]=q;
if(s[0]=='C')dp[0][2]--;
if(s[0]=='?')dp[0][3]--;

rep(i,len){
    
    if(s[i]=='A')dp[i+1][0]=dp[i][0]+1;
    else dp[i+1][0]=dp[i][0];
    if(s[i]=='?')dp[i+1][1]=dp[i][1]+1;
    else dp[i+1][1]=dp[i][1];
    if(i==0)continue;
    if(s[i]=='C')dp[i][2]=dp[i-1][2]-1;
    else dp[i][2]=dp[i-1][2];
    if(s[i]=='?')dp[i][3]=dp[i-1][3]-1;
    else dp[i][3]=dp[i-1][3];
}
ll jyo[100002];
jyo[2]=1;
jyo[1]=0;
jyo[0]=0;
rep(i,99999){
    jyo[i+3]=(jyo[i+2]*3)%mo;
}

/* for (int i = 0; i < len; ++i) {
    cout << dp[i][0] << " "<< dp[i][1] << " "<< dp[i][2] << " "<< dp[i][3] << endl;
} */

for(ll i = 1; i < len-1; i++){
    if(s[i]=='B'||s[i]=='?')ans+=(((dp[i][0]*jyo[dp[i][1]+2]+dp[i][1]*jyo[dp[i][1]+1])%mo)*((dp[i][2]*jyo[dp[i][3]+2]+dp[i][3]*jyo[dp[i][3]+1])%mo))%mo;
    
}
ans=ans%mo;


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








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

int main(){
    long long N, M, K;
    long long A_tmp, B_tmp;
    long long A_start, A_pos;
    long long ans;
    std::cin >> N >> M >> K;
    vector<long long> A(N+1), B(M+1);

    A[0] = 0;
    B[0] = 0;

    for(long long i = 1; i <= N; i++){
        if(i == 1){
            std::cin >> A[i];
        }else{
            if(A[i-1] >= 1000000000){
                A[i] = 1000000001;
                std::cin >> A_tmp;
            }else{
                std::cin >> A_tmp;
                A[i] = A[i-1] + A_tmp;
            }
        }
        //debug
        // std::cout << A[i] << " ";
    }
    // for(int i = 0; i < N+1; i++){
    //     std::cout << A[i] << " ";
    // }
    // std::cout << M;

    for(long long i = 1; i <= M; i++){
        // std::cout << i << "\n"; 
        if(i == 1){
            std::cin >> B[i];
        }else{
            if(B[i-1] >= 1000000000){
                B[i] = 1000000001;
                std::cin >> B_tmp;
            }else{
                std::cin >> B_tmp;
                B[i] = B[i-1] + B_tmp;
            }
        }
        // std::cout << B[i] << " ";
    }

    //B=0のときのAの最大値
    for(int i = N; i >= 0; i--){
        if(A[i] <= K){
            A_start = A[i];
            A_pos = i;
            ans = A_pos;
            // std::cout << ans << "\n";
            break; 
        }
    }

    for(int i = 0; i < M + 1; i++){
        // i + 1はBの冊数
        B_tmp = B[i];
        for(int j = A_pos; j >= 0; j--){
            // std::cout << A[j] << " " << B_tmp << "\n";
            if(B_tmp + A[j] <= K){
                A_pos = j;
                if(ans < i + j){
                    ans = i + j;
                    // std::cout << i << " " << j << "\n";
                }
                break;
            }
        }
    }

    std::cout << ans;

}

Measured memory_bytes: 6344
//abc104_c.cpp
//Sat Sep  8 18:34:42 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int dp[11][1001];
int p[11],c[11];

void dpfill (int x){
	for (int i=0;i<=1000;i++){
		dp[x][i] = dp[x-1][i];
	}
	for (int i=1;i<=p[x];i++){
		for (int j=0;j<=1000;j++){
			int temp;
			if (j>=i){
				temp = dp[x-1][j-i]+i*x*100;
				if (i == p[x]){
					temp = temp + c[x];
				}
				if (temp >= dp[x][j]){
					dp[x][j] = temp;
				}
			}
		}
	}
}

int main(){
	int d,g;
	cin >> d >> g;

//	int p[d],c[d];
	p[0] = 0;
	c[0] = 0;
	for (int i=1;i<=d;i++){
		cin >> p[i] >> c[i];
	}

	for (int i=0;i<1000;i++){
		dp[0][1000] = 0;
	}

	for (int i=1;i<=d;i++){
		dpfill(i);
	}

	for (int i=1;i<=1000;i++){
//		cout << dp[1][i] << " ";
		if (dp[d][i] >= g){
			cout << i << endl;
			break;
		}
	}

}

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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            auto itr = lower_bound(vec.begin(),vec.end(),vec[i]+vec[j]);
            int dis = distance(vec.begin(),itr)-1;
            ans += dis-j;
        }
    }
    cout << ans << endl;
}


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

int main() {
  string A;
  cin >> A;
  if (A=="a"||A=="b"||A=="c"||A=="d"||A=="e"||A=="f"||A=="g"||A=="h"||A=="i"||A=="j"||A=="k"||A=="l"||A=="m"||A=="n"||A=="o"||A=="p"||A=="q"||A=="r"||A=="s"||A=="t"||A=="u"||A=="v"||A=="w"||A=="x"||A=="y"||A=="z") {
    cout << "a" << endl;
  }
  else {
    cout << "A" << endl;
  }
}


Measured memory_bytes: 3628
#include<stdio.h>
int max(int a, int b)
{
	if (a > b)return a;
	else return b;
}
int main()
{
	int n;
	long long int k;
	scanf("%lld %lld", &n, &k);
	int i, j;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	int b[100005][60];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 60; j++)
		{
			b[i][j] = (int)(a[i] % 2);
			a[i] /= 2;
		}
	}
	int s[60][2];
	for (i = 0; i < 60; i++)
	{
		s[i][0] = s[i][1] = 0;
		for (j = 0; j < n; j++)
			s[i][b[j][i]]++;
	}
	long long int p[60];
	p[0] = 1;
	for (i = 1; i < 60; i++)
		p[i] = p[i - 1] * 2;
	long long int f[64];
	f[0] = 0;
	for (i = 0; i < 60; i++)
		f[i + 1] = p[i] * max(s[i][0], s[i][1]) + f[i];
	int kb[60];
	for (i = 0; i < 60; i++)
	{
		kb[i] = (int)(k % 2);
		k /= 2;
	}
	long long int v = 0, ans = 0;
	for (i = 59; i >= 0; i--)
	{
		if (kb[i] == 0)
		{
			v += p[i] * s[i][1];
			if (v > ans)
				ans = v;
		}
		else
		{
			if (v + p[i] * s[i][1] + f[i] > ans)
				ans = v + p[i] * s[i][1] + f[i];
			v += p[i] * s[i][0];
			if (ans < v)
				ans = v;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 24320
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;



int main() {
	int H, W, N;
	cin >> H >> W >> N;
	
	if (H > W) {
		int swap = H;
		H = W;
		W = swap;
	}
	/*H<=Wになっている。*/
	for (int i = 1; i <= H; i++) {
		if (i*W >= N) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<int> p={1,2,4,8,16,32,64,128};
  
  for(int x:p){
    if(x>n) {
    cout << x/2 << endl;
    return 0;
    }
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll arr[5];
    ll ans;
    ll x,y;
    cin>>x>>y;
    double c,t;
    c=(4*x*1.00-y)/2;
    t=(y-2*x)/2.00;
    //cout<<c<<" "<<t;
    if(floor(c)==c&&floor(t)==t)
    {
        if(c>=0&&t>=0)
        {
            cout<<"Yes";
        }
        else
        cout<<"No";
    }
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3608
#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
int main()	{
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double ans=(double)w*(double)h/2.0;
  printf("%lf %d\n",ans,x+x==w && y+y==h);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int T[7][7]={
	{-1,300,500,600,700,1350,1650},
	{6,-1,350,450,600,1150,1500},
	{13,7,-1,250,400,1000,1350},
	{18,12,5,-1,250,850,1300},
	{23,17,10,5,-1,600,1150},
	{43,37,30,25,20,-1,500},
	{58,52,45,40,35,15}
};
main()
{
	int A;
	while(cin>>A,A)
	{
		int h,m;cin>>h>>m;m+=h*60;
		int B,m2;cin>>B>>h>>m2;m2+=h*60;
		if(A>B)A^=B^=A^=B;
		A--,B--;
		bool flag=T[B][A]<=40;
		if(!(1050<=m&&m<=1170||1050<=m2&&m2<=1170))flag=false;
		int ans=T[A][B];
		if(flag)ans>>=1;
		while(ans%50)ans++;
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
// << left shift *2 and >>right shift /2
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;cin>>n;
    long long int a[n][3];
    for(long long int i=0;i<n;i++)
    for(long long int j=0;j<3;j++)
    cin>>a[i][j];
    long long int dp[n][3];
    dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
    for(long long int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }   
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;
    //cin>>t;long long int temp=t;
    while(t--)
    {
        //cout<<"Case "<<temp-t<<": ";
        solve();
    }
}


Measured memory_bytes: 8308
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
using namespace std;
typedef long long ll;
const int N=3e5+50;
int n,k,x;
int a[N],b[N];
int main()
{
    //freopen("/Users/zilongzhang/Desktop//l.txt","r",stdin);
    scanf("%d%d",&k,&x);
    int mi=max(-1000000,x-k+1);
    int ma=min(1000000,x+k-1);
    for(int i=mi;i<=ma;i++)printf("%d ",i);

    return 0;
}

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

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

const ll INF = 1LL << 60;

ll dp[100010][3];
ll a[100010], b[100010], c[100010];


int main(){
    int N; cin >> N;
    rep(i, 100010)rep(j, 3) dp[i][j] = -INF;
    rep(i, N){
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i<N; ++i){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    cout << max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]) << endl;
}


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

int main(void){
	vector<string> str;
	vector<string> ans;
	string s;
	bool ch=false;
	while(cin >> s){
		if(s.find(".")!=string::npos)s=s.substr(0,s.size()-1);
		if(s.find(",")!=string::npos)s=s.substr(0,s.size()-1);
		str.push_back(s);
	}
	for(int i=1;i<str.size();i++){
		if(str[i].size()>=3 && str[i].size()<=6){
			if(ch)cout << " " << str[i];
			else cout<< str[i],ch=true;
		}
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int main(void){
string s;
while(1){
	cin>>s;
	if(s=="#")break;
	//now -1 l 1 r
	int r=-1,l=-1,ans=0,now=0;
for(int i=0;i<s.size();i++){
	if(s[i]=='1'||s[i]=='4'||s[i]=='7'){
		if(now==0){
			if(l==0){
				r=0;
			//	cout<<ans<<' '<<now<<' '<<l<<' '<<r<<endl;
				continue;
			}
		l=0;
		if(r!=-1&&r!=0){
			now=-1;
		}

		}else{
			if(now==1){
				now=-1;
				l=0;
			}else if(l>0){
				now=-1;
				l=0;
				ans++;
			}else{
				now=1;
				r=0;
			}
		}

		}else if(s[i]=='2'||s[i]=='8'){
	if(now!=0){
		if(now==-1){
			if(l==2){
				l=1;
				ans++;
			}else{
				now=1;
				r=1;
			}
		}else{
			if(now==1){
				if(r==0){
					r=1;
					ans++;
				}else{
					now=-1;
					l=1;
				}
			}
		}

	}else{
		if(l==0){
			r=1;
			now=1;
		}else if(r==2){
			l=1;
			now=-1;
		}else{
			r=1;
			l=1;
		}
	}

		}else{
			if(now==0){
				if(r==2){
					l=2;
//cout<<ans<<' '<<now<<' '<<l<<' '<<r<<endl;
					continue;
				}
				r=2;
				if(l!=-1&&l!=2){
					now=1;
				}
			}else{
				if(now==-1){
					now=1;
					r=2;
				}else{
					if(r!=2){
						ans++;
						r=2;
					}else{
						l=2;
						now=-1;
					}
				}

			}

}
//cout<<ans<<' '<<now<<' '<<l<<' '<<r<<endl;
}
cout<<ans<<endl;

}

	return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
//      std macros
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
//      dereference
#define F first
#define S second
#define pb push_back
#define mp make_pair
//      loops
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define PER(i,b,a) for(int i=b;i>=a;--i)
#define all(X) (X).begin(), (X).end()
//      I/O
#define sd(n) scanf("%d",&n)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
//      debug
#define debug(x) cerr<<"debug->"<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
//      set values
#define mset(n,k) memset(n,k,sizeof(n))
#define MOD 1000000007
ll INV2=500000004;
ll INV6=166666668;
//modular expo
ll power(ll a,ll b, ll c){
    ll x=1,y=a;
    while(b>0){
        if(b&1)
            x=(x*y)%c;
        y=(y*y)%c;
        b/=2;
    }
    return x%c;
}
//perfect numbers till 10^6 6, 28, 496, 8128
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};//clockwise from left
int dr[]={1,1,0,-1,-1,-1, 0, 1};
int dc[]={0,1,1, 1, 0,-1,-1,-1};//anticlockwise from down
int main()
{

  ll a,b,c;
  sll3(a,b,c);
  ll ar[4];
  ar[0] = a+b;
  ar[1] = a+c;
  ar[2] = b+c;
  sort(ar,ar+3);
  printf("%lld\n",ar[0]);

            


return 0;
}

Measured memory_bytes: 764
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  string S,T;
  cin>>S>>T;
  int count=0;
  for(int i=0;i<S.length();i++){
    if(S[i]!=T[i]){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <numeric>

using namespace std;

int gcd3(int x, int y, int z) { return gcd(x, gcd(y, z)); }

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

  int sum = 0;
  for (int a = 1; a <= K; ++a) {
    for (int b = 1; b <= K; ++b) {
      for (int c = 1; c <= K; ++c) {
        sum += gcd3(a, b, c);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3648
N, T = map(int, raw_input().split())
A_n = map(int, raw_input().split())

count = 0
max_profit = A_n[1] - A_n[0]
min_element = min(A_n[0], A_n[1])
for i in xrange(1, len(A_n)):
    if A_n[i] - min_element > max_profit:
        max_profit = A_n[i] - min_element
        count = 0

    if A_n[i] - min_element == max_profit:
        count += 1

    if A_n[i] < min_element:
        min_element = A_n[i]

print count


Measured memory_bytes: 11304
import sys
N = int(input())
data = [int(i) for i in input().split()]
sum = 1

if 0 in data:
    print(0)
    sys.exit()

for j in data:
    sum *= j
    if sum > 10 ** 18:
        print(-1)
        sys.exit()
        
else:
    print(sum)

Measured memory_bytes: 84736
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      String str = sc.next();
      if (str.equals("-")) break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int s = sc.nextInt();
        String str1 = str.substring(s);
        String str2 = str.substring(0, s);
        str = str1 + str2;        
      }
      System.out.println(str);
    }
  }
}


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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let _: f64 = read();
  let hs: Vec<f64> = read_vec();

  let mut max = hs[0];
  let mut ans = 0;

  for h in hs {
    if max <= h {
      max = h;
      ans += 1;
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
      	HashMap<String, Integer> nam = new HashMap<String, Integer>();
      
      int memo = 0;
      for(int i = 0;i < a;i++){
        String ss = in.next();
        
        if(nam.get(ss) == null){
          nam.put(ss,1);
        }else{
          memo = nam.get(ss);
          nam.put(ss,memo+1);
        }
     }
      
      memo = 0;int b = in.nextInt();
      for(int i = 0;i < b;i++){
        String ss = in.next();
        
        if(nam.get(ss) == null){
          nam.put(ss,-1);
        }else{
          memo = nam.get(ss);
          nam.put(ss,memo-1);
        }
     }
      int max = 0;int min = 0;String M = "aa";
    for(Map.Entry<String, Integer> entry : nam.entrySet()) {
            String ss = entry.getKey();
            max = entry.getValue();
      	if(max >= min){
        	M = ss;
          	min = max;
        }
        }
      
      System.out.println(min);
      
      
      
	}
}


Measured memory_bytes: 23892
# https://atcoder.jp/contests/abc156/tasks/abc156_d

import sys
input = sys.stdin.readline


from operator import mul
from functools import reduce

def pow_k(x, n, mod):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return (K * x) %mod


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def main():
    n, a, b = [int(i) for i in input().strip().split()]
    MOD = 10**9 + 7
    _sum = ((pow_k(2, n,MOD))-1) % MOD
    cmb_a = combination(n, a,MOD)
    cmb_b = combination(n, b,MOD)
    ans = (_sum - cmb_a - cmb_b) % MOD
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 84172
n, y = map(int, input().split())
ans = [-1, -1, -1]

for i in range(2001):
    for j in range(2001):
        d, m = divmod(y - (10000*i + 5000*j), 1000)
        if m == 0 and i+j+d == n and d >= 0:
            ans = [i, j, d]
            break

print(' '.join(map(str, ans)))


Measured memory_bytes: 40908
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int a[200005];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  bool really = true;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) != t.at(2-i)) really = false;
  }
  if (really) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
function Main(input) {
  const args = input.split(" ").map((x) => parseInt(x));
  let w = args[0];
  let h = args[1];
  let x = args[2];
  let y = args[3];
  let r = args[4];
  if (x - r < 0 || w < x + r || y - r < 0 || h < y + r) {
    console.log("No");
  } else {
    console.log("Yes");
  }
}

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


Measured memory_bytes: 15372
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
//#include <unordered_map>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

#define fopen freopen("substrcmp.in", "r", stdin); freopen("substrcmp.out","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define IOSFAST ios::sync_with_stdio(false); cin.tie(0)

const ll MOD = 1000LL * 1000 * 1000 + 7;
const int INF = 1e9;
const ll base = 1e18;
const int MAX = 1000;
const double EPS = 1e-9;
const double PI = acos(-1.);

string s;
int x,y;
int a[4];

int main()
{
	IOSFAST;
	cin >> s;
	FOR(i,0,s.size())
	{
		if (s[i] == 'N')
		{
			a[0] = 1;
		}
		if (s[i] == 'S')
		{
			a[1] = 1;
		}
		if (s[i] == 'E')
		{
			a[2] = 1;
		}
		if (s[i] == 'W')
		{
			a[3] = 1;
		}
	}
	if ((a[0] ^ a[1]) || (a[2] ^ a[3]))
	{
		cout << "No";
	}else
	{
		cout << "Yes";
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N, K;
    cin >> N >> K;
    int index;
    rep(i, N)
    {
        int input;
        cin >> input;
        if (input == 1)
            index = i + 1;
    }
    K--;
    int ans = 0;
    ans += (index - 1 + K - 1) / K;
    ans += (N - index + K - 1) / K;
    int a = (index - 1) % K;
    int b = (N - index) % K;
    if ((a != 0 && b != 0 && a + b <= K))
    {
        ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 250
int main(){
	int i,n;
	int H[MAX];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&H[i]);
	}
	for(i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,H[i]);
		if(i/2!=0) printf("parent key = %d, ",H[i/2]);
	    if(i*2<=n) printf("left key = %d, ",H[i*2]);
	    if(i*2+1<=n) printf("right key = %d, ",H[i*2+1]);
	    printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	int a[n];
	int s=0,r;
	cin>>a[1];
	int k=a[1],l=0;
	s+=1;
	l+=a[1];
	for(int i=2;i<=n;i++) {
		cin>>a[i];
		s+=1;
		r=min(k,a[i]);
		k=r;
		l+=a[i];
	}
	s+=(m-l)/k;
	cout<<s;
	return 0;
}


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

int main() {
  int A;
  int B;
  int C;
  cin >> A >> B >> C;
  if(A==B and A !=C){
    cout << "Yes";
  }
  else if(C==B and A != C){
    cout << "Yes";
  }
  else if(A==C and A != B){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,x;
  cin >> N >> x;
  vi a(N);
  rep(i,N) cin >> a[i];
  sort(a.begin(),a.end());
  
  int sum=0,ans=N;
  rep(i,N) {
    sum+=a[i];
    if(sum>x) {
      ans=i;
      break;
    }
  }
  if(ans==N&&sum<x) ans--;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  double a, b, c, d, e, f;
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
    double ee = e / b, dd = d / a;
    double ax = a * ee, cx = c * ee;
    printf("%.3f ", (cx - f) / (ax - d) == -0 ? 0 : (cx - f) / (ax - d));
    b *= dd, c *= dd;
    printf("%.3f\n", (c - f) / (b - e) == -0 ? 0 : (c - f) / (b - e));
  }
  return 0;
}


Measured memory_bytes: 2752
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        out.println(min(c,b/a));
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#define ll long long
using namespace std;
ll n;
struct zhw{
	ll a;
	int b;
};
vector<zhw>a;
int main()
{
	scanf("%lld",&n);
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			a.push_back((zhw){i*1ll,0});
			while(n%i==0)
			{
				a.back().b++;
				n/=i;
			}
		}
	}
	if(n>1)
		a.push_back((zhw){n,1});
	int ans=0;
	for(int i=0;i<a.size();i++)
	{
		int k=sqrt(a[i].b*2);
		if(k*(k+1)>a[i].b*2)
			k--;
		ans+=k;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3836
# -*- coding: utf-8 -*-
#C - GCD on Blackboard
import sys 
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = [0] + list(map(int, readline().split()))
# L(i) := A1, A2, ..., Ai-1の最大公約数
# R(i) := Ai, Ai+1, ..., ANの最大公約数
L = [0]*(N+1)
L[0] = 0
R = [0]*(N+2)
R[N+1] = 0

for i in range(1,N+1):
    L[i] = gcd(L[i-1],A[i])
for i in range(N,-1,-1):
    R[i] = gcd(R[i+1],A[i])

ans = 1
for i in range(N):
    m = gcd(L[i],R[i+2])
    ans = max(m,ans)
print(ans)

Measured memory_bytes: 86872
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};


int main()
{
    
  cin>>M>>N;
  vector<Int> A(N);
  
  for(auto &x:A) cin>>x;
  Int sum=accumulate(A.begin(),A.end(),0LL);
  
  cout<<(sum>=M ? "Yes\n":"No\n");
    
   
}

Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	string s;
	int n, a, b;cin >> n;
	while(n--){
		cin >> s;a = b = 0;
		sort(s.begin(), s.end());
		string r = s;
		reverse(r.begin(), r.end());
		
		int m = 1;
		for(int i = 7;i >= 0;i--){
			a += (s[i]-'0')*m;
			b += (r[i]-'0')*m;
			m *= 10;
		}
		cout << b-a << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3152
#include<cstdio>
typedef long long ll;
const int mod=1000000007;
int a[2005];
int main(){
	int n,k,i,j,res,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=2;i<=n;++i)
		for(j=1;j<i;++j)if(a[j]>a[i])++ans;
	ans=(ll)ans*k%mod;
	for(i=1;i<=n;++i){
		for(j=1,res=0;j<=n;++j)if(a[j]>a[i])++res;
		ans=(ans+(ll)res*k%mod*(k-1)%mod*500000004)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n)  cin >>a[i];
  int key=1;
  int count=0;
  rep(i,n){
    if(a[i]==key){
      key++;
      count++;
    }
  }
  if(count==0) cout <<-1<<endl;
  else cout <<n-count<<endl;
}

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

string s[200000];
int main() {
	
	int i, n;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	//cout<< endl << "sort" << endl;
	//for (i = 0; i < n; i++) {
	//	cout << s[i] << endl;
	//}
	//cout << "sort" << endl << endl;
	string t;
	t = s[0];
	int counter = 1, maxc = 0;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter > maxc)maxc = counter;
			counter = 1;
		}

	}
	if (counter > maxc)maxc = counter;

	t = s[0]; counter = 1;
	for (i = 1; i < n; i++) {
		if (s[i] == t) {
			counter++;
		}
		else {
			t = s[i];
			if (counter  == maxc)cout << s[i-1] << endl;
			counter = 1;
		}

	}
	if (counter == maxc) {
		cout << s[n - 1] << endl;
	}
	return 0;
	//D
	/*int n,k;
	cin >> n >> k;
	int i;
	long long int a[200000];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}*/
	//E
	/*string s;
	cin >> s;
	int i, j;
	int flag = 0;
	long long int sum = 0;
	for (i = s.size() - 1; i >= 0; i--) {
		j = s[i] - '0' + flag;
		if (j == 10) {
			j = 0;
			flag = 1;
		}
		else {
			flag = 0;
		}
		if (j <= 5) {
			sum = sum + j;
		}
		else {
			sum = sum + 10 - j;
			flag = 1;
		}
	}
	cout << sum + flag << endl;
	return 0;*/


}

Measured memory_bytes: 9880