akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
map<int,int> a;
int main(){
	while(true){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		int h[1500],w[1500],sh[1501]={},sw[1501]={};
		a.clear();
		rep(i,n) cin>>h[i];
		rep(i,m) cin>>w[i];
		rep(i,n) sh[i+1]=sh[i]+h[i];
		rep(i,m) sw[i+1]=sw[i]+w[i];
		rep1(i,n) rep(j,i) a[sh[i]-sh[j]]++;
		long long ans=0;
		rep1(i,m) rep(j,i){
			int k=sw[i]-sw[j];
			ans+=a[k];
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 19052
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	int N, X, T;
	cin >> N >> X >> T;
	cout << (N + X - 1) / X * T << endl;
	return 0;
}

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

const int INF = 1 << 29;

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

    int m;
    while(cin >> m && m){

        int n;
        cin >> n;

        int d[300];
        for(int i = 1; i <= n; ++i){
            cin >> d[i];
        }

        bool g[300][300];
        for(int i = 0; i <= n + 1; ++i){
            for(int j = 0; j <= n + 1; ++j){
                g[i][j] = false;
            }
        }

        for(int i = 0; i < n + 1; ++i){
            for(int j = 1; j <= m; ++j){
                if(i + j >= n + 1){
                    g[i][n + 1] = true;
                }
                else {
                    g[i][max(0, min(n + 1, i + j + d[i + j]))] = true;
                }
            }
        }

        for(int k = 0; k <= n + 1; ++k){
            for(int i = 0; i <= n + 1; ++i){
                for(int j = 0; j <= n + 1; ++j){
                    if(g[i][k] && g[k][j]){
                        g[i][j] = true;
                    }
                }
            }
        }

        bool check = g[0][n + 1];
        for(int i = 1; i <= n; ++i){
            //cout << g[0][i] << " " << g[i][n + 1] << endl;
            if(g[0][i] && !g[i][n + 1]){
                check = false;
            }
        }

        cout << (check ? "OK" : "NG") << endl;
    }

   return 0;
}

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

using namespace std;
typedef long long ll;

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

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

    rep2(i, 1, n + 1)
    {
        double price = i * 1.08;
        if (n == (int)price)
        {
            cout << i << '\n';
            return (0);
        }
    }

    cout << ":(" << '\n';
    return (0);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    ll a = N/K;
    ll b= (N-(K/2))/K+1;
    if(K > 2*N){
        cout << 0 << endl;
        return 0;
    }
    if(K%2 == 0){
        cout << a*a*a + b*b*b <<endl;
    }
    else{
        cout << a*a*a <<endl;
    }
    return 0;
}

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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 6e5 + 10;
const int maxM = 1e5 + 100;
const int oo = 1e9 + 100;
const int MOD = 1e9 + 7;
const int Base = 311;
const long double du = 1e-9;
const string YES = "YES";
const string NO = "NO";
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

typedef pair<int, int> i2;
int fen[maxN];
int n;
void update(int p, int val){
    for(int i = p; i <= n; i += i & -i)
        fen[i] = max(fen[i], val);
}
int get(int p) {
    int ans = 0;
    for(int i = p; i; i -= i & -i)
        ans = max(ans, fen[i]);
    return ans;
}
int LIS(vector <i2> a) {
    int sz = (int)a.size();
    vector <int> Nen;
    for (i2 x : a) {
        Nen.push_back(x.first);
        Nen.push_back(x.second);
    }
    sort(Nen.begin(), Nen.end());
    Nen.resize(unique(Nen.begin(), Nen.end()) - Nen.begin());
    n = (int)Nen.size();
    for (i2 &x : a) {
        x.first = lower_bound(Nen.begin(), Nen.end(), x.first) - Nen.begin() + 1;
        x.second = lower_bound(Nen.begin(), Nen.end(), x.second) - Nen.begin() + 1;
    }
    sort(a.begin(), a.end(), [](i2 a, i2 b) {
        if (a.first != b.first) return a.first < b.first;
        return a.second > b.second;
    });
    ///for (i2 x : a) cout << x.first << " " << x.second << endl;
    for (i2 x : a) {
        int f = get(x.first);
        update(x.second, f + 1);
    }
    return get(n);
}
void solve() {
    int n;
    cin >> n;
    vector <i2> a(n);
    for (int i = 0; i < n; i++) {
        int x, L;
        cin >> x >> L;
        a[i] = i2(x - L, x + L);
    }
    cout << LIS(a);
}
int main(int argc,char *argv[]) {
    ///srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   /// doc();
    solve();
}


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

