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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x, a, b;
    cin >> x;

    rep(i, -5000, 5000)
    {
        rep(j, -5000, 5000)
        {
            a = i * i * i * i * i;
            b = j * j * j * j * j;
            if (a - b == x)
            {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    cin >> N;
    map<string, ll> ss;
    for (ll i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(begin(s), end(s));
        ss[s]++;
    }

    auto ans = accumulate(begin(ss), end(ss), 0LL,
        [](auto acc, auto&& i) {
            auto m = i.second;
            // acc + mC2
            return acc + m * (m - 1) / 2;
        });

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 11264
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int s[100];

void init()
{
}

void solve()
{
    int m = INF;
    int sum = 0;
    REP(i, N){
        sum += s[i];
        if(s[i] % 10 != 0 && (m > s[i])) m = s[i];
    }
    if(sum % 10 != 0)
        cout << sum << endl;
    else
        cout << (m == INF ? 0 : sum - m) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> s[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()
T = input()

print(sum(1 if S[i] == T[i] else 0 for i in range(3)))



Measured memory_bytes: 38256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_V 1000
#define MAX_E 2000
#define INF 100000000

typedef struct edge_tbl
{
	int from;
	int to;
	int cost;
} edge;

edge es[MAX_E];
int V, E;

void
bellman_ford(int s)
{
	int d[MAX_V];
	int i, j;

	for (i = 0; i < V; ++i)
		d[i] = INF;

	d[s] = 0;
	i = 0;
	while (true)
	{
		bool update = false;
		for (j = 0; j < E; ++j)
		{
			edge e = es[j];
			if (d[e.from] != INF && d[e.from] + e.cost < d[e.to])
			{
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (i == V - 1)
				{
					printf("NEGATIVE CYCLE\n");
					return;
				}
			}
		}

		if (!update)
			break;

		i++;
	}

	for (i = 0; i < V; ++i)
	{
		if (d[i] == INF)
			printf("INF\n");
		else
			printf("%d\n", d[i]);
	}
}

int
main(int argc, char** argv)
{
	int r;
	int s, t, d;
	int i;

	scanf("%d %d %d", &V, &E, &r);
	for (i = 0; i < E; ++i)
	{
		scanf("%d %d %d", &s, &t, &d);
		es[i].from = s;
		es[i].to = t;
		es[i].cost = d;
	}

	bellman_ford(r);
	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
#define ull unsigned  long long
using namespace std;
const int INF =1e9+10;
const int N = 5e2 + 10;
signed main() {
    int n,a,b;
    si(n);
    ll x=1,y=1;
    ll r,l,mid;
    rep(i,1,n){
        si(a);
        si(b);
        mid=max(x/a,y/b);
        while(mid*a<x||mid*b<y){
            mid++;
        }
        x=mid*a;
        y=mid*b;
    }
    pl(x+y);
    return 0;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define EPS     1e-11
#define INF     0x7fffffff
#define LL_INF  0x7fffffffffffffff

typedef long long LL;
struct Point {
        int x, y;
};
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};


int main() {
    LL N, K;
    cin >> N >> K;
    LL res = (N/K)*(N/K)*(N/K);
    if (K % 2 == 0) {
        LL n = N/K;
        if (N % K >= K / 2)
            n++;
        res += n*n*n;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> a(n+1);

    int64_t res = 1, node = 1, sum = 0;

    for(auto&& e : a){
        cin >> e;
        sum += e;
    }

    // コーナーケース
    if(n == 0){
        if(a[0] != 1){
            cout << -1 << '\n';
        }else{
            cout << 1 << '\n';
        }
        return 0;
    }else if(a[0] != 0){
        cout << -1 << '\n';
        return 0;
    }

    // node : 深さi-1の頂点のうち葉でないもの
    // res : 頂点の総和
    // sum : 深さiよりも深い位置にある頂点の個数

    // 深さ1から始める
    for(int i = 1; i <= n; ++i){
        node = min(node * 2, sum);
        res += node;
        node -= a[i];
        sum -= a[i];;
        // 頂点の増やす量が追いつかない場合
        if(node < 0){
            cout << -1 << '\n';
            return 0;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3744
n = input()

a = n[0]
comp = ""

for i in range(len(n)):
    comp += a

if int(n) == int(comp):
    print(n)
elif int(n) < int(comp):
    print(comp)
else:
    b = str(int(a) + 1)
    ans = ""
    for i in range(len(n)):
        ans += b
    print(ans)


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

using namespace std;
const int maxn = 2e5 + 20 , mod = 1e9 + 7;
int n , dp[maxn] , c[maxn] , a[maxn];
long long res;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] != a[i - 1]) 
		{
			c[a[i]] += dp[i - 1];
			dp[i] = c[a[i]];
		}
		else
		{
			dp[i] = dp[i - 1];
		}
		dp[i] %= mod;
		c[a[i]] %= mod;
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    int ans = 0, diff = 10000;
    for (int i = 0; i < n; i++) {
        ans += l + i;
        if (abs(l + i) < abs(diff)) {
            diff = l + i;
        }
    }
    cout << ans - diff << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
	int a, b, c;
	while (cin >> a >> b >> c) {
		int flag = 0;
		for (int k = 1; k <= 10000005; k++) {
			if ((b*k + c) % a == 0) {
				printf("YES\n"); 
				flag = 1; 
				break;
			}
		}
		if (!flag) 
			printf("NO\n");
	}

	system("pause");
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,r,ans;
    cin>>n>>r;
    if(n>=10)
    {
        ans=r;
    }
    else
    {
        ans=r+100*(10-n);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   string a,b;
   int i=0;
   cin>>a>>b;
   while(i<min((int)a.length(),(int)b.length()))
   {
    cout<<a[i]<<b[i];
    i++;
   }
   if(i<(int)a.length())
    cout<<a[i];
   if(i<(int)b.length())
    cout<<b[i];
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(auto &t:a)cin>>t;return i;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class RollingHash{
public:
  typedef unsigned long long ull;
  const ull B = 1777771; //ハッシュ基数
  int n;
  string s;
  vector<ull> hash;
  vector<ull> k;

  RollingHash(){};
  RollingHash(string s):n(s.size()),s(s),hash(n+1),k(n+1){
    for(int i=0;i<n;i++) hash[i+1] = hash[i] * B + s[i];
    k[0] = 1;
    for(int i=1;i<=n;i++) k[i] = k[i-1] * B;
  }

  ull get(int l,int r){return hash[r] - hash[l] * k[r-l];}//[l,r)
};

signed main(){
  string a,b;
  cin>>a;
  cin>>b;
  RollingHash A(a),B(b);

  int n = a.size();
  int m = b.size();
  for(int i=0;i<n;i++)
    if(A.get(i,i+m) == B.get(0,m)) cout<<i<<endl;
  
  return 0;
}



Measured memory_bytes: 20584
n = int(input())
h = [int(i) for i in input().split()]

ans = 0
cand = 0
for i in range(1,n):
    if h[i] <= h[i-1]:
        cand += 1
    else:
        ans = max(ans, cand)
        cand = 0
ans = max(ans, cand)
print(ans)

Measured memory_bytes: 14252
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 100000000
#define EPS 1e-10
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
int w, h;
const int dx[] = { 0, 1, 0,-1};
const int dy[] = {-1, 0, 1, 0};
int wall[31][31][4];
struct node{
  int x, y, step;
  bool operator<(const node &o) const{
    return step > o.step;
  }
};
int main(){
  while(cin >> w >> h, w||h){
    int a;
    memset(wall, 0, sizeof(wall));
    rep(x, w-1){
      cin >> a;
      if(a) wall[x][0][1] = wall[x][0][3] = true;
    }
    rep(y, h-1){
      rep(x, w){
	cin >> a;
	if(a) wall[x][y][2] = wall[x][y+1][0] = true;
      }
      rep(x, w-1){
	cin >> a;
	if(a) wall[x][y+1][1] = wall[x+1][y+1][3] = true;
      }
    }
    int ans = -1;
    priority_queue<node> pq;
    pq.push((node){0, 0, 0});
    bool done[31][31] = {0};
    while(!pq.empty()){
      int x = pq.top().x;
      int y = pq.top().y;
      int step = pq.top().step;
      pq.pop();
      if(done[x][y]) continue;
      done[x][y] = true;
      //cout << x << " " << y << " " << step << endl;
      if(x == w-1 && y == h-1){
	ans = step;
	break;
      }
      rep(d, 4){
	int nx = x + dx[d];
	int ny = y + dy[d];
	if(!wall[x][y][d] && nx >= 0 && ny >= 0 && nx < w && ny < h){
	  pq.push((node){nx, ny, step+1});
	}
      }
    }
    cout << ans + 1 << endl;
  }
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  while (N >= 0) {
    if (N % 4 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
    N -= 7;
  }
  cout << "No" << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> H(N);
    REP(i, N){
        cin >> H[i];
        // ans += H[i];
    }
    // sort(H.begin(), H.end(), greater<ll>());
    // REP(i, K){
    //     ans -= H[i];
    //     H[i] = 0;
    // }
    sort(H.begin(), H.end());
    REP(i, N-K){
        ans += H[i];
    }
    
    cout << ans << endl;
    
    
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
vector<int> arr[mxn];
int sub[mxn];
int n, m, k, q;
string s, t;

void dfs(int node) {
    sub[node] = 1;
    for (int next : arr[node]) {
        if (!sub[next]) {
            dfs(next);
            sub[node] += sub[next];
        }
    }
}

void solve() {
    cin >> n >> m;
    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        arr[u].pb(v);
        arr[v].pb(u);
    }
    for (int i = 1; i <= n; i++) {
        if (!sub[i]) {
            dfs(i);
        }
    }
    int ans = sub[1];
    for (int i = 2; i <= n; i++) ans = max(ans, sub[i]);
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ll long long

int main() {
    int n;
    cin >> n;
    int l[n];
    std::vector<int> v;
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
        v.push_back(l[i]);
    }
    Sort_rev(v);
    int ans = 0;

    for (int i = 0; i < n-2; ++i) {
        for (int j = i+1; j < n-1; ++j) {
            for (int k = j+1; k < n; ++k) {
                if ( v[i] >= v[j]+v[k] ) {
                    break;
                }
                ans++;
            }
        }
    }

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

/*
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];

void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}

void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}
*/


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
result = 0
if a[0] > x:
    result += a[0] - x
    a[0] = x
for i in range(N-1):
    if a[i] + a[i+1] > x:
        result += a[i] + a[i+1] - x
        a[i+1] = x - a[i]
print(result)

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

using namespace std;

string s;
int n;
long long ans; 

void dfs(int a,long long b)
{
	if(a==n)
	{
		ans+=b;
		return;
	}
	
	for(int i=a;i<s.size();i++)
	{
		long long cnt=0;
		for(int j=a;j<=i;j++)
			cnt=cnt*10+s[j]-'0';
		
		dfs(i+1,b+cnt);
	}
}

int main()
{
	cin>>s;
	n=s.size();
	
	dfs(0,0);
	
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	string str;
	cin >> str;
	int n = str.size(), s = 0, ans = 0;
	rep(i,n){
		if(str[i] == 'S')s++;
		if(str[i] != 'S' and s > 0){
			ans++;s--;
		}
	}
	printf("%lld\n", n-ans*2);
	return 0;
}






Measured memory_bytes: 640
N = int(input())
lis = [0]*N
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x -1
            if ans >= N:
                pass
            else:
                lis[ans] += 1
for i in range(N):
    print(lis[i])

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

using namespace std;

void solve()
{
    int n;
    cin>>n;

    string s;
    cin>>s;
    int res=s.size();

    if(res<=n)
        cout<<s<<endl;
    else
    {
        for(int i=0;i<n;i++)
            cout<<s[i];

        cout<<"...";
    }
}


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

    solve();
    return 0;
}


Measured memory_bytes: 3660
using System;

namespace _20200328
{
    class Program
    {
        static void Main()
        {
            var x = int.Parse(Console.ReadLine());
            var coin500 = x / 500;
            var rest = x % 500;
            var coin5 = rest / 5;
            Console.WriteLine(coin500 * 1000 + coin5 * 5);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > A;
  rep(i, N) {
    int a;
    cin >> a;
    A.push_back(make_pair(a, i+1));
  }
  sort(A.begin(), A.end());
  rep(i, N)
    cout << A[i].second << ' ';
  cout << endl;
  return 0;
}



Measured memory_bytes: 1780
#include<cstdio>

using namespace std;

int a[100001],b[100001];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	long long s1=0,s2=0,s3=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		a[i]-=b[i];
		s1+=a[i];
		if(a[i]>0)s2+=a[i];
		if(a[i]<0)s3+=-(a[i]/2);
	}
	if(s2>s3||s2>-s1){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
}


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

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

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

int main() {
	int n, d; scanf("%d%d", &n, &d);
	std::vector<std::vector<int>> vec(n);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < d; j++) {
			int x; scanf("%d", &x);
			
			vec[i].push_back(x);
		}
	}
	
	auto isSquare = [](i64 x) {
		for(i64 i = 1; i * i <= x; i++) {
			if(i * i == x) return true;
		}
		return false;
	};
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int D = 0;
			for(int k = 0; k < d; k++) {
				D += (vec[i][k] - vec[j][k]) * (vec[i][k] - vec[j][k]);
			}
		
			ans += isSquare(D);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        String str = in.next();
        String sc = in.next();


        int a = sc.length()-1;


        str =  str + sc.charAt(a);


        if(str.equals(sc))
        {
            System.out.println("Yes");

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







    }





Measured memory_bytes: 39104
/* C program for Merge Sort */
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
int a[100001];
int n;
long long int mod=1000000007;
int max_q(int i){
    //cout<<"Function enters"<<endl;
    if(i>=n-1){
        return 0;
    }
    
    if(dp[i]!=-1){
        return dp[i];
    }
    if(i+2<n){
        dp[i]=min(abs(a[i]-a[i+1])+max_q(i+1),abs(a[i]-a[i+2])+max_q(i+2));
        return dp[i];
    }
    if(i+1<n){
        dp[i]=abs(a[i]-a[i+1])+max_q(i+1);
        return dp[i];
    }
        //dp[i][j][k]=max(dp[i][j][k],longest_sub(i,j,k+1));
        
    return dp[i];
    
}
int main() 
{ 
    for(int i=0;i<=100000;i++){
        dp[i]=-1;
    }
    cin>>n;
    for(int i =0;i<n;i++){
        cin>>a[i];
    }
    cout<<max_q(0);
	return 0; 
} 


Measured memory_bytes: 2560
use proconio::marker::Usize1;
use std::collections::BTreeMap;
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        l: usize,
        pq: [(Usize1,Usize1);k],
        rs: [(Usize1,Usize1);l],
    }
    let (mut ufk,mk)=f(n,pq);
    let (mut ufl,ml)=f(n,rs);
    let mut a=vec![0;n];
    for i in 0..n { if a[i]==0 {
        let sk=count(&mut ufk, i);
        let sl=count(&mut ufl, i);
        let mut u=vec![];
        let (uf1,uf2,m1) = if sk<sl {
            (&mut ufk, &mut ufl, &mk)
        }
        else {
            (&mut ufl, &mut ufk, &ml)
        };
        let j=find(uf1, i);
        for &v in m1.get(&j).unwrap().iter() {
            if equiv(uf2, i, v) {
                u.push(v);
            }
        }
        let c=u.len();
        for u in u {
            a[u]=c;
        }
    }}
    println!("{}",itertools::join(a, " "));
}
fn f(n:usize, uv: Vec<(usize,usize)>) -> (Vec<i32>,BTreeMap<usize,Vec<usize>>) {
    let mut uf=vec![-1;n];
    for (u,v) in uv {
        union(&mut uf, u, v);
    }
    let mut m=BTreeMap::new();
    for i in 0..n {
        let k=find(&mut uf, i);
        m.entry(k).or_insert(vec![]).push(i);
    }
    (uf,m)
}
fn find(uf: &mut Vec<i32>, i: usize) -> usize {
    if uf[i]<0 {
        i
    }
    else {
        uf[i]=find(uf, uf[i]as usize)as i32;
        uf[i]as usize
    }
}
fn equiv(uf: &mut Vec<i32>, i: usize, j: usize) -> bool{
    find(uf, i)==find(uf, j)
}
fn union(uf: &mut Vec<i32>, i: usize, j: usize) {
    let mut i=find(uf, i);
    let mut j=find(uf, j);
    if i==j {
        return;
    }
    if uf[i]>uf[j] {
        std::mem::swap(&mut i, &mut j);
    }
    uf[i]+=uf[j];
    uf[j]=i as i32;
}
fn count(uf: &mut Vec<i32>, i: usize) -> usize {
    let i=find(uf, i);
    (-uf[i])as usize
}

Measured memory_bytes: 42028
//https://atcoder.jp/contests/abc145/tasks/abc145_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    string S; cin>>S;  
    ll tmp=N/2;
    auto outno = [](){
        cout<<"No"<<endl;
        exit(0);
    };
    if(N%2==1)outno();
    REP(i,tmp){
        if(S.at(i)!=S.at(tmp+i)){
            outno();
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import statistics
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n = int(input())
nums = make_divisors(n)
a = statistics.median_low(nums)
b = n / a
print(int(a+b-2))

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    vector<int> ans(n);

    rep(r, 2)
    {
        int cnt = 0;
        rep(i, n)
        {
            if (s[i] == 'R')
            {
                cnt++;
            }
            else
            {
                ans[i] += cnt / 2;
                ans[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }
        reverse(ALL(ans));
        reverse(ALL(s));
        rep(i, n)
        {
            if (s[i] == 'L')
            {
                s[i] = 'R';
            }
            else
            {
                s[i] = 'L';
            }
        }
    }

    rep(i, n)
    {
        cout << ans[i];
        if (i != n - 1)
        {
            cout << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 1024
s=input()
for _ in range(int(input())):
 a=input().split()
 if a[0]=='print':print(s[int(a[1]):int(a[2])+1])
 if a[0]=='reverse':
  s=s[0:int(a[1])]+s[int(a[1]):int(a[2])+1][::-1]+s[int(a[2])+1:]
 if a[0]=='replace':
  s=s[0:int(a[1])]+a[3]+s[int(a[2])+1:]

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

    long long a,b,c,d,e,g,h,i,j,k,l,m,n,x,y,z;
    string sr;
    cin>>a;
    cin>>sr;
    if(sr.length()<=a)
        cout<<sr<<endl;
    else
    {
        for(long long i=0;i<a;i++)
            cout<<sr[i];
        cout<<"..."<<endl;
    }




}


Measured memory_bytes: 3628
a,b=gets.split.map(&:to_i)
if a==2 && b==2
  puts "Yes"
elsif a==2 || b==2
  puts "No"
else
  aa = [4,6,9,11].include?(a)
  bb = [4,6,9,11].include?(b)
  puts(aa ^ bb ? "No" : "Yes")
end
  

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

#define MAX_N 2000
#define MAX_P2 10

#define sqrInf 999999999

using namespace std;

int rez;
int n, k, q;

int a[MAX_N + 1];
int b[MAX_N + 1];

int st[MAX_N + 1];
int dr[MAX_N + 1];
int stk[MAX_N + 1];

void readFile()
{
    cin >> n >> k >> q;

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

void done(int &elim, int &cate, int &good)
{
    if(cate + good >= k)
        elim += min(good, cate + good - k + 1);

    cate = 0;
    good = 0;
}

bool pos(int dr, int st)
{
    int i;
    int good = 0;
    int cate = 0;
    int elim = 0;
    for(i = 1; i <= n; i ++)
    {
        if(a[i] < a[st])
            done(elim, cate, good);

        else
            if(a[i] > b[dr])
                cate ++;

        else
            good ++;
    }

    done(elim, cate, good);

    return (elim >= q);
}

void cautBin(int poz)
{
    int i = 0;
    int pas = 1 << 10;
    while(pas != 0)
    {
        if(i + pas < n && pos(i + pas, poz) == 0)
            i += pas;

        pas >>= 1;
    }

    i ++;

    if(pos(i, poz) == 0)
        return;

    rez = min(rez, b[i] - a[poz]);
}

void baga(int dr[], int lst, int ldr, int sign)
{
    int i;
    int stkLen = 0;
    for(i = lst; i != ldr + sign; i += sign)
    {
        while(stkLen > 0 && a[stk[stkLen]] > a[i])
        {
            dr[stk[stkLen]] = i;
            stkLen --;
        }

        stk[++ stkLen] = i;
    }

    while(stkLen > 0)
    {
        dr[stk[stkLen]] = ldr + sign;
        stkLen --;
    }
}

void getRez()
{
    rez = sqrInf;

    sort(b + 1, b + n + 1);

    int i;
    baga(dr, 1, n, 1);
    baga(st, n, 1, -1);

    for(i = 1; i <= n; i ++)
    {
        st[i] ++;
        dr[i] --;

        if(i - st[i] + dr[i] - i + 1 >= k)
            cautBin(i);
    }
}

void solve()
{
    getRez();
}

void printFile()
{
    cout << rez << "\n";
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;
typedef long long ll;

int N, M, Q;
vector<int> ve[100001];
int vdis[11][100001];
int vv[100001], dd[100001], cc[100001];

void dfs(int v, int d, int n){
  //if(d == 1)  cout << v << " " << n << endl;
  if(d < 0 || vdis[d][v] >= n)  return;
  for(int i = d; i >= 0; i--){
    if(vdis[i][v] < n) vdis[i][v] = n;
    else break;
  }
  for(int i = 0; i < ve[v].size(); i++){
    dfs(ve[v][i], d-1, n);
  }
}

int main(){
  cin >> N >> M;
  for(int i = 0; i <= 10; i++)  fill(vdis[i], vdis[i]+N+1, -1);
  for(int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    a--;  b--;
    ve[a].push_back(b);
    ve[b].push_back(a);
  }

  cin >> Q;
  for(int i = 0; i < Q; i++){
    cin >> vv[i] >> dd[i] >> cc[i];
    vv[i]--;
  }

  for(int i = Q-1; i >= 0; i--){
    dfs(vv[i], dd[i], i);
  }

  for(int i = 0; i < N; i++){
    cout << ((vdis[0][i] == -1) ? 0 : cc[vdis[0][i]]) << endl;
  }

  return 0;
}


Measured memory_bytes: 12024
import           Control.Monad
import qualified Data.IntSet   as S

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [n, k] <- readInts
  sets <- replicateM k (getLine >> S.fromList <$> readInts)
  print $ solve n sets

solve :: Int -> [S.IntSet] -> Int
solve n sets = S.size $ foldl (S.\\) (S.fromList [1..n]) sets


Measured memory_bytes: 5456
#include<stdio.h>
int main(){
    int a,b;
    char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='?'){
        break;
    }
    else if(op=='+'){
        printf("%d\n",a+b);
    }
    else if(op=='-'){
         printf("%d\n",a-b);
    }
    else if(op=='*'){
         printf("%d\n",a*b);
    }
    else if(op=='/'){
         printf("%d\n",a/b);
    }

    }

    return 0;
}

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

string today;
vector<string> week={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main() {
    cin>>today;
    for (int i=0; i<7; i++) {
        if (today==week[i]) {
            cout<<7-i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
'use strict';
function Main(stdin){
  const input = stdin.trim().split(' ').map(str => Number(str));
  const A = input[0], B = input[1], C = input[2], D = input[3];
  
  let start =  A < C ? C : A;
  let end = B < D ? B : D;
  let result = end < start ? 0 : end - start;
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for (int i=0;i<N;i++) {
    int x;
    cin >> x;
    if (x< K-x) {
      sum += 2*x;
    }
    else {
      sum+= 2*(K-x);
    }
  
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 105
using namespace std;

int n, x, a[N];
int main()
{
	int i;
	cin >> n >> x;
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	for (i = 0; i < n && x >= a[i]; x -= a[i], i++);
    cout << i - (x > a[i]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF = 1LL << 60;
int main(){
    int k;
    cin >> k;
    queue<ll> q;
    for(ll i=1; i<=9; i++){
        q.push(i);
    }
    ll ans=0;
    while(k>0){
        ll now =q.front(); q.pop();
        ll last = now % 10;
        if(last!=0) q.push(now*10+last-1);
        q.push(now*10+last);
        if(last!=9) q.push(now*10+last+1);
        k--;
        ans = now;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    long long h1,s1,h2,s2;
    cin>>h1>>s1>>h2>>s2;
    while(true)
    {
        h2-=s1;
        if(h2<=0) {cout<<"Yes";return 0;}
        h1-=s2;
        if(h1<=0) {cout<<"No";return 0;}
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,i=1;
     map<ll,ll>mp;
     cin>>t;
     mp[t]++;
     while(true)
     {
         i++;
         if(t%2==0)
            t=t/2;
         else
            t=3*t+1;
         if(mp[t]==1)
         {
             cout<<i<<endl;
             return 0;
         }
         else
            mp[t]++;
     }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<set>
using namespace std;

struct init{
	init(){
		cin.tie(0); ios::sync_with_stdio(false);
	}
}________init;
typedef vector<int> E;
typedef vector<E> Graph;
typedef long long LL;
#define rep(i,n) for (auto i = 0; i < n;i++)
#define range(it,v) for (auto& it : v)
inline bool inner(int l, int v, int r){
	return (l <= v&&v <= r);
}
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int  N;
	while (cin >> N) {
		LL a, d, M;
		int K;
		cin >> a >> d >> M;
		a -= d;
		vector<int> x(M),y(M),z(M);
		rep(i, M)cin >> x[i] >> y[i] >> z[i];
		cin >> K; K--;
		rep(id, M){
			int i = M - id - 1;
			y[i]--, z[i]--;
			if (x[i] == 0 && inner(y[i], K, z[i])){
				int sz = z[i] - y[i];
				int m = K - y[i];
				K = y[i] + (sz - m);
			}
		}

		LL val = a + d*(K + 1);
		rep(i, M){
			if (inner(y[i], K, z[i])){
				if (x[i] == 0){
					int sz = z[i] - y[i];
					int m = K - y[i];
					K = y[i] + (sz - m);
				}
				if (x[i] == 1){
					val += 1;
				}
				if (x[i] == 2){
					val /= 2;
				}
			}
		}
		cout << val << endl;
	}
	return 0;
}

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

int main() {
   int N,M;
   cin >> N >> M;
   int total = 0;
   vector<int> A(N);
   for(int i=0; i<N; i++) {
      cin >> A[i];
      total += A[i];
   }

   sort(A.begin(), A.end());
   reverse(A.begin(), A.end());
   double limit = (double)total / (4.0 * M);

   for(int i=0; i<M; i++) {
      if(A[i] < limit) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
}

Measured memory_bytes: 3596
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; let result = junban (a,b,c)
  ; putStrLn result
  }

junban :: (Int, Int, Int) -> String
junban (x,y,z)
  | x < y && y < z = "Yes"
  | otherwise      = "No"


getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3556
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <numeric>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define Icin(s) ll (s);cin>>(s);
#define Scin(s) ll (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
int N;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    V vec;
    vec.push_back(0);
    rep(i,n){
        ll x;cin>>x;vec.push_back(x);
    }
    V vec1=vec;
    rep3(i,1,n+1)vec[i]+=vec[i-1];
    rep(i,n+1){
     //   cout<<vec[i]<<" ";
        vec[i]%=m;
      //  cout<<vec[i]<<endl;
    }
    
    map<ll,ll> mp;
    rep(i,n+1)mp[vec[i]]++;
    ll res=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
     //   cout<<itr->second<<endl;
        if(itr->second>=2){
            ll k=itr->second;
            res+=(k*(k-1))/2;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int read(){
	int f=1,re=0;
	char ch;
	for(ch=getchar();!isdigit(ch)&&ch!='-';ch=getchar());
	if(ch=='-'){f=-1,ch=getchar();}
	for(;isdigit(ch);ch=getchar()) re=(re<<3)+(re<<1)+ch-'0';
	return re*f;
}
const int inf=1e9+7;
int n,m,f[109][109];
char s[109][109];
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) f[i][j]=inf;
	f[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(s[i+1][j]=='.') f[i+1][j]=min(f[i+1][j],f[i][j]);
			else f[i+1][j]=min(f[i+1][j],f[i][j]+(s[i][j]=='.'));
			if(s[i][j+1]=='.') f[i][j+1]=min(f[i][j+1],f[i][j]);
			else f[i][j+1]=min(f[i][j+1],f[i][j]+(s[i][j]=='.'));
		}printf("%d\n",f[n][m]);
	return 0;
} 

Measured memory_bytes: 256
n=gets.split
m=->r,d{r.map{|i|n[i]}.rotate(d).map.with_index{|v,i|n[r[i]]=v}}
gets.chop.chars{|c|m[(c<?F||?V<c)?[0,2,5,3]:[0,4,5,1],c>?R?1:-1]}
puts n[0]


Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, d ,x,t,ans=0;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		cin >> t;
		for (int j = 0; j < d; j += t) {
			ans++;
		}
	}
	cout << ans + x << endl;
}

Measured memory_bytes: 256
//ABC 073 B
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iomanip>
using namespace std;

int main() {
	int loop,start,end,count=0;

	cin >> loop;

	for (int i = 0; i < loop; i++) {
		cin >> start;
		cin >> end;
		count += end - start + 1;
	}

	cout << count;

		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    map<string, bool> acquired;
    cin >> N;
    int count = 0;
    for (int i = 0;i < N;i++) {
        string S;
        cin >> S;
        if (acquired.count(S) != 0) continue;
        count++;
        acquired[S] = true;
    }
    cout << count << endl;
}

Measured memory_bytes: 19260
#include <stdio.h>

int main(){
  int h,w;
  char map[100][100];
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++){
    scanf("%s",map[i]);
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      printf("%c",map[i][j]);
    }
    printf("\n");
    for(int j=0;j<w;j++){
      printf("%c",map[i][j]);
    }
    printf("\n");
  }
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;

    int target = 753;
    int ans = 753;
    REP(i, S.length()-2) {
        int current = stoi(S.substr(i, 3));
        ans = min(ans, abs(current - target));
    }
    print(ans);
}

signed main() {
    solve();
}


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

int main() {
	// your code goes here
	int n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	for(int i=0; i<n; i++){
		cout << s.at(i) << t.at(i);
	}
	return 0;
}


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

using namespace std;
const int N=1e2+10;
const int M=1e5+10;

int n, W;
int w[N], v[N];
int dp[N][M];

int main() {
	cin>>n>>W;
	for(int i=1; i<=n; i++) {
		cin>>w[i]>>v[i];
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0]=0;
	int ans=0;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=100000; j++) {
			dp[i][j]=dp[i-1][j];
			if (j>=v[i]) dp[i][j]=min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
			if (dp[i][j]<=W&&j>ans) {
				ans=j;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 43264
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL) {
          y = x;
          if (z->key < x->key)
              x = x->left;
          else
              x = x->right;
      }

  z->parent = y;

  if (y == NIL) {
          root = z;
  }else {
    if (z->key < y->key)
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(Node u){
  if (u == NIL)
      return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u){
  if (u == NIL)
        return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25172
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 str = br.readLine();
		while (!str.equals("0 0 0 0 0 0")) {
			String[] dataset = str.split(" ");
			int[] parameter = new int[6];
			for (int i = 0; i < 6; i++) {
				parameter[i] = Integer.parseInt(dataset[i]);
			}
			int k1 = Search(parameter[0], parameter[1]);
			int k2 = Search(parameter[2], parameter[3]);
			int k3 = Search(parameter[4], parameter[5]);
			long k = LCM(k1, k2, k3);
			System.out.println(k);
			str = br.readLine();
		}
	}

	private static int Search(int a, int m) {
		int k = 1;
		int an = a % m;
		while (an != 1) {
			an = (an * a) % m;
			k += 1;
		}
		return k;
	}

	private static long LCM(int k, int l, int m) {
		long gcm1 = Euclid(k, l);
		long lcm1 = k * l / gcm1;
		long gcm2 = Euclid(lcm1, m);
		long lcm2 = lcm1 * m / gcm2;
		return lcm2;
	}

	private static long Euclid(long x, long y) {
		while (x != y) {
			if (x < y) {
				y = y - x;
			} else {
				x = x - y;
			}
		}
		return x;
	}
}

Measured memory_bytes: 24776
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
cnt = 0
l = []
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            cnt += (k + 1) * k // 2 if j > i else k * (k - 1) // 2
            cnt %= mod
print(cnt % mod)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  double t,x;
  cin >> t >> x;
  cout << t/x << endl;
}


Measured memory_bytes: 256