akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int m;

  cin >> m;

  while( m-- ) {
    string s;
    set<string> all;

    cin >> s;
    
    all.insert( s );
    
    for(int i=1; i<s.size(); i++) {
      string s1 = "", s1_ = "", s2 = "", s2_ = "";

      for(int j=0; j<i; j++) s1 += s[j], s1_ += s[i-1-j];
      for(int j=i; j<s.size(); j++) s2 += s[j], s2_ += s[s.size()-1-j+i];

      //cout << s1 + " "<< s1_ + " " << s2 + " " << s2_ << endl; 
      all.insert( s1 + s2_ );
      all.insert( s1_ + s2 );
      all.insert( s1_ + s2_ );
      all.insert( s2 + s1 );
      all.insert( s2 + s1_ );
      all.insert( s2_ + s1 );
      all.insert( s2_ + s1_ );
      
    }

    cout << all.size() << endl;
  }
  
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int h, w;
	cin >> h >> w;

	int c[10][10];
	rep(i, 10) rep(j, 10) cin >> c[i][j];

	int a[h][w];
	rep(i, h) rep(j, w) cin >> a[i][j];

	// ワーシャルフロイドで各数字から各数字への最短距離を求める
	rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

	// 壁の数字ごとに1までの最短距離を足す
	ll ans = 0;
	rep(i, h) {
		rep(j, w){
			if(a[i][j] >= 0) ans += c[a[i][j]][1];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int read(){
    char c;int x=0,f=1;
    c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return f*x;
}
int main(){
	return 0&(int)puts(abs(read()-read())<=1?"Brown":"Alice");
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
bool cmp(pair<ll,ll> p1 , pair<ll,ll>p2){
	// if(p1.f==p2.f){
	// 	return p1.s>p2.s;
	// }
	return p1.f>p2.f;
}
int main(){
	//mahakal(),fast;
	ll n ,m ;
	cin>> n >> m ;
	vector<pair<ll,ll>> vec;
	for(ll i=0,a,b ;i< n ;i++){
		cin>>a>>b ;
		vec.pb({b,a});
	}
	sort(vec.begin(),vec.end(),cmp);
	ll slot[m+1]={0};
	ll ans=0;
	set<ll> st ;
	for(ll i=0;i<=m ;i++)st.insert(i);
	for(ll i=0;i<n ;i++){
		ll idx=m-vec[i].s;
		if(idx<0)continue;
		// for(ll j=idx;j>=0 ; j--){
		// 	if(slot[j]==0){
		// 		slot[j]=vec[i].f;
		// 		break;
		// 	}
		// }
		auto ps=st.lower_bound(idx);
		if(*ps==idx){
			ans+=vec[i].f;
			st.erase(ps);
		}
		else{
			if(ps==st.begin())continue;
			else{
				--ps;
				ans+=vec[i].f;
				st.erase(ps);
			}
		}
	}
	// for(ll i=0;i<=m;i++)ans+=slot[i];
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 7280
///Prochnost
#include<bits/stdc++.h>
#define pb push_back
#define task "BUILT"
#define MOD 1000000007
#define mx 200010
#define EPS 1e-6
#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
using namespace std;
///mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
///int rnd(int l,int r){return l+rng()%(r-l+1);}
template <typename T> inline void read(T &x)
{
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'))
        ;
    if(c=='-')
    {
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar()))
        x=x*10+c-48;
    if(nega)
        x=-x;
}
template <typename T> inline void writep(T x)
{
    if(x>9)
        writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    writep(x);
    putchar(' ');
}
template <typename T> inline void writeln(T x)
{
    write(x);
    putchar('\n');
}
struct data
{
    int u, v, w, id;
} a[mx],p[mx];
int root[mx], n;
void nhap()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i].u >> a[i].v, a[i].id = i;
}
bool cmp(data a,data b)
{
    return a.u < b.u;
}
bool cmp2(data a, data b)
{
    return a.v < b.v;
}
bool cmp3(data a, data b)
{
    return a.w < b.w;
}
int get(int u)
{
    return(root[u])?(root[u] = get(root[u])): u;
}
void solve()
{
    long long ans = 0;
    int m = 0;
    sort(a + 1, a + 1 + n,cmp);

    for(int i = 2; i <= n; i++)
    {
        p[++m] = {a[i].id,a[i-1].id,abs(a[i].u - a[i-1].u)};
    }
    p[++m] = {a[1].id, a[n].id, abs(a[1].u - a[n].u)};
    sort(a + 1, a + 1 + n,cmp2);
    for(int i = 2; i    <= n; i++)
    {
        p[++m] = {a[i].id,a[i-1].id,abs(a[i].v - a[i-1].v)};
    }
    p[++m] = {a[1].id, a[n].id, abs(a[1].v - a[n].v)};
    p[++m] = {1, n, min(abs(a[1].u - a[n].u),abs(a[1].v - a[n].v))};
    sort(p + 1, p + 1 + m, cmp3);
    for(int i = 1; i <= m; i++)
    {
        int x = get(p[i].u);
        int y = get(p[i].v);
        if(x != y)
        {
            root[x] = y;
            ans += 1ll * p[i].w;
        }
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    nhap();
    solve();
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1e9 + 7;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    string k;
    ll d;
    cin >> k >> d;
    ll n = sz(k);
    vv dp(n, v(d, 0));

    // dp[i][j] = number of ways to form number till i-th position from MSB such
    // that i-th posn par remainder is j
    for (ll i = 0; i < k[0] - '0'; i++) {
        dp[0][i % d] += 1;
    }

    ll sumsofar = k[0] - '0';
    for (ll pos = 1; pos < n; pos++) {
        for (ll prevrem = 0; prevrem < d; prevrem++) {
            for (ll dig = 0; dig < 10; dig++) {
                ll rem = prevrem + dig;
                rem %= d;
                dp[pos][rem] += dp[pos - 1][prevrem];
                dp[pos][rem] %= MOD;
            }
        }

        for (ll i = 0; i < k[pos] - '0'; i++) {
            ll rem = (sumsofar + i) % d;
            dp[pos][rem] += 1;
            dp[pos][rem] %= MOD;
        }

        sumsofar += k[pos] - '0';
    }
    if (sumsofar % d != 0)
        dp[n - 1][0] -= 1;
    dp[n - 1][0] += MOD;
    dp[n - 1][0] %= MOD;

    cout << dp[n - 1][0];
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define endl "\n"
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
typedef pair<ll, string> ls;
typedef pair<ll, ls> lls;
ll N;
string S[50];
ll C[50];
map<ls, ll> mp;
priority_queue<lls, vector<lls>, greater<lls>> que;

void f(ls S, ll C) {
    if(mp.count(S) == 0) {
        mp[S] = C;
        que.push({C, S});
    } else if(chmin(mp[S], C)) {
        mp[S] = C;
        que.push({C, S});
    }
}

bool IsPallindrome(string S) {
    string T = S;
    reverse(T.begin(), T.end());
    return S == T;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> S[i] >> C[i];
        f({1, S[i]}, C[i]);
    }
    ll ans = INF;
    while(!que.empty()) {
        auto now = que.top();
        //cerr << now.second.first << " " << now.second.second << " " << now.first << endl;
        que.pop();
        if(IsPallindrome(now.second.second)) {
            chmin(ans, now.first);
            continue;
        }
        for(int i = 0; i < N; i++) {
            string a = now.second.second;
            string b = S[i];
            if(now.second.first) {
                reverse(b.begin(), b.end());
            }
            ll retrev = now.second.first;
            if(a.size() < b.size()) {
                swap(a, b);
                retrev = 1 - retrev;
            }
            ll l = min(a.size(), b.size());
            if(a.substr(0, l) != b.substr(0, l)) continue;
            ll newc = now.first + C[i];
            string T = a.substr(l, a.size() - l);
            f({retrev, T}, newc);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int N, M;
string flag[100];

int main() {
	scanf("%d %d", &N, &M);
	rep(i, N) cin >> flag[i];
	int ans = INF;
	rep(i, N - 2) {	//W
		int wcnt = 0;
		rep(j, i + 1) rep(k, M) {
			if(flag[j][k] != 'W') ++wcnt;
		}
		FOR(j, i + 1, N - 1) {	//B
			int bcnt = 0;
			FOR(k, i + 1, j + 1) rep(l, M) {
				if(flag[k][l] != 'B') ++bcnt;
			}
			int rcnt = 0;
			FOR(k, j + 1, N) {	//R
				rep(l, M) if(flag[k][l] != 'R') ++rcnt;
			}
			int total = wcnt + bcnt + rcnt;
			ans = min(ans, total);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
  vector<int> v;
  for( int i=0; i<5; i++ ){
    int d;
    cin >> d;
    v.push_back( d );
  }
  sort( v.begin(), v.end() );
  cout << v[4] << ' ' << v[3] << ' ' << v[2] << ' ' << v[1] << ' ' << v[0] << endl;
  return 0;
}

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    string s;
    cin >> s;
    int res = inf<int>;
    for(int i = 0; i < 26; ++i) {
        char c = 'a' + i;
        if(s.find(c) == string::npos) {
            continue;
        }

        string t = s;
        int cnt = 0;
        while(true) {
            {
                bool ok = true;
                for(auto cc : t) {
                    ok &= cc == c;
                }
                if(ok) {
                    break;
                }
            }
            
            cnt++;
            string nxt;
            for(int j = 0; j + 1 < t.size(); ++j) {
                if(t[j] == c || t[j + 1] == c) {
                    nxt += c;
                } else {
                    nxt += t[j];
                }
            }
            t = move(nxt);
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}


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

using namespace std;

#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=2e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

	int n;
	cin >> n;

	for(int i=1; i<=9; i++)
	{
		if(n%i==0)
		{
			int a=n/i;

			if(a<=9)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	
	return 0;
}

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

int main()
{
  char s;
  cin >> s;

  if (isupper(s))
  {
    cout << 'A' << endl;
  }
  else
  {
    cout << 'a' << endl;
  }

   return 0;
}


Measured memory_bytes: 3608
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N = int(input())
A = [int(i) for i in input().split()]
B =sum(A)
count =0
num = 0
while count < B//2:
    count +=A[num]
    num += 1
count_alt = count - A[num-1]
print(min(abs(B-count*2),abs(B-count_alt*2)))


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

const int N = 100005;

int n;
int a[N][3];
int f[N][3];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 3; ++j) {
			scanf("%d", &a[i][j]);
			f[i][j] = -1e9 - 123;
		}
	}
	for (int i = 0; i < 3; ++i) {
		f[1][i] = a[1][i];
	}
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) if (j ^ k) {
				f[i + 1][k] = max(f[i + 1][k], f[i][j] + a[i + 1][k]);
			}
		}
	}
	printf("%d\n", max(f[n][0], max(f[n][1], f[n][2])));
}

Measured memory_bytes: 2560
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// Credits - github.com/EndlessCheng/codeforces-go
func solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	n:= 0
	Fscan(in, &n);
	n-=400
	n/=200
	Fprintf(out,"%d",8-n)
}

func main() { solve(os.Stdin, os.Stdout) }



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

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

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool r = false;
    if (a - b >= 0 && d >= b) {
      ll k = gcd(b, d);
      ll x = a <= c ? a + ((c - a) / k + 1) * k : c + (a - c - 1) % k + 1;
      r = x - b >= 0;
    }
    cout << (r ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
from collections import defaultdict


def search(colors):
    dp = [1] * len(colors)
    c_dict = defaultdict(list)
    c_sum = defaultdict(int, {colors[0]:1})
    for i in range(1, len(colors)):
        color = colors[i]
        dp[i] = dp[i-1]
        if color != colors[i-1]:
            dp[i] += c_sum[color]
            c_sum[color] = dp[i]
    print(dp[-1] % (10**9 + 7))

N = int(input())
colors = []
for _ in range(N):
    colors.append(int(input()))

search(colors)


Measured memory_bytes: 760832
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

  ll h,w,n;
  std::cin>>h>>w>>n;

  ll sr,sc;
  std::cin>>sr>>sc;
  sr--;sc--;

  std::string s,t;
  std::cin>>s>>t;

  ll left=-1,right=w;

  for(ll i=n-1;i>=0;i--){
    if(t[i]=='L'){
      if(right!=w)right++;
    }else if(t[i]=='R'){
      if(left!=-1)left--;
    }
    if(s[i]=='L'){
      left++;
    }else if(s[i]=='R'){
      right--;
    }
    if(left+1==right){
      std::cout<<"NO\n";
      return 0;
    }
  }

  ll up=-1,down=h;

  for(ll i=n-1;i>=0;i--){
    if(t[i]=='U'){
      if(down!=h)down++;
    }else if(t[i]=='D'){
      if(up!=-1)up--;
    }
    if(s[i]=='U'){
      up++;
    }else if(s[i]=='D'){
      down--;
    }
    if(up+1==down){
      std::cout<<"NO\n";
      return 0;
    }
  }

  if(up<sr&&sr<down&&left<sc&&sc<right)std::cout<<"YES\n";
  else std::cout<<"NO\n";

  return 0;
}


Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    long long mod = 1e9 + 7;
    vector<long long>v(n + 5);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    long long dp[n + 5][k + 5], cum[n + 5][k + 5];
    sort(v.begin() + 1, v.begin() + n + 1);
    dp[1][0] = 1, cum[1][0] = 1;
    for(int i = 1; i <= v[1]; i++){
        dp[1][i] = 1;
        cum[1][i] = (cum[1][i - 1] + dp[1][i]) % mod;
    }
    for(int i = v[1] + 1; i <= k; i++){
        dp[1][i] = 0;
        cum[1][i] = cum[1][i - 1];
    }
    for(int i = 2; i <= n; i++){
        for(int j = 0; j <= v[i]; j++){
            dp[i][j] = cum[i - 1][j];
            if(j == 0){
                cum[i][j] = dp[i][j];
            }
            else{
                cum[i][j] = (cum[i][j - 1] + dp[i][j])%mod;
            }
        }
        for(int j = v[i] + 1; j <= k; j++){
            dp[i][j] = (cum[i - 1][j] - cum[i - 1][j - v[i] - 1] + 2*mod) % mod;
            cum[i][j] = (cum[i][j - 1] + dp[i][j]) % mod;
        }
    }
    cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 159908
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  long long cnt[26] = {};
  for (char c : s) {
    cnt[c - 'a']++;
  }
  long long n = (long long) s.length();
  long long ans = n * (n - 1) / 2;
  for (int i = 0; i < 26; i++) {
    ans -= cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans + 1<< endl;
  return 0;	
}

Measured memory_bytes: 720
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll x,k,d;
  cin>>x>>k>>d;
  x = abs(x);
  ll ret;
  if(k&1)ret = min(abs(x-d), abs(x+d));
  else ret = x;
  if(x/k>=d){
    x = x - k * d;
    ret = min(ret, x);
  } else {
    ll k1 = x/d;
    ll t1 = x - k1 * d;
    ll kk1 = k1 & 1;
    ll kk2 = k & 1;
    if(kk1==kk2)ret = min(ret, t1);
    else ret =min(ret, abs(t1-d));
  }
  cout<<ret<<endl;
  return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int sum = 0;
  rep(i,n){
    int x;
    cin >> x;
    sum += min(2*x,2*(k-x));
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void PR(bool f){
  cout << (f ? "YES" : "NO") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  PR(k <= (n+1)/2);
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
class UnionFind{
    public:
        int n;
        vector<T> p, rank;

        UnionFind(int n)
            : n(n), p(n+1, -1), rank(n+1) {}

        int find(int v){
            if(p[v] == -1){
                return v;
            }
            p[v] = find(p[v]);
            return p[v];
        }

        bool unite(int u, int v){
            u = find(u);
            v = find(v);

            if(u == v){
                return false;
            }

            if(rank[u] < rank[v]){
                swap(u, v);
            }

            if(rank[u] == rank[v]){
                rank[u]++;
            }

            p[v] = u;
            return true;
        }

        bool same(int u, int v){
            u = find(u);
            v = find(v);
            return u == v;
        }
};

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

    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> edge(m);
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        edge[i] = make_tuple(c, a, b);
    }
    sort(ALL(edge));

    auto graph = initVec2<P>(n + 1, 0);
    UnionFind<int> uf(n);
    int sum = 0;
    rep(i, m){
        int u, v, w;
        tie(w, u, v) = edge[i];
        if(uf.unite(u, v)){
            graph[u].emplace_back(v, w);
            graph[v].emplace_back(u, w);
            sum += w;
        }
    }

    auto weight = initVec2<int>(n + 1, n + 1);
    for(int i = 1; i <= n; i++){
        stack<tuple<int, int, int>> st;
        st.emplace(i, 0, 0);

        while(not st.empty()){
            int v, p, w;
            tie(v, p, w) = st.top();
            st.pop();

            weight[i][v] = w;

            for(P pp : graph[v]){
                int u = pp.first;
                int we = pp.second;
                if(u == p){
                    continue;
                }
                st.emplace(u, v, max(w, we));
            }
        }
    }

    int q;
    cin >> q;
    rep(i, q){
        int s, t;
        cin >> s >> t;

        cout << sum - weight[s][t] << endl;
    }

    return 0;
}


Measured memory_bytes: 136320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    ll x,y;
    cin >> x >> y;
    int cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout << cnt;


    
}

/*
*/



Measured memory_bytes: 256
#include <stdio.h>

int main() {   
    int a,b,c,tmp;
    scanf("%d %d %d", &a,&b,&c);
    
    if(b < a){
        tmp = a;
        a = b;
        b = tmp;
    }if (c < a) {
        tmp = a;
        a = c;
        c = tmp;
    }if (c < b) {
        tmp = b;
        b = c;
        c = tmp;
    }
    
    printf("%d %d %d\n", a,b,c);
    
    return 0;
}



Measured memory_bytes: 2040
idx=Array.new(100100,0)
n,q=gets.split.map(&:to_i)
s=gets.chomp
cnt=0
for i in 1..s.length-1 do
  if s[i-1]=="A" && s[i]=="C"
    cnt+=1
  end
  idx[i]=cnt
end
for i in 1..q do
  a,b=gets.split.map(&:to_i)
  p idx[b-1]-idx[a-1]
end











Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007



int main()
{
	FAST;
	ll a[5];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1];
	return 0;
}

