akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;
// Union-Find木
// 初期化 UF(N); Nは要素数
// 結合 unite(x,y); 同じ集合か判定 same(x,y);
// 集合の数 count
struct UnionFind {

  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vP xp(n), yp(n);
  rep(i, n){
    ll x, y;
    cin >> x >> y;
    xp[i] = {x, i};
    yp[i] = {y, i};
  }
  Sort(xp), Sort(yp);

  priority_queue<T, vT, greater<T>> to;
  rep(i, n-1){
    ll u = xp[i].second;
    ll v = xp[i+1].second;
    to.emplace(abs(xp[i].first - xp[i+1].first), u, v);
    u = yp[i].second;
    v = yp[i+1].second;
    to.emplace(abs(yp[i].first - yp[i+1].first), u, v);
  }

  ll ans = 0;
  UnionFind uf(n);
  while(uf.count() > 1){
    ll c, u, v;
    tie(c, u, v) = to.top();
    to.pop();
    if(!uf.same(u,v)){
      uf.unite(u,v);
      ans += c;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12688
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (auto &x : p) {
		cin >> x;
	}

	int s = accumulate(p.begin(), p.end(), 0);
	int m = *max_element(p.begin(), p.end());
	int ans = s - m / 2;
	cout << ans << endl;
}


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

template <int B> // (1 << B) >= MAX_LEN
struct lowest_common_ancestor {
    vector<vector<int>> graph;
    int N, root;
    int parent[B][1 << B], depth[1 << B];

    lowest_common_ancestor() {}
    void init(vector<vector<int>>& _graph, int _root) {
        graph = _graph;
        root = _root;

        N = graph.size();

        // set ancestors
        set_parent(root, -1, 0);
        for (int b = 1; b < B; ++b) {
            for (int i = 0; i < N; ++i) {
                if (parent[b-1][i] == -1) {
                    parent[b][i] = -1;
                } else {
                    parent[b][i] = parent[b-1][parent[b-1][i]];
                }
            }
        }
    }

    int query(int u, int v) {
        if (depth[u] > depth[v]) {
            int t = u; u = v; v = t;
        }

        for (int i = 0; i < B; ++i) {
            if ((((depth[v] - depth[u]) >> i) & 1) != 0) {
                v = parent[i][v];
            }
        } // depth[u] == depth[v]

        if (u == v) return u;

        for (int b = B-1; b >= 0; --b) {
            if (parent[b][u] != parent[b][v]) {
                u = parent[b][u];
                v = parent[b][v];
            }
        }

        return parent[0][u];
    }

private:
    void set_parent(int v, int p, int d) {
        parent[0][v] = p;
        depth[v] = d;
        for (const int& e : graph[v]) {
            if (e != p) {
                set_parent(e, v, d+1);
            }
        }
    }
};

int N;
vector<vector<int>> g;
lowest_common_ancestor<17> lca;

int main() {
    cin >> N; g.resize(N);
    for (int j = 0; j < N; ++j) {
        int k; cin >> k;
        for (int x = 0; x < k; ++x) {
            int c; cin >> c;
            g[j].push_back(c);
        }
    }

    lca.init(g, 0);
    int Q; cin >> Q;
    for (int j = 0; j < Q; ++j) {
        int u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
    return 0;
}

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

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

  vector<char> S( N );
  int count = 0;

  for( int i = 0; i < N; i++ ) {
    cin >> S.at( i );

  }

  for( int i = 0; i < N - 2; i++ ){
    if( S.at( i ) == 'A' && S.at( i + 1 ) == 'B' && S.at( i + 2 ) == 'C' ) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, ans = -1;

	cin >> A >> B;

	for (int price = 1; price < 1500; price++) {
		if (price * 8 / 100 == A &&
			price * 10 / 100 == B) {
			ans = price;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a>=13) cout<<b<<endl;
  else if(a<=5) cout<<0<<endl;
  else cout<<b/2<<endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 10000000000;

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

using namespace std;

//fixed << setprecision(10)

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



//満足度の最大値をDP[i]とする
vector<vector<ll>>dp(100100,vector<ll>(3));
vector<vector<ll>>a(100100,vector<ll>(3));


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

	rep(i, n)rep(j, 3)cin >> a[i][j];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)continue;

				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	ll ans = -INF;
	for (int i = 0; i < 3; i++)	chmax(ans, dp[n][i]);

	cout << ans << endl;
}

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

using namespace std;

int n, a[110];

int dp[100010][2];

int go(int k, bool turn) {

    if(dp[k][turn] != -1) return dp[k][turn];

    int ans = !turn ? 0 : 1;

    for(int i = 0; i < n; i++) {

        if(k >= a[i]) {
            if(!turn) {
                ans = max(ans, go(k - a[i], !turn));
            }
            else {
                ans = min(ans, go(k - a[i], !turn));
            }
        }

    }

    return dp[k][turn] = ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    int k;
    cin >> n >> k;

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

    memset(dp, -1, sizeof dp);

    cout << (go(k, 0) ? "First" : "Second") << endl;
};

/*
 * K
**/


Measured memory_bytes: 8832
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

const int maxn = 1e5 + 5;

int a[maxn];
int cnt[maxn];

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        scanf("%d",a + i);
        a[i]++;
        cnt[a[i]]++;
    }
    for(int i = 1;i <= n;i++){
        ans = max(ans,cnt[a[i]] + cnt[a[i] - 1] + cnt[a[i] + 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;

int main(){
    constexpr long long mod=1e9+7;
    typedef pair<int,long long> P;
    int N;cin>>N;
    vector<int> x(N);
    REP(i, N) cin >> x[i];
    vector<int> A(N),rank(N);
    A[0]=(x[0]-1);rank[0]=1;
    REP(i,N-1){
        A[i+1]=A[i]+x[i+1]-x[i]-1;
        rank[i+1]=max({rank[i],x[i]/2-A[i]+1,1});
    }
    // REP(i,N) cout<<A[i]<<" \n"[i==N-1];
    // REP(i,N) cout<<rank[i]<<" \n"[i==N-1];
    sort(All(rank));
    long long ans=1;
    REP(i,N){
        long long k=upper_bound(All(rank),i+1)-rank.begin();
        ans=ans*(k-i)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, X, L[111], x = 0, c = 1;

  std::cin >> N >> X;

  for (int i = 0; i < N; i ++) {
    std::cin >> L[i];

    x += L[i];

    if (x <= X)
      c ++;
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 888
def solve():
    from collections import deque
    from sys import stdin
    f_i = stdin
    
    N, M = map(int, f_i.readline().split())
    S = f_i.readline().rstrip()
    
    pos = N
    rec = deque()
    while pos:
        for move in range(M, 0, -1):
            next_pos = pos - move
            if next_pos >= 0 and S[next_pos] == '0':
                pos = next_pos
                rec.appendleft(move)
                break
        else:
            print(-1)
            break
    else:
        print(' '.join(str(move) for move in rec))

solve()

Measured memory_bytes: 10916
from math import sin, cos, radians
A, B, H, M = map(int, input().split())  # 時針Acm, 分針Bcm, H時M分
hour_hand_theta = (H*60+M)*0.5
minit_hand_theta = 6*M

# print(hour_hand_theta)
# print(minit_hand_theta)

# x1, y1をAの座標とする
x1 = A*cos(radians(hour_hand_theta))
y1 = A*sin(radians(hour_hand_theta))

# x2, y2をBの座標とする
x2 = B*cos(radians(minit_hand_theta))
y2 = B*sin(radians(minit_hand_theta))
# print("x1, y1 : ", x1, y1)
# print("x2, y2 : ", x2, y2)
ans = ((x1-x2)**2 + (y1-y2)**2) ** (1/2)
print(ans)


Measured memory_bytes: 9576
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Scan()
	texts := strings.Split(stdin.Text(), " ")
	text := GetStdin(texts)
	out := Run(text)
	fmt.Println(out)
}

func Run(data []string) string {
	ins := []int{}
	for _, d := range data {
		i, _ := strconv.Atoi(d)
		ins = append(ins, i)
	}
	sort.Ints(ins)
	return strconv.Itoa(ins[0] + ins[1])
}

func GetStdin(text []string) []string {
	if len(text) > 1 {
		return text
	}
	max, _ := strconv.ParseInt(text[0], 10, 64)
	var ret string
	for index := 0; index < int(max); index++ {
		stdin.Scan()
		ret += stdin.Text() + "\n"
	}
	return strings.Split(ret, "\n")
}

Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List
import Data.Char

solve k s = take (k-1) s ++ [toLower $ s!!(k-1)] ++ drop k s

main = solve <$> (read . head . tail . words <$> getLine) <*> getLine >>= putStrLn

Measured memory_bytes: 508
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e7+5+5e6;
using namespace std;
const ll INF=1e15+7;
const ll mod=998244353;
ll n,m,p;
ll dp[305][305];
ll num[maxn];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
    for(int i=0;i<=n;i++)
        for(int k=0;k<=n;k++) dp[i][k]=INF;
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=n-m;k++)
        {
            for(int j=0;j<i;j++)
            {
                dp[i][k]=min(dp[i][k],dp[j][k-1]+max(0ll,num[i]-num[j]));
            }
        }
    }
    //
    ll res=INF;
    for(int i=1;i<=n;i++)
        res=min(res,dp[i][n-m]);
    if(m==n) printf("0\n");
    else
        printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(;;){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			break;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			break;
		}
	}
	re 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}


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

int main(){
  char a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  if(a==f&&b==e&&c==d){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
/*
AizuOnline A2502
Title
*/
#include <stdio.h>
#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))

int m,n;
int s[394],l[394],p[394];
int maxlen,minlen;
int w;
int ans[394];
int result[394];
//
int find_kyoku(int len)  //len ga hanni nai de mottomo point no takai kyoku
{
        int i,max_;

        max_=-1;
        for(i=1;i<=m;i++)
        {
                if(len >= s[i] && len <= l[i] && max_ < p[i])
                        max_ = p[i];
        }
#ifdef DEBUG
        printf("L=%d R=%d\n",len,max_);
#endif

        return(max_);
}
int solve(int len,int depth)
{
        int i,ret,max_,find;

#ifdef DEBUG
        for(i=0;i<depth;i++)
                printf(":");
        printf("Len=%d \n",len);
#endif
        if(len==0)
                return(0);
        if(result[len]!=0)
                return(result[len]);
        max_ = 0;
        for(i=minlen;i<=min(maxlen,len);i++)
        {
                if((find=find_kyoku(i))!=-1)
                        ret=solve(len-i,depth+1)+find;
                if(max_ < ret)
                        max_ = ret;
        }
        result[len]=max_;
#ifdef DEBUG
        for(i=0;i<depth;i++)
                printf(":");
        printf("ret=%d\n",max_);
#endif
        return(max_);
}
void init()
{
        int i;
        for(i=1;i<=393;i++)
                result[i]=0;
        for(i=1;i<minlen;i++)
                result[i]=-1;
}
main()
{
        int i;


        scanf("%d",&m);
        maxlen=0;minlen=INT_MAX;
        for(i=1;i<=m;i++)
        {
                scanf("%d %d %d",&s[i],&l[i],&p[i]);
                if(s[i]<minlen)
                        minlen=s[i];
                if(s[i]>maxlen)
                        maxlen=l[i];
        }

        init();
        scanf("%d",&n);
        for(i=1;i<100;i++)
                solve(i,0);
#ifdef DUMP
        for(i=1;i<100;i++)
                printf("%d:%d|",i,result[i]);
#endif
        for(i=1;i<=n;i++)
        {
                scanf("%d",&w);
                ans[i]=solve(w,0);
                if(ans[i]==-1)
                        goto NG;
        }
        for(i=1;i<=n;i++)
                printf("%d\n",ans[i]);
        return(0);
NG:
        printf("-1\n");
        return(0);
}

Measured memory_bytes: 628
import std.stdio;
import std.string;
import std.conv;

int main()
{
	string s;
	int i= 0;
	int stack[];
	stack.length = 10;
	while((s = readln()).length != 0)
	{
		int line = s.chomp.to!int;

		if(line == 0)
		{
			i--;
			writeln(stack[i]);
		}
		else
		{
			stack[i] = line;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 1052
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N, P = map(int, readline().split())
    S = [int(i) for i in readline().strip()[::-1]]

    ans = 0
    if P == 2 or P == 5:
        for i, s in enumerate(S):
            if s % P == 0:
                ans += N - i
        print(ans)
        exit()

    a = {}
    a[0] = 1
    t = 0
    x = 1
    for s in S:
        t += s * x
        t %= P
        
        if t in a:
            a[t] += 1
        else:
            a[t] = 1

        x *= 10
        x %= P
    
    ans = 0
    for v in a.values():
        ans += v * (v-1) // 2
    
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    int s = (N+1000)/1000;
    if(N%1000==0){
        cout << 0 << endl;
      return 0;
    }
    cerr << s << endl;
    cout << 1000*s-N << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long double ld;

const int Maxn = 205;
const int Maxm = 40005;
const int Inf = 1000000000;

int n;
int t[Maxn], v[Maxn];
int mx[Maxm];
int dp[Maxm][Maxn];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &t[i]); t[i] *= 2;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]); v[i] *= 2;
	}
	int cur = 0;
	for (int i = 0; i < n; i++) {
		for (int j = cur; j < cur + t[i]; j++)
			mx[j] = v[i];
		cur += t[i];
	}
	fill((int*)dp, (int*)dp + Maxm * Maxn, -Inf);
	dp[0][0] = 0;
	for (int i = 0; i < cur; i++)
		for (int j = 0; j < Maxn; j++) if (dp[i][j] > -Inf && j <= mx[i]) {
			if (j > 0) dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + j + j - 1);
			if (j + 1 <= mx[i]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + j + j + 1);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + j + j);
		}
	cout << fixed << setprecision(20) << ld(dp[cur][0]) / ld(8) << endl;
	return 0;
}

Measured memory_bytes: 32384
#include <iostream>
using namespace std;
int main()
{
	double w,h,x,y,ans=0;
	double ANS;
	cin >> w >> h >> x >> y;

	ANS = w*h/2;
	if(w/2==x && h/2==y){
		ans=1;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> heights(n + 2, 0);
	vector<int> dp(n + 2, 0);

	for (int i = 0; i < n; ++i)
	{
		cin >> heights[i + 2];
	}
	heights[0] = heights[1] = heights[2];

	for (int i = 0; i < n; ++i)
	{
		dp[i + 2] = min(dp[i] + abs(heights[i] - heights[i + 2]), dp[i + 1] + abs(heights[i + 1] - heights[i + 2]));
	}

	cout << dp.back();

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
     
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
const ll MOD2 = 1e9 + 7;
const int MOD = 1e9 + 7;
 
const ull infull = numeric_limits<unsigned long long>::max();
 
void fix(int &x, ll MOD) {
    x = (x % MOD);
    if(x < 0) x += MOD;
    return;
}
 
ll lgput(ll a, ll b, ll MOD) {
    ll ret = 1;
    a %= MOD;
    while(b) {
        if(b&1) ret = ret*a % MOD;
        a = a*a % MOD;
        b >>= 1;
    }
 
    return ret;
}
 
ll inv(ll a, ll MOD) {
    return lgput(a, MOD-2, MOD);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;

int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));

    ll n, a, b;
    cin >> n >> a >> b;

    if(a > b) swap(a, b);

    if((b - a) % 2 == 0) {
        cout << (b - a) / 2 << '\n';
        return 0;
    }

    /// il mutam pe a pe 1 si mai mutam odata pe b

    cout << min(a + (b-a-1)/2, (n-b+1) + (n - (a + (n-b+1)))/2);
    return 0; 
}

Measured memory_bytes: 256
from collections import defaultdict

N, W = map(int, input().split())
wv = defaultdict(list)
for _ in range(N):
    w, v = map(int, input().split())
    wv[w].append(v)

for k in wv.keys():
    wv[k].sort(reverse=True)

kw = list(wv.keys())
kw.sort()
l = [len(wv[k]) for k in kw]
l = l + (4 - len(l)) * [0]
# print(l)

ans = 0
for i in range(l[0] + 1):
    wi = kw[0] * i
    if W < wi:
        break
    vi = sum(wv[kw[0]][:i])
    if l[1] == 0:
        ans = max(ans, vi)
    for j in range(l[1] + 1):
        if 2 <= len(kw):
            wj = wi + kw[1] * j
            if W < wj:
                break
            vj = vi + sum(wv[kw[1]][:j])
            if l[2] == 0:
                ans = max(ans, vj)
            for k in range(l[2] + 1):
                if 3 <= len(kw):
                    wk = wj + kw[2] * k
                    if W < wk:
                        break
                    vk = vj + sum(wv[kw[2]][:k])
                    if l[3] == 0:
                        ans = max(ans, vk)
                    for m in range(l[3] + 1):
                        if 4 <= len(kw):
                            wm = wk + kw[3] * m
                            if W < wm:
                                break
                            vm = vk + sum(wv[kw[3]][:m])
                            ans = max(ans, vm)
print(ans)


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;
ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return mod_pow(x * x % MOD, n / 2) % MOD;
    else return x * mod_pow(x, (n - 1)) % MOD;
}
ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    ll ret = 1;
    while (n) if (n & 1) ret = ret * x % MOD; x = x * x % MOD; n /= 2;
    return ret;
}
ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) ret *= (i + 1); ret %= MOD;
    return ret;
}
ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);
    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}
