akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve();
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


void solve(){
    ll n, m;
    cin >> n >> m;
    ll sx[n], sy[n], cx[m], cy[m];
    rep(i, n) cin >> sx[i] >> sy[i];
    rep(i, m) cin >> cx[i] >> cy[i];
    ll ax[n], a[n];
    rep(i, n)
    {
        a[i] = inf;
        rep(j, m)
        {
            ll dis = abs(sx[i] - cx[j]) + abs(sy[i] - cy[j]);
            if(a[i] > dis) {
                a[i] = dis;
                ax[i] = j+1;
            }
        }
    }
    rep(i, n) cout << ax[i] << " ";
}


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

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

  vector<bool> p(102, true);
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    p[t] = false;
  }

  int ans = 0;
  for (int i = 0; i <= 100; i++) {
    if (x - i >= 0 && p[x - i]) {
      ans = x - i;
      break;
    }
    if (x + i <= 101 && p[x + i]) {
      ans = x + i;
      break;
    }
  }

  cout << ans << endl;
}


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

int main() {
    int A; cin >> A;
    int h = A / 3600;
    int m = (A % 3600) / 60;
    int s = ( A % 3600 ) % 60;
    cout << h << ':' << m << ':' << s << endl;
}


Measured memory_bytes: 3096
#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() {
    int N; cin >> N;
    vector<ll> A(N+1);
    rep(i,N+1) cin >> A.at(i);
    vector<ll> B(N);
    rep(i,N) cin >> B.at(i);

    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] > B[i]) {
            cnt += B[i];
            A[i] -= B[i];
            B[i] = 0;
        } else {
            cnt += A[i];
            B[i] -= A[i];
            A[i] = 0;
        }

        if (A[i+1] > B[i]) {
            cnt += B[i];
            A[i+1] -= B[i];
            B[i] = 0;
        } else {
            cnt += A[i+1];
            B[i] -= A[i+1];
            A[i+1] = 0;
        }
    }
    cout << cnt << endl;
}


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

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

    public void Solve(ConsoleInput cin)
    {
      var s = cin.Read;
      var t = cin.Read;
      var a = cin.ReadInt;
      var b = cin.ReadInt;
      var u = cin.Read;
      WriteLine(u == s ? $"{a - 1} {b}" : $"{a} {b - 1}");
    }
  }

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

Measured memory_bytes: 11220
s = input()
if(s[0] == 'R' and s[1] == 'R' and s[2] == 'R'):
    print(3)
elif(s[0] == 'R' and s[1] == 'R' and s[2] == 'S'):
    print(2)
elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
    print(2)
elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    print(1)
else:
    print(0)


Measured memory_bytes: 9040
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}


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

#define ll long long int

using namespace std;


int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  ll l = 0, r = 1;
  ll cur = a[0];
  for (; l < n; l++) {
    if (r == l) {
      cur += a[r];
      r++;
    }
    while ((a[r] & cur) == 0 && r < n) {
      cur += a[r];
      r++;
    }
    cur -= a[l];
    ans += r - l;
  }
  cout << ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

ll n , k ;
vector<ll> rui;

ll f(ll x){
    if(x<0) return 0;
    return rui[x];
}

int main(){
    string s; cin >> s;
    ll ss = s.size();
    if(s.at(ss-1) == 's') s += 'e';
    s += 's';
    cout << s << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int final_ans = 0;
  int ans = 0;

  for(int i=0; i<s.size(); i++){
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      ans++;
      if (i==s.size()-1){
        final_ans = max(final_ans, ans);
      }
    } else {
      final_ans = max(final_ans, ans);
      ans = 0;
    }
  }

  cout << final_ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools


def main():
    N = int(input())
    PN = tuple(map(int, input().split()))
    QN = tuple(map(int, input().split()))

    a = 0
    for i, PN2 in enumerate(itertools.permutations(sorted(PN))):
        if PN == PN2:
            a = i

    b = 0
    for i, QN2 in enumerate(itertools.permutations(sorted(QN))):
        if QN == QN2:
            b = i

    print(abs(a - b))


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INFTY 200000000000
long long dp[310][310];
vector<long long> a(310);
int b;
const double PI=3.1415926535897932;
int main(){
    ll n,m;cin >> n>>m;
    vector<ll> a(m);
    ll sum=0;
    for (int i = 0; i < m; i++)
    {
        cin>>a[i];
        sum += a[i];
    }

    if(sum>n) cout << -1 << endl;
    else cout << n-sum<<endl;
    

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,t,a;
    cin >> n >> t >> a;
    vector <int> h(n);
    vector <long double> palaceT(n);
    long double diff;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        palaceT[i] = (long double)t - (long double)0.006*(long double)h[i];
        if(i == 0){
            diff = abs((long double)a-palaceT[i]);
            ans = i + 1;
        }else{
            if(diff > abs((long double)a-palaceT[i])){
                diff = abs((long double)a-palaceT[i]);
                ans = i+1;
            }
        }
        //cout << abs((long double)a-palaceT[i]) << " ";
        //cout << diff << " ";
    }
    //cout << endl;
    #if 0
    for(int i = 0; i < n; i++){
        cout << palaceT[i] << " ";
    }
    cout << endl;
    #endif
    cout << ans << endl;
    return 0;
}

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

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

    ll ans = N - 1;
    for(ll i=1;i * i<=N;i++){
        if(N % i == 0){
            ans = min(ans, (i - 1) + (N / i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
  int n;
  cin>>n;
  
  string s,t;
  cin>>s>>t;
  
  string out;
  for(int i=0;i<n;i++){
    out.push_back(s.at(i));
    out.push_back(t.at(i));
  }
  
  cout<<out<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[15];
bool dfs(int n, int a, int b)
{
    bool ret = false;
    if(n == 10) return (true);
    if(A[n] > a) ret |= dfs(n + 1, A[n], b);
    if(A[n] > b) ret |= dfs(n + 1, a, A[n]);
    return (ret);
}
int main()
{
    int N;
    cin >> N;
    while(N--) {
        for(int i = 0; i < 10; i++) cin >> A[i];
        if(dfs(0, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return (0);
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  map<string,int> mp;
  int n; cin >> n;
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, m = 1e18;
    cin >> n;
    long long a[n + 1], s[n + 1];
    s[0] = 0;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    for (long long i = 1; i <= n; i++)
        s[i] = s[i - 1] + a[i];
    for (long long i = 1; i < n; i++)
        m = min(m, abs(s[n] - s[i] * 2));
    cout << m;
}

Measured memory_bytes: 6744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	cin >> n;
	int a=n;
	while(n/10)
	{
		s += n%10;
		n /= 10;
	}
	s += n;
	if(a%s)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	int a = (s.size()-1) / 2;
	int count = 0;
	while (s.substr(0, a) != s.substr(a, a)) {
		a--;
	}
	cout << a *2 << endl;
	return 0;
}

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

typedef vector<int> vi;

int main() {
    int n;
    vi a;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int v;
        scanf("%d", &v);
        a.push_back(v);
    }
    vi cand;
    for (int i = 0; i < 2; i++)
        for (int d = 1; d * d <= a[i]; d++)
            if (a[i] % d == 0) {
                cand.push_back(d);
                cand.push_back(a[i] / d);
            }
    int ans = 1;
    for (auto v : cand) {
        int cnt = 0;
        for (auto aa : a)
            if (aa % v == 0)
                cnt++;
        if (cnt >= n - 1)
            ans = max(ans, v);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<set>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 524287;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 524287;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	set<pair<int, char*>> ST;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			ST.insert(mp(n, s[i]));
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	for (auto p : ST) {
		auto S = p.second;
		int k[26] = {};
		ll are = 0;
		for (int i = p.first - 1; i >= 1; i--) {
			int tmp = query(are);
			rep(j, 26) if ((tmp >> j & 1)) {
				k[j]++;
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

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

#define inf 1 << 31; //int なら31

void solve(long long N, std::string S)
{
    //long long Ssize = S.size();
    long long Lside_L = 0, Lside_R = 0, Rside_L = 0, Rside_R = 0;
    long long Min = inf;
    Min *= -1;

    //全体のRL数確認
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'E')
            Rside_R++;
        else
            Rside_L++;
    }

    //リーダ基準のRL
    for (int i = 0; i < N; i++)
    {
        long long change = 0;
        change += (Lside_L + Rside_R);
        if (S[i] == 'E')
            change--; //リーダーがRだった場合は, Lになる回数が一つ減る

        Min = min(Min, change);

        if (S[i] == 'E')
        {
            Rside_R--;
            Lside_R++;
        }
        else
        {
            Rside_L--;
            Lside_L++;
        }
    }

    cout << Min << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 1028
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;


int main()
{
	string str;
	cin>>str;
	if( str[0] != 'A'){
		cout<<"WA"<<endl;
		return 0;
	}
	int count = 0;
	for(int i = 2; i <= str.length() -2;i++){
		if(str[i] == 'C') count++;
	}
	if(count != 1){
		cout<<"WA"<<endl;
		return 0;
	}
	for(int i = 1; i < str.length(); i++){
		int num = str[i];
		if( (num < 'a'  || 'z' < num ) && (num != 'C')){
			cout<<"WA"<<endl;
			return 0;
		}
	}
	cout<<"AC"<<endl;
	return 0;
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (i < n && j < m && s[i] == t[j]) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            if (i < n) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            }
            if (j < m) {
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
            }
        }
    }

    string lcs;
    int i = n, j = m;
    while (i != 0 || j != 0) {
        assert(i - 1 < n && j - 1 < m);
        if (i > 0 && j > 0 && s[i - 1] == t[j - 1] && dp[i][j] == dp[i - 1][j - 1] + 1) {
            lcs += s[i - 1];
            --i;
            --j;
        } else if (i > 0 && dp[i][j] == dp[i - 1][j]) {
            --i;
        } else if (j > 0 && dp[i][j] == dp[i][j - 1]) {
            --j;
        } else {
            assert(false);
        }
    }
    reverse(begin(lcs), end(lcs));
    cout << lcs << "\n";

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define LL long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define sch(n) scanf(" %c", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define Unique(a)  sort(all(a)),a.erase(unique(all(a)),a.end())

#define inf (1LL<<50)
#define eps 1e-9

ll Set(ll n, ll pos)
{
    return n|(1LL<<pos);
}

bool Check(ll n, ll pos)
{
    return (bool) (n&(1LL<<pos));
}

ll a[110];
ll dp[110][100010];
ll csum[110][100010];

#define mod 1000000007

int main ()
{
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  ios_base::sync_with_stdio(0); // no printf/scanf must be present
    ll cs, ts, i, j, k, x, y, z, q, m, n, cap;

    while(sl(n) != EOF)
    {
        sl(m);
        for (i = 1; i <= n; i++)
        {
            sl(a[i]);
        }

        dp[0][0] = 1;
        csum[0][0] = 1;

        for (i = 0; i <= n; i++)
        {
            for (k = 0; k <= m; k++)
            {
                if (i == 0 && k == 0) continue;

                if (i)
                {
                    dp[i][k] = csum[i-1][k];
                    ll lo = k - a[i];
                    lo = max(lo, 0LL);
                    if (lo)
                    {
                        dp[i][k] -= csum[i-1][lo-1];
                    }
                    if (dp[i][k] < 0)
                        dp[i][k] += mod;
                }

                csum[i][k] = dp[i][k];
                if (k)
                    csum[i][k] = (csum[i][k] + csum[i][k-1])%mod;
            }
        }

        printf("%lld\n", dp[n][m]);
    }
    return 0;
}


Measured memory_bytes: 162048
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int N, X, Y;
    while(cin >> N >> X >> Y){
        vector<vector<int>> g(N);
        for(int i=0;i<N-1;i++){
            g[i].push_back(i+1);
            g[i+1].push_back(i);
        }
        g[X-1].push_back(Y-1);
        g[Y-1].push_back(X-1);
        vector<int> res(N, 0);
        for(int i=0;i<N;i++){
            vector<int> dist(N, -1);
            dist[i] = 0;
            queue<int> qu; qu.push(i);
            while(!qu.empty()){
                int t = qu.front(); qu.pop();
                for(auto& v : g[t]){
                    if(dist[v] != -1) continue;
                    dist[v] = dist[t] + 1;
                    qu.push(v);
                }
            }
            for(int j=i+1;j<N;j++) ++res[dist[j]];
        }
        for(int i=1;i<N;i++) cout << res[i] << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int trace(int a[],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
       if((i>0)&&(i!=n))
        printf(" ");
       printf("%d",a[i]);
    }
    cout<<endl;
}
int insertionsort(int a[],int n)
{
    int j,i,v;
    for(i=1;i<n;i++)
    {
        v=a[i];
        j=i-1;
        while(j>=0&&a[j]>v)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        trace(a,n);
    }
}
int main()
{
    int n,i,j;
    int a[100];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    trace(a,n);
    insertionsort(a,n);
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> B(N + 1), C(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    B.at(i + 1) = B.at(i) + A.at(i);
  }
  long long ans = 0;
  
  for(int i = 0; i < N - 1; i++){
    C.at(i) = (B.at(N) - B.at(i + 1)) % 1000000007;
    ans += A.at(i) * C.at(i);
    ans %= 1000000007;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 7216
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n - 2):
    a = L[i]
    for j in range(i + 1, n - 1):
        b = L[j]
        k = bisect.bisect_left(L[j + 1:], a + b)
        ans += k
print(ans)


Measured memory_bytes: 51548
<?php
  $a = fgets(STDIN);
  $b = explode(" ",fgets(STDIN));
  $arr = array_fill(0, $a - 1, 0);
  for($i=0; $i<$a; $i++){
    $arr[$b[$i] - 1 ] = $i + 1;
  }
  $s = implode(" ", $arr);
  echo $s;

  
  ?>

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

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
int main(){
   string s;
  
   int memo[26] = {0};
   int i;
   int flag = 1;
  
   cin >> s;
  
   for(i = 0; i < s.size(); i++){
       memo[(int)s[i]-97]++;
   }
for(i = 0; i < 26; i++){
       if(memo[i]%2 != 0){
           flag = 0;
       }
   }
  
   if(flag){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
n, l = gets.split.map(&:to_i)
l_arr = []
abs_arr = []
l_arr_sum = 0

n.times{
l_arr <<  l
l_arr_sum += l
l += 1
}


l_arr.each { |i|
abs_arr << i.abs
}
abs_arr.sort!

if l_arr_sum  >= 0
  p l_arr_sum  - abs_arr[0]
else
  p l_arr_sum  + abs_arr[0]
end


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

int main() {
    int n, a, odd = 0, even = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a & 1) ++odd;
        else ++even;
    }
    if (odd & 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}

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

int main(){

	int n;
	const int num = 39;

	while(cin >> n){
		n %= num;
		if(n == 0) cout << "3C39" << endl;
		else if(n < 10) cout << "3C0" << n << endl;
		else cout << "3C" << n << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/5/27 9:46:49
 *Ended  Time*  : 2018/5/27 10:22:57
*********************************************/

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 200000;

int n;
LL XOR[MaxN + 5], sum[MaxN + 5];

int main()
{
    while(scanf("%d", &n) != EOF)
	{
		XOR[0] = sum[0] = 0;
		for(int i = 1; i <= n; i++) {
			LL x;
			scanf("%lld", &x);
			XOR[i] = XOR[i - 1] ^ x;
			sum[i] = sum[i - 1] + x;
		}
		LL ans = 0LL;
		int l = 1;
		for(int r = 1; r <= n; r++) {
			while((sum[r] - sum[l - 1]) != (XOR[r] ^ XOR[l - 1]) && l <= n) l++;
			ans += (LL)(r - l + 1);
		}
		printf("%lld\n", ans);
	}
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> nums(100002, 0);

    int a = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        nums.at(a)++;
        nums.at(a + 1)++;
        nums.at(a + 2)++;
    }

    sort(nums.begin(), nums.end());
    reverse(nums.begin(), nums.end());

    cout << nums.at(0) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[500010];
int main(){
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);

    rep(i, n) {
        int a; cin >> a;
        fw.add(i, a);
    }

    rep(i, q){
        int b; cin >> b;
        if (b == 0) {
            int p;
            ll x;
            cin >> p >> x;
            fw.add(p, x);
        }
        else {
            int l, r; cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		char s[] = br.readLine().toCharArray();
		char t[] = br.readLine().toCharArray();
		br.close();

		int row = t.length;
		int col = s.length;
		int tb[][] = new int[row + 1][col + 1];

		for ( int r = 0; r < row; r++ ) {
			for ( int c = 0; c < col; c++ ) {
				if ( t[r] == s[c] ) {
					tb[r + 1][c + 1] = tb[r][c] + 1;
				} else {
					tb[r + 1][c + 1] = Math.max(tb[r + 1][c], tb[r][c + 1]);
				}
			}
		}

		int r = row;
		int c = col;
		ArrayDeque<Character> stack = new ArrayDeque<Character>();
		stack.add(' ');
		while ( tb[r][c] != 0 ) {

			// 左上に行けるとき
			if ( tb[r - 1][c - 1] == tb[r][c] ) {
				r -= 1;
				c -= 1;
			} else
			// 上にだけ行けるとき
			if ( tb[r - 1][c] == tb[r][c] ) {
				r -= 1;
			} else
			// 左にだけ行けるとき
			if ( tb[r][c - 1] == tb[r][c] ) {
				c -= 1;
			} else
			// 行き止まり
			{
				stack.add((Character) s[c - 1]);
				r -= 1;
				c -= 1;
			}
		}

		StringBuilder sb = new StringBuilder();
		while ( stack.size() > 0 ) {
			sb.append(stack.pollLast());
		}
		System.out.println(sb);
	}
}


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

using namespace std;

int main()
{
    int n,m;
    int a_num,b_num;
    cin >> n >> m;

    int *array = new int[n];
    int *array_ = new int[n];
    int array2;

    for(int i = 0;i < m;i++){
        cin >> a_num >> b_num;
        if(a_num == 1 || a_num == n || b_num == 1 || b_num == n){
            array[a_num - 1]++;
            array_[b_num - 1]++;
        }
    }
            int sum = 0;
            for(int k = 0;k < n;k++){
                sum += array[k] * array_[k];    
            }
            array2 = sum;
    
    if(array2 != 0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    delete[] array;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) 
{
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && a < c && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
	
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int n, m;
vector<vector<pair<int, int>>> g;
vector<int> dist;

void dfs(int v, int d) {
    if (dist[v] != INT_MAX) return;
    dist[v] = d;
    rep(i, sz(g[v])) {
        dfs(g[v][i].first, d + g[v][i].second);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    g.resize(n);
    dist.resize(n, INT_MAX);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -1 * d);
    }
    rep(i, n) {
        if (dist[i] != INT_MAX) continue;
        dfs(i, 0);
    }
    rep(i, n) {
        rep(ii, sz(g[i])) {
            if ((dist[i] + g[i][ii].second) != dist[g[i][ii].first]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 12032
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll N, W;
vector<ll> weight(110), value(110);
vector<vector<ll>> memo(110, vector<ll>(100010, -1));

ll solve(ll n, ll v)
{
    if (memo.at(n).at(v) != -1)
    {
        return memo.at(n).at(v);
    }
    if (n == N)
    {
        if (v == 0)
        {
            return 0;
        }
        else
        {
            return 100000000000000;
        }
    }
    if (v - value.at(n) < 0)
    {
        return memo.at(n).at(v) = solve(n + 1, v);
    }
    else
    {
        ll res1 = solve(n + 1, v);
        ll res2 = solve(n + 1, v - value.at(n)) + weight.at(n);
        return memo.at(n).at(v) = min(res1, res2);
    }
}

int main()
{
    cin >> N >> W;
    rep(0, i, N)
    {
        cin >> weight.at(i) >> value.at(i);
    }

    memo.at(0).at(0) = 0;
    ll ans = 0;

    rep(0, i, 100010)
    {
        if (solve(0, i) <= W)
        {
            ans = i;
        }
    }

    cout << ans << endl;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	int a, b; cin >> a >> b;
	cout << ( a + b + 1 ) / 2 << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
edge = [tuple(map(int, input().split())) for i in range(M)]
cost = [-float("inf")] * N
cost[0] = 0

for n in range(N-1):
  for m in range(M):
    a, b, c = edge[m]
    cost[b-1] = max(cost[b-1], cost[a-1] + c)

r = cost[-1]
for m in range(M):
    a, b, c = edge[m]
    cost[b-1] = max(cost[b-1], cost[a-1] + c)

print(r if cost[-1] == r else "inf")

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

int main() {
	int N;
    string U[10];
    double X[10];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> X[i] >>  U[i];
    double money = 0;

	for (int i = 0; i < N; ++i){
		if(U[i][0] == 'J') money += X[i];
		if(U[i][0] == 'B') money += 380000.0 * X[i];
	}
	cout << money << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){int n,k,l,i;while(1){cin>>n>>k;if(n==0&&k==0)break;int s[k];for(i=0;i<k;i++)s[i]=0,cin>>s[i];for(i=0;i<n;i++)for(int j=0;j<k;j++)cin>>l,s[j]-=l;for(i=0;i<k;i++){if(s[i]<0){cout<<"No\n";break;}if(i==k-1)cout<<"Yes\n";}}}

Measured memory_bytes: 844
from itertools import permutations

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
inf = 10**9

edges=[[inf for i in range(n+1)] for i in range(n+1)]

for i in range(m):
  a,b,c = map(int,input().split())
  edges[a][b] = c
  edges[b][a] = c


for k in range(1,n+1):
  for i in range(1,n):
    for j in range(i,n+1):
      if edges[i][j] > edges[i][k] + edges[k][j]:
        edges[i][j] = edges[i][k]+edges[k][j]
        edges[j][i] = edges[i][j]


ans = inf
for i in permutations(R):
  tmp = 0
  for j in range(r-1):
    tmp += edges[i[j]][i[j+1]]
  ans = min(tmp, ans)

print(ans)

Measured memory_bytes: 4000
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

    int N, M;
    while(cin >> N >> M, N) {
        int ans = 0;
        vector< iP > edge(N);
        for(int i = 0; i < N; i++) {
            int d, p; cin >> d >> p;
            edge[i] = iP(p, d);
        }
        sort(edge.begin(), edge.end(), greater< iP >());
        for(int i = 0; i < N; i++) {
            if(M > 0) {
                if(edge[i].sc <= M) M -= edge[i].sc;
                else {
                    ans += edge[i].fr * (edge[i].sc - M);
                    M = 0;
                }
            } else ans += edge[i].sc * edge[i].fr;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1276
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	n=int(input())
	dp=[[0]*3 for _ in range(n+1)]
	
	
	for i in range(n):
		a,b,c=map(int,input().split())
		dp[i+1][0]=max(dp[i][1],dp[i][2])+a
		dp[i+1][1] = max(dp[i][2], dp[i][0]) + b
		dp[i+1][2] = max(dp[i][0], dp[i][1]) + c
		
	print(max(dp[n][0],dp[n][1],dp[n][2]))
	
	
	
if __name__ == "__main__":
	main()


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

using namespace std;

int main()
{
    vector<int> s((1000 + 2) * (1000 - 2) / 2, 0);
    for (int l = 2; l <= 1000; ++l) {
        for (int i = 1; i <= 1000 - l + 1; ++i) {
            int sum = 0;
            for (int j = i; j < i + l; ++j) {
                sum += j;
            }
            s[sum] += 1;
        }
    }

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

        cout << s[n] << endl;
    }
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, A, B;
  ci(N, A, B);
  int a = 0;
  repi(i, 1, N + 1){
    st s = tos(i);
    int c = 0;
    rep(j, sz(s)){
      c += s.at(j) - 48;
    }
    if(A <= c && c <= B){
      a += i;
    }
  }
  co(a);
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;
  typedef pair<ll, ll> P;

  static const ll MAX = 100010LL;
  ll N, A[MAX], dp[MAX];

  void init() {
    scanf("%lld", &N);
    rep(i, N) scanf("%lld", &A[i]);
    rep(i, N+1) dp[i] = LINF;
  }

  void solve() {
    rep(i, N) *upper_bound(dp, dp+N, -A[i]) = -A[i];
    rep(i, N+1) if(dp[i] == LINF) {
      printf("%lld\n", i);
      return;
    }
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            string[] s = new string[N];
            for(var i = 0; i < N; i++)
            {
                char[] ss = Console.ReadLine().ToArray();
                Array.Sort(ss);
                var sss = new StringBuilder();
                for(var j = 0; j < 10; j++)
                {
                    sss.Append(ss[j]);
                }
                s[i] = sss.ToString();
            }
            Array.Sort(s);
            int cnt = 0;
            long ans = 0;
            var c = new Calculation();

            List<int> anslist = new List<int>();
            for(int i = 1; i < N; i++)
            {

                if (s[i] == s[i - 1])
                {
                    cnt++;
                    if (i == N - 1)
                    {
                        anslist.Add(cnt + 1);
                    }
                }
                else
                {
                    if (cnt > 0)
                    {
                        anslist.Add(cnt + 1);
                    }
                    cnt = 0;
                }
            }

            foreach(var i in anslist)
            {
                ans += c.GetNCR(i, 2);
            }

           
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }



    public class Calculation
    {
        public long GetNCR(int n, int r) //二項係数(生の値)
        {
            if (n == 1) { return 1; }
            long[] nC = new long[n + 1];
            nC[0] = 1;
            for (var i = 0; i <= r - 1; i++)
            {
                nC[i + 1] = nC[i] * (n - i) / (i + 1);
            }
            return nC[r];
        }
    }

    public class Graph
    {
        
    }
}


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

int main() {
  int N;
  cin >> N;
  long a[N];
  a[0] = 2;
  a[1] = 1;

  if(N == 0)cout << a[0] << endl;
  if(N == 1)cout << a[1] << endl;
  if(N > 1){
    for(int i =0;i<= N-2;i++){
      a[i+2]=a[i+1]+a[i];
    }
    cout << a[N] << endl;
  }
}


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

map<long long, int> prime_factor(long long n) {
    map<long long, int> res;
    for (long long i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) if (n % i == 0) {
        res.push_back(i);
        if (i * i != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N;
    cin >> N;
    cout << prime_factor(N).size() << " " << divisor(N).size() - 1 << endl;
}


Measured memory_bytes: 3160
let _=readLine(),p=readLine()!.characters.split(" ").map{Int(String($0))!}
print((1..<p.count-1).reduce(0){i,j in let k=(p[j-1]<p[j]&&p[j]<p[j+1])||(p[j-1]>p[j]&&p[j]>p[j+1]) ?1:0;return i+k})

Measured memory_bytes: 4208
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Tue Jan 22 16:25:25 2019
//
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)

	fmt.Println(A * B / 2)
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;
    int fr = 0;
    int cnt[10]; memset(cnt,0,sizeof(cnt));
    int cc = 0;

    for (int i = 0;i < N;i++){
        int a; cin >> a;
        if(a >= 3200){ fr++; continue;}
        if(cnt[a/400] == 0) cc++;
        cnt[a/400]++;
    }

    cout << max(cc,1) << " " << cc+fr << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  cin>>n;
  int x=0;
  for(int i=0;i<n.size();i++){
    x+=n.at(i)-'0';
  }
  if(x%9==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}
  

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
using namespace std;
int pcnt(int x){
    return __builtin_popcount(x);
}
int f(int x){
    if(x == 0)return 0;
    else return f(x % pcnt(x)) + 1;
}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    vector<int>ans(n);
    for(int i = 0;i < n;i++){
        x[i] = s[i] - '0';
    }
    int pc = 0;
    for(int i = 0;i < n;i++){//元の数の１ビットの個数を調べる
        pc += x[i];
    }


    //////////

    for(int b = 0;b < 2;b++){//0を1に置き換えた場合と1を0におきかえた場合を調べる}
        int npc = pc;
        if(b == 0){//0ビットを1に直した場合
            npc++;//合計が1増える
        }else{//1を0に直した場合
            npc--;//合計が1減る
        }
        if(npc <= 0)continue;
        int r0 = 0;
        for(int i = 0;i < n;i++){
            r0 = (r0 * 2) % npc;//10進数に直しながら剰余演算
            r0 += x[i];
        }

        int k = 1;//各桁のビットの置き換えを行う
        for(int i = n - 1;i >= 0;i--){
            if(x[i] == b){//今見てるビットがお目当てだった場合
                int r = r0;
                if(b == 0) r = (r + k) % npc;
                else{
                    r = (r - k + npc) % npc;
                }
                ans[i] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }

    }

    for(int i = 0;i < n;i++){
        cout << ans[i] << endl;
    }

    return 0;
}

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

int digit(ll A) {
    int cnt = 0;
    while (A != 0) {
        cnt++;
        A /= 10;
    }
    return cnt;
}

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

    int ans = 1e9;
    for (ll i = 1; i * i <= N; i++) {
        int digitA, digitB;
        if (N % i == 0) {
            digitA = digit(i);
            digitB = digit(N / i);
            ans = min(max(digitA, digitB), ans);
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double bumbo = 0.0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            bumbo += 1.0/a;
        }
        double result = 1.0/bumbo;
        System.out.println(result);
    }
}


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

data = list(map(int, input().split(' ')))

before_max = 0

dai = 0

for i in range(len(data)):
    if(i == 0):
        before_max = data[i]
    else:
        # 自分の身長がこれまでの最大身長よりも高いとき
        if(before_max < data[i]):
            before_max = data[i]
            continue
        # これまでの最大身長よりも自分の身長が低いとき
        elif(before_max > data[i]):
            dai += before_max - data[i]

print(dai)

Measured memory_bytes: 32228
#%%
import time

import numpy as np

N = int(input())
A = [0] * N
B = [0] * N
C = [[] for _ in range(N) ]
takahashi = []
aoki = []

start = time.time()

for i in range(N):
  A[i], B[i] = map(int,input().split())


D = np.array(A) + np.array(B)
for i in range(N):
  C[i] = [i, D[i]]


elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()

C = sorted(C, key=lambda x:x[1])


elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
start = time.time()


if N %2 == 0 :
  for i in range(1,N,2):
    tmp_max = C[-i][0]
    takahashi.append(A[tmp_max])
    tmp_max = C[-i-1][0]
    aoki.append(B[tmp_max])

elif N %2 != 0 :
  for i in range(1,N-1,2):
    tmp_max = C[-i][0]
    takahashi.append(A[tmp_max])
    tmp_max = C[-i-1][0]
    aoki.append(B[tmp_max])
  tmp_max = C[-N][0]
  takahashi.append(A[tmp_max])

print(sum(takahashi)-sum(aoki))

elapsed_time = time.time() - start
#print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")





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

int main(){ 
string s,t,u;
int a,b;
cin>>s>>t>>a>>b>>u;
if(u==s){
cout<<a-1<<" "<<b<<endl;
}
else if(u==t){
cout<<a<<" "<<b-1<<endl;
}
else{
cout<<"No"<<endl; 
}
}

Measured memory_bytes: 256