akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);

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

  int mid = a.size() / 2;
  rep(i, n) {
    int offset = 0;
    if (a.size() % 2 == 0) {
      if (i % 2 == 0) {
        offset = ((i+1) / 2);
      } else {
        offset = - ((i+1) / 2);
      }
    } else {
      if (i % 2 == 0) {
        offset = - ((i+1) / 2);
      } else {
        offset = ((i+1) / 2);
      }
    }
    if (i == 0) offset = 0;
    b[mid + offset] = a[i];
  }

  rep(i, n) {
    cout << b[i] << " ";
  }
  cout << endl;

  return 0;
}


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

const long mod = 1000000007;

long fact[1000001];

void fact_table()
{
  for (long i = 1; i <= 1000000; i++)
    fact[i] = fact[i - 1] * i % mod;
}

long pow(long a, long b)
{
  if (b == 0)
    return 1;
  if (b % 2 == 0)
  {
    long half = pow(a, b / 2);
    return half * half % mod;
  }
  else
  {
    return a * pow(a, b - 1) % mod;
  }
}

long inv(long n)
{
  return pow(n, mod - 2);
}

long comb(long n, long r)
{
  if (n - r < r)
    return comb(n, n - r);
  return fact[n] * inv(fact[n - r] * fact[r] % mod) % mod;
}