long long modpow(long long a,long long n,long long MOD){
    int ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}

long long modinv(long long a, long long MOD) {
    return modpow(a, MOD - 2, MOD);
}

int main(){
    long long n,a,b,MOD;
    MOD = 1000000007;
    cin >> n >> a >> b;
    //fact(n,b,MOD);

    int all = modpow(2,n,MOD) - 1;
    long long fac1[b],fac2[b];
    fac1[0] = n % MOD;
    fac1[1] = fac1[0] * (n - 1) % MOD;
    fac2[0] = fac2[1] = 1;
    for (int i = 2;i < b + 1;i++) {
        fac1[i] = fac1[i - 1] * (n - i) % MOD;
        fac2[i] = fac2[i - 1] * i % MOD;
    }

    long long cmba = fac1[a - 1] * modinv(fac2[a],MOD) % MOD;
    long long cmbb = fac1[b - 1] * modinv(fac2[b],MOD) % MOD;

    int ans;
    ans = all - cmba - cmbb;
    ans %= MOD;
    if (ans < 0) ans += MOD;

    cout << ans << endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int k;
  string s;
  cin >> k;
  cin >> s;
  rep(i, s.size()) {
    if (i >= k) {
      cout << "...";
      break;
    } else {
      cout << s[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
#define N 1001
static const int INFTY = (1<<21);

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init();
void enqueue(int x);
int empty();
int dequeue();
void bfs(int s);

int main(){
  int  l, m, k, i, j; 

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &l, &m);
    l--;
    for ( j = 0; j < m; j++ ){
      scanf("%d", &k);
      k--;
      M[l][k] = 1;
    }
  }
  
  bfs(0);

  return 0;
}

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}



Measured memory_bytes: 2140
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
const int dx2[] = { -1,-1, 0,1,1, 1, 0,-1 }; const int dy2[] = { 0,-1,-1,-1,0, 1, 1, 1 };
struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int h, w;
int cell[50][50];
int main() {
	while (cin>>w>>h,h) {

		REP(i, h)
			REP(j, w)
			cin >> cell[i][j];
		int ans = 0;
		REP(i, h)
			REP(j, w)
			if (cell[i][j] == 1) {
				ans++;
				queue<pii> Q;
				Q.push(pii(i, j));
				cell[i][j] = 0;
				while (!Q.empty()){
					pii q = Q.front();Q.pop();
					int y = q.first;
					int x = q.second;
					REP(k,8) {
						if (0 <= y + dy2[k] && y + dy2[k] < h && 0 <= x + dx2[k] && x + dx2[k] < w &&cell[y + dy2[k]][x + dx2[k]]) {
							cell[y + dy2[k]][x + dx2[k]] = 0;
							Q.push(pii( y + dy2[k], x + dx2[k]));
						}
					}
				}
			}
		cout << ans << endl;
	}
}

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

int main() {
    string s; cin >> s;
    string S = s; reverse(begin(S), end(S));
    string t1 = s.substr(0, (s.size() - 1) / 2);
    string t2 = t1; reverse(begin(t2), end(t2));
    string u1 = s.substr((s.size() + 1) / 2, (s.size() - 1) / 2);
    string u2 = u1; reverse(begin(u2), end(u2));

    if(s == S and t1 == t2 and u1 == u2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;


int main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  ll n;
  cin >> n;
  
  ++n;

  ll cnt = 0;
  while (n > 9) {
    n /= 10;
    ++cnt;
  }

  int ans = (n - 1) + 9 * cnt;

  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll h[100010];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  a -= b;
  ll l = 0, r = 1e9;
  while (l <= r) {
    ll m = (l + r) / 2;
    ll hurt = b * m;
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
      if (h[i] <= hurt) continue;
      cnt += (h[i] - hurt + a - 1) / a;
    }
    if (cnt > m) l = m + 1;
    else r = m - 1;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 1024
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]

sMax = 0
eMin = 0
for s, e in l:
  if sMax < s or sMax == 0:
    sMax = s
  if eMin > e or eMin == 0:
    eMin = e

if eMin - sMax >= 0:
  print(eMin - sMax + 1)
else:
  print(0)

Measured memory_bytes: 21156
x = int(input())
def level(x):
    if x >= 1800:
        return 1
    elif x>= 1600:
        return 2
    elif x>=1400:
        return 3
    elif x>=1200:
        return 4
    elif x >= 1000:
        return 5
    elif x >= 800:
        return 6
    elif x >= 600:
        return 7
    else:
        return 8
print(level(x))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n);
    VEC(ll, a, n);
    ll money = 1000;
    REP(i, n - 1) if(a[i] < a[i + 1]) money += (money / a[i]) * (a[i + 1] - a[i]);
    print(money);
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int ans=0;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1]){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}


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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

