akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

class UFT{
  int n;
  vector<int> p, h;
public:
  UFT(){
    n = 0;
  }
  UFT(int n){
    for (int i=0; i<n; i++){
      p.push_back(i);
      h.push_back(0);
    }
    this->n = n;
  }
  void add(){
    p.push_back(n++);
    h.push_back(0);
  }
  int rootOf(int x){
    if (p[x] == x){
      return x;
    } else {
      return p[x] = rootOf(p[x]);
    }
  }
  void unite(int x, int y){
    x = rootOf(x);
    y = rootOf(y);
//    cout << "unite " << x << " and " << y << endl;
    if (x==y) return; // already united
    if (h[x] < h[y]){
      p[x] = y;
    } else if (h[x]>h[y]){
      p[y] = x;
    } else { // h[x] = h[y];
      p[y] = x;
      h[x]++;
    }
  }
  bool isSame(int x, int y){
//    cout << "isSame " << x << " and " << y << " -> ";
    return rootOf(x) == rootOf(y);
  }
  void print(){
    cout << p[0] << "(" << rootOf(0) << ")";
    for (int i=1; i<n; i++)
      cout << " "  << p[i] << "(" << rootOf(i) << ")";
    cout << endl;
  }
};

int main(void){
  int n,q,c,x,y;
  UFT *uft;
  
  cin >> n >> q;
  uft = new UFT(n);
  for (int i=0; i<q; i++){
    cin >> c >> x >> y;
  //  uft->print();
    if (c==0){ // unite
      uft->unite(x, y);
    } else { // same
      cout << (uft->isSame(x,y)?1:0) << endl;
    }
  }
  return 0;
}
  
  



Measured memory_bytes: 3332
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 200005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  // calc LIS
  int cand = 0;
  for (int i = 0; i < N ; ++i)
  {
    dp[A[i]] = dp[A[i] - 1] != -1 ? dp[A[i] - 1] + 1 : 1;
    cand = max(cand, dp[A[i]]);
  }
  ans = N - cand;
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N;
    for (int i = 0; i < N; ++i)
    {
      scanf("%lld", &A[i]);
    }
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
  }

  return 0;
}

Measured memory_bytes: 2560
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

# x + y のパリティが同一かチェック, 異なる座標が存在する場合は実現不可能
p = set()
for i in range(N):
    p.add((XY[i][0] + XY[i][1]) % 2)
if len(p) > 1:
    print(-1)
    sys.exit()

# 腕の長さを1,2,4,8... で考えると, パリティ1を実現できる.
# 与えられた座標のパリティが0の場合, X座標を-1し, パリティ1の場合に帰着する(あとでX+1する)
if 0 in p:
    for i in range(N):
        XY[i][0] -= 1

# アームを準備
D = []
for i in range(35):
    D.append(2**i)
D.sort(reverse=True)

Ans = []
# 順番に計算
for i in range(N):
    x,y = XY[i][0],XY[i][1]
    x0,y0 = 0,0
    ans = ""
    # 原点を中心にX字で分割される領域の (上下左右) どちらかを判断し, 移動させ, 都度原点を調整
    for d in D:
        dx,dy = x-x0,y-y0
        # 右
        if dy < dx and dy > -dx:
            ans += "R"
            x0 += d
        # 下
        elif dy < dx and dy < -dx:
            ans += "D"
            y0 -= d
        # 左
        elif dy > dx and dy < -dx:
            ans += "L"
            x0 -= d
        # 上
        else:
            ans += "U"
            y0 += d
    Ans.append(ans)

# パリティが 0 の場合 : 長さ1のアームを追加, X座標を -1 した分を +1 して調整(つまり最後に "R" を追加する)
if 0 in p:
    D.append(1)
    print(len(D))
    print(" ".join(map(str,D)))
    for ans in Ans:
        print(ans + "R")
# パリティが 1 の場合 : そのまま出力
else:
    print(len(D))
    print(" ".join(map(str,D)))
    for ans in Ans:
        print(ans)





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

using namespace std;

