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

int main(void)
{
    long long N;
    cin >> N;
    string S;
    cin >> S;
    vector<long long> preans(10);
    long long ans = 0;
    for(long long i = 0; i < 10; i++)
    {
        for (long long j = 0; j < 10; j++)
        {
            for (long long k = 0; k < 10; k++)
            {
                preans[k] = 0;
            }
            long long count = 0;
            for (long long k = 0; k < N; k++)
            {
                if (count == 0)
                {
                    if (S[k] - '0' == i)
                    {
                        count++;
                    }
                }
                else if (count == 1)
                {
                    if (S[k] - '0' == j)
                    {
                        count++;
                    }
                }
                else if (count == 2)
                {
                    preans[S[k] - '0']++;
                }
            }
            for (long long k = 0; k < 10; k++)
            {
                if (preans[k] > 0)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define F first
#define S second
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n, a, b; cin >> n >> a >> b;
  if((b - a - 1) % 2 == 1)cout << "Alice" << endl;
  else cout << "Borys" << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

a = [input() for x in range(n)]
b = [input() for x in range(m)]

ball = ''.join(b)

def check():
    for i in range(n):
        if i + m > n:
            continue

        for j in range(n):
            if j + m > n:
                continue

            aall = ""
            for k in range(m):
                aall += a[i+k][j:j+m]

            if aall == ball:
                return True

    return False

ret = "Yes" if check() else "No"
print(ret)


Measured memory_bytes: 3064
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0]
for i in a:
    aa.append(aa[-1]+i)
bb = [0]
for i in b:
    bb.append(bb[-1]+i)
ans = 0
j = m
for i in range(n+1):
    if aa[i] > k:
        break
    while aa[i] + bb[j] > k and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47544
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).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; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n; cin >> n;
  vvi a(n,vi(3));
  rep(i,n) rep(j,3) cin >> a[i][j];

  vvi dp(n+1,vi(3,0));
  rep(i,n) {
    rep(j,3) rep(k,3) {
      if(j == k) continue;
      chmax(dp[i+1][j], dp[i][k] + a[i][k]);
    }
  }

  int ans = 0;
  rep(i,3) chmax(ans, dp[n][i]);
  cout << ans << endl;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	ll n,i,j,k,l,m;
	cin>>n>>k;
	ll arr[n];
	for(i=0;i<n;i++)
		cin>>arr[i];
	l=0;
	m=1;
	for(i=0;i<n;i++)
	{
		l+=arr[i];
		if(l<=k)
			m++;
		else
			break;
	}
	cout<<m<<"\n";
	return 0;
}
	

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

/*  FordFulkerson: Ford-Fulkersonのアルゴリズムで最大流を求める構造体

    verify : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=ja

    max_flow(G,s,t)：sからtへのグラフGの最大流を求める
    副作用：G は最大流の残余ネットワークになる
    計算量: O(|f*||E|) (f*:最大流) (この最悪ケースになることはほぼ無い)
*/

template <class T>
struct Edge {
    int rev, from, to;  // rev:逆向きの辺の番号
    T cap, original_cap;
    Edge(int r, int f, int t, T c) : rev(r), from(f), to(t), cap(c), original_cap(c) {}
};
template <class T>
struct Graph {
    vector<vector<Edge<T>>> G;
    Graph(int n = 0) : G(n) {}
    vector<Edge<T>>& operator[](int i) { return G[i]; }
    const size_t size() const { return G.size(); }
    Edge<T>& redge(Edge<T> e) {  // 逆向きの辺を返す
        return G[e.to][e.rev];   // 自己ループはないと仮定（あれば G[e.to][e.rev + 1] とする必要がある）
    }
    void add_edge(int from, int to, T cap) {  // 有向辺を加える
        G[from].push_back(Edge<T>((int)G[to].size(), from, to, cap));
        G[to].push_back(Edge<T>((int)G[from].size() - 1, to, from, 0));
    }
};
/* FordFulkerson: Ford-Fulkersonのアルゴリズムで最大流を求める構造体
    max_flow(G,s,t)：sからtへのグラフGの最大流を求める
    副作用：G は最大流の残余ネットワークになる
    計算量: O(|f*||E|) (f*:最大流) (この最悪ケースになることはほぼ無い)
*/
template <class T>
struct FordFulkerson {
    const T INF = 1e9;
    vector<int> used;
    FordFulkerson(){};
    T dfs(Graph<T>& G, int v, int t, T f) {  // 増加可能経路を見つけて増加分のフローを返す
        if (v == t) return f;
        used[v] = true;
        for (auto& e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                T d = dfs(G, e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G.redge(e).cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    T max_flow(Graph<T>& G, int s, int t) {
        T flow = 0;
        while (true) {
            used.assign(G.size(), 0);
            T f = dfs(G, s, t, INF);  // f が増加分のフロー
            if (f == 0) {
                return flow;
            } else {
                flow += f;
            }
        }
        return 0;
    }
};

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

    ll X, Y, E;
    cin >> X >> Y >> E;
    Graph<ll> g(X + Y + 2);
    rep(i,E) {
        ll x, y;
        cin >> x >> y;
        g.add_edge(x, X+y, 1);
    }
    rep(i, X) g.add_edge(X + Y, i, 1);
    rep(i, Y) g.add_edge(X + i, X+Y+1, 1);

    FordFulkerson<ll> ff;
    ll ans = ff.max_flow(g, X+Y, X+Y+1);
    cout << ans << endl;
}



Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int[] numArray = parseInt(getSplitLine(line));

        int x;
        int y;
        if (numArray[0] > numArray[1]) {
            x = numArray[0];
            y = numArray[1];
        } else {
            x = numArray[1];
            y = numArray[0];
        }

        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }

        System.out.println(y);
    }

    private static String[] getSplitLine(String line) {
        return line.split("\\s");
    }

    private static int[] parseInt(String[] line) {
        int[] numArray = new int[line.length];
        for (int i = 0; i < line.length; i++) {
            numArray[i] = Integer.parseInt(line[i]);
        }
        return numArray;
    }
}


