akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <memory.h>
using namespace std;

int main() {
    int N,M;
    scanf("%d %d",&N,&M);
    int P[M];
    for(int i = 0; i < M; i++) {
      scanf("%d",&P[i]);
      P[i]--;
    }
    int A[N-1];
    int B[N-1];
    int C[N-1];
    int Count[N-1];
    for(int i = 0; i < N-1; i++) {
      Count[i] = 0;
    }
    for(int i = 0; i < N-1; i++) {
      scanf("%d %d %d",&A[i],&B[i],&C[i]);
    }
    int now = P[0];
    for(int i = 1; i < M; i++) {
      if(now < P[i]) {
        for(; now < P[i]; now++) {
          Count[now]++;
        }
      }
      else {
        now--;
        for(; now >= P[i]; now--) {
          Count[now]++;
        }
      }
      now = P[i];
    }
    long long sum = 0;
    for(int i = 0; i < N-1; i++) {
      long long  tmp = Count[i];
      sum += min(tmp * A[i],tmp * B[i] + C[i]);
    }
    printf("%lld\n",sum);



}

Measured memory_bytes: 3140
#include<iostream>
using namespace std;
int main()
{int A,B;
 cin>>A>>B;

 if((A==1&&B==2)||(A==2&&B==1))
    cout<<3;
 else if ((A==1&&B==3)||(A==3&&B==1))
    cout<<2;
 else if ((A==3&&B==2)||(A==2&&B==3))
    cout<<1;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

unsigned long f(unsigned long n) {
  if (n % 4 == 0) {
    return n;
  } else if (n % 4 == 2) {
    return n + 1;
  } else if (n % 4 == 1){
    return 1;
  } else {
    return 0;
  }
}

int main()
{
  unsigned long A, B; cin >> A >> B;

  cout << (f(A - 1) ^ f(B)) << endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
using namespace std;
int n,a[N];
int main()
{
	bool bo=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=a[1]) bo=0;
	}
	if(bo)
	{
		if(a[1]==n-1) printf("Yes\n");
		else if(a[1]*2<=n) printf("Yes\n");
		else printf("No\n");
	}
	else
	{
		int mx=a[1],mi=a[1];
		for(int i=1;i<=n;i++) mx=max(mx,a[i]),mi=min(mi,a[i]);
		if(mx-mi>1) printf("No\n");
		else
		{
			int t=0;
			for(int i=1;i<=n;i++) if(a[i]==mi) t++;
			if(t>=mx) printf("No\n");
			else if(n-t>=2*(mx-t)) printf("Yes\n");
			else printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main( void )
{
	long n, x, min = 1000000, max = -1000000;
	long long sum = 0;
	
	scanf("%ld", &n);
	
	while( n-- > 0 ){
		scanf("%ld", &x);
		
		if( x < min ) min = x;
		if( x > max ) max = x;
		sum += x;
	}
	
	printf("%ld %ld %lld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for(int i=0;i<n;++i)
#define for1(n) for(int i=1;i<=n;i+=3)
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
const int mod = 1000000007;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
int n, m;
int vis[100009], len[100009];
vector<vector<int>>adj;
void dfs(int node)
{
    vis[node] = 1;
    len[node] = 0;
    for (auto& child : adj[node])
    {
        if (!vis[child])
            dfs(child);
        len[node] = max(len[node], len[child] + 1);
    }
}
int main()
{
	//GOAT();
    memset(vis, 0, sizeof vis);
    memset(len, 0, sizeof len);
    cin >> n >> m;
    adj=vector<vector<int>>(n+1);

    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u>>v;
        adj[u].push_back(v);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i])
        {
            dfs(i);
        }
    }

    int mx = 0;
    for (int i = 1; i <= n; i++)mx = max(mx, len[i]);
    cout << mx << endl;
}

Measured memory_bytes: 7808
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		int[] d = new int[n + 1];
		d[0] = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		for (int i = 1; i <= n; i++) {
			d[i] = d[i - 1] + l[i - 1];
		}
		for (int i = 0; i <= n; i++) {
			if (d[i] <= x) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	string s;
	cin>>n>>s;
	if(n&1)
	{
	    cout<<"No";
	}
	else
	{
	    string s1=s.substr(0,n/2);
	    string s2=s.substr(n/2,n/2);
	    if(s1==s2)
	    {
	        cout<<"Yes";
	    }
	    else
	        cout<<"No";
	}
    return 0;
}


//252908XL

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

ll power(ll e, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0)
    return power(e * e, x / 2);
  return e * power(e, x - 1);
}

int main() {
  ll a, b;
  cin >> a >> b;
  a %= b;
  map<ll, int> amp, bmp;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      amp[i]++;
      a /= i;
      i--;
    }
  }
  for (ll i = 2; i * i <= b; i++) {
    if (b % i == 0) {
      bmp[i]++;
      b /= i;
      i--;
    }
  }
  if (a > 1)
    amp[a]++;
  if (b > 1)
    bmp[b]++;
  ll ans = 1;
  for (auto &v : bmp) {
    if (v.second - amp[v.first] >= 1)
      ans *= v.first;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll p,q,r; cin >> p >> q >> r;
  cout << p+q+r-max({p,q,r}) << endl;
}



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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A+B) > (C+D))
    cout << "Left" << endl;
  else if ((A+B) == (C+D))
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<(n);++i)
#define Endl endl
#define int long long
#define INF 1145141919810893

