akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

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

    vector<int> A(N), B(N), C(N);
    long long count_A = 0, count_C = 0, count = 0;

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

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

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

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    // Bを固定する
    for(int i = 0; i < N; i++) {
        count_A = 0;
        count_C = 0;

        // AからBより小さい要素の数を数える
        auto iter1 = lower_bound(A.begin(), A.end(), B[i]);
        count_A += iter1 - A.begin();

        // CからBより大きい要素の数を数える
        auto iter2 = upper_bound(C.begin(), C.end(), B[i]);
        count_C += C.end() - iter2;

        // 上の2つをかけてそれぞれのBについて何通り組めるか数える
        count += count_A * count_C;
    }

    cout << count << endl;
	return 0;
}

Measured memory_bytes: 4548
#include"iostream"
using namespace std;
int main(void) {
	int a, b, tmp,res = 0;
	cin >> a >> b;

	for (int i = 0; i < b; i++) {
		cin >> tmp;
		res += tmp;
	}
	if (res >= a) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int lcm(int x, int y){
	int g = gcd(x,y);
	return x/g*y;
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = (sum%MOD*i%MOD)%MOD;
    }
    return sum;
}

int main(){
	ll a,b; cin >> a >> b;
	if (a*2 <= b){
		cout << (b-2*a)/4 + a << endl;
	}else{
		cout << b/2 << endl;
	}
}

Measured memory_bytes: 256
n, m= map(int, input().split())

flag_ac = [0]*n
cnt_wa = [0]*n
cnt_penalty = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        cnt_wa[int(p)-1] += 1
    elif s == "AC" and flag_ac[int(p)-1] == 0:
        flag_ac[int(p)-1] = 1
        cnt_penalty += cnt_wa[int(p)-1]
        
print(sum(flag_ac), cnt_penalty)

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a + b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		sc.close();
	}
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1)/2 + m * (m - 1)/2 << endl;
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;

	cin >> s;
	long long ans = 0;

	int st = -1, c = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (st == -1) {
			if (s[i] == 'C') {
				st = 0;
			}
		}
		else if (st == 0) {
			if (s[i]=='B') {
				st = 1;
				c++;
			}
			else if (s[i] == 'C') {
				st = 0;
				c = 0;
			}
			else {
				st = -1;
				c = 0;
			}
		}
		else {
			if (s[i]=='A') {
				ans += c;
				st = 1;
			}
			else if (s[i]=='C') {
				st = 0;
			}
			else {
				st = -1;
				c = 0;
			}
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int k, n; cin >> k >> n;
	vector<int> a(n);
	for( auto &t : a ) cin >> t;
	int lm = -1;
	for( int i = 0; i < n-1; ++i ){
		lm = max(lm, a[i+1]-a[i]);
	}
	lm = max(lm, k-a[n-1]+a[0]);
	cout << k-lm << endl;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;

  rep(i, S.size()){
    // 出力する文字が'A'からどれだけ進ませるか
    int gap = S[i] - 'A' + N;
    // Zの次はAにするために26で割ったあまりを利用する
    cout << (char) ('A' + (gap % 26));
  }
  cout << endl;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    
    if ( a < b ){
    
    cout << "a" << " " << "<" << " " << "b" << endl;
    
    }
    
    else if ( a > b ){
    
    cout << "a" << " " << ">" << " " <<  "b" << endl;
    
    }
    
    else if ( a == b ){
        
    cout << "a" << " " << "==" << " " << "b" << endl;
    
    }
    
}


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

void solve(){
    
}

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

    int a=0,b=0,c=0,d=0;
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        if(s=="AC")
            a++;
        if(s=="TLE")
            b++;
        if(s=="WA")
            c++;
        if(s=="RE")
            d++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<c<<"\n";
    cout<<"TLE x "<<b<<"\n";
    cout<<"RE x "<<d<<"\n";

      
    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    double n,m;
    cin>>n>>m;
    double ans=0;
    double cnt=1;
    double rui=pow(2,m);
    double memo=rui;
    while(true){
        ans+=((double)1900*m+(double)100*(n-m))*cnt*memo;
        cnt++;
        memo=1-rui;
        memo*=rui;
        if(((double)1900*m+(double)100*(n-m))*cnt*memo<0.0000000000000001) break;
    }
    // cout<<ans<<endl;
    cout<<(int)ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 998244353;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
