akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main() {
    int q, a, b, c, d;
    scanf("%d", &q);
    for(int i = 1; i <= q; i++) {
        int ans = 0;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        for(int i = a; i <= c; i++)
            for(int j = b; j <= d; j++)
                if(i % 2 == 1 && j % 2 == 0)
                    continue;
                else
                    ans++;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-8;
typedef complex<double> P;

int next_flag(P &now, P &d, vector<P> &ps, vector<bool> &used){
  int res = 0;
  double a = 400.0;
  REP(i, ps.size()){
    if(used[i]) continue;
    int ty = ps[i].imag() - now.imag();
    int tx = ps[i].real() - now.real();
    int ny = now.imag() - d.imag();
    int nx = now.real() - d.real();
    double tmpa = atan2(tx * ny - nx * ty, tx * nx + ty * ny) / M_PI;
    if(tmpa < a || (abs(tmpa - a) < EPS && abs(now - ps[i]) < abs(now - ps[res]))){
      res = i;
      a = tmpa;
    }
  }
  return res;
}

int main() {
  int N;
  while(cin >>N && N){
    vector<P> ps(N);
    REP(i, N){
      int x, y; cin >>x >>y;
      ps[i] = P(x, y);
    }
    vector<bool> used(N, 0);
    P now = P(0, 0), d = P(1, 0);
    double res = 0.0;
    REP(n, N){
      int next = next_flag(now, d, ps, used);
      used[next] = 1;
      res += abs(now - ps[next]);
      d = now;
      now = ps[next];
    }
    printf("%.1lf\n", res);
  }
  return 0;
}

Measured memory_bytes: 1320
#include <iostream>
using namespace std;
int main(void){
 
int m,d,sum = 0;
cin >> m >> d;

for (int i = 1; i <= m; i++){
    for (int j = 2; j <= d / 10; j++){
        for (int k = 2; k <= 9; k++){
             if(j * 10 + k > d){
              continue;
            }
            if (i == j * k){
                sum++;
            }
        }
    }
}

cout << sum << endl;
 
 return 0; 
}


Measured memory_bytes: 256
S=input()
pr=10**9+7
a1,a2,a3=0,0,0
c=0
for i in S:
    if i=="A":
        a1=(a1+pow(3,c,pr))%pr
    elif i=="B":
        a2=(a2+a1)%pr
    elif i=="C":
        a3=(a3+a2)%pr
    else:
        a1,a2,a3=(3*a1+pow(3,c,pr))%pr,(3*a2+a1)%pr,(3*a3+a2)%pr
        c+=1
print(a3)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N, Q;
	while(cin >> N >> Q && N+Q){
		map<int32, int32> cnt;
		REP(i, N){
			int32 M;
			cin >> M;
			REP(j, M){
				int32 x;
				cin >> x;
				cnt[x]++;
			}
		}
		int32 res = 0;
		for(auto x : cnt){
			if(x.sc >= Q && cnt[res] < x.sc){
				res = x.fs;
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int get(int a, int b)
{
	if (a > b)return 2100000000;
	else return b - a;
}
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", min(min(get(a, b), get(-a, b) + 1), min(get(a, -b) + 1, get(-a, -b) + 2)));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
    int i,j;
    int n;
    while(1){
        cin>>n;
        if(n==0) break;
        stack<P> st;
        int w=0;
        for(i=1;i<=n;i++){
            int x;
            cin>>x;
            if(i%2==1){
                if(i==1) st.push(P(x,1));
                else{
                    P u=st.top();
                    if(u.fi==x) st.top().se++;
                    else st.push(P(x,1));
                }
            }
            else {
                P u=st.top();
                if(u.fi==x) st.top().se++;
                else {
                    st.pop();
                    int r=1+u.se;
                    if(st.size()) {
                        r+=st.top().se;
                        st.pop();
                    }
                    st.push(P(x,r));
                }
            }
        }
        ll sum=0;
        while(st.size()){
            sum+=(1-st.top().fi)*st.top().se;
            st.pop();
        }
        cout<<sum<<endl;
    }
}


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

ll dp[440][440];
ll sum[440][440];
ll a[440];

int main() {
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(l,n){
        sum[l][l+1] = a[l];
        for (int r = l+2; r <= n; r++){
            sum[l][r] = sum[l][r-1] + a[r-1];
        }
    }
    for(int width = 2;width <= n; width++){
        for(int l = 0;l+width <= n; l++){
            int r = l + width;
            dp[l][r] = LINF;
            for(int m = l+1;m < r;m++){
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + sum[l][r]);
            }
        }
    }
    cout << dp[0][n] << endl;
    
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define MAX 2e6 + 1
typedef long long ll;
bool check(string s, int k){
    
}
int main() {
	int s,w;
	cin>>s>>w;
	if(w>=s)
	    cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
	
	
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

import sys
import os



"""
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
"""

def include3(v):
    s = str(v)
    if '3' in s:
        return True
    else:
        return False

def call(n):
    for i in range(1, n + 1):
        if i % 3 == 0:
            print(" ", end='')
            print(i, end='')
        else:
            if include3(i):
                print(" ", end='')
                print(i, end='')

n = int(input())
call(n)
print()

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

typedef long long ll;

const ll N = 3010;
const ll moder = 1e9 + 7;

ll dp[N][N][2];

void add(ll &a, ll b){
    a += b;
    a -= a >= moder ? moder : 0;
    a += a < 0 ? moder : 0;
}

void addmult(ll &a, ll b, ll c){
    a = (a + 1ll * b * c) % moder;
    a += a < 0 ? moder : 0;
}

int main(){
    ll n, m;
    scanf("%lld%lld", &n, &m);
    dp[0][0][1] = 1;
    for (int i = 1; i <= n; ++ i){
       dp[0][i][0] = 1;
    }
    for (ll i = 0; i < m; ++ i){
        for (ll j = 0; j <= n; ++ j){
            if (!j){
                add(dp[i + 1][j + 1][1], dp[i][j][1]);
                add(dp[i + 1][j][1], dp[i][j][1]);
                continue;
            }
            for (int k = 0; k < 2; ++ k){
                if (j == 1){
                    add(dp[i + 1][j - 1][1], dp[i][j][k]);
                    add(dp[i + 1][j][1], dp[i][j][k]);
                    if (n > 1){
                        add(dp[i + 1][j][k], dp[i][j][k]);
                        add(dp[i + 1][j + 1][k], dp[i][j][k]);
                    }
                    continue;
                }
                if (j == n){
                    add(dp[i + 1][j - 1][k], dp[i][j][k]);
                    add(dp[i + 1][j][k], dp[i][j][k]);
                    continue;
                }
                add(dp[i + 1][j - 1][k], dp[i][j][k]);
                addmult(dp[i + 1][j][k], 2, dp[i][j][k]);
                add(dp[i + 1][j + 1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    for (ll i = 0; i <= n; ++ i){
        add(ans, dp[m][i][1]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll m=1e9+7;
ll fact[2005];
void pre_calc()
{
    fact[0]=1;
    for(int i=1;i<=2004;i++)
    {
        fact[i]=(fact[i-1]*i)%m;
    }
//    for(int i=0;i<10;i++)cout<<fact[i]<<" ";cout<<endl;
}
ll power(ll a,ll b)     ///calculate a^b%m
{
    ll res=1;
    ll y=a;
    while(b>0)
    {
        if(b%2==1)
        {
            res=(res*y)%m;
        }
        y=(y*y)%m;
        b/=2;
//        cout<<"res = "<<res<<endl;
    }
    return res;
}
///(1/a)%m=a^(m-2)%m

ll mmi(ll n)
{
    return power(n,m-2);
}

ll ncr(ll n,ll r)
{
    ll res;
//    cout<<fact[n]<<"  "<<fact[n-r]<<"  "<<fact[r]<<"  "<<mmi(fact[n-r])<<"  "<<mmi(fact[r])<<endl;
    res=(((fact[n]*mmi(fact[n-r]))%m)*mmi(fact[r]))%m;
    return res;
}

int main()
{
    pre_calc();
    ll n,b;
    cin>>n>>b;
    ll r=n-b;
    for(int i=1;i<=b;i++)
    {
        ll ans;
        if(b<i)ans=0;
        else if(i>(r+1))ans=0;
        else
            ans=(ncr(r+1,i)*ncr(b-1,i-1))%m;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N;
	int a[10];
	int i;
	int b_top = 0, c_top = -1;

	int flag = 1;

	scanf("%d", &N);

	for(;N > 0; N--) {
		flag = 1;
		b_top = 0;
		c_top = -1;
		for(i = 0; i < 10; i++)
			scanf("%d", &a[i]);
		
	i = 0;
	while(i < 10) {
		if(b_top > c_top) {
			if(a[i] > b_top)
				b_top = a[i];
			else if(a[i] > c_top)
				c_top = a[i];
			else {
				flag = 0;
				break;
			}
		}

		else {
			if(a[i] > c_top)
				c_top = a[i];
			else if(a[i] > b_top)
				b_top = a[i];
			else {
				flag = 0;
				break;
			}
		}

		i++;
	}

	if(flag)
		printf("YES\n");
	else
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const DIGIT = 2 * 1e5;

ll mod_pow(ll a, ll n, ll p) {
  if (n == 0) return 1 % p;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (mod_pow(a, 1, p) * mod_pow(a, n-1, p)) % p;
  ll t = mod_pow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
  ll n;
  string x;
  cin >> n >> x;

  bitset<DIGIT> bs2(x);
  ll cnt = bs2.count();

  ll plus_mod = 0;
  ll minus_mod = 0;
  rep(i, n) {
    if (x[n-1-i] - '0') {
      plus_mod = (plus_mod + mod_pow(2, i, cnt+1)) % (cnt+1);
      if (cnt != 1) minus_mod = (minus_mod + mod_pow(2, i, cnt-1)) % (cnt-1);
    }
    // cout << i << " " << plus_mod << " " << minus_mod << endl;
  }
  // cout << plus_mod << " " << minus_mod << endl;
  // ll xx = bs2.to_ullong();
  // ll max_digit = ll(pow(2, n-1));
  // bitset<DIGIT> md2(max_digit);
  // cout << max_digit << endl;
  // cout << DIGIT << endl;

  rep(i, n) {
    ll mod;
    // cout << i << endl;
    if (x[i] == '1') {
      if (cnt == 1) {
        cout << 0 << endl;
        continue;
      }
      mod = (minus_mod - mod_pow(2, n-1-i, cnt-1)) % (cnt-1);
      if (mod < 0) mod += (cnt-1);
    } else {
      mod = (plus_mod + mod_pow(2, n-1-i, cnt+1)) % (cnt+1);
      if (mod < 0) mod += (cnt+1);
    }


    // bitset<DIGIT> tmp = (md2 >> i) ^ bs2;
    // cout << i << " " << tmp << " " << xx << " " << max_digit << endl;
    ll ans = 1;
    while(mod != 0) {
      // cout << mod << endl;
      mod %= __builtin_popcountll(mod);
      ans++;
    }
    cout << ans << endl;
  }
  // 00         1       10       1       1      100      10     1     1   0 1    100   1110
  // (4194304)  1048576 524288   131072  65536  32768    4096   1024  512 0 128  64  008420

  return 0;
}


Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        Scanner cin2 =new Scanner();
        int N2=cin.nextInt();
        Console.WriteLine(N2*2-N);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 11092
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	if(a*b%2)cout<<"Odd"<<endl;
	else cout<<"Even"<<endl;
}











Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a; cin >> n;
	double test[51] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		test[h] = a;
	}
	for (int h = 0; h < n - 1; h++) {
		for (int i = h + 1; i < n; i++) {
			if (test[h] > test[i]) {
				int uio = test[h];
				test[h] = test[i];
				test[i] = uio;
			}
		}
	}
	for (int h = 0; h < n - 1; h++) {
		test[h + 1] = (test[h] + test[h + 1]) / 2;
	}
	cout << test[n - 1] << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<iomanip>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const ll INF = 1000000007;
ll dp[3001][3001];
int flag[3001][3001];
vector<ll>a(3001);

ll f(int l,int  r) {
	if (flag[l][r])return dp[l][r];
	flag[l][r] = 1;
	if (l == r)return dp[l][r] = a[l];
	return dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1));
}
int main() {
	int n;
	cin >> n;
	rep(i, n)cin >> a[i];
	ll ans = (f(0, n - 1));
	cout << ans;
	return 0;
}

Measured memory_bytes: 77448
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;
typedef string str;
typedef vector<str> vs;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) str s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

const int MAX = (int)1e5 + 9;

int arr[MAX];

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

	ini(n); ini(m);
	forn(i, 0, m) in(arr[i]);
	if (n >= m) {
		outn(0);
		return 0;
	}
	sort(alln(arr, m));
	int md = arr[m-1] - arr[0];
	vi d;
	forn(i, 1, m) d.pb(arr[i] - arr[i-1]);
	sort(all(d));
	reverse(all(d));
	forn(i, 0, n-1) md -= d[i];
	outn(md);
		
	return 0;
}


Measured memory_bytes: 1276
a = gets.chomp!.to_i
b = gets.chomp!.to_i
c = gets.chomp!.to_i
d = gets.chomp!.to_i
e = gets.chomp!.to_i

puts [a,b,c,d,e].permutation(5).map {|arr|
    arr.each_with_index.inject(0) {|sum, (a, index)|
        if index == arr.size - 1
            sum += a
        else
            sum += a + (a % 10 == 0 ? 0 : 10 - a % 10)
        end
    }
}.min

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

const int N=100010;
int ls[N],c[N];

int calc(int n) {
    c[2]=abs(ls[1]-ls[2]);
    c[3]=min(abs(ls[1]-ls[3]), c[2]+abs(ls[2]-ls[3]));
    for (int i=4;i<=n;i++) c[i] = min(c[i-1]+abs(ls[i]-ls[i-1]), c[i-2]+abs(ls[i-2]-ls[i]));
    //for (int i=2;i<=n;i++)cout<<c[i]<<" ";
    return c[n];
}

int main() {
    cin.tie(0);ios::sync_with_stdio(0);
    int n,t;
    cin>>n;
    for (int i=1;i<=n;i++) cin>>ls[i];
    cout<<calc(n)<<"\n";
    
    
    return 0;
}

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

const int N=200001;
bool vis[N];
int count=0;

void dfs(vector<vector<int>> &g, int root){
    vis[root]=true;
    count+=1;
    for(int v:g[root]){
        if(!vis[v]){
            dfs(g,v);
        }
    }
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0; i<m;++i){
        int u,v;
        cin>>u>>v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int mx=0;
    for(int i=0;i<n; ++i){
        count=0;
        if(!vis[i]){
            dfs(g,i);
        }
        mx=max(mx,count);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 23560
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N;
    cin >> N;
    vector<int> v[N];
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    queue<int> qu;
    int st[N];
    memset(st,0,sizeof(st));
    st[0]=1;st[N-1]=-1;
    qu.push(0);
    qu.push(N-1);
    while(qu.size()){
        int s=qu.front();
        qu.pop();
        for(int i=0;i<v[s].size();i++){
            if(st[v[s][i]]==0){
                if(st[s]==1){
                    qu.push(v[s][i]);
                    st[v[s][i]]=1;
                }
                else if(st[s]=-1){
                    qu.push(v[s][i]);
                    st[v[s][i]]=-1;
                }
            }
        }
    }
    int fennec=0,snuke=0;
    for(int i=0;i<N;i++){
        if(st[i]==1) fennec++;
        else snuke++;
    }
    if(fennec>snuke) puts("Fennec");
    else puts("Snuke");
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<vector<int>> p(n+1,vector<int>(n+1));
  for(int i=0;i<m;i++){
    int l,r;cin >> l >> r;
    p[l][r]++;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      p[i][j]+=p[i][j-1];
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      p[i][j]+=p[i-1][j];
    }
  }
  for(int i=0;i<q;i++){
    int s,t;cin >> s >> t;
    cout << p[t][t]+p[s-1][s-1]-p[t][s-1]-p[s-1][t] << endl;
  }
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;
	
int main()
{
    cin >> N >> K;
    ll ans = 0;
    for(ll b=K+1;b<=N;b++){
        ans += N/b * max(0ll, b-K) + max(0ll, N%b - max(K - 1, 0ll));
    }
    cout << ans;
}


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


int main() {
  
  int N; //候補地数
  cin >> N;
  int T; //気温基準値
  cin >> T;
  int A; //目標気温
  cin >> A;
  vector<int> H(N); //標高
  for(int i = 0; i < N; i++) cin >>  H[i];
  
  int best_tempture = 1<<30;
  int ans_num = 0;
  bool initialize = false;
  
  for(int i = 0 ; i < N ; i++){
    
     int tmp = (T*1000 - H[i]*6) - (A * 1000);
    if(tmp < 0) tmp = -tmp;
    if(best_tempture > tmp) best_tempture = tmp,ans_num = i;
    
    
    
  }
  
  cout << ans_num + 1 << endl;

  
 
}


           

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define lli  long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      auto pl:mp       pl.S && pl.F
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)
{   int res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t, i, j, n, x;
    cin >> t;
    string s;
    map<string, lli> mp;
    for (i = 0; i < t; i++) {
        cin >> s;
        mp[s]++;
    }
    cout << "AC  x  " << mp["AC"] << "\n";
    cout << "WA  x  " << mp["WA"] << "\n";
    cout << "TLE  x  " << mp["TLE"] << "\n";
    cout << "RE  x  " << mp["RE"] << "\n";
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll D,G;
    cin >> D >>G;
    vector<pair<ll,ll>> sc(D);
    for(int i = 0; i < D; i++){
        cin >> sc[i].first >> sc[i].second;
    }

    ll m = 1ll << 60;
    for(unsigned int i = 0; i < 1 << D; i++){
        for(int ti = -1; ti < D; ti++){
            ll tmp = 0;
            ll tc = 0;
            for(int j = 0; j < D; j++){
                if((i & (1 << j)) && j != ti){
                    tmp += (sc[j].first) * (j + 1) * 100 + sc[j].second;
                    tc += sc[j].first;
                }
            }
            if(ti == -1){
                if(tmp >= G){
                    m = min(m,tc);
                }
                continue;
            }
            if(i & (1 << ti)){
                if(tmp + sc[ti].first * (ti + 1) * 100 < G){
                    continue;
                }
                tc += ceil((double)max(0ll,G - tmp) / (double)(100 * (ti + 1)));
                m = min(m,tc);
            }
        }
    }
    cout << m << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>s(N);
    ll sum=0;
    ll mn=INF;
    rep(i,N){
        cin>>s[i];
        sum+=s[i];
        if(s[i]%10!=0){
            chmin(mn,s[i]);
        }
    }

    if(mn==INF){
        cout<<0<<endl;
    }else{
        if(sum%10==0){
            cout<<sum-mn<<endl;
        }else{
            cout<<sum<<endl;
        }
        
    }


    return 0;
    

}

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

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<vector<int>>v(M, vector<int>(M));
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> v[i][j];
		}
	}
	vector<vector<int>>field(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> field[i][j];
			field[i][j]--;
		}
	}
	int ans = MOD;
	vector<vector<int>>num(3, vector<int>(M));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			num[(i + j) % 3][field[i][j]]++;
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			if (i == j)continue;
			for (int k = 0; k < M; k++) {
				if (i == k || j == k)continue;
				int box = 0;
				for (int l = 0; l < M; l++) {
					box += v[l][i] * num[0][l];
				}
				for (int l = 0; l < M; l++) {
					box += v[l][j] * num[1][l];
				}
				for (int l = 0; l < M; l++) {
					box += v[l][k] * num[2][l];
				}
				//cout << i << " " << j << " " << k << " " << box << endl;
				ans = min(ans, box);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <math.h>	
#include <string>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <algorithm>
#include <unordered_set>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main() {
	
	string a;
	cin >> a;
	for (int t = 0; t < a.size(); t += 2) {
		if (a[t] == 'L') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int t = 1; t < a.size(); t += 2) {
		if (a[t] == 'R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

class node {
public:
	node() {
		parent = -1;
		children.clear();
		depth = -1;
	}
	int parent;
	vector<int> children;
	int depth;
};

int n;
node d[100000];

int main(void) {
	int a,k,c;
	cin >> n;
	for(int i =0;i<n;i++){
		cin >> a >> k;
		for(int j = 0;j < k;j++){
			cin >> c;
			d[a].children.push_back(c);
			d[c].parent = a;
		}
	}
	queue<int> q;
	for(int i = 0;i < n;i++){
		if(d[i].parent == -1){
			d[i].depth = 0;
			q.push(i);
		}
	}
	while(!q.empty()){
		int v = q.front();q.pop();
		for(auto& e:d[v].children){
			if(d[e].depth == -1){
				d[e].depth = d[v].depth + 1;
				q.push(e);
			}
		}
	}
	for(int i = 0;i < n;i++){
		cout << "node " << i << ": parent = " << d[i].parent << ", depth = " << d[i].depth << ", ";
		if(d[i].parent == -1) cout << "root";
		else if(d[i].children.size() == 0) cout << "leaf";
		else cout << "internal node";
		cout << ", [";
		for(int j = 1;j < ((signed)d[i].children.size());j++) cout << d[i].children[j-1] << ", ";
		if(d[i].children.size() != 0)cout << d[i].children[d[i].children.size()-1];
		cout << "]" << endl;
	}
}



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

typedef pair<int, int> P;
ll mod = 1e9+7;

bool solve(int s, int c, int n,int k){
    int tmp = n;
    tmp = tmp/(pow(10,k-s)) - (int)(tmp/pow(10,k-s+1))*10;
    // cout << n <<" " << tmp << " " << s << " " << c << endl;
    return tmp==c;
}

int main() {

    int n,m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m){
        cin >> p[i].first >> p[i].second;
    }

    int ans = -1;
    if(n==1){
        for(int i = 0;i<10;i++){
            bool ok =true;
            rep(j,m){
                if(!solve(p[j].first,p[j].second,i,n)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans=i;
                break;
                }
        }
    }else if(n==2){
        for(int i = 10; i <100;i++ ){
            bool ok =true;
            rep(j,m){
                if(!solve(p[j].first,p[j].second,i,n)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans=i;
                break;
                }
        }
    }else{
        for(int i = 100; i < 1000;i++){
            bool ok =true;
            rep(j,m){
                if(!solve(p[j].first,p[j].second,i,n)){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans=i;
                break;
                }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,m,st,ed;
struct P{int x,y;LL v;}p[85];
struct Q{int o,a,b;}q[325];
char op[3];
struct Edge{int x,y,d,next;LL c;}e[100010];
int last[450],len;
void ins(int x,int y,int d,LL c)
{
	int t=++len;
	e[t].x=x;e[t].y=y;e[t].d=d;e[t].c=c;
	e[t].next=last[x];last[x]=t;
}
void addedge(int x,int y,int d,LL c){/*printf("%d %d %d %lld\n",x,y,d,c);*/ins(x,y,d,c),ins(y,x,0,-c);}
LL f[450];int pre[450];bool in[450];
bool spfa()
{
	memset(f,-63,sizeof(f));f[st]=0;
	memset(in,false,sizeof(in));
	queue<int>q;q.push(st);
//	printf("st %d\n",st);
	while(!q.empty())
	{
		int x=q.front();q.pop();in[x]=false;
//		printf("x=%d\n",x);
		for(int i=last[x];i;i=e[i].next)
		{
			int y=e[i].y;
			if(e[i].d>0&&f[x]+e[i].c>f[y])
			{
				pre[y]=i;
				f[y]=f[x]+e[i].c;
				if(!in[y])in[y]=true,q.push(y);
			}
		}
	}
	if(f[ed]>0)return true;
	return false;
}
LL Ans,ans=0;
void work()
{
	int x=ed;
	while(x!=st)
	{
		Ans+=e[pre[x]].c;
		e[pre[x]].d--,e[pre[x]^1].d++;
		x=e[pre[x]].x;
	}
}
int lx[85],rx[85],ly[85],ry[85];
void solve(int k)
{
	memset(last,0,sizeof(last));len=1;
	for(int i=1;i<=n;i++)
	addedge(p[i].x,200+i,1,p[i].v),addedge(200+i,100+p[i].y,1,0);
	for(int i=1;i<=k;i++)lx[i]=ly[i]=1,rx[i]=ry[i]=100;
	for(int i=1;i<=m;i++)
	{
		if(q[i].o==0)lx[q[i].b+1]=max(lx[q[i].b+1],q[i].a+1);
		if(q[i].o==1&&k>q[i].b)rx[k-q[i].b]=min(rx[k-q[i].b],q[i].a-1);
		if(q[i].o==2)ly[q[i].b+1]=max(ly[q[i].b+1],q[i].a+1);
		if(q[i].o==3&&k>q[i].b)ry[k-q[i].b]=min(ry[k-q[i].b],q[i].a-1);
	}
	for(int i=2;i<=k;i++)lx[i]=max(lx[i],lx[i-1]),ly[i]=max(ly[i],ly[i-1]);
	for(int i=k-1;i;i--)rx[i]=min(rx[i],rx[i+1]),ry[i]=min(ry[i],ry[i+1]);
//	printf("%d %d %d %d\n",lx[1],rx[1],ly[1],ry[1]);
	st=200+n+2*k+1,ed=st+1;
//	printf("st=%d ed=%d\n",st,ed);
	for(int i=1;i<=k;i++)
	{
		if(lx[i]>rx[i]||ly[i]>ry[i])return;
//		printf("%d %d %d %d\n",lx[i],rx[i],ly[i],ry[i]);
		addedge(st,200+n+i,1,0),addedge(200+n+k+i,ed,1,0);
		for(int j=lx[i];j<=rx[i];j++)addedge(200+n+i,j,1,0);
		for(int j=ly[i];j<=ry[i];j++)addedge(100+j,200+n+k+i,1,0);
//		printf("st=%d\n",st);
	}
	int u=0;Ans=0;
	while(spfa())u++,work();
//	printf("u=%d\n",u);
	if(u!=k)return;
//	puts("ok");
	ans=max(ans,Ans);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)p[i].x=read(),p[i].y=read(),p[i].v=read();
	m=read();
	for(int i=1;i<=m;i++)
	{
		scanf("%s",op);
		q[i].a=read(),q[i].b=read();
		if(op[0]=='L')q[i].o=0;
		if(op[0]=='R')q[i].o=1;
		if(op[0]=='D')q[i].o=2;
		if(op[0]=='U')q[i].o=3;
	}
//	solve(4);
	for(int i=1;i<=n;i++)solve(i);
	printf("%lld",ans);
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

int const M = 1e9 + 7;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N, K;
    cin >> N >> K;
    int ans = 1;
    for(int i = K; i <= N; i++){
        int l = i * ( i - 1);
        l >>= 1;
        int r = i * N - l;
        ans += (r - l + 1) % M;
        ans = (ans) % M;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b,c,d,t=0;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if (a<b) {swap(a,b);swap(c,d);}
    int k=0,l=0;
    if (a>1) {if (s.at(a-2)=='.') l++;}
    for (int i=a-1;i<c;i++){
        if (s.at(i)=='#') {l=0;k++;}
        if (s.at(i)=='.') {l++;k=0;}
        if (l==3) t=1;
        if (k==2) {cout << "No" << endl;return 0;}
    }
    if (c!=n) {if (s.at(c)=='.' && l==2) t=1;}
    k=0;l=0;
    if (d>c && t==0) {cout << "No" << endl;return 0;}
    for (int i=b-1;i<d;i++){
        if (s.at(i)=='#') {l=0;k++;}
        if (s.at(i)=='.') {l++;k=0;}
        if (l==3) t=1;
        if (k==2) {cout << "No" << endl;return 0;}
    }
    cout << "Yes" << endl;
}


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

int main( )
{
    int n, x;
    int ara[111];
    int i, j, k;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
    }
    int mn = 1e9;
    int s = 0;
    for (int p = 0; p <= 100; p++) {
        s = 0;
        for (i = 1; i <= n; i++) {
            s += (ara[i] - p) * (ara[i] - p);
        }
        mn = min(mn, s);
    }
    cout << mn << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int n,m;
vector<int> k[15];
bool p[15];
bool on[15];
int ans;
void dfs(int dp){
	if(dp!=n){
		dfs(dp+1);
		on[dp]=1;
		dfs(dp+1);
		on[dp]=0;
		return;
	}
	else{
		bool nw[15];
		memset(nw,0,sizeof(nw));
		for(int i=0;i<m;i++){
			for(int j=0;j<k[i].size();j++){
				if(on[k[i][j]]==1)nw[i]^=1;
			}
		}
		for(int i=0;i<m;i++){
			if(nw[i]!=p[i])return;
		}
		ans++;
	}
}
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int num;
		cin>>num;
		for(int j=0;j<num;j++){
			int a;
			cin>>a;
			k[i].push_back(a-1);
		}
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	dfs(0);
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 256
from collections import defaultdict

def factorization(n):
  res = []
  for i in range(2, int(n**0.5//1) + 1):
    if n%i == 0:
      cnt = 0
      while n%i==0:
        n = n//i
        cnt += 1
      res.append([i,cnt])

  if n != 1:
    res.append([n,1])

  return res

N = int(input())
factors = defaultdict(int)
factors[1] = 1
for i in range(2, N+1):
  f = factorization(i)
  for d,cnt in f:
    factors[d] += cnt

mod = 10**9+7
res = 1
for i in range(2, N+1):
  res *= (factors[i]+1)
  res %= mod

print(res)

Measured memory_bytes: 40688
N = int(input())
S = input()

count_list=[]
for i in range(1,N):
  X = S[0:i]
  Y = S[i:N]
  count=0
  temp = []
  for c in X:
    if c in Y:
      if c not in temp:
        count += 1
        temp.append(c)
  count_list.append(count)
print(max(count_list))

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

int main() {
  int d;
  cin >> d;
  if(d==25){
    cout << "Christmas" << endl;
  }
  if(d==24){
    cout << "Christmas Eve" << endl;
  }
  if(d==23){
    cout << "Christmas Eve Eve" << endl;
  }
  if(d==22){
    cout << "Christmas Eve Eve Eve" << endl;
  
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    FOR(i,0,N)cin >> a[i];
    ll DP[N][K+1];
    //DP[i][j] := i人目までにj個分ける場合の数
    FOR(i,0,N)FOR(j,0,K+1)DP[i][j] = 0;
    FOR(j,0,a[0]+1){
        DP[0][j] = 1;
    }
    FOR(i,1,N){
        FOR(j,1,K+1)DP[i-1][j] += DP[i-1][j-1];
        FOR(j,0,K+1){
            DP[i][j] = DP[i-1][j] - (j-a[i] > 0 ? DP[i-1][j-a[i]-1] : 0);
            DP[i][j] %= INF;
        }
    }
    cout << DP[N-1][K] << endl;
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <limits.h>

int main(){
  int A,B,max=-INT_MAX;
  scanf("%d %d",&A,&B);
  if(max<A*B)max=A*B;
  if(max<A-B)max=A-B;
  if(max<A+B)max=A+B;
  printf("%d\n",max);
}

Measured memory_bytes: 128
class Dice
	def initialize(labels)
		@labels = labels
		@top    = labels[0]
		@front  = labels[1]
		@right  = labels[2]
		@left   = labels[3]
		@back   = labels[4]
		@bottom = labels[5]
	end
	attr_reader :top, :front, :right, :left, :back, :bottom

	def roll(op)
		case op
		when "E"
			@t      = @top
			@top    = @left
			@left   = @bottom
			@bottom = @right
			@right  = @t
		when "W"
			@t      = @top
			@top    = @right
			@right  = @bottom
			@bottom = @left
			@left   = @t
		when "N"
			@t      = @top
			@top    = @front
			@front  = @bottom
			@bottom = @back
			@back   = @t
		when "S"
			@t      = @top
			@top    = @back
			@back   = @bottom
			@bottom = @front
			@front  = @t
		when "R" # Roll around front and back
			@f      = @front
			@front  = @left
			@left   = @back
			@back   = @right
			@right  = @f 
		end
	end

	def same?(dice2)
		if dice2.top == @top && dice2.left == @left && dice2.front == @front &&
		   dice2.right == @right && dice2.back == @back && dice2.bottom == @bottom 
		   return true
		else
		   return false
		end
	end
end

def same_rolled?(dice1, dice2)
	for i in 0..3
		i.times{dice1.roll("E")}
		for j in 0..3
			j.times{dice1.roll("N")}
			for k in 0..3
				k.times{dice1.roll("W")}
				for l in 0..3
					l.times{dice1.roll("S")}
					return true if dice1.same?(dice2)
				end
			end
		end
	end
	return false
end
n = gets.strip.to_i
dices = Array.new(n){nil}
ret = "Yes"
for i in 0..n-1
	labels = gets.strip.split(" ").map{|item| item.to_i}
	dices[i] = Dice.new(labels)
	if i > 0
		for j in 0..i-1
			ret = "No" if same_rolled?(dices[i], dices[j])
		end
	end
end
puts ret


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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n+1);
    vector<int> dp(n+1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++) cin >> h[i];

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j <= i+2; j++) {
            //if (j >= n) continue;
            dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]));
        }
    }

    cout << dp[n-1];
}


Measured memory_bytes: 1024
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (3*10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
N, K = map(int, input().split())

K = min(N-1, K)

r = 0
for i in range(K+1):
    r = (r + mul(cmb(N, i), cmb(N-1, N-i-1)))%mod
print(r)


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

#define mx 100000
vector<int> adj[mx+5];
vector<int> prob[mx+5], comp(mx+5, 0);
map<int, int> sz;
int cnt = 1;

void dfs(int node) {
	comp[node] = cnt;
	for(auto it: adj[node]) {
		if(comp[it] == 0) {
			dfs(it);
		}
	}
}

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 0; i < m; ++i) {
		int r1, r2;
		cin >> r1 >> r2;
		adj[r1].push_back(r2);
		adj[r2].push_back(r1);
	}
	for(int i = 0; i < k; ++i) {
		int r1, r2;
		cin >> r1 >> r2;
		prob[r1].push_back(r2);
		prob[r2].push_back(r1);
	}
	for(int i = 1; i <= n; ++i) {
		if(comp[i] == 0) {
			dfs(i);
			++cnt;
		}
	}
	for(int i = 1; i <= n; ++i) ++sz[comp[i]];
	for(int i = 1; i <= n; ++i) {
		int ans = sz[comp[i]] - adj[i].size();
		for(auto it: prob[i]) {
			if(comp[it] == comp[i]) --ans;
		}
		cout << ans-1 << " ";
	}
	return 0;
}

Measured memory_bytes: 12928
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1], s = h[2], M = 1000000000;

		var a = Enumerable.Repeat(s, k).Concat(Enumerable.Repeat(s == M ? 1 : M, n - k));
		Console.WriteLine(string.Join(" ", a));
	}
}


Measured memory_bytes: 37344
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  int ans = 0;
  FOR(i, 1, n-1){
    if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

num = int(input())

words = []
for _ in range(num):
    words.append(input())

words = tuple(words)

d = {}
for word in words:
    if word in d:
        d[word] += 1
    else:
        d[word] =1


# keyをndarrayで取得
keys = np.array([a[0] for a in d.items()])

# valueをndarrayで取得
values = np.array([a[1] for a in d.items()])

# valueがmaxであるkeyを探してくる
keys_of_max_val = keys[values == values.max()]

keys_of_max_val.sort()

print('\n'.join(keys_of_max_val))

Measured memory_bytes: 87112
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::collections::HashMap;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut count = HashMap::new();
    for _ in 0..n {
        let s: String = scan(tokens);
        let mut s = s.into_bytes();
        s.sort();
        *count.entry(s).or_insert(0) += 1;
    }
    let mut ans: usize = 0;
    for &c in count.values() {
        ans += c * (c - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 19028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl

void solve(){
	int n; cin>>n; ll sum = 0;
	unordered_map<int,int> um;
	rep(i,0,n-1){
		int a; cin>>a; sum += a;
		um[a]++;
	}
	int q; cin>>q;
	while(q--){
		int b,c; cin>>b>>c;
		int freq = um[b];
		sum += (c-b)*freq;
		um.erase(b);
		um[c] += freq;
		cout << sum << nl;
	}
}

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}


Measured memory_bytes: 6608