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

const bool DEBUG = false;

long long X;

void input() { cin >> X; }

int main(int argc, char const *argv[]) {
  input();

  long long num500 = X / 500;
  long long rest = X % 500;
  long long num5 = rest / 5;

  cout << num500 * 1000 + num5 * 5 << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main() {

	int i,j;
	int times;
	for (i = 1; i < 10; i++) {

		for (j = 1; j < 10; j++) {
			times = i * j;
			std::cout << i << "x" << j << "=" << times << std::endl;
		}
		
	}

	return 0;
}


Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int b[100],c[100],a[100];
	for(int i=0;i<n;i++)
	cin>>b[i];
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		a[i]=i+1;
	}
	int m=1,top1,top2;
	bool p1=true,p2=true;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		p1=false;
	}
	if(p1)
	top1=m;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=c[i])
		p2=false;
	}
	if(p2)
	top2=m;
	while(next_permutation(a,a+n))
	{
		m++;
		bool p1=true,p2=true;
		for(int i=0;i<n;i++)
		{
			if(a[i]!=b[i])
			p1=false;
		}
		if(p1)
		top1=m;
		for(int i=0;i<n;i++)
		{
			if(a[i]!=c[i])
			p2=false;
		}
		if(p2)
		top2=m;
	}
	cout<<abs(top1-top2);
}

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

int main()
{
    int n;
    scanf("%d", &n);

    int taro_score = 0;
    int hanako_score = 0;

    char taro_card[101];
    char hanako_card[101];

    int i;
    for (i = 0; i < n; i++) {
        scanf("%s", taro_card);
        scanf("%s", hanako_card);

        if (strcmp(taro_card, hanako_card) == 0) {
            taro_score += 1;
            hanako_score += 1;
        } else if (0 < strcmp(taro_card, hanako_card)) {
            taro_score += 3;
        } else if (strcmp(taro_card, hanako_card) < 0) {
            hanako_score += 3;
        }

    }

    printf("%d %d\n", taro_score, hanako_score);

    return 0;
}



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