char s[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%s", s+1 );
}

void work ()
{
	// main work

	n = strlen ( s+1 );

	int l = 1, r = n, ans = 0;
	while ( l < r ) {
		if ( s[l] == 'x' && s[r] != 'x' ) ++ans, ++l;
		else if ( s[l] != 'x' && s[r] == 'x' ) ++ans, --r;
		else if ( s[l] == s[r] ) ++l, --r;
		else {
			cout << -1 << endl;
			return;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	char s[100+3+2];
	int k;

	while(scanf("%d\n%100[a-z]", &k, s)==2)
	{
		int l=strlen(s);

		if(l>k)
		{
			sprintf(s+k, "...");
		}
		printf("%s\n", s);
	}
	return 0;
}


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

// const int di[] = {-1,0,1,0};
// const int dj[] = {0,-1,0,1};

pair<int, int> dhw[] = { // <h, w>
        { 1, 0},
{ 0,-1},        { 0, 1},
        {-1, 0},
{ 2,-2},{ 2,-1},{ 2, 0},{ 2, 1},{ 2, 2},
{ 1,-2},{ 1,-1},        { 1, 1},{ 1, 2},
{ 0,-2},                        { 0, 2},
{-1,-2},{-1,-1},        {-1, 1},{-1, 2},
{-2,-2},{-2,-1},{-2, 0},{-2, 1},{-2, 2}
};

int main() {
  int h, w; cin>>h>>w;
  int si, sj; cin>>si>>sj;
  int ti, tj; cin>>ti>>tj; --si; --sj; --ti; --tj;
  vector<string> s(h); rep(i,h) cin>>s[i];

  const int INF = 1e9;
  vector<vector<int>> dist(h,vector<int>(w,INF));
  dist[si][sj] = 0;
  deque<P> q;
  q.emplace_back(si,sj);

  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    int d = dist[i][j];
    q.pop_front();
    // if (dist[i][j] != d) continue;

    rep(v,4) {
      // int ni = i+di[v], nj = j+dj[v];
      int ni = i+dhw[v].first, nj = j+dhw[v].second;
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] <= d) continue;
      dist[ni][nj] = d;
      q.emplace_front(ni,nj);
    }

    // for (int ei = -2; ei <= 2; ++ei) {
    //   for (int ej = -2; ej <= 2; ++ej) {
		for(int v=4; v<24; ++v){
			// int ni = i+ei, nj = j+ej;
      int ni = i+dhw[v].first, nj = j+dhw[v].second;
			if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
			if (s[ni][nj] == '#') continue;
			if (dist[ni][nj] <= d+1) continue;
			dist[ni][nj] = d+1;
			q.emplace_back(ni,nj);
      // }
    }

  }

  int ans = dist[ti][tj];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}


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

int main() {
  int H, W; cin >> H >> W;
  vector<vector<string>> S(H,vector<string>(W));
  rep(i, 0, H) rep(j, 0, W) cin >> S[i][j];
  rep(i, 0, H) rep(j, 0, W) {
    if(S[i][j] == "snuke") {
      cout << char('A' + j)  << (i + 1) << endl;
    }
  }
  return 0;
}


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


public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		final long c = sc.nextLong();
		
		int count = 0;
		for(long pos = a; pos <= b; pos++){
			if(c % pos == 0){
				count++;
			}
		}
		
		System.out.println(count);
		
	}
	
}

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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)

#define LL long long
#define mp make_pair
#define pb push_back

LL n;

pair<vector<int>, vector<int> > solve(LL d, int deg) {
	if (d == 0) {
		vector<int> x, y;
		x.clear(); y.clear();
		return mp(x, y);
	}

	if (d == 1) {
		vector<int> x, y;
		x.clear(); y.clear();
		x.pb(deg); y.pb(deg);
		return mp(x, y);
	}
	
	if (d % 2) {
	
		pair<vector<int>, vector<int> > ret = solve(d / 2, deg + 1);
		
		ret.first.pb(deg); ret.second.pb(deg);
		return ret;	
	} else {
		pair<vector<int>, vector<int> > ret = solve(d - 1, deg + 1);
		ret.first.pb(deg); ret.second.insert(ret.second.begin(), deg); 	
		
		return ret;
	}
}

