akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  vector<int> d;
  for (int i = 0; i + 1 < n; i++) {
    d.push_back(in[i + 1] - in[i]);
  }
  sort(d.begin(), d.end());
  vector<long long> sum(n);
  for (int i = 0; i + 1 < n; i++) {
    sum[i + 1] = sum[i] + d[i];
  }
  long long ans = 1LL << 60;
  for (int i = 0; i <= n - 1; i++) {
    ans = min(ans, 1LL * b * i + 1LL * a * sum[n - 1 - i]);
  }
  cout << ans << endl;
  return 0;	
}

Measured memory_bytes: 1912
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h, m; cin >> a >> b >> h >> m;
    double radh = 30.0 * h, radm = 6.0 * m;
    radh += 0.5 * m;
    double mid = radh - radm;
    // chmin(mid, 360 - mid);
    double rad = mid * M_PI / 180.0;
    double c2 = (double)(a * a) + (double)(b * b) - (double)(2 * a * b) * cos(rad);
    cout << fixed << setprecision(12) << sqrt(c2) << '\n';
    return 0;
}


Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    int a, b, m; cin >> a >> b >> m;
    vector<int> A(a), B(b);
    REP(i, a) cin >> A[i];
    REP(i, b) cin >> B[i];
    int tmpmin = 1000000;
    REP(i, m){
        int x, y, c;
        cin >> x >> y >> c;
        int tmp = A[x-1]+B[y-1]-c;
        //cout << "tmp; " << tmp << endl;
        tmpmin = min(tmpmin, tmp);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    tmpmin = min(A[0] + B[0], tmpmin);
    cout << tmpmin << endl;
    
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
string s, t;

int main(){

  n = in();
  s = stin();
  t = stin();

  REP( i , n+1 ){
    if( s.substr( i ) == t.substr( 0 , n-i ) ){
      printf( "%lld\n" , n + i );
      return 0;
    }
  }

  assert( false );
  
  return 0;
}


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

int main()
{
	int n;
	set <long long> p;

	cin >> n;

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

		sort(a, a + 3);

		long long pt = a[0] * 100000000 + a[1] * 10000 + a[2];
		p.insert(pt);
	}
	
	cout << n - p.size() << endl;

	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
char c[N][N]; ll _s[N][N+N]; int _gg[N][N+N],n,m;
struct P{int x,y;}a[N*N];
vector<P> v1[N],_v2[N+N];
#define s(x,y) _s[x][y+N]
#define gg(x,y) _gg[x][y+N]
#define v2(x) _v2[x+N]
inline int S(int x1,int y1,int x2,int y2)
{if(x1>x2||y1>y2||x1<2||x2>n+m||y1<1-m||y2>n-1)return 0;
return s(x2,y2)-s(x2,y1-1)-s(x1-1,y2)+s(x1-1,y1-1);}
inline bool cmp1(P x,P y){return x.y<y.y;}
inline bool cmp2(P x,P y){return x.x<y.x;}
int main()
{	int t=0; ll s1=0,s2=0; cin>>n>>m;
	for(rint i=1;i<=n;i++) scanf("%s",c[i]+1);
	for(rint i=1;i<=n;i++)
	for(rint j=1;j<=m;j++)
	if(c[i][j]=='#')
	{
//	cerr<<"!!!"<<i+j<<" "<<i-j<<endl;
	a[++t]=P{i+j,i-j},v1[i+j].push_back(a[t]),v2(i-j).push_back(a[t]),gg(i+j,i-j)++;
	}
	for(rint i=2;i<=n+m;i++) sort(v1[i].begin(),v1[i].end(),cmp1);
	for(rint i=1-m;i<=n-1;i++) sort(v2(i).begin(),v2(i).end(),cmp2);
	for(rint i=2;i<=n+m;i++)
	for(rint j=1-m;j<=n-1;j++) s(i,j)=s(i-1,j)+s(i,j-1)-s(i-1,j-1)+gg(i,j);
	for(rint i=2;i<=n+m;i++)
	for(rint j=0;j<v1[i].size();j++)
	for(rint k=j+1;k<v1[i].size();k++)
	{	P x=v1[i][j],y=v1[i][k];
		int d=y.y-x.y;
	//	cerr<<"!!!"<<x.x<<" "<<x.y<<" "<<y.y<<" "<<x.x+d<<" "<<S(x.x+d,x.y+1,x.x+d,y.y-1)<<endl;
		s1+=S(x.x+d,x.y+1,x.x+d,y.y-1)+S(x.x-d,x.y+1,x.x-d,y.y-1);
		s2+=S(x.x+d,x.y,x.x+d,x.y)+S(x.x+d,y.y,x.x+d,y.y)+
			S(x.x-d,x.y,x.x-d,x.y)+S(x.x-d,y.y,x.x-d,y.y);
	}
//	debug(s1);debug(s2);
	for(rint i=1-m;i<=n-1;i++)
	for(rint j=0;j<v2(i).size();j++)
	for(rint k=j+1;k<v2(i).size();k++)
	{	P x=v2(i)[j],y=v2(i)[k];
		int d=y.x-x.x;
		s1+=S(x.x+1,x.y+d,y.x-1,x.y+d)+S(x.x+1,x.y-d,y.x-1,x.y-d);
		s2+=S(x.x,x.y+d,x.x,x.y+d)+S(y.x,x.y+d,y.x,x.y+d)+
			S(x.x,x.y-d,x.x,x.y-d)+S(y.x,x.y-d,y.x,x.y-d);
	}
//	debug(s1);debug(s2);
	cout<<s1+s2/2;
	return 0;
}


Measured memory_bytes: 23808
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    P = list(map(int, readline().rstrip().split()))
    l = ['x' if p == i+1 else 'o' for i, p in enumerate(P)]
    l = ''.join(l)
    ll = l.replace('xx', '')
    ans = (len(l) - len(ll)) // 2 + ll.count('x')
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 14008
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main m = new Main();
        m.solve();
    }
    private void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Path>[] graph = new List[N];
        for (int i = 0; i < N; i++) {
            graph[i] = new ArrayList<>();
        }
        for (int i = 0; i < N - 1; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            long c = scan.nextLong();
            Path p1 = new Path(a, b, c);
            graph[a].add(p1);
            Path p2 = new Path(b, a, c);
            graph[b].add(p2);
        }
        int Q = scan.nextInt();
        int K = scan.nextInt()-1;
        Queue<Integer> queue = new LinkedList<>();
        long[] distances = new long[N];
        Arrays.fill(distances, Long.MAX_VALUE);
        distances[K] = 0;
        queue.add(K);
        while(!queue.isEmpty()) {
            int current = queue.poll();
            List<Path> neighbors = graph[current];
            for (Path p : neighbors) {
                if (distances[p.from] + p.cost < distances[p.to]) {
                    distances[p.to] = distances[p.from] + p.cost;
                    queue.add(p.to);
                }
            }
        }
        for (int i = 0; i < Q; i++) {
            int from = scan.nextInt() - 1;
            int to = scan.nextInt() - 1;
            System.out.println(distances[from] + distances[to]);
        }
    }

    class Path {
        int from;
        int to;
        long cost;
        Path(int from, int to, long cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 180804
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}


void solve()
{

	ll i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
	    m=n/i;
	    sum+=(m*(m+1)/2)*i;
	}
	cout<<sum;
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3640
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#define SZ(x) ((int)(x).size())
#define all(x)  x.begin(),x.end()
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define tt int t;cin >> t;while(t--)
#define int3(x,y,z) int x,y,z;cin >> x >> y >> z;
#define int2(x,y) int x,y;cin >> x >>y;
#define int1(x) int x;cin>>x;
#define vi vector<int>
#define vii vector<vector<int>>
typedef long long ll;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//bool cmp(pair<string,int>p1,pair<string,int>p2) {
//    return p1.ss > p2.ss;
//}
//if (s1.find(s2) != std::string::npos) {
//   std::cout << "found!" << '\n';
//}


using namespace std;

int main() {
    fio
    int2(k,n)

    vi ind;
    for (int i = 0; i < n; ++i) {
        int x ;
        cin >> x;
        ind.pb(x);
    }
    sort(all(ind));
    int dist = -1;
    for (int j = 0; j < n-1; ++j) {
        dist = max(dist,ind[j+1] - ind[j]);
    }
    dist = max(dist,(k-ind[n-1]) + ind[0]);
    cout << k - dist << endl;




    return 0;
}






Measured memory_bytes: 1400
s = str(input()).lower()
result = s.translate(str.maketrans({'a': 'x', 'b': 'x', 'c': 'x', 'd': 'x', 'e': 'x', 'f': 'x', 'g': 'x', 'h': 'x', 'i': 'x', 'j': 'x', 'k': 'x', 'l': 'x', 'm': 'x', 'n': 'x', 'o': 'x', 'p': 'x', 'q': 'x', 'r': 'x', 's': 'x', 't': 'x', 'u': 'x', 'v': 'x', 'w': 'x', 'y': 'x', 'z': 'x'}))
print(result)

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, m;
  cin >> n >> m;
  int a[n+1]={};
  for(int i=0; i<m; i++){
    int l, r;
    cin >> l >> r;
    l--;
    a[l] += 1;
    a[r] -= 1;
  }
  int ans = 0;
  if(a[0]==m) ans++;
  for(int i=1; i<n; i++){
    a[i] += a[i-1];
    if(a[i]==m) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

void mainp()
{
	int n, k;
	cin>>n>>k;
	
	long long ans=1000000000000000000ll;
	for(int i=0; i<(1<<n); i++)
	{
		long long temp=1;
		for(int j=0; j<n; j++)
		{
			if(i&(1<<j)) temp*=2;
			else temp+=k;
		}
		
		ans=min(ans, temp);
	}
	
	cout<<ans<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	mainp();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  char c[3][3];
  rep(i, 3){
    rep(j, 3) cin >> c[i][j];
  }

  rep(i, 3) cout << c[i][i];
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int main(){
    ll n,k,ans;
    cin>>n>>k;
    if(!(k%2)){
        ans=pow(n/k,3)+pow(n/(k/2)-n/k,3);
    }
    else{
        ans=pow(n/k,3);
    }
    cout<<ans<<endl;
    return 0;   
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)



def mas():
    n,m = map(int,input().split())
    s = list(input())
    t = list(input())


    length = lcm(n,m)
    stepn = length//n
    stepm = length//m
    step_lcm = lcm(stepn,stepm)

    if s[0] != t[0]:
        print(-1)
        return 0
    else:
        if step_lcm >= length:
            print(length)
            return 0
        else:
            steps = step_lcm//stepn
            stept = step_lcm//stepm

            pos_s = 0
            pos_t = 0
            i = 0
            pos_s = 0
            pos_t = 0
            while pos_s < n and pos_t < m:
                if not s[pos_s] == t[pos_t]:
                    print(-1)
                    return 0
                i+=1
                pos_s = i*steps
                pos_t = i*stept
            print(length)

mas()

Measured memory_bytes: 4628
//
//  main.cpp
//  ABC164
//
//
//  Copyright © 2020 エロやん. All rights reserved.
//

#include <iostream>
using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
    c=c-b;
        if(c<=0){
        cout<<"Yes"<<endl;
            goto EXIT;
        }
        a=a-d;
        if(a<=0){
        cout<<"No"<<endl;
        
            goto EXIT;
            
        }
        
    }
    EXIT:
    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int>vec(N,1);
  for(int i=0;i<K;i++){
    int d;
    cin >>d;
    for(int j=0;j<d;j++){
      int x;
      cin >> x;
      vec.at(x-1)=0;
    }
  }
  int sum=0;
  for(int a:vec){
    sum+=a;
  }
  cout << sum << endl;
  
  
}


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

typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a=n/100;
	int b=n-a*100;
	if(a>=20){
		cout<<1<<endl;
		return 0;
	}else{
		if(b<=a*5){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	}
	return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  string S;
  cin >> S;
  map<int,int> m;
  for(char s: S){
    if(m.count(s) == 0){
      m[s] = 1;
    } else { 
      m[s]++;
    }
  }

  bool flg1 = true;
  for(auto x: m){
    if(x.second != 2){
      flg1 = false;
      break;
    }
  }
  bool flg2 = (m.size()==2 ? true : false);
  cout << (flg1&&flg2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
 #define MOD ((int)1e9+7)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
ll visited[100005];
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

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

const int MAX = 2e5 + 10 ;
void finis(){cout<<-1;}


int main()
{  ios::sync_with_stdio(0);
    cin.tie(0);
ll ans=0;
  ll n,k;ll a[n];/*
     cin>>n>>k;
     for(int i=0;i<n;i++){cin>>a[i];}
     sort(a,a+n);
     for(int i=0;i<k;i++){ans+=a[i];}
 cout<<ans;*/
 char x;cin>>x;if(x>='a'&&x<='z'){cout<<'a';}else{cout<<'A';}
    
 
 
 
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i;
	int dp;
	while (scanf("%d",&n) != EOF) {
		dp=1;
		for (i=1;i<=n;i++) dp+=i;
		printf("%d\n",dp);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
  #pragma GCC optimize("O2")
  #define all(c) c.begin(), c.end()
  #define pb push_back
  #define ll long long
  const int MAXN = 1e5 + 5;
  const int mod = 1e9 + 7;
  
  using namespace std;
  
  int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll s = 0;
    for (ll i = 1; i <= n; i++) {
      if (i%3 == 0 || i%5 == 0) continue;
      s += i;
    }
    cout << s;
    return 0;
  }

Measured memory_bytes: 3652
import java.util.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int count = 0;
        for(int i = 0;i < n;i++){
            BigInteger bi = new BigInteger(sc.next());
            if(bi.isProbablePrime(5)) count++;
        }
        System.out.println(count);
        
    }
}


Measured memory_bytes: 55256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

    int X = A * B;
    int Y = A * B * 2;
    int Z = A * B * 3;

    if (X % 2 == 1 || Y % 2 == 1 || Z % 2 == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

char rc[500][500],bc[500][500];
int h,w;

int main(){
    cin >> h >> w;
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            char c;
            cin >> c;
            if(c=='#') rc[i][j] = bc[i][j] = '#';

            if(j==0) rc[i][j] = '#';
            else if(j==w-1) bc[i][j] = '#';
            else{
                if(i%2) rc[i][j] = '#';
                else bc[i][j] = '#';
            }
        }
    }
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cout << (rc[i][j]=='#'?'#':'.');
        }
        cout << endl;
    }
    cout << endl;
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cout << (bc[i][j]=='#'?'#':'.');
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int v;
int e;

