akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;
 
struct NODE{
	ll dist;
	ll number;
	bool done;
	vl edges_to;
	vl edges_cost;
	bool operator<= (const NODE &temp) const { return this->dist >= temp.dist; }
	bool operator>= (const NODE &temp) const { return this->dist <= temp.dist; }
	bool operator< (const NODE &temp) const { return this->dist > temp.dist; }
	bool operator> (const NODE& temp) const { return this->dist < temp.dist; }
};
 
void dijkstra(vector<NODE> &nodes, ll start){
	priority_queue<NODE> q;
	vb contains_flag(nodes.size(),false);
	nodes[start].dist = 0;
	q.push(nodes[start]);
	contains_flag[start] = true;
	while (!q.empty()){
		NODE temp_v = q.top();
		q.pop();
		contains_flag[temp_v.number] = false;
		//cout << "temp_v.number="<<temp_v.number << endl;
		temp_v.done = true;
		rep(i, temp_v.edges_to.size()){
			ll to = temp_v.edges_to[i];
			ll cost = temp_v.edges_cost[i] + temp_v.dist;
			if (nodes[to].dist < 0 || cost < nodes[to].dist){
				nodes[to].dist = cost;
				if (!contains_flag[to]){
					q.push(nodes[to]);
					//cout << "push_" << to << endl;
					contains_flag[to] = true;
				}
			}
		}
	}
}
 
int main(){
	ll n; cin >> n;
	vector<NODE> nodes(n);
	nodes[0].dist = -1;
	nodes[0].done = false;
	nodes[0].number = 0;
	rep(i, n-1){
		ll a, b, c;
		cin >> a >> b >> c;
		nodes[a-1].edges_to.push_back(b-1);
		nodes[a-1].edges_cost.push_back(c);
		nodes[b - 1].edges_to.push_back(a - 1);
		nodes[b - 1].edges_cost.push_back(c);
		nodes[i + 1].number = i + 1;
		nodes[i + 1].dist = -1;
		nodes[i + 1].done = false;
	}
	/*
	rep(i, n){
		cout << i << "番目" << endl;
		cout << "number=" << nodes[i].number << endl;
		cout << "next_edges_size=" << nodes[i].edges_to.size() << endl;;
		for (ll j : nodes[i].edges_to) cout << " " << j;
		cout << endl;
		for (ll cost : nodes[i].edges_cost) cout << " " << cost;
		cout << endl;
	}
	*/
	ll q, k; cin >> q >> k;
	k--;
	dijkstra(nodes, k);
	rep(i, q){
		ll x, y; cin >> x >> y;
		x--; y--;
		//cout << x << " to " << k << " =" << dijkstra(nodes, x, k) << endl;
		//cout << k << " to " << y << " =" << dijkstra(nodes, k, y) << endl;
		//cout << "ans=" << ans << endl;
		cout << nodes[x].dist+nodes[y].dist << endl;
	}
	return 0;
}

Measured memory_bytes: 31932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int a,b;cin>>a>>b;
    if(a==1&&b==2)cout<<'3';
    else if(a==1&&b==3)cout<<'2';
    else if(a==2&&b==1)cout<<'3';
    else if(a==2&&b==3)cout<<'1';
    else if(a==3&&b==1)cout<<'2';
    else if(a==3&&b==2)cout<<'1';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 2e9