int main(){
	cin >> n;
	
	pair<vector<int>, vector<int> > V = solve(n, 1);
	
	int sum = V.first.size() + V.second.size();
	
	printf("%d\n", sum);
	
	FOR(i, 0, V.first.size()) printf("%d ", V.first[i]);
	
	FOR(i, 0, V.second.size()) printf("%d%c", V.second[i], (i == V.second.size() - 1 ? '\n': ' '));
}

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

using namespace std;

int n, m;
int a[51], b[51];
bool g[51][51];
bool visited[51];


bool dfs(int x) {
    visited[x] = true;
    auto all_visited = true;
    for (int i = 1; i <= n; ++i) {
        if (!visited[i]) {
            all_visited = false;
            break;
        }
    }
    if (all_visited) return true;

    bool res = false;
    for (int i = 1; i <= n; ++i) {
        if (g[x][i] && !visited[i]) {
            res = dfs(i);
        }
    }
    return res;
}


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

    for (int i = 1; i <= 50; ++i) {
        visited[i] = false;
        for (int j = 1; j <= 50; ++j) {
            g[i][j] = false;
        }
    }

    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < m; ++i) {
        g[a[i]][b[i]] = false;
        g[b[i]][a[i]] = false;
        dfs(1);
        auto bridge = false;
        for (int j = 1; j <= n; j++) {
            if (!visited[j]) bridge = true;
        }
        if (bridge) ans++;

        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
        for (int j = 1; j <= 50; ++j) {
            visited[j] = false;
        }
    }

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

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

int main() {
	int N, X;
	cin >> N >> X;
	
	int msum = 0,
		mmin = (1 << 29);
	for (int i = 0; i < N; i++) {
		int m;
		cin >> m;
		
		msum += m;
		mmin = min(mmin, m);
	}
	
	int ans = N;
	X -= msum;
	
	ans += X / mmin;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int H,W; cin>>H>>W;
    i64 ans=min(H,W);
    if (H%3==0 || W%3==0) {
        cout<<0<<endl;
        return 0;
    }
    i64 S[3];
    REP(i,3) {
        S[0] = H*(W/3+i);
        S[1] = H/2*(W-W/3-i);
        S[2] = (H+1)/2*(W-W/3-i);
        sort(S,S+3);
        ans = min(S[2]-S[0],ans);
    }
    swap(W,H);
    REP(i,3) {
        S[0] = H*(W/3+i);
        S[1] = H/2*(W-W/3-i);
        S[2] = (H+1)/2*(W-W/3-i);
        sort(S,S+3);
        ans = min(S[2]-S[0],ans);
    }
    cout<<ans<<endl;
}


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

int f(const vector<pair<long long, long long>> &ab, size_t i)
{
    long long l = 0;
    long long r = 1e9 + 5;
    while (r - l > 1)
    {
        long long c = (l + r) / 2;
        size_t idx = (lower_bound(ab.begin(), ab.end(), make_pair(c, 0ll)) - ab.begin());
        if (idx > i)
        {
            r = c;
        }
        else
        {
            l = c;
        }
    }
    return l;
}

int g(const vector<pair<long long, long long>> &ba, size_t i)
{
    long long l = 0;
    long long r = 1e9 + 5;
    while (r - l > 1)
    {
        long long c = (l + r) / 2;
        size_t idx = (upper_bound(ba.begin(), ba.end(), make_pair(c, 0ll)) - ba.begin());
        if (idx >= i)
        {
            r = c;
        }
        else
        {
            l = c;
        }
    }
    return l;
}

