akhauriyash/Code-Regression huggingface dataset:
#Fibonacci Number
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=jp


class fibonacci:
    def __init__(self):
        self.result: List[int] = [-1]*1000
        return 
    def calc(self,n):
        if (n == 0 or n == 1):
            self.result[n] = 1
            return 1
        if (self.result[n] != -1):
            return self.result[n]
        self.result[n-1] = self.calc(n-1) 
        self.result[n-2] = self.calc(n-2)
        return self.result[n-1] + self.result[n-2]
n = int(input())

print (fibonacci().calc(n))




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

using namespace std;

const int INF = 1 << 30;

int main()
{
  double cost = 20 * acos(-1) / 4.0;

  int a, b, c, d, n, x[200000], y[200000];

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

  if(a > c) swap(a, c), swap(b, d);
  bool flip = false;
  if(b > d) swap(b, d), flip = true;


  vector< pair< int, int > > idx;
  for(int i = 0; i < n; i++) {
    if(a <= x[i] && x[i] <= c && b <= y[i] && y[i] <= d) {
      if(flip) idx.emplace_back(x[i], y[i] * -1);
      else idx.emplace_back(x[i], y[i]);
    }
  }
  sort(begin(idx), end(idx));

  vector< int > dp(idx.size(), INF);
  for(auto &p : idx) {
    *lower_bound(begin(dp), end(dp), p.second) = p.second;
  }
  int pos = lower_bound(begin(dp), end(dp), INF) - begin(dp);
  double ret = (c - a) * 100.0 + (d - b) * 100.0;
  if(min(c - a, d - b) + 1 == pos) ret += cost;
  ret -= pos * (20.0 - cost);
  cout << fixed << setprecision(15) << ret << endl;
}

Measured memory_bytes: 4980
//Name: Cookie Counter
//Level: 3
//Category: 数学,数え上げ,動的計画法,DP
//Note:

/**
 * D日のうちe日だけクッキーを1枚以上食べたとすると、そういう日の取り方は全部でcomb(D, e)通りある。
 * 毎日1枚以上のクッキーを食べるとしたとき、e日目にクッキーがk枚だけ残っているような食べ方のパターン数は
 *   dp[e][k] = Σdp[e-1][k+1 ≦ k' < k+X]
 * であるが、dp[e][N]からdp[e][0]に向けて埋めていくと、Σの中身を再利用できるため、更新がO(1)になる。
 *
 * オーダーは O(N^2)。
 */

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const long long MOD = 1000000007;