Measured memory_bytes: 24488
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxx = 110;
const int INF = 2e9 + 10;

int n,q;
int d[maxx][maxx];

void floyd() {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (d[i][k] == INF)
                continue;
            for (int j = 0; j < n; j++) {
                if (d[k][j] == INF)
                    continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
int main()
{
    int u, v, c;
    scanf("%d %d", &n, &q);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++)
            d[i][j] = i == j ? 0 : INF;
    }

    // 输入权值
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &u, &v, &c);
        d[u][v] = c;
    }

    floyd();

    // 判断是否存在负环
    bool negative = false;
    for (int i = 0; i < n; i++)
        if (d[i][i] < 0)
            negative = true;

    if (negative)
        printf("NEGATIVE CYCLE\n");
    else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (d[i][j] == INF)
                    printf("INF");
                else
                    printf("%d", d[i][j]);
                printf("%c", j == n - 1 ? '\n' : ' ');
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3252
N=input()
keta=len(N)
K=int(input())

# 桁DP
# dp[桁数][未満フラグ][0じゃない数の数]
# 010みたいなときに頭の0を数えないよう注意（0を数えると面倒、0じゃないを数えれば問題なし）

dp=[[[0 for i in range(K+1)] for j in range(2)] for k in range(keta)]

# ある数が与えられたときに、その数未満で0じゃない数の値を返す
def getMiman(X):
  if X>0:
    return X-1
  else:
    return 0

x0=int(N[0])
# 未満じゃないのに先頭が0はあり得ない
dp[0][0][0]=0
# 未満で、0じゃない数が存在しないのは先頭から0の場合のみ
dp[0][1][0]=1
# 未満じゃなく、0でない数が1->元の数の場合なので1
dp[0][0][1]=1
# 未満で、0でない数が1　3の場合2,1
dp[0][1][1]=getMiman(x0)

