akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
	int t,n,s,f,a,b=0,c;
	while(1){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for (a=1;a<=n;a++){
			scanf("%d %d",&s,&f);
			b=b+(f-s);
		}
		if (t<=b){
			printf("OK\n");
		}
		else{
			c=t-b;
			printf("%d\n",c);
		}
		b=0;
	}
	return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    if(mp.size() <= k);
    else{
        vector<int> A(mp.size());
        int i = 0;
        for(auto x : mp){
            A[i] = x.second;
            i++;
        }
        sort(A.begin(), A.end());
        for(int i = 0; i < mp.size() - k; i++){
            ans += A[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10368
n=int(input())
lis=[]
for i in range(0,n):
  p,q=map(str,input().split())
  lis.append([p,int(q),i+1])
for j in range(0,n):
  for k in range(0,n-1):
    if lis[n-k-1][0]<lis[n-k-2][0]:
      t=lis[n-k-2]
      lis[n-k-2]=lis[n-k-1]
      lis[n-k-1]=t
    elif lis[n-k-1][0]==lis[n-k-2][0]:
      if lis[n-k-1][1]>=lis[n-k-2][1]:
        t=lis[n-k-2]
        lis[n-k-2]=lis[n-k-1]
        lis[n-k-1]=t
      
for i in range(n):
  print(lis[i][2])
  

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		String s=String.valueOf(n);
		int cnt=0;
		for(int i=0;i<s.length();i++) {
			char c=s.charAt(i);
			if(c=='2') {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main() {
  string S;
  cin >> S;
  

  int ans = 1e9;
  rep(i, S.size()-2) {
    int k = 0;
    k += (int)(S[i] - '0')*100;
    k += (int)(S[i+1] - '0')*10;
    k += (int)(S[i+2] - '0');
    ans = min(ans, abs(k-753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

/*
struct Edge{
    int u,v,weight;
    bool operator<(Edge const& other) {
        return weight<other.weight;
    }
};

vector<int> parent,rank;

void make_set(int v) {
    parent[v]=v;
    rank[v]=0;
}

int find_set(int v) {
    if(v==parent[v])
        return v;
    return parent[v]=find_set(parent[v]);
}

void union_sets(int a,int b) {
    a=find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rank[a]<rank[b])
            swap(a,b);
        parent[b]=a;
        if(rank[a]==rank[b])
            rank[a]++;
    }
}*/

/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/

int solve(){
   	string s;
	cin>>s;
	if(s=="SUN")cout<<"7"<<endl;
	else if(s=="MON")cout<<"6"<<endl;
	else if(s=="TUE")cout<<"5"<<endl;
	else if(s=="WED")cout<<"4"<<endl;
	else if(s=="THU")cout<<"3"<<endl;
	else if(s=="FRI")cout<<"2"<<endl;
	else cout<<"1"<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll C[200005][30];

int main()
{
    string S;
    cin >> S;
    memset(C, 0, sizeof(C));
    for (int i = S.length() - 1; i >= 0; --i)
    {
        ll m = INF;
        REP(j, 26)
        {
            C[i][j] = C[i + 1][j];
            m = std::min(m, C[i][j]);
        }
        C[i][S[i] - 'a'] = m + 1;
    }

    string ans = "";
    ll mi = 0;
    REP(i, S.length())
    {
        if (i != 0 && mi + 'a' != S[i - 1])
            continue;
        mi = 0;
        REP(j, 26)
        {
            if (C[i][mi] > C[i][j])
                mi = j;
        }
        ans.push_back((char)(mi + 'a'));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47492
#include<iostream>
#include <math.h>

using namespace std;
int main()
{
	int a, b, flag = 0;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		flag = 1;
	}
	if (flag == 0) {
		cout << "Yay!" << endl;
	}
	if (flag == 1) {
		cout << ":(" << endl;
	}
    return 0;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }


/**
 *  @brief SとS[i:|S|-1](i=0,1,...,|S|-1)の
 *         最長共通接頭辞(LCP: Longest Common Prefix)を導出する
 *  @note  Z-Algorithm 計算量O(|S|)
 */
class LCPCalculator {
public:
    /**
     *  @param (S)    対象の文字列
     *  @param (dupl) falseの場合、max_lcp_length_を
     *                S[0:i-1]とS[i:|S|-1](i=1,...,|S|-1)の最長共通接頭辞の最大値とする
     */
    explicit LCPCalculator(const string& S,
                           const bool&   dupl = true) :
        dupl_(dupl), S_(S) { createTable(); }
    ~LCPCalculator() { }

    const string& getString() const { return S_; }
    const std::vector<int>& getTable() const { return table_; }
    const int& getMaxLCPLength() const { return max_lcp_length_; }

    void rerun(const string& S) { S_ = S; createTable(); }

private:
    const bool       dupl_;
    std::string      S_;
    std::vector<int> table_;           // table_[i] : SとS[i:|S|-1]の最長共通接頭辞の長さ
    int              max_lcp_length_;  // 求まる最長共通接頭辞の最大値

    void createTable() {
        table_    = std::vector<int>(S_.size(), 0);
        table_[0] = S_.size();
        max_lcp_length_  = 0;
        size_t i = 1, j = 0, k = 0;
        while(i < S_.size()) {
            while(i + j < S_.size() && S_[j] == S_[i + j]) j++;
            table_[i]       = j;
            max_lcp_length_ = max(max_lcp_length_, (int)(dupl_ ? j : min(j, i)));
            if(j == 0) { i++; continue; }
            k = 1;
            while(i + k < S_.size() && k + table_[k] < j) {
                table_[i + k] = table_[k];
                k++;
            }
            i += k; j -= k;
        }
    }
};

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

    int N;
    std::cin >> N;
    string S;
    std::cin >> S;

    int ans = 0;
    REP(i, N - 1) {
        LCPCalculator lcp(S.substr(i), false);
        chmax(ans, lcp.getMaxLCPLength());
    }

    std::cout << ans << std::endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  map<char, string> mp;
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  reverse(ALL(sa));
  reverse(ALL(sb));
  reverse(ALL(sc));
  mp['a'] = sa;
  mp['b'] = sb;
  mp['c'] = sc;
  char now = 'a';
  while(true) {
    if(mp[now].size() == 0) {
      cout << (char)toupper(now) << endl;
      return 0;
    }
    char next = mp[now].back(); mp[now].pop_back();
    now = next;
  }
}

Measured memory_bytes: 256
n,k=map(int, input().split())
a = list(map(int, input().split()))
k = min(k,50)
for i in range(k):
    aa = [0]*n
    for j in range(n):
        aa[max(0,j-a[j])] += 1
        if j+a[j]+1 < n: aa[j+a[j]+1] -= 1
    for j in range(n-1):aa[j+1] = aa[j]+aa[j+1]
    a = aa[:]

print(*a)

Measured memory_bytes: 220616
import numpy as np
#S = list(input().strip())
#length = len(S)
#op = np.asarray(S)

def solution():
    S = input()
    N = len(S)
    num = [0] * 2019
    num[0] = 1
    c, ans, dgt = 0, 0, 1
    for i in reversed(range(N)):
        c = (c + int(S[i]) * dgt) % 2019
        dgt *= 10
        dgt %= 2019
        ans += num[c]
        num[c] += 1
        
    print(ans)

solution()



def sample():
    x = -1
    count = 0
    for i in op:
        x += 1
        group = ""
        for j, name in enumerate(op, x):
            group += name
            if int(group) % 2019 == 0:
                count += 1
    print(count)

def checkValue():
    count = 0
    for i in range(length):
        group = ""
        for j in range(i, length):
            group += op[j]
            if int(group) % 2019 == 0:
                count += 1
    print(count)
#checkValue()
    


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

int main(){
  int n;  cin >> n;
  string ans = "Yes";
  int nowh = 0, noww = 0, nowt = 0;
  while(n--){
    int t, w, h;  cin >> t >> w >> h;
    int s = t - nowt - abs(w-noww) - abs(h-nowh);  // absを忘れることがあった
    if(s >= 0 && s%2 == 0)
      noww = w, nowh = h, nowt = t;
    else
      ans = "No";
  }

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


Measured memory_bytes: 3492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N; cin>>N;
    int P=N*800;
    int R=(N/15)*200;
    cout<<P-R<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
long a,b,c,k;
inline void solve(void){
  in(a,b,c,k);
  if(a>=k)out(k);
  else if(a+b>=k)out(a);
  else out(a-(k-a-b));
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a = {0,1,2,4,8,16,32,64};
    for(int i = 7; i > 0; i--){
        if(N >= a[i]){
            cout << a[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2;
    cin>>s1>>s2;
    rep(i,s1.size()) {
        if (s1[i] != s2[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n,d,a;
    cin>>n>>d>>a;
    priority_queue<P,vector<P>,greater<P> > p;
    LL life[n];
    LL attack[n];
    LL sum=0;
    LL ans=0;
    for(int i=0;i<n;i++){
        LL x,h;
        cin>>x>>h;
        life[i]=h;
        p.push(P(x,i));
        p.push(P(x+2*d,n+i));
    }
    while(!p.empty()){
        P q=p.top();
        p.pop();
        //cout<<q.first<<' '<<q.second<<' '<<'k'<<endl;
        LL x=q.second;
        if(x<n){
            if(life[x]>sum){
                if(life[x]%a==0){attack[x]=life[x]-sum;}
                else{attack[x]=a*((life[x]-sum)/a+1);}
                sum=sum+attack[x];
                ans=ans+attack[x]/a;
                //cout<<ans<<' '<<q.first<<' '<<q.second<<endl;
            }
            else{attack[x]=0;}
        }
        else{
            x=x-n;
            sum=sum-attack[x];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};



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

  int K, S;
  cin >> K >> S;

  int cnt = 0;
  REP(X, K+1)REP(Y, K+1) if(S-X-Y>=0 && S-X-Y <= K) cnt++;

  cout << cnt << endl;

  return 0;
}


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

public class Main{
    public static void main(String[] args ){
        //Scanner scan = new Scanner(System.in);
        //BufferedReader reader = new Bufferedreader(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        char[] words;
        int i=0;
        try{
            //while((word[i] = scan.nextChar))
            String line = reader.readLine();
            words = line.toCharArray();
            //String newline = line.toLowerCase();
            for(i=0; i<words.length; i++){
                if(Character.isUpperCase(words[i])){
                    words[i] = Character.toLowerCase(words[i]);
                }else{
                    words[i] = Character.toUpperCase(words[i]);
                }
            }
            StringBuffer newline = new StringBuffer(new String(words));
            System.out.println(newline);

        }catch(IOException e){
            System.out.println(e);
        }

    }
}


Measured memory_bytes: 24444
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, M; cin >> N >> M;
  vector<int> A(N+1,0);
  int a, b;
  rep(i,M) {
    cin >> a >> b;
    if (a==1) A[b]++;
    else if (b==N) A[a]++;
  }

  int idx = find(all(A), 2) - A.begin();
  if (idx==N+1) cout << "IMPOSSIBLE" << endl;
  else cout << "POSSIBLE" << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3988
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

def choose2(n):
    return n * (n - 1) // 2

counts = Counter(A)
total = 0
for n, count in counts.items(): 
    #初めに、同じ数同士から2つ選んだ時の組み合わせの総和を求める
    combi = choose2(count)
    total += combi 

for i in A:
    #上で求めた組み合わせの総和から、消える数字について1つ減らしたときの組み合わせを減らす
    temp = total - choose2(counts[i])
    temp += choose2(counts[i] - 1) 
    print(temp)

Measured memory_bytes: 26780
#include <iostream>

using namespace std;

int n, x1, y1, z1, w1, x2, y2, z2, w2;

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
      cout << x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2 << ' ';
      cout << x1 * y2 + x2 * y1 + z1 * w2 - z2 * w1 << ' ';
      cout << x1 * z2 - y1 * w2 + x2 * z1 + y2 * w1 << ' ';
      cout << x1 * w2 + y1 * z2 - y2 * z1 + x2 * w1 << endl;
     }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//b問題
//上面v[0]と前面v[1]が与えられるので、右側v[2]を答える


// 5		v[4]
//413	v[3]v[0]v[2]
// 2		v[1]
// 6		v[5]

//N
//	  v[4]				v[0]
//v[3]v[0]v[2]	→	v[3]v[1]v[2]
//	  v[1]				v[5]
//	  v[5]				v[4]

//S
//	  v[4]				v[5]
//v[3]v[0]v[2]	→	v[3]v[4]v[2]
//	  v[1]				v[0]
//	  v[5]				v[1]

//E
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[5]v[3]v[0]
//	  v[1]				v[1]
//	  v[5]				v[2]

//W
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[0]v[2]v[5]
//	  v[1]				v[1]
//	  v[5]				v[3]


class dice
{
public:
	explicit dice(int _dice[6])
	{
		for(int i = 0; i < 6; ++ i)
		{
			v[i] = _dice[i];
		}
	}

	void mov(char c)
	{
		int buf;
		//北方向
		if(c == 'N')
		{
			buf = v[0];
			v[0] = v[1];
			v[1] = v[5];
			v[5] = v[4];
			v[4] = buf;
		}
		else if(c == 'S')
		{
			buf = v[0];
			v[0] = v[4];
			v[4] = v[5];
			v[5] = v[1];
			v[1] = buf;		
		}
		else if(c == 'E')
		{
			buf = v[0];
			v[0] = v[3];
			v[3] = v[5];
			v[5] = v[2];
			v[2] = buf;	
		}
		else if(c == 'W')
		{
			buf = v[0];
			v[0] = v[2];
			v[2] = v[5];
			v[5] = v[3];
			v[3] = buf;				
		}
	}
// 5		v[4]
//413	v[3]v[0]v[2]
// 2		v[1]
// 6		v[5]

	int migi[5] = {1,2,4,3,1};
	//上面v[0]固定で前面v[?]が与えられるので、右側v[?]を答える
	int find_right(int front)
	{
		int res = -1;

		REP(i,4)
		{
			if(front == v[migi[i]])
			{
				res = v[migi[i+1]];
			}
		}
		return res;
	}

	//指定の値を上面
	void tadasu(int up)
	{
		//初期位置
		if(v[0] == up) return;

		string kororin = "WWNWW";
		REP(i,kororin.size())
		{
			mov(kororin[i]);
			if(v[0] == up) break;
		}
		return;
	}
int operator[](size_t i){return v[i];}
private:
	int v[6];
};

int main(){
//    std::ifstream in("resource/input.txt");
//    std::cin.rdbuf(in.rdbuf());

	//6面
	int _dice[6];
	REP(i,6)
	{
		cin >> _dice[i];
	}
	//サイコロの作成
	dice d(_dice);

	int n;
	cin >> n;

	pair<int,int> men[n];
	int val[n];

	REP(i,n)
	{
		//初期化
		val[i] = -1;
		int tmp1,tmp2;
		cin >> tmp1 >> tmp2;

		men[i] = {tmp1, tmp2};
	}



	//6面すべてを上面に変更できるようにする

	//上面v[0]と前面v[1]が与えられるので、右側v[2]を答える
	//初期位置


	REP(i,n)
	{
		d.tadasu(men[i].first);
		val[i] = d.find_right(men[i].second);
	}
	REP(i,n)
	{
		cout << val[i] << endl;
	}
	
    //cout << fixed << setprecision(5) << dm << endl;
	//std::printf("%.5f¥n", res);
	
	return 0;
}




Measured memory_bytes: 3168
'use strict';
const main = input => {
  let a = input[0], b = input[1];
  if (a!='1' && b!='1') console.log('1');
  if (a!='2' && b!='2') console.log('2');
  if (a!='3' && b!='3') console.log('3');
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21952
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	for (auto a : s) {
		if (a != ',') cout << a;
		else cout << " ";
	}
	cout << endl;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int[] a ={nextInt(),nextInt(),nextInt(),nextInt(),nextInt(),nextInt()};

		System.out.println(a[4]-a[0]>a[5]?":(":"Yay!");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
'use strict';

function Main(input) {
  const N = Number(input.split("\n")[0].split(" ")[0]);
  const A = Number(input.split("\n")[0].split(" ")[1]);
  const B = Number(input.split("\n")[0].split(" ")[2]);

  const max = Math.min(A, B);

  let min = 0;
  if ((A + B) >= N) {
    min = (N - A - B) * -1;
  }

  console.log(max + " " + min);

};

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


Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
    ull i,n,x,y,sum=0;
    cin>>n;
    x=n;
    while(n)
    {
        y=n%10;
        sum+=y;
        n=n/10;
    }
    if(x%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

int main()
{
  bool is_prime[1000000];fill(is_prime,is_prime+1000000,true);
  int count_prime[1000000];fill(count_prime,count_prime+1000000,0);
  is_prime[0]=false,is_prime[1]=false;
  for(int i=2;i<1000000;i++)
  {
    count_prime[i]=count_prime[i-1]+is_prime[i];
    if(!is_prime[i])continue;
    for(int j=i*2;j<1000000;j+=i)is_prime[j]=false;
  }
  int n;
  while(cin>>n)printf("%d\n",count_prime[n]);
}


Measured memory_bytes: 8008
#include <stdio.h>
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
int main(void){
	int a,b;
	double ans;
	scanf("%d %d",&a,&b);
	if(a>b){
		swap(&a,&b);
	}
	if(b-a>180){
		b-=360;
	}
	ans=(a+b)*1.0/2;
	if(ans<0){
		ans+=360;
	}
	printf("%.1f\n",ans);
	return 0;
}

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

using namespace std;

int main(){
    char s[5];
    scanf("%s",s);
    
    int a = s[0] - '0'; int b = s[1] - '0'; int c = s[2] - '0'; int d = s[3] - '0';
    
    int ans1 = a + b + c + d;
    int ans2 = a + b + c - d;
    int ans3 = a + b - c + d;
    int ans4 = a + b - c - d;
    int ans5 = a - b + c + d;
    int ans6 = a - b + c - d;
    int ans7 = a - b - c + d;
    int ans8 = a - b - c - d;
    
    if(ans1 == 7)
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    
    else if(ans2 == 7)
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    
    else if(ans3 == 7)
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    
    else if(ans4 == 7)
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    
    else if(ans5 == 7)
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    
    else if(ans6 == 7)
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    
    else if(ans7 == 7)
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    
    else if(ans8 == 7)
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
    
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

#define idp
#define F first
#define S second
#define p2(a, b) idp cout << a << "\t" << b << endl
#define p3(a, b, c) idp cout << a << "\t" << b << "\t" << c << endl
#define p4(a, b, c, d) idp cout << a << "\t" << b << "\t" << c << "\t" << d << endl
#define p5(a, b, c, d, e) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << endl
#define p6(a, b, c, d, e, f) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << endl
#define p7(a, b, c, d, e, f, g) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << endl
#define p8(a, b, c, d, e, f, g, h) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << endl
#define p9(a, b, c, d, e, f, g, h, i) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << "\t" << i << endl
#define p10(a, b, c, d, e, f, g, h, i, j) idp cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e << "\t" << f << "\t" << g << "\t" << h << "\t" << i << "\t" << j << endl


li n, c, k;

const li INF = 1ll << 50;

li t[100100];
int main(void)
{
	cin >> n >> c >> k;
	rep(i, n) {
		cin >> t[i];
	}
	sort(t, t + n);

	li res = 0;
	li border = INF;
	li num_user = 0;
	rep(i, n) {
		//p5(i, res, t[i], border, num_user);
		if (border == INF) {
			res++;
			border = t[i] + k;
			num_user = 1;
		} else if (border < t[i]) {
			res++;
			border = t[i] + k;
			num_user = 1;
		} else {
			num_user++;
		}
		if (num_user == c) {
			num_user = 0;
			border = INF;
		}
		//p5("/", res, t[i], border, num_user);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    char c;
    scanf("%c", &c);

    int aiueo = c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
    puts(aiueo == 1 ? "vowel" : "consonant");

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long mod=1e9+7;
long N;
long c[2<<17];
long F[2<<17],I[2<<17];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(long a,long b){return F[a]*I[b]%mod*I[a-b]%mod;}
main()
{
	cin>>N;
	F[0]=1;
	for(long i=1;i<=N;i++)F[i]=F[i-1]*i%mod;
	I[N]=power(F[N],mod-2);
	for(long i=N-1;i>=0;i--)I[i]=I[i+1]*(i+1)%mod;
	for(int i=0;i<N;i++)
	{
		cin>>c[i];
	}
	sort(c,c+N);
	long N2=power(2,N);
	long ans=0;
	for(int i=0;i<N;i++)
	{
		long now=(N-i-1)*power(2,N-i-2)+power(2,N-i-1);
		now%=mod;
		ans+=N2*c[i]%mod*now%mod;
		N2=N2*2%mod;
	}
	cout<<ans%mod<<endl;
}

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

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

  int arr[n][m], vec[m];

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

  int x = 0;
  for (int i = 0; i < n; i++) {
    x = 0;
    for (int j = 0; j < m; j++) {
      x += arr[i][j] * vec[j];
    }
    cout << x << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3056
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
import re
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=[int(x) for x in input().split()]
uf=UnionFind(n)
for _ in range(m):
    a,b=[int(x)-1 for x in input().split()]
    uf.union(a,b)
ans=0
for i in range(n):
    ans=max(ans,uf.size(i))
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct query { ll n; ll x; ll m; };

int main() {
  int k, q; cin >> k >> q;
  ll d[k]; rep(i,k) cin >> d[i];
  query qu[q]; rep(i,q) { ll n, x, m; cin >> n >> x >> m; qu[i] = {n,x,m}; }
  rep(i,q) {
    ll result = qu[i].n-1;
    ll nd[k] = {}; rep(j,k) nd[j] = d[j]%qu[i].m;
    // debug(nd,nd+k);
    rep(j,k) if (nd[j]==0) result -= ((qu[i].n-1)+(k-1-j))/k;
    ll sum = qu[i].x;
    rep(j,k) sum += nd[j] * (((qu[i].n-1)+(k-1-j))/k);
    // cout << sum << endl;
    result -= sum/qu[i].m - qu[i].x/qu[i].m;
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 512
import sys
import random
import time
import numpy as np
import bisect

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    m = 26
    start = time.time()
    dT = 0.993
    T = 180
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    H = [None]*D
    for i in range(D):
        g = [s[i][j] + 25 * c[j] for j in range(m)]
        y = min(g)
        h = sum(g) - m * y
        g = [(x-y)/h for x in g]
        for j in range(1, m):
            g[j] += g[j-1]
        H[i] = g

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.85:
        for _ in range(200):
            d = random.randint(0, D-1)
            q = bisect.bisect(H[d], random.random())
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = nsc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])
    return

solve()


Measured memory_bytes: 27852
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double calcPoly(const vector<double> &poly, double x) {
  double ret = 0.0;
  double base = 1;
  REP(i, poly.size()) {
    ret += poly[i] * base;
    base *= x;
  }
  return ret;
}

// find max point [left, right]
double ts(const vector<double> &poly, double left, double right) {
  REP(iter, 300) {
    double lmid = (left * 2.0 + right) / 3.0;
    double rmid = (left + right * 2.0) / 3.0;
    double lans = calcPoly(poly, lmid);
    double rans = calcPoly(poly, rmid);
    assert(!isnan(lans) && !isnan(rans));
    if (lans < rans) {
      left = lmid;
    } else {
      right = rmid;
    }
  }
  return left;
}

// find 0 point [left, right]
// poly must monotonic increase in [left, right]
double bs(const vector<double> &poly, double left, double right) {
  REP(iter, 200) {
    double mid = (left + right) / 2.0;
    double ans = calcPoly(poly, mid);
    if (ans < 0) {
      left = mid;
    } else {
      right = mid;
    }
  }
  return left;
}

vector<double> differential(const vector<double> &poly) {
  vector<double> ret(poly.size() - 1, 0);
  FOR(i, 1, poly.size()) {
    ret[i - 1] = poly[i] * i;
  }
  return ret;
}

vector<double> minusPoly(const vector<double> &poly) {
  vector<double> ret(poly.size(), 0);
  REP(i, poly.size()) { ret[i] = -poly[i]; }
  return ret;
}

void printPoly(const vector<double> &poly) {
  for (int i = poly.size() - 1; i >= 0; i--) {
    cout << poly[i] << " ";
  }
  cout << endl;
}

char str[1000];
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    vector<double> poly(4, 0);
    scanf("%lf %lf %lf %lf", &poly[3], &poly[2], &poly[1], &poly[0]);
    assert(-100 <= poly[0] && poly[0] <= 100);
    assert(-100 <= poly[1] && poly[1] <= 100);
    assert(-100 <= poly[2] && poly[2] <= 100);
    assert(-100 <= poly[3] && poly[3] <= 100);
    assert(poly[3] != 0);
    if (poly[3] < 0) { poly = minusPoly(poly); }
    vector<double> dif = minusPoly(differential(poly));
    double center = ts(dif, -1000, 1000);
    double leftLocalMax = ts(poly, -1000, center);
    double rightLocalMin = ts(minusPoly(poly), center, 1000);
    double ans[3];
    ans[0] = bs(poly, -1000, leftLocalMax);
    ans[1] = bs(minusPoly(poly), leftLocalMax, rightLocalMin);
    ans[2] = bs(poly, rightLocalMin, 1000);
    int minusans = 0;
    int plusans = 0;
    REP(i, 3) {
      if (fabs(calcPoly(poly, ans[i])) < EPS) {
        if (ans[i] < -EPS) { minusans++; }
        if (ans[i] > EPS) { plusans++; }
      }
    }
    printf("%d %d\n", plusans, minusans);
  }
  assert(scanf("%s", str) == EOF);
}

Measured memory_bytes: 960
use std::io::stdin;
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n,) = input!(usize);

    let mut h = HashMap::<u64, u32>::new();

    for i in 0..n {
        let (a,) = input!(u64);

        let val = h.entry(a).or_insert(0);
        *val += 1;
    }

    let ans = h.values()
        .fold(0, |sum, i| if i % 2 == 1 { sum + 1 } else { sum });

    println!("{}", ans);
}

fn main() {
    solve();
}


Measured memory_bytes: 12540
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    // read input
    ll N, K;
    cin >> N >> K;
    vector<ll> value(N+1, 0);
    rep(i, 0, N)
    {
        // read
        cin >> value[i+1];

        // minus one
        --value[i+1];

        // cumulative sum
        value[i+1] += value[i];

        // take modulo
        value[i+1] %= K;
    }

    unordered_map<int, int> cnts;
    ll res = 0;
    int left = 0;
    int right = 1;
    while (left<N+1)
    {
        // push to cnts
        while (right<N+1 and right-left<K)
            ++cnts[value[right++]];

        // count
        // cout << left << ':' << value[left] << ' ' << cnts[value[left]] << endl;
        res += cnts[value[left]];

        // pop que
        // cout << left << ' ' << right << ' ' << res << endl;
        ++left;
        --cnts[value[left]];
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10056
#include <iostream>

using namespace std;

typedef struct Goods_ {
    u_int value;
    u_int weight;
} Goods;

int main(void)
{
    u_int n, total;
    cin >> n >> total;
    Goods goods[n];
    for (u_int i = 0; i < n; i++) {
        u_int v, w;
        cin >> v >> w;
        goods[i] = Goods{v, w};
    }

    u_int values[total+1];
    for (u_int i = 0; i <= total; i++)
        values[i] = 0;
    
    for (u_int i = 0; i < n; i++) {
        Goods g = goods[i];
        for (u_int w = total; w >= g.weight; w--) {
            auto temp = g.value + values[w - g.weight];
            if (!values[w] || values[w] < temp)
                values[w] = temp;
        }
    }

    cout << values[total] << endl;
    
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
}


Measured memory_bytes: 256