long long modpow(long long a, long long x) {
    long long res = 1;
    while(x) {
        if(x & 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        x /= 2;
    }
    return res;
}

long long inv(long long x) {
    return modpow(x, MOD-2);
}

long long inv_tbl[2001];

bool solve() {
    int N, X;
    long long D;
    if(!(cin >> N >> D >> X)) return false;
    if(!N && !D && !X) return false;

    long long ans = 0;
    long long comb = 1;
    vector<long long> dp[2];
    dp[0].resize(N+1);
    dp[1].resize(N+1);
    dp[0][N] = 1;
    for(int d = 1; d <= min<long long>(N,D); ++d) {
        long long acc = 0;
        for(int k = N; k >= 0; --k) {
            dp[1][k] = acc;
            acc += dp[0][k];
            if(k+X-1 <= N) acc += (MOD - dp[0][k+X-1]);
            acc %= MOD;
        }
        comb *= (D-d+1) % MOD;
        comb %= MOD;
        comb *= inv_tbl[d];
        comb %= MOD;
        ans += dp[1][0] * comb;
        ans %= MOD;
        dp[0].swap(dp[1]);
    }
    cout << ans << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    for(int i = 1; i <= 2000; ++i) {
        inv_tbl[i] = inv(i);
    }

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1252
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[200010];
vector<int> c(10010, 0);
int num[200010];
bool used[200010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    string S,T;
    cin >> S >> T;
    int ans=0;

    for(int i =0; i<3; i++){
        if(S[i]==T[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5496
using System;
 
class A
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        long N = long.Parse(s[0]);
        long A = long.Parse(s[1]);
        long B = long.Parse(s[2]);
        long a = A - 1;
        long b = N - B;
        long c = ((a - b) > 0) ? b : a;

        if ((B - A) % 2 == 0)
        {
            Console.WriteLine((B - A) / 2);
        }
        if ((B - A) % 2 == 1)
        {
            Console.WriteLine((c + 1 + (B - A)/2));
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int coun[105][105][105];
vector<int>x,y,z;
int rx[52][2], ry[52][2], rz[52][2];
int a[52],b[52],c[52],d[52],e[52],f[52];
int n,m;

int compress1(){
	for(int i = 0;i < n;i++){
		x.push_back(a[i]);
		x.push_back(d[i]);
	}
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	for(int i = 0;i < n;i++){
		rx[i][0] = find(x.begin(),x.end(),a[i])-x.begin();
		rx[i][1] = find(x.begin(),x.end(),d[i])-x.begin();
	}
	return x.size();
}

int compress2(){
	for(int i = 0;i < n;i++){
		y.push_back(b[i]);
		y.push_back(e[i]);
	}
	sort(y.begin(), y.end());
	y.erase(unique(y.begin(), y.end()), y.end());
	for(int i = 0;i < n;i++){
		ry[i][0] = find(y.begin(),y.end(),b[i])-y.begin();
		ry[i][1] = find(y.begin(),y.end(),e[i])-y.begin();
	}
	return y.size();
}

int compress3(){
	for(int i = 0;i < n;i++){
		z.push_back(c[i]);
		z.push_back(f[i]);
	}
	sort(z.begin(), z.end());
	z.erase(unique(z.begin(), z.end()), z.end());
	for(int i = 0;i < n;i++){
		rz[i][0] = find(z.begin(),z.end(),c[i])-z.begin();
		rz[i][1] = find(z.begin(),z.end(),f[i])-z.begin();
	}
	return z.size();
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d %d %d %d %d %d",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]);
	}
	int w = compress1();
	int h = compress2();
	int d = compress3();
	for(int i = 0;i < n;i++){
	for(int tx=rx[i][0];tx<rx[i][1];tx++)
    {
      for(int ty=ry[i][0];ty<ry[i][1];ty++)
        {
          for(int tz=rz[i][0];tz<rz[i][1];tz++)
        {
          coun[tx][ty][tz]++;
        }
        }
    }
	}
  long long ans=0;
  for(int i=0;i<=w;i++)
    {
      for(int j=0;j<=h;j++)
    {
      for(int k=0;k<=d;k++)
        {
          if(coun[i][j][k]>=m)
        {
          long long s1=(x[i+1]-x[i]),s2=(y[j+1]-y[j]),s3=(z[k+1]-z[k]);
          ans+=s1*s2*s3;
        }
        }
    }
    }
	//long long ans = 0;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6604
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <functional>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ll, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
#ifndef ONLINE_JUDGE
    scanf("%lld", &a);
#else
    scanf("%I64d", &a);
#endif
    return a;
}

#define N 100000

ll d1[N];
ll d2[N];
ll res[N];
int vs[N];
vector<pair<int, ll> > ne1[N];
vector<pair<int, ll> > ne2[N];

void dijk(int s, ll *d, vector<pair<int, ll> > *ne) {
    priority_queue<pii, vector<pii>, greater<pii> > Q;
    memset(vs, 0, sizeof(vs));
    d[s] = 0;
    Q.push({0,s});
    while(!Q.empty()){
        int u = Q.top().second;
        Q.pop();
        if (vs[u])
            continue;
        vs[u] = 1;
        for(auto &c : ne[u]){
            int v = c.first;
            if (vs[v])
                continue;
            int w = c.second;
            if(d[v] == -1 || d[v] > d[u]+w){
                d[v] = d[u]+w;
                Q.push({d[v],v});
            }
        }
    }
}

int main() {
    memset(d1, -1, sizeof(d1));
    memset(d2, -1, sizeof(d2));
    int n = gi();
    int m = gi();
    int s1 = gi()-1;
    int s2 = gi()-1;

    for (int i = 0; i < m; i++) {
        int u = gi()-1;
        int v = gi()-1;
        ll a1 = gi();
        ll a2 = gi();
        ne1[u].push_back({v, a1});
        ne1[v].push_back({u, a1});
        ne2[u].push_back({v, a2});
        ne2[v].push_back({u, a2});
    }

    dijk(s1, d1, ne1);
    dijk(s2, d2, ne2);

    ll mx = 0;
    for (int i = n-1; i >= 0; i--) {
        ll alt = 1000000000000000LL - (d1[i] + d2[i]);
        mx = MAX(alt, mx);
        res[i] = mx;
    }

    for (int i = 0; i < n; i++)
        printf("%lld\n", res[i]);

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  char color[N];
  for(int i=0; i<N; i++){
    cin >> color[i];
  }
  
  int  p=0,w=0,g=0,y=0;
  for(int i=0; i<N; i++){
    if( color[i] == 'P' ){p = 1;}
    else if( color[i] == 'W' ){w = 1;}
    else if( color[i] == 'G' ){g = 1;}
    else if( color[i] == 'Y' ){y = 1;}
  }
  if(p+w+g+y == 3){cout<< "Three" << endl;}
  if(p+w+g+y == 4){cout << "Four" << endl;}
  
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

class UnionFind
{
private:
  vector<int> par, sizes;

public:
  UnionFind(int n = 200010) : par(n), sizes(n, 1)
  {
    rep(i, n) par[i] = i;
  }

  int root(int x)
  {
    if (x == par[x])
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sizes[x] < sizes[y])
      swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y)
  {
    return root(x) == root(y);
  }

  int size(int x)
  {
    return sizes[root(x)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll n, m, k;
  cin >> n >> m >> k;
  UnionFind uf;
  int a[100010], b[100010];
  rep(i, m) cin >> a[i] >> b[i];
  int c[100010], d[100010];
  rep(i, k) cin >> c[i] >> d[i];

  ll ans[100010] = {};
  rep(i, m)
  {
    a[i]--, b[i]--;
    uf.unite(a[i], b[i]);
    ans[a[i]]--;
    ans[b[i]]--;
  }

  rep(i, n)
  {
    ll t = uf.size(i);
    ans[i] += t - 1;
  }

  rep(i, k)
  {
    c[i]--, d[i]--;
    if (uf.same(c[i], d[i]))
    {
      ans[c[i]]--;
      ans[d[i]]--;
    }
  }

  rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");

  return 0;
}


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

struct edge{
    int from;
    int to;
    int cost;
};

using namespace std;

int pow(int n, int k){
    int ans = 1;
    for(int i = 0; i < k; i++){
        ans *= n;
    }
    return ans;
}

int main(){
    int L;
    vector<edge> es;
    cin >> L;
    int tmp = 1, cnt = 0;
    while(L >= tmp){
        tmp *= 2;
        cnt++;
    }
    for(int i = 1; i < cnt ; i++){
        edge edge1 = {i, i+1, 0};
        edge edge2 = {i, i+1, pow(2, i-1)};
        es.push_back(edge1);
        es.push_back(edge2);
    }
    tmp = pow(2, cnt-1);
    if(L%2 == 1){
        edge edge1 = {1, cnt, tmp};
        es.push_back(edge1);
        tmp+= 1;
        L = (L - 1)/2;
    }else{
        L = L/2;
    }
    for(int i = 2; i < cnt; i++){
        if(L%2 == 1){
            edge edge1 = {i, cnt, tmp};
            es.push_back(edge1);
            tmp+= pow(2, i-1);
        }
        L = (L - (L%2))/2;
    }
    cout << cnt << ' ' << es.size() << endl;
    for(int i = 0; i < es.size(); i++){
        cout << es[i].from << ' ' << es[i].to << ' ' << es[i].cost << endl;
    }
}

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

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

    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    graph = [[-1 for _ in range(n)] for _ in range(n)]

    for i in range(n):
        ai = int(input())

        for _ in range(ai):
            xi, yi = map(int, input().split())
            xi -= 1
            graph[i][xi] = yi

    ans = 0

    # bit全探索
    for bit in range(1 << n):
        d = [0 for _ in range(n)]

        for j in range(n):
            if (bit >> j) & 1:
                d[j] = 1

        is_ok = True

        for j in range(n):
            if d[j] == 1:
                for k in range(n):
                    if graph[j][k] == -1:
                        continue

                    if graph[j][k] != d[k]:
                        is_ok = False

        if is_ok:
            ans = max(ans, sum(d))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
long gcd_euclid(long m, long n) {
long temp;
while (n) {
temp = m % n;
m = n;
n = temp;
}
return m;
}
int main(){
long a, b;
long temp;
long gcd, lcm;
while(scanf("%ld %ld", &a, &b) != EOF){
gcd = gcd_euclid(a, b);
temp = a / gcd;
lcm = temp * b;
printf("%ld %ld\n", gcd, lcm);
}
return 0;
}

Measured memory_bytes: 1024
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int c[4][4],a[4],b[4];
int main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>c[i][j],a[i]=-1,b[i]=-1;
	a[1]=1;
	for(int ff=1;ff<=150000;ff++) {
		int xx;
		xx++;
	}
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++){
			if(a[i]!=-1&&b[j]!=-1){
				if(c[i][j]!=a[i]+b[j]){
					cout<<"No";
					return 0;
				}
			}
			else if(a[i]!=-1&&b[j]==-1) b[j]=c[i][j]-a[i];
			else a[i]=c[i][j]-b[j];
		}
	cout<<"Yes";
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

bool kai(string s){
    ll n=s.size();
    rep(i,0,n-1){
        if(s[i]!=s[n-1-i])return false;
    }
    return true;
}

int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    if(kai(s)){
        string a,b;
        rep(i,1,(n-1)/2){
            a+=s[i-1];
        }
        rep(i,(n+3)/2,n){
            b+=s[i-1];
        }
        if(kai(a)&& kai(b)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'B' && s[i + 1] == 'W')
            count++;
    }
    for (int i = s.size() - 1; i >= 1; i--)
    {
        if (s[i] == 'B' && s[i - 1] == 'W')
            count++;
    }
    cout << count;
    // int w, h, n;
    // int A[w][h] = {0};
    // cin >> w >> h >> n;
    // for (int i = 0; i < n; i++)
    // {
    // }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();
    return 0;
}


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

int main() {
        int n;
        scanf("%d", &n);
        vector<int> v(n), c(n);
        rep(i, n) {
                scanf("%d", &v[i]);
        }
        rep(i, n) {
                scanf("%d", &c[i]);
        }
        int ans = 0;
        rep(i, n) {
                ans += (v[i] > c[i] ? v[i] - c[i] : 0);
        }
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	int a[n];
	bool can=true;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 && a[i]%5!=0)
			{
				can=false;
			}
		}
	}
cout<<(can?"APPROVED":"DENIED");
	
	
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 1000000007;
	//static long mod =998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";


		int res = 0;


		int n = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		res++;
		char now=str[0];

		for ( int i = 1; i < str.Length; i++ ) {
			if ( now != str[i] ) { now = str[i]; res++; }
		}


			Console.WriteLine(res);

		return;

	}




	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11232
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a+=b;
    c+=d;
    if(a>c)cout<<"Left";
    else if(a==c)cout<<"Balanced";
    else cout<<"Right";
    
    return 0;
    
}


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

int main(){
  int n; cin>>n;
  int even=0,odd=0;
  for(int i=0;i<n;i++){
    int x; cin>>x;
    if(x%2==0) even++;
    else odd++;
  }if(odd%2==1){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
}

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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; scanf("%d", &x); return x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 5010;

int mod;

inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }

int f[MAXN][MAXN];
int g[MAXN][MAXN];
int S[MAXN * 2];

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri; mod = ri;
	int N = (n + 1) / 2;

	f[0][0] = 1;
	for(int i = 1; i <= N; i++)
		for(int j = 0; j <= n; j++)
			for(int k = j; k <= n; k += i)
				Add(f[i][k], f[i - 1][j]);

	g[0][0] = 1;
	for(int i = N - 1; i >= 1; i--) {
		for(int j = 0; j <= n; j++) {
			if(i * j >= n) break;
			for(int k = i * j; i + k <= n; k++)
				if(i + k <= n)
					Add(g[j + 1][k + i], g[j][k]);
		}
	}

	for(int i = 0; i <= n; i++)
		for(int j = 1; j <= n; j++)
			Add(g[i][j], g[i][j - 1]);
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= n; j++)
			Add(g[i][j], g[i - 1][j]);

	int n1 = N, n2 = N - 1;
	int res = 0;
	if(!(n & 1)) {
		for(int x = 1; x <= n; x++)
			for(int i = 0; i < x; i++)
				res = (res + 1LL * f[n1][i] * g[n - x][x - i - 1]) % mod;
	} else {
		for(int x = 1; x <= n; x++)
			for(int i = 0; i < x; i++)
				res = (res + 1LL * f[n1 - 1][i] * g[n - x][x - i - 1]) % mod;
	}
/*
	for(int i = 0; i <= n; i++) printf("%d\n", S[i]);

	for(int i = 1; i <= n; i++) Add(S[i], S[i - 1]);

	int res = 0;
	for(int i = 0; i < n; i++) Add(res, S[i]);
*/
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 147712
N = int(input())
A = []
A = list(map(int, input().split()))

c_amount = 1000
for i in range(N-1):
    if(A[i]>=A[i+1]):
        pass
    else:
        c_amount+=(c_amount//A[i])*(A[i+1]-A[i])

print(c_amount)


Measured memory_bytes: 8832
#include<iostream>

using namespace std;

struct Card{
  char suit;
  int value;
};

void bubbleSort(Card matrix[], int N){
  
  Card temp;

  for(int i=0;i<N-1;i++){
    for(int j=N-1;j>i;j--){
      if(matrix[j-1].value > matrix[j].value){
        temp = matrix[j-1];
        matrix[j-1] = matrix[j];
        matrix[j] = temp;  
      }
    }
  }
}

void selectionSort(Card matrix[], int N){

  Card temp;

  for(int i=0;i<N-1;i++){
    int minj = i;
    for(int j=i+1;j<N;j++){
      if( matrix[j].value < matrix[minj].value ){
        minj = j;
      }
    }
    
    temp = matrix[i];
    matrix[i] = matrix[minj];
    matrix[minj] = temp;
  }

}

bool isStable(Card matrix1[], Card matrix2[], int N){
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int a=0;a<N;a++){
         for(int b=a+1;b<N;b++){

           bool criteria;
           criteria = (matrix1[i].value == matrix1[j].value && \
                       matrix1[i].value == matrix2[b].value && \
                       matrix1[i].suit  == matrix2[b].suit  && \
                       matrix1[j].value == matrix2[a].value && \
                       matrix1[j].suit  == matrix2[a].suit );

           if(criteria){
             return false;
           }else{
          }
         }    
      }
    }
  }
  return true;
}