for i in range(1,keta):
  # 全桁をDP
  x=int(N[i])
  # 未満じゃないのに0じゃない数が0個なのはあり得ない
  dp[i][0][0]=0
  # 未満で、0じゃない数が存在しないのはここまでずっと0だった場合のみ
  dp[i][1][0]=1
  for j in range(1,K+1):
    # 未満じゃなくて、0じゃない数がj個なのは以下の合計：
    # ・前の桁（未満じゃない）で0じゃない数がj-1個で、今回の桁が0じゃない場合
    # ・前の桁（未満じゃない）で0じゃない数がj個で、今回の桁が0
    dp[i][0][j]=dp[i-1][0][j-1]*(x!=0)+dp[i-1][0][j]*(x==0)
    
    # 未満で、0じゃない数がj個なのは以下の合計：
    # ・前の桁（未満じゃない）で0じゃない数がj-1個で、今回の桁が未満相当（getMiman）
    # ・前の桁（未満じゃない）で0じゃない数がj個で、今回の桁が0でない場合に0を選択する
    # ・前の桁（未満）で0じゃない数がj-1個で、今回は1-9まで選べるので9通り
    # ・前の桁（未満）で0じゃない数がj個で、今回は0を選ぶ
    dp[i][1][j]=dp[i-1][0][j-1]*getMiman(x)+dp[i-1][0][j]*(x!=0)+dp[i-1][1][j-1]*9+dp[i-1][1][j]*1
  
print(dp[keta-1][0][K]+dp[keta-1][1][K])  


Measured memory_bytes: 3064
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int D, N;
	std::cin >> D >> N;

	int result;
	if (D == 0)
		result = 1;
	else if (D == 1)
		result = 100;
	else
		result = 10000;
	if (N == 100)
		result *= 101;
	else
		result *= N;
	std::cout << result << "\n";
}


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

#define ll long long
using namespace std;

vector<ll> a;
ll getDigit(ll n){
    
    if(n==0){
        return 0;
    }
    
    return getDigit(n/10)+1;
}

ll dfs(ll i,ll b,ll s){
    ll r1,r2;
    if(i==a.size()-1){
        //cout<<"s : "<<s+a[i]<<endl;
        return s+a[i];
    }else{
        r1=dfs(i+1,0,s+a[i]);
        r2=dfs(i+1,10*b+10*a[i],10*b+10*a[i]+s-b);

        //cout<<r1+r2<<endl;
        return r1+r2;        
    }
}

int main(){
    ll n,dig;
    cin>>n;

    dig=getDigit(n);
    //cout<<dig<<endl;
    a.resize(dig);
    for(ll i=0; i<dig; i++){
        a[i]=n%10;
        n/=10;
        //cout<<i<<endl;
    }
    reverse(a.begin(),a.end());
/*
    for(auto m: a){
        cout<<m<<" ";
    }cout<<endl;
*/
    cout<<dfs(0,0,0)<<endl;

    return 0;
    
}

Measured memory_bytes: 764
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     mt           make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=3e3+10;

vector<vector<ld>> dp(N,vector<ld>(N,-1));       // (index, heads till now)

vector<ld> p;
int n;

ld rec(int ind,int h)
{
    if(ind==-1)
        return h>(n/2);

    if(dp[ind][h]!=-1)
        return dp[ind][h];

    ld res=0;
    res=( (1-p[ind])*rec(ind-1,h) + p[ind]*rec(ind-1,h+1) );

    //cout<<ind<<" "<<h<<" "<<res<<"\n";

    return (dp[ind][h]=res);
}

void solve()
{
    cin>>n;

    p.resize(n);
    for(int i=0;i<n;++i)
        cin>>p[i];

    ld ans=rec(n-1,0);

    cout<<fixed<<setprecision(10)<<ans;
}

int32_t main()
{
    //fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 142208
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }
 
