akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr int MAX_N = 3000;

ll N, M;
ll dp[MAX_N+1][MAX_N+1];
ll pw[MAX_N*MAX_N+1], ppw[MAX_N+1];
ll comb[MAX_N+1][MAX_N+1];

ll powMod( ll x, ll y )
{
  ll ret = 1;

  while( y > 0 )
  {
    if( y & 1 )
      ret = (ret*x)%M;

    y >>= 1;
    x = (x*x)%M;
  }

  return ret;
}

int main()
{
  scanf( "%lld%lld", &N, &M );

  dp[0][0] = dp[1][0] = dp[1][1] = 1;
  repi( i, 2, N+1 )
  {
    dp[i][0] = 1;

    repi( j, 1, i+1 )
      dp[i][j] = (dp[i-1][j]+j*dp[i-1][j]+dp[i-1][j-1]) % M;
  }

  rep( i, N+1 )
    comb[i][0] = comb[i][i] = 1;

  repi( i, 1, N+1 ) repi( j, 1, N+1 )
    comb[i][j] = (comb[i-1][j-1]+comb[i-1][j]) % M;

  pw[0] = 1;
  rep( i, N*N )
    pw[i+1] = 2*pw[i]%M;

  ppw[0] = 2;
  rep( i, N )
    ppw[i+1] = ppw[i]*ppw[i]%M;

  ll ans = 0;
  rep( k, N+1 )
  {
    int sgn;
    if( k % 2 == 0 )
      sgn = 1;
    else
      sgn = -1;

    ll way = 0, tmp = pw[N-k], t = 1;
    rep( x, k+1 )
    {
      way = (way + dp[k][x]*t)%M;
      t = (t*tmp) % M;
    }

    ans = (ans + sgn*comb[N][k]%M*ppw[N-k]%M*way%M + M) % M;
  }

  printf( "%lld\n", ans%M );

  return 0;
}

Measured memory_bytes: 211200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}