vector<vector<int>> edges(101010,vector<int>());
vector<int> vis(101010,-1);

vector<int> vec;

int c(int k){
	priority_queue<int> que;
	que.push(k);
	for(int a : vec){
		que.push(a);
	}
	while(que.size() >= 2){
		int t1 = que.top();
		que.pop();
		int t2 = que.top();
		que.pop();
		que.push(t1 - t2);
	}
	return que.top();
}

int binary(){
	for(int i = 0;i <= v;i++){
		if(c(i) == 0){
			return i;
		}
	}
	return -1;
}


P bfs(int s){
	queue<P> que;
	que.emplace(s,0);
	vis[s] =  0;
	P res = {0,0};
	while(!que.empty()){
		int v = que.front().first;
		int d= que.front().second;
		que.pop();
		if(d % 2 == 0) res.first++;
		else res.second++;

		for(auto& to : edges[v]){
			if(vis[to] == -1){
				vis[to] = (d + 1) % 2;
				que.emplace(to,vis[to]);
			}
			else if((vis[to] - vis[v] + 1) % 2 != 0){
				return {-1,-1};
			}
		}
	}
	return res;
}

int main(){
	cin >> v >> e;
	for(int i = 0;i < e;i++){
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	bitset<101010> bit(1);
	for(int i = 1;i <= v;i++){
		if(vis[i] == -1){
			auto p = bfs(i);
			if(p.first == -1){
				cout << -1 << endl;
				return 0;
			}
			bit = (bit << p.first) | (bit << p.second);
		}
	}

	i64 res = 0;
	for(i64 i = 0;i < v;i++){
		if(bit[i])res = max(res, i * (v - i) - e);
	}

	cout << res << endl;
}



Measured memory_bytes: 9524
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)