int main(){
    ll K,X; cin >> K >> X;
    if(500*K >= X) print("Yes");
    else print("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{     

      ios_base::sync_with_stdio(0);
      cin.tie(0);
      int n,wt;
      cin>>n>>wt;
    
      int w[n+1],v[n+1];
      
      long long int dp[n+1][wt+1];
    
      for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    
      for(int i=0;i<n;i++)
      	dp[i][0]=0;
      for(int i=0;i<n;i++)
      {
        for(int j=1;j<=wt;j++)
        {
          if(i==0)
          {
            if(j>=w[i])
              dp[i][j]=v[i];
            else
              dp[i][j]=0;
          }
          else
          {
          if(j-w[i]<0)
            dp[i][j]=dp[i-1][j];
          else
          	dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
          }
        }
      }
      cout<<dp[n-1][wt];


return 0;    
}

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

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

	long long mans[N][2];
	for(int i = 0; i < N; i++){
		int a, b; cin >> a >> b;
		mans[i][0] = a;
		mans[i][1] = b;
	}
	long long points[M][2];
	for(int i = 0; i < M; i++){
		int c, d; cin >> c >> d;
		points[i][0] = c;
		points[i][1] = d;
	}

	int min_inds[N];
	for(int i = 0; i < N; i++){
		long long min_dis = abs(points[0][0] - mans[i][0]) + abs(points[0][1] - mans[i][1]);
		int min_ind = 0;
		for(int j = 1; j < M; j++){
			long long dis = abs(points[j][0] - mans[i][0]) + abs(points[j][1] - mans[i][1]);
			if(dis < min_dis){
				min_dis = dis;
				min_ind = j;
			}
		}
		min_inds[i] = min_ind + 1;
		cout << min_inds[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

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

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

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


int main(void){
  int n;
  cin >> n;
  int work[n+1];
  rep(i,n){
    work[i+1] = 0;
  }
  rep(i,n-1){
    int id;
    cin >> id;
    work[id]++;
  }

  rep(i,n){
    cout << work[i+1] << endl;
  }
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M; cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    // 累積和
    vector<ll> s(N+1, 0); // s[0] = 0 になる
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

    vector<ll> mo(N+1);
    rep(i, N+1){
        mo[i] = s[i] % M;
    }

    unordered_map<ll, ll> um;
    rep(i, N+1){
        um[mo[i]]++;
    }

    ll res = 0;
    for(auto c: um){
        res += (c.second*(c.second-1))/2;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 10124
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
    	List<Integer> ans = new ArrayList<Integer>();
    	while(line!=null){
    		ans.add(Integer.parseInt(line));
    		line = br.readLine();
    	}
		Collections.sort(ans,new Comparator<Integer>(){
			public int compare(Integer a,Integer b){
				return b-a;
			}
		});
    	for(int i=0;i<3;i++){
    		System.out.println(ans.get(i));
    	}
	}
}

Measured memory_bytes: 24324
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a==b){
            if(c != a)
                System.out.println("Yes");
            else
                System.out.println("No");
        } else if(a==c){
            if(b != a)
                System.out.println("Yes");
            else
                System.out.println("No");
        } else if(b==c){
            if(a != b)
                System.out.println("Yes");
            else
                System.out.println("No");

        } else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#include <random>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 100005;
const int MAXM = 50005;
const double EPS = 1e-8;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}

void solve()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max(max(a*c,a*d),max(b*c,b*d))<<endl;
}


int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();

    // int T;
    // cin >> T;
    // while (T--)
        solve();

    //cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long ans = 0;
  rep(i,n-1){
    ans += n/(i+1);
    if(n%(i+1) == 0)ans--;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {

  int n;
  while(true) {

    cin>>n;
    if(!n) break;

    vector<int> v;
    int s;
    for(int i=0; i<n; i++) {
      cin>>s;
      v.push_back(s);
    }

    sort(v.begin(), v.end());

    long long sum=0,l;
    for(int i=0; i<n; i++) {
      l=0;
      for(int j=0; j<i; j++)
	l += v[j];
      sum += l;
    }

    cout<<sum<<endl;
  }
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int a[100005]={0},b[100005]={0};
int main()
{
	int i,n,m=1e6,t,A,B,M,ta,tb,T,ma=1e6,mb=1e6;
	cin>>A>>B>>M;
	for(i=1;i<=A;i++){scanf("%d",&a[i]);if(a[i]<ma)ma=a[i];}
	for(i=1;i<=B;i++){scanf("%d",&b[i]);if(b[i]<mb)mb=b[i];}
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&ta,&tb,&t);
		T=a[ta]+b[tb]-t;
		if(T<m)m=T;
	}
	cout<<min(m,ma+mb);
	return 0;
} 

Measured memory_bytes: 1024
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    sumv = i
    cnt = 1
    while True:
        if sumv >= k: break
        sumv *= 2
        cnt /= 2
    ans += cnt
print(ans/n)

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <utility>

using namespace std;
typedef long long ll;

struct node {
    vector< pair<int, ll> > edges;
    ll dist;
};

node nd[100000];
void dfs(int cur,  int pre, ll cost_sum) {
    for(int i=0;i<nd[cur].edges.size();i++) {
        if(nd[cur].edges[i].first == pre) continue;
        dfs(nd[cur].edges[i].first, cur, cost_sum+nd[cur].edges[i].second);
    }
    nd[cur].dist = cost_sum;
    return;

}

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n-1;i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        nd[a].edges.push_back(make_pair(b, c));
        nd[b].edges.push_back(make_pair(a, c));
    }
    ll Q, K;
    cin >> Q >> K;
    K--;
    dfs(K, -1, 0);
    for(int i=0;i<Q;i++) {
        int x, y;
        cin >> x >> y;
        x--;y--;
        cout << nd[x].dist + nd[y].dist << endl;
    }



}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 1001001001;
  rep(i, s.size()-t.size()+1){
    int add = 0;
    rep(j, t.size()){
      if(s.at(i+j) != t.at(j)) add++;
    }
    // cerr << add << endl;
    ans = min(ans, add);
  }
  cout << ans << endl;
  return 0;
}

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

int N;
const int MAX_N = 2.0e5 + 100;
ll a[MAX_N];

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

    ll sum = 0;
    for (int i = 0; i < N; i++) {
        sum += a[i];
    }

    ll min_diff = 1.0e18;
    ll now = 0;
    for (int i = 0; i < N - 1; i++) {
        now += a[i];
        min_diff = min(min_diff, abs(now - (sum - now)));
    }

    cout << min_diff << endl;

    return 0;
}


Measured memory_bytes: 1792
n, c, k = [int(x) for x in raw_input().split()]

t = []
for i in xrange(n):
	t.append(int(raw_input()))

t.sort()

d = -k - 1
ans = 0
p = 0
for ti in t:
	if d + k < ti or p >= c:
		ans += 1
		d = ti
		p = 0
	p += 1

print(ans)


Measured memory_bytes: 6332
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100100100;//10^17
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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



int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a;
    rep(i, N){
        int n;
        cin >> n;
        a.push_back(n);
    }
    vector<pair<int, int>> pairs(M);
    rep(i, M){
        int n, m;
        cin >> n >> m;
        pairs[i] = make_pair(m, n);
    }
    sort(all(a));
    sort(all(pairs), greater<pair<int, int>>());
    int p_index = 0;
    rep(i, N){
        if(p_index == M) break;
        if(a[i] < pairs[p_index].first){
            a[i] = pairs[p_index].first;
            pairs[p_index].second--;
            if(pairs[p_index].second == 0)p_index++;
        }
    }

    ll ans = 0;
    rep(i, N) ans += a[i];
    cout << ans << endl;
    
} 

Measured memory_bytes: 1528
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    multiset <int, greater<int>> st;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (st.size() == 0) {
            st.insert(a);
        } else {
            auto itr = st.upper_bound(a);
            if (itr == st.end()) {
                st.insert(a);
            } else {
                st.erase(itr);
                st.insert(a);
            }
        }
    }

    cout << st.size() << "\n";
    return 0;
}

Measured memory_bytes: 4992
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,m=get_i
city=array(n,1,0)
m.times do|i|
  a,b=get_i
  a-=1
  b-=1
  city[a]+=1
  city[b]+=1
end
n.times do|i|
  puts city[i]
end

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


const int vmax=200010;
int par[vmax],sz[vmax];
void init(){rep(i,vmax) par[i]=i,sz[i]=1;}
int find(int x){ 
	if(par[x]==x){
		return x;
	}else{
		sz[par[x]]+=sz[x],sz[x]=0;
		par[x]=find(par[x]);
		return par[x];
	}
}

void unite(int a,int b){a=find(a);b=find(b);par[a]=b;find(a);}


int main(void){
	int n;
	cin >> n;
	init();
	vector<edge> graph;
	rep(i,n-1){
		int a,b,c;
		cin >> a >> b >> c;
		graph.push_back(edge(c,a,b));
	}
	sort(graph.begin(),graph.end());

	ll ans=0LL;
	for(auto &e:graph){
		int a,b,c;
		tie(c,a,b)=e;
		a=find(a),b=find(b);
		ans+=1LL*sz[a]*sz[b]*c;
		unite(a,b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7420
<?php
    fscanf(STDIN,'%d %d',$k,$n);
    $aArray = explode(' ',trim(fgets(STDIN)));
    
    $distArray = [];
    for($index=0;$index<$n-1;++$index){
        $distArray[] = $aArray[$index+1] - $aArray[$index];
    }
    $distArray[] = ($k - $aArray[$n-1]) + $aArray[0];

    echo $k - max($distArray).PHP_EOL;
?>

Measured memory_bytes: 67428
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final char[] THE = {'t', 'h', 'e'};
		final char[] THIS = {'t', 'h', 'i', 's'};
		final char[] THAT = {'t', 'h', 'a', 't'};
		while(sc.hasNext()){
			char[] charset = sc.nextLine().toCharArray();
			for (int i = 0; i <= (int)('z'-'a'); i++){
				if (isMatch(charset, THE)
						|| isMatch(charset, THIS)
						|| isMatch(charset, THAT)){
					System.out.println(charset);
					break;
				}
				charset = charshift(charset, 'a', 'z');
			}
		}
		sc.close();
	}
	
	private static boolean isMatch(char[] c, char[] pattern){
		boolean res = false;
		for (int i = 0; i < c.length - pattern.length + 1; i++){
			boolean flag = true;
			for (int j = 0; j < pattern.length; j++){
				flag = flag && (c[i+j] == pattern[j]);
			}
			if(flag){
				res = flag;
				break;
			}
		}
		return res;
	}
	
	private static char[] charshift(char[] c, char start, char end){
		char[] res = new char[c.length];
		for (int i=0; i < c.length; i++){
			if(c[i]>= start && c[i]< end){
				res[i] = (char)((int)c[i] + 1);
			}else if(c[i] == end){
				res[i] = start;
			}else{
				res[i] = c[i];
			}
		}
		return res;
	}
}

Measured memory_bytes: 18028
import numpy as np
N, M, K = [int(x) for x in input().split(' ')]
A =  [int(x) for x in input().split(' ')]
B =  [int(x) for x in input().split(' ')]
cA = np.cumsum([0] + A)
cB = np.cumsum([0] + B)
ans = 0
for nA in range(len(cA)):
  if K < cA[nA]:
    break
  time_left = K - cA[nA]
  nB = np.searchsorted(cB, time_left, side='right') - 1
  #print(nA, cA[nA], time_left, nB, cB[nB])
  ans = max(ans, nA + nB)
print(ans)
	

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<int, int> > g[n];
    int label[n];
    for(int i=0;i<n;i++) label[i] = -1;
    for(int i=0;i<n-1;i++){
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        g[u].push_back(make_pair(v, w));
        g[v].push_back(make_pair(u, w));
    }
    queue<int> Q;
    label[0] = 0;
    Q.push(0);
    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        int lb = label[v];
        for(pair<int, int> p: g[v]){
            int u = p.first, w = p.second;
            if(label[u] == -1){
                // labeling
                if(w %2 == 0){
                    label[u] = lb;
                }else{
                    label[u] = (lb + 1) % 2;
                }
                Q.push(u);
            }
        }
    }
    for(int i=0;i<n;i++) cout << label[i] << endl;
}

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

int main() {
  int N,sum;
  sum = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i =0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end(),greater<int>() );
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum += vec.at(i);
    }
    else if(i%2==1){
      sum -= vec.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).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 INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
int N;
vi G[114514];
int color[114514]={0};
int main(){
	ll K;
	ll N=50;
	cin>>K;
	ll x=K/(ll)N,y=K%N;
	cout<<N<<endl;
	for(ll i=0;i<y;i++){
		cout<<2*N+x-y<<" ";
	}
	for(ll i=0;i<N-y;i++){
		cout<<N-1+x-y<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;
  if(n/100 == n%10) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#D - Chat in a Circle
N = int(input())
A = list(map(int,input().split()))
#ソート
arr = []
arr = sorted(A,reverse = True)

Friend_min_max_wa = 0
i =0
j = 0
for i in range(N -1):
    if i % 2 != 0 : j = j + 1
    Friend_min_max_wa = Friend_min_max_wa + arr[j]

# 出力
print(Friend_min_max_wa)

Measured memory_bytes: 31344
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
#define ll long long
#define M
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}
int main() {
	int n = read();
	int ans = read();
	for(int i = 1; i < n; i++) ans = gcd(ans, read());
	cout << ans << "\n";



	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll LINF = (ll) 4e18;
#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> towns(r);

    rep(i, r) {
        cin >> towns[i];
        towns[i]--;
    }
    sort(all(towns));

    ll dist[n][n];
    rep(i, n) rep(j, n) dist[i][j] = (i == j ? 0 : LINF);

    rep(k, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        dist[a][b] = dist[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    ll ans = LINF;
    do {
        ll dist_sum = 0;
        rep(i, r - 1) dist_sum += dist[towns[i]][towns[i + 1]];
        ans = min(ans, dist_sum);
    } while (NP(towns));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
ll n,W;
int w[100+10],v[100+10];
int dp[100+10][100000+10];
int main()
{
    cin>>n>>W;
    for(int i=0;i<n;i++)    cin>>w[i]>>v[i];
    fill(dp[0],dp[0]+100000+1,inf);
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            if(j<v[i])  dp[i+1][j]=dp[i][j];
            else    dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
        }
    }
    int res=0;
    for(int i=0;i<=100000;i++)
    {
        if(dp[n][i]<=W) res=i;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 41216
#include <iostream>
    #include <numeric>
    #include <vector>
    #include <string>
    #include <algorithm>
    using namespace std;
    int main(){
      int n;
      cin>>n;
      long long int num1=0;
      long long int num2=0;
      long long int num3=0;
      long long int num4=0;
      long long int num5=0;
      for(int i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        if(tmp[0]=='M'){
          num1+=1;
        }
        else if(tmp[0]=='A'){
          num2+=1;
        }
        else if(tmp[0]=='R'){
          num3+=1;
        }
        else if(tmp[0]=='C'){
          num4+=1;
        }
        else if(tmp[0]=='H'){
          num5+=1;
        }
      }
      vector<long long> ans(10);
      ans[0]=num1*num2*num3;
      ans[1]=num1*num2*num4;
      ans[2]=num1*num2*num5;
      ans[3]=num1*num3*num4;
      ans[4]=num1*num3*num5;
      ans[5]=num1*num4*num5;
      ans[6]=num2*num3*num4;
      ans[7]=num2*num3*num5;
      ans[8]=num2*num4*num5;
      ans[9]=num3*num4*num5;
      long long sum=accumulate(ans.begin(),ans.end(), 0LL);
      cout<<sum<<endl;
     }

Measured memory_bytes: 256