void solve() {
    int r; cin >> r;
    cout << 2 * 3.14159265358979323846 * r;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3760
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        mut l: usize,
    }
    let mut r = 1;
    let mut m = 1;
    while 2 * m <= l {
        r += 1;
        m *= 2;
    }
    let mut edges = vec![];
    for i in 1..r {
        edges.push((i - 1, i, 0));
        edges.push((i - 1, i, 2usize.pow(i - 1)));
    }
    for i in (1..r).rev() {
        if l - 2usize.pow(i - 1) >= 2usize.pow(r - 1) {
            edges.push((i - 1, r - 1, l - 2usize.pow(i - 1)));
            l -= 2usize.pow(i - 1);
        }
    }
    println!("{} {}", r, edges.len());
    for &(u, v, d) in &edges {
        println!("{} {} {}", u + 1, v + 1, d);
    }
}


Measured memory_bytes: 2196
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a;
    a.sort();
    puts!("{}\n", a[n / 2] - a[n / 2 - 1]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    
    long long a[N];
    long long sum=0,mae=0,ans=1e18;
 
    for(int i=0;i<N;i++){
        cin >>a[i];
        sum+=a[i];
    }
    for(int i=0;i<N;i++){
        mae+=a[i];
        if(i+1<N)ans=min(ans,abs(sum-mae*2));
    }
        cout<<ans<<endl;
}