#define mod 1000000007LL
#define eps 0.0001
#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define SZ(x) ((ll)(x).size())
#define sum(x) accumulate(ALL(x), 0LL)//?
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; }
ll rec(ll x){
    if (x == 1) return 1;
    return (rec(x/2)*2+1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H;
    cin >> H;
    cout << rec(H) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e11 + 7;
const int maxn = 2e5+5;
int c[2510][2510];
int n, m;
int getid(int x,int y) {
    return x * m + y;
}
int main(){
    memset(c, -1, sizeof(c));
  cin >> n >> m;
  string s[n+1];
  f(n) {
    cin >> s[i];
  }
  f(n) {
    fr(j,0,m) {
        if (s[i][j] == 'o') {
            int v[n+1][m+1] = {};
            v[i][j] = 1;
            queue<pair<int,int>>q;
            q.push({i,j});
            while (q.size()) {
                auto now = q.front();
              //cout << now.F <<' '<<now.S << endl;
                q.pop();
                c[getid(i,j)][getid(now.F,now.S)] = (now.F - i) + (now.S - j);
                if (now.F < n - 1 && s[now.F+1][now.S] != '#' && !v[now.F+1][now.S]) {
                    v[now.F+1][now.S] = 1;
                    q.push({now.F+1,now.S});
                }
                if (now.S < m - 1 && s[now.F][now.S+1] != '#' && !v[now.F][now.S+1]) {
                    v[now.F][now.S+1] = 1;
                    q.push({now.F,now.S+1});
                }
              //cout << "GG"<<endl;
            }
        }
    }
  }
  mcf_graph<int,ll>g(2*n*m + 2);
  int st = 2 * n * m;
  int t = 2 * n * m + 1;
 
  for(int i=0;i<n*m;i++){
    g.add_edge(st,i,1,0);
    g.add_edge(i + n * m,t,1,0);
  }
  for(int i=0;i<n*m;i++){
    if (c[i][i] == -1)continue;
    for(int j=0;j<n*m;j++){
      if (c[i][j] == -1)continue;
      //cout << -c[i][j] << endl;
      //cout << i << ' '<<j<<' '<<5000 - c[i][j]<<endl;
      g.add_edge(i,n*m+j,1,5000-c[i][j]);
    }
  }
  auto result=g.flow(st,t);
  cout << 5000*result.F - result.S << endl;
}

Measured memory_bytes: 33896
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    a = list(map(int, input().split()))

    x = 0
    for i in range(2, n):
        x ^= a[i]
    d = a[0]+a[1]-x
    if d%2 == 1 or d < 0:
        print(-1)
        return
    d >>= 1
    if d&x != 0 or d > a[0]:
        print(-1)
        return
    k = x.bit_length()
    tmp = d
    # d^tmp はd&x=0からd|tmpと一緒
    for i in range(40, -1, -1):
        if (x >> i) & 1:
            if tmp|1<<i <= a[0]:
                tmp |= 1<<i
    if 0 < tmp <= a[0]:
        print(a[0]-tmp)
    else:
        print(-1)



if __name__ == '__main__':
    main()

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

const long long MAX = 1001;
const long long MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long 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(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long finv_pow[MAX][MAX];
long long dp[MAX][MAX];

int main() {
    COMinit();

    //input
    long long N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;

    //calc
    long long i,j,k,l;
    for(i=1; i<MAX; i++){
        finv_pow[i][1]=finv[i];
    }
    for(i=1; i<MAX; i++){
        for(j=2; j<MAX; j++){
            finv_pow[i][j]=(finv_pow[i][j-1]*finv[i])%MOD;
        }
    }
    for(i=0; i<MAX; i++){
        for(j=0; j<MAX; j++){
            dp[i][j]=0;
        }
    }
    for(i=0; i<MAX; i++){
        dp[i][0]=1;
    }
    long long val;
    for(j=C; (j*A<=N)&&(j<=D); j++){
        val=fac[N];
        val*=finv[N-j*A];
        val%=MOD;
        val*=finv_pow[A][j];
        val%=MOD;
        val*=finv[j];
        val%=MOD;
        dp[A][j*A]+=val;
        dp[A][j*A]%=MOD;
    }
    for(i=A+1; i<=B; i++){
        for(j=A; j<=N; j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD;
            for(k=C; (k<=D)&&(j-i*k>=0); k++){
                val=dp[i-1][j-i*k];
                val*=fac[N-(j-i*k)];
                val%=MOD;
                val*=finv[N-j];
                val%=MOD;
                val*=finv_pow[i][k];
                val%=MOD;
                val*=finv[k];
                val%=MOD;
                dp[i][j]+=val;
                dp[i][j]%=MOD;
            }
        }
    }

    //output
    cout << dp[B][N] << endl;
    return 0;
}

Measured memory_bytes: 19200
N = int(input())
e = [tuple(map(int, input().split())) for _ in range(N)]
e.sort(key=lambda x: x[0] + x[1], reverse=True)

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += e[i][0]
    else:
        ans -= e[i][1]
print(ans)

Measured memory_bytes: 21376
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


ll mod(ll i, ll j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];
    ll x = T[0], y = A[0];
    ll ans = 0;
    REP(i,1, N) {
        ll S = x + y;
        ll t = mod(-S, ll(T[i] + A[i]));
        //ll x_new = (S + t) * T[i] / ll(T[i] + A[i]);
        ll x_new = T[i];
        ll mul1 = 1;
        if (x_new < x) {
            ll add = 0;
            if (x % x_new != 0) add++;
            mul1 = x / x_new + add;
        }
        //ll y_new = (S + t) * A[i] / ll(T[i] + A[i]);
        ll y_new = A[i];
        ll mul2 = 1;
        if (y_new < y) {
            ll add = 0;
            if (y % y_new != 0) add++;
            mul2 = y / y_new + add;
        }
        x = max(mul1, mul2) * x_new;
        y = max(mul1, mul2) * y_new;
    }
    
    cout << x + y << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc138/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() {
  // vector<int> A{ 1 };
  // auto idx = lower_bound(A.begin(), A.end(), 1) - A.begin();
  // cout << idx << endl;
  solve();
  return 0;
}

void solve() {
  string s, t;
  vector<int> A[30];
  cin >> s >> t;
  int n = s.size();
  // 各文字が出現するインデックスを昇順で格納する.
  for (int i=0; i<s.size(); i++) {
    char c = s[i];
    A[c-'a'].push_back(i);
  }

  // 1
  ll total = 0;
  ll s_idx = -1;
  for (auto&&b: t) {
    if (!A[b-'a'].size()) {
      cout << -1 << endl;
      return;
    }

    // 今いるインデックスs_idx以降でbが出現する最小インデックスを探す.
    int i = lower_bound(A[b-'a'].begin(), A[b-'a'].end(), s_idx) - A[b-'a'].begin();
    if (i < A[b-'a'].size() and s_idx == A[b-'a'][i]) {
      i++; // 今いるインデックス"以降"なので+1
    }
    // もし以降に無ければ先頭に戻る. その時のコストは
    if (i >= A[b-'a'].size()) {
      total += n - s_idx;
      s_idx = A[b-'a'][0];
      total += s_idx;
    } else {
      // 以降に存在する場合、そこに移動する.
      int idx = A[b-'a'][i];
      total += idx - s_idx;
      s_idx = idx;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define int long long 
#define register rg
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
typedef long long ll;
main() {
	//file("a");
	int a,b;
	cin>>a>>b;
	printf("%lld",max(a,b)+max(max(a,b)-1,min(a,b))); 
	return 0;
}


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

signed main() {
	cout.precision(16);
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; ++i)cin >> x[i] >> y[i];
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}
	cout << ans * 2 / n << endl;
}

Measured memory_bytes: 256
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN {
    int n,k;
    typedef vector<int> vec;
    vec a[7];
    inline vec Read(){
        RG vec ret(n);
        for(res i=0;i<n;i++)ret[i]=read()-1;
        return ret;
    }
    inline void print(const RG vec &a){
        for(res i=0;i<n;i++)printf("%d ",a[i]+1);
        puts("");
    }
    inline vec getinv(const RG vec &a){
        RG vec ret(n);
        for(res i=0;i<n;i++)ret[a[i]]=i;
        return ret;
    }
    inline vec mul(const RG vec &a,const RG vec &b){
        RG vec ret(n);
        for(res i=0;i<n;i++)ret[i]=a[b[i]];
        return ret;
    }
    inline vec qpow(RG vec x,res y){
        RG vec ret(n);
        for(res i=0;i<n;i++)ret[i]=i;
        while(y){
            if(y&1)ret=mul(ret,x);
            x=mul(x,x),y>>=1;
        }
        return ret;
    }
    vec p,q;
    inline void MAIN(){
        n=read(),k=read(),p=Read(),q=Read();
        a[1]=p,a[2]=q;
        for(res i=3;i<=6;i++)a[i]=mul(a[i-1],getinv(a[i-2]));
        RG vec A=mul(mul(q,getinv(p)),mul(getinv(q),p)),B=qpow(A,(k-1)/6);
        print(mul(mul(B,a[(k-1)%6+1]),getinv(B)));
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 5880
import sys
sys.setrecursionlimit(10**7)

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def unite(x, y):
    x, y = root(x), root(y)
    if x == y: return
    par[x] = y

def is_same(x, y):
    return root(x) == root(y)


n, m = map(int, input().split())
par = [i for i in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    unite(a, b)

cnt = [0]*n
for p in par:
    cnt[root(p)] += 1
print(max(cnt))

Measured memory_bytes: 229292
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        enum Status
        {
            SAME, UP, DOWN
        };

        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);

            Status status = Status.SAME;
            int cur = A[0];

            var ans = 0;

            for (int i = 1; i < N; i++)
            {
                if (status == Status.SAME && cur != A[i])
                {
                    status = cur - A[i] > 0 ? Status.UP : Status.DOWN;

                }
                else if ((status == Status.UP && A[i] > cur) || (status == Status.DOWN && A[i] < cur))
                {
                    ans++;
                    status = Status.SAME;
                }
                cur = A[i];
            }
            WriteLine(ans + 1);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}

Measured memory_bytes: 22496
n = int(input())
A = list(map(int, input().split()))


def CountingSort(A, B, k):
    C = [0] * (k+1)

    for j in range(n):
        C[A[j]] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]
        # 累積和
    for j in range(n-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1
    return B


k = max(A)
B = [0] * n
B = CountingSort(A, B, k)
print(*B)



Measured memory_bytes: 224380
#include<cstdio>
#define N 1000005
char c[N];int i,m,n,o[N],p[N],q[3],u,v,w,x,y,z;
int main()
{
    for(scanf("%s",c+1),i=1;c[i];i++)if(c[i]!=c[n])c[++n]=c[i],q[c[n]-65]++;
    q[0]<q[1]?q[2]<q[0]?x=2,y=0,z=1:(x=0,q[1]<q[2]?y=1,z=2:(z=1,y=2)):(q[2]<q[1]?x=2,y=1,z=0:(x=1,q[0]<q[2]?y=0,z=2:(z=0,y=2)));
    for(i=1,*c=c[1]==x+65?0:x+65,c[n+1]=x+65;i<=n;i++)c[i-1]==x+65?c[i+1]==x+65?c[i]==y+65?v++:w++:u++:0;
    if(u+v<w&&n&&c[1]==z+65&&c[2]!=y+65)for(i=1,q[z]--,w--,n--;i<=n;i++)c[i]=c[i+1];
    if(u+v<w&&n&&c[n]==z+65&&c[n-1]!=y+65)n--,w--,q[z]--;
    for(i=1,*c=n=c[n+1]=0;c[i];i++)u+v<w&&c[n]==x+65&&c[i]==z+65&&c[i+1]==x+65?i++,w--,q[x]--,q[z]--:c[++n]=c[i];
    for(i=1,n=c[n+1]=0;c[i];i++)q[y]<q[z]&&c[i]==z+65&&c[n]!=c[i+1]?q[z]--:c[++n]=c[i];
    for(i=1,n=c[n+1]=0,*c=c[1]==x+65?0:x+65;c[i];i++)q[x]<q[y]&&c[n]==x+65&&c[i+1]!=x+65&&c[i+2]!=x+65?q[y]--,q[z]--,i++:c[++n]=c[i];
    return 0&(*c=c[n+1]=0,printf("%s\n",c+1));
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void B_task();

int main()
{
	B_task();
	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N;
	get1int(N);
	std::vector<LLONG> An(N, 0);

	LLONG l = 0, total = 0;
	get1int<LLONG>(l);
	An[0] = l;
	total += l;
	for (int i = 1; i < N; i++) {
		get1int<LLONG>(l);
		An[i] = l + An[i - 1];
		total += l;
	}

	LLONG minD = 2020202020 + 1;
	for (int i = 0; i < N; i++) {
		minD = tp_min<LLONG>(tp_abs<LLONG>((total - An[i]) - An[i]), minD);
	}

	printf("%lld\n", minD);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int n;
    cin>>n;
    unordered_set<string> unique;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        unique.insert(s);
    }
    cout<<unique.size();
    
}

Measured memory_bytes: 17724
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;



int main(){
   lint a,b,k;
   cin >> a >> b >> k;
   
   cout << max((lint)0,a-k)  << " "<< max((lint)0,b-max((lint)0,k-a))<< endl;
   
   return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    String s = sc.next();
    char[] sArray = s.toCharArray();
    int q = Integer.parseInt(sc.next());
    CharIndexes indexesForAllAlphabet[] = new CharIndexes[27];
    for (int i = 0; i < 27; i++) {
      indexesForAllAlphabet[i] = new CharIndexes();
    }
    for (int i = 0; i < n; i++) {
      char c = sArray[i];
      int index = c - 'a';
      indexesForAllAlphabet[index].addIndex(i);
    }
    for (int query = 0; query < q; query++) {
      int type = Integer.parseInt(sc.next());
      if (type == 1) {
        int i = Integer.parseInt(sc.next()) - 1;
        char c = sc.next().charAt(0);
        indexesForAllAlphabet[sArray[i] - 'a'].removeIndex(i);
        sArray[i] = c;
        indexesForAllAlphabet[sArray[i] - 'a'].addIndex(i);
      } else {
        int l = Integer.parseInt(sc.next()) - 1;
        int r = Integer.parseInt(sc.next()) - 1;
        int ans = 0;
        for (CharIndexes indexes : indexesForAllAlphabet) {
          if (indexes.containsIndexRange(l, r)) {
            ans++;
          }
        }
        pw.println(ans);
      }
    }
  }

  static class CharIndexes {

    SortedSet<Integer> indexes = new TreeSet<>();

    void addIndex(int index) {
      indexes.add(index);
    }

    void removeIndex(int index) {
      indexes.remove(index);
    }

    boolean containsIndexRange(int from, int endInclusive) {
      return !indexes.subSet(from, endInclusive + 1).isEmpty();
    }
  }
}


Measured memory_bytes: 98188
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll a,b,c,n,m,x,y,p;
string s;
int main(){
	cin >> a >> p;
	cout << (a*3+p)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 H,W,M;
	cin >> H >> W >> M;
	vector<pair<int,int>> a(M);
	map<int,int> h, w;
	REP(i,M){
		cin >> a[i].first >> a[i].second;
		h[a[i].first]++;
		w[a[i].second]++;
	}
	
	int hmax=0, wmax=0, hcount=0, wcount=0;
	map<int,int> hindex,windex;
	for(auto x: h){
		chmax(hmax, x.second);
	}
	for(auto x: w){
		chmax(wmax, x.second);
	}
	for(auto x: h){
		if(x.second==hmax) hcount++;
	}
	for(auto x: w){
		if(x.second==wmax) wcount++;
	}
	for(auto x: h){
		if(x.second==hmax) hindex[x.first]=wcount;
	}
	for(auto x: w){
		if(x.second==wmax) windex[x.first]=hcount;
	}

	
	for(auto x: a){
		if(hindex.find(x.first)!=hindex.end() && windex.find(x.second)!=windex.end()){
			hindex[x.first]--;
			windex[x.second]--;
		}else{
			continue;
		}
		if(hindex[x.first]==0) hindex.erase(x.first);
		if(windex[x.second]==0) windex.erase(x.second);
	}
	
	if(hindex.empty() || windex.empty()){
		cout << hmax+wmax-1 << endl;
	}else{
		cout << hmax+wmax << endl;
	}
	
	
	return 0;
}

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef vector<vector<ll>> mat;

// 行列A*Bの計算
mat mulmod(mat &A, mat&B){
    mat C((int)A.size(), vector<ll>((int)B.size()));
    for(int i=0; i<(int)A.size(); ++i){
        for(int j=0; j<(int)B[0].size(); ++j){
            for(int k=0; k<(int)B.size(); ++k){
                C[i][j] += A[i][k] * B[k][j];
                chmod(C[i][j]);
            }
        }
    }
    return C;
}

// A^nの計算
mat matrixpowmod(mat A, ll n){
    mat B((int)A.size(), vector<ll>((int)A.size(), 0));
    for(int i=0; i<(int)A.size(); ++i) B[i][i] = 1;

    while(n>0){
        if(n&1) B = mulmod(B, A);
        A = mulmod(A, A);
        n >>= 1;
    }
    return B;
}

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

    ll n, k; cin >> n >> k;
    mat A(n, vector<ll>(n));
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> A[i][j];

    mat C = matrixpowmod(A, k);
    ll ans = 0;
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j){
        ans += C[i][j];
        chmod(ans);
    }

    cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    double n;
    cin >> n;
    double ans = n/1.08;
    double a = (n+0.99)/1.08;
    //cout << ans <<" "<< a << endl;
    if((int)ans!=(int)a|| (int)ans==ans) {
        cout << (int)a << endl;
    }else {
        cout << ":(" << endl;
    }

  return 0;
}



Measured memory_bytes: 3680
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 1001001001;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}
int main() {
    ll N, M;
    cin >> N >> M;
    vector<P> num(N);
    ll a, b;
    rep(i, N) {
        cin >> a >> b;
        num[i] = P(a, b);
    }
    sort(all(num));
    ll now = 0;
    ll money = 0;
    rep(i, N) {//cost kosuu
        if (now + num[i].second <= M) {
            money += num[i].second * num[i].first;
            now += num[i].second;
        }
        else {
            money += (M - now) * num[i].first;
            break;
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int n;
    long long sum=0;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        sum+=i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3592
use std::io::*;

fn read_int(s: &mut StdinLock) -> usize {
    s.by_ref().bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .skip_while(|c| c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as usize + a * 10)
}
fn main(){
    let s = stdin();
    let mut s = s.lock();
    let n = read_int(&mut s);
    let k = read_int(&mut s);
    let mut old_mins: usize = 0;
    let mut old_maxs: usize = 0;
    let mut ans: usize = 0;
    for i in 0..n {
        old_mins = old_mins + i;
        old_maxs = old_maxs + n - i;
        if i >= k - 1 {
            ans = (ans + old_maxs - old_mins + 1)%1000000007;
        }
    }
    println!("{}", ans+1);
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n=s.size();
    reverse(s.begin(),s.end());
    s='0'+s;
    for(int i=0;i<5;i++) s+='0';
    vector<vector<int>> dp(n+6,vector<int>(2,(1<<30)));
    dp[0][0]=0;
    for(int o=1;o<=n+5;o++)
    {
        int num=(s[o]-'0');
        for(int i=0;i<=9;i++)
        {
            //no carry
            if(num<=i) dp[o][0]=min(dp[o][0],dp[o-1][0]+i+(i-num));
            else dp[o][1]=min(dp[o][1],dp[o-1][0]+i+(10+i-num));
            //carry
            if(num+1<=i) dp[o][0]=min(dp[o][0],dp[o-1][1]+i+(i-(num+1)));
            else dp[o][1]=min(dp[o][1],dp[o-1][1]+i+(10+i-(num+1)));
        }
    }
    cout << dp[n+5][0] << endl;
    return 0;
}


Measured memory_bytes: 55856
#include <stdio.h>

int main() {
    int mount;
    int mount1 = 0, mount2 = 0, mount3 = 0;
    for (int i = 0; i < 10; i++) {
        scanf("%d", &mount);
        if (mount1 < mount) {
            mount3 = mount2;
            mount2 = mount1;
            mount1 = mount;
        } else if (mount2 < mount) {
            mount3 = mount2;
            mount2 = mount;
        } else if (mount3 < mount) {
            mount3 = mount;
        }
    }
    printf("%d\n%d\n%d\n", mount1, mount2, mount3);
    return 0;
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

int dp[1000][1000],q[40][3];
signed main(){
	int n, m1, m2;
	fill((int*)dp, (int*)(dp+1000), inf);
	scanf("%lld%lld%lld", &n, &m1, &m2);
	rep(i,n)rep(j,3)scanf("%lld", &q[i][j]);
	dp[0][0] = 0;
	rep(i,n){
		drep(y,400,0)drep(x,400,0){
			int yy = y-q[i][0], xx = x-q[i][1];
			if(yy < 0 || xx < 0)continue;
			if(dp[yy][xx] == inf)continue;
			dp[y][x] = min(dp[yy][xx]+q[i][2], dp[y][x]);
		}
	}
	int ans = inf;
	rrep(i,400){
		if(i*m1 > 400 || i*m2 > 400)break;
		ans = min(ans, dp[i*m1][i*m2]);
	}
	if(ans == inf)printf("-1\n");
	else printf("%lld\n", ans);
	return 0;
}

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

int main()
{
    int n,k,x;
    cin>>n>>k;
    map<int,int>mp;

    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        mp[x]++;
    }
    if(mp.size()<=k)
        cout<<0<<endl;
    else
    {
        int m=mp.size();
        vector<int>v;
        for(auto x : mp)
            v.push_back(x.second);
        sort(v.begin(),v.end());
        int cnt=0;
        for(int i=0;i<m-k;i++)
            cnt+=v[i];
        cout<<cnt<<endl;
//        for(auto x : v)
//            cout<<x<<" ";
    }


}


Measured memory_bytes: 13604
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		


		System.out.println(N*N);
		




	}

	static void sieve(ArrayList<Long> list){
		int n = 50000000;
		boolean[] is_prime = new boolean[n+1];
		int[] prime = new int[n];
		for(int i= 0;i <=n;i++){
			is_prime[i] = true;
		}
		list.add((long) 1);
		for(int i = 2;i <= n;i++){
			if(is_prime[i]){
				list.add((long)i);
				for(int j = 2*i;j <= n;j+=i){
					is_prime[j] = false;
				}
			}
		}



	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






Measured memory_bytes: 23892
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
int cnt[N];

int main(){
	int x;
	cin>>x;
	if(x%10==x/100) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int[]a=new int[n],b=new int[n],tmpA=new int[n],tmpB=new int[n];
		for(int i=0;i<n;i++) 
			tmpA[i]=sc.nextInt();
			
		for(int i=0;i<n;i++)
			tmpB[i]=sc.nextInt();
		long ans=0;
		for(int k=0;k<30;k++) {
			int T=1<<k;
			for(int i=0;i<n;i++) {
				a[i]=tmpA[i]%(2*T);
				b[i]=tmpB[i]%(2*T);
			}
			

			Arrays.sort(a);
			Arrays.sort(b);
			for(int i=0;i<n/2;i++) {
				int x=b[n-i-1];
				b[n-i-1]=b[i];
				b[i]=x;
			}

			int xor=0;
			int []t=new int [5];
			for(int i=0;i<n;i++) {
				for(int j=1;j<=4;j++)
					while(t[j]<n && a[i]+b[t[j]]>=T*j)
						t[j]++;
				
				int one=Math.max(0, t[1]-t[2]),two=Math.max(0, t[3]-t[4]);
				xor^=one;
				xor^=two;
			}
			if((xor&1)==1)
				ans+=T;

		}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

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

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

	}

}

Measured memory_bytes: 63864
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

ll N, K;
ll a[1010], sum[1010];
std::vector<bool> removed;
std::vector<ll> S;

int main()
{
  scanf( "%lld%lld", &N, &K );

  rep( i, N )
    scanf( "%lld", a+i );

  rep( i, N )
    sum[i+1] += sum[i]+a[i];

  rep( i, N ) rep( j, i+1 )
    S.emplace_back( sum[i+1]-sum[j] );

  removed.assign( S.size(), false );

  ll ans = 0;

  for( int b = 40; b >= 0; --b )
  {
    ll cnt = 0;

    rep( i, S.size() ) if( !removed[i] )
      cnt += S[i]>>b&1;

    if( cnt >= K )
    {
      ans += 1ll<<b;

      rep( i, S.size() ) if( !removed[i] && !(S[i]>>b&1) )
      { removed[i] = true; }
    }
  }

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

  return 0;
}

Measured memory_bytes: 6512
K = int(input())

def S(n):
    m = n
    s = 0
    while m > 0:
        s  += m % 10
        m //= 10
    return s

# the number of 9s
n9 = 0
e = 10 ** n9

count = 0
upper = 1
while count < K:
    n = (upper + 1) * e - 1
    s = S(upper) + 9 * n9
    if n <= e * s:
        print(n)
        upper += 1
        count += 1
    else:
        n9 += 1
        e  *= 10
        upper //= 10


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

using namespace std;

const int MOD = 1e9 + 7;

int n,m,i,j,k;
long long dp[305][305][305];
vector <pair<int, int> > q[305];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < m; i++){
		int x,y,z;
		scanf("%d%d%d", &x, &y, &z);
		q[y].push_back({x, z});
	}
	
	dp[0][0][0] = 1LL;
	
	long long res = 0;
	
	for(i = 0; i <= n; i++){
		for(j = 0; j <= i; j++){
			if(i != 0 && j == i) continue;
			for(k = 0; k <= j; k++){
				if(j != 0 && k == j) continue;
				if(dp[i][j][k] == 0) continue;
				
				int nxt = i;
				
				for(int ii = 0; ii < q[nxt].size(); ii++){
					int x = q[nxt][ii].first; int y = q[nxt][ii].second;
					if(y == 1){
						if(j >= x)
						dp[i][j][k] = 0LL;
					}
					else if(y == 2){
						if(j < x || k >= x)
						dp[i][j][k] = 0LL;
					}
					else{
						if(k < x)
						dp[i][j][k] = 0LL;
					}
				}
				
				if(i == n)
				res = (res + dp[i][j][k]) % MOD;
				
				dp[nxt + 1][j][k] = (dp[nxt + 1][j][k] + dp[i][j][k]) % MOD;
				dp[nxt + 1][i][k] = (dp[nxt + 1][i][k] + dp[i][j][k]) % MOD;
				dp[nxt + 1][i][j] = (dp[nxt + 1][i][j] + dp[i][j][k]) % MOD;
			}
		}
	}
	
	printf("%lld\n", res);
}



Measured memory_bytes: 219392
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
    int n,mx=-1;
    cin>>n;
    set<string>st;
    vector<string>v;
    map<string,int>mp;
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
        mx=max(mx,mp[s]);
        st.insert(s);
    }
    for(auto x: st)
    {
        if(mp[x]==mx)v.pb(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)cout<<v[i]<<endl;


}


