akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n, v;
  cin >> n >> v;
  vector<int> a(n), b(n), c(n), d(n);
  cin >> a >> b >> c >> d;
  map<int, int> m;
  rep(i, n) rep(j, n) m[a[i] + b[j]]++;
  int cnt = 0;
  rep(i, n) rep(j, n) cnt += m[v - (c[i] + d[j])];
  cout << cnt << endl;
}



Measured memory_bytes: 128068
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int d[5],p,j;
	rep(i,0,5) cin>>d[i];
	p=min(d[0],min(d[1],d[2]));
	j=min(d[3],d[4]);
	o(p+j-50);
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
    long N,A,B,C,d;
    scanf("%ld",&N);
    scanf("%ld",&A);
    scanf("%ld",&B);
    C=N/(A+B);
    d=(N%(A+B));
    if(A<d){
       printf("%ld",A*C+A); 
    }else{
        printf("%ld",A*C+d);
    }


}

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

const ll MOD=1e9+7;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  for(int i = 0; i < n; i++){
    ll big=0, small=0;
    for(int j = i+1; j < n; j++){
      if(a[i] > a[j]) small++;
      if(a[i] < a[j]) big++;
    }
    ans += big * (k*(k-1)/2 % MOD) + small * (k*(k+1)/2 % MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, q, v, w;
	cin >> n >> q;
	for(int i=0; i<q; i++){
		cin >> v >> w;
		if(1<n){
			while(v!=w){
				if(v<w) swap(v, w);
				v=(v+n-2)/n;
			}
		}
		cout << min(v, w) << endl;
	}

	return 0;
}


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

#define ll long long
#define ii pair<int, int>
#define dd pair<double, double>
#define pb(i) push_back(i)
const double PI = 3.14159265359;
const int inf = 1e9+77;
const ll mod = 1e9+7;
const double eps = 1e-7;
//int dir1[8] = {0, 0, 1, -1, 1, -1, 1, -1};
//int dir2[8] = {1, -1, 0, 0, 1, 1, -1, -1};
int dir1[4] = {0, 0, 1, -1};
int dir2[4] = {1, -1, 0, 0};

int main()
{
	int i, j;

	int ind = 0;
	string s[2], mid;
	cin >> mid;
	s[0] = "", s[1] = "";

	int q; cin >> q;
	while(q--)
	{
		int a, b;
		char c;
		
		cin >> a;
		if(a == 1)
			ind = (ind+1)%2;
		else
		{
			cin >> b >> c;
			if(b == 1)
				s[ind] += c;
			else
				s[(ind+1)%2] += c;
		}
	}

	for(i = s[ind].size()-1; i > -1; i--)
		cout << s[ind][i];
	
	if(ind == 0)
		cout << mid;
	else
		for(i = mid.size()-1; i > -1; i--)
			cout << mid[i];
	
	cout << s[(ind+1)%2] << '\n';

}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

vector<ll> vec[55];
ll par[55], dep[55], X[21], Y[21], lca[21], n, m, dp[1<<21];

void  dfs(ll u, ll p){
    par[u] = p;
    dep[u] = dep[p]+1;
    for(auto x: vec[u]){
        if(p != x){
            dfs(x, u);
        }
    }
}

void solve(){
    ll n, m; cin >>  n >> m;
    ll a[n], a2[n];
    memset(a2, 0, sizeof(a2));
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        a[i] /= 2;
    }
    ll l = a[0];
    for(ll i = 1; i < n; i++){
        ll g = __gcd(l, a[i]);
        l /= g;
        l *= a[i];
        if(l > m){
            cout << 0; return;
        }
    }
    for(ll i = 0; i < n; i++){
        if(((l/a[i])%2) == 0){
            cout << 0; return;
        }
    }
    cout << 1+((m-l) / (2*l));


}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

const i64 INF = 9e18;

// (n, m) => n番より前からm個選ぶ場合の最大値
i64 dp[1001][1001];