vector<ll>A,B,C;
int main(){
	int N;
	cin>>N;
	ll tmp;
	rep(i,N){
		cin>>tmp;
		A.push_back(tmp);
	}
	rep(i,N){
		cin>>tmp;
		B.push_back(tmp);
	}
	rep(i,N){
		cin>>tmp;
		C.push_back(tmp);
	}
	sort(ALL(A));
	sort(ALL(B));
	sort(ALL(C));
	ll ans=0;
	rep(i,N){
		ll u=lower_bound(ALL(A),B[i])-A.begin();
		ll o=C.end()-upper_bound(ALL(C),B[i]);
		ans+=u*o;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3316
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    var ans = 0
    for (i in 0 until s.length/2) {
        if (s[i] != s[s.length - i - 1]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31516
#!/usr/bin/env python3

def main():
    n, m, k = map(int, input().split())
    ans = 'No'
    for i in range(n + 1):
        for j in range(m + 1):
            if (n - i) * j + (m - j) * i == k:
                ans = 'Yes'
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9096
import sys
import collections


def resolve(in_):
    k = int(next(in_))

    q = collections.deque(range(1, 10))
    lunlun = q.popleft()

    for _ in range(k - 1):
        a = lunlun * 10
        m = lunlun % 10
        if (b := m - 1) >= 0:
            q.append(a + b)
        q.append(a + m)
        if (b := m + 1) <= 9:
            q.append(a + b)
        lunlun = q.popleft()

    return lunlun


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19668
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum_manzoku = 0
for i in range(N):
    sum_manzoku += B[A[i]-1]
    if i >= 1 and A[i] - A[i-1] == 1:
        sum_manzoku += C[A[i]-2]
print(sum_manzoku)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  // This will work only for g++ compiler.
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forab(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define __builtin_popcount(x) ones(x)
#define __builtin_popcountl(x) onesl(x)
#define __builtin_popcountll(x) onesll(x)// to be used with algorithms that processes a container Eg: find(all(c
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define InputOuput freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll linf = 1e18L +5;
const int inf = 1e9 +5 ;
vi vis;
vi dp;

int dfs(int at, unordered_map<int , vi> &adj){
    if(vis[at]  == 1 ) {
        return -1;
    }
    else if( vis[at] == 2) return dp[at];
    vis[at] = 1;
    if(present(adj,at)){
        int mxside = 0;
        for(int v : adj[at]){
            mxside = max(mxside, dfs(v,adj));
        }
        dp[at] = 1 + mxside;
    }
    vis[at] = 2;
    return dp[at];
}
int main(){
   // InputOuput;
    Fast;
    int ans = 0;

    int n, m ; cin >> n >> m ;
    unordered_map<int , vi> adj;
    for0(i,m){
        int u,v; cin >> u>> v;
        if(!present(adj,u))adj[u] = vi();
        adj[u].pb(v);
    }
    vis = vi(n+1,0);
    dp = vi(n+1,0);
    for1(i,n){
        int len = dfs(i,adj);
        ans = max(ans, len);
    }
    cout << ans <<'\n';
    return 0;

}

Measured memory_bytes: 15404
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t mod = 998244353 ;

int64_t solve(vector<vector<int64_t> > &t,int x,int y){
    if (x < 1 || y < 1)
    {
        return 0 ;
    }
    
    if (t.at(x).at(y) != -1)
    {
        return t.at(x).at(y) ;
    }else
    {
        t.at(x).at(y) = ( solve(t,x-1,y)*y + solve(t,x,y-1)*x - solve(t,x-1,y-1) * (x-1) * (y-1) ) % mod;
        if (t.at(x).at(y) < 0)
        {
            t.at(x).at(y) += mod ;
        }
        return t.at(x).at(y) ;
    }
    
    
}

int main(){
    int a,b,c,d ;
    cin >> a >> b >> c >> d ;
    vector<vector<int64_t> > t(c+2,vector<int64_t>(d+2,-1)) ;
    t.at(a).at(b) = 1 ;
    t.at(a+1).at(b) = b ;
    t.at(a).at(b+1) = a ;
    cout << solve(t,c,d) << endl ;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
int inf = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int n;
    scanf("%d", &n);
    vector<int> p(n);
    rp(i, 0, n) scanf("%d", &p.at(i));
    int res = 0;
    rp(i, 1, n-1) {
        if(p.at(i) > p.at(i-1) and p.at(i) < p.at(i+1)) res++;
        else if (p.at(i) < p.at(i-1) and p.at(i) > p.at(i+1)) res++;
    }
    printf("%d", res);
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s, t, u;
  cin >> s >> t >> u;
  int d = 'a' - 'A';
  cout << (char)(s[0] - d);
  cout << (char)(t[0] - d);
  cout << (char)(u[0] - d) << endl;
  return 0;
}


Measured memory_bytes: 3040
#include <cstdio>
#include <cstring>
char str[100010], ch[100010];
int main()
{
	while(~scanf("%s",str))
	{
		  ch[0] = str[0];
		  int k = strlen(str) , d = 1;
		  for(int i = 1; i < k; i++)
		  {
		  	    if(str[i] == str[i-1])
                      continue;
					  ch[d++] = str[i]; 		  	         
		  }
		  printf("%d\n",d-1);
	}
	return 0;
}


Measured memory_bytes: 384
N,K = map(int,input().split())
p = list(map(int,input().split()))
e = []
for i in range(N):
    x = p[i] * (p[i]+1) / (2 * p[i])
    e.append(x)
#print(e)
ans = 0
tmp = 0
for i in range(K):
    tmp += e[i]
if tmp > ans:
    ans = tmp
for i in range(N-K):
    #print(tmp)
    tmp -= e[i]
    tmp += e[i+K]
    if tmp > ans:
        ans = tmp
print(ans)

Measured memory_bytes: 25060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner teclado = new Scanner(System.in);
        String s = teclado.next();
        Boolean check = false;
       for(int x = 0; x < 3; x++){
           if(s.charAt(x) == s.charAt(x+1)){
                check = true;
                break;
   }
       }
       if(check){
           System.out.println("Bad");
       }else{
           System.out.println("Good");
       }
    }   
    }


Measured memory_bytes: 21076
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

using ll = long long;

const int N = 20;
int tab[N][N];
ll sum[(1 << 16)];
ll dp[(1 << 16)];
int n;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) scanf("%d", &tab[i][j]);
    }
    
    for (int x = 0; x < (1 << n); ++x) {
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if ((x & (1 << i)) && (x & (1 << j))) sum[x] += tab[i][j];
            }
        }
    }
    
    for (int x = 0; x < (1 << n); ++x) {
        dp[x] = sum[x];
        for (int y = x; y > 0; y = x & (y - 1)) {
            dp[x] = max(dp[x], dp[y] + dp[x ^ y]);
        }
    }
    printf("%lld\n", dp[(1 << n) - 1]);
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
  int n,ans;
  scanf("%d",&n);
  if(n%2==0){
    ans=n/2;
    printf("%d",ans);
  }
  else{
    ans=(n+1)/2;
    printf("%d",ans );
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//		ABC115_A();
		//		ABC115_B();
		ABC115_C();
		// ABC115_D();
	}


	private static void ABC115_C() {
		Scanner scanner = null;
		int totalTreeNum = 0;
		int selectedTreeNum = 0;

		try {
			scanner = new Scanner(System.in);
			totalTreeNum = scanner.nextInt();
			selectedTreeNum = scanner.nextInt();

			int[] treeTehightList = new int[totalTreeNum];

			for (int i = 0; i < totalTreeNum; i++) {
				treeTehightList[i] = scanner.nextInt();
			}

			Arrays.sort(treeTehightList);

			//			int[] sabunList = new int[treeTehightList.length - 1];

			//			for (int i = 0; i < sabunList.length; i++) {
			//				sabunList[i] = treeTehightList[i + 1] - treeTehightList[i];
			//			}
			int minDiff = Integer.MAX_VALUE;
			for (int i = 0; i < treeTehightList.length - (selectedTreeNum - 1); i++) {
				if (minDiff > treeTehightList[i + selectedTreeNum - 1] - treeTehightList[i]) {
					minDiff = treeTehightList[i + selectedTreeNum - 1] - treeTehightList[i];
				}

			}
			System.out.println(minDiff);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

}

Measured memory_bytes: 50124
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K,S,cnt=0;
  cin >> K >> S;
  
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0 && S-i-j<=K)
        cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	char x, y;
	cin >> x >> y;
	if (x < y)cout << "<" << endl;
	else if (x > y)cout << ">" << endl;
	else cout << "=" << endl;
	return 0;
}

Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    NO_TLE
    int k,x;
    cin>>k>>x;
    int tmp=0;
    for(int i=x-k+1;;++i)
    {
        if(i>=-1000000)
        {
            cout<<i;
            tmp=i+1;
            break;
        }
    }
    for(int i=tmp;i<=x+k-1;++i)
    {
        if(i>=-1000000&&i<=1000000)
            cout<<' '<<i;
    }
    cout<<endl;
    return 0;
}







































Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int used[100100];
vector<pair<ll,ll> > g[100100];
ll d[100100];