Measured memory_bytes: 36212
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)


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

	printf("%d\n", n * a > b ? b : n * a);
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CGuessTheNumber {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<int> s(m), c(m);
      rep(i, m) {
        cin >> s[i] >> c[i];
      }
      int ans = -1;
      for(int i=0; i<=999; i++) {
        if (n==1) {
          if (i >= 10) continue;
        }
        if (n==2) {
          if (i < 10 || i >= 100) continue;
        }
        if (n==3) {
          if (i < 100) continue;
        }
        bool flag = true;
        rep(j, m) {
          int tmp = i;
          int d = n-s[j];
          while(d--) {
            tmp/=10;
          }
          if (tmp%10 != c[j]) flag = false;
        }
        if (flag) {
          ans = i;
          break;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  CGuessTheNumber solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//Yes, Noと表示後終了
void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}

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

//実行部
void Main()
{
  ll k, ans = 0;
  cin >> k;
  for(ll i = 1;i <= k;i++)
  {
    for(ll j = 1;j <= k;j++)
    {
      for(ll t = 1;t <= k;t++)
      {
        ans += gcd(i, gcd(j, t));
      }
    }
  }
  fin(ans)
  return;
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


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

int main(){
	int n,d;
	cin>>n>>d;
	int cnt=0;
	for(int i=1;i<=n;i++){
		ll x,y;
		cin>>x>>y;
		double dx=sqrt(x*x+y*y*1.0);
		if(dx<=d)cnt++;
	}
	cout<<cnt;
	return 0;
}

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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll sum = 0;
	for (ll i = 0; i <= 100; ++i) {
		sum = a  * (i + 1);
		//cout << sum << endl;
		if (sum % b == c) {
			cout << "YES";
			return 0;
				
			}
	}
	cout << "NO";
}



















Measured memory_bytes: 256