stack<int> st;
int x;

signed main() {
    while(cin>>x){
        if(x)st.push(x);
        else {
            std::cout << st.top() << '\n';
            st.pop();
        }
    }



    return 0;
}



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

typedef vector<int>  vi;
typedef set<char> setchar;
typedef set<int> sett;
typedef deque <int> dq;
typedef long long ll;
#define vec(a)  a.begin(),a.end()
#define pb     push_back
#define pf     push_front
#define F first
#define S second
#define mem(a,b) memset(a,b,sizeof(a));
#define inI(a)  scanf("%d",&a);
#define inT(a,b)  scanf("%d %d",&a,&b);
#define inL(a)  scanf("%lld",&a);
#define SWAP(a,b) a= a^b, b=a^b, a=a^b

//int fx[]={+0,-1,-1,-1,+0,+1,+1,+1};
//int fy[]={-1,-1,+0,+1,+1,+1,+0,-1};
int fx[]= {0,-1,0,+1};
int fy[]= {-1,0,+1,0};



int main()
{

    //freopen("input.txt","r",stdin);
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t)
        cout<<"Yes"<<"\n";
    else
        cout<<"No\n";



    return 0;

}







Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
    int n,v,c=0,d=0,i,j,jj;
    std::vector<int> A;

    cin >> n;

    for(i=0;i<n;i++){
        cin >> v;
        jj=(int)sqrt(v);
        for(j=2;j<=jj;j++){
            d=0;
            if(v%j==0){
                d++;
                break;
            }
        }
        if(d==0){
            c++;
        }
        
    }
    cout << c <<"\n";
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

   //int t; cin>>t; while(t--) 
	int n,m; cin>>n>>m;
	int ans=(n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans;
	
    return 0 ;  
}

Measured memory_bytes: 256
// C - Traveling Salesman around Lake
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

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

	vi A(N+1);
	rp(i,0,N) cin>>A[i];
	A[N] = A[0] + K;

	vi d(A.size()-1);
	rp(i, 0, A.size()-1) d[i] = A[i+1] - A[i];

	sort(all(d));

	int ans = 0;
	rp(i, 0, N-1) ans += d[i];
	cout<< ans <<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n,s=0;
    cin>>n;
    vector<long long> va(n,0);
    vector<long long> vb(n,0);
    for(int i=0;i<n;i++){
        cin>>va[i]>>vb[i];
    }
    for(int i=n-1;i>=0;i--){
        s+=((vb[i]-(va[i]+s)%vb[i])%vb[i]);
    }
    cout<<s<<endl;
}


Measured memory_bytes: 1792
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()

i = 1

while i*1000<N:
    i+=1

