akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#pragma warning(disable:4996)
//FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 0x7fffffff
#define NM 100005
#define MOD 1000000007
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define sd(n) fscanf(in,"%lld",&n)
typedef long long int ll;

int n, check[NM * 2], N;
struct LIST {
	ll x;
	int idx;
	bool operator()(const LIST& A, const LIST& B) {
		return A.x < B.x;
	}
}p[NM*4];
void input() {
	si(n); N = n * 2;
	FOR(i, 1, n) {
		int a, b; si(a), si(b);
		if (a > b) swap(a, b);
		p[i * 2 - 1].x = a; p[i * 2 - 1].idx = i;
		p[i * 2].x = b; p[i * 2].idx = i;
	}
	sort(p + 1, p + 1 + N, LIST());
}
ll case1() {
	FOR(i, 1, n) check[i] = 0;
	ll res = 1e18;
	int L = 1, R = N + 1;
	check[p[1].idx] = 1;
	while (check[p[R - 1].idx] == 0) check[p[--R].idx] = 1;
	if (R <= N) res = min(res, (p[N].x - p[1].x)*(p[R - 1].x - p[L + 1].x));
	for (L=2;L<=N;L++){
		while (check[p[L].idx] == 1 && R <= N) check[p[R++].idx] = 0;
		if (R == N + 1) break;
		check[p[L].idx] = 1;
		res = min(res, (p[N].x - p[1].x)*(p[R - 1].x - p[L + 1].x));
	}
	return res;
}
ll case2() {
	FOR(i, 1, n) check[i] = 0;
	int L = 1, R = N;
	check[p[1].idx] = 1;
	check[p[N].idx] = 2;
	while ((check[p[L + 1].idx] & 1) == 0)
		check[p[++L].idx] ^= 1;
	while ((check[p[R - 1].idx] & 2) == 0)
		check[p[--R].idx] ^= 2;
	return (p[N].x - p[L + 1].x)*(p[R - 1].x - p[1].x);
}
int main() {
	input();
//	fprintf(out, "%lld %lld ", case1(), case2());
	fprintf(out, "%lld", min(case1(), case2()));
	return 0;
}

Measured memory_bytes: 7168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<string> 
#include<vector>
#include<stack>
#include<queue> 
#define PI 3.14159265358979323846
typedef long long ll;
using namespace std;
const ll Mod=1e9+7;
ll gcd(ll a, ll b) 
{
    if (b == 0) return a;
    else gcd(b, a % b);
}
long long quick_mod(long long a,long long b)//a的b次方对Mod取余 
{
    long long ans = 1;
    a %= Mod; //对刚进来的a进行取模运算，避免后面第一次求平方运算溢出
    while(b)
    {
        if(b&1) //对二进制下的 b 进行按位与1运算，求二进制下 b 的最低位是否为1
            ans = ans * a % Mod; //对结果进行保存
        b>>=1; //二进制下的 b 右移一位，相当于十进制下的 b 除以2
        a = a * a % Mod; 
    }
    return ans % Mod;
}
const int inf=0x3f3f3f3f;
int main()
{
	static ll a[200020]={0};
	ll n=0,k=0,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	for(int i=0;i<n-k;i++)
	ans+=a[i];
	//ans+=k;
	cout<<ans<<endl;
	return 0;
} 






Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int edge = 0;
    int iner = 0;
    int f=0;
    

    for(int i=0;i<s.size();i++){
        if(i==0){
            if(s[i]=='L'){edge++;continue;}
        }

        if(i==s.size()-1){
            if(s[i]=='R'){edge++;continue;}
        }
        
        if (s[i] == 'R' && s[i + 1] == 'R') {

        } else if (s[i] == 'L' && s[i - 1] == 'L') {

        } else if (s[i] == 'R' && s[i + 1] == 'L') {
            iner += 1;
            i++;
        }
    }

    int ans=s.size()-(iner*2+edge);