signed main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K%2==0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
void solve(void)
{
  int N, X;
  cin >> N >> X;
  int ANS = 1;
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    int A;cin>>A;
    SUM += A;
    if(SUM <= X)ANS++;
  }
  cout<<ANS<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static StringTokenizer st;
	public static void main(String[] args) throws IOException {
		int n = readInt();
      	int m = readInt();
      	int d = n*(n-1)/2 + m*(m-1)/2;
      	System.out.println(d);
	}
	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}
	static long readLong () throws IOException {
		return Long.parseLong(next());
	}
	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}
	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}
	static char readCharacter () throws IOException {
		return next().charAt(0);
	}
	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}





Measured memory_bytes: 22996
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head =(head +1)% LEN;
  return x;
}

int min(int a,int b) {return a<b? a:b;}

int main(){
  int time=0,c;
  int i,q;
  P u;

  scanf("%d %d",&n,&q);
  for(i=0;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=0;
  tail=n;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    time+=c;
    if(u.t>0) enqueue(u);
    else printf("%s %d\n",u.name,time);
  }

  return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if(K <= A){
        cout << K << endl;
    }
    else if(K <= A+B){
        cout << A << endl;
    }
    else{
        cout << A - (K-A-B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>

int main(void){
	while(1){
		int w;
		scanf(" %d", &w);
		if(w==-1) break;
		
		int price = 1150;
		if(w<=10){}
		else if(w<=20){
			price += (w-10)*125;
		}
		else if(w<=30){
			price += 1250 + (w-20)*140;
		}
		else{	
			price += 1250 + 1400 + (w-30)*160;
		}
	
		printf("%d\n", 4280-price);
	
	}

	return 0;
}

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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	lli 			long long int
#define 	rep(i, n) 		for(int i = 0 ; i < n ; i++)
#define 	repn(i, n) 		for(int i = n - 1 ; i >= 0 ; i--)
#define 	loop(i, a, b)	for(int i = a ; i < b ; i++)
#define 	mod1 			1000003
#define 	hello 			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define 	F 				first
#define 	S 				second
#define 	pb 				push_back
#define 	mp				make_pair
#define 	B 				begin()
#define 	E 				end()
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define 	vs 				vector<string>
#define 	print(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//g++ -std=c++14
//fixed<<setprecision(9);
//max_element(mp.begin(), mp.end(), compare)


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; }

bool compare(const pair<string, int> &a, const pair<string, int> &b){ return a.second < b.second; }

int gcd(int a, int b) 
{ 	
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}

int main()
{
	boost;
	lli n, k, s;
	cin>>n>>k>>s;
	vector<lli> arr(n);
	rep(i, k)arr[i] = s;
	if(s != 1000000000)
		loop(i, k, n)arr[i] = s+1;
	else
		loop(i, k, n)arr[i] = s-1;
	rep(i, n)cout<<arr[i]<<ws;
	cout<<nl;


}

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

using namespace std;

vector<int> solve(int N, int K)
{
    if ((N == 1 and K == 1) or (K >= (1 << N)))
        return { };

    list<int> xs;

    if (K == 0)
    {
        for (int i = 0; i < (1 << N); ++i)
        {
            xs.push_back(i);
            xs.push_back(i);
        }    
    } else
    {
        xs.push_back(K);

        for (int i = 0; i < (1 << N); ++i)
        {
            if (i == K)
                continue;

            xs.push_front(i);
            xs.push_back(i);
        }

        xs.push_back(K); 
    }

    return vector<int>(xs.begin(), xs.end());
}

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

    auto ans = solve(N, K);

    if (ans.empty())
        cout << "-1\n";
    else
        for (size_t i = 0; i < ans.size(); ++i)
            cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for (int i=1; i<=n; i++)
using namespace std;
using f=float; using ll=long long; using ld=long double;
using ull=unsigned long long; using vi=vector<int>; using pii=pair<int, int>;

int gcd(int a, int b) {
    if ( b < a ) swap(a, b);
    int t;
    while ( b != 0 ) {
        t = a%b; a = b; b = t;
    }
    return a;
}
int gcd3(int a, int b, int c) {
    int d = gcd(a, b);
    return gcd(d, c);
}
int main() {
//    int a = gcd3(3, 6, 12);
    int n;
    cin >> n;
    ll sum = 0;
    REP(i, n ) {
        REP(j, n) {
            REP(k, n) {
                sum += gcd3(i, j, k);
            }
        }
    }
    cout << sum << endl;
    return 0;
} 


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

map<string, int> v;

int main() {
    ios_base::sync_with_stdio(false);
    int maxi = 0;
    int n; cin >> n;

    while(n--) {
        string s; cin >> s;
        v[s]++;
        maxi = max(maxi,v[s]);
    }

    vector<string> ans;
    for(auto x : v) if(x.se == maxi) ans.pb(x.fi);
    if(ans.size()) sort(ans.begin(), ans.end());
    for(auto x : ans) cout << x << endl;


    return 0;
}



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

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n], dp[n];
    for(int i=0; i<n; i++){
		cin >> a[i];
		dp[i] = INT_MAX;
    }

    dp[0] = 0, dp[1] = abs(a[1] - a[0]);
    for(int i=2; i<n; i++){
		for(int j=1; j<=k; j++){
			if(i-j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
		}
    }

    cout << dp[n-1];

    return 0;
}


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

using namespace std;
#define ll long long 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  ll a[1000050];
  int n;
  cin >> n;
  REP(i, n){
    int x;
    cin >> x;
    a[x] = i + 1;
  } 

  REP(i, n){
    cout << a[i + 1] << endl;
  }

}


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