Measured memory_bytes: 3596
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0 for _ in range(n+1)] # sum_A[i]:=上からi冊の本を読むときにかかる時間
for i in range(1, n+1):
    sum_A[i] = sum_A[i-1] + A[i-1]
sum_B = [0 for _ in range(m+1)] # sum_B[i]:=上からj冊の本を読むときにかかる時間
for j in range(1, m+1):
    sum_B[j] = sum_B[j-1] + B[j-1]

ans = 0
i = 0
j = m
while i <= n and sum_A[i] <= k:
    while sum_A[i] + sum_B[j] > k:
        j -= 1
    ans = max(ans, i + j)
    i += 1
print(ans)

Measured memory_bytes: 47340
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll a,b,c;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b >> c;
    cout << c-min( c , a-b );

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2100000000
#define M 100000

struct pair{
  char al;
  int num;
};

struct pair a[M],b[M];

void merge(int left, int mid, int right){
  int i, j, k, n1=mid-left, n2=right-mid;
  struct pair L[n1+1], R[n2+1];
  
  for(i=0;i<n1;i++) L[i]=a[left+i];
  for(i=0;i<n2;i++) R[i]=a[mid+i];
  L[n1].num=R[n2].num=N;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num){
	a[k]=L[i++];
    }
    else{
      a[k]=R[j++];
    }
  }
}