//main.cpp-Sample


namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
}


using namespace std;
signed main (){
	incin(a);
	incin(b);

	if(a <= 8 && b<= 8){
		cout<<"Yay!"<<endl;
	}else{
		cout<<":("<<endl;
	}
	return 0;
}




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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int h,a;
    cin >> h >> a;
    int count = 0;
    while(h>0) {
        h-=a;
        count++;
    }
    cout << count<< endl;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int N,W,D;
    while(cin>>N>>W>>D,N||W||D){
        vpint v;
        v.pb(pint(W,D));
        while(N--){
            int P,S;
            cin>>P>>S;
            P--;
            auto p=v[P];
            v.erase(v.begin()+P);
            pint x,y;
            S%=p.fi+p.se;
            if(S<p.fi){
                x=pint(S,p.se);
                y=pint(p.fi-S,p.se);
            }
            else{
                x=pint(p.fi,S-p.fi);
                y=pint(p.fi,p.fi+p.se-S);
            }
            if(x.fi*x.se>y.fi*y.se)swap(x,y);
            v.pb(x);
            v.pb(y);
        }
        vint u(v.size());
        rep(i,v.size())u[i]=v[i].fi*v[i].se;
        sort(all(u));
        for(int i=0;i<u.size();i++){
            if(i)cout<<" ";
            cout<<u[i];
        }
        cout<<endl;
    }
    return 0;
}

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