int main()
{
    size_t N;
    cin >> N;

    vector<long long> A(N);
    vector<long long> B(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if (N % 2 == 0)
    {
        long long l2 = A[N / 2] + A[N / 2 - 1];
        long long r2 = B[N / 2] + B[N / 2 - 1];
        cout << r2 - l2 + 1 << endl;
    }
    else
    {
        long long l = A[N / 2];
        long long r = B[N / 2];
        cout << r - l + 1 << endl;
    }
}


Measured memory_bytes: 6404
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((H-h)*(W-w));
    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

struct MaxSegmentTree{
  int size_;
  int length_;
  vector<ll> data_;
  umap<int, int> par_info_;
  umap<int, pair<int, int>> chil_info_;
  
  MaxSegmentTree(int size)
    :size_(CalcSize(size)), length_((size_+1)/2), data_(size_, 0)
  { Init(); }
  
  int CalcSize(int size)
  { int n = 1; while(n < size)n *= 2; return 2 * n - 1; }
  void Init(){
    for(int i = (size_/2)-1; i >= 0; --i){
      int l = i*2 + 1, r = i*2 + 2;
      par_info_[l] = i;
      par_info_[r] = i;
      chil_info_[i] = {l,r};
    }
  }
  
  void Set(int idx, ll x){
    int pos = (size_/2)+idx;
    data_[pos] = x;
    while(pos != 0){
      pos = par_info_[pos];
      ll l, r;tie(l, r) = chil_info_[pos];
      data_[pos] = data_[l]|data_[r];
    }
  }
  
  ll GetMax(int target_l, int target_r, int idx = 0,
	    int range_l = 0, int range_r = -1){
    if(range_r == -1){
      range_r = length_;
      if(target_l > target_r || target_l < 0 || target_r > length_){
	cerr << "SegmentTree GetMin target index error\n";
	cerr << "target_l:" << target_l << " target_r:" << target_r << endl;
	return -(1e+18);
      }
    }
    
    if(target_r <= range_l || target_l >= range_r) return 0;
    if(target_r >= range_r && target_l <= range_l) return data_[idx];
    
    int l, r; tie(l, r) = chil_info_[idx];
    int mid = (range_l + range_r)/2;
    
    ll val_l = GetMax(target_l, target_r, l, range_l, mid);
    ll val_r = GetMax(target_l, target_r, r, mid, range_r);
    
    return val_l|val_r;
  }  
};

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int q; cin >> q;
  MaxSegmentTree seg(n);
  for(int i = 0; i < n; ++i){
    seg.Set(i,1<<(s[i]-'a'));
  }
  // cerr << endl;
  // for(int i = 0; i < seg.size_; ++i){
  //   cerr << i << ' ' << bitset<32>(seg.data_[i]) << endl;
  // }
  
  for(int i = 0; i < q; ++i){
    int a,b; cin >> a >> b;
    if(a == 1){
      char c; cin >> c;
      seg.Set(b-1,1<<(c-'a'));
    }
    else{      
      int c; cin >> c;
      b--;
      // debug(seg.GetMax(b,c));
      cout << __builtin_popcount(seg.GetMax(b, c)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 78320
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    string rs[]={"dream","dreamer","erase","eraser"};
    rep(i,4)reverse(rs[i].begin(),rs[i].end());
    int p=0;
    bool same=false;
    while(p<s.size()){
        same=false;
        rep(i,4){
            string cmp=rs[i];
            int len=cmp.length();
            string tmp=s.substr(p,len);
            if(tmp==cmp){
                p+=len;
                same=true;
                break;
            }
        }
        if(same)continue;
        else {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}




Measured memory_bytes: 512
using System;
using System.Linq;

namespace _1_3_D {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine();
            var array = input.Split(' ').Select(x => int.Parse(x)).ToArray();
            var count = Enumerable.Range(array[0], array[1] - array[0] + 1).Where(x => array[2] % x == 0).Count();
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 18416
function main(){
	var n = scan();
	var a = Array(n);
	rep(n, function(i){
		a[i] = scan();
	});
	a = a.concat(a);

	var dp = Array(n + 1);
	rep(n + 1, function(i){
		dp[i] = Array(n);
		rep(n, function(j){
			if(i == 0){
				dp[i][j] = 0;
			}
			else if(i == 1){
				dp[i][j] = a[j];
			}
			else{
				if(a[j + 1] < a[j + i - 1]){
					dp[i][j] = dp[i - 2][(j + 1) % n] + a[j];
				}
				else{
					dp[i][j] = dp[i - 2][(j + 2) % n] + a[j];
				}
				if(a[j] < a[j + i - 2]){
					dp[i][j] = Math.max(dp[i - 2][j] + a[i + j - 1], dp[i][j]);
				}
				else{
					dp[i][j] = Math.max(dp[i - 2][(j + 1) % n] + a[i + j - 1], dp[i][j]);
				}
			}
		});
	});
	print(Math.max.apply(null, dp[n]));
}

function rep(n, func){
	for(var i = 0; i < n; ++i){
		func(i);
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input = '';
var input_index = 0;

function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}

function print(val){
	console.log(val);
}

process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 57624
import numpy as np
N = int(raw_input())
p = np.array(map(int, raw_input().split()))

q = np.zeros(N, dtype='int')
for i in range(N):
    q[p[i]-1] = i
a = np.zeros(N, dtype='int')
b = np.zeros(N, dtype='int')

ai = 0
bi = 0
for i in range(N):
    if ai + bi < q[i]:
        ai = q[i] - bi
    elif ai + bi > q[i]:
        bi = q[i] - ai
    else:
        pass
    a[i] = ai
    b[i] = bi
a += np.arange(1, N+1, dtype='int')
b -= np.arange(1, N+1, dtype='int')
b -= b.min()
b += 1

a_list = [str(x) for x in a]
b_list = [str(x) for x in b]
print ' '.join(a_list)
print ' '.join(b_list)

Measured memory_bytes: 13884
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
l[0] = a[0]

for i in range(1,n):
    l[i] = l[i-1] + a[i]
sum = sum(a)
ans = 10**10+1
for i in range(len(l)-1):
    x = l[i]
    y = sum - l[i]
    tmp = abs(x-y)
    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 100312
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long 
ll a,b,na;
ll sm,xr,ad; ll re;
int n;
int main(){
    scanf("%d",&n);
    scanf("%lld%lld",&a,&b);
    sm=a+b;
    for (int i=3;i<=n;++i){
        scanf("%lld",&re); xr^=re;
    }
    ad=sm-xr;
    if (ad<0||ad&1){
        cout<<"-1";
        exit(0);
    }
    ad>>=1; na=ad;
    ll ta,tx; bool flag=true;
    for (int j=60;j>=0;--j){
        ta=(ad>>j)&(1ll); tx=(xr>>j)&(1ll); 
        if (!ta&&tx){
            if (na+(1ll<<j)<=a) na+=1ll<<j;
        }
        else if (ta&&tx){
            flag=false; break;
        }
    }
    if (!flag||na<=0||na>a) cout<<"-1";
    else cout<<a-na;
    return 0;
}

Measured memory_bytes: 3712
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = [0]
for i in range(n):
    sum_a.append(sum_a[i] + a[i])
sum_b = [0]
for i in range(m):
    sum_b.append(sum_b[i] + b[i])

ans = 0
j = m
for i in range(n + 1):
    if sum_a[i] > k:
        break
    while sum_b[j] > k - sum_a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 133644
N = int(input())
word_count = {}
for i in range(N):
    word = input()
    if word not in word_count:
        word_count[word] = 1
    else:
        word_count[word] += 1

counts = [val for (key, val) in word_count.items()]
max_count = max(counts)
words = sorted([key for (key, val) in word_count.items() if val == max_count])
for word in words:
    print(word)


Measured memory_bytes: 34652
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > a(n); std::cin >> a;
  lint inf = std::numeric_limits< lint >::max();
  lint ans = inf;
  rep(med, -100, 101) {
    lint now = 0;
    for (int x : a) {
      now += (x-med) * (x-med);
    }
    // debug(med, now);
    cmn(ans, now);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int C[N], S[N], F[N];
    for (int i = 1; i < N; i++)
        cin >> C[i] >> S[i] >> F[i];

    for (int i = 1; i < N; i++) {
        int t = S[i] + C[i];
        for (int j = i+1; j < N; j++) {
            t += max(0, S[j]-t);
            while (t%F[j] != 0) t++;
            t += C[j];
        }

        cout << t << "\n";
    }

    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int h, w, n, sr, sc;
    string s, t;
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    //縦
    string s_ud(n, ' '), t_ud(n, ' ');
    for (int i = 0; i < n; i++) {
        s_ud[i] = s[i] == 'L' || s[i] == 'R' ? ' ' : s[i];
        t_ud[i] = t[i] == 'L' || t[i] == 'R' ? ' ' : t[i];
    }
    int top = 0, bottom = h + 1;
    for (int i = n - 1; i >= 0; i--) {
        if (t_ud[i] == 'U') {
            bottom = min(bottom + 1, h + 1);
        } else if (t_ud[i] == 'D') {
            top = max(top - 1, 0);
        }
        if (s_ud[i] == 'U') {
            top++;
        } else if (s_ud[i] == 'D') {
            bottom--;
        }
        if (top + 1 == bottom) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (sr <= top || sr >= bottom) {
        cout << "NO" << endl;
        return 0;
    }
    //横
    string s_lr(n, ' '), t_lr(n, ' ');
    for (int i = 0; i < n; i++) {
        s_lr[i] = s[i] == 'U' || s[i] == 'D' ? ' ' : s[i];
        t_lr[i] = t[i] == 'U' || t[i] == 'D' ? ' ' : t[i];
    }
    int left = 0, right = w + 1;
    for (int i = n - 1; i >= 0; i--) {
        if (t_lr[i] == 'L') {
            right = min(right + 1, w + 1);
        } else if (t_lr[i] == 'R') {
            left = max(left - 1, 0);
        }
        if (s_lr[i] == 'L') {
            left++;
        } else if (s_lr[i] == 'R') {
            right--;
        }
        if (left + 1 == right) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (sc <= left || sc >= right) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define debug(ccc)  cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e5+100;
const ll inf = 1e18;

ll power(ll a,ll n){
    if(n==0){
        return 1;
    }
    ll b = power(a,n/2);
    b = b*b%mod;
    if(n%2) b= b*a%mod;
    return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}



struct BIT{
    int sum[N];
    int n;
    
    void init(int _n){
        n = _n;
        memset(sum,0,sizeof(sum));
    }
    
    void add(int pos,int x){
        while(pos<=n){
            sum[pos]=(sum[pos]+x);
            pos += pos&-pos;
        }
    }
    
    ll get(int pos){
        ll ret = 0;
        while(pos>0){
            ret+=sum[pos];
            pos -= pos&-pos;
        }
        return ret;
    }
} bit;

vector <pii> A;

int cmp(pii a,pii b){
    return (a.Y-a.X)<(b.Y-b.X);
}

int main(){
 //     freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
    int n,m; scanf("%d%d",&n,&m);
    REP(i,n){
        int l,r; scanf("%d%d",&l,&r);
        r++;
        A.pb(mp(l,r));
    }
    bit.init(m+10);
    sort(all(A),cmp);
    int ans = n,in=0;
    printf("%d\n",ans);
    REPP(i,2,m+1){
        int pans = 0;
        while(in<A.size() && A[in].Y-A[in].X<i){
            bit.add(A[in].X,1);
            bit.add(A[in].Y,-1);in++;ans--;
        }
        pans=ans;
        for(int j=0;j<=m;j+=i) pans+= bit.get(j);
        printf("%d\n",pans);
    }

    return 0;
}


Measured memory_bytes: 4592
A, B, K = map(int, input().split())

def sosa(a,b,i):
    if i % 2 == 1:
        if a % 2 == 0:
            return([a // 2, b + a//2])
        else:
            return([(a-1) // 2, b + (a-1) // 2])
    else:
        if b % 2 == 0:
            return([a + b // 2, b //2])
        else:
            return([a+(b-1) //2,(b-1)//2])

for i in range(1,K+1):
    newA, newB = sosa(A,B,i)
    A, B = newA, newB

print('%d %d' % (A, B))

Measured memory_bytes: 3064
h=maximum.map head.filter ((==1).last)
i=minimum.map head.filter ((==2).last)
j=maximum.map (!!1).filter ((==3).last)
k=minimum.map (!!1).filter ((==4).last)
f l [a,b,c]=do
 let q=if not (null (filter ((==1).last) l)) then h l else 0
     w=if not (null (filter ((==2).last) l)) then i l else a
     e=if not (null (filter ((==3).last) l)) then j l else 0
     r=if not (null (filter ((==4).last) l)) then k l else b
 let z=a*b-(q*b+(a-w)*b+e*a+(b-r)*a-(b-r+e)*(a-w+q))
 if z<0||e>=r||q>=w then 0 else z
main=do
 l<-map(map read).map words.lines<$>getContents
 print$f (tail l) (head l)

Measured memory_bytes: 1020
# ABC079 C
abcd = input()
ABCD = []
for i in range(len(abcd)):
    ABCD.append(abcd[i])

# print(ABCD)

# 全通り検査する
for i in range(2**3):
    op = []

    # 各ビットのチェック
    for j in range(3):
        # 最下位ビットが１なら"+"
        if ((i >> j) & 1):
            op.append("+")
        else:
            op.append("-")
    # 全パターン網羅できていること確認
    # print(op)

    # ans = 0
    # for k in range(len(op)):
    #     if op[k] == "+":
    #         ans = ABCD[k]+ABCD[k+1]
    #         ABCD[k+1] = ans
    #         print(ans)
    #     else:
    #         ans = ABCD[k]-ABCD[k+1]
    #         ABCD[k+1] = ans
    # if ans == 7:
    #     print(op)

    # 数値の配列と演算子の配列の結合
    tmp = [None] * (len(ABCD)+len(op))
    # 最初から最後まで1個飛ばしで代入
    tmp[::2] = ABCD
    tmp[1::2] = op
    # print(tmp) # 色の配列完成
    
    # 計算
    ans = ""
    for i in tmp:
        ans += i
    # evalは文字列をpythonのコードとして実行してくれる関数，つまり文字列で表現された数式を計算してくれる
    if eval(ans) == 7:
        print(ans + "=7")
        exit()



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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    vector<i64> x, y;
    pair<i64, int> maxi = make_pair(0, 0), mini = make_pair(1000000001, 0);
    priority_queue<pair<i64, int>, vector<pair<i64, int>>, greater<pair<i64, int>>> blue;
    for(int i=0;i<n;++i){
        i64 xi, yi;
        cin >> xi >> yi;
        x.push_back(xi);
        y.push_back(yi);
        maxi = max({maxi, make_pair(xi, i), make_pair(yi, i)});
        mini = min({mini, make_pair(xi, i), make_pair(yi, i)});
        blue.push(make_pair(min(xi, yi), i));
    }

    pair<i64, int> rmin = maxi, bmax = mini;
    for(int i=0;i<n;++i){
        rmin = min(rmin, max(make_pair(x[i], i), make_pair(y[i], i)));
        bmax = max(bmax, min(make_pair(x[i], i), make_pair(y[i], i)));
    }
    i64 ans = (maxi.first - rmin.first) * (bmax.first - mini.first);

    if(maxi.second != mini.second){
        for(int i=0;i<n;++i){
            auto p = blue.top(); blue.pop();
            auto new_blue = make_pair(max(x[p.second], y[p.second]), p.second);
            blue.push(new_blue);
            bmax = max(bmax, new_blue);
            ans = min(ans, (maxi.first - mini.first) * (bmax.first - blue.top().first));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8532
#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass #sortされていない
n, m = map(int,input().split())
divs = list(reversed(sorted(divisor(m))))
for i in divs:
    if m//i >= n:
        print(i)
        break

Measured memory_bytes: 3060
import sys
mod = 7 + 10 ** 9

def solve():
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    DP = [[0] * W for _ in range(H + 1)]
    pattern = [1, 2, 3, 5, 8, 13, 21]
    DP[0][0] = 1
    for h in range(H):
        for w in range(W):
            if w == 0:
                DP[h+1][w] += (DP[h][w] * pattern[max(0, W - 2)]) % mod
                if W > 1: DP[h+1][w] += (DP[h][w+1] * pattern[max(0, W - 3)]) % mod
            elif w == W - 1:
                DP[h+1][w] += (DP[h][w] * pattern[max(0, W - 2)]) % mod
                if W > 1: DP[h+1][w] += (DP[h][w-1] * pattern[max(0, W - 3)]) % mod
            else:
                DP[h+1][w] += (DP[h][w]  * pattern[max(0, w - 1)] * pattern[max(0, W - w - 2)]) % mod
                DP[h+1][w] += (DP[h][w+1] * pattern[max(0, w - 1)] * pattern[max(0, W - w - 3)]) % mod
                DP[h+1][w] += (DP[h][w-1] * pattern[max(0, w - 2)] * pattern[max(0, W - w - 2)]) % mod
            DP[h+1][w] %= mod
    print(DP[H][K - 1])

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    vector<int>a(26,-1),b(26,-1);
    rep(i,n){
        int x=s[i]-'a',y=t[i]-'a';
        if(a[x]!=-1||b[y]!=-1){
            if(a[x]!=y||b[y]!=x){
                cout<<"No"<<endl;
                return 0;
            }
        }
        a[x]=y;
        b[y]=x;
    }
    cout<<"Yes"<<endl;
}


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

const int INF = 1e+9;

int main()
{
  int n, m;
  int a[1000], b[1000], c[1000];
  int dist[100][100];

  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j) dist[i][j] = 0;
      else dist[i][j] = INF;
    }
  }

  for(int i = 0; i < m; i++){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }

  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }

  int ans = m;
  for(int i = 0; i < m; i++){
    bool f = false;
    for(int j = 0; j < n; j++){
      if(dist[j][a[i]]+c[i] == dist[j][b[i]]) f = true;
    }
    if(f) ans--;
  }

  cout << ans << endl;

  return 0;
}

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

int main(void)
{
	string a,b;
	//a.resize(101);
	//b.resize(101);
	
	cin>>a>>b;
	for(int i=a.size(),j=i;i>=1;i--)
	{
		string tmp1=a.substr(j-1);
		string tmp2=a.substr(0,j-1);
		a=tmp1+tmp2;
		if(a == b)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100000
int partition(int,int);
int A[N], n;

int main(){
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}
int partition(int p,int r){
  int i,j,k,c;
  k=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=k){
      i++;
      c=A[i];
      A[i]=A[j];
      A[j]=c;
    }
  }
  c=A[i+1];
  A[i+1]=A[r];
  A[r]=c;
  return i+1;
}

Measured memory_bytes: 992
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

using Graph = vector<vector<int> >;

int main() {
    // 頂点数と辺数
    int N; cin >> N;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N; ++i) {
        int g, k; cin >> g >> k;
        rep(j,k){
          int a;
          cin >> a;
          a--;
          G[i].push_back(a);
        }
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << v + 1 << " " << dist[v] << endl;
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll i1 = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll i2 = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        ans += i1 * (n - i2);
    }
    cout << ans << endl;
    return 0;
}

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

int h, w;
int x[26];
char a;
bool ans = 1;
int flag2 = 0, flag1 = 0;
int tmp;

int main(void) {
  scanf("%d %d",&h, &w);
  for(int i=0;i<26;i++)	x[i] = 0;
  for(int i=0;i<h*w;i++){
    cin>>a;
    x[a-97]++;
  }

  for(int i=0;i<26;i++){
    tmp = x[i] % 4;
    if(tmp >= 2) flag2++;
    if(tmp == 1 || tmp == 3) flag1++;
  }

  if( flag1 != (h*w)%2 ) ans = 0;
  if( flag2 > ( (h%2) * w + (w%2) * h )/2 - ((h*w)%2))	ans = 0;

  if(ans) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
using namespace std;
template<typename T>inline void read(T &x){
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&k^'-')k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
const int MAXN=1e6+7;
static int n,a;
inline void init()
{
    read(n);read(a);
}
inline void solve()
{
    puts(n%500>a?"No":"Yes");
}
int main(void){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())

def length(x, y, u, v):
    return ((x - u)**2 + (y - v)**2)**0.5

XY = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0

for x, y in XY:
    for u, v in XY:
        ans += length(x, y, u, v)

print(ans / N)

Measured memory_bytes: 3188