void outputAllMatrix(Card matrix[], int N){
  for(int i=0;i<N;i++){
    if(i>0){
      cout << " ";
    }
    cout << matrix[i].suit << matrix[i].value;
  }
  cout << endl;
}


int main(void){
  
  int N_tot;
  cin >> N_tot;

  Card* matrix1 = new Card [N_tot];
  Card* matrix2 = new Card [N_tot];

  for(int i=0;i<N_tot;i++){
    cin >> matrix1[i].suit >> matrix1[i].value;
  }
  
  for(int i=0;i<N_tot;i++){
    matrix2[i] = matrix1[i];
  }

  bubbleSort(matrix1, N_tot);
  selectionSort(matrix2, N_tot);

  outputAllMatrix(matrix1,N_tot);
  cout << "Stable" << endl;

  outputAllMatrix(matrix2, N_tot);
  
  if(isStable(matrix1, matrix2, N_tot)){
      cout << "Stable" << endl;
  }else{
      cout << "Not stable" << endl;    
  }

  delete [] matrix1;
  delete [] matrix2;

  return 0;
}


Measured memory_bytes: 3092
using System;
class Calculate
{
    public bool solve(int[] a, int i, int m) {
        if (m == 0) {
            return true;
        }
        if (i >= a.Length) {
            return false;
        }
        bool res = solve(a, i + 1, m) || solve(a, i + 1, m - a[i]);
        return res;
    }
}
class C
{
    public static void Main() {
        int n, q;
        Calculate cal = new Calculate();
        n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++) {
            a[i] = int.Parse(input[i]);
        }
        q = int.Parse(Console.ReadLine());
        string[] input2 = Console.ReadLine().Split(' '); 
        for(int i = 0; i < q; i++) {
            if(cal.solve(a, 0, int.Parse(input2[i]))) {
                Console.WriteLine("yes");
            } else {
                Console.WriteLine("no");
            }
        }
    }
}