int main(){
  long long int N,M;
  cin>>N>>M;
  long long int ans=N;
  for(int i=0;i<=40;i++){
    long long int L=0,R=10000000000000000;
    while(R-L>1){
      long long int mid=(R+L)/2;
      long long int fire=mid-M*i;
      if(fire<0){
        L=mid;
        continue;
      }
      vector<long long int>box;
      for(int j=0;j<=i;j++)box.push_back(fire/(i+1));
      for(int j=0;j<fire%(i+1);j++)box[j]++;
      reverse(box.begin(),box.end());
      if(box.front()==0){
        L=mid;
        continue;
      }
      long long int bag=1;
      bool big=false;
      for(auto j:box){
        if(log10(bag)+log10(j)>13){
          big=true;
          break;
        }
        else {
          bag*=j;
        }
      }
      if(!big){
        cerr<<i<<" "<<mid<<" "<<bag<<endl;
      }
      if(big||bag>=N)R=mid;
      else L=mid;
    }
    ans=min(ans,R);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	unsigned long long N;
	cin >> N;

	if ((N == 0) || (N == 1))
	{
		cout << 0 << endl;
	}
	else
	{
		vector<unsigned long long> A;
		for (unsigned long long i = 0; i < N; ++i)
		{
			unsigned long long a;
			cin >> a;
			A.emplace_back(a);
		}

		unsigned long long current = A[0];
		unsigned long long result = 0u;
		for (unsigned long long i = 1; i < N; ++i)
		{
			if (A[i] < current)
			{
				result += (current - A[i]);
			}
			else if(current < A[i])
			{
				current = A[i];
			}
		}

		cout << result << endl;
	}
}

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

int main(){
  string s; cin >> s;
  int n = s.size();
  string ans;
  if(s[n-1]=='s') ans = s+"es";
  else ans = s+"s";

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define N_MAX 1e5
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

bool Gcomp_Fi(P& l, P& r){
  return l.first > r.first;
}
//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int n;
vector<int>v;

int main(void){
  cin >> n;
  vector<P> one(N_MAX);
  vector<P> two(N_MAX);
  v.resize(n);
  int i,j;
  REP(i,N_MAX){
    one[i].first = 0;
    one[i].second = i;
    two[i].first = 0;
    two[i].second = i;
  }
  REP(i,n){
    cin >> v[i];
    if(i%2) one[v[i]].first++;
    else two[v[i]].first++;
  }
  sort(one.begin(),one.end(),Gcomp_Fi);
  sort(two.begin(),two.end(),Gcomp_Fi);
  P p1,p2;
  int min = N_MAX ;
  if(one[0].second != two[0].second){
    p1 = one[0];
    p2 = two[0];
  }
  else{
    if(one[0].first + two[1].first > one[1].first + two[0].first){
      p1 = one[0];
      p2 = two[1];
    }else{
      p1 = one[1];
      p2 = two[0];
    }
  }
  cout << n - p1.first - p2.first << endl;
  return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String yohou = scan.next();
		String jissai = scan.next();

		String[] y = new String[yohou.length()];
		String[] j = new String[yohou.length()];

		int k = 0;

		for(int i=0;i<yohou.length();i++) {
			y[i] = yohou.substring(i, i+1);
		}
		for(int i=0;i<jissai.length();i++) {
			j[i] = jissai.substring(i, i+1);
		}

		for(int i=0;i<yohou.length();i++) {
			if(y[i].equals(j[i])) {
				k += 1;
			}
		}
		System.out.println(k);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO

vector<int> v[100];
int p[100];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int s;
            cin>>s;
            v[s].push_back(i);
        }
    }
    for(int i=1;i<=m;i++) cin>>p[i];
    int cnt=0;
    for(int i=0;i<(1<<n);i++){
        bool ok=true;
        int arr[m+1];
        memset(arr,0,sizeof arr);
        for(int j=1;j<=n;j++){

            if(i&(1<<(j-1))){
                for(auto e:v[j]) arr[e]++;
            }

        }
        for(int j=1;j<=m;j++) if(arr[j]%2!=p[j]) ok=false;
        if(ok) cnt++;
    }
    cout<<cnt;

    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 3684
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A=sc.nextInt();
        int amari=N%500;
        if(A>=amari){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


     
    }
}