int main(){
  int N;
  string S, T;
  cin >> N >> S >> T;
    rep(i,N){
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

const int MOD = 998244353;
inline int add(int a, int b){ return (a+b)%MOD; }
inline int sub(int a, int b){ return ((a-b)%MOD + MOD)%MOD; }
inline int mul(int a, int b){ return ((ll)a*b)%MOD; }

int n, s;
vector<int> a;
v2<int> dp;

int f(int index, int sum){
    if(sum < 0) return 0;
    if(index==-1) return sum==0;
    if(dp[index][sum] != -1) return dp[index][sum];

    dp[index][sum] = add(mul(2,f(index-1, sum)), f(index-1, sum-a[index]));
    return dp[index][sum];
}

void solve(){
    cin >> n >> s;
    a = vector<int>(n);
    for(int i = 0; i < n; ++i) cin >> a[i];

    dp = fill(n, s+1, -1);
    cout << f(n-1, s) << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

int main(void) {
    using namespace std;

    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        int sum = 0;
        int score;
        for (int i = 0 ; i < n / 4 ; i++) {
            cin >> score;
            sum += score;
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 3048
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
int dp[101010];
int h[101010];

int rec(int now) {
  if (now == N) return 0;
  if (dp[now] >= 0) return dp[now];
  int res = rec(now + 1) + abs(h[now] - h[now + 1]);
  if (now + 2 <= N) res = min(res, rec(now + 2) + abs(h[now] - h[now + 2]));
  return dp[now] = res;
}

signed main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> h[i];
  mm(dp);

  cout << rec(1) << endl;
  return 0;
}


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

int main() {
    int N, numerator, denominator = 0;
    cin >> N;
    numerator = N;
    for(int i = 8; i >= 0; i--){
        int number = 0;
        number = N / std::pow(10, i);
        denominator += number;
        N -= number * std::pow(10, i);
    }
    if((numerator % denominator) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
void solve(std::string S){
    bool s1 = S[0] == 'R';
    bool s2 = S[1] == 'R';
    bool s3 = S[2] == 'R';
    if( s1 && s2 && s3){
      cout << 3 << endl;
    } else if(!( s1 || s2 || s3)){
      cout << 0 << endl;
    } else if(s2 && (s1 || s3)){
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
}
 
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int V, E;
    cin >> V >> E;

    vector<vector<ll>> dp(V, vector<ll>(V, INF));

    rep(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        dp[s][t] = d;        
    }

    rep(i, V) dp[i][i] = 0;

    rep(k, V) {
        rep(i, V) {
            rep(j, V) {
                if (dp[i][k] == INF || dp[k][j] == INF) continue;
                chmin(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    bool flag = true;
    rep(i, V) if (dp[i][i] < 0) flag = false;
    if (!flag) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    } 
    rep(i, V) {
        rep(j, V) {
            if (dp[i][j] == INF) {
                cout << "INF";
            }
            else cout << dp[i][j];
            if (j != V - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3248
#include"bits/stdc++.h"
using namespace std;

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

    vector<pair<long long, long long>> p(N);
    long long sum = 0, min_second = INT_MAX;
    bool all_same = true;
    for (int i = 0; i < N; i++) {
        cin >> p[i].first >> p[i].second;
        sum += p[i].first;
        if (p[i].first != p[i].second) {
            all_same = false;
        }
    }
    if (all_same) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (p[i].first > p[i].second) {
            min_second = min(min_second, p[i].second);
        }
    }


    cout << sum - min_second << endl;
}

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

int main(){
	int k;
	cin >> k;
	if(k%2==0){
		cout << (k/2)*(k/2) << endl;
	}else{
		cout << ((k+1)/2)*(k/2) << endl;
	}
    return 0;
}



Measured memory_bytes: 256
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "money", long, "stack");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto a = new string[](h);
    iota(h).each!(x => a[x] = sread());

    long[char] cntalf;

    foreach (e; a)
    {
        foreach (f; e)
        {
            if (f in cntalf)
                cntalf[f] += 1;
            else
                cntalf[f] = 1;
        }
    }
    long cnt4, cnt2, cnt1;
    foreach (key, value; cntalf)
    {
        cnt4 += value / 4;
        cnt2 += (value % 4) / 2;
        cnt1 += value % 2;
    }
    bool check = true;
    long need4 = (h / 2) * (w / 2), need2 = (h % 2) * (w / 2) + (w % 2) * (h / 2),
        need1 = (h % 2) * (w % 2);

    if (need4 > cnt4)
        check = false;

    cnt2 += (cnt4 - need4) * 2;

    if (need2 > cnt2)
        check = false;

    if (need1 > cnt1)
        check = false;

    if (check)
        writeln("Yes");
    else
        writeln("No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

typedef pair<int, int> pi;

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

set<pi> stars;
pi starmap[201];

int main(){
    while(1){
        stars=set<pi>();
        FOR(i,201){
            starmap[i]=pi();
        }
    int m, n;
    cin>>m;
        if(m==0)return 0;
    FOR(i, m){
        int x, y;
        cin>>x>>y;
        starmap[i]=pi(x, y);
    }
    cin>>n;
    FOR(i, n){
        int x, y;
        cin>>x>>y;
        stars.insert(pi(x, y));
    }
    for(auto itr = stars.begin(); itr != stars.end(); ++itr){
        int dx, dy;
        dx= itr->first-starmap[0].first;
        dy=itr->second-starmap[0].second;
        FOR(j,m){
            if(j==0)continue;
            pi tmp=pi(starmap[j].first+dx, starmap[j].second+dy);
            if(stars.find(tmp)==stars.end())break;
            if(j==m-1){
                cout<<dx<<" "<<dy<<endl;
                j=m;
                itr=stars.end();
            }
        }
    }
    }
    return 0;
}
        


Measured memory_bytes: 3152
S=input()
N = len(S) + 1
ary = [0] * N
for i in range(N-1):
    if S[i] == "<":
        ary[i+1] = ary[i] + 1

for i in range(N-2,-1,-1):
    if S[i] == ">":
        ary[i] = max(ary[i], ary[i+1] + 1)

print(sum(ary))

Measured memory_bytes: 46320
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int dp[100009];

void DP(int x){
    for(int i=N;i-x>=0;i--){
        if(dp[i-x]!=INF) chmin(dp[i],dp[i-x]+1);
    }
}

void calc(int x){
    int n=1;
    while(n*x<=N) n*=x;
    while(n>=x){
        rep(i,x-1){
            DP(n);
        }
        n/=x;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N+1) dp[i]=INF;
    dp[0]=0;
    
    calc(9);
    calc(6);
    rep(i,N) chmin(dp[i+1],dp[i]+1);
    cout1(dp[N])
}

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

bool inv(string s,int i){
  for (char c:s){
    if (c==(i+'a')){
      return true;
    }
  }
  return false;
}

int shu(string s,string t){
  int a=0;
  for (int i=0;i<26;i++){
    if(inv(s,i) and inv(t,i)){
      a++;
    }
  }
  return a;
}


int main(){
  int N;
  cin >> N;
  string s,t="";
  cin >> s;
  int ans=0;
  while(s!=""){
    t.push_back(s.back());
    s.pop_back();
    ans=max(shu(s,t),ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
using namespace std;
typedef pair<double,double> P;
int n;
double x[50000],r[50000];
vector<P> seg;
double eps=1e-9;
bool check(double m){
	seg.clear();
	rep(i,n){
		if(r[i]<m) continue;
		seg.push_back(P(x[i]-sqrt(r[i]*r[i]-m*m),x[i]+sqrt(r[i]*r[i]-m*m)));
	}
	sort(seg.begin(),seg.end());
	if(seg.size()==0) return false;
	double mx=0,nowl=seg[0].fs,nowr=seg[0].sc;
	rep(i,seg.size()){
		if(nowr+eps<seg[i].fs){
			mx=max(mx,nowr-nowl);
			nowl=seg[i].fs,nowr=seg[i].sc;
		}else{
			nowr=max(nowr,seg[i].sc);
		}
	}
	mx=max(mx,nowr-nowl);
	if(mx>m*2) return true;
	return false;
}
int main(){
	while(true){
		cin>>n;
		if(n==0) break;
		rep(i,n) cin>>x[i]>>r[i];
		double ub=100000,lb=0;
		while(ub-lb>0.00000001){
			double m=(ub+lb)/2;
			if(check(m)) lb=m;
			else ub=m;
		}
		printf("%.12f\n",ub*2);
	}
}

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;

template <class T>
T GCD(T a, T b) { return b == 0 ? a : GCD(b, a%b); }

int main()
{
  ll A, B, C, D; cin >> A >> B >> C >> D;

  ll l = C*D/GCD(C, D);
  cout << (B-A+1) - ((B/C + B/D - B/(l)) - ((A-1)/C + (A-1)/D - (A-1)/(l))) << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
const int maxn=1e6; 
int LIS(int a[],int n){
	int d[maxn]={0},len=0;
	d[len++]=a[0];
	for(int i=1;i<n;i++){
		if(a[i]<d[len-1]){
			d[len++]=a[i];
		}
		else{
			int pos=lower_bound(d,d+len,a[i])-d;
			d[pos]=a[i];
		}
	}
	return len;
}

int main(){
	int a[maxn],n;
	read(n);
	for(int i=0;i<n;i++) read(a[i]);
	cout<<LIS(a,n)<<endl;
	exit(0);
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string s;
  int n,i,j,ret=0,a6=6,a9=9,nn;
  cin >> n;
  int dp[n+1];
  for(i=0;i<n+1;i++)dp[i]=i;
  for(i=0;i<n+1;i++){
    a6=a9=1;
    for(j=0;j<=6;j++){
      a6*=6;
      if(i+a6>n)continue;
      dp[i+a6]=min(dp[i]+1,dp[i+a6]);
    }
    for(j=0;j<=5;j++){
      a9*=9;
      if(i+a9>n)continue;
      dp[i+a9]=min(dp[i]+1,dp[i+a9]);
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 640
# coding: utf-8
import math
#a, d = map(int,input().split())
N = int(input())
S = input()
ans = 0
x = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    elif S[i] == "D":
        x -= 1
    ans = max(ans, x)

print(ans)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a), std::greater<>());

	int sum = std::accumulate(begin(a), end(a), 0);
	for(int i = 0; i < m; i++) {
		if(a[i] * 4 * m >= sum)  continue;
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    } 
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); } 
    int size(int x) { return -d[find(x)]; }
};


int main() {
    int N, M, K; cin >> N >> M >> K;
    UnionFind uf(N);
    vector<int> ng1(N); 
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        A--, B--;
        uf.unite(A, B);
        ng1[A]++;
        ng1[B]++;
    }

    vector<int> ng2[N];
    for (int i = 0; i < K; i++) {
        int C, D; cin >> C >> D;
        C--, D--;
        ng2[C].push_back(D);
        ng2[D].push_back(C);
    }

    
    for (int i = 0; i < N; i++) {
        int ans = uf.size(i) - 1 - ng1[i];
        for (int j : ng2[i]) {
            if (uf.same(i, j)) ans--;
        }
        if (i) cout << " ";
        cout << ans;
    }
    cout << endl;
}

Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=1e5+5;
int h[maxn],m,n,ma[maxn];
//vector<ll > g[maxn];
int main()
{
 cin>>n>>m;
 for(int i=1;i<=n;i++) cin>>h[i];
 for(int i=1;i<=m;i++) 
 {
 	 int a,b;
	  cin>>a>>b;
	 ma[a]=max(ma[a],h[b]);
	 ma[b]=max(ma[b],h[a]);
 }
ll ans=0;
for(int i=1;i<=n;i++)
{
	ans+=h[i]>ma[i];
}
cout<<ans;
return 0;
}

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

typedef struct{
    string name;
    int Rank,idx;
} food;

food d[105];

bool cmp(food x,food y)
{
    if(x.name<y.name)
        return true;
    if(x.name==y.name)
    {
        if(x.Rank>y.Rank)
            return true;
    }
    return false;
}
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> d[i].name >> d[i].Rank;
        d[i].idx=i;
    }
    sort(d+1,d+n+1,cmp);
    for(int i=1;i<=n;i++)
        cout << d[i].idx << '\n';
    return 0;
}

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

class Program {
    static void Main (string[] args) {
        var input = Console.ReadLine().Split(' ');

        Console.WriteLine(input[0].Substring(0,3));
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}


Measured memory_bytes: 25796
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll h,w;
    cin>>h>>w;
    string stra[h];
    rep(i,h) cin>>stra[i];
    vector<vector<ll>> v(h,vector<ll> (w));
    rep(i,h) rep(j,w) v[i][j]=0;
    rep(i,h) rep(j,w) if(stra[i][j]=='#') v[i][j]=INF;
    rep(i,h) rep(j,w){
        if(stra[i][j]=='#'){
            if(i>=1) v[i-1][j]++;
            if(j>=1) v[i][j-1]++;
            if(i<=h-2) v[i+1][j]++;
            if(j<=w-2) v[i][j+1]++;
            if(i>=1&&j>=1) v[i-1][j-1]++;
            if(i>=1&&j<=w-2) v[i-1][j+1]++;
            if(i<=h-2&&j>=1) v[i+1][j-1]++;
            if(i<=h-2&&j<=w-2) v[i+1][j+1]++;
        }
    }
    rep(i,h) {
        rep(j,w) {
        if(v[i][j]>=INF) cout<<'#';
        else cout<<v[i][j];
        }
        cout<<endl;
    }

    //cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;




int main(){
    vector<ll> k;
    for(int i=1;i<=9;i++){
        for(int t=0;t<=9;t++){
            for(int h=0;h<=9;h++){
                ll a=i*10001;
                a+=t*1010;
                a+=h*100;
                k.push_back(a);
            }
        }
    }
    ll a,b;
    cin>>a>>b;
    ll count=0;
    for(int i=0;i<k.size();i++){
        if(a<=k[i] && k[i]<=b){count++;}
    }
    cout<<count<<endl;
    
    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<int> v(n); rep(i,n) cin>>v[i];
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(v[1]-v[0]);
  for(int i=2; i<n; i++){
  	dp[i] = min(dp[i-2] + abs(v[i]-v[i-2]), dp[i-1] + abs(v[i]-v[i-1]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    double s, w, h;
    while (scanf("%lf,%lf,%lf", &s, &w, &h) != EOF) {
        if (w / (h*h) >= 25) {
            cout << s << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    int b = a / 200;
    cout << 10 - b << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS
    int n;
    cin>>n;
    int flag=0;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i] && i<n-2)
        {
            if(a[i+1]==b[i+1] && a[i+2]==b[i+2])
            {
                cout<<"Yes \n";
                flag=1;
                break;
            }
        }
    }
    if(flag==0)
        cout<<"No \n";
    return 0;
}

Measured memory_bytes: 3620
H,W,K = list(map(int, input().split()))
table = [input() for _ in range(H)]
ans = 0

for mask_h in range(2 ** H):
  for mask_w in range(2 ** W):
    black = 0
    for i in range(H):
      for j in range(W):
        if ((mask_h >> i) & 1 == 0) and ((mask_w >> j) & 1 == 0) and table[i][j] == '#': # 塗り潰し行、列ではなくて、色が黒'#'の場合
          black += 1

    if black == K:
      ans += 1
print(str(ans))

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int a,b,n;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int c1=0,c2=0;
    bool flag = 1;
    for(char o:s){
        if(o=='a'){
            if(c1<a+b){c1++;COUT("Yes");}
            else COUT("No");
        }
        else if (o=='b'){
            if(c1<a+b&&c2<b){c1++;c2++;COUT("Yes");}
            else COUT("No");
        }
        else COUT("No");
    }
    return 0;
} 

Measured memory_bytes: 896
fun main(args:Array<String>){
  val n=readLine()!!.toInt();
  val a=readLine()!!.split(" ").map(String::toInt);
  println(f(a,0));
}

fun f(a:List<Int>,count:Int):Int{
  return if(a.all{it%2==0}){
    f(a.map{it/2},count+1);
  }else{
    count;
  }
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a;
    priority_queue<int , vector<int> , greater<int> > q;
    vector< int > v;
    map< int,int > m;
    Scd(n);
    Rep(i,n){
        Scd(a);
        q.push(a);
        m.insert(make_pair(a,i%2));
    }

    int cnt[2] = {};

    Rep(i,n){
        if( m.find(q.top())->second != i%2 ){
            cnt[i%2]++;
        }
        q.pop();
    }

    int ans = min(cnt[0] , cnt[1] );
    ans += (ans - max( cnt[0] , cnt[1] ) + 1) / 2;

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

    return 0;
}



Measured memory_bytes: 5368
#include <stdio.h>

int main(void) {
    int N, i, a = 0, w = 0, t = 0, r = 0;
    char s[4];
    scanf ("%d", &N);
    for (i = 0 ; i < N ; i++) {
        scanf ("%s", s);
        if (s[0] == 'A') a++;
        if (s[0] == 'W') w++;
        if (s[0] == 'T') t++;
        if (s[0] == 'R') r++;
    }
    printf ("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, w, t, r);
    return 0;
}

Measured memory_bytes: 1728
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int MOD = 998244353;
const int N = 3003;

int n, s, a[N], dp[N], dp2[N];

void add(int& x, int y) {
  x += y;
  if (x >= MOD)
    x -= MOD;
}

int main() {
  init_ios();
  cin >> n >> s;
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 0; j <= s; ++j)
      dp2[j] = 2*dp[j]%MOD;
    for (int j = a[i]; j <= s; ++j)
      add(dp2[j], dp[j-a[i]]);
    for (int j = 0; j <= s; ++j)
      dp[j] = dp2[j];
  }
  cout<<dp[s]<<"\n";
}

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

int main()
{
    int n;
    cin >> n;
    int a[100002];
    bool b[31] {0};
    int x = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        x ^= a[i];
        for(int j = 0; ; j++){
            if(a[i] % 2){
                b[j] = true;
                break;
            }
            a[i] /= 2;
        }
    }
    int ans = 0;
    for(int i = 0; i < 31; i++){
        if(((x >> i) & 1) != ((x >> (i + 1)) & 1)){
            if(b[i]) ans++;
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

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

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

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

    std::vector<mint> ds(n - 1);
    mint px;
    std::cin >> px;
    for (auto& d : ds) {
        mint x;
        std::cin >> x;
        d = x - px;
        px = x;
    }

    std::vector<mint> fs(n), facc(n);
    fs[0] = facc[0] = 0;
    for (int k = 1; k < n; ++k) {
        fs[k] = facc[k - 1] / k + 1;
        facc[k] = facc[k - 1] + fs[k];
    }

    mint ans = 0;
    for (int k = 0; k < n - 1; ++k) ans += fs[k + 1] * ds[k];
    for (int i = 1; i < n; ++i) ans *= i;

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


Measured memory_bytes: 1408
#include<stdio.h>
int a[121212];
int min(int a, int b) { if (a < b)return a; return b; }
int main() {
	int n; long long ans = 0; scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (a[i - 1] % 2 && a[i]) a[i - 1]--, a[i]--, ans++;
	}
	for (int i = 1; i <= n; i++)ans += a[i] / 2;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 640
x, k, d = map(int, input().split())

def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0

if x > 0:
  x1 = x - k * d
else:
  x1 = x + k * d

if sgn(x) == sgn(x1):
  print(abs(x1))
  exit()
  
xright = x % d
xleft = x % d - d
#0目前
xr = (abs(x - xright) // d) % 2
if k % 2 == xr:
  print(abs(xright))
elif k % 2 != xr:
  print(abs(xleft))

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

int N;
int W;
long long w[110];
long long v[110];
long long dp[110][100010];

int main ()
{
    cin >> N >> W;
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    //memset(dp, 0, sizeof(dp));
    for(int i = 0; i < 110; i++) for(int j = 0; j < 100010; j++) dp[i][j] = 1LL<<60;
    dp[0][0] = 0;
    for(int i = 0; i < N; i++)
    {
        for(long long j = 0; j <= 100010; j++)
        {
            if(j - v[i] >= 0)
            {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 100010; j++)
    {
        if(dp[N][j] <= W) res = max(res, (long long)j);
    }
    cout << res << endl;
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

bool check(ll a, ll b){
    rep(i,0,21){
        if((a>>i&1) && (b>>i&1))return false;
    }
    return true;
}

signed main(){
	//cout << fixed << setprecision(10);
    set<string> st;
    int n; cin >> n;
    rep(i,0,n){
        string s; cin >> s;
        st.emplace(s);
    }
    cout << st.size() << endl;
    
    
	return 0;
}

Measured memory_bytes: 19104
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
    int r ;
    while(y){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}
int main(){
    int n;
    scanf("%d", &n);
    int res = 1;
    for(int i = 0; i < n; i++){
        int b;
        scanf("%d", &b);
        res = lcm(res, b);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#define INF 1<<19
const int MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
    int a,b;
    cin >> a >> b;
    if(a+b == 15){
        cout << '+' << endl;
    }else if(a * b == 15){
        cout << '*' << endl;
    }else{
        cout << 'x' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class SegmentTree():
    def __init__(self, values, merge_func=min, default=float("inf")):
        n = len(values)
        self.size = 1
        self.default = default
        self.merge = merge_func
        while self.size < n:
            self.size *= 2
        # tree[0] = empty
        # child of tree[n] = tree[n*2], tree[n*2+1]
        self.tree = [self.default] * self.size * 2
        self.range = [None] * self.size * 2
        for i in range(n):
            self.tree[self.size + i] = values[i]
        for i in range(self.size):
            self.range[self.size + i] = (i, i+1)
        for i in range(self.size-1, 0, -1):
            self.tree[i] = self.merge(self.tree[i*2], self.tree[i*2+1])
            self.range[i] = (self.range[i*2][0], self.range[i*2+1][1])

    def get(self, index):
        return self.tree[self.size + index]

    def update(self, index, value):
        index += self.size
        self.tree[index] = value
        while index > 1:
            index //= 2
            self.tree[index] = self.merge(
                self.tree[index*2], self.tree[index*2+1])

    # query segmentation value of [a, b)
    def query(self, a, b):
        q = [1]
        ret = self.default
        while len(q):
            k = q.pop()
            l, r = self.range[k]
            if r <= a or b <= l:
                continue
            if a <= l and r <= b:
                ret = self.merge(ret, self.tree[k])
            else:
                q.append(k*2)
                q.append(k*2+1)
        return ret


def main():
    MAX = 300001
    N, K = map(int, input().split())
    rmq = SegmentTree([0]*MAX, merge_func=max, default=0)
    for _ in range(N):
        A = int(input())
        mx = rmq.query(A-K, A+K+1)
        rmq.update(A, mx+1)
    ans = rmq.query(0, MAX)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 115356
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b > a + W) {
			System.out.println(b - (a + W));
		}else if(a > b + W) {
			System.out.println(a - (b + W));
		}else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23636
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 1000000007;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] ad;
	static int n, m, k;
	static long[][] memo;
	static seg[]a;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		a=new seg[n];
		memo=new long[n][30001];
		for(int i=0;i<n;i++) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			long v=sc.nextLong();
			a[i]=new seg(x, y, v);
		}
		Arrays.sort(a);
		for(long []y:memo)
			Arrays.fill(y, -1);
		System.out.println(dp(0,30000));
		out.flush();
	}
     static long dp(int i,int w) {
    	 if(i==n)
    		 return 0;
    	 if(memo[i][w]!=-1)
    		 return memo[i][w];
  //  	 System.out.println(i+" "+w);
    	 long ans=dp(i+1,w);
    	 if(a[i].a<=w)
    		 ans=Math.max(ans,a[i].v+dp(i+1,Math.min(w-a[i].a, a[i].b)));
    	 return memo[i][w]=ans;
     }
	static class seg implements Comparable<seg> {
		int a;
		int b;
		long v;

		seg(int s, int e, long vv) {
			a = s;
			b = e;
			v = vv;
		}

		public String toString() {
			return a + " " + b + " " + v;
		}

		public int compareTo(seg o) {
			return o.a + o.b - a - b;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 317780
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

uint64_t a[100001];
uint64_t b[100000];

int main(void)
{
    uint64_t n,r,m;

    scanf("%ld",&n);
    
    for(uint64_t i=0;i<=n;i++)
    {
        scanf("%ld",&(a[i]));
    }
    for(uint64_t i=0;i<n;i++)
    {
        scanf("%ld",&(b[i]));
    }

    r = 0;
    m = 0;
    for(uint64_t i=0;i<n;i++)
    {  
        uint64_t now;
        now = a[i];
        if(now < r)
        {
            m += now;
            r = b[i];
        }else {
            now -= r;
            m += r;

            if(now < b[i])
            {
                r = b[i] - now;
                m += now;
            }else{
                r = 0;
                m += b[i];
            }
        }
    }
    if(a[n] < r)
    {
        m+= a[n];
    }else
    {
        m+= r;
    }

    printf("%ld\n",m);

    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
int n;
string s;
int lef;
int righ;
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='(') lef++;
		else if(s[i]==')') {
			if(lef<=0) righ++;
			else lef--; 
		}
	}
	for(int i=0;i<righ;i++) cout<<"(";
	for(int i=0;i<n;i++) cout<<s[i];
	for(int i=0;i<lef;i++) cout<<")";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K):
    if K == 1:
        return 0
    return (N - K)


def main():
    N, K = read_int_n()
    print(slv(N, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6340
N,M = map(int,input().split())

L = []
R = []

ans = 0

for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

Lmax = max(L)
Rmin = min(R)

for i in range(1,N+1):
    if Lmax <= i and i <= Rmin:
        ans += 1

print(ans)


Measured memory_bytes: 10996
# 2020/04/30
# AtCoder Grand Contest 004 - A

# Input
abc = list(map(int,input().split()))

# Even Check
evenflg = False
for i in range(3):
    if abc[i] % 2 == 0:
        evenflg = True
        break

if evenflg:
    ans = 0
else:
    abc.sort()
    ans = abc[0] * abc[1]

# Output
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n; cin >> n;
    ll m; cin >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    rep(i, n-1) a[i+1] += a[i];
    rep(i, n) a[i] %= m;

    map<ll, ll> mp;
    rep(i, n) mp[a[i]]++;

    ll ans = 0;
    for (auto kv: mp) {
        ll k = kv.first, v = kv.second;
        if (k == 0) ans += v * (v+1) / 2;
        else ans += v * (v-1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7828
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi s(n);
    ll sum = 0;
    rep(i, n){
        cin >> s[i];
        sum += s[i];
    }
    if(sum%10 != 0) cout << sum << endl;
    else{
        sort(all(s));
        bool flg = false;
        for(ll i=0; i<n; i++){
            if(s[i]%10 != 0){
                cout << sum-s[i] << endl;
                flg = true;
                break;
            }
        }
        if(!flg) cout << 0 << endl;
    }
}

Measured memory_bytes: 256