int shiguma(int a,int b){
  int c=b-a+1;
  return c;
}
int main(){
  int N;
  cin>>N;

  int a=1;
  int b=9;
  int ans=0;
  bool check=1;
  while(check){
    if(a<=N){
      if(b<N){
        ans+=shiguma(a,b);
      }else{
        ans+=shiguma(a,N);
        check=0;
      }
    }else{
      check=0;
    }
    a*=100;
    b=b*100+99;
  }
  cout<<ans<<endl;


}


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

int main() {
  int n;
  cin >> n;
  int c(n);
  int arr[n];
  unordered_set<int> s;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    //s.insert(arr[i]);
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; ++i) {
    //s.erase(arr[i]);
    //unordered_set<int> rmved;
    //cout << arr[i] << endl;
    if (i && arr[i] == arr[i-1]) {
      c--;
      s.insert(arr[i]);
      continue;
    }
    if (i + 1 < n && arr[i] == arr[i+1]) {
      c--;
      s.insert(arr[i]);
      continue;
    }
    for (int j = 1; j * j <= arr[i]; ++j) {
      if (arr[i] % j) continue;
      if (s.count(j) || s.count(arr[i] / j)) {
        //cout << j << ' ' << arr[i] / j << endl;
        c--;
      	break;
      }
    }
    s.insert(arr[i]);
  }
  //if (n > 1 && arr[0] == arr[1]) c--; 
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 12180
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
char a[N];
int main (){
	int n;scanf ("%d",&n);
	scanf ("%s",a+1);int ans=0;
	for (int i=1;i<=n-2;i++)
		if (a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C') ans++;
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int nxt[3005][3005], arr[3005], lst[3005], n, m;
int dp[3005][2][2][3005], qx[3005], qy[3005], pw[3005];
int solve(int p, int x, int y)
{
	int t = p == -1 ? -1 : std::max(nxt[p][x], nxt[p][y]), coef = pw[p - t];
	p = t;
	if (p == -1) {
		return (arr[x] > arr[y]) * coef;
	}
	int tp = qx[p] == x || qy[p] == x;
	int &res = dp[p][tp][tp ? (x == qx[p]) : (y == qx[p])][tp ? y : x];
	if (~res)
		return res;
	res = solve(p - 1, x, y);
	if ((qx[p] == x && qy[p] == y) || (qy[p] == x && qx[p] == y)) {
		res += solve(p - 1, y, x);
	} else if (qx[p] == x || qy[p] == x) {
		res += solve(p - 1, qx[p] ^ qy[p] ^ x, y);
	} else if (qx[p] == y || qy[p] == y) {
		res += solve(p - 1, x, qx[p] ^ qy[p] ^ y);
	}
	return res = (ll)res * coef % MOD;
}
int main()
{
	// freopen("AGC030-D.in", "r", stdin);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
	}
	pw[0] = 1;
	for (int i = 1; i <= m; i++) {
		pw[i] = pw[i - 1] * 2 % MOD;
	}
	memset(lst, -1, sizeof(lst));
	for (int i = 0; i < m; i++) {
		scanf("%d%d", qx + i, qy + i);
		qx[i]--;
		qy[i]--;
		lst[qx[i]] = lst[qy[i]] = i;
		memcpy(nxt[i], lst, sizeof(lst));
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			(ans += solve(m - 1, i, j)) %= MOD;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 176896
#include "bits/stdc++.h"
#include <unordered_map>

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int N;
	cin >> N;
	unordered_map<string,int> mp;

	rep(i, N) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	int count = 0;
	for(auto&p: mp) {
		int s = p.second;
		count += s * (s - 1) / 2;
	}
	print(count);
}

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

#define vi vector<int>
#define pb push_back

int a[100 * 100 + 10];
int main() {
    int h, w, n, num, ni;

    cin >> h >> w >> n;
    ni = 0;
    rep(i, n) {
        cin >> num;
        for(int j = 0; j < num; j++) {
            a[ni] = i + 1;
            ni++;
        }
    }
    rep(y, h) {
        if(y % 2 == 0) {
            rep(x, w) { 
                cout << a[y * w + x];
                if (x!=w-1)cout << " "; 
                }
        } else {
            rep(x,w){
                cout << a[((y+1)*w -1)-x];
                if (x!=w-1)cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
ret = 0
item = [[0 for i in range(10)] for j in range(10)]
for i in range(1, N+1):
    x = str(i)
    item[int(x[-1])][int(x[0])] += 1
for i in range(10):
    for j in range(10):
        ret += item[i][j] * item[j][i]
print(ret)


Measured memory_bytes: 3060
(n,m,x),*t=[[*map(int,t.split())]for t in open(0)]
m=9**9
for i in range(1,2**n):
    c,*a=map(sum,zip(*[t[j]for j in range(n)if 1<<j&i]))
    if min(a)>=x:m=min(m,c+1)
print(m%9**9-1)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,a,b; cin >> k;
    int cont=0,seq=0;
    while(k--){
        cin >> a >> b;
        if(a==b){
            cont++;
            seq++;
        }
        else cont = 0;
        if(cont == 3) break;
    }
    if(cont == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double rad = (double) (60 * h - 11 * m) * M_PI / 360;
  double c = (double) cos(rad);
  double k = (double) a * a + b * b - 2 * a * b * c;
  double ans = (double) sqrt(k);
  cout << setprecision(15) << ans << endl;
} 

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int n;
  cin>>n;
  map<string,int>mp;
  rep(i,n){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for (auto& p:mp){
    int s=p.second;
    ans+=(ll)s*(s-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && b == c) cout << 1 << endl;
  else if(a == b || b == c || c == a) cout << 2 << endl;
  else cout << 3 << endl;
}

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

using namespace std;

typedef long long LL;

int N,A[100010];

int main()
{
    scanf("%d",&N);
    for (int i=1;i<=N;i++)scanf("%d",&A[i]);
    LL ans = 0;
    for (int i=2;i<=N;i++)
    {
        if (A[i] > 0 && A[i-1] % 2 == 1)
        {
            A[i]--;
            A[i-1]--;
            ans++;
        }
    }
    for (int i=1;i<=N;i++) ans += A[i] / 2;
    printf("%lld\n",ans);
}

Measured memory_bytes: 640
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}


const ll N=2e5+5;

 
int main()
{ 

IOS;

ll n;cin>>n;

set<ll>s;

ll val=0;

FOR(i,n){
  ll x;cin>>x;
  s.insert((x)^(x-1));
  val=val^x;
}

ll cnt=0;


if(!val){
  cout<<0<<endl;
return 0;
}

(val);

for(ll i=29;i>=0;i--){
 // ll temp=0;
  if((1ll<<i)&val){
    ll y=1ll<<(i+1);
    y--;
   // if(i<3)d1(y);
    if(s.count(y)){
      val=val^y;
      cnt++;
    }
  }
}

if(val){
  cnt=-1;
}

d1(cnt);

//end_routine();

return 0;
 
 }

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a;
                a = Console.ReadLine();
                if (a == null) break;
                string d = "";
                string b = "";
                int c = 0;
                for (int i = 0; i <= a.Length - 1; i++)
                {
                    if (a.Substring(i, 1) != " ")
                    {
                        d = d + a.Substring(i, 1);
                        c += 1;
                    }
                    else
                    {
                        break;
                    }
                }
                for (int i = c + 1; i <= a.Length - 1; i++)
                {
                    b = b + a.Substring(i, 1);
                }
                c = int.Parse(b) + int.Parse(d);
                int z = 0;
                while (c != 0)
                {
                    c = c / 10;
                    z += 1;
                }
                Console.WriteLine(z);
            }
        }
    }
}

Measured memory_bytes: 5628
fn main() {
    let input: Vec<i32> = read_vec();
    let x = input[0];
    let p: Vec<i32> = read_vec();

    println!("{}", solve(&p, x));
}

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

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

fn solve(p: &[i32], x: i32) -> i32 {
    let mut new_p = Vec::from(p);
    new_p.sort();

    if let Some(i) = new_p.iter().position(|n| n == &x) {
        for j in 1_usize.. {
            if i < j {
                // 先に先頭に到達
                let h = new_p[0];
                return if new_p.len() > 1 && new_p[1] != h + 1 { h + 1 } else { h - 1 };
            }
            if i + j >= new_p.len() {
                // 先に末尾に到達
                let l = new_p.last().unwrap();
                return if new_p.len() > 1 && new_p[i + j - 2] != l - 1 {
                    l - 1
                } else {
                    l + 1
                };
            }

            // まだ数列の中にいる
            if new_p[i - j] != x && new_p[i - j] != x - j as i32 {
                // 先頭側が空いてる
                return new_p[i - j + 1] - 1;
            }

            if new_p[i + j] != x && new_p[i + j] != x + j as i32 {
                // 末尾側が空いている
                return new_p[i + j - 1] + 1;
            }
        }
    }

    x
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_solve_1() {
        let input = &[4, 7, 10, 6, 5];
        assert_eq!(8, solve(input, 6));
    }

    #[test]
    fn test_solve_2() {
        let input = &[4, 7, 10, 6, 5];
        assert_eq!(9, solve(input, 10));
    }

    #[test]
    fn test_solve_3() {
        let input = &[];
        assert_eq!(100, solve(input, 100));
    }
}


Measured memory_bytes: 2056
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int c; cin >>c;
  cout << c*c*c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N;
  double ans;
  cin>>N;
  int v[N];
  for(int i=0;i<N;i++) cin>>v[i];
  sort(v,v+N);
  ans=v[0];
  for(int i=1;i<N;i++){
  	ans=(double)(ans+v[i])/2;
  }
  cout<<ans<<endl;
}	


Measured memory_bytes: 256
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: 
            for x,y in testimony[j]:
                if (i>>x)&1 != y: 
                    flag = 1
                    break
    if flag == 0: 
        honest = max(honest, bin(i)[2:].count('1')) 
print(honest)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inp(n);
    inp(k);
    inpv(a, n);
    sort(all(a));
    while(k--&&a.size()){
        a.pop_back();
    }
    ll ans = 0;
    for(auto i:a){
        ans+=i;
    }
    out(ans);
}

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