int main()
{
  long N, M;
  cin >> N >> M;
  map<long, long> prime;
  for (long i = 2; i * i <= M; i++)
  {
    while (M % i == 0)
    {
      prime[i]++;
      M /= i;
    }
  }
  if (M != 1)
    prime[M]++;
  fact[0] = 1;
  fact_table();
  long ans = 1;
  for (auto p : prime)
  {
    ans *= comb(p.second + N - 1, N - 1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#define int long long

using namespace std;

int L, R, d;

signed main()
{
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
n = int(input())
for i in range(1,n+1):
 x = i
 if x%3==0:
  print(f" {i}",end="")
 else:
  while x>0:
   if x%10==3:
    print(f" {i}",end="")
    break
   else:
    x = x//10
print()



Measured memory_bytes: 5884
#include<stdio.h>
int main()
{
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    int i;
    int max = 0, min = 2000000000;
    for (i = 0; i < 3; i++)
    {
        if (max < a[i])
            max = a[i];
        if (min > a[i])
            min = a[i];
    }
    printf("%d\n", max - min);
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int n, m;

int st[N], ed[N];

vector < int > g[N];

int main(){
    fastScan(n); fastScan(m);
    for(int i = 1; i <= m; i++){
        int u, v;
        fastScan(u); fastScan(v);
        if(u > v) swap(u, v);
        g[u].pb(v);
        st[u]++; ed[v]++;
    }
    int ans = 0;
    stack < int > X;
    for(int i = 1; i <= n; i++){
        if(ed[i] > 0){
            ans++;
            while(X.size() > 0){
                int v = X.top();
                ed[v]--;
                X.pop();
            }
        }
        if(g[i].size() > 0){
            for(int j = 0; j < g[i].size(); j++){
                X.push(g[i][j]);
            }
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 6656
m, d = map(int, input().split())
cnt = 0
for mm in range(1, m + 1):
    for dd in range(1, d + 1):
        d1 = dd % 10
        d10 = dd // 10
        if d1 * d10 == mm and d1 >= 2 and d10 >= 2:
            cnt += 1
print(cnt)


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> str(h);

  for(int i = 0; i < h; i++) {
    cin >> str.at(i);
  }

  for(int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for(int j = 0; j < h; j++) {
    cout << "#" << str.at(j) << "#" << endl;
  }

  for(int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

namespace A_Still_TBD
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split('/');
            var year = int.Parse(input[0]);
            var month = int.Parse(input[1]);
            var day = int.Parse(input[2]);
            var a = new DateTime(year, month, day);
            var b = new DateTime(2019, 4, 30);
            if (a <= b)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}

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

int main(){
  int d;
  int c[27];
  int s[400][27];
  int t[400];
  static int last[27];//最後の開催日

  cin >> d;
  rep(i, 26)cin >> c[i+1];
  rep(i, d){
    rep(j, 26){
      cin >> s[i+1][j+1];
    }
  }

  //各日トップになる問題を計算しておく
  int top[400];
  for(int i=1;i<=d;i++){
    int mx = -INF;
    int mxi;
    for(int j=1;j<=26;j++){
      // int tmp=s[i][j]-5*c[j];
      int tmp=s[i][j]-c[j];
      if(tmp>mx){
        mx = tmp;
        mxi = j;
      }
    }
    top[i]=mxi;
  }
  
  rep(i, d)cout << top[i+1] << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

const int SIZE = 100;
int ans[SIZE][SIZE];

int main() {
  int white, black; cin>>white>>black;
  int A = max(white, black);
  int B = min(white, black);
  string mark =	black >	white ?	".#" : "#.";
  int h = 0, w = 0;
  for(int a = 0; a < A; a++) {
    int x = (a % 24)*4 + 2;
    int y = (a / 24)*4 + 2;
    //    cout << y << ":" << x << endl;                                                
    for(int xx = -1; xx <= 1; xx++)
      for(int yy = -1; yy <= 1; yy++) {
        ans[y+yy][x+xx] = 1;
        //      cout << y+yy << " " << x+ xx << endl;                                   
        w = max(w, x+xx);
        h = max(h, y+yy);
      }
  }
  //  cout << "B=" << B << endl;                                                        
  for(int b = 0; b < B-1; b++) {
    int x = (b % 24)*4 + 2;
    int y = (b / 24)*4 + 2;
    ans[y][x] = 0;
    //    cout << y << "," << x << endl;                                                
  }
  h += 2; w += 2;
  cout << h << " " << w	<< endl;
  REP(y,h) {
    REP(x,w) {
      cout << mark[ans[y][x]];
    }
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n];

  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll ans1=0,ans2=0;
  ll s=0;
  for(int i=0;i<n;i++){
    s+=a[i];
    if(i%2==0&&s<=0){
      ans1+=1-s;
      s=1ll;
    }else if(i%2==1&&s>=0){
      ans1+=s+1;
      s=-1ll;
    }
  }
  s=0;
  for(int i=0;i<n;i++){
    s+=a[i];
    if(i%2==1&&s<=0){
      ans2+=1-s;
      s=1ll;
    }else if(i%2==0&&s>=0){
      ans2+=s+1;
      s=-1ll;
    }
  }
  cout<<min(ans1,ans2)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  cin >> n;
  int d[n]; rep(i,n) cin >> d[i];
  cin >> m;
  int t[m]; rep(i,m) cin >> t[i];
  sort(d,d+n); sort(t,t+m);
  int i = 0, j = 0;
  while(i < n && j < m){
    if(d[i] == t[j]) j++;
    i++;
  }
  if(j == m){
    cout << "YES\n";
  }else{
    cout << "NO\n";
  }
}

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

struct BINNODE {
	int key;
	BINNODE *parent;
	BINNODE *left;
	BINNODE *right;

	BINNODE (int k) {
		key=k;
		parent=nullptr;
		left=nullptr;
		right=nullptr;
	}
};

void preorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	printf(" %d",root->key);
	preorderwalk(root->left);
	preorderwalk(root->right);
	return;
}

void inorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	inorderwalk(root->left);
	printf(" %d",root->key);
	inorderwalk(root->right);
	return;
}

bool findnode(int v, BINNODE* root) {
	if(root == nullptr) return false;
	if(root->key ==v ) return true;
	return (v< root->key)?findnode(v,root->left) : findnode(v,root->right);
}

int main() {
	int m,v;
	int i;
	string cmd;
	BINNODE* root=nullptr;
	BINNODE* x;
	BINNODE* y;
	BINNODE* z;
	cin >> m;
	for(i=0; i<m; ++i) {
		cin >> cmd;
		if(cmd=="find") {
			cin >> v;
			printf(findnode(v,root) ? "yes\n" : "no\n");
		} else if(cmd=="insert") {
			cin >> v;
			z=new BINNODE(v);
			y=nullptr;
			x=root;
			while(x!=nullptr) {
				y=x;
				if (z->key < x->key) {
					x=x->left;
				} else {
					x=x->right;
				}
			}
			z->parent = y;

			if(y==nullptr) {
				root=z;
			} else if(z->key < y->key) {
				y->left = z;
			} else {
				y->right = z;
			}
		} else {
			inorderwalk(root);
			printf("\n");
			preorderwalk(root);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 22012
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N;
    vi A(2 * 100000);
    cin >> N;
    REP(i, 1, N) {
        int n;
        cin >> n;
        A[n - 1]++;
    }
    rep(i, N) cout << A[i] << endl;
}


Measured memory_bytes: 3868
def solve(n, a):
    ans = 1
    b = [a[i+1] - a[i] for i in range(n-1)]
    c = list(filter(lambda _: _ != 0, b))
    i = 0
    m = len(c)
    while i < m-1:
        if c[i] * c[i+1] < 0:
            ans += 1
            i += 1
        i += 1
    return ans

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

int main()
{
    int64_t H, W, ans;
    cin >> H >> W;
    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        if (H % 2 == 1 && W % 2 == 1)
        {
            cout << H * W / 2 + 1 << endl;
        }
        else
        {
            cout << H * W / 2 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define BPhuong "vsteps"
    #define maxn 100004
    #define maxm
    #define bit(x, i) ((x>>i)&1)
    #define fid(i,a,b) for(int i = a; i>=b; i--)
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define pii pair<int, int>
    #define ll long long
    #define f first
    #define se second
    #define pb push_back
    using namespace std;
    int n, a[maxn], k, b[maxn];
    void nhap(){
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);cout.tie(NULL);
        srand(time(NULL));
        cin >> n >> k;
        fi(i, 1, n) cin >> a[i];
    }
    void xuli(){
        fi(i, 0, k){
            fi(j, 1, n){
                if(b[i] == 0 && a[j]+i <= k){
                    b[i+a[j]] = 1;
                }
            }
        }
        if(b[k]) cout << "First" << '\n';
        else cout << "Second" << '\n';
    }
    int main(){
        nhap();
        xuli();
    }


Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    int s = 0; {
        int m = n;
        while(m > 0) {
            s += m % 10;
            m /= 10;
        }
    }
    if(n % s == 0) yes();
    else no();
    return 0;
}


Measured memory_bytes: 256
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  var a = o.l();
  var s = [0];
  for(var i = 0; i < n;i++)s[i+1] = s[i] + a[i];
  var w = [];
  for(var l = 0; l < n; l++){
    for(var r = l+1; r <= n; r++){
      var t = s[r]-s[l];
      w.push(t);
    }
  }
  var ans = 0;
  for(i = 39; i > 30; i--){
    var t = [], z = Math.pow(2,i);
    for(var j = 0; j < w.length; j++){
      if((w[j] / z | 0) & 1)t.push(w[j]);
    }
    if(t.length >= k){ans += z; w = t;}
  }
  for(;i >= 0; i--){
    var t = [], z = 1 << i;
    for(j = 0; j < w.length; j++){
      if((z & w[j]) !== 0)t.push(w[j]);
    }
    if(t.length >= k){ans += z; w = t;}
  }
  return ans;
}

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}
int n,q;
vector<int> g[210000];
vector<int> ans(210000,0);

void dfs(int v, int pre){
  //cout << v << " " << pre << endl;
  rep(i,g[v].size()){
    if(g[v][i] == pre)continue;
    ans[g[v][i]] += ans[v];
    dfs(g[v][i], v);
  }
}

signed main(){
  cin>>n>>q;
  rep(i,n-1){
    int a,b;cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    //g[b].push_back(a);
  }
  rep(i,q){
    int p,x;cin>>p>>x;
    p--;ans[p] += x;
  }
  dfs(0,-1);
  rep(i,n){
    cout << ans[i] << (i == n-1 ? "\n" : " ");
  }
}


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

int main() {
  vector<int> s(100005,0),a(100005,0);
  vector<bool> isPrime(100005,true);
  int q,l,r;
  cin>>q;
  isPrime[0]=isPrime[1]=false;

  for(int i=2;i*i<=100000;i++) if(isPrime[i]) for(int j=2*i;j<=100000;j+=i) isPrime[j]=false;
  for(int i=0;i<=100000;i++) a[i]=isPrime[i]&&isPrime[(i+1)/2];
  for(int i=0;i<100000;i++) s[i+1]=s[i]+a[i];

  for(int i=0;i<q;i++) {
    cin>>l>>r;
    cout<<s[r+1]-s[l]<<endl;
  }
}


Measured memory_bytes: 3836
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int i , cn=0;
    for(i=0; i<s.size(); i++){
        cn+= (s[i]-'0');
    }
    if(cn%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 200005;

int n, a[MAXN];

int main(){
	int t;
	scanf("%d %d",&n,&t);
	t  = 1;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	int dap = 0, minv = 2e9;
	for(int i=1; i<=n; i++){
		dap = max(dap, a[i] - minv);
		minv = min(minv, a[i]);
	}
	minv = 2e9;
	int cnt = 0;
	for(int i=1; i<=n; i++){
		if(a[i] - minv == dap) cnt++;
		minv = min(minv, a[i]);
	}
	cout << max(1, cnt - t + 1);
}


Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
struct node{
    int to,nxt;
}sq[1001000];
int all=0,head[10010];
int n,m,na,nb,nc,fa[1001000],dis1[1001000],dis2[1001000],dis3[1001000],pre1[1001000],
    pre2[1001000],pre3[1001000],a[1001000],b[1001000],c[1001000];
bool vis[1001000];
struct hnode{
    int u,dis;
};
bool operator <(hnode p,hnode q) {return p.dis>q.dis;}
priority_queue<hnode> q;

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*10+(ch-'0');ch=getchar();}
    return x*f;
}

int find(int x) {if (fa[x]==x) return fa[x];fa[x]=find(fa[x]);return fa[x];}

void Merge(int x,int y)
{
    int fx=find(x),fy=find(y);
    if (fx!=fy) fa[fy]=fx;
}

void add(int u,int v)
{
    //cout << u << " " << v << endl;
    all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void dij(int st,int *dis,int *pre)
{
    rep(i,1,n) {pre[i]=i;dis[i]=maxd;}
    memset(vis,0,sizeof(vis));
    dis[st]=0;q.push((hnode){st,0});
    while (!q.empty())
    {
        int u=q.top().u;q.pop();
        if (vis[u]) continue;vis[u]=1;
        int i;
        for (i=head[u];i;i=sq[i].nxt)
        {
            int v=sq[i].to;
            if (dis[v]>dis[u]+1)
            {
                dis[v]=dis[u]+1;
                if (!vis[v]) q.push((hnode){v,dis[v]});
            }
            if (dis[v]==dis[u]+1) pre[v]=min(pre[v],pre[u]);
        }
    }
}

int main()
{
    n=read();na=read();nb=read();nc=read();
    rep(i,1,na) a[i]=read();
    rep(i,1,nb) b[i]=read();
    rep(i,1,nc) c[i]=read();
    sort(a+1,a+1+na);sort(b+1,b+1+nb);sort(c+1,c+1+nc);
    rep(i,1,n) fa[i]=i;
    rep(i,2,na) Merge(a[1],a[i]);
    rep(i,2,nb) Merge(b[1],b[i]);
    rep(i,2,nc) Merge(c[1],c[i]);
    //rep(i,1,n) cout << fa[i] << " ";cout << endl;
    m=read();
    rep(i,1,m)
    {
        int u=read(),v=read(),fx=find(u),fy=find(v);
        if (fx!=fy) {add(fx,fy);add(fy,fx);}
    }
    dij(a[1],dis1,pre1);
    dij(b[1],dis2,pre2);
    dij(c[1],dis3,pre3);
    int ans1=maxd,ans2=maxd;
    //rep(i,1,n) cout << dis1[i] << " ";cout << endl;
    rep(i,1,n)
    {
        if (find(i)!=i) continue;
        if (dis1[i]+dis2[i]+dis3[i]<ans1)
        {
            ans1=dis1[i]+dis2[i]+dis3[i];
            ans2=maxd;
        }
        if (dis1[i]+dis2[i]+dis3[i]==ans1)
        {
            ans2=min(min(ans2,pre1[i]),min(pre2[i],pre3[i]));
        }
    }
    printf("%d %d\n",ans1,ans2);
    return 0;
}
/*
8 1 2 2 
5
4 6
3 8
7
1 2
2 3
3 4
5 6
6 7
7 8
2 6
 */


Measured memory_bytes: 11992
/**
 *    author:  math2do
 *    created: 31.05.2020 18:14:21
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(const char &ch) {
  return "'" + string(1, ch) + "'";
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  vector <int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  } 
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n & 1) {
    int m = n / 2;
    cout << b[m] - a[m] + 1 << endl;
  } else {
    int r = n / 2;
    int l = r - 1;
    int low = a[l] + a[r];
    int high = b[l] + b[r];
    cout << high - low + 1 << endl;
  } 
  return 0;
}


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

vector<int> Zalgo(const string &S){
    int N = (int) S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while(i < N){
        while(i + j < N && S[j] == S[i+ j]) ++j;
        res[i] = j;
        if(j == 0) {++i; continue;}
        int k = 1;
        while(i + k < N && k + res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    int res = 0;
    rep(i, N){
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        rep(j, T.size()){
            int l = min(lcp[j], j);
            res = max(l, res);
        }
    }

    cout << res << endl;
}

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

int main() {
	char com[20];
	priority_queue<int> PQ;
	while (1) {
		cin >> com;
		if (com[0] == 'i') {
			int key;
			cin >> key;
			PQ.push(key);
		}
		else if (com[1] == 'x') {
			cout << PQ.top() << endl;
			PQ.pop();
		}
		else if (com[0] == 'e') {
			break;
		}
	}
}


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

const long mod = 1000000007;
long n;
vector<int> g[200000];
vector<int> degs[200000];

long mpow(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return b * mpow(b, e - 1) % mod;
  long t = mpow(b, e / 2);
  return t * t % mod;
}

long inv(long n) {
  return mpow(n, mod - 2);
}

int rec(int from, int prev) {
  int sum = 1;
  for (int to : g[from]) {
    if (to == prev) continue;
    int deg = rec(to, from);
    if (deg > 0) degs[from].push_back(deg);
    sum += deg;
  }

  int rem = n - sum;
  if (rem > 0) {
    degs[from].push_back(rem);
  }
  return sum;
}

int main() {
  cin >> n;
  for (int j = 1; j < n; ++j) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  rec(0, -1);

  long sum = 0;
  for (int i = 0; i < n; ++i) {
    long prob = 1;
    prob = (prob + mod - inv(mpow(2, n - 1))) % mod;
    for (int deg : degs[i]) {
      prob = (
        prob + mod -
        (1 + mod - inv(mpow(2, deg))) % mod
        * inv(mpow(2, n - 1 - deg)) % mod
      ) % mod;
    }
    sum = (sum + prob * 500000004) % mod;
  }
  cout << sum << endl;
}

Measured memory_bytes: 35456
import sys
input = sys.stdin.readline

n, k = map(int,input().split())

kodomo = [i for i in range(1,n+1)]

DS = []
okashi = []

for i in range(k):
    DS.append(int(input()))
    okashi.append(list(map(int,input().split())))

for i in range(k):
    for j in range(DS[i]):
        try:
            kodomo.remove(okashi[i][j])
        except ValueError:
            continue

print(len(kodomo))

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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  const double pi = acos(-1.0);
  double x;

  while(cin >> x, x != 0.0){
    int a = 0;
    while(++a){
      int b1 =  ceil(a * (pi - x));
      int b2 = floor(a * (pi + x));

      int b = (abs(pi - b1 * 1.0 / a) < abs(pi - b2 * 1.0 / a)) ? b1 : b2;

      if(abs(pi - b * 1.0 / a) < x + 1e-10){
	cout << b << "/" << a << endl;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int ctoi(const char);
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 0; i < b; i++)
        if(a * i % b == c){
            cout << "YES";
            return 0;
        }
    cout << "NO";
    return 0;
}

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

int main(){

  int x;
  cin >> x;
  if(x == 0) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 100000000
#define limit 1000005
#define minval -100000000000000000
#define maxval 1000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
int lpf[limit];
void LPF()
{
     rep(i, limit)
         lpf[i] = 0;
     loop(p, 2, limit, 1)
         if(lpf[p] == 0)//prime
             loop(j,p,limit,p)
                 lpf[j] = p;
}
void input()
{
    LPF();

    int n;
    cin >> n;
    vi a(n);
    rep(i,n)
        cin >> a[i];
    sort(all(a));

    vvi g(n);
    vi fre(limit, 0);
    rep(i,n)
    {
        int x = a[i];
        while(x > 1)
        {
            int d = lpf[x];
            while(x%d == 0)
                x = x/d;
            g[i].pb(d);
            fre[d]++;
        }
    }

    bool ok = 1;
    rep(i,n)
    {
        rep(j, (int)g[i].size())
            fre[g[i][j]]--;
        
        rep(j, (int)g[i].size())
        {
            if(fre[g[i][j]] != 0)
            {
                ok = 0;
                break;
            }
        }
        if(!ok)
            break;
    }

    if(ok)
    {
        cout << "pairwise coprime";
        return;
    }

    int gg = a[0];
    rep(i,n)
        gg = __gcd(gg, a[i]);
    if(gg == 1)
    {
        cout << "setwise coprime";
        return;
    }
    cout << "not coprime";
}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}


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

typedef long long ll;
const int maxn=2e5+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,a[maxn];
vector<int> G[maxn];

multiset<int> M[maxn];
int dp[maxn],ans[maxn];

struct segtree
{
    int seg[maxn*4];

    void modify(int now,int l,int r,int x,int v)
    {
        if (l==r)
        {
            seg[now]=v;
            return;
        }
        int m=(l+r)>>1;
        if (x<=m) modify(now*2,l,m,x,v);
        else modify(now*2+1,m+1,r,x,v);
        seg[now]=max(seg[now*2],seg[now*2+1]);
    }

    int query(int now,int l,int r,int ql,int qr)
    {
        if (qr==0) return 0;
        if (r<ql||l>qr) return -inf;
        else if (l>=ql&&r<=qr) return seg[now];
        int m=(l+r)>>1;
        return max(query(now*2,l,m,ql,qr),query(now*2+1,m+1,r,ql,qr));
    }
}tree;

void dfs(int now,int p)
{
    dp[now]=tree.query(1,1,n,1,a[now]-1)+1;
    M[a[now]].insert(dp[now]);
    if ((*(--M[a[now]].end()))==dp[now]) tree.modify(1,1,n,a[now],dp[now]);

    for (int i:G[now])
        if (i!=p) dfs(i,now);

    int mx=(*(--M[a[now]].end()));
    M[a[now]].erase(M[a[now]].find(dp[now]));
    if (sz(M[a[now]])==0||(*(--M[a[now]].end()))!=mx)
    {
        if (sz(M[a[now]])==0) tree.modify(1,1,n,a[now],0);
        else tree.modify(1,1,n,a[now],(*(--M[a[now]].end())));
    }
}

multiset<int> MM;

void dfs2(int now,int p)
{
    MM.insert(dp[now]);
    ans[now]=(*(--MM.end()));
    for (int i:G[now])
        if (i!=p) dfs2(i,now);
    MM.erase(MM.find(dp[now]));
}

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    vector<int> values;
    for (int i=1;i<=n;i++) values.pb(a[i]);
    sort(all(values));
    values.resize(unique(all(values))-values.begin());
    for (int i=1;i<=n;i++) a[i]=lower_bound(all(values),a[i])-values.begin()+1;

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

    dfs(1,-1);
    dfs2(1,-1);
    for (int i=1;i<=n;i++) cout<<ans[i]<<endl;
}



Measured memory_bytes: 58408
import java.util.Scanner;

public class Main {
	
	static int sum = 0; //print
	
	void search(char[][] board, int i) {
		out: for(int j = 0; j < board[i].length; j++) {//1??????????????¢?´¢
			if(board[i][j] == board[0][0]) {
				for(int k = j + 1; k < board[i].length; k++) {//2??????????????¢?´¢
					if(board[i][k] == board[0][1]) {
						int interval = k - j;//1???????????¨2??????????????????
						int cnt = 2;//?????????????????¢?´¢???????????????
						for(int m = k + interval; m < board[i].length; m = m + interval) {//3???????????\????????¢?´¢
							if(board[i][m] == board[0][cnt]) {
								cnt = cnt + 1;
								if(cnt == board[0].length) {
									sum = sum + 1;
									break out;
								}
							} else {
								break;
							}
						}
					}
				}
			}				
		}
	}

	
	
	void doIt() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] board = new char[n + 1][];
		board[0] = sc.next().toCharArray();
		for(int i = 1; i <= n; i++) {
			board[i] = sc.next().toCharArray();
			new Main().search(board, i);
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 27288
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;

void input(){
    cin >> s;
}

vector<string> StringSplit(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    /*数字の間に+が入るか入らないかをbitで管理*/
    ll sum = 0;
    for(int bit = 0; bit < (1 << (s.size() - 1)); bit++){
        int l = 0; // 左端
        ll tmp = 0;
        int r;
        for(r = 0; r < s.size() - 1; r++){
            if(bit & (1<<r)){
                string t = s.substr(l, r - l + 1); 
                tmp += stoll(t);
                l = r + 1;
            }
        }
        string t = s.substr(l, r - l + 1);
        tmp += stoll(t);
        sum += tmp;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import math;q=2*math.pi
from cmath import phase as h
t=lambda x:h(x)+(q if 0>h(x)else 0)
n=int(input())
r=range(n)
c=[complex(input().replace(' -', '-').replace(' ','+')+"j")for _ in r]
for i in r:a=sorted([t(c[j]-c[i])/q for j in r if j!=i]);d=[a[j]-a[j-1] for j in r[:-1]];d[0]+=1;print(max(max(d)-1/2,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
ll N;
ll a[500050];
ll xorsum[500050];
ll timesofzero[500050];
vector<l_l> dp[1500000];
ll dpsum[1500000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> a[i];
    for(int i = 1; i <= N; i++) {
        xorsum[i] = xorsum[i-1] ^ a[i];
        timesofzero[i] = timesofzero[i-1];
        if(xorsum[i] == 0) timesofzero[i]++;
        //cerr << i << " " << timesofzero[i] << endl;
    }
    for(int i = 1; i <= N; i++) {
        if(xorsum[i] == 0) continue;
        l_l now;
        now.first = i;
        ll deltazero = 0;
        if(!dp[xorsum[i]].empty()) deltazero = timesofzero[i] - timesofzero[dp[xorsum[i]].back().first];
        now.second = 1;
        if(!dp[xorsum[i]].empty()) now.second = dp[xorsum[i]].back().second;
        now.second += dpsum[xorsum[i]] * deltazero;
        now.second %= mod;
        dp[xorsum[i]].push_back(now);
        dpsum[xorsum[i]] += now.second;
        dpsum[xorsum[i]] %= mod;
        //cerr << now.first << " "  << deltazero << " " << xorsum[i] << " " << now.second << endl;
    }
    ll ans = 0;
    //cerr << xorsum[N] << endl;
    if(xorsum[N] == 0) {
        ans += beki(2, timesofzero[N] - 1);
        for(int val = 1; val <= (1<<20); val++) {
            for(int i = 0; i < dp[val].size(); i++) {
                ans += dp[val][i].second;
                ans %= mod;
            }
        }
    } else {
        int val = xorsum[N];
        ans++;
        for(int i = 0; i < dp[val].size(); i++) {
            ans += dp[val][i].second * (timesofzero[N] - timesofzero[dp[val][i].first]);
            //cerr << ans << endl;
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70636
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;

ll dp[2501][55][55]={0};
int main(){
    int n,ave; cin>>n>>ave;
    ll ans=0;
    vi v;
    for(int i=0; i<n;i++){
        int gotiusa; cin>>gotiusa;
        dp[gotiusa][i][1]+=1;
        v.push_back(gotiusa);
    }
    for(int j=0; j<n-1;j++){
        for(int k=1; k<51;k++){
            for(int i=0; i<2501;i++){
                if(!dp[i][j][k])continue;
                dp[i][j+1][k]+=dp[i][j][k];
                dp[i+v[j+1]][j+1][k+1]+=dp[i][j][k];
            }
        }
    }
    for(int i=0; i<2501;i++)
        for(int k=1; k<51;k++){
            if(dp[i][n-1][k]==0)continue;
            else if(i/k==ave&&i%k==0){
                ans+=dp[i][n-1][k];
                //cout<<i<<" "<<k<<endl;
            }
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 55552
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int a,b,c,i,tmp;

    scanf("%d%d%d",&a,&b,&c);
    for ( tmp = a; tmp <= b; tmp++) {
        if(c % tmp == 0){
            i++;
        }
    }
    printf("%d\n",i);
    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 100000000


int32_t main() 
{ 
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif


    
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      ll n,m,k;
      cin>>n>>m>>k;
      umap h,v;
      set<pii>s;
      while(k--){
        ll x,y;
        cin>>x>>y;
        s.insert({x,y});

        h[x]++;
        v[y]++;

      }

      ll max_x=0,max_y=0;
      for(auto x:h)max_x=max(max_x,x.ss);
      for(auto x:v)max_y=max(max_y,x.ss); 


      vi vert,hori;

      for(auto x:h)if(x.ss==max_x)hori.pb(x.ff);
      for(auto x:v)if(x.ss==max_y)vert.pb(x.ff);

      ll ck=0;

      for(auto x:vert)
        for(auto y:hori)if(!s.count({y,x})){
          ck=1;break;
        }

      // cout<<max_x<<" "<<max_y<<" ";

      if(ck==1)cout<<max_y+max_x;
      else cout<<max_x+max_y-1;


  
    }





return 0;
}     



Measured memory_bytes: 57232
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(ReadLine());
      List<string> s = ReadLine().Split().ToList().ConvertAll(x=>x.ToString());
      var hashSet = new HashSet<string>(s);
      if (hashSet.Count==3)
      {
        WriteLine("Three");
      }
      else
      {
        WriteLine("Four");
      }
    }
}

Measured memory_bytes: 28252
#include <stdio.h>
#include <stdlib.h>

#define MAX 100001

typedef struct{
  char mark;
  int number;
  int sta;
} card;

int partition(card *, int, int);
void quicksort(card *, int, int);

int main(){

  int n, i, flag=0;
  card A[MAX];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf(" %c%d", &A[i].mark, &A[i].number);
    A[i].sta=i;
  }

  quicksort(A, 0, n-1);

  for(i=0; i<n; i++){
    if(A[i].number == A[i+1].number){
      if(A[i].sta > A[i+1].sta){
        flag=1;
      }
    }
  }

  if(flag==0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  for(i=0; i<n; i++){
    printf("%c %d\n", A[i].mark, A[i].number);
  }

  return 0;
}

int partition(card *A, int p, int r){
  int x, i, j;
  card trmp1, trmp2;

  x=A[r].number;
  i=p-1;

  for(j=p; j<=r-1; j++){
    if(A[j].number<=x){
      i=i+1;
      trmp1=A[i];
      A[i]=A[j];
      A[j]=trmp1;
    }
  }

  trmp2=A[i+1];
  A[i+1]=A[r];
  A[r]=trmp2;

  return i+1;
}

void quicksort(card *A ,int p, int r){
  int q;

  if(p<r){
    q=partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    while (cin >> n && n) {
        vector<int> s(n), p(n), q(n), r(n);
        for (int i = 0; i < n; ++i) {
            cin >> s[i] >> p[i] >> q[i] >> r[i];
        }
        int P, Q, R, C;
        cin >> P >> Q >> R >> C;
        bool flag = false;
        for (int i = 0; i < n; ++i) {
            if (p[i] <= P && q[i] <= Q && r[i] <= R && 4 * p[i] + 9 * q[i] + 4 * r[i] <= C) {
                cout << s[i] << '\n';
                flag = true;
            }
        }
        if (!flag) {
            cout << "NA" << '\n';
        }
    }
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    string S, T;
    cin >> S >> T;
    int sum = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x=scanner.nextInt();
		
		int p=0;
		int t=0;
		while(p<x) {
			t++;
			p+=t;
		}
		
		System.out.println(t);

	}
}


Measured memory_bytes: 22868
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int flag = 0;
      if(a%500<=b){
        flag = 1;
      }
		// 出力
      if(flag==0){
		System.out.println("No");
	}else{
        System.out.println("Yes");
      }
      }
}

Measured memory_bytes: 21844