Measured memory_bytes: 21716
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 
void solve() {
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    rep(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
    int dp[n][3] = {0};
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];    
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
 
signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 2688
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

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

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

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  string s;
  cin >> s;
  map<char, int> mp;
  for (int i = 0; i < s.length(); ++i) ++mp[s[i]];
  for (auto x : mp) {
    if (x.s % 2 != 0) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}



Measured memory_bytes: 3660
from collections import deque


def m():
    M = int(input())
    A = deque(sorted([int(i) for i in input().split()]))
    steps = []
    # get last A
    maxA = A.pop()
    minA = A.popleft()
    while len(A) > 0:
        b = A.popleft()
        if b > 0:
            steps.append("{} {}".format(minA, b))
            minA -= b
        else:
            steps.append("{} {}".format(maxA, b))
            maxA -= b
    steps.append("{} {}".format(maxA, minA))
    print(maxA - minA)
    for s in steps:
        print(s)


m()


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

signed main(){
	ll N, K;
	cin >> N >> K;
	vector<int> A(N);
	for(int i = 0; i < N; i++)
		cin >> A.at(i);

	vector<int> city_th(N, -1);
	ll count = 1, pos = 1;
	while(count <= K){
		if(city_th.at(pos-1) == -1)
			city_th.at(pos-1) = count;
		else{
			ll loopnum = (K-count)/(count-city_th.at(pos-1));
			count += loopnum*(count-city_th.at(pos-1));
		}
		
		pos = A.at(pos-1);
		count++;
	}
	cout << pos << endl;

	return 0;	
}

Measured memory_bytes: 4824
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
#include <atcoder/all>
using namespace std; using namespace atcoder;
using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;
int main() {
	MOD = 998244353;
	cin >> N >> M;
	vl A(N), B(M);
	for (i = 0; i < N; i++) cin >> A[i];
	for (i = 0; i < M; i++) cin >> B[i];
	vl C = convolution<998244353>(A, B);
	for (i = 0; i < N+M-1; i++) {
		co3(C[i]);
	}
}

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

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

using namespace std;

int main(){
	while(1){
		long long int n, m, p, d, ans;
		vector<pair<int,int> > pd;
		cin >> n >> m;
		if (n==0 && m==0) return 0;
		ans = 0;
		
		REP(i,n){
			cin >> d >> p;
			pd.push_back(make_pair(p,d));
		}
		
		sort(pd.begin(), pd.end(), greater<pair<int,int> >() );
		
		REP(i,n){
			p = pd[i].first;
			d = pd[i].second;
			if (m>0){
				if (m<d){
					ans += (d-m)*p;
				}
				m -= d;
			}else{
				ans += d*p;
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}




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

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

    set<pair<long long int, long long int>> ball;
    for(int i=0; i<n; i++){
        long long int x, y;
        cin >> x >> y;
        ball.insert({x,y});
    }

    vector<long long int> x, y;
    for(auto b : ball){
        x.push_back(b.first);
        y.push_back(b.second);
    }

    int ans = n;// INF
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            set<pair<long long int, long long int>> test = ball;
            long long int p = x[j] - x[i];
            long long int q = y[j] - y[i];

            int times = 0;
            for(int k=0; k<n; k++){
                long long int nx = x[k];
                long long int ny = y[k];
                if(test.find({nx,ny}) == test.end()) continue;
                while(test.find({nx+p, ny+q}) != test.end()){
                    test.erase({nx,ny});
                    nx += p;
                    ny += q;
                }
                test.erase({nx,ny});
                times += 1;
            }
            ans = min(ans, times);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef vector<int> vi;
#define mp make_pair
#define MAX 1e13
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pi> vii;
#define LSOne(S) (S & (-S))
const int N = 1e5 + 10;
int arr[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int ans = arr[n / 2] - arr[n / 2 - 1];
	cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

typedef struct {
    int time;
    int tower[3][15];
    int t[3];
} HANOI;

HANOI queue[50000];
int head, tail;
int pow[30];

void enq(HANOI t)
{
	queue[tail % 50000] = t;
	tail++;
}

void deq(HANOI *t)
{
	*t = queue[head % 50000];
	head++;
}

char v[15000000];

int move(HANOI temp, int from, int to, int pw)
{
    int num;
    int i, j;
    HANOI first;
    if ((temp.t[from] > 0 && temp.t[to] > 0 && temp.tower[from][temp.t[from] - 1] > temp.tower[to][temp.t[to] - 1]) ||temp.t[from] > 0 && temp.t[to] == 0){
        first = temp;
        first.tower[to][temp.t[to]] = first.tower[from][temp.t[from] - 1];
        first.tower[from][temp.t[from] - 1] = 0;
        first.t[from]--;
        first.t[to]++;
        first.time++;
        num = 0;
        for (i = 0; i < 3; i++){
            for (j = 0; j < first.t[i]; j++){
                num += i * pow[first.tower[i][j] - 1];
            }
            num %= 15000000;
        }
        if (v[0] == 1 || v[pw] == 1){
            printf("%d\n", first.time);
            return (1);
        }
        if (!v[num]){
            v[num] = 1;
            enq(first);
        }
    }
    return (0);
}

int main(void)
{
    int n, m;
    HANOI start, temp;
    int i, j;
    int pw;
    
    pow[0] = 1;
    for (i = 1; i < 20; i++){
        pow[i] = pow[i - 1] * 3;
    }
    
    while (1){
        scanf("%d%d", &n, &m);
        
        if (n + m == 0){
            break;
        }
        memset(start.tower, 0, sizeof(start.tower));
        for (i = 0; i < 3; i++){
            scanf("%d", &start.t[i]);
            for (j = 0; j < start.t[i]; j++){
                scanf("%d", &start.tower[i][j]);
            }
        }
        
        memset(v, 0, sizeof(v));
        
        start.time = 0;
        head = tail = 0;
        pw = pow[n] - 1;
        enq(start);
        
        while (head != tail){
            deq(&temp);
            
            if (temp.time > m){
                printf("-1\n");
                break;
            }
            
            if (move(temp, 0, 1, pw)){
                break;
            }
            if (move(temp, 1, 0, pw)){
                break;
            }
            if (move(temp, 1, 2, pw)){
                break;
            }
            if (move(temp, 2, 1, pw)){
                break;
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 24000
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    vll a(n); REP(i,n) cin>>a[i];
    ll ans=0;
    ll j=0;
    ll sum=0;
    REP(i,n){
        
        while(j<n && ((sum^a[j])==(sum+a[j]))){
            // cout<<sum+a[j]<<' '<<(sum^a[j])<<' '<<1111<<endl;
            sum += a[j];
            j++;
        }
        ans += j-i;
        if(i==j) j++;
        else sum-=a[i];
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	int N; std::cin >> N;
	std::vector<int> H(N); for (auto& r : H) std::cin >> r;
	int ans = 0; int count = 0;
	for (int i = 0; i < N - 1; ++i)
		if (H[i] >= H[i + 1]) ++count;
		else {
			ans = std::max(ans, count);
			count = 0;
		}
	std::cout << std::max(ans, count) << std::endl;

	return 0;
}

Measured memory_bytes: 3780
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
c = 0
v = []
for i in range(n-1):
    if a[i] != a[i+1]:
        c += 1
        if c >= 2:
            v.append([a[i],c])
        c = 0
    else:
        c += 1
if a.count(a[-1]) >=2 :
    v.append([a[-1],a.count(a[-1])])
if len(v) == 0:
    print(0)
elif v[0][1] >= 4:
    print(v[0][0]**2)
elif len(v) >= 2:
    print(v[0][0]*v[1][0])

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

string s;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	s = "0" + s;
	auto dp = make_v<int64>(s.size()+1, 2);
	fill_v<int64>(dp, INF_LL);
	dp[0][0] = 0;
	REP(i, s.size()) s[i] -= '0';
	REP(i, s.size()) {
	  REP(j, 2) {
	    int64 now = j*10;
	    REP(k, 2) {
	      int64 obj = s[i]+k, cost = 0;
	      if (obj > now) cost += obj - now;
	      chmin(dp[i+1][k], dp[i][j] + cost + max((int64)0, now-obj));
//	      cout << "(" << i << " " << j << " " << k << ": " << dp[i][j] << " " << cost << " " << max((int64)0, now-obj) << ") ";
	    }
//	    cout << endl;
	  }
	}
	cout << dp[s.size()][0] << endl;
}


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

int N;

int main() {
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    vector<int> A(N), B(N), C(N);
    A[0] = a[0]; B[0] = b[0]; C[0] = c[0];
    for (int i = 1; i < N; i++) {
        A[i] = a[i] + max(B[i - 1], C[i - 1]);
        B[i] = b[i] + max(C[i - 1], A[i - 1]);
        C[i] = c[i] + max(A[i - 1], B[i - 1]);
    }
    
    int maxAB = max(A[N - 1], B[N - 1]);
    cout << max(maxAB, C[N - 1]) << endl;
}

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

using namespace std;

int main() {
	int n,w;
	cin>>n>>w;
	long long a[n][2];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<2;j++)
	    {
	        cin>>a[i][j];
	    }
	}
	long long k[n+1][w+1];
	for(int i=0;i<=n;i++)
	{
	    for(int j=0;j<=w;j++)
	    {
	        if(i==0||j==0)
	        k[i][j]=0;
	        else if(a[i-1][0]<=j)
	        k[i][j]=max(a[i-1][1]+k[i-1][j-a[i-1][0]],k[i-1][j]);
	        else
	        k[i][j]=k[i-1][j];
	    }
	}
	
	cout<<k[n][w];
	
	return 0;
}


Measured memory_bytes: 79104
//go:generate echo "https://atcoder.jp/contests/abc176/tasks/abc176_b"
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *scanner) StringSlice(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func solve(n string) bool {
	sum := 0
	for _, c := range n {
		n, _ := strconv.Atoi(string(c))
		sum += n
	}
	return sum%9 == 0
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.String()
	if solve(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2436
n = int(input())
a = list(map(int,input().split()))
b =list(map(int, input().split()))
c =list(map(int, input().split()))

ans =sum(b)

for i in range(n-1):
  if a[i+1] - a[i] == 1:
    ans += c[a[i] -1]
    
print(ans)

Measured memory_bytes: 3064
s = gets.chomp
acgt = ['A','C','G','T' ]
count = 0

while s.length > 0
  if acgt.include?(s[0])
    i = 0
    while acgt.include?(s[i])
      count = i+1 if count < i+1
      i += 1
    end
  end
  s.slice!(0)
end

puts count

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li dp[2][1001000];

int main() {
    string s;
    cin >> s;

    dp[0][0] = 0;
    dp[1][0] = 1;
    rep(i, sz(s)) {
        li num = s[i] - '0';
        dp[0][i + 1] = min(dp[0][i] + num, dp[1][i] + 10 - num);
        dp[1][i + 1] = min(dp[1][i] + 9 - num, dp[0][i] + num + 1);
    }
    cout << dp[0][sz(s)] << endl;

    return 0;
}

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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  
  int p1, p2;
  p1 = a * n;
  p2 = b;
  
  if(p1 <= p2)
    cout << p1 << endl;
  if(p2 < p1)
    cout << p2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		long[] st = new long[31]; st[0] = 1;
		for(int i=1;i<=30;i++) {
			st[i] += st[i-1];
			if(i-2>=0) st[i] += st[i-2];
			if(i-3>=0) st[i] += st[i-3];
		}
		
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			System.out.println(((st[n]+9) / 10 + 364) / 365);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 15356
PROGRAM piyo
      IMPLICIT NONE
      character(10) :: s,t,u
      integer :: a,b
      
      read*,s,t
      read*,a,b
      read*,u
      
      
      if( trim(s)==trim(u) ) a = a - 1
      if( trim(t)==trim(u) ) b = b - 1
      
      print*, max(0,a),max(0,b)

      
      END PROGRAM

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    bool flag = false;
    int k = -1;
    for(int i = 2; i < S.size()-1; i++){
        if(flag == true && S[i] == 'C'){
            cout << "WA" << endl;
            return 0;
        }
        if(S[i] == 'C'){
            flag = true;
            k = i;
        }
    }
    for(int i = 1; i < S.size(); i++){
        if(isupper(S[i])){
            if(i != k){
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    if(flag == false) cout << "WA" << endl;
    else cout << "AC" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> ans(N);
    for(int i=1; i<N; ++i){
        for(int j=1; j<sqrt(N); ++j){
            for(int k=1; k<sqrt(N); ++k){
                int n = pow(i, 2)+pow(j, 2)+pow(k, 2)+i*j+j*k+k*i;
                if(n<=N) ans[n-1]++;
            }
        }
    }
    for(auto a: ans){
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(){
    ll n;
    cin>>n;
    vvl a(2,vl(n,0));
    ll ans = 0;
    rep(i,n) cin>>a[0][i];
    rep(i,n) cin>>a[1][i];
    rep(i,n){
        ll sum = 0;
        rep(j,n){
            if(j > i){
                sum += a[1][j];
            }
            else if(i > j){
                sum += a[0][j];
            }
            else{
                sum += (a[0][j]+a[1][j]);
            }
        }
        ans = max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int t = scanner.nextInt();
		for (int i = 0; i < t; i++) {
			int n = scanner.nextInt();
			int a = scanner.nextInt();
			int cu = 0, cd = 0;
			for (int j = 1; j < n; j++) {
				int b = scanner.nextInt();
				if (b - a > cu) {
					cu = b - a;
				}
				else if (b - a < cd) {
					cd = b - a;
				}
				a = b;
			}
			System.out.println(cu + " " + -cd);
		}
		scanner.close();
	}

}


Measured memory_bytes: 35568
N,M,C = map(int,list(input().split()))
B = list(map(int,(input().split())))
counter = 0
for i in range(N):
    A = list(map(int,(input().split())))
    sum_val = 0
    for j in range(M):
        sum_val +=A[j]*B[j]
    sum_val += C
    if sum_val >0:
        counter += 1
print(counter)


Measured memory_bytes: 9144
N, S = map(int, input().split())
A = map(int, input().split())
 
def solve(length, target, nums):
  
  dp = [[0]*(target+1) for i in range(length+1)]
  dp[0][0] = 1
  for i, n in enumerate(nums):
    for j, comb_num in enumerate(dp[i]):
      sub = j - n
      dp[i + 1][j] += comb_num * 2
      #print(i, j, sub, dp[i])
      if sub >= 0:
        dp[i + 1][j] += dp[i][sub]
      dp[i + 1][j] %= 998244353
  #print(dp)
  print(dp[length][target])
  
solve(N, S, A)

Measured memory_bytes: 139272
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        t: [usize;n],
        m: usize,
    }

    let mut p: Vec<usize> = Vec::new();
    let mut x: Vec<usize> = Vec::new();

    for i in 0..m {
        input!{
            p_tmp: usize,
            x_tmp: usize,
        }
        p.push(p_tmp);
        x.push(x_tmp);
    }
    debug!(x);
    let mut sum = 0;
    for i in 0..n {
        sum += t[i];
    }

    for i in 0..m {
        println!("{}", sum-t[p[i]-1]+x[i]);
    }

}


Measured memory_bytes: 2184
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[]) throws Exception
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
           int d=sc.nextInt(),tt=sc.nextInt(),s=sc.nextInt(),z=0;long ans=0;
           double tt1=(double)d/s;
           if(tt1<=tt)
           //String s=sc.next();
           
           pw.println("Yes");
           else pw.println("No");
        }
           pw.close();
    }
}
  

Measured memory_bytes: 32692
let max_m = 2000

let make_dp a n =
  let dp = Array.make_matrix (n + 1) (max_m + 1) false in
  for i = 1 to n do dp.(i).(a.(i-1)) <- true done;
  for i = 2 to n do
    for j = 1 to max_m do
      if dp.(i-1).(j) || j > a.(i-1) && dp.(i-1).(j - a.(i-1)) then dp.(i).(j) <- true;
    done;
  done;
  dp

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let dp = make_dp a n in
  let q = Scanf.scanf "%d " (fun i -> i) in
  for _ = 0 to q - 1 do
    Printf.printf "%s\n" (if dp.(n).(Scanf.scanf "%d " (fun i -> i)) then "yes" else "no")
  done

Measured memory_bytes: 2536
url = "https://atcoder.jp//contests/abc159/tasks/abc159_a"

def main():
    e, v = list(map(int, input().split()))
    lis = []
    for i in range(e):
        lis.append(1)
    for i in range(v):
        lis.append(2)
    count = 0
    for i in range(len(lis)):
        for j in range(i + 1, len(lis)):
            # print(lis[i], lis[j])
            if (lis[i] + lis[j]) % 2 == 0:
                count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	L := make([]int, N)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		L[i] = V
	}
	sort.Ints(L)
	ans := 0
	for a := 0; a < N-2; a++ {
		for b := a + 1; b < N-1; b++ {
			// なぜか以下うまくいかない 意味不明 わけわからん 2時間くらい無駄にした
			// from := sort.Search(N, func(j int) bool {
			// 	if a == 0 && b == 1 {
			// 		fmt.Printf("L[%d]+L[%d]=%d+%d > L[j] = L[%d]= %d????\n", a, b, L[a], L[b], j, L[j])
			// 	}
			// 	return j > b && L[a]+L[b] > L[j]
			// })
			// したかないのでスクラッチ
			l, r := b, N
			for r > l {
				mid := (l + r) / 2
				if L[a]+L[b] > L[mid] {
					l = mid + 1
				} else {
					r = mid
				}
			}
			if l > b {
				// fmt.Printf("L[%d]+L[%d]=%dを初めて下回るのはL[%d]=%d までの %d 個\n", a, b, L[a]+L[b], l-1, L[l-1], (l-1)-b)
				ans += (l - 1 - b)
			}
		}
	}
	fmt.Println(ans)
}


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

int digit(int a){
    int dig = 1;
    while(a/10 != 0){
        a /= 10;
        if(a != 0) dig++;
    }
    return dig;
}

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

    int Ans = 0;
    for(int i = 1; i < N+1; i++){
        if(digit(i) % 2 != 0) Ans++;
    }
 cout << Ans << endl; 
 
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,m,pre[2020][2020],nxt[2020][2020],pre1[2020][2020],nxt1[2020][2020];
string s[2020];

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        cin >> n >> m;
        for(int i=1;i<=n;i++){
                cin >> s[i];
                s[i] = " "+s[i];
                for(int j=1;j<=m;j++){
                        if(s[i][j]!='.')continue;
                        if( s[i][j-1]=='.' ){
                                pre[i][j] = pre[i][j-1];
                        }
                        else {
                                pre[i][j] = j;
                        }
                }
                for(int j=m;j>=1;j--){
                        if(s[i][j]!='.')continue;
                        if( s[i][j+1]=='.' ){
                                nxt[i][j] = nxt[i][j+1];
                        }
                        else {
                                nxt[i][j] = j;
                        }
                }
        }

        for(int i=1;i<=m;i++){
                for(int j=1;j<=n;j++){
                        if( s[j][i]!='.' )continue;
                        if( s[j-1][i]=='.' ){
                                nxt1[j][i] = nxt1[j-1][i];
                        }
                        else nxt1[j][i] = j;
                }
                for(int j=n;j>=1;j--){
                        if( s[j][i]!='.' )continue;
                        if( s[j+1][i]=='.' ){
                                pre1[j][i] = pre1[j+1][i];
                        }
                        else pre1[j][i] = j;
                }
        }
        int ans = 0;
        for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                        ans = max( ans,  nxt[i][j]-pre[i][j]+1 + pre1[i][j]-nxt1[i][j]  );
                }
        }
        cout << ans << endl;


return 0;
}
///....


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

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

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

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

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

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

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

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

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

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

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

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] s = new int[m][2];
    for (int i = 0; i < m; i++) {
      s[i] = sc.nextIntArray(2);
    }
    int min = n == 1 ? 0 : (int) Math.pow(10, n - 1);
    for (int val = min; val < Math.pow(10, n); val++) {
      boolean isMatch = true;
      String[] digits = Integer.toString(val).split("");
      for (int[] si : s) {
        if (!digits[si[0] - 1].equals(Integer.toString(si[1]))) {
          isMatch = false;
          break;
        }
      }
      if (isMatch) {
        System.out.println(val);
        return;
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 22612
# -*- coding: utf-8 -*-
A, B, C, D = map(int, input().split())
ans = 0
Am = 0
Bm = 0
df = 0
t = 0

def lcm(x, y):
	return (x * y) // gcd(x, y)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

t = B - A + 1
Am = B // C - (A - 1) // C
Bm = B // D - (A - 1) // D
df = B // lcm(C, D) - (A - 1)//lcm(C, D)
ans = t - (Am + Bm) + df
print(ans)

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

long n;

long a[100000+10];
long b[100000+10];

int main()
{
  cin >> n;
  for(long i=0;i<n;i++){
    cin >> a[i];
  }
  for(long i=0;i<100000+10;i++){
    b[i] = 0;
  }

  for(long i=0;i<n;i++){
    b[a[i]]++;
    b[a[i]+1]++;
    if(a[i] != 0){
      b[a[i]-1]++;
    }
  }

  long max = 0;
  for(long i=0;i<100000+10;i++){
    if(b[i] > max){
      max = b[i];
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 1792