//    cout<<ans<<endl;
//    cout<<edge<<endl;

    ans+=min(k,iner)*2;
    k-=min(k,iner);

    if(k>0&&s[0]=='L'){
        k--;
        ans+=1;
    }
    if(k>0&&s[s.size()-1]=='L'){
        ans-=1;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = 321;
int A[MAXN][MAXN];
int cur[MAXN], cnt[MAXN];
int n, m;

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

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			A[i][j] = fetch<int>() - 1;
		}
	}

	int answ = 0;
	for(int i = 0; i < m; ++i) {
		cur[i] = 1;
	}

	for(int i = 0; i < n; ++i) {
		int s = A[i][0];
		++cnt[s];
		answ = max(answ, cnt[s]);
	}

	for(int ph = 0; ph < m - 1; ++ph) {
		memset(cnt, 0, sizeof(cnt));
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m; ++j) {
				int s = A[i][j];

				if(cur[s]) {
					++cnt[s];
					break;
				}
			}
		}

		int pos = max_element(cnt, cnt + m) - cnt;
		answ = min(answ, cnt[pos]);
		cur[pos] = 0;
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, C;
  cin>>N>>C;
  int D[C][C];
  for(int i=0;i<C;++i) {
    for(int j=0;j<C;++j) {
      cin>>D[i][j];
    }
  }
  int c[N][N];
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      cin>>c[i][j];
      c[i][j]--;
    }
  }
  int color[3][C];
  for(int i=0;i<3;++i) {
    for(int j=0;j<C;++j) {
      color[i][j] = 0;
    }
  }
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      color[(i+j)%3][c[i][j]]++;
    }
  }
  int ans=inf;
  int tmp;
  for(int i=0;i<C;++i) {
    for(int j=0;j<C;++j) {
      if(i==j) continue;
      for(int k=0;k<C;++k) {
        if(i==k || j==k) continue;
        tmp = 0;
        for(int l=0;l<C;++l) {
          tmp += color[0][l]*D[l][i];
        }
        for(int l=0;l<C;++l) {
          tmp += color[1][l]*D[l][j];
        }
        for(int l=0;l<C;++l) {
          tmp += color[2][l]*D[l][k];
        }
        ans = min(ans, tmp);
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4540
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
using namespace std;
using Data = pair<long long, vector<int> >;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;
const int mod = 1e9+7;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    UnionFind uf(n);

    REP(i,m) {
        int x,y,z;cin >> x >> y >> z;
        x--;y--;
        uf.merge(x,y);
    }
    
    set<int> se;
    REP(i,n) se.insert(uf.root(i));
    pl(se.size())
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()

// ----- Tools ----- //
template <typename Key, typename Value, typename Arg>
bool containsKey(const unordered_map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
template <typename Key, typename Value, typename Arg>
bool containsKey_tm(const map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
bool startsWith(string str, string tar) {return (str.rfind(tar, 0) == 0);}
bool contains(string str, string tar) {return (str.find(tar) != std::string::npos);}
vector<string> split(string str, char ch) {vector<string> res; stringstream ss(str); string s; while (getline(ss, s, ch)) res.push_back(s); return res; }
char toLower(char& ch) {if ('A' <= ch && ch <= 'Z') return ch - 'A' + 'a'; else return ch;}
char toUpper(char& ch) {if ('a' <= ch && ch <= 'z') return ch - 'a' + 'A'; else return ch;}

// -------- Main Code -------- //

// --------------- //

void runcase() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for (int i=0; i<n; i++) cin >> arr[i];

    sort(all(arr));

    map<int, int> map_cnt;
    for (auto u : arr) map_cnt[u] ++;

    vector<int> arr2;
    int pv = -1;
    for (int i=0; i<n; i++) {
        if (arr[i] != pv) arr2.emplace_back(arr[i]);
        pv = arr[i];
    }
    arr = arr2;

    // for (auto u : arr2) cout << u << " ";
    // cout << '\n'; 

    n = arr.size();
    sort(all(arr));
    ll res = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (arr[i] + arr[j] > arr[k]) {
                    res += 1LL * map_cnt[arr[i]] * map_cnt[arr[j]] * map_cnt[arr[k]];
                }
            }
        }
    }
    cout << res << '\n';
}

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

    // int t;
    // cin >> t;
    // while (t-- > 0)
        runcase();

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  if(N==M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")

MOD = 1000000007

# 処理内容
def main():
    N = int(input())
    
    a = 1
    for _ in range(N):
        a = a * 10 % MOD
    
    b = 1
    for _ in range(N):
        b = b * 9 % MOD
    
    c = 1
    for _ in range(N):
        c = c * 8 % MOD
    
    ans = (a - 2*b + c) % MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 77732
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(ll i = (ll)(a); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion

int main(){
    ll l, r;
    cin >> l >> r;

    if(r - l >= 2018){
        cout << 0 << endl;
        return 0;
    }

    int ans = 2019;
    FOR(i, l , r){
        for(ll j = r; j > l; j--){
            int ij = (i*j) % 2019;
            ans = min(ans, ij);
        }
    }

    cout << ans << endl;
}




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

typedef long long ll;

const int MN = 305, P = 998244353;

typedef std::bitset<MN> bst;

bst val[MN], vec[MN];

int n, m, cnt;

inline int fpw(int x, int k) {
	int res = 1;
	for (; k; k >>= 1, x = (ll) x * x % P)
		if (k & 1) res = (ll) res * x % P;
	return res;
}

inline int read() {
	int x; bool f; char c;
	for (f = 0; (c = getchar()) < '0' || c > '9'; f = c == '-');
	for (x = c ^ '0'; (c = getchar()) >= '0' && c <= '9'; x = (x << 1) + (x << 3) + (c ^ '0'));
	return f ? -x : x;
}

int main() {
	n = read(), m = read();
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			val[i][j] = read();

	for (int i = 0; i < n; ++i)
		for (int j = m; j--; )
			if (val[i][j]) {
				if (vec[j].count()) val[i] ^= vec[j];
				else {
					++cnt;
					vec[j] = val[i];
					for (int k = j; k--; )
						if (vec[j][k]) vec[j] ^= vec[k];
					for (int k = j; ++k < m; )
						if (vec[k][j]) vec[k] ^= vec[j];
					break;
				}
			}

	printf("%lld\n", (ll)fpw(2, m - 1) * (fpw(2, n) - fpw(2, n - cnt) + P) % P);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n),B;
  ll ans = 0;
  for(auto &a:A){cin>>a;a--;}
  for(ll i=0;i<n-1;i++){
    if(i == A[i]){
      swap(A[i],A[i+1]);
      ans++;
    }
  }
  if(A.back() == n-1){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    long long n = 0;
    long long m = 0;

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

    if (m / 2 <= n) printf("%lld\n", m / 2);
    else printf("%lld\n", (2 * n + m) / 4);
    return 0;
}
		

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

int main() {

  long long int n, m;
  cin >> n >> m;

  vector< long long int > b;

  long long int cnt_0 = 0;
  long long int cnt_1 = 0;

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

    long long int in;
    cin >> in;
    b.push_back( in );

    if ( in == 0 ) cnt_0++;
    if ( in == 1 ) cnt_1++;

  }

  vector< long long int > v0, v1;
  long long int cnt_a = 0;
  long long int cnt_b = 0;

  for ( long long int i = 0; i < m; i++ ) {

    long long int in;
    cin >> in;

    if ( ( i % 2 ) == 0 ) {
      cnt_a += in;
      for ( long long int j = 0; j < in; j++ ) {
	v0.push_back(0);
	v1.push_back(1);
      }
    }else {
      cnt_b += in;
      for ( long long int j = 0; j < in; j++ ) {
	v0.push_back(1);
	v1.push_back(0);
      }
    }

  }

  long long int ans = 100000000;

  if ( cnt_0 == cnt_a ) {

    long long int c = 0;
    long long int k = 0;

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

      if ( v0[i] == 1 ) continue;
      while(1) {
	if ( b[k] == 0 ) {
	  c += abs( k - i );
	  break;
	}
	k++;
      }
      k++;

    }

    ans = min( ans, c );

  }

  if ( cnt_0 == cnt_b ) {

    long long int c = 0;
    long long int k = 0;

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

      if ( v1[i] == 1 ) continue;
      while(1) {
	if ( b[k] == 0 ) {
	  c += abs( k - i );
	  break;
	}
	k++;
      }
      k++;

    }

    ans = min( ans, c );

  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/


int main(){


    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int n,k; cin>>n>>k;
    vector<int>A(n); for(int i=0;i<n;i++)cin>>A[i];
    ll dp[n+1];
    for(int i=0;i<=n;i++)dp[i]=LLONG_MAX;
    dp[0]=0;
    dp[1]=abs(A[0]-A[1]);

    for(int i=2;i<n;i++){
       
       for(int j=1;i-j>=0 and j<=k;j++)
        dp[i]=min( dp[i],dp[i-j]+abs(A[i]-A[i-j]));
    }
    cout<<dp[n-1];

    return 0;  
    
}


Measured memory_bytes: 4508
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i > 0:
        if a[i] - a[i - 1] == 1:
            ans += c[a[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


if __name__ == '__main__':
    data = set(get_sieve_of_eratosthenes(100000))
    pos = []
    for i in data:
        if (i + 1) % 2 == 0:
            if (i + 1) // 2 in data:
                pos.append(i)
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        ans = 0
        for i in pos:
            if i <= r and l <= i:
                ans += 1
        print(ans)

Measured memory_bytes: 52400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int MOD = 100000007;
const int MAXN = 1000000;
const int inf = 0x3f3f3f3f;
int main()
{
	//freopen("data.txt","r",stdin);
	char str[10];
	scanf("%s", str);
	for (int i = 0; i < 4; i++)
	{
		if (str[i] == str[i + 1])
		{
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  cout<<v[n-1]-v[0]<<endl;
  
}
///////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> dif(m-1),x(m);
    rep(i,m){
        cin >> x[i];
    }
    if (m <= n)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    rep(i,m-1){
        dif[i] = x[i + 1] - x[i];
    }
    sort(dif.begin(), dif.end());
    int ans = 0;
    rep(i,m-n){
        ans += dif[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <list>
#include <vector>
#include <climits>

using namespace std;
typedef long int ll;

void dfs_visit(vector<list<ll>>& G,ll u,vector<bool>& visited,list<ll>& top)
{
    visited[u] = true;

    for (ll v:G[u])
    {
        if (!visited[v])
        {
            dfs_visit(G,v,visited,top);
        }
    }

    top.push_front (u);
}

void dfs(vector<list<ll>>& G,list<ll>& top)
{
    vector<bool> visited(G.size());

    for (ll u=0;u<G.size();++u)
    {
        if (!visited[u])
        {
            dfs_visit(G,u,visited,top);
        }
    }
}

vector<list<ll>> complement(vector<list<ll>>& G)
{
    vector<list<ll>> comp(G.size());

    for (ll u=0;u<G.size();++u)
    {
        for (auto v:G[u])
        {
            comp[v].push_back(u);
        }
    }

    return comp;
}

ll longest_path(list<ll>& top,vector<list<ll>>& G)
{
    vector<ll> dp(G.size());
    vector<list<ll>> comp = complement(G);

    for (auto v:top)
    {
        ll M = -INT_MAX;
        for (auto u:comp[v])
        {
            M = max(dp[u],M);
        }
        dp[v] = max(M + 1,dp[v]);
    }

    ll ans = -INT_MAX;

    for (auto k:dp)
    {
        ans = max(ans,k);
    }

    return ans;
}

list<ll> topological_sort(vector<list<ll>>& G)
{
    ll n = G.size();
    list<ll> top;
    dfs(G,top);

    return top;
}

int main()
{
    ll V,E;
    cin>>V>>E;

    vector<list<ll>> G(V);
    for (ll e=0;e<E;++e)
    {
        ll x,y;
        cin>>x>>y;

        G[x-1].push_back(y-1);
    }

    list<ll> top = topological_sort(G);

    //cout<<endl;
    cout<<longest_path(top,G)<<endl;

    return 0;
}


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

int n;

void counting_sort(int A[], int B[], int k)
{
    int C[k + 1];
    for(int i = 1; i <= k; i++)
        C[i] = 0;

    for(int j = 1; j <= n; j++)
        C[A[j]]++;

    for(int i = 1; i <= k; i++)
        C[i] = C[i] + C[i - 1];

    for(int j = n; j >= 1; j--)
    {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main()
{
    scanf("%d", &n);
    int A[n + 1];
    int B[n + 1];
    for(int i = 1; i <= n; i++)
        scanf("%d", &A[i]);
    counting_sort(A, B, 10000);
    for(int i = 1; i < n; i++)
        printf("%d ", B[i]);
    printf("%d\n", B[n]);
}


Measured memory_bytes: 18868
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <deque>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int K = 0; cin >> K;
  if (K <= 10) {
    cout << K << endl;
    return 0;
  }

  deque<LL> que;
  int cnt = 0;
  LL v = 0;
  for (int i = 1; i <= 9; ++i) que.push_back(i);
  while (cnt != K) {
    v = que.front(); que.pop_front();
    LL a = v % 10LL;
    if (a == 0) {
      que.push_back(v * 10LL);
      que.push_back(v * 10LL + 1LL);
    } else if (a == 9) {
      que.push_back(v * 10LL + 8LL);
      que.push_back(v * 10LL + 9LL);
    } else {
      que.push_back(v * 10LL + a-1LL);
      que.push_back(v * 10LL + a);
      que.push_back(v * 10LL + a+1LL);
    }
    ++cnt;
  }
  cout << v << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        cout << "Bad" << '\n';
    }
    else
    {
        cout << "Good" << '\n';
    }

    return 0;
}


Measured memory_bytes: 3568
/*
    B - Can you solve this?
    https://atcoder.jp/contests/abc121/tasks/abc121_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> src(m);

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

    int total = 0;
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            int input;
            cin >> input;
            sum += src[j] * input;
        }
        sum += c;
        // cout << "sum : " << sum << endl;
        if (sum > 0)
            total++;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
N = 86402
ans = []
loop {
  n = gif
  break if n == 0
  m = array N,0
  rep n do
    s,e = gs
    stt = s.split(':').map(&:to_i)
    enn = e.split(':').map(&:to_i)
    l = stt[0]*60*60 + stt[1]*60 + stt[2]
    r = enn[0]*60*60 + enn[1]*60 + enn[2]
    m[l]     += 1
    m[r]   -= 1
  end

  repl 1, N-1 do |i|
    m[i] += m[i-1]
  end
  ans << m.max
}

puts ans

Measured memory_bytes: 20572
#include<bits/stdc++.h>
using namespace std ;
priority_queue<int,vector<int>,greater<int> > pq ; 
vector<pair<int,int> > v ; 
int n , m ; 
int main(){
  cin>>n>>m ; 
  for(int i=0;i<n;i++){
     int x;  
     cin>>x ; 
     pq.push(x) ; 
  }
  
  for(int i=0;i<m;i++){
     int b , c ; 
     cin>>b>>c ; 
    v.push_back({c,b}) ; 
  }
  sort(v.begin(),v.end()) ; 
  reverse(v.begin(),v.end()) ; 
  long long int ans = 0 ; 
  for(int i=0;i<m;i++){
    long long int val = v[i].first ; 
    int cnt = v[i].second ; 
    while(!pq.empty() && cnt > 0){
       long long int chk = pq.top() ;
        
       if(chk < val){
          ans += val ;
         pq.pop() ;
         cnt-- ; 
       }
      else{
        break ; 
      }
    }
  }
  while(!pq.empty()){
   // cout<<pq.top(
     ans += (long long int)pq.top() ; 
     pq.pop() ; 
  }
  cout<<ans<<"\n" ; 
}

Measured memory_bytes: 1784
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    lst = [0 for _ in range(10**6+1)]
    a.sort()
    cnt = 0
    st = set()

    for i in a:
        if lst[i] == -1:
            pass
        elif lst[i] == 0:
            cnt += 1
            lst[i] = 1
            time = 10**6//i
            for j in range(2,time+1):
                lst[i*j] = -1
        elif lst[i] == 1:
            st.add(i)
    
    ans = cnt - len(st)
    print(ans)
main()            


Measured memory_bytes: 169700
if __name__ == '__main__':


    while True:

        sign = int(raw_input())
        if sign == 0:
            break

        num = int(raw_input())

        time = 0
        for i in xrange(num):

            a,b = map(int, raw_input().split(' '))
            time += b - a

        jug = sign - time
#        print 'jug,sign,time'
#        print jug,sign,time
        if jug <= 0:
            print 'OK'

        else:
            print jug

Measured memory_bytes: 4212
N = int(input())
A, B = map(int, input().split())
P = [i for i in map(int, input().split())]

P.sort()


p_1 = list(filter(lambda x: x<=A, P))
p_2 = list(filter(lambda x: A < x <= B, P))
p_3 = list(filter(lambda x: B <x, P))

print(min(len(p_1), len(p_2), len(p_3)))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << 1 << endl;
    else if (a == b || b == c || a == c)
        cout << 2 << endl;
    else
        cout << 3 << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map (read :: String -> Int) . words <$> getLine
  strs <- replicateM h getLine
  let headder = replicate w '#'
  let ans = solve (headder : strs)
  mapM_ putStrLn ans
  putStrLn $ headder++"##"

solve :: [String] -> [String]
solve = map  (f. f)
  where
    f = (:) '#' . reverse


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

int main(void)
{
	int n, m, a, b, c, d;
	int data[25][25];
	int start, end, money, price;
	
	for (int i = 0; i < 25; i++){
		for (int j = 0; j < 25; j++){
			data[i][j] = 10000000;
		}
	}
	
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		data[a][b] = c;
		data[b][a] = d;
	}
	scanf("%d,%d,%d,%d", &start, &end, &money, &price);
	
	for (int k = 1; k <= n; k++){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				data[i][j] = min(data[i][j], data[i][k] + data[k][j]);
			}
		}
	}
	
	cout << money - (price + data[start][end] + data[end][start]) << endl;
	
	return 0;
}

Measured memory_bytes: 0
N,K = map(int, input().split())
H = list(map(int, input().split()))
L = [0]*N
for i in range (1,N):
  L[i] = min(L[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i,K)+1))
print(L[N-1])

Measured memory_bytes: 85400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mx INT_MAX
#define mn INT_MIN
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define itr set<int> :: iterator
const int N = 1e5+10;

int dp[3001][3001];

string solve(string s1, string s2, int n, int m){
    
    if(n==0 || m==0)
        return "";

    // if(dp[n][m]!= "")
    //     return dp[n][m];

    if(s1[n-1]==s2[m-1]){
        return solve(s1, s2, n-1, m-1) + s1[n-1];
       // return dp[n][m];
    }else{
        string l =  solve(s1, s2, n-1, m);
        string r = solve(s1, s2, n, m-1);
        if(l.length() > r.length()){
           // dp[n][m] = l;
            return l;
        }
        else{
           // dp[n][m] = r;
            return r;
        }
    }

    return "";
}

int main(){

    // ******* START HERE ******
    
    string s1, s2;
    cin>>s1>>s2;

    int n = s1.length();
    int m = s2.length();
    
    for(int i=0; i<=n; i++) dp[i][0]= 0;
    for(int i=0; i<=m; i++) dp[0][i] = 0;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s1[i-1] == s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else{
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }
   
   int x = n;
   int y = m;
   string res = "";
    while(x!=0 && y!=0){
       if(dp[x-1][y] == dp[x][y]){
        x--;
       }else if(dp[x][y-1] == dp[x][y]){
        y--;
       }else{
        res = s1[x-1] + res;
        x--; y--;
       }
    }
    
    cout<<res<<endl;

    // ***** END HERE ***** 
    return 0;
}

Measured memory_bytes: 38776
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int A,B;
	cin>>A>>B;
	if(A>=13){
		cout<<B<<endl;
	}else if(A>=6){
		cout<<B/2<<endl;
	}else{
		cout<<0<<endl;
	}
}

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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  int count = 0;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> a[i][j];
      if(a[i][j] == '#') {
	count++;
      }
    }
  }

  if(h + w - 1 < count) {
    cout << "Impossible" << endl;
  }
  else {
    cout << "Possible" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MAX = 999999;
const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

int dp[100100];

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;

    dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1;
    for (int i = 106; i <= 100001; ++i) {
        if (! dp[i - 100] && ! dp[i - 101] && ! dp[i - 102] && ! dp[i - 103] && ! dp[i - 104] && ! dp[i - 105]) dp[i] = 0;
        else dp[i] = 1;
    }

    if (dp[x]) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << a * (n / (a + b)) + min(a, n % (a + b)) << endl;
}


Measured memory_bytes: 256
program average_length
    implicit none
    integer(4):: n, dn
    integer(4),allocatable:: p(:,:)
    integer(4):: i,j,k
    real(8), allocatable:: d(:)

    read*, n
    dn = n*(n-1)/2
    allocate(p(2,n))
    allocate(d(dn))
    do i=1, n
        read*, p(:,i)
    end do

    block; integer(4):: c=1, x1, y1
    do i=1,n-1
        x1 = p(1,i)
        y1 = p(2,i) 
        do j=i+1,n
            d(c) = sqrt(dble(((x1-p(1,j))*(x1-p(1,j))) + (y1-p(2,j))*(y1-p(2,j))))
            c=c+1
        end do
    end do
    end block

    print*, sum(d(:))*2/dble(n)
end program average_length

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

const int nax = 1e5 + 5;
int freq[nax];
int dp[nax];

int main(){
		
	for(int i = 0; i < nax; ++i){
		freq[i] = 0;
		dp[i] = 0;
	}

	int n,k;
	cin >> n >> k;

	int arr[n];
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
		freq[arr[i]] = 1;		
		dp[arr[i]] = 1;
	}

    sort(arr,arr + n);

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

    cout << (dp[k] == 1 ? "First" : "Second");      	
 	
	return 0;
}

Measured memory_bytes: 1152
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint v[58],ma[58];
lint co[58][58];
int main()
{
	rep(i,55){
		co[i][0]=co[i][i]=1;
		REP(j,1,i) co[i][j]=co[i-1][j]+co[i-1][j-1];
	}
	
	int n,a,b;
	
	lint out=0;
	cin>>n>>a>>b;
	rep(i,n) cin>>v[i];
	sort(v,v+n);reverse(v,v+n);
	ma[0]=0;
	rep(i,n) ma[i+1]=ma[i]+v[i];
	
	lint ms=0,mn=58;
	REP(i,1,n+1){
		if(i<a || i>b) continue;
		if(ms*i<mn*ma[i]) ms=ma[i],mn=i;
	}
	REP(i,1,n+1){
		if(i<a || i>b) continue;
		if(ms*i!=mn*ma[i]) continue;
		int x=0,y=0;
		rep(j,n){
			if(v[j]==v[i-1]){
				x++;
				if(j<i) y++;
			}
		}
		out+=co[x][y];
	}
	printf("%.12f\n",1.0*ms/mn);
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i,j=0;
	int r,c,n;
	long t;
	
	scanf("%d %d",&r,&c);
	
	long sum[c];
	
	for(i=0;i<c;i++) sum[i]=0;
	
	
	for(i=0;i<r;i++){
		t=0;
		for(j=0;j<c;j++){
			scanf("%d",&n);
			sum[j] += n;
			t += n;
		printf("%d ",n);
		
		}
		
		printf("%ld\n",t);
	}
	
	t=0;
	for(i=0;i<c;i++){
		printf("%ld ",sum[i]);
		
		t += sum[i];
	}
	
	printf("%ld\n",t);
	
	return 0;
}


Measured memory_bytes: 2108
import std.stdio;

void main(){
	int n,m;
	while(readf("%d\n",&n),n) {
		int[7] ans;
		foreach(i; 0..n){
			readf("%d\n",&m);
			if (m>60) m=60;
			ans[m/10]++;
		}
		foreach (i;ans) writeln(i);
	}
}

Measured memory_bytes: 984
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
int N;
ll dp[maxn];
void solve(){
	dp[0] = 1;
	for(int i = 3;i<=N;i++){
		for(int j = 3;i-j>=0;j++){
			dp[i] = (dp[i] + dp[i-j])%mod;
		}
	}
	printf("%lld\n",dp[N]);
}	
int main(){
	// debug;
	
	read(N);
	solve();
	
	return 0;
}


Measured memory_bytes: 3744
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        mut n: usize,
    }
    let mut prime_factors = vec![];
    let mut d = 2;
    while n > 1 {
        if d * d > n {
            break;
        }
        while n % d == 0 {
            prime_factors.push(d);
            n /= d;
        }
        d += 1;
    }
    if n > 1 {
        prime_factors.push(n);
    }
    eprintln!("{:?}", prime_factors);

    let mut count = HashMap::new();
    for &f in &prime_factors {
        *count.entry(f).or_insert(0) += 1usize;
    }
    eprintln!("{:?}", count);

    let mut result = 0;
    for &c in count.values() {
        let mut s = 0;
        for j in 1.. {
            s += j;
            if s > c {
                result += j - 1;
                break;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 2184
package main

import(
  "fmt"
)

func main() {
  var n, m int
  fmt.Scan(&n, &m)
  
  ans := 0
  
  if n >= 2 {
    ans += n*(n-1)/2
  }
  
  if m >= 2 {
    ans += m*(m-1)/2
  }
  
  fmt.Print(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=2000+5;
bitset<N> L[N],R[N],a[N];
signed main(){
	int n;char ch;
	cin>>n;
	for(int i=2;i<=n;++i)
		for(int j=1;j<i;++j){
			cin>>ch;
			a[i][j]=ch-'0';
			a[j][i]=(ch-'0')^1;
		}
	for(int i=1;i<=n;++i)
		L[i][i]=R[i][i]=1;
	for(int len=2;len<=n;++len)
		for(int i=1;i+len-1<=n;++i){
			int j=i+len-1;
			L[j][i]=(L[j]&R[i+1]&a[i]).count()!=0;
			R[i][j]=(L[j-1]&R[i]&a[j]).count()!=0;
		}
	int ans=0;
	for(int i=1;i<=n;++i)
		ans+=(L[n][i] & R[1][i]);
	cout<<ans;
	return 0;
}

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

const long long MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        //ビット積
        if (n & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long combi(long long n, long long r){
	long long X = 1, Y = 1;
	
	for (long long i = n; i >= n - r + 1; i--){
		X = (X * i) % MOD;
	}
	for (long long i = r; i >= 1; i--){
		Y = (Y * i) % MOD;
	}
	return (X * modpow(Y, MOD - 2,MOD)) % MOD;
}

int main(){
    long long a , b , n;
    cin >> n >> a >> b ;
    
    long long ans = modpow(2, n, MOD) - 1;

	ans = (ans + MOD - combi(n, a)) % MOD;
	ans = (ans + MOD - combi(n, b)) % MOD;
 
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  
  string S;
  cin >> S;
  
  ll max = 0;
  for (int start=0;start<n;start++){
    ll A[n];
    fill(A, A+n, 0);
    //A[0] = n;
    //cout << S[start] << " ";
      
    int i = start+1;
    int j = 0;
    while (i < n) {
      //cout << start << endl;
      while (i+j < n && S[j+start] == S[i+j]) ++j;
      A[i] = j;
      if (j == 0) { ++i; continue;}
      int k = 1;
      while (i+k < n && k+A[start+k] < j) A[i+k] = A[start+k], ++k;
      i += k; j -= k;
    }
  
    for (int ii=0;ii<n;ii++){
      //cout << A[ii] << " ";
      if (A[ii] > ii-start) A[ii] = ii-start;
      if (A[ii] > max) max = A[ii];
    }
    //cout << endl;
  }
  
  cout << max << endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
const ll mod = 1000000007;
vector<ll> inv, FactorialInv, Factorial;
ll beki(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll dp[3000][3000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination(5000000);
    ll N, K;
    cin >> N >> K;
    if(K == 1) {
        cout << 1 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            dp[i][j] += combination(i-1+(K-1)*(j-1)+K-2, K-2) * (dp[i][j-1]);
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod;
        }
        for(int j = 0; j < i; j++) dp[i][j] = 0;
        for(int j = 1; j <= N; j++) {
            //cerr << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    ll ans = dp[N][N] * Factorial[N] % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 164224