Measured memory_bytes: 1792
s = input()
x = len(s)
for i in range(x-2):
    n = s[i:i+3]
    m = list(set(n))
    if len(m) == 2:
        print(i+1,i+3)
        exit(0)
if x == 2:
    if s[0] == s[1]:
        print(1,2)
        exit(0)
print(-1,-1)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
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; }

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
    ll A,B; cin >> A >> B;
    map< int64_t, int > mp, mpa = prime_factor(A), mpb = prime_factor(B);
    for(auto itr : mpa){
        chmax(mp[itr.first], itr.second);
    }
    for(auto itr : mpb){
        chmax(mp[itr.first], itr.second);
    }
    ll res = 1;
    for(auto itr : mp){
        res *= pow(itr.first,itr.second);
    }
    cout << res;
}

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

int main(){
    int N,L;
    cin >> N >> L;
    string s[101];
    for(int i=0; i<N; i++){
        cin >> s[i];
    }
    sort(s,s+N);
    for(int i=0; i<N; i++){
        cout << s[i];
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  string s;
  vector<string> ss;
  int k;
  cin >> s >> k;
  REP(i,s.size()){
    REP(j,6){
      if (s.size()-i>j) ss.push_back(s.substr(i,j+1));
    }
  }
  SORT(ss);
  UNIQ(ss);
  cout << ss[k-1];
  return 0;
}

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

int main(){
  char N;
  cin >> N;
  if(N=='A'||N=='B'||N=='C'||N=='D'||N=='E'||N=='F'||N=='G'||N=='H'||N=='I'||N=='J'||N=='K'||N=='L'||N=='M'||N=='N'||N=='O'||N=='P'||N=='Q'||N=='R'||N=='S'||N=='T'||N=='U'||N=='V'||N=='W'||N=='X'||N=='Y'||N=='Z'){
    cout << "A" << endl;
  }
  else{
    cout << "a" << endl;
  }
}

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

namespace MSolutionA
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine((CIN.Int()-2)*180);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline ll readll(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

const int N=305;
const ll inf=1e18;
int n,k,a[N],a2[N],m,id[N],id2[N];
ll f[N][N],c[N][N],c2[N][N];

inline void upd(ri i,ri x,ll y){for(;x<=m;x+=x&(-x))c[x][i]=min(c[x][i],y);}
inline void upd2(ri i,ri x,ll y){for(;x<=m;x+=x&(-x))c2[x][i]=min(c2[x][i],y);}
inline ll qry(ri i,ri x){ll y=inf;for(;x;x-=x&(-x))y=min(y,c[x][i]);return y;}
inline ll qry2(ri i,ri x){ll y=inf;for(;x;x-=x&(-x))y=min(y,c2[x][i]);return y;}

inline void init(){
	rep(i,0,m)rep(j,0,n)c[i][j]=c2[i][j]=inf;
}

int main()
{
	n=read();k=read();
	rep(i,1,n)a[i]=read(),a2[i]=a[i];
	sort(a2+1,a2+n+1);m=unique(a2+1,a2+n+1)-a2-1;
	rep(i,1,n)id[i]=lower_bound(a2+1,a2+m+1,a[i])-a2,id2[i]=m+1-id[i];
	init();
	rep(i,1,n){
		REP(j,n-k,2){
			f[i][j]=min(qry(j-1,id[i])+a[i],qry2(j-1,id2[i]));
			upd(j,id[i],f[i][j]-a[i]);
			upd2(j,id2[i],f[i][j]);
		}
		f[i][1]=a[i],upd(1,id[i],f[i][1]-a[i]),upd2(1,id2[i],f[i][1]);
	}ll ans=inf;
	rep(i,1,n)ans=min(ans,f[i][n-k]);
	printf("%lld\n",ans);
	return 0; 
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/


signed main(){
  int n;
  cin>>n;
  vi a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
  vi x(n,-1);
  rep(i,n){
    x[i]=(c.end()-upper_bound(all(c),b[i]));
  }
  rep(i,n-1) x[i+1]+=x[i];
  
  int ans=0;
  rep(i,n){
    int l=upper_bound(all(b),a[i])-b.begin();//b[l]~b[n-1] n-l個
    if(l>0) ans+=x[n-1]-x[l-1];
    else ans+=x[n-1];
    // cout<<l<<endl;
  }
  // rep(i,n) cout<<x[i]<<' ';
  // cout<<endl;
  cout<<ans<<endl;

  return 0;
}

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

int main(){
    int n; cin >> n;
    int sum = 0;

    for(int i = n; i > 0; i /= 10){
        sum += i % 10;
    }

    if(n % sum == 0){
        put("Yes");
    }else{
        put("No");
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int n = in.nextInt();
			if(n==0) return ;
			int ans = -1;
			long masks[] = new long[n];
			long frees[] = new long [30];
			for(int i=0; i<n; i++){
				int f = in.nextInt();
				for(int j=0; j<f; j++){
					frees[in.nextInt()-1] |= 1L<<i;
				}
			}
			for(int i=0; i<n; i++) masks[i] |= 1L<<i;
			for(int i=0; i<30; i++){
				long mask=0;
				for(int j=0; j<n; j++)if((frees[i] & (1L<<j)) > 0){
					mask |= masks[j];
				}
				if(Long.bitCount(mask)==n){
					ans = i+1;
					break;
				}
				for(int j=0; j<n; j++)if((frees[i] & (1L<<j)) > 0){
					masks[j] |= mask;
				}
			}
			System.out.println(ans);
		}
	}
	
}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

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

    vector<lint> h(N);
    REP(i, N) {
      lint x; cin >> x; h[i] = x;
    }

    lint res = 0;

    lint idx = 0;

    while(idx < N) {
      lint val = h[idx];
      
      if(h[idx] == 0) {
        idx++;
        continue;
      }

      lint end_idx = idx;
      while(true) {
        if(end_idx == N-1) {
          break;
        }
        if(h[end_idx+1] == 0) {
          break;
        }
        end_idx++;
        val = min(val, h[end_idx]);
      }

      res += val;

      FOR(i, idx, end_idx+1) {
        h[i] -= val;
      }
    }

    PRINT(res);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

int main(){


	int N, D, X; std::cin >> N >> D >> X;
	int ans = 0;
	rep(i, N){
		int A; std::cin >> A;
		ans += ((D - 1) / A + 1);
	}

	std::cout << ans + X;


	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
l=1
r=N
dis=set()
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.add(a)
        dis.add(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1

Measured memory_bytes: 17444
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b= read::<usize>();

    let diff = b - a;
    let mut height = 0_usize;

    for i in 0..(b-a) {
        height += i;
    }
    println!("{}", height-a);
}



Measured memory_bytes: 4352
#include <stdio.h>
#include<math.h>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	int n,m,from,to,tmp,count;
	queue<int> Q;

	while(true){
		scanf("%d",&n);
		scanf("%d",&m);
		if(n == 0 && m == 0)break;

		count = 0;

		int table[n+1][n+1],checkTable[n+1];

		for(int i=0; i < n+1; i++){
			checkTable[i] = 0;
			for(int k=0; k < n+1; k++){
				table[i][k] = 0;
			}
		}

		for(int i=0; i < m; i++){
			scanf("%d %d",&from,&to);
			table[from][to] = 1;
			table[to][from] = 1;
		}

		for(int i=2; i <= n; i++){
			if(table[1][i] == 1){
				Q.push(i);
				checkTable[i] = 1;
				count++;
			}
		}


		while(!Q.empty()){
			tmp = Q.front();
			Q.pop();

			for(int i=2; i <= n; i++){
				if(table[tmp][i] == 1 && checkTable[i] == 0){
					checkTable[i] = 1;
					count++;
				}
			}
		}

		printf("%d\n",count);

	}

    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int i;
    int count = 0;

    for(i=1;i<=N;i++){
        string s = to_string(i);
        int size = s.size();
        if(size % 2 == 1){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
}
int n;
char s[N];
void input()
{
	n=read<int>();
	scanf("%s",s+1);
}
typedef unsigned long long ull;
//typedef pair<ull,ull>pii;
map<ull,int>mp;
const ull base=661;
void add(int p)
{
	ull Hash1=1,Hash2=3;
	For(i,1,n)
	{
		if((p>>(i-1))&1)Hash1=Hash1*base+s[i];
		else Hash2=Hash2*base+s[i];
	}
	mp[Hash1*Hash2]++;
}
ll ans;
void cal(int p)
{
	ull Hash1=1,Hash2=3;
	For(i,1,n)
	{
		if((p>>(i-1))&1)Hash1=Hash1*base+s[n*2-i+1];
		else Hash2=Hash2*base+s[n*2-i+1];
	}
	ans+=mp[Hash1*Hash2];
}
void work()
{
	int Max=(1<<n)-1;
	For(i,0,Max)add(i);
	For(i,0,Max)cal(i);
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int[] x = new int[N];
		int[] y = new int[M];

		for(int i=0;i<N;i++) {
			x[i]=sc.nextInt();
		}

		for(int i=0;i<M;i++) {
			y[i]=sc.nextInt();
		}

		Arrays.sort(x);
		Arrays.sort(y);

		int K = Y-X;

		for(int i=1; i<=K; i++) {
			if(x[N-1]<X+i && X+i<=y[0]) {
				System.out.print("No War"); break;
			}
			if(i==K) System.out.print("War");

		}
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	static long gcd(int u,int v){
		int r = u%v;
		if(r == 0) {
			return v;
		}else {
			return gcd(v,r);
		}
	}


	void main() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			long g = gcd(a,b);
			long l = a*(b/g);
			System.out.println(g + " " + l);
		}
	}

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

}



Measured memory_bytes: 26180