void sort(int left, int right){
  if(left+1<right){
    int mid=(left+right)/2;
    sort(left,mid);
    sort(mid,right);
    merge(left,mid,right);
  }
}

int partition(int p,int r){
  struct pair x=b[r],n;
  int j,i=p-1;

  for(j=p;j<r;j++){
    if(b[j].num<=x.num){
      i++;
      n=b[i]; b[i]=b[j]; b[j]=n;
    }
  }
  n=b[i+1]; b[i+1]=b[r]; b[r]=n;

  return i+1;
}

void quicksort(int p, int r){
  int  q;
  if(p<r){
    q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }  
}

int main(){
  int n,i,f=1;
  char c[5];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",c,&b[i].num);
    b[i].al=a[i].al=c[0];
    a[i].num=b[i].num;
  }
        
  sort(0,n);
  quicksort(0,n-1);

    for(i=0;i<n;i++){
      if(a[i].al != b[i].al) f=0;
    }

  if(f==1) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++) printf("%c %d\n",b[i].al,b[i].num);
  
    return 0;
}



Measured memory_bytes: 4080
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let mut a:i32 = read();
    let mut b:i32 = read();
    b += a * 3;
    println!("{}", b / 2);
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int p, q, r;
    cin >> p >> q >> r;

    cout << min(p + q, min(q + r, p + r)) << '\n';
    return 0;
}

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