Measured memory_bytes: 8880
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr uint64_t INF = 1e18;

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

  int32_t N, K;
  cin >> N >> K;
  vector<int32_t> P(N,0);
  for (auto& p : P) {
    cin >> p;
  }
  sort(P.begin(), P.end());
  int32_t sum = 0;
  for (int i = 0; i < K; i++) {
    sum += P[i];
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3652
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;

void main() {
  int N, T; readlnTo(N, T);

  int ans = int.max;
  foreach(i; 0..N) {
    int c, t; readlnTo(c, t);
    if (t <= T)
      ans = min(c, ans);
  }

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

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}


Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  int o = (1 <= stoi(s.substr(0, 2))) && (stoi(s.substr(0, 2)) <= 12);
  int t = (1 <= stoi(s.substr(2, 2))) && (stoi(s.substr(2, 2)) <= 12);
  if (o && t) cout << "AMBIGUOUS" << '\n';
  else if (o) cout << "MMYY" << '\n';
  else if (t) cout << "YYMM" << '\n';
  else cout << "NA" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){
    int i,j,k,n,x,sum,count;
    while(true){
        cin>>n>>x;
        count=0;
        if(n==0 and x==0)break;
        for(i=1;i<n+1;i++){
            for(j=i+1;j<n+1;j++){
                for(k=j+1;k<n+1;k++){
                    sum=i+j+k;
                    if(sum==x){
                        count+=1;
                    }
               }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}




Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int a = 0, b = 0, an = 0, bn = 0;
    for (int i = 0; i < 4; i++) {
	int c = S[i];
	if (a == 0) {
	    a = c;
	    an++;
	} else if (c == a) {
	    an++;
	} else if (b == 0) {
	    b = c;
	    bn++;
	} else if (c == b) {
	    bn++;
	} else {
	    break;
	}
    }
    if (an == 2 && bn == 2) {
	cout << "Yes" << endl;
    } else {
	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    ll T,A,B,C,D;
    cin >> T;
    vector<string> ans;
    rep(i,T){
        set<ll> st;
        cin >> A >> B >> C >> D;
        if(D<B){
            ans.push_back("No");
            continue;
        }
        if(A<B){
            ans.push_back("No");
            continue;
        }
        if(B==1){
            ans.push_back("Yes");
            continue;
        }
        if(C>=B){
            ans.push_back("Yes");
            continue;
        }
        ll now = A%B;
        ll add = D%B;
        if(now>C){
            ans.push_back("No");
            continue;
        }
        if(add==0){
            ans.push_back("Yes");
            continue;
        }
        int cnt = 0;
        //mod B を考える
        bool ok = 1;
        ll dis;
        ll t;
        ll last;
        while(cnt<1000){
            cnt++;
            dis = B - now;
            t = dis/add;
            last = now + t*add;
            if(last==B)last -= add;
            if(last>C){
                ok = 0;
                ans.push_back("No");
                break;
            }
            now = (last + add) %B;
        }
        if(ok)ans.push_back("Yes");
    }
    for(auto x:ans)cout << x << endl;
}

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

int main(){
  int N;
  int X[110];
  cin >> N;
  for(int i = 0; i < N; i++) cin >> X[i];
  
  long long int ret = 10000000;
  long long int sum;
  for(int i = 0; i < 100; i++){
    sum = 0;
    for(int j = 0; j < N ; j++){
      sum += (i - X[j]) * (i - X[j]);
    }
    ret = min(ret, sum);
  }
  cout << ret;
}

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

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

  int ans = 0;
  for(int a=1; a<=k; a++) {
    for(int b=1; b<=k; b++) {
      for(int c=1; c<=k; c++) {
        ans += __gcd(__gcd(a,b), c);
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3624
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
const ll INF=1e16;
typedef pair<ll,pii> piii;

struct UF{
  vector<int> data;
  UF(int size):data(size,-1){}
  bool unite(int x,int y){
    x=root(x); y=root(y);
    if(x!=y){
      if(data[y]<data[x]) swap(x,y);
      data[x]+=data[y]; data[y]=x;
    }
    return x!=y;
  }
  bool findSet(int x,int y){return root(x)==root(y);}
  int root(int x){return data[x]<0?x:data[x]=root(data[x]);}
  int size(int x) {return -data[root(x)];}
};


int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,q;
  cin>>n>>q;
  vector<piii> es;
  vector<ll> w(n,INF);
  rep(i,q){
    ll a,b,c;
    cin>>a>>b>>c;
    es.eb(c,pii(a,b));
    MN(w[a],c+1);
    MN(w[b],c+2);
  }
  //cout<<w;
  rep(i,n*2) MN(w[(i+1)%n],w[i%n]+2);
  //cout<<w;
  rep(i,n) es.eb(w[i],pii(i,(i+1)%n));
  sort(all(es));
  UF uf(n);
  ll re=0;
  //cout<<es;
  for(piii p:es){
    if(uf.unite(p.Y.Y,p.Y.X)) re+=p.X;
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 10220
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn];

int main()
{
    IOS();
    ll n,x;
    cin>>n>>x;
    REP(i,n)cin>>d[i];
    sort(d,d+n);
    ll tt = 0;
    REP(i,n)
    {
      if(d[i] <= x)tt++,x-=d[i];
      else{
        cout<<tt<<endl;
        return 0;
      }
    }
    if(x != 0)tt--;
    cout<<tt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
#define INF (1<<26)

int segN=1000000;
struct data{
  int value;
  data* ch[2];
 
  void init(){
    value=INF;
    ch[0]=(data*)malloc(sizeof(data));
    ch[1]=(data*)malloc(sizeof(data));
    ch[0]->ch[0]=NULL;
    ch[1]->ch[0]=NULL;
  }
  
  void set(int i,int x,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(i<l || r<=i)return;
    if(x<value)value=x;
    if(r-l==1)return;
    ch[0]->set(i,x,l,m);
    ch[1]->set(i,x,m,r);
  }
   
  void set(int i,int x){
    set(i,x,0,segN);
  }
   
  int min(int a,int b,int l,int r){
    int m=(l+r)/2;
    if(ch[0]==NULL)init();
    if(b<=l || r<=a)return INF;
    if(a<=l && r<=b)return value;
    int lc=ch[0]->min(a,b,l,m);
    int rc=ch[1]->min(a,b,m,r);
    return (lc<rc?lc:rc);
  }
 
  int min(int a,int b){
    if(0<=a&&a<b)return min(a,b,0,segN);         
    else return INF;
  }
};
 
 
   
 
 
 
 
 


int rak[MAX+1];
int tmp[MAX+1];
int n,k;

bool compare_sa(int i,int j){
  if(rak[i]!=rak[j])return (rak[i]<rak[j]);
  else{
    int ri=(i+k<=n?rak[i+k]:-1);
    int rj=(j+k<=n?rak[j+k]:-1);
    return ri < rj;
  }
}

void construct_sa(string s,int *sa){
  n=s.size();
  for(int i=0;i<=n;i++){
    sa[i]=i;
    rak[i]=(i<n?s[i]:-1);
  }
  for(k=1;k<=n;k*=2){
    sort(sa,sa+n+1, compare_sa );
    tmp[sa[0]]=0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]]=tmp[sa[i-1]]+
        (compare_sa(sa[i-1],sa[i])?1:0);
    }
    for(int i=0;i<=n;i++)rak[i]=tmp[i];
  }
}


int search(string target,int *sa,string s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>=0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<0)return n+1;
  return l;
}

int search2(string target,int *sa,string s){
  int l=0,r=n,m;
  int size=target.size(),res;
  while(l<r){
    m=(l+r)/2;
    res=s.compare(sa[m],size,target);
    if(res>0)r=m;
    else l=m+1;
  }
  if(s.compare(sa[l],size,target)<=0)return n+1;
  return l;
}

data T,T2;
string s,s2;
string x,y;
int m;
int sa[MAX+1];
int sa2[MAX+1];

int main(){
  T.init();
  T2.init();
  cin>>s;
  s2=s;
  reverse(s2.begin(),s2.end());
  
  construct_sa(s2,sa2);
  construct_sa(s,sa);

  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa[i]<<' '<<s.substr(sa[i])<<endl;
  }
  for(int i=0;i<=n;i++){
    //cout<<i<<' '<<sa2[i]<<' '<<s2.substr(sa2[i])<<endl;
  }
  
  for(int i=0;i<=n;i++){
    T.set(i,sa[i]);
    T2.set(i,sa2[i]);
  }
  
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    reverse(y.begin(),y.end());
    int xl=search(x,sa,s),xr=search2(x,sa,s);
    int yl=search(y,sa2,s2),yr=search2(y,sa2,s2);
    int xs=x.size(),ys=y.size();
    int X=T.min(xl,xr);
    int Y=T2.min(yl,yr);
    if(Y!=INF)Y=n-Y;
    
    //cout<<xl<<' '<<xr<<' '<<X<<endl;
    //cout<<yl<<' '<<yr<<' '<<Y<<endl;

    if(Y<X+xs)cout<<0<<endl;
    else if(X==INF||Y==INF)cout<<0<<endl;
    else cout<<Y-X<<endl;
    
  }
    
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int val;
  scanf("%d", &val);
  int sum = 0;
  for (int i = val; i > 0; i /= 10) {
    sum += (i % 10);
  }
  printf("%s\n", (val % sum == 0) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n')))
    if len(s) == 4:
        print("Yes")
    elif len(s) == 2:
        if "N" in s and "S" in s:
            print("Yes")
        elif "E" in s and "W" in s:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
def main():
    s = input()
    n = int(input())
    
    t = []
    a = []
    for i in s:
        ord_i = ord(i)
        t.append(((123 - ord_i)%26, ord_i))
    
    for i in t:
        if n >= i[0]:
            a.append('a')
            n -= i[0]
        else:
            a.append(chr(i[1]))
            
    a[-1] = chr(ord(a[-1]) + n%26)
    print(''.join(a))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 11252
n = int(input())
a = list(map(int,input().split()))
A = sorted(a,reverse=True)
alice = []
bob = []
if n%2==0:
    for i in range(n//2):
        alice.append(A[0])
        A.pop(0)
        bob.append(A[0])
        A.pop(0)
    print(sum(alice)-sum(bob))
else:
    for i in range(n//2):
        alice.append(A[0])
        A.pop(0)
        bob.append(A[0])
        A.pop(0)
    alice.append(A[0])
    print(sum(alice)-sum(bob))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	print(num2alpha(N).lower())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

         
                    
using namespace std;
                     
#define rep(i,a,b); for(long long int i=a;i<b;i++)
#define mk make_pair        
#define LIMIT 100007
#define MOD 1000000007
#define ll long long int
#define endl '\n'
#define min3(a,b,c) ((a>b)?((b>c?c:b):(a>c?c:a)))
#define max3(a,b,c) ((a<b)?((b<c?c:b):(a<c?c:a)))
#define min(a,b) (a>b?b:a)
// #define x.first x.f
// #define x.second x.s
#define max(a,b) (a<b?b:a)
#define pb push_back
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<ll> v;

void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          v.pb(p); 
} 

ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return 2; 
  
    // iterate from 3 to sqrt(n) 
    for (ll i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return i; 
    } 
  
    return n; 
}

int main() 
{ 
    FAST
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t=1;
	while(1)
	{
		ll x;
		cin>>x;
		if(x==0) {cout<<t;
			return 0;
		}
		t++;
	}

    return 0; 
}  


Measured memory_bytes: 3540
n = gets.chomp.to_i
n.times do
  i = gets
  a, b, c = i.chomp.split
  a, b, c = a.to_i, b.to_i, c.to_i
  if (a**2 == (b**2 + c**2) || b**2 == (a**2 + c**2) || c**2 == (a**2 + b**2) )
    puts 'YES'
  else
    puts 'NO'
  end
end

Measured memory_bytes: 6108
n, q = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
point_list = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    point_list[p] += x

from collections import deque
d = deque()
d.append(0)
visited = set([])

while d:
    x = d.popleft()
    for child in graph[x]:
        if child not in visited:
            point_list[child] += point_list[x]
            d.append(child)
        visited.add(x)
print(*point_list)

Measured memory_bytes: 62872
n = int(input())
l, l1, l2 = list(""), list(""), list("")
for i in range(n):
    x, y = map(int, input().split())
    l1.append(x)
    l2.append(y)
for i in range(n - 1):
    for j in range(i + 1, n):
        l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5)
print('{:.10f}'.format(2 * sum(l) / n))

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n, m;
	cin>>n>>m;
	vint v(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		v[a-1]++;
		v[b-1]++;
	}
	bool ok = true;
	rep(i,n){
		ok &= v[i]%2==0;
	}
	cout<<(ok?"YES":"NO")<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 640