#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
#define ld long double

const int mod = 1000000007;
const ld PI = acosl(-1.0);
ll temp;

int primes[1000001];
int ins[1000001];
void sieve()
{
    for (int i = 0; i < 1000001; i++)
        primes[i] = i;
    for (int i = 2; i * i < 1000001; i++)
    {
        if (primes[i] == i)
        {
            for (int j = i * i; j < 1000001; j += i)
            {
                if(primes[j] == j)
                primes[j] = i;
            }
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    f1(i, 0, n)
        cin >> a[i];
    sieve();
    int gcd = a[0];
    f1(i, 1, n)
    {
        gcd = __gcd(gcd, a[i]);
    }

    memset(ins, 0, sizeof ins);

    int pairco = true;
    for(int i = 0; i < n; i++)
    {
        temp = a[i];
        while(temp != 1)
        {
            ins[primes[temp]]++;
            int fact = primes[temp];
            while(temp % fact == 0 && fact != 1)
            temp /= fact;
        }
    }
    f1(i, 2, 1000001)
    {
        // cout<<i<<gp<<ins[i]<<endl;
        if(ins[i] > 1)
        {
            pairco = false;
            break;
        }
    }
    if(pairco)
    cout<<"pairwise coprime"<<endl;
    else if(gcd == 1)
    {
        cout<<"setwise coprime"<<endl;
    }
    else
    {
        cout<<"not coprime"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 27044
#include<iostream>
#include<map>


using namespace std;

int main()
{
    // 整数の入力
    int a;
    int temp;
    cin >> a;

    map<int,int> mp;

    for(int i; i<a; i++){
        cin >> temp;
        mp[temp]++;
    }

    temp = 0;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->first != itr->second){
            if(itr->first < itr->second){
                temp += (itr->second - itr->first);
            }else{
                temp += itr->second;
            }
        }
    }

    cout << temp << endl;

    return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstring>
#include<cstdio>
#define int long long
using namespace std;

const int mo=1e9+7;

int n,a[200001],tree[200001],tree1[200001],d[200001],cnt[200001];
int zero[200001],pos[200001];

int get(int o) {int yu=0;for(int i=o;i>=1;i-=(-i)&i) yu=(yu+tree[i])%mo;return yu;}

int get1(int o) {int yu=0;for(int i=o;i>=1;i-=(-i)&i) yu+=tree1[i];return yu;}

void put(int o,int p){for(int i=o;i<=n;i+=(-i)&i) tree[i]=(tree[i]+p)%mo,tree1[i]++;}

int mi(int o,int p)
{
	int u=1;
	while(p>0)
	{
		if(p&1) u=1ll*u*o%mo;
		o=1ll*o*o%mo;
		p>>=1;
	}
	return u;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) put(a[i],1);
	for(int i=1;i<=n;i++) cnt[i]=get1(n)-get1(i-1);
	int S=1;
	for(int i=1;i<=n;i++) 
	{
		if((cnt[i]-n+i)<=0) {cout<<0<<endl;return 0;}
	    S=1ll*S*(cnt[i]-n+i)%mo;
	}
	pos[0]=1;d[0]=1;
	for(int i=1;i<=n;i++)
	{
		int yu=1ll*(cnt[i]-n+i-1)*mi(cnt[i]-n+i,mo-2)%mo;
		if(yu==0) {pos[zero[i]=(zero[i-1]+1)]=i;d[i]=d[i-1];}else 
		{d[i]=1ll*d[i-1]*yu%mo;zero[i]=zero[i-1];}
	}
	memset(tree,0,sizeof(tree));
	memset(tree1,0,sizeof(tree1));
	int ans=0;
	for(int i=1;i<=n;i++)
	{
	    ans+=1ll*d[a[i]]*((get(a[i])-get(pos[zero[a[i]]]-1)+mo)%mo)%mo*mi(2,mo-2)%mo*S%mo;
	    ans%=mo;
	    put(a[i],mi(d[a[i]],mo-2));
	}
	memset(tree,0,sizeof(tree));
	memset(tree1,0,sizeof(tree1));
	for(int i=n;i>=1;i--)
	{
		ans-=1ll*d[a[i]]*((get(a[i]-1)-get(pos[zero[a[i]]]-1)+mo)%mo)%mo*mi(2,mo-2)%mo*S%mo;
		ans=(ans+mo)%mo;
		ans+=1ll*get1(a[i]-1)*S%mo;
		ans%=mo;
		put(a[i],mi(d[a[i]],mo-2));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
def main():
    H, W = map(int, input().split())
    A = [[c for c in input()] for _ in range(H)]
    sniprows = set()
    for i in range(H):
        snip = True
        for j in range(W):
            if A[i][j] == "#":
                snip = False
        if snip:
            sniprows.add(i)
    snipcols = set()
    for j in range(W):
        snip = True
        for i in range(H):
            if A[i][j] == "#":
                snip = False
        if snip:
            snipcols.add(j)
    for i in range(H):
        if i in sniprows:
            continue
        ans = ""
        for j in range(W):
            if j in snipcols:
                continue
            ans += A[i][j]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

long long A[200005];

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

    long long cnt = 0;
    for(int i = 0;i < N; i++)
    {
        cin >> a;
        if(a == cnt+1)
        {
            cnt++;
        }
        A[i] = a;
    }
    if(cnt == 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N - cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a, b;
		int S, L;
		
		a = scan.nextInt();
		b = scan.nextInt();
		
		S = a * b;
		L = (a + b) * 2;
		System.out.println(S + " " + L);
	}

}

Measured memory_bytes: 26140
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don�t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         System.out.println(3*N*N);
      }
      public static void sort(int[] arr)
      {
         //stable heap sort
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   }

Measured memory_bytes: 21204
n = int(input())
dl = list(map(int, input().split()))

MOD = 998244353
ans = 0
d_comb = [0]*n

if dl[0] == 0:
    ans = 1
    d_comb[0] = 1
else:
    print(0)
    exit()

dl.sort()
if n == 1:
    print(1)
    exit()
elif dl[1] == 0:
    print(0)
    exit()

for d in dl[1:]:
    ans *= d_comb[d-1]
    d_comb[d] += 1
    ans %= MOD

print(ans)    


Measured memory_bytes: 86148
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#define N 101

using namespace std;

int main () {
  // first 权重，second 顶点 id
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > V[N];
  int n, a, T[N], cost = 0, cnt = 0;

  cin >> n;
  
  // 输入为邻接矩阵
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a;

      if (a >= 0) {
        V[i].push(make_pair(a, j));
      }
    }
  }
  
  for (int i = 0; i < N; i++)
    T[i] = 0;

  T[0] = 1;

  while (cnt < n - 1) {
    int minCost = (1 << 21);
    int minI;

    // cout << "cnt = " << cnt << endl;

    for (int i = 0; i < n; i++) {
      if (T[i]) {
        // cout << "i = " << i << endl;
        while (V[i].size() && T[V[i].top().second])
          V[i].pop();

        if (V[i].size() && V[i].top().first < minCost) {
          minCost = V[i].top().first;
          minI = i;
        }
      }
    }

    // cout << minI << " " << V[minI].top().first << " " << V[minI].top().second << endl;

    cost += V[minI].top().first;
    T[V[minI].top().second] = 1;
    V[minI].pop();
    cnt++;
  }

  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 3184
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	int ans = 0;
	for(int i=1; i<n/2; i++){
		ans++;
	}
	if(n%2 == 1) ans++;
	if(n==1) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<string> a(n); REP(i, n) cin >> a[i];
  vector<string> b(m); REP(i, m) cin >> b[i];

  REP(i, n-m+1) {
    int index = -1;
    while (true) {
      bool ok = true;
      index = a[i].find(b[0], index + 1);
      if (index != -1 && index <= n-m) {
        FOR(j, 1, m) {
          int ind = a[i+j].find(b[j], index);
          if (ind == index) continue;
          ok = false;
        }
      } else break;
      if (ok) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
b = [0]*4
for i in range(3):
    roads = list(map(int,input().split()))
    for j in roads:
        b[j-1] += 1
        #Count the degree of each vertice

numOdds = 0
for i in b:
    if i%2!=0:
        numOdds+=1

if numOdds==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		int numOrigin = num;
		int sumEachDigit = 0;
		while(num>0) {
			sumEachDigit += num % 10;
			num /= 10;
		}
		if(numOrigin%sumEachDigit==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
/* All our base are belong to AC */
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
ll adad(ll x) {return x*(x+1)/2;} // 1～xの総和

int d;
ll c[26], s[365][26], t[365];
set<int> v[26];
ll an;

void solve0() {
  an=0;
  for(int i=0;i<d;i++) {
    an+=s[i][t[i]];
  }
  for(int i=0;i<26;i++) {
    int bf = -2;
    ll su = 0;
    for(int x : v[i]) {
      su+=adad(x-bf-1);
      bf=x;
    }
    an-=su*c[i];
  }
}

void solve1(int h, int k) {
  int bf = t[h];
  an-=s[h][bf];
  an+=s[h][k];

  auto s1 = v[bf].lower_bound(h);
  auto s2 = v[bf].upper_bound(h);
  s1--;
  //cout<<*s1<<" "<<h<<" "<<*s2<<endl;

  an+=adad((*s2) - h - 1) * c[bf];
  an+=adad(h - (*s1) - 1) * c[bf];
  an-=adad((*s2) - (*s1) - 1) * c[bf];
  v[bf].erase(h);
  
  auto t1 = v[k].lower_bound(h);
  auto t2 = v[k].upper_bound(h);
  t1--;
  //cout<<*t1<<" "<<h<<" "<<*t2<<endl;

  an-=adad((*t2) - h - 1) * c[k];
  an-=adad(h - (*t1) - 1) * c[k];
  an+=adad((*t2) - (*t1) - 1) * c[k];
  v[k].insert(h);
  t[h]=k;
}

int main() {
  cin>>d;
  for(int i=0;i<26;i++) {
    cin>>c[i];
  }
  for(int i=0;i<d;i++) {
    for(int j=0;j<26;j++) {
      cin>>s[i][j];
    }
  }
  for(int i=0;i<26;i++) {
    v[i].insert(-1);
    v[i].insert(d);
  }
  for(int i=0;i<d;i++) {
    t[i] = i%26;//r::nd(26)-1;
    v[t[i]].insert(i);
  }
  solve0();
  for(int i=0;i<7700000;i++) {
    int f = i%d, g = i%26;
    //int f = r::nd(d)-1;
    //int g = r::nd(26)-1;
    ll ba = an;
    int undo = t[f];
    solve1(f,g);
    if (ba > an) solve1(f,undo);
    //if(i%700000==0)cout<<an<<" ";
  } //cout<<endl;
  for(int i=0;i<d;i++) {
    cout<<t[i]+1<<endl;
  }
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

// Binary Indexed Tree (Fenwick Tree)
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main(){
    int N,Q; cin >> N >> Q;
    vector<int> c(N);
    rep(i,N) cin >> c[i];
    vector<int> pi(N+1,-1);
    vector<vector<int>> ps(N);
    rep(i,N){
        int l = pi[c[i]];
        if (l!=-1) ps[l].push_back(i);
        pi[c[i]] = i;
    }

    vector<vector<pair<int, int>>> qs(N);
    rep(i,Q){
        int l, r; cin >> l >> r;
        l--;
        r--;
        qs[l].emplace_back(r,i);
    }


    BIT<int> d(N);
    vector<int> ans(Q);
    for (int x = N-1; x >= 0; --x){
        for (int y : ps[x]) d.add(y,1);
        for (auto query : qs[x]){
            int r = query.first, i = query.second;
            ans[i] = (r-x+1) - d.sum(r);
        }
    }

    rep(i,Q) cout << ans[i] << endl;
}

Measured memory_bytes: 59940
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<ext/rope>
#define int long long
using namespace std;
using namespace __gnu_cxx;
typedef long long LL;
const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
vector<int> g[MAXN];
int fa[MAXN],mx[MAXN];
void dfs(int u,int f){
	fa[u]=f;
	for(int i=0;i<g[u].size();i++){
		int v = g[u][i];
		if(v==f) continue;
		dfs(v,u);
		mx[u] = max(mx[u],mx[v]+1);
	}
}
signed main(){
	int n,u,v; scanf("%lld%lld%lld",&n,&u,&v);
	for(int i=1;i<n;i++){
		int x,y; scanf("%lld%lld",&x,&y);
		g[x].push_back(y); g[y].push_back(x);
	}
	dfs(v,-1);
	int dis=0,rt=u;
	while(rt!=v) dis++,rt=fa[rt];
	dis=(dis-1)>>1;
	while(dis--) u=fa[u];
	int res=mx[u];
	while(u!=v) res++,u=fa[u];
	printf("%lld\n",res-1);
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    bool ans = true;
    rep(i, h) rep(j, w) {
        if (s[i][j] != '#') continue;
        bool ok = false;
        if (i-1>=0 && s[i-1][j]=='#') ok = true;
        if (i+1<=h-1 && s[i+1][j]=='#') ok = true;
        if (j-1>=0 && s[i][j-1]=='#') ok = true;
        if (j+1<=w-1 && s[i][j+1]=='#') ok = true;
        if (!ok) ans = false;
    }
    if (ans) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3556
# coding: utf-8
# Your code here!
MOD=10**9+7

def dot(a, b):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        for k, aik in enumerate(a[i]):
            for j,bkj in enumerate(b[k]):
                res[i][j] += aik*bkj
                res[i][j] %= MOD
 
    return res


n,k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(n)]

ans = [[0] * n for _ in range(n)]
for i in range(n):
    ans[i][i] = 1

while k:
    k, i = divmod(k, 2)
    if i:
        ans = dot(ans, A)
    A = dot(A, A)

print(sum(sum(A) % MOD for A in ans) % MOD)

Measured memory_bytes: 43612
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}

for(int i=0;i<n;i++){
    System.out.print(a[n-i-1]);
    if(i!=n-1)System.out.print(" ");
}System.out.println("");
}
}


Measured memory_bytes: 26388
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main (String[] args){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++) a[i]=sc.nextInt();
		sc.close();
		for(int i=n-1;i>0;i--) System.out.print(a[i]+" ");
		System.out.println(a[0]);
	}
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

    int N, M;
    ll MOD = 1e9+7;
    cin >> N >> M;

    vector<ll> dp(N+10);
    vector<ll> a(M);

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

    for(int i = 0; i < dp.size(); i++){
        dp[i] = 0;
    }
    dp[0] = 1;

    vector<ll> is_broken(N+10);
    for(int i = 0; i < is_broken.size(); i++){
        is_broken[i] = 0;
    }

    for(int i = 0; i < M; i++){
        is_broken[a[i]] = 1;
    }
    
    for(int i = 0; i < N; i++){
        if(is_broken[i] == 0){//こわれてなかったら
            if(is_broken[i+1] == 0){
                dp[i+1] = (dp[i+1] + dp[i]) % MOD;
            }
            if(is_broken[i+2] == 0){
                dp[i+2] = (dp[i+2] + dp[i]) % MOD;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}



Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int start = Integer.parseInt(sc.next());
        int end = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        for (int i = start; i <= end; i++) {
            if (i < start + n || i > end - n) {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (ll i = 0; i < B; i++) { ans *= A - i; }
    for (ll i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    ll e=1000000007;
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll c = 0;
    ll ans = 0;
    rep(i, N) {
        cin >> A[i];
        c += A[i];
    }
    for (ll i = N - 1; 0 < i; i--) {
        c -= A[i];
        ans += A[i]%e*(c%e);
        ans %= e;
    }
    cout << ans % e << endl;
}

Measured memory_bytes: 4844
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}

//LOVE NyantakoGG

using namespace std;


int main() {
	long long N, M;
	cin >> N >> M;
	long long ans = 1;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	else if (abs(N - M) == 0) {
		for (int i = 1; i <= N; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		for (int i = 1; i <= M; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		ans *= 2;
		ans %= 1000000007;
	}
	else {
		for (int i = 1; i <= N; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		for (int i = 1; i <= M; i++) {
			ans *= i;
			ans %= 1000000007;
		}
		ans %= 1000000007;
	}
	cout << ans << endl;
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<vector<int>> switches;
    int p[m];
    for (int i = 0; i < m; ++i) {
        int k; cin >> k;
        vector<int> s(k);
        for (int j = 0; j < k; ++j) {
            cin >> s[j];
            --s[j];
        }
        switches.PB(s);
    }
    for (int i = 0; i < m; ++i) cin >> p[i];
    int ans = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        bool ok = true;
        for (int i = 0; i < m; ++i) {
            int c = 0;
            for (auto j : switches[i]) {
                if (mask & (1 << j)) ++c;
            }
            c %= 2;
            if (c != p[i]) ok = false;
        }
        if (ok) ++ans;
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 256