int main(){

  int64_t n, y;
  cin >> n >> y;
  
  y= y/1000;
  
  bool flaga=0;
  for(int i=0; i<=n; i++){
  	for(int j=0; j<=(n-i); j++){
        	if((9*i + 4*j + n) == y ){
            	cout << i << " " << j << " " << n-i-j << endl;
                flaga =1;
              	break;
            }
    }
    if(flaga) break;
  }
 if(flaga==0){
 	cout << -1 << " " << -1 << " " << -1 << endl;
 }
}

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


using namespace std;
using ll = long long;


int main() {
    char ch;
    cin >> ch;
    if(ch >= 'A' && ch <= 'Z') {
      cout << 'A' << "\n";
    } else {
      cout << 'a' << "\n";
    }



  return 0;
}



Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int[] alph = new int[26];
		char[] target = S.toCharArray();
		for (int i = 0; i < target.length; i++) {
			alph[target[i] - 'a']++;
		}
		for (int i = 0; i < target.length; i++) {
			if (alph[i] > 1) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
		sc.close();
	}
}


Measured memory_bytes: 23252
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int w = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int ans = 0;
		if(a < b){
			if(b > a + w){
				ans = b - (a + w);
			}
		}else{
			if(a > b + w){
				ans = a - (b + w);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main() {
  string X; cin >> X;
  int N, S, W, E;
  N = S = W = E = 0;
  rep(i, 0, X.size()){
    if(X[i] == 'N') N++;
    if(X[i] == 'S') S++;
    if(X[i] == 'E') E++;
    if(X[i] == 'W') W++;
  }
  string res;
  if(N && S && E && W || N && S && !E && !W || !N && !S && E && W) res = "Yes";
  else res = "No";
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

#define MAX 1000000

using namespace std;

int n, num[MAX];
bool isp[MAX];

void sieve() {
	for(int i = 2; i < MAX; i++)
		isp[i] = true;
	for(int i = 2; i * i < MAX; i++)
		if(isp[i])
			for(int j = i * i; j < MAX; j += i)
				isp[j] = false;

	num[0] = num[1] = 0;
	for(int i = 2; i < MAX; i++)
		num[i] = num[i-1] + isp[i];
}

int main() {
	sieve();
	while(cin >> n)
		cout << num[n] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


using namespace std;


int main() {
	double L;

	//double len = pow(x, 1/3);
	cin >> L;
	cout << fixed << setprecision(10) << (L / 3.0) * (L / 3.0) * (L / 3.0) << endl;


	return 0;

}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n; cin>>n;
        
        int sum = 0;
        int arr[n];
        int brr[n];
        for (int i = 0; i < n; i++)
		{
			cin>>arr[i];
		}
		for (int i = 0; i < n; i++)
		{
			cin>>brr[i];
		}
		for (int i = 0; i < n; i++)
		{
			sum +=max(0LL,arr[i] - brr[i]);
		}
		cout<<sum;
		
			

		
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    G = [[] for _ in range(N)]
    for i, a in enumerate(A):
        G[a-1].append(i+1)
    for g in G:
        print(len(g))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

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

// Matrix Multiplication

int main(){
	int n, m, l;
	long a[100][100];
	long b[100][100];
	long c[100][100];

	cin >> n >> m >> l;

	for(int i = 0;i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0;i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			c[i][j] = 0;
			for(int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			cout << c[i][j];
			if(j != l - 1){
				cout << ' ';
			}
		}
		cout << endl;
	}
	


	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    unordered_map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto &p : mp)
    {
        int s = p.second;
        // cout << s << endl;
        ans += (ll)s * (s - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
#include<iostream>
#include<vector>
using namespace std;
int main(){

	int n, ma, mi;
	cin >> n;

	vector<int> a(n);

	for (int i = 0; i < n; i++){
		cin >> a.at(i);
	}

	for (int i = 0; i < n; i++){

		if (i == 0){
			ma = a.at(i);
			mi = a.at(i);
		}

		else if (ma < a.at(i)){
			ma = a.at(i);
		}

		else if (mi > a.at(i)){
			mi = a.at(i);
		}
	}

	cout << ma - mi << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

int main(){
  int n,m;
  vector<int> vec;

  scanf("%d%d", &n, &m);

  while(1){
    vec.clear();

    for(int i=n;i<=m;i++){
      if(!(i%400)) vec.push_back(i);
      else if((i%100) && !(i%4)) vec.push_back(i);
    }

    vector<int>::iterator it;
    for(it=vec.begin();it!=vec.end();it++){
      printf("%d\n", *it);
    }

    if(vec.size() == 0) puts("NA");

    scanf("%d%d", &n, &m);
    if(n==0&&m==0) break;
    else puts("");
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
using namespace std;

main() {

  int i, n;
  cin >> n;
  
  int array[n];
  for(i = 0; i < n; i++){
    cin >> array[i];
  }
  
  
  for(i = n-1; i >= 0; i-- ){
    if(i == n-1){
      printf("%d",array[i]);
    }else{
    printf(" %d",array[i]);
    }
  }
  printf("\n");



}

Measured memory_bytes: 1148
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
char s[N];
int n,cur,ret;
int main() {
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,n) {
		if (s[i]=='T') {
			--cur;
			if (cur==-1) cur=0,ret++;
		} else ++cur;
	}
	printf("%d\n",ret+cur);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;


int main() {
   

    long s;
    cin >> s;
    int a,b,c;
    a = s/3600;
    s %= 3600;
    b = s/60;
    s %= 60;
    cout << a << ':' << b << ':' << s << endl;
}


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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
  ll N;
  string S;
  cin >> N;
  cin >> S;

  ll red = 0, blue = 0;
  for (auto s : S) {
    if (s == 'R') {
      red++;
    } else {
      blue++;
    }
  }

  cout << (red > blue ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
program main
 implicit none
  integer a,b,c,d
  b=0
  read*,a,b
  c=0
  if(a==1.or.a==3.or.a==5.or.a==7.or.a==8.or.a==10.or.a==12)c=c+1
  if(b==1.or.b==3.or.b==5.or.b==7.or.b==8.or.b==10.or.b==12)c=c+1
  if(c==2)print*,'Yes'
  d=0
  if(a==4.or.a==6.or.a==9.or.a==11)d=d+1

  if(b==4.or.b==6.or.b==9.or.b==11)d=d+1
  if(d==2)print*,'Yes'
  if(a==2.or.b==2) then
    print*,'No'
  else if (c==1.and.d==1)then
  print*,'No'
  end if
end program

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;

namespace ABC135
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var p = ReadInts();
            //int ans = 0;
            int cnt = 0;
            var sortedp = p.OrderBy(s => s).ToArray();
            // 昇順ソートされたものと0個or2個異なる＝題意を満たす
            for (int i = 0; i < n; i++)
            {
                if (p[i]!=sortedp[i])
                {
                    cnt++;
                    if (cnt>2)
                    {
                        break;
                    }
                }
            }
            if (cnt==0 || cnt==2)
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
            //WriteLine("{0}", ans);
            Read();
        }
        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    }
}


Measured memory_bytes: 13396