ll gcd(ll a,ll b){
    while(a != b){
        if(a < b){
            b -= a;
        }else{
            a -= b;
        }
    }
    return a;
}
ll lcm(ll a, ll b){
    ll x;
    x = gcd(a,b);
    return a*b/x;
}

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

    ll a,b;
    cin >> a >> b;
    
    cout << lcm(a,b) << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
using namespace std;
const int maxn=100000+10;
int a[maxn],xds[maxn*4],szx;
int n,t,anss,cnt;
inline int bigger(int f1,int f2){
	if (a[f1]>=a[f2])return f1;
	else return f2;
}
inline int find(int l,int r){
	int ans=0;
	l+=szx-1;
	r+=szx+1;
	while ((l>>1)!=(r>>1)){
		if (!(bool)(l&1)){
			ans=bigger(ans,xds[l+1]);
		}
		if ((bool)(r&1)){
			ans=bigger(ans,xds[r-1]);
		}
		l=l>>1;
		r=r>>1;
	}
	return ans;
}
int main(){
	int b1,b2,b3,b4;
	scanf("%d%d",&n,&t);
	for (b1=1;b1<=n;b1++){
		scanf("%d",&a[b1]);
	}
	a[0]=-1;
	szx=1;
	anss=0;
	while (szx-2<n)szx=szx*2;
	for (b1=1;b1<=szx;b1++){
		xds[b1]=0;
	}
	for (b1=1;b1<=n;b1++){
		xds[b1+szx]=b1;
	}
	for (b1=szx-1;b1>=1;b1--){
		xds[b1]=bigger(xds[b1*2],xds[b1*2+1]);
	}
	for (b1=1;b1<=n-1;b1++){
		b2=find(b1+1,n);
		//printf("%d\n",a[b2]-a[b1]);
		if (anss<a[b2]-a[b1]){
			anss=a[b2]-a[b1];
			cnt=1;
		} else if(anss==a[b2]-a[b1]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>
#include <bitset>

constexpr long long MOD = 1000000007;

int main()
{
  long long N;
  std::cin >> N;
//  int ans1 = 0;
//  for (long long i = N - 1; 0 < i; --i)
//  {
//    if (N / i == N % i)
//      ans1 += i;
//  }
  if (N < 3)
  {
    std::cout << 0 << std::endl;
    return 0;
  }
  long long  ans = N - 1;
  long long limit = (std::sqrt(N) + 1LL) * 3;
  for (long long i = 2; i <= limit; ++i)
  {
    long long left = 1;
    long long right = N;
    long long n = -1;
    while (left < right)
    {
      long long mid = left + ((right - left) / 2LL);
      long long quot = N / mid;
      if (i < quot)
        left = mid + 1;
      else if (quot < i)
        right = mid;
      else
      {
        long long res = N % mid;
        if (res == quot)
        {
          n = mid;
          break;
        }
        else if (res < i)
          right = mid;
        else
          left = mid + 1;
      }
    }
    if (0 < n)
    {
//      std::cout << n << ": " << i << std::endl;
      ans += n;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <queue>
using namespace std;

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

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

void dfs(int x,int y){
    table[x][y]='0';
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx>=0&&nx<12&&ny>=0&&ny<12&&table[nx][ny]=='1'){
            dfs(nx,ny);
        }        
    }
}

int main(){
    while(cin >> table[0]){
        for(int i=1;i<12;i++) cin >> table[i];
        int ans=0;
        rep(i,12){
            rep(j,12){
                if(table[i][j]=='1'){
                    dfs(i,j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010] = {0};

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) cin >> value[i] >> weight[i];


    // DPループ
    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= W; w++) {
        if (w >= weight[i]){
            dp[i + 1][w]=max(dp[i][w-weight[i]]+value[i],max(dp[i][w],dp[i+1][w-weight[i]]+value[i]));
        }
        else dp[i + 1][w] = dp[i][w];
        }
    }

    cout << dp[n][W] << endl;
}



Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

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

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int M1 = sc.nextInt();
            int D1 = sc.nextInt();
            int M2 = sc.nextInt();
            int D2 = sc.nextInt();

            if (D2 == 1) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  

      string s,t;cin>>s>>t;
      cout<<t<<s;
        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
N=int(input());p=[[]for _ in range(N+1)]
for _ in range(N-1):u,v,w=map(int,input().split());p[u].append((v,w));p[v].append((u,w))
s=[(1,0)];l=[-1]*N
while s:
 a,w=s.pop()
 l[a-1]=w%2
 for b,c in p[a]:
  if l[b-1]==-1:s.append((b,w+c))
for i in l:print(i)

Measured memory_bytes: 38800
#include <cmath>
#include <iostream>
using namespace std;
int main(){

int N;
double a;

cin >>N;

for(int i=0;i<=20;i++){
    
a=i;
  
   if(N<pow(2.0,a)){
   break;}
}
   cout<<pow(2.0,a-1)<<endl;



return 0;
}


Measured memory_bytes: 3476
n = int(input())
A = {}
B = list(map(int,input().split()))
S = sum(B)
for i in B:
    if i in A:
        A[i] += 1
    else:
        A[i] = 1
#print(A)
q = int(input())
for _ in range(q):
    b,c = map(int,input().split())
    if (b in A) and A[b] > 0:
        S += (c-b)*A[b]
        if not c in A:
            A[c] = 0
        A[c] += A[b]
        A[b] = 0
    print(S)

Measured memory_bytes: 20836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=500050;
char s[N];
int main()
{
	int n,i;
	scanf("%s",s+1);
	n=strlen(s+1);
	int w=0;
	ll sol=0;
	for(i=n;i>=1;i--)
	{
		if(s[i]=='W') w++;
		else sol+=w;
	}
	printf("%lld\n",sol);
	return 0;
}

Measured memory_bytes: 384
package main

import (
    "fmt"
)

func main() {
    a := scanInt()
    b := scanInt()
    c := scanInt()
    if a == b && b == c {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N, K;
	int R, S, P;
	cin >> N >> K >> R >> S >> P;
	string T;
	cin >> T;
	vector<int>A = { R,S,P };
	string Takahashi;
	long ans = 0;
	for (long i = 0; i < N; i++) {
		if (T.at(i) == 'r') {
			Takahashi.push_back('p');
		}
		else if (T.at(i) == 's') {
			Takahashi.push_back('r');
		}
		else {
			Takahashi.push_back('s');
		}
	}
	long j = 0;
	for (long i = K; i < N; i++) {
		if (Takahashi.at(i) == Takahashi.at(j)) {
			Takahashi.at(i) = 'n';
		}
		j++;
	}
	for (long i = 0; i < N; i++) {
		if (Takahashi.at(i) == 'r') {
			ans += R;
		}
		else if (Takahashi.at(i) == 's') {
			ans += S;
		}
		else if (Takahashi.at(i) == 'p') {
			ans += P;
		}
	}
	std::cout << ans << endl;
}


Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e2+2;

ll mult(ll x, ll y)
{
    return 1LL * x * y;
}

ll power(ll base, ll exp)
{
    ll ret = 1;
    for (; exp; exp >>= 1, base = mult(base, base))
        if (exp&1)
            ret = mult(ret, base);

    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll n;
    cin>>n;
    ll cnt=0,res=0;
    while(n)
        n/=2,cnt++;
    lp(i,0,cnt)
        res+=power(2,i);
    cout<<res;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define SORT(A) sort(A.begin(), A.end())
#define SORTG(A) sort(A.begin(), A.end(), greater<int>())
#define bit_search(bit, n) REP(bit, 1<<n)
#define bit_i_t(bit, i) (bit>>i) & 1
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<string> VS;
using ll = long long;
const int INF = 1e9;

int main()
{
    string num;
    cin >> num;
    int result;
    bit_search(bit, 3)
    {
        VC op(3);
        result = num.at(0) - '0';
        REP(i, 3)
        {
            if (bit_i_t(bit, i))
            {
                result += num.at(i+1) - '0';
                op.at(i) = '+';
            }
            else
            {
                result -= num.at(i+1) - '0';
                op.at(i) = '-';
            }
        }
        if (result == 7)
        {
            cout << num.at(0) << op.at(0) << num.at(1) << op.at(1) << num.at(2) << op.at(2) << num.at(3) << '=' << '7' << endl;
            return 0;
        }
    }
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e18;

ll H,W;
string A[1010];
ll visited[1010][1010];
ll ans;
ll dy[]={1,0,-1,0};
ll dx[]={0,1,0,-1};
int main() {
	cin >> H>>W;
	REP(i,0,H){
		cin>>A[i];
	}
	queue<pair<int,int>> q;
	REP(i,0,H){
		REP(j,0,W){
			if(A[i][j]=='#'){
				q.push({i,j});
				visited[i][j]=0;
			}else{
				visited[i][j]=-1;
			}
		}
	}
	while(!q.empty()){
		auto now=q.front();
		q.pop();
		ll y=now.first;
		ll x=now.second;
		for(ll k=0;k<4;k++) {
			ll ny = y + dy[k];
			ll nx = x + dx[k];
			if (!CK(nx, 0, W) || !CK(ny, 0, H) || visited[ny][nx] >= 0) {
				continue;
			}
			visited[ny][nx] = visited[y][x] + 1;
			q.push({ny, nx});
			ans = max(ans, visited[ny][nx]);
		}

	}

	p(ans);
	return 0;
}


Measured memory_bytes: 17424