// O(N^2)
int main() {
    int N, M;
    cin >> N >> M;
    vector<tuple<i64, i64, i64>> data(N);
    for(auto &d : data) {
        i64 x, y, z;
        cin >> x >> y >> z;
        d = make_tuple(x, y, z);
    }
    i64 ans = 0;
    for(int bits = 0; bits < 8; bits++) {
        for(int n = 0; n <= N; n++) {
            for(int m = 0; m <= M; m++) {
                dp[n][m] = -INF;
            }
        }
        dp[0][0] = 0;
        bool a = bits & 1, b = bits & 2, c = bits & 4;
        for(int n = 0; n < N; n++) {
            for(int m = 0; m <= M; m++) {
                i64 x, y, z;
                tie(x, y, z) = data[n];
                if(a) x *= -1;
                if(b) y *= -1;
                if(c) z *= -1;
                dp[n + 1][m] = dp[n][m];
                if(m > 0) {
                    dp[n + 1][m] = max(dp[n][m],
                        dp[n][m - 1] + x + y + z);
                }
            }
        }
        ans = max(ans, dp[N][M]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
	int M = Integer.parseInt(sc.next());
	int[] a = new int[M];
	int[] b = new int[M];
	long[] ans = new long[M];

	for(int i = 0; i<M; i++) {
	    a[i] = Integer.parseInt(sc.next());
	    b[i] = Integer.parseInt(sc.next());
	}

	UnionFind uf = new UnionFind(N);
	for(int i = M-1; i >=0; i--) {
	    if(i == M-1) {
		ans[i] = (long)N*(long)(N-1)/2;
		continue;
	    }
	    if(uf.root(a[i+1]) != uf.root(b[i+1])) {
		ans[i] = ans[i+1] - (long)((long)uf.size(a[i+1])*(long)uf.size(b[i+1]));

	    } else {
		ans[i] = ans[i+1];
	    }
	    uf.connect(a[i+1],b[i+1]);
	}
	for(int i = 0; i<M; i++) {
	    System.out.println(ans[i]);
	}
    }
}
class UnionFind {
    int[] parent;
    UnionFind(int n) {
	parent = new int[n+1];
	for(int i = 0; i<=n; i++) {
	    parent[i] = -1;
	}
    }

    int root(int A) {
	if(parent[A]<0) return A;
	parent[A] = root(parent[A]);
	return parent[A];
    }

    boolean connect(int A, int B) {
	A = root(A);
	B = root(B);
	if(A == B) {
	    return false;
	}
	if(size(A) < size(B)) {
	    int tmp = B;
	    B = A;
	    A = tmp;
	}
	parent[A] += parent[B];
	parent[B] = A;
	return true;
    }

    int size(int A) {
	return -1*parent[root(A)];
    }
}

Measured memory_bytes: 69848
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
/*
double squareRoot(long long number, int precision) 
{ 
    long long start = 0, end = number; 
    long long mid; 
    double ans; 
    while (start <= end) { 
        mid = (start + end) / 2; 
        if (mid * mid == number) { 
            ans = mid; 
            break; 
        }  
        if (mid * mid < number) { 
            start = mid + 1; 
            ans = mid; 
        } 
        else { 
            end = mid - 1; 
        } 
    } 
    double increment = 0.1; 
    for (long long i = 0; i < precision; i++) { 
        while (ans * ans <= number) { 
            ans += increment; 
        } 
        ans = ans - increment; 
        increment = increment / 10; 
    } 
    return ans; 
} 
*/
int main()
{
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
long long h,w; cin>>h>>w;
if(h==1 || w==1)
cout<<1;
else
cout<<(h*w +1)/2;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  int max, min, N;
  cin >> N;
  int A[N];

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

  max = min = A[0];

  for (int i = 0; i < N; i++) {
    if(A[i] > max) {
      max = A[i];
    }
    if(A[i] < min) {
      min = A[i];
    }
  }

  cout << max - min;
  
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[],int b[],int m,int n,string s[],vector<string> t[],string u){
  int i,j;
  int c[100],g=-1;
  int sum;
  for(i=0;i<m;i++){
    if(b[i]&&t[i][0]==u)
      return -1;
  }
  for(i=0;i<n;i++){
    if(s[i]==u)
      break;
  }
  if(i!=n)
    g=a[i];
  for(i=0;i<m;i++){
    if(t[i][0]==u){
      memcpy(c,b,sizeof(c));
      c[i]=1;
      sum=0;
      for(j=1;j<(int)t[i].size();j++){
	int tmp;
	if((tmp=f(a,c,m,n,s,t,t[i][j]))==-1)
	  return g;
	else
	  sum+=tmp;
      }
      if(g==-1||g>sum)
	g=sum;
    }
  }
  return g;
}
int main(){
  int i,j,k;
  int a[100],b[100],m,n;
  string s[100],u;
  vector<string> t[100];
  while(cin>>n&&n){
    for(i=0;i<n;i++)
      cin>>s[i]>>a[i];
    cin>>m;
    for(i=0;i<m;i++){
      cin>>u>>k;
      t[i].clear();
      t[i].push_back(u);
      for(j=0;j<k;j++){
	cin>>u;
	t[i].push_back(u);
      }
    }
    cin>>u;
    memset(b,0,sizeof(b));
    cout<<f(a,b,m,n,s,t,u)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import itertools

def main():
    number = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    num_list = list(range(1, number+1))
    permu = list(itertools.permutations(num_list, number))
    where_p = permu.index(p)
    where_q = permu.index(q)
    print(abs(where_p-where_q))
if __name__ == '__main__':
    main()

Measured memory_bytes: 70280
import java.util.*;
public class Main
{
	static	double EPS=1e-4;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			Point p1=new Point(in.nextDouble(), in.nextDouble()); 
			Point p2=new Point(in.nextDouble(), in.nextDouble()); 
			if(p1.x==0&&p1.y==0&&p2.x==0&&p2.y==0)
				return;
			Point p3=new Point(in.nextDouble(), in.nextDouble()); 
			Point p4=new Point(in.nextDouble(), in.nextDouble()); 
			Point p5=new Point(in.nextDouble(), in.nextDouble()); 
			Point p6=new Point(in.nextDouble(), in.nextDouble());
			boolean judge=true;
			if(!lineCross(p1, p2, p3, p4))
				judge=false;
			if(!lineCross(p3, p4, p5, p6))
				judge=false;
			if(!lineCross(p5, p6, p1, p2))
				judge=false;

			if(judge)
			{
				double a1=slanting(p1, p2);
				double a2=slanting(p3, p4);
				double x1=(a1*p1.x-p1.y-a2*p3.x+p3.y)/(a1-a2);
				if(a1==-1.123)
					x1=p1.x;
				else if(a2==-1.123)
					x1=p3.x;
				double y1=(p2.y-p1.y)/(p2.x-p1.x)*(x1-p1.x)+p1.y;
				if(a1==-1.123)
					y1=(p4.y-p3.y)/(p4.x-p3.x)*(x1-p3.x)+p3.y;

				a1=slanting(p3, p4);
				a2=slanting(p5, p6);
				double x2=(a1*p3.x-p3.y-a2*p5.x+p5.y)/(a1-a2);
				if(a1==-1.123)
					x2=p3.x;
				else if(a2==-1.123)
					x2=p5.x;
				double y2=(p4.y-p3.y)/(p4.x-p3.x)*(x2-p3.x)+p3.y;
				if(a1==-1.123)
					y2=(p5.y-p6.y)/(p5.x-p6.x)*(x2-p5.x)+p5.y;

				a1=slanting(p5, p6);
				a2=slanting(p1, p2);
				double x3=(a1*p5.x-p5.y-a2*p1.x+p1.y)/(a1-a2);
				if(a1==-1.123)
					x3=p5.x;
				else if(a2==-1.123)
					x3=p1.x;
				double y3=(p6.y-p5.y)/(p6.x-p5.x)*(x3-p5.x)+p5.y;
				if(a1==-1.123)
					y3=(p2.y-p1.y)/(p2.x-p1.x)*(x3-p1.x)+p1.y;

				double a=x2-x1;
				double b=y2-y1;
				double c=x3-x1;
				double d=y3-y1;
				double S=Math.abs(a*d-b*c)/2;
				if(S<EPS)
					System.out.println("kyo");
				else if(S<100000)
					System.out.println("syo-kichi");
				else if(S<1000000)
					System.out.println("kichi");
				else if(S<1900000)
					System.out.println("chu-kichi");
				else 
					System.out.println("dai-kichi");			
			}
			else
				System.out.println("kyo");
		}
	}

	static boolean lineCross(Point p1,Point p2,Point p3,Point p4)
	{
		double jc1=(p1.x-p2.x)*(p3.y-p1.y)+(p1.y-p2.y)*(p1.x-p3.x);
		double jd1=(p1.x-p2.x)*(p4.y-p1.y)+(p1.y-p2.y)*(p1.x-p4.x);
		double jc2=(p3.x-p4.x)*(p1.y-p3.y)+(p3.y-p4.y)*(p3.x-p1.x);
		double jd2=(p3.x-p4.x)*(p2.y-p3.y)+(p3.y-p4.y)*(p3.x-p2.x);
		return jc1*jd1<=0 && jc2*jd2<=0;
	}

	static double slanting(Point p1,Point p2)
	{
		if(Math.abs(p1.x-p2.x)<EPS)
			return -1.123;
		else
			return (p1.y-p2.y)/(p1.x-p2.x);
	}
}
class Point
{
	double x;
	double y;
	Point(double x,double y)
	{
		this.x=x;
		this.y=y;
	}
}

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

string s[12];
bool checked[12][12];

void fill(int x, int y){
	checked[y][x] = true;
	if (y+1 < 12 && !checked[y+1][x] && s[y+1][x] == '1') {
		fill(x, y+1);
	}
	if (y > 0 && !checked[y-1][x] && s[y-1][x] == '1') {
		fill(x, y-1);
	}
	if (x+1 < 12 && !checked[y][x+1] && s[y][x+1] == '1') {
		fill(x+1, y);
	}
	if (x > 0 && !checked[y][x-1] && s[y][x-1] == '1') {
		fill(x-1, y);
	}
}

int main(){
	int ans;
	while(cin >> s[0]){
		if (s[0].size() == 0) {
			continue;
		}
		for (int i = 1; i < 12; i++) {
			cin >> s[i];
		}
		
		// initialize
		for (int y = 0; y < 12; y++) {
			for (int x = 0; x < 12; x++) {
				checked[y][x] = false;
			}
		}
		ans = 0;
		for (int y = 0; y < 12; y++) {
			for (int x = 0; x < 12; x++) {
				if (!checked[y][x] && s[y][x] == '1') {
					ans++;
					fill(x, y);
				}
			}
		}
		cout << ans << endl;
	} 
	return 0;
}

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

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int wwl = 0, wwm = w, hhl = 0, hhm = h;
    for (int i = 0; i < n; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1 && x >= wwl)
            wwl = x;
        if (a == 2 && wwm > x)
            wwm = x;
        if (a == 3 && y >= hhl)
            hhl = y;
        if (a == 4 && hhm > y)
            hhm = y;
    }
    if (wwl >= wwm || hhl >= hhm)
        cout << 0 << endl;

    else
    {
        int ans = (wwm - wwl) * (hhm - hhl);
        cout << ans << endl;
    }
}

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

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(){
    ll n, minn = 1e9+7, ans = 1e9+7; cin >> n;
    vector<ll> a(n); 
    rep(i,n){
        cin >> a[i];
        minn = min(a[i],minn);
    }

    
    for(auto x : a){
        if(x % minn != 0 && gcd(x,minn) == 1){
            put(1);
            return 0;
        }
    }

    ans = a[0];
    
    for(auto x : a){
        if(x == minn) continue;
        ans = min(ans, gcd(x, minn));
    }

    put(ans);
}

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

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
#define mod 1000000007
#define INF 10e10
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;
	vector<int>a(n);

	rep(i, n) {
		cin >> a[i];
	}

	vector<int>b(n + 1);//b[i]=i-1→iのコスト
	int sum = abs(a[0]);
	b[0] = abs(a[0]);
	rep1(i, n) {
		b[i] = abs(a[i-1] - a[i]);
		sum += b[i];
	}
	b[n] = abs(a[n - 1]);
	sum += b[n];
	int ans;
	//println(sum);
	rep(i, n) {
		if (i == 0) {
			ans = sum - b[0]-b[1] +abs(a[1]);
		}
		else if (i == n - 1) {
			ans = sum - b[n]-b[n-1] + abs(a[n-2]);
		}
		else {
			ans = sum - b[i] - b[i + 1] + abs(a[i - 1] - a[i+1]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4836
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 305;
int n , m , mod;
int C[N][N] , f[N][N] , g[N][N];
inline void init()
{
	for(int i = 0;i <= n;i ++) for(int j = C[i][0] = 1;j <= i;j ++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	for(int i = 0;i <= m;i ++) g[1][i] = m - i + 1 , f[1][i] = 1;
	for(int i = 2;i <= n;i ++) 
	{
		for(int j = 0;j <= m;j ++) for(int u = 1;u < i;u ++) f[i][j] = (f[i][j] + 1ll * C[i - 2][u - 1] * g[u][j + 1] % mod * f[i - u][j] % mod) % mod;
		for(int j = m;j >= 0;j --) g[i][j] = (f[i][j] + g[i][j + 1]) % mod;
	}
}
int main()
{
	n = read() + 1; m = read(); mod = read();
	init(); printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    char c;
    cin >> c;
    if (c == 'A') cout << 'T' << endl;
    else if (c == 'T') cout << 'A' << endl;
    else if (c == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(c>a+b+1){
		printf("%d",b+a+b+1);
	}
	else{
		printf("%d",b+c);
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

# length N list of list of results in chronological order for each problem
# unattempted problems are represented as empty list
list_problem_results = [[] for i in range(N)]

for _ in range(M):
    problem_index, result = input().split()
    problem_index = int(problem_index)-1
    list_problem_results[problem_index].append(result)

# get the total number of problems with at least one AC
count_completed_problems = sum(["AC" in problem for problem in list_problem_results])

# get the number of WA before getting AC on problems where there was at least one AC
overall_penalty_count = 0
for problem in list_problem_results:
    count_penalty = 0
    for result in problem:
        if result == "WA":
            count_penalty += 1
        elif result == "AC":
            overall_penalty_count += count_penalty
            break

print(count_completed_problems, overall_penalty_count)

Measured memory_bytes: 21204
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Bits
-- import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> [Int] -> Int
solve bN hs as = runST $ do
  vec <- VUM.replicate (bN+1) 0
  forM_ (zip hs as) $ \(h,a) -> do
    cur <- bit_intv vec h
    bit_add vec bN h (cur + a)
  bit_intv vec bN

-------------------------------------------------------------------------------

bit_add :: VUM.MVector s Int -> Int -> Int -> Int -> ST s ()
bit_add v n i x = sub i
  where
    sub !j | j > n     = return ()
           | otherwise = do
               VUM.modify v (max x) j
               sub (j + (j .&. (-j)))

bit_intv :: VUM.MVector s Int -> Int -> ST s Int
bit_intv v i = sub 0 i
  where
    sub !acc 0 = return acc
    sub !acc !j = do
      y <- VUM.read v j
      sub (max acc y) (j - (j .&. (-j)))


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      hs = map readBInt line2
      line3:remLines3 = remLines2
      as = map readBInt line3
  in solve bN hs as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "4\n3 1 4 2\n10 20 30 40\n"
inp2 = "1\n1\n10\n"
inp3 = "5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n"
inp4 = "9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 60
test2 = tv2 == 10
test3 = tv3 == 5000000000
test4 = tv4 == 31
alltest = test1 && test2 && test3 && test4



Measured memory_bytes: 6652
#include<iostream>
using namespace std;
#define max 10000
#define NIL -1

struct node { int p, le, ri; };

node T[max];
int n, D[max], H[max] = {};

int sibling(int u)
{
	if (T[u].p == NIL)return NIL;
	if (T[T[u].p].ri != u && T[T[u].p].ri != NIL)return T[T[u].p].ri;
	if (T[T[u].p].le != u && T[T[u].p].le != NIL)return T[T[u].p].le;
	return NIL;
}

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "sibling = " << sibling(u) << ", ";

	int degr=0;
	if(T[u].le != NIL)degr++;
	if(T[u].ri != NIL)degr++;
	cout<<"degree = "<<degr <<", ";

	cout << "depth = " << D[u] << ", ";
	cout << "height = " << H[u] << ", ";

	if (T[u].p == NIL)cout << "root";
	else if (T[u].le == NIL && T[u].ri == NIL)cout << "leaf";
	else cout << "internal node";
	
	cout<<endl;
}


void rec(int u, int  p)
{
	if (u == NIL)return;
	D[u] = p;
	if (T[u].ri != NIL)rec(T[u].ri, p+1);
	if (T[u].le != NIL)rec(T[u].le, p + 1);
}

int high(int u)
{
	int h1 = 0, h2 = 0;
	if (T[u].le != NIL)
		h1 = high(T[u].le)+1;
	if (T[u].ri != NIL)
		h2 = high(T[u].ri) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int main()
{
	int i, d, v, l, r=0;
	cin >> n;
	for (i = 0; i < n; i++)  T[i].p = NIL;

	for (i = 0; i < n; i++)
	{
		cin >> v >> l >>d;
		T[v].le = l;
		T[v].ri = d;
		if (l != NIL)T[l].p = v;
		if (d != NIL)T[d].p = v;
	}

	for (i = 0; i < n; i++) if (T[i].p == NIL) r = i;

	rec(r, 0);
	high(r);

	for (i = 0; i < n; i++)  print(i);
	return 0;
}



Measured memory_bytes: 3124
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/union_find.hpp
#ifndef UNION_FIND_HPP
#define UNION_FIND_HPP


/*
usage:

tools::union_find<std::int_fast64_t> uf(10);
uf.unite(1, 3);
uf.is_same(1, 3);
*/

namespace tools {
  template <typename T>
  class union_find {
  private:
    std::vector<T> parents;
    std::vector<T> sizes;
    T component_count;

  public:
    union_find(const T n) :
      parents(n),
      sizes(n, 1),
      component_count(n) {
      for (T i = 0; i < n; ++i) {
        parents[i] = i;
      }
    }

    T root(const T x) {
      return this->parents[x] == x ? x : (this->parents[x] = this->root(this->parents[x]));
    }

    bool is_same(const T x, const T y) {
      return this->root(x) == this->root(y);
    }

    void unite(T x, T y) {
      x = this->root(x);
      y = this->root(y);
      if (x == y) return;

      if (this->sizes[x] < this->sizes[y]) std::swap(x, y);
      this->parents[y] = x;
      this->sizes[x] += this->sizes[y];
      --this->component_count;
    }

    T size() const {
      return this->component_count;
    }

    T size(const T x) {
      return this->sizes[this->root(x)];
    }
  };
}

#endif

// main.cpp

int main() {
  i64 N, M, K;
  std::cin >> N >> M >> K;
  std::vector<i64> A(M), B(M), C(K), D(K);
  for (i64 i = 0; i < M; ++i) {
    std::cin >> A[i] >> B[i];
    --A[i];
    --B[i];
  }
  for (i64 i = 0; i < K; ++i) {
    std::cin >> C[i] >> D[i];
    --C[i];
    --D[i];
  }

  tools::union_find<i64> uf(N);
  for (i64 i = 0; i < M; ++i) {
    uf.unite(A[i], B[i]);
  }

  std::vector<i64> term1(N, 0);
  for (i64 i = 0; i < M; ++i) {
    ++term1[A[i]];
    ++term1[B[i]];
  }

  std::vector<i64> term2(N, 0);
  for (i64 i = 0; i < K; ++i) {
    if (uf.is_same(C[i], D[i])) {
      ++term2[C[i]];
      ++term2[D[i]];
    }
  }

  {
    std::string delimiter = "";
    for (i64 i = 0; i < N; ++i) {
      std::cout << delimiter << uf.size(i) - 1 - term1[i] - term2[i];
      delimiter = " ";
    }
    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 7040
a,b = map(int, input().split())
l = [str(_) for _ in range(a,b+1)]
x = 0
for i in range(b-a+1):
    y = int(len(l[i])/2)
    if l[i][:y] == l[i][-1:-(y+1):-1]:
        x += 1
print(x)


Measured memory_bytes: 8728
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct P{
  double x;
  double y;
};

void k(int n, struct P a, struct P b){
  struct P s, t, u;
  double th = M_PI * 60.0/180.0;
  
  if(n == 0) {
      return ;
  }

  s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  k(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  k(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  k(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  k(n-1, t, b);

  return ;
}

int main(){
  struct P a, b;
  int n;

  scanf("%d", &n);
  if(n<0 || n>6){
  exit(1);
  }


  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;


  printf("%.8f %.8f\n", a.x, a.y);
  k(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



  




Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main(){
	// std::vector<int> v(6);
	int t1, t2;
	std::vector<int> a(4, 0);
	for(int i=0; i<3; i++){
		std::cin >> t1 >> t2;
		a[t1-1]++;
		a[t2-1]++;
	}
	for(int i=0; i<4; i++){
		if(a[i]>=3){
			std::cout << "NO" << std::endl;
			return 0;
		}
	}

	std::cout << "YES" << std::endl;
	return 0;
}


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

int main() {
	long n,m,i,j,ans,cur;
	cin >> n;
	vector<string> s(n);
	for(i=0; i<n; i++){
		cin >> s[i];
	}
	
	ans=0;
	for(m=0; m<n; m++){
		cur=0;
		for(i=0; i<n; i++){
			for(j=0; j<n; j++){
				if(s[(m+i)%n][j]!=s[(m+j)%n][i]){
					cur=1;
				}
			}
		}
		if(cur==0){
			ans+=n;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


int main(){
  int a,b;
  cin >> a >> b;
  int amin = 0;
  int amax = 0;
  int bmin = 0;
  int bmax = 0;
  if(a%2 == 0){
    amin = a*25/2;
    amax = (a+1)*25/2;
  }
  else{
    amin = a*25/2+1;
    amax = (a+1)*25/2-1;
  }
  bmin = b*10;
  bmax = (b+1)*10-1;
  //cout << amin << amax << bmin << bmax << endl;
  if(amin <= bmin && bmin <= amax){
	cout << bmin << endl;
  }
  else if(bmin <= amin && amin <= bmax){
    cout << amin << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n, m=0, a, arry[100001]={0};

    scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d", &a);
		arry[a-1]++;
		arry[a  ]++;
		arry[a+1]++;
		if( a+1 >= m ){ m = a+1; }
	}

  	int max=0;
	for(int i=0; i<m; i++){
		if( arry[i] >= max ){ max = arry[i]; }
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

char b;

int main(){
    cin >> b;
    if(b == 'A'){
        cout << 'T';
    }else if(b == 'C'){
        cout << 'G';
    }else if(b == 'G'){
        cout << 'C';
    } else{
        cout << 'A';
    }



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

struct Station {
	double x, y, z, r;
};
const int MAX_N = 100;
typedef pair<double, int> Node;
int n;
Station stations[MAX_N + 1];
bool used[MAX_N];

double getdist(int A, int B) {
	const Station& a = stations[A];
	const Station& b = stations[B];
	double dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
	double d = sqrt(dx * dx + dy * dy + dz * dz);
	return max(d - (a.r + b.r), 0.);
}

double prim() {
	fill(used, used + n, false);
	double result = 0;
	priority_queue<Node, vector<Node>, greater<Node> > que;
	que.push(make_pair(0., 0));
	while (!que.empty()) {
		Node current = que.top();
		que.pop();
		double dist = current.first;
		int pos = current.second;
		if (used[pos]) continue;
		used[pos] = true;
		result += dist;
		for (int i = 0; i < n; i++) {
			if (i == pos) continue;
			que.push(make_pair(getdist(pos, i), i));
		}
	}
	return result;
}

int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> stations[i].x >> stations[i].y >> stations[i].z >> stations[i].r;
		}
		printf("%.3lf\n", prim());
	}
	return 0;
}

Measured memory_bytes: 1636
import java.util.Scanner;

public class Main{

		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String str1 = sc.next();
	        String str2 = sc.next();
	        
	        if(str2.length() == str1.length()+1) {
	        String sub = str2.substring(0,str1.length());
	        if(sub.equals(str1)) {
	        	System.out.println("Yes"); 
	        }
	        else {
	        	System.out.println("No"); 
	        }
	        }
            
            

          
	        
            //System.out.println(res); 
	        
	}
}

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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll K;
  cin >> K;
  string S;
  cin >> S;
  
  if(S.size() <= K){
    cout << S << endl;
    return 0;
  }
  for(int i=0;i<K;i++){
    cout << S[i];
  }
  
    
  
  cout << "..." << endl;
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(usize);
    let (s, ) = input!(String);

    let mut current: char = ' ';
    let mut len = n;

    for c in s.chars() {
        if current == c {
            len -= 1;
        }
        current = c;
    }

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

fn main() {
    solve();
}


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

int main()
{
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(u == s){
        a--;
    }
    else if(u == t){
        b--;
    }

    cout << a << " " << b;
    return 0
    ;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y,w;
    char hoge,fuga;
    cin>>hoge>>fuga;
    if(hoge=='H'&&fuga=='H') cout<<'H'<<endl;
    if(hoge=='H'&&fuga=='D') cout<<'D'<<endl;
    if(hoge=='D'&&fuga=='H') cout<<'D'<<endl;
    if(hoge=='D'&&fuga=='D') cout<<'H'<<endl;

    return 0;
}


Measured memory_bytes: 3540
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nt = readints;
    int n = nt[0], t = nt[1];

    int ans = int.max;
    for (int i = 0; i < n; i++) {
        auto ct = readints;
        if (ct[1] <= t) {
            ans = min(ans, ct[0]);
        }
    }

    if (ans == int.max)
        writeln("TLE");
    else
        writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data[i];
	}
	long long int dp[21][110] = {0};
	dp[data[0]][0] = 1;
	for (int i = 1; i < n-1; i++) {
		for (int j = 0; j < 21; j++) {
			if (j+data[i] <= 20) {
				dp[j+data[i]][i] += dp[j][i-1];
			}
			if (j-data[i] >= 0) {
				dp[j-data[i]][i] += dp[j][i-1];
			}
		}
	}
	/*for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < 21; j++) {
			cout << dp[j][i] << ' ';
		}
		cout << endl;
	}*/
	cout << dp[data[n-1]][n-2] << endl;
	return 0;
}

Measured memory_bytes: 1216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] d = sc.nextIntArray(n);
    Arrays.sort(d);
    System.out.println(d[n / 2] - d[n / 2 - 1]);
  }
}

Measured memory_bytes: 35892
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int x1=2*n;
	int x2=4*n;
	if(m%2!=0){
		cout<<"No\n";
	}
	else{
		if(m>=x1&&m<=x2){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
	}
}

Measured memory_bytes: 3604
n,a,b = map(int, input().split())

l = max(a,b)
s = min(a,b)

if (l-s)%2 == 0:
  print((l-s)//2)
else:
  t = s - 1
  b = n - l
  pre = min(t,b)
  ans = pre + 1 + (l-s-1)//2
  print(ans)
  

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size(), ans = 0;
    for (int i = 1; i < n; i++) {
        if (i % 2 == 1) {
            if (s[0] == s[i]) {
                ans++;
            }
        } else {
            if (s[0] != s[i]) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
int main(){
	scanf ("%d%d%d",&a,&b,&c);
	if ((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&a!=b)) printf ("Yes\n");
	else printf ("No\n");
	return 0;
}

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

using namespace std;
int n;


int main() {
  cin >> n;
  vector<int> e(n);
  for(int i = 0; i < n; ++i) {
    cin >> e[i];
  }
int res = 0;
  sort(e.begin(), e.end());

  for(int i = n -1; i >= 0; --i) {
    for(int j = i -1; j >= 0; --j) {
      auto loc = lower_bound(e.begin(), e.end(), e[i] - e[j] + 1);
      int d = distance(loc, e.end());
      int a = n - j;
      if(d > a)
      res += d - a;
    }
  }
  cout << res << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
    
		// 文字列の入力
		String[] s = sc.next().split("");
        int ans = 0;
        int count = 0;
    
        for(int i = 0; i < n; i++) {
          if (s[i].equals("I")) {
            count++;
          } else {
            if (count > ans) {
              ans = count;
            }
            count--;
          }
          if (i == n - 1) {
            if (count > ans) {
              ans = count;
            }
          }
        }
        
		// 出力
		System.out.println(ans);
	}
}

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

int main(){
  string S;
  cin >> S;
  int A,Z;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'){
      A=i;
      break;
    }
  }
  for(int i=S.size()-1;i>-1;i--){
    if(S.at(i)=='Z'){
      Z=i;
      break;
    }
  }
  cout << Z-A+1 << endl;
}
      

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    using ll = long long;
     
    #define INF (1LL << 31 - 1)
    #define MOD int(1e9+7)
    #define repi(i,j,n) for(int i = (j); i < (n); ++i)
    #define rep(i,n) repi(i,0,n)
    #define fi first
    #define se second
     
    inline void init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
     
    int n, dp[301][301], a[301][301];
    bool used[301][301];
     
    int main() {
        init();
     
        cin >> n;
        rep(i,n){
            rep(j,n) {
                cin >> a[i][j];
                dp[i][j] = a[i][j];
            }
        }
     
     
        rep(k,n) {
            rep(i,n) {
                rep(j,n) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
     
        rep(i,n) {
            rep(j,n) {
                if (a[i][j] != dp[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
     
        ll sum = 0;
        bool flag;
     
        rep(i,n) {
            repi(j,i+1,n) {
                flag = false;
     
                rep(k,n) {
                    if (i != k and j != k and dp[i][j] == dp[i][k] + dp[k][j]) {
                        flag = true;
                    }
                }
     
                if (!flag) sum += dp[i][j];
            }
        }
     
        cout << sum << endl;
     
        return 0;
    }

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200005
using namespace std;
typedef long long ll;
int n,m,nxt[N];
ll l,r,ans[26],w[26],f[105][26],len[105];
char s[N];
void print(){
	for(int i=0;i<25;i++) printf("%lld ",ans[i]);
	printf("%lld",ans[25]);
}
void solve(int k,ll pos,int op){
	if(pos>len[k]||pos<1) return;
	if(k<=1){
		int x=k==0?m:n;
		if(!op) for(int i=1;i<=pos;i++) ans[s[i]-'a']++;
		else for(int i=pos;i<=x;i++) ans[s[i]-'a']++;
		return;
	}
	if(!op){
		if(len[k-1]<=pos) {for(int i=0;i<26;i++) ans[i]+=f[k-1][i];solve(k-2,pos-len[k-1],0);}
		else solve(k-1,pos,0);
	}else{
		if(len[k-1]>=pos-1){for(int i=0;i<26;i++) ans[i]+=f[k-2][i];solve(k-1,pos,1);}
		else solve(k-2,pos-len[k-1],1);
	}
}
void get(int k,ll l,ll r){
	if(l>len[k-1]){get(k-2,l-len[k-1],r-len[k-1]);return;}
	if(r<=len[k-1]){get(k-1,l,r);return;}
	solve(k-1,l,1);
	solve(k-2,r-len[k-1],0);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1)>>1;
	for(int i=2;i<=n;i++){
		nxt[i]=nxt[i-1];
		while(s[nxt[i]+1]!=s[i]&&nxt[i]) nxt[i]=nxt[nxt[i]];
		if(s[nxt[i]+1]==s[i]) nxt[i]++;
	}
	m=n-nxt[n];
	for(int i=1;i<=m;i++) w[s[i]-'a']++;
	scanf("%lld%lld",&l,&r);
	if(n%m==0||r<=n){
		if(l<=n){
			for(int i=l;i<=n&&i<=r;i++) ans[s[i]-'a']++;
			if(r<=n) {print();return 0;}
			l=n+1;
		}
		l-=n;r-=n;
		ll L=(l%m==0)?m:l%m,R=(r%m==0)?m:r%m;
		if((l-1)/m==(r-1)/m){
			for(int i=L;i<=R;i++) ans[s[i]-'a']++;
			print();
			return 0;
		}
		for(int i=L;i<=m;i++,l++) ans[s[i]-'a']++;
		for(int i=1;i<=R;i++,r--) ans[s[i]-'a']++;
		for(int i=0;i<26;i++) ans[i]+=(r-l+1)/m*w[i];
		print();
		return 0;
	}
	for(int i=1;i<=m;i++) f[0][s[i]-'a']++;
	for(int i=1;i<=n;i++) f[1][s[i]-'a']++;
	len[0]=m;len[1]=n;
	for(int i=2;i<=100;i++){
		for(int p=0;p<26;p++) f[i][p]=f[i-1][p]+f[i-2][p];
		len[i]=len[i-1]+len[i-2];
	}
	int x;
	for(int i=0;i<=100;i++){
		if(len[i]<r&&len[i+1]>=r){
			x=i;break;
		}
	}
	get(x+1,l,r);
	print();
	return 0;
}

Measured memory_bytes: 896
#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

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

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

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

  ll N;
  cin >> N;
  V<ll> as(N);

  ll sum = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    sum += a;
    as[i] = a;
  }

  ll ii = -1;
  ll s = 0;

  rep(i, N) {
    s += as[i];
    if (sum % 2 == 0 && s == sum / 2) {
      cout << 0 << endl;
      return 0;
    }

    if (s > sum / 2) {
      ii = i;
      break;
    }
  }

  ll l = s - as[ii];
  ll r = sum - s;
  ll res = min(sum - 2 * l, sum - 2 * r);

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

vector<vector<long long int>> dp;// 0: white, 1: black
vector<vector<int>> graph;

int DFS(int v, int parent_v, int color){
    if(dp[v][color] != -1) return dp[v][color];

    dp[v][color] = 1;
    for(int child_v : graph[v]){
        if(child_v != parent_v){
            if(color == 0) dp[v][color] *= DFS(child_v, v, 0) + DFS(child_v, v, 1);
            if(color == 1) dp[v][color] *= DFS(child_v, v, 0);
            dp[v][color] %= MOD;
        }
    }
    return dp[v][color];// if no child_v, dp[v][color] = 1
}

int main(){
    int n;
    cin >> n;
    dp.resize(n, vector<long long int>(2, -1));
    graph.resize(n);

    for(int i=0; i<n-1; i++){
        int x, y;
        cin >> x >> y;
        x -= 1;
        y -= 1;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    long long int ans = DFS(0, -1, 0) + DFS(0, -1, 1);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20864
#include <stdio.h>
#include <string.h>
 
int main(){
	int n;
	scanf("%d", &n);
	
	char str[n+1];
	scanf("%s", &str);
	
	if (n%2!=0){
		printf("No\n");
	}
	else {
		int s=1;
		for (int i=0; i<n/2; i++){
			if (str[i]!=str[i+n/2]){
				s=0;
			}
		}
			if(s){
				printf("Yes\n");
			}
			else{
				printf("No\n");
			}
	}
	return 0;
}

Measured memory_bytes: 1660
from collections import defaultdict as dd

def check(L):
    strings = {}
    for i in range(N - L):
        s= S[i:i+L+1]
        if s in strings:
            start, end = strings[s]
            #print('exists', s, i, start, end)
            if i > end:
                #print('True')
                return True
        else:
            strings[s] = i, i + L
    
    #print('False')
    return False


N = int(raw_input())
S= raw_input()
lo = 0
hi = N/2 + 1
for i in range(13):
    mid= (lo +hi)//2
    has_two = check(mid)
    #print('checking ', mid)
    if has_two:
        lo = mid
    else:
        hi = mid
print(hi)


Measured memory_bytes: 9908