void dfs(int x){
	used[x]++;
	if(used[x]>2)return;
	for(auto p:g[x]){
		if(d[p.first]==0){
			d[p.first]=d[x]+p.second;
			dfs(p.first);
		}
		else{
			if(d[p.first]!=d[x]+p.second){
				cout << "No" << endl;
				exit(0);
			}
		}
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	for(int i=0;i<m;i++){
		ll l,r,c; cin >> l >> r >> c;
		l--; r--;
		g[l].push_back(make_pair(r,c));
		g[r].push_back(make_pair(l,-c));
	}
	for(int i=0;i<n;i++){
		if(!used[i]){
			d[i]=0;
			dfs(i);
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 16000
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int W, H;
bool memo[51][51][51][51];
string grid1[51];
string grid2[51];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct S{
  int x1, y1, x2, y2;
  S(int x1, int y1, int x2, int y2) :
    x1(x1), y1(y1), x2(x2), y2(y2) {}
};
bool valid1(int x, int y){
  return (x >= 0 && y >= 0 && x < W && y < H && grid1[y][x] != '#');
}
bool valid2(int x, int y){
  return (x >= 0 && y >= 0 && x < W && y < H && grid2[y][x] != '#');
}
int main(){
  while(cin>>W>>H && W){
    REP(i, H)cin>> grid1[i] >> grid2[i];
    memset(memo, 0, sizeof(memo));
    int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
    REP(y, H)REP(x, W){
      if(grid1[y][x] == 'L'){
        x1 = x; y1 = y;
      }
      if(grid2[y][x] == 'R'){
        x2 = x; y2 = y;
      }
    }
    assert(x1 != -1 && y1 != -1 && x2 != -1 && y2 != -1);
    queue<S> que;
    que.push(S(x1, y1, x2, y2));
    bool ans = false;
    while(!que.empty()){
      S s = que.front(); que.pop();
      if(memo[s.x1][s.y1][s.x2][s.y2]) continue;
      memo[s.x1][s.y1][s.x2][s.y2] = true;
      if(grid1[s.y1][s.x1] == '%' && grid2[s.y2][s.x2] == '%') {
        ans = true;
        break;
      }
      if(grid1[s.y1][s.x1] == '%' || grid2[s.y2][s.x2] == '%'){
        continue;
      }
      REP(r, 4){
        int nx1 = s.x1, ny1 = s.y1, nx2 = s.x2, ny2 = s.y2;
        if(valid1(s.x1 + dx[r], s.y1 + dy[r])){
          nx1 += dx[r]; ny1 += dy[r];
        }
        if(valid2(s.x2 - dx[r], s.y2 + dy[r])){
          nx2 += -dx[r]; ny2 += dy[r];
        }
        if(!memo[nx1][ny1][nx2][ny2]) que.push(S(nx1, ny1, nx2, ny2));
      }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
    int A[9], record[9], N;
    for (int i = 0; i < 9; i++) {
        cin >> A[i];
        record[i] = 0;
    }
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        for (int j = 0; j < 9; j++) {
            if (A[j] == b) {
                record[j] = 1;
            }
        }
    }
    if (record[0] + record[1] + record[2] == 3) {
        cout << "Yes" << endl;
    } else if (record[3] + record[4] + record[5] == 3) {
        cout << "Yes" << endl;
    } else if (record[6] + record[7] + record[8] == 3) {
        cout << "Yes" << endl;
    } else if (record[0] + record[3] + record[6] == 3) {
        cout << "Yes" << endl;
    } else if (record[1] + record[4] + record[7] == 3) {
        cout << "Yes" << endl;
    } else if (record[2] + record[5] + record[8] == 3) {
        cout << "Yes" << endl;
    } else if (record[0] + record[4] + record[8] == 3) {
        cout << "Yes" << endl;
    } else if (record[2] + record[4] +record[6] == 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    ll a,b;
    cin>>a>>b;
    ll ruijo = 1;
    ll ans = 0;
    while(ruijo <= b){
        if(ruijo == 1){
            if(((b+1)/2-a/2)%2 == 1) ans += ruijo;
            ruijo *= 2;
            continue;
        }
        if((a&ruijo) == 0 && (b&ruijo) == ruijo){
            if((b%ruijo)%2 == 0) ans += ruijo;
        }
        else if((a&ruijo) == ruijo && (b&ruijo) == 0){
            if((a%ruijo)%2 == 1) ans += ruijo;
        }
        else if((a&ruijo) == ruijo && (b&ruijo) == ruijo){
            if((b%ruijo+1 + a%ruijo)%2 == 1) ans += ruijo;
        }
        ruijo *= 2;
    }
    cout<<ans<<endl;
}

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

vector<vector<int>> G;

int rec(int v = 0, int pre = -1) {
  int res = 0;
  for (auto &u : G[v]) {
    if (u == pre) continue;
    res += rec(u, v);
  }

  if (res >= 2) return res;
  return !res;
}

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

  G.resize(n);

  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  cout << (rec() ? "First" : "Second") << endl;
}


Measured memory_bytes: 5888
n = int(input())
a = list(map(int, input().split()))

al = 0
for i in range(2,n):
    al ^= a[i]
ans = 0
s = a[0]+a[1]
if s-al<0 or (s-al)%2:
    ans = -1
else:
    d = (s-al)//2
    now = d
    for i in range(65,-1,-1):
        if (1 << i)&al and (1 << i)+now<=a[0]:
            now += 1 << i
    if now==0 or now>a[0] or d&al!=0:
        ans = -1
    else:
        ans = a[0]-now

print(ans)



Measured memory_bytes: 62008
#include <bits/stdc++.h>
using namespace std;
int main(){
  string b;
  char d='1';
  long long a,c=0;
  cin>>a>>b;
  for(int i=1;i<=3;i++){
    if(i==1)
    c+=(b[0]-d+1)*pow(10,3-i);
    else
    c+=(b[i]-d+1)*pow(10,3-i);
  }
  cout<<c*a/100<<endl;
  return(0);
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =998244353;
ll dp[3003][3003];
ll a[3003];
int main()
{
        FastIO
        ll n,s,i,j;
        cin>>n>>s;
        ll ans=0;
		for(i=1;i<=n;i++) cin>>a[i];
  		for(i=1;i<=n;i++)
    	{
          	for(j=0;j<=s;j++)
    		{	dp[i][j]+=dp[i-1][j];
    			dp[i][j]%=mod;
				if(j+a[i]<s)
    			{	if(j==0)
    					dp[i][j+a[i]]+= i;
    				else
    					dp[i][j+a[i]]+= dp[i-1][j];
                 	
                	dp[i][j+a[i]]%=mod;
    			}
    			else if(j+a[i]==s)
    				{
    					if(j==0)
    						ans+= i*(n-i+1);
    					else
    						ans+=dp[i-1][j]*(n-i+1);
    					ans%=mod;
                	}

            }

    	}
		cout<<ans;
    	return 0;
    }


Measured memory_bytes: 70656
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100100
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, A;
    cin >> N >> A;
    ll x[55];
    ll i, j, k;
    for(i=0; i<N; i++) {
        cin >> x[i];
    }
    
    
    ll dp[N+5][N*A+5][N+5];
    memset(dp, 0, sizeof(dp));
    
    dp[0][0][0]=1;
    for(i=1; i<=N; i++) {
        for(j=0; j<=N*A; j++) {
            for(k=1; k<=i; k++) {
                if(j>=x[i-1])
                    dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-x[i-1]][k-1];
                else
                    dp[i][j][k-1]=dp[i-1][j][k-1];
            }
        }
    }
    
    
    ll ans=0;
    for(k=1; k<=N; k++) {
        ans+=dp[N][k*A][k];
    }
    
    pr(ans);
}













Measured memory_bytes: 59392
#include<iostream>

using namespace std;

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

    int xyh[100][3];
    for(int i=0; i<n; ++i){
        cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
    }

    int usei;
    int ii = 0;
    while (true){
        if (xyh[ii][2] > 0) {
            usei = ii;
            break;
        }
        ii++;
    }

    int ax, ay, ah;
    for (int i=0; i<=100; ++i){
        for (int j=0; j<=100; ++j){
            int tmph = abs(xyh[usei][0] - i) + abs(xyh[usei][1] - j) + xyh[usei][2];
            for (int k=0; k<n; ++k){
                int ph = max(tmph - abs(xyh[k][0] - i) - abs(xyh[k][1] - j), 0);
                if (xyh[k][2] != ph) {
                    break;
                } else if (k == n - 1){
                    ax = i;
                    ay = j;
                    ah = tmph;
                    goto end;
                }
            }
        }
    }
    end:

    cout << ax << " " << ay << " " << ah << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    vector<pair<ll,int>> cb(m);
    for(int i=0; i<m; i++){
        ll b,c;
        cin>>b>>c;
        cb[i]=make_pair(c,b);
    }
    sort(a.begin(),a.end());
    sort(cb.begin(),cb.end(),greater<>());
    int itr=0;
    ll ans=0;
    for(int i=0; i<m; i++){
        for(int j=0; j<cb[i].second&&itr<n; j++){
            ans += max(a[itr],cb[i].first);
            itr++;
        }
    }
    for(int i=itr; i<n; i++) ans+=a[i];
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;

int main()
{
   char s[20]; scanf("%s", s);
   for(int i=0;i<4;i++) cout<<s[i];
   printf(" ");
   for(int i=4;i<strlen(s);i++) cout<<s[i];
   printf("\n");
   return 0;
}


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


int main(void) {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> sorttedX(N);
  rep(i, N) {
    cin >> X[i];
    sorttedX[i] = X[i];
  }

  sort(sorttedX.begin(), sorttedX.end());
  int centerPos = N / 2;
  int centerNum = sorttedX[centerPos];

  rep(i, N) {
    if (X[i] < centerNum) {
      cout << sorttedX[centerPos] << endl;
    } else {
      cout << sorttedX[centerPos - 1] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4820
#include<cstdio>
#include<cstring>
#define maxn 1000005
char s[maxn];
int w,n;
int main()
{
	scanf("%s",s);
	scanf("%d",&w);
	n=strlen(s);
	for(int i=0;i<n;i+=w) printf("%c",s[i]);
}

Measured memory_bytes: 128
n=int(input())
a,b=map(int, input().split())
p=list(map(int, input().split()))

first=[i for i in p if i <= a]
second=[i for i in p if i <= b and i >= a+1]
third=[i for i in p if i >=b+1]

print(min(len(first), len(second), len(third)))

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long N = Long.parseLong(S);
		long ans = 0;
		{
			long N_ = N;
			while (N_ > 0) {
				ans += N_ % 10;
				N_ /= 10;
			}
		}
		{
			long tmp = 9 * (S.length() - 1);
			tmp += (S.charAt(0) - '0') - 1;
			ans=Math.max(ans, tmp);
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 22228
fun main(arr:Array<String>) {
    val ans = rotate(readLine()!!, readLine()!!)
    println(if(ans) "Yes" else "No")
}

fun rotate(txt:String, target:String):Boolean {
    if(txt == target) {
        return true
    }
    for(i in (1 until txt.length)) {
        val tmp = txt.substring(i) + txt.substring(0 until i)
        if(tmp == target) {
            return true
        }
    }
    return false
}

Measured memory_bytes: 33596
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	int odd = (N+1)/2;
	printf("%.12lf\n",(double)odd/(double)(N));
	//out(N);
	return 0;
}


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

int main(){
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) cnt++;
    }

    cout << cnt << endl;
}


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

int main() {
  //ifstream cin("test.in");
  int m, f, r;
  while (cin >> m >> f >> r) {
    if (m == -1 && f == -1 && r == -1)
      break;
    if (m == -1 || f == -1) {
      cout << "F" << endl;
      continue;
    }
    int t = m + f;
    if (t >= 80) {
      cout << "A" << endl;
      continue;
    }
    if (t >= 65) {
      cout << "B" << endl;
      continue;
    }
    if (t >= 50) {
      cout << "C" << endl;
      continue;
    }
    if (t >= 30) {
      if (r >= 50)
        cout << "C" << endl;
      else
        cout << "D" << endl;
      continue;
    }
    cout << "F" << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> a(N);
    map<ll, int> mp;
    mp[0] = 1;
    ll sum = 0;
    ll ans = 0;
    REP(i,N){
        ll a;
        cin >> a;
        sum += a;
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
}

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

int solve3(int s1,int s2,int s3){
	int v[]={s1,s2,s3};
	sort(v,v+3);
	return v[2]-v[0];
}

int solve2(int a,int b,int s){
	int res=INT_MAX;
	res=min(res,solve3((a/2)*b,(a-a/2)*b,s));
	res=min(res,solve3(a*(b/2),a*(b-b/2),s));
	return res;
}

int solve(int a,int b){
	int a1=a/3,a2=a/3+1,b1=b/3,b2=b/3+1;
	int res=INT_MAX;
	res=min(res,solve2(a-a1,b,a1*b));
	res=min(res,solve2(a-a2,b,a2*b));
	res=min(res,solve2(a,b-b1,a*b1));
	res=min(res,solve2(a,b-b2,a*b2));
	return res;
}

int main(void){
	int H,W;
	cin>>H>>W;
	cout<<solve(H,W)<<endl;
	return 0;
}


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

using namespace std;

int main(){
  int k;
  int n;
  int ans=0;
  cin >> k >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  vector<int> b;
  for(int i=0;i<n-1;i++){
    b.push_back( abs( a.at(i)-a.at(i+1) ) );
  }
  b.push_back( abs(k-a.at(n-1)) + a.at(0) );
  sort(b.begin(), b.end());

  ans = k - b.at(n-1);
  cout << ans << endl;

  return 0;
}


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

int main() {
	long long n, a, b, ans;
	cin >> n >> a >> b;
	
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	else if (n == 1) {
		if (a != b) cout << 0 << endl;
		else cout << 1 << endl;
		return 0;
	}
	else cout << b * (n - 1) + a - (a * (n - 1) + b) + 1 << endl;
	return 0;
	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), m = in.ni();
        StringBuilder sb = new StringBuilder();
        if(m%2==0){
            for (int i = 1; i <= m/2; i++) {
                sb.append(i).append(' ').append(m+2-i);
                sb.append("\n");
            }
            for (int i = 1; i <= m/2; i++) {
                sb.append(i+m+1).append(' ').append(2*m+1-i+1);
                sb.append("\n");
            }
        }else{
            for (int i = 1; i <= m/2; i++) {
                sb.append(i).append(' ').append(m+1-i);
                sb.append("\n");
            }
            for (int i = 1; i <= (m+1)/2; i++) {
                sb.append(i+m).append(' ').append(2*m+1-i+1);
                sb.append("\n");
            }
        }

        out.println(sb.toString());
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

#define MOD 1'000'000'007

typedef long long int ll;
long long int dp[2001];

ll getWays(int s)
{
	if(s == 0) return 1;
	if(s == 3) return 1;

	if(s < 3) return 0;
	

	if(dp[s] != -1) return dp[s];
	ll ways = 0;
	for(int i = 3; i <= s; ++i)
	{
		ways += getWays(s - i);
		ways %= MOD;
	}
	 
	dp[s] = ways % MOD;
	return dp[s];
}
int main()
{
	memset(dp, -1, sizeof(dp));
	
	int s;
	cin >> s;
	cout << getWays(s) % MOD;

	return 0;
}

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

int main()
{
    int mon, day;
    while( cin >> mon >> day )
    {
        int d = 0;
        
        if( mon == 0 && day == 0 )
            break;

        switch( mon )       //入力手前の月の日数分合計し、日にちを足して、最後に7で割った余りを出す。
        {
            case 12:
                d += 30;
            case 11:
                d += 31;
            case 10:
                d += 30;
            case 9:
                d += 31;
            case 8:
                d += 31;
            case 7:
                d += 30;
            case 6:
                d += 31;
            case 5:
                d += 30;
            case 4:
                d += 31;
            case 3:
                d += 29;
            case 2:
                d += 31;
        }

        switch( ( day + d ) % 7 )               //次ごとの計算は面倒。日に直せば、あとは余りを出すだけ。
        {
            case 0:
                cout << "Wednesday" << endl;
                break;
            case 1:
                cout << "Thursday" << endl;
                break;
            case 2:
                cout << "Friday" << endl;
                break;
            case 3:
                cout << "Saturday" << endl;
                break;
            case 4:
                cout << "Sunday" << endl;
                break;
            case 5:
                cout << "Monday" << endl;
                break;
            case 6:
                cout << "Tuesday" << endl;
                break;
        }

    }
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb emplace_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int dp[1000005];
bool prime[1000005];
ll a[1000005];
bool primesquare[1000005];
void SieveOfEratosthenes( ll n)
{
    for (ll i = 2; i <= n; i++)
        prime[i] = true;
    prime[1] = false;
    for (ll p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (ll i = p * 2; i <= n; i += p)
                prime[i] = false;
        }
    }
    ll j = 0;
    for (ll p = 2; p <= n; p++) {
        if (prime[p]) {
            a[j] = p;
            if((p*p)<1000005)
                primesquare[p * p] = true;
            j++;
        }
    }
}
ll countDivisors(ll n)
{
    if (n == 1)
        return 1;
    ll ans = 1;
    for (ll i = 0;; i++) {
        if (a[i] * a[i] * a[i] > n)
            break;
        ll cnt = 1; // cnt is power of prime a[i] in n.
        while (n % a[i] == 0) // if a[i] is a factor of n
        {
            n = n / a[i];
            cnt = cnt + 1; // incrementing power
        }


        ans = ans * cnt;
    }

    // if a[i] is greater than cube root of n

    // First case
    if (prime[n])
        ans = ans * 2;

    // Second case
    else if (primesquare[n])
        ans = ans * 3;

    // Third case
    else if (n != 1)
        ans = ans * 4;

    return ans; // Total divisors
}

int main()
{
    int n;
    cin>>n;
    SieveOfEratosthenes(1000001);
    for(int i=2; i<=n; i++)
    {

        dp[i]=dp[i-1]+countDivisors(i-1);
    }
    cout<<dp[n];
}

Measured memory_bytes: 9564
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(ll i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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;
}
class UnionFind {
public:
    vector<ll> par;
    void init(ll n) {
        rep(i, 0, n) {
            //par[i] == iのとき、iの親はiとなるから初期化では全て根であるとする。
            par.push_back(i);
        }
    }
    void clear() {
        rep(i, 0, par.size()) {
            par[i] = i;
        }
    }

    ll root(ll x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    // これは併合するために使う
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        // 併合済ならばfalse
        if (x == y) return false;

        par[y] = x;
        return true;
    }

    bool isSame(ll x, ll y) {
        return root(x) == root(y);
    }
};
int main() {
    ll N, M;;
    cin >> N >> M;
    vector<pair<ll, ll> > e(M);
    ll u, v;
    rep(i, 0, M) {
        cin >> u >> v;
        --u; --v;
        e[i] = make_pair(u, v);
    }

    UnionFind T;
    T.init(N);
    int ans = 0;
    rep(i, 0, M) {
        ll p, b, c;
        T.clear();
        bool flag = true;
        rep(j, 0, M) {
            if (i == j) continue;
            T.unite(e[j].first, e[j].second);
        }

        rep(j, 0, N) {
            if (T.root(0) != T.root(j)) {
                flag = false;
            }
        } 
        if (!flag) ++ ans;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;

  ll n = s.size() + 1;

  vll a(n);

  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = a[i + 1] + 1;
    }
  }

  rep(i, n - 1) {
    if (s[i] == '<') {
      chmax(a[i + 1], a[i] + 1);
    }
  }

  ll ans = accumulate(all(a), 0ll);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
    ll n,k; cin>>n>>k;
    vector<ll>v(n+1);
    fo(i,1,n+1) cin>>v[i];
    vector<bool>dp(k+1);
    fo(stones,0,k+1)
    {
    	fo(i,1,n+1)
    	{
    		if(stones>=v[i] && dp[stones-v[i]]==false)
    			dp[stones]=true;
    	}
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 256
require 'prime'
MOD = 10 ** 9 + 7
hash = Hash.new(0)

n = gets.to_i
n.downto(1) do |num|
  divisors = Prime.prime_division(num)
  divisors.each do |divisor, count|
    hash[divisor] += count
  end
end

ans = 1
hash.values.each do |value|
  ans *= (value + 1)
end

puts ans % MOD


Measured memory_bytes: 2300
A = input()

# #for i in range(int(4)):
# a_y = int(A[0]) * 1000
# b_y = int(A[1]) *100
# c_y = int(A[2])*10
# d_y = int(A[3])

# yyyy = a_y + b_y + c_y + d_y
#print(yyyy)
if int(A[5])!=0:
    mm = (int(A[5])*10) + (int(A[6]))
else:
    mm = int(A[6])

if int(A[8])!=0:
    dd = (int(A[8])*10) + (int(A[9]))
else:
    dd = int(A[9])
    

# if yyyy>2019:
#     print("TBD")
# elif yyyy==2019 and mm>=5:
#     print("TBD")
# else:
#     print("Heisei")

if mm>4:
    print("TBD")
else:
    print("Heisei")


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

int main(){
    int N;
    cin >> N;
    vector<pair<double, string>> X(N);
    for (int i = 0; i < N; i++){
        double x;
        string u;
        cin >> x >> u;
        X.at(i) = make_pair(x, u);
    }
    double money = 0;
    for (int i = 0; i < N; i++){
        if (X.at(i).second == "JPY"s){
            money += X.at(i).first;
        }
        else{
            money += X.at(i).first * 380000;
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  string s;
  cin >> n >> s;
  ll ans = 0, r = 0, w = 0;
  rep(i, n) {
    if (s[i] == 'R') r++;
  }
  w = n - r;
  ll cnt = 0;
  rep(i, r) {
    if (s[i] == 'R') cnt++;
  }
  cout << r-cnt << endl;

  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int main()
{
    int busqueda;
    int arr[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cin>> busqueda;
    cout<< arr[busqueda - 1];

    return 0;
}


Measured memory_bytes: 256
//AOJ 6-2
#include<stdio.h>

int main(void) {

	int repeatNumber = 0;	scanf("%d", &repeatNumber);	//printf("%d\n", repeatNumber);//デバック用
	int spade[13] = {0};
	int heart[13] = {0};
	int chulab[13] = {0};
	int dia[13] = {0};
	char judge1= 'A';
	int judge2 = 0;

	for (int i = 0; i < repeatNumber; i++) {
		scanf(" %c %d", &judge1, &judge2);	//printf("%c %d\n", judge1, judge2);	//デバック用

		if (judge1 == 'S') {
			spade[judge2 - 1]++;
		}
		else if (judge1 == 'H') {
			heart[judge2 - 1]++;
		}
		else if (judge1 == 'C') {
			chulab[judge2 - 1]++;
		}
		else if (judge1 == 'D') {
			dia[judge2 - 1]++;
		}
	}

	for (int i = 0; i < 13; i++) {
		if (spade[i] != 1) {
			printf("S %d\n", i + 1);
		}
	}

	for (int i = 0; i < 13; i++) {
		if (heart[i] != 1) {
			printf("H %d\n", i + 1);
		}
	}

	for (int i = 0; i < 13; i++) {
		if (chulab[i] != 1) {
			printf("C %d\n", i + 1);
		}
	}

	for (int i = 0; i < 13; i++) {

		if (dia[i] != 1) {
			printf("D %d\n", i + 1);
		}
	}

	return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
  int n, m; cin >> n >> m;
  vector<pair<ll, int> > vt;
  for (int i = 0; i < n; i++) {
    int v; cin >> v; vt.push_back({v, 0});
  }
  for (int i = 0; i < m; i++) {
    int v; cin >> v; vt.push_back({v, 1});
  }
  sort(all(vt));
  int horyzontal = 0, vertical = 0;
  ll ans = 0;
  for (auto x : vt) {
    if (x.second == 0) { // vertical
      ans += x.first * (m + 1 - horyzontal);
      vertical++;
    }
    else {
      ans += x.first * (n + 1 - vertical);
      horyzontal++;
    }
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N , count = 0;
    cin >> N;
    vector <string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    sort(S.begin() , S.end());
    for(int i = 0; i < N - 1; i++){
        if(S.at(i) == S.at(i + 1)){
            count++;
        }
    }
    cout << N - count << endl;
}

Measured memory_bytes: 9600