Out.int(i*1000 - N)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 69304
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u128; n],
    }
    let mut result = 1;
    if a.iter()
        .collect::<std::collections::HashSet<_>>()
        .contains(&0)
    {
        println!("{}", 0);
        return;
    }
    for ai in a {
        result *= ai;
        if result > 10u128.pow(18) {
            println!("{}", -1);
            return;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 6624
n=int(input())
arr=[]
cnt=1
for i in range(n):
  arr.append(int(input()))
i=0
while cnt < n:
  j = arr[i]
  if j == 2:
    print(cnt);
    break
  else:
    i=j-1
    cnt+=1
    if cnt>=n:
      print(-1)
      break

Measured memory_bytes: 7084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		long n = sc.nextLong();
		long m = sc.nextLong();
		
		long res = 0;
		
		if(2 * n > m) {
			res+=m/2;
		}else{
			res+=n;
			m -= n*2;
			res += m/4;
		}
		
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

using namespace std;

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

    return(0);
}


Measured memory_bytes: 1792
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int():
        return int(input())

    def map_int_input():
        return map(int, input())

    MII = map_int_input

    def MII_split():
        return map(int, input().split())

    def MII_to_index():
        return map(to_index, input())

    def MII_split_to_index():
        return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs():
        return list(map(int, input()))

    LII = list_int_inputs

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

    # 2次元リスト化
    def LII_2D(rows_number):
        return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number):
        return [LII_split() for _ in range(rows_number)]

    import math
    def L(x, y, z):
        return int(x * x + y * y + z * z + x * y + y * z + z * x)

    N = input_int()
    # for n in range(1, N + 1):  # f(n)を計算する仮定でf(n-1)の候補が現れるので...

    ans = [0 for _ in range(N)]
    for x in range(1, 105):
        for y in range(1, 105):
            for z in range(1, 105):
                f = L(x, y, z)

                if f <= N:
                    ans[f - 1] += 1
                    # if x == y == z:
                    #     ans[f - 1] += 1
                    # else:
                    #     ans[f - 1] += 3

    for a in ans:
        print(a)
resolve()

Measured memory_bytes: 9200
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	std::string S;
	in >> N >> S;

	rep(i, S.length())
	{
		if (S[i] + N > 'Z') S[i] = 'A' + (N - ('Z' - S[i]) - 1);
		else S[i] += N;
	}

	out << S << std::endl;
}


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

bool isP(int x){
  if(x==0||x==1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}

int main(){
  int n,a,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt+=isP(a);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	x=c-(a-b);
	if(x>=1){
		printf("%d\n",x);
	}
	else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 128
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x = ni()
a = 100
i = 0
while a < x:
    a += a//100
    i += 1

print(i)

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

int main(){
    int k;
    cin>>k;
    string S;
    cin>>S;
    if(S.size()<=k) cout<<S<<"\n";
    else{
        for(int i=0; i<k; ++i) cout<<S[i];
        cout<<"...\n";
    }
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main() {
    ll A, B, C, K; cin >> A >> B >> C >> K;
    ll M = 0;
    while (A > 0 && K > 0) {
        M++;
        A--;
        K--;
    }
    while (B > 0 && K > 0) {
        B--;
        K--;
    }
    while (C > 0 && K > 0) {
        M--;
        C--;
        K--;
    }
    cout << M << endl;
}

Measured memory_bytes: 3632
n = int(input())

mins = [0] * n
maxs = [0] * n
for i in range(n):
    a, b = map(int, input().split())
    mins[i] = a
    maxs[i] = b

mins = sorted(mins)
maxs = sorted(maxs)

if n % 2 != 0:
    print(maxs[((n+1)//2) - 1] - mins[((n+1)//2) - 1] + 1)
else:
    print(int(2 * ((maxs[((n+1)//2) - 1] + maxs[n//2])/2 - (mins[((n+1)//2) - 1] + mins[n//2])/2) + 1))


Measured memory_bytes: 26936
#include<iostream>
using namespace std;
int main() {
	long long A,B;
	cin >> A >> B;
	long long a=4-A%4, b=B%4, n=0;
	for(long long i=A;   i<A+a; i++) n=n^i;
	for(long long i=B-b; i<=B;  i++) n=n^i;
	cout << n << endl;
	return 0;
}    


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())

if 2**1<=N<2**2:
    print(2**1)
elif 2**2<=N<2**3:
    print(2**2)
elif 2**3<=N<2**4:
    print(2**3)
elif 2**4<=N<2**5:
    print(2**4)
elif 2**5<=N<2**6:
    print(2**5)
elif 2**6<=N<2**7:
    print(2**6)
elif 2**7<=N<2**8:
    print(2**7)
elif 2**8<=N<2**9:
    print(2**8)
elif 2**9<=N<2**10:
    print(2**9)
elif 2**10<=N<2**11:
    print(2**10)
elif 2**11<=N<2**12:
    print(2**11)
elif 2**12<=N<2**13:
    print(2**12)
elif 2**13<=N<2**14:
    print(2**13)
elif 2**14<=N<2**15:
    print(2**14)
elif 2**15<=N<2**16:
    print(2**15)
elif 2**16<=N<2**17:
    print(2**16)
elif 2**17<=N<2**18:
    print(2**17)
elif 2**18<=N<2**19:
    print(2**18)
elif 2**19<=N<2**20:
    print(2**19)
else:
    print(2**20)


Measured memory_bytes: 5608
N = int(input())
P = [list(map(int,input().split())) for i in range(N)] # list of [t, x, y]
pret = prex = prey = 0
f = 1
for i in range(N):
    t = P[i][0]
    x = P[i][1]
    y = P[i][2]
    td = t - pret
    xd = abs(x - prex)
    yd = abs(y - prey)
    diff = xd + yd # 最低かかるt
    if td < diff:
        f = 0
        break
    if (td - diff) % 2 == 0:
        pret = t
        prex = x
        prey = y
        continue
    else:
        f = 0
        break
if f == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27032
int a,b,c,d,i,j;
main(){
  for(;~scanf("%d",&i);){
    for(a=10,j=0;a--;)
      for(b=10;b--;)
	for(c=10;c--;)
	  for(d=10;d--;)
	    (a+b+c+d-i)?0:j++;
    printf("%d\n",j);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  string ans = "Yes";
  set<string> box;
  string l;
  cin >> l;
  char last = l.at(l.size()-1);
  box.insert(l);
  rep(i,n-1){
    string s;
    cin >> s;
    if(box.count(s) || s.at(0) != last){
      ans = "No";
      break;
    }
    last = s.at(s.size()-1);
    box.insert(s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
def main():
    s = input()
    k = int(input())

    prev = s[0]
    prev_idx = 0
    idx = 1

    acm = []
    while idx < len(s):
        if s[idx] != prev:
            acm.append(idx - prev_idx)
            prev_idx = idx
            prev = s[idx]
        idx += 1

    acm.append(idx - prev_idx)

    bl = True
    for i in range(len(s) - 1):
        bl = bl and (s[i] == s[i+1])

    if bl:
        ans = len(s) * k // 2

    elif s[0] == s[-1]:
        ad = acm[0] + acm[-1]
        acm2 = acm[1:-1] + [ad]
        tmp = 0
        for e in acm2:
            tmp += e // 2
        tmp2 = 0
        for e in acm:
            tmp2 += e // 2
        ans = tmp * (k - 1) + tmp2

    else:
        tmp = 0
        for e in acm:
            tmp += e // 2
        ans = tmp * k

    print(ans)


if __name__ == "__main__":
    main()


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S; cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if(S[i] == 'A' && S[i+1] == 'C'){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int N,K; cin >> N >> K;
  int r = N, ans = 0;
  while(r >= K){
    r /= K;
    ans++;
  }
  cout << ans+1 << endl;
  return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int m=t.size();
    int ans=1e9;
    for(int i=0;i<n;i++){
        int count=0;
        for(int j=0;j<m;j++){
            if(i+j>=n){
                count=1e9;
                break;
            }
            if(s[i+j]!=t[j]) count++;
        }
        ans=min(count,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
# https://atcoder.jp/contests/abc144/tasks/abc144_b
# -*- coding: utf-8 -*-

input_val = int(input())
hantei = 0

for i in range(1, 10):
    val_side = input_val / i
    if val_side < 10 and i * int(val_side) == input_val:
        hantei = 1
        break

if hantei == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 1000005
#define mod 1000000007

ll all[maxN]={};
int s;

void solve() {
	
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	all[1]=1;
	for(int i=2;i<=1000000;i++){
		if(i%3!=0&&i%5!=0){
			all[i]=all[i-1]+i;
		}else{
			all[i]=all[i-1];
		}
	}
	cin>>s;
	cout<<all[s]<<endl;
}

Measured memory_bytes: 11480
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        long K = sc.nextLong();
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next())-1;
	        }
	        long ans=Long.MAX_VALUE;
	        int[] first = new int[N];
	        int[] second = new int[N];
	        int tmp=0;
	        boolean flg=false;
	        int min=0;
	        for(int i=1;true;i++) {
	        	tmp=(int) a[tmp];
	        	if(tmp!=0&&first[tmp]==0) {
	        		first[tmp]=i;
	        	} else if(second[tmp]==0) {
	        		second[tmp]=i;
	        		if(flg==false) {
	        			min=tmp;
	        			flg=true;
	        		}
	        	} else {
	        		break;
	        	}
	        }
	        if(K<second[min]) {
	        	for(int i=0;i<N;i++) {
	        		if(first[i]==K) {
	        			System.out.println(i+1);
	        			return;
	        		} 
	        	}
	        } else {
	        	int z =second[min]-first[min];
	        	int t = (int) ((K-first[min])%z);
	        	for(int i=0;i<N;i++) {
		        	if(second[i]!=0&&(second[i]-second[min])%z==t) {
	        			System.out.println(i+1);
	        			return;		        		
		        	}	        		
	        	}
	        }
	    }
	}

Measured memory_bytes: 60844
input = readlines
n = input[0].to_i
dish_rates = input[1..-1].map{|element| element.chomp.split(' ').map(&:to_i)}.sort_by{|e| e.inject(:+)}.reverse
if n == 1
  puts dish_rates[0][0]
else
  puts (0..n - 1).select{|i| i % 2 == 0}.map{|i| dish_rates[i][0]}.inject(:+) - (0..n - 1).select{|i| i % 2 == 1}.map{|i| dish_rates[i][1]}.inject(:+)
end



Measured memory_bytes: 19048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 100005;

ll n, a[N], c = 2, ans;

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
	ans += a[1]-1;
	for(ll i=2;i<=n;i++) {
		ans += (a[i]-1)/c;
		if(a[i] == c) c++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

ll solve()
{
    ll K,N;
    cin >> K;
    N = 50;
    cout << N << endl;
    vector<ll> ans(50);
    for1(i,50) {
        ans[i] = N - 1 + K / 50;
    }
    for1(i,K%50) {
        for1(j,50) {
            ans[j] -= 1;
        }
        ans[i] += N + 1;
    }
    for1(i,50) {
        if (i != 0) {
            cout << " ";
        }
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


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

int main(){
    string s,t;cin>>s>>t;
    bool ans=1;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i))ans=0;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;

  scanf("%d", &n);

  printf("%d\n", n / 3);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n;
  cin>>n;
  if(n==1) cout<<"Hello World"<<endl;
  else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
  
}

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b >= c) cout << b + c << '\n';
  else if (a >= c - b) cout << b + c << '\n';
  else cout << 2 * b + a + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include<cstring>
#include<iostream>
using namespace std;
char s[107];
unsigned long long k;
int main()
{
    cin>>s;
    cin>>k;
    for(int i=0;i<strlen(s);++i)
    {
        if(s[i]!='1')
        {
            cout<<s[i];
            return 0;
        }
        if(i+1==k)
        {
            cout<<s[i];
            return 0;
        }
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] n = new int[3];

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

		Arrays.sort(n);

		for (int i = 0; i < 3; i++) {
			System.out.print(n[i]);

			if (i != 2) {
				System.out.print(" ");
			} else {
				System.out.println();
			}

		}

		sc.close();

	}

}



Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    cin>>k>>s;
  int j = s.size();
    if(j <= k){
        cout<<s<<endl;
    }
    else{
        string s2 = s.substr(0,k);
        s2+="...";
        cout<<s2<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<61> Bitset;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = INT_MAX;
const int MAX = 300000;
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); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    ll K;
    cin>>N>>K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin>>A[i];
    vector<int> s;
    vector<int>ord(N+1,-1);
    int v = 1;
    while(ord[v]==-1){
        ord[v] = s.size();
        s.push_back(v);
        v = A[v-1];
    }
    int l = ord[v];
    int c = s.size() - l;
    if(K <= l){
        cout<<s[K]<<endl;
    }
    else{
        K -= l;
        cout<<s[l+K%c]<<endl;
    }
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> cnts(3, 0);
  int n = s.size();
  for (int i = 0; i < n; ++i) cnts[s[i] - 'a']++;
  bool is_valid = true;
  for (int i = 0; i < 3; ++i)
    for (int j = i + 1; j < 3; ++j)
      if (abs(cnts[i] - cnts[j]) > 1) is_valid = false;
  if (!is_valid) puts("NO");
  else puts("YES");
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long sum = 0;
        long max = 0;
        long min = 0;
        int i = Integer.parseInt(scan.next());
        long[] ary = new long[i];
        for(int a=0;a<i;a++){
            ary[a]=Long.parseLong(scan.next());
            if(a==0){ 
                min=ary[a];
                max=ary[a];
            }
            sum+=ary[a];
            if(ary[a]>max) max = ary[a];
            if(min>ary[a]) min = ary[a];
        }
        System.out.println(min+" "+max+" "+sum);
        scan.close();
    }
}

Measured memory_bytes: 27844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double t;
    priority_queue<double, vector<double>, greater<double>> pq;
    
    for(int i=0;i<n;i++)
    {
        cin>>t;
        pq.push(t);
    }
 
    while(pq.size()>1)
    {
        double a = pq.top();
        pq.pop();
        double b = pq.top();
        pq.pop();
        pq.push((a+b)/2);
    }
    printf("%.10lf", pq.top());
    return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int par[N], sz[N], n, m;

void build()
{
      lop(i, 0, n)
      {
            par[i] = i;
            sz[i] = 1;
      }
}

int find(int a)
{
      if ( par[a] == a) return a;
      return par[a] = find(par[a]);
}

void make_union(int a, int b)
{
      int pa = find(a);
      int pb = find(b);

      if ( pa != pb )
      {
            if ( sz[pa] < sz[pb] )swap(pa, pb);
            par[pb] = pa;
            sz[pa] += sz[pb];
      }
}

void solve()
{
      cin >> n >> m;
      build();
      lop(i, 0, m)
      {
            int a, b;
            cin >> a >> b;
            a--;
            b--;

            make_union(a, b);
      }

      int ans = 0;

      lop(i, 0, n) ans = max(ans, sz[i]);
      cout << ans << endl;

}

int32_t main()
{
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

      int test = 1;
      // cin >> test;
      while (test--)solve();


}





















Measured memory_bytes: 6740
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N; cin >> N;
    vector<int> M(N);
    rep(i,N) M[i] = i;
    vector<pair<ll,ll>> Z(N);
    rep(i,N) {
        int x, y;
        cin >> x >> y;
        Z[i] = make_pair(x,y);
    }

    double all = 0;
    ll cnt = 0;
    do {
        double sum = 0;
        for (int i = 0; i < N - 1; i++) {
            ll x1 = Z[M[i]].first;
            ll y1 = Z[M[i]].second;
            ll x2 = Z[M[i+1]].first;
            ll y2 = Z[M[i+1]].second;
            sum += sqrt(pow(x1 - x2, 2) + pow (y1 - y2, 2));
        }
        all += sum;
        cnt++;
    } while (next_permutation(begin(M), end(M)));
    cout << fixed << setprecision(10);
    cout << all / cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{
    ll a,b,c,x,y;
    ll ans = INF;
    cin >> a >> b >> c >> x >> y;

    for(ll i = 0; i <= x; i++) {
        ans = min(ans, i * a + (x-i)*2*c + max(y-(x-i), (ll)0) * b);        
    }

    for(ll i = 0; i <= y; i++) {
        ans = min(ans, i * b + (y-i)*2*c + max(x-(y-i), (ll)0) * a);        
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636