akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N,K;
	std::cin >> N >> K;
	std::vector<bool> v;
	v.resize(N);
	for ( int i = 0 ; i < K ; i++ ) {
		int d;
		std::cin >> d;
		for ( int ii = 0 ; ii < d ; ii++ ) {
			int A;
			std::cin >> A;
			v[A-1] = true;
		}
	}
	std::cout << N-std::count(v.begin(),v.end(),true) << std::endl;
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
blist = list(map(int, input().split()))
ans = []
for i in range(N):
    for index in range(N-i-1, -1, -1):
        if blist[index] == index + 1:
            ans.append(blist.pop(index))
            break
    else:
        print(-1)
        break
else:
    for num in ans[::-1]:
        print(num)


Measured memory_bytes: 3060
N, M = map(int, input().split())
MOD = 10**9 + 7
exist = [1 for _ in range(N+2)]
for _ in range(M):
    exist[int(input())] = 0
dp = [0 for _ in range(N+2)]
dp[0], dp[1] = 1, exist[1]
for i in range(2, N+1):
    if exist[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N])

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, s = 0, t = 0, tmp;
  cin >> n;
  v1i v(n);
  rep(i, n){
    cin >> v[i];
    s += v[i];
    if(i % 2 == 1) t += v[i];
  }
  rep(i, n){
    if(i == 0){
      tmp = s - 2 * t;
      cout << tmp << " ";
    }
    else{
      tmp = v[i-1]*2 - tmp;
      cout << tmp;
      if(i < n-1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}


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

int main() {
	double v;
	vector<int> r;
	while(scanf("%lf",&v) != EOF)
	{
		r.push_back(int(floor(v*v/98))+2);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

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

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rInt(a) scanf("%d",&a);

main(){
    int n,y;
    scanf("%d %d",&n,&y);
    y/=1000;
    rep(i,n+1) rep(j,n+1){
        if(i+j>n) continue;
        int k = n-i-j;
        int val = i*10 + j*5 + k;
        if(val==y){
            printf("%d %d %d\n",i,j,k);
            return 0;
        }
    }
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String str = S;
		String[] S1 = str.split("");
		int num1 = Integer.parseInt(S1[0]);
		int num2 = Integer.parseInt(S1[1]);
		int num3 = Integer.parseInt(S1[2]);
		int num4 = Integer.parseInt(S1[3]);
		int N1 = num1 * 10 + num2;
		int N2 = num3 * 10 + num4;
//		System.out.println(N1);
//		System.out.println(N2);
		
		if (1 <= N1 && N1 <= 12) {
			if (1 <= N2 && N2 <= 12) {
				System.out.println("AMBIGUOUS");
			} else {
				System.out.println("MMYY");
			}
		} else {
			if (1 <= N2 && N2 <= 12) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 20812
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

int main() { 
  int r, g, b;
  cin >> r >> g >> b;
  int sum = r*100 + g*10 + b;

  if (sum%4 == 0)
    puts("YES");
  else
    puts("NO");
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	string N_s = to_string(N);
	int S=0;
	for (int i = 0; i < N_s.size(); i++) {
		S += int(N_s[i] - '0');
	}
	if (N%S == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s, ss;
  while (getline(cin, ss))
    s += ss;
  int ans[26] = {};
  int n = s.size();
  rep(i, 0, n) {
    if (isalpha(s[i]))
      ans[tolower(s[i]) - 'a']++;
  }

  rep(i, 0, 26) { cout << (char)(i + 'a') << " : " << ans[i] << endl; }
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

int N,M;
int sum;

int main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int h;
        cin>>h;
        sum+=h;
    }
    if(N-sum>=0)cout<<N-sum<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3636
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))

Measured memory_bytes: 38256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n, t, i;

    long long T[200001];

    long long s = 0;
  
      
    scanf("%lld %lld", &n, &t );
   

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

         scanf("%lld", &T[i] );

         }
   

    if( n == 1 ) s = t;

    else if( n > 1 ){

             for( i = 0 ; i < n - 1 ; i = i + 1 ){

                  if( T[i + 1] - T[i] < t ){

                      s += T[i + 1] - T[i];

                      }

                  else s += t;
                  
                  }

          s += t;

          }

    printf("%lld\n", s );


    return 0;
                                                          
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);   
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    const int inf = 1e9+10;
    vector<int> dp(n, inf);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
            }
        }
    }
    cout << dp[n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    auto v = prime_factorize(N);
    ll ans = 0;
    for(auto itr=v.begin();itr!=v.end();itr++){
        int t=1;
        while(true){
            if(t*(t+1)/2 <= itr->second && itr->second < (t+1)*(t+2)/2) break;
            t++;
        }
        ans += t;
    }
    cout << ans << enld;
    return 0;
}

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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    string S;
    cin >> S;
    int res_int = 0;
    if (S == "MON") res_int = 6;
    if (S == "TUE") res_int = 5;
    if (S == "WED") res_int = 4;
    if (S == "THU") res_int = 3;
    if (S == "FRI") res_int = 2;
    if (S == "SAT") res_int = 1;
    if (S == "SUN") res_int = 7;
    cout << res_int << endl;
    return;
}

int main() {
    solve();
    return 0;
}

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

int a[20];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		int sum = 0;
		rep(i, n) {
			scanf("%d", &a[i]);
			sum += a[i];
		}
		int Min = INT_MAX;
		rep(i, 1 << n) {
			int cnt = 0;
			rep(j, n)if ((i >> j) & 1)cnt += a[j];
			Min = min(Min, abs(cnt - (sum - cnt)));
		}
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int dfs(string s, int N){
    if(stol(s) > N) return 0;

    int res = 0;
    int cnt3 = 0, cnt5 = 0, cnt7 = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '3') cnt3++;
        if(s[i] == '5') cnt5++;
        if(s[i] == '7') cnt7++;
    }
    if(cnt3 > 0 && cnt5 > 0 && cnt7 > 0) res++;

    res += dfs(s+'3', N);
    res += dfs(s+'5', N);
    res += dfs(s+'7', N);

    return res;
}


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

    cout << dfs("0", N) << endl;
}

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

typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	n -= (n/k) * k;
	cout<<min(n, k-n)<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,ll> type;
typedef pair<ll,type> event;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n,q; cin >> n >> q;
  vector<event> v;
  rep(i,n){
    int s,t,x; cin >> s >> t >> x;
    v.push_back({s-x,type(-1,x)}); //工事開始
    v.push_back({t-x,type(0,x)}); //工事終了
  }
  rep(i,q){
    int d; cin >> d;
    v.push_back({d,type(1,i)});//クエリ
  }
  sort(v.begin(),v.end());
  
  vector<ll> res(q);
  multiset<ll> se;
  for(auto p:v){
    ll x = p.first; //時間
    int ty = p.second.first; //イベントタイプ
    ll val = p.second.second; //value
    if(ty == -1) se.insert(val); //開始イベントなら
    else if (ty == 0) se.erase(se.lower_bound(val)); //終了イベントなら
    else res[val] = (se.empty() ? -1: *(se.begin())); //クエリイベントなら
  }
  for(auto v:res) cout << v << endl;
  return 0;
}

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

int main() {
	string S;

	cin >> S;
	if (S=="SSS") cout << 0 << endl;
	else if (S=="SSR") cout << 1 << endl;
	else if (S=="SRS") cout << 1 << endl;
	else if (S=="RSS") cout << 1 << endl;
	else if (S=="RSR") cout << 1 << endl;
	else if (S=="RRS") cout << 2 << endl;
	else if (S=="SRR") cout << 2 << endl;
	else cout << 3 << endl;

	return 0;
}


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

using namespace std;

using ll = long long;

int Solve() {
    string s;
    cin >> s;
    for (int i = s.size() - 2; 0 < i; i -= 2) {
        string t = s.substr(0, i);
        int size = t.size();
        if (t.substr(0, size / 2) == t.substr(size / 2, size / 2))
            return size;
    }
    return 0;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

N, M = map(int, input().split())
A = list(map(int, input().split()))
B_C = [list(map(int, input().split())) for _ in range(M)]

A = sorted(A)
B_C = sorted(B_C, key=lambda x: x[1])[::-1]
itr = 0
for b_c in B_C:
    for i in range(itr, N):
        itr = i
        if b_c[1] < A[i] or b_c[0] == 0:
            break
        if A[i] < b_c[1] and 0 < b_c[0]:
            A[i] = b_c[1]
            b_c[0] -= 1
print(sum(A))
   

Measured memory_bytes: 33736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int S = Integer.parseInt(str);

		//		Watch1 w1 = new Watch1();
		//		String x = w1.henkan(h,m,s);
		System.out.println(S / 3600 + ":" + (S % 3600) / 60 + ":" + (S % 3600) % 60);
	}

}



Measured memory_bytes: 24448
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}


Measured memory_bytes: 5196
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

const int MAXN = 1e5+10;

struct _Point {
  llint cost;
  int idx;
  int x, y;
  _Point () {}
  _Point (int _idx, int _x, int _y) {
    idx = _idx;
    x = _x;
    y = _y;
  }
  friend bool operator < (const _Point &A, const _Point &B) {
    return A.cost > B.cost;
  }
};

bool bio[MAXN];

int n;

vector<_Point> P;
vector<int> G[MAXN];

priority_queue<_Point> pq;

inline int get_dist(const _Point &A, const _Point &B) {
  return min(abs(A.x - B.x), abs(A.y - B.y));
}

inline bool cmp_x(const _Point &A, const _Point &B) {
  return A.x < B.x;
}

inline bool cmp_y(const _Point &A, const _Point &B) {
  return A.y < B.y;
}

inline bool cmp_id(const _Point &A, const _Point &B) {
  return A.idx < B.idx;
}

llint prim() {
  llint sol = 0;
  P[0].cost = 0;
  pq.push(P[0]);
  while (!pq.empty()) {
    while (!pq.empty() && bio[pq.top().idx]) pq.pop();
    if (pq.empty()) break;

    _Point curr = pq.top();
    pq.pop();
    bio[curr.idx] = true;
    sol += (llint) curr.cost;

    for (int nxt : G[curr.idx]) {
      if (bio[nxt]) continue;
      _Point _nxt = P[nxt];
      _nxt.cost = get_dist(P[curr.idx], P[nxt]);
      pq.push(_nxt);
    }
  }
  return sol;
}

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    P.emplace_back(i, x, y);
  }

  sort(P.begin(), P.end(), cmp_x);
  for (int i = 0; i < P.size() - 1; ++i) {
    G[P[i].idx].push_back(P[i + 1].idx);
    G[P[i + 1].idx].push_back(P[i].idx);
  }

  sort(P.begin(), P.end(), cmp_y);
  for (int i = 0; i < P.size() - 1; ++i) {
    G[P[i].idx].push_back(P[i + 1].idx);
    G[P[i + 1].idx].push_back(P[i].idx);
  }

  sort(P.begin(), P.end(), cmp_id);
  printf("%lld\n", prim());

  return 0;
}



Measured memory_bytes: 13936
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0, sum = 0;
string s = ""; asas; cncn;

int main(void) {
	int k, sum;
	cin >> k >> sum;
	for (int i = 0; i <= k; i++) {
		for (int j = 0;j <= k; j++) {
			if (k >=sum-( i + j )&& 0 <= sum - (i + j))cnt++;
		}
	}
	cout << cnt << rt;
	please AC;
}

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

int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string ans;
    rep(i,n) {
        putchar(s[i]);
        putchar(t[i]);
    }
    putchar('\n');
}

Measured memory_bytes: 3568
package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)
	ans := 1
	for i := 2; i <= X; i++ {
		for j := 2; j <= X; j++ {
			num := int(math.Pow(float64(i), float64(j)))
			if num > X {
				break
			} else if num > ans {
				ans = num
			}
		}
	}
	fmt.Println(ans)
}


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

vector<int> graph[100005];
int col[100005];
int cnt[3];
bool bipartite;

long long ans;

void dfs(int t)
{
    cnt[col[t]]++;
    for (int nxt : graph[t])
    {
        if (col[nxt])
        {
            if (col[nxt] == col[t]) bipartite = false;
            continue;
        }
        col[nxt] = col[t] ^ 3;
        dfs(nxt);
    }
}

int main()
{
    int n, m;
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d",&a,&b);
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    for (int i = 1; i <= n; i++)
    {
        if (col[i]) continue;
        cnt[1] = cnt[2] = 0;
        bipartite = true;
        col[i] = 1;
        dfs(i);

        if (bipartite) ans += cnt[1] * 1LL * cnt[2];
        else ans += (cnt[1] + cnt[2]) * 1ll * (cnt[1] + cnt[2] - 1) / 2;
    }

    printf("%lld\n", ans - m);
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long N = in.nextLong();
		long Y = in.nextLong();
		Boolean flag = true;
		for(int i=0;i<=N;i++) {
			for(int j=0;j<=N-i;j++) {
				Long ans=10000*i+5000*j+1000*(N-i-j);
				if(ans==Y) {
					System.out.println(String.format("%d %d %d",i ,j,(N-i-j)));
					flag= false;
					break;
				}

			}
			if(!flag) {
				break;
			}
		}
		if(flag) {
			System.out.println("-1 -1 -1");
		}
		
	}
}

Measured memory_bytes: 27988
A, B, C, D = gets.split.map(&:to_i)

num = B - A + 1

a1 = B / C
a2 = (A - 1) / C
a3 = a1 - a2

b1 = B / D
b2 = (A - 1) / D
b3 = b1 - b2

lcm = C.lcm(D)

c1 = B / lcm
c2 = (A - 1) / lcm
c3 = c1 - c2

puts num - (a3 + b3 - c3)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    string temp;
    while(cin >> temp, temp[0] != '#'){
        string inp;
        rep(i,temp.size()){
            if(temp[i] == 'n' or temp[i] == 'w'){
                inp+=temp[i];
            }
        }

        int sum, k = 1;
        rep(i,inp.size()) k *= 2;
        for(int i = inp.size() - 1; i >= 0; i--){
            if(i == inp.size() - 1){
                if(inp[i] == 'n') sum = 0;
                else sum = 90 * k;
            }else{
                k/=2;
                if(inp[i] == 'n') sum-=90 * k;
                else sum+=90 * k;
            }
        }
        rep(i,inp.size() - 1) k *= 2;
        while(sum % 2 == 0 && k % 2 == 0){
            sum/=2;
            k/=2;
        }
        if(k == 1) cout << sum << endl;
        else cout << sum << '/' << k << endl;
    }
}

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

long gcd(long a, long b){
    if(b > 0){
        return gcd(b, a % b);
    }else{
        return a;
    }
}

long lcm(long a, long b){
    return (a * b / gcd(a, b));
}

int main()
{
    long a, b;
    
    while(cin >> a >> b){
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    } 
    
    return 0;
}

Measured memory_bytes: 1160
R, L = gets.chomp.split(' ').map(&:to_i)
ans = 2019
if R - L >= 2019
  ans = 0
else
  RR = R
  count = 0
  while RR <= L
    if RR == R
      RR += 1
      count += 1
      next
    end
    count.times do |c|
      ans = [(R + c) * RR % 2019, ans].min
      #   puts "ans:#{(R + c) * RR % 2_019}"
    end
    RR += 1
    count += 1
    break if ans == 0
  end
end
puts ans


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1; i<=N; i+=2) {
    int sum = 0;
    for(int j=1; j<=i; j++) {
      if(i % j == 0) sum++;
    }
    if(sum == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let mut h: u64 = input();
    let mut n = 1u64;
    let mut sum = 0;
    while (h > 0) {
        // println!("{}, {}", h, n);
        h /= 2;
        sum += n;
        n *= 2;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MOD = 1e9 + 7;
ll fact[1000006];

ll power(ll x,ll y){
    ll res = 1;

    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}

ll invmod(ll x){
    return power(x,MOD-2);
}

void solve(){   

    fact[0] = 1;
    FOR(i,1,1000000) fact[i] = (fact[i-1]*i)%MOD;

    ll n,a,b,c; cin>>n>>a>>b>>c;

    a = a*invmod(100)%MOD;
    b = b*invmod(100)%MOD;
    c = c*invmod(100)%MOD;

    ll i_c = ((1-c)%MOD+MOD)%MOD;
    ll con = (invmod(i_c))%MOD;

    ll temp = invmod(a+b);

    a = (a*temp)%MOD;
    b = (b*temp)%MOD;

    ll ans = 0;
    FOR(m,n,2*n-1){
        ll temp_1 = (fact[m-1]*invmod(fact[n-1]))%MOD;
        temp_1 = (temp_1*invmod(fact[m-n]))%MOD;

        ll temp_2 = (power(a,n)*power(b,m-n))%MOD;
        temp_2 = (temp_2 + (power(a,m-n)*power(b,n))%MOD)%MOD;

        temp_2 = (temp_2*m)%MOD;
        temp_2 = (temp_2*con)%MOD;
        temp_1 = (temp_1 * temp_2)%MOD;

        ans = (ans+temp_1)%MOD;
    }

    cout<<ans<<endl;
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 8192
from operator import attrgetter

class City:
    def __init__(self, index, p, year):
        self.index = index
        self.p = p
        self.year = year
        self.rank = 0

n, m = [int(v) for v in input().split()]
city_list = []
for i in range(m):
    p, y = [int(v) for v in input().split()]
    city_list.append(City(i, p, y))

city_list.sort(key=attrgetter('p', 'year'))

p = 1
rank = 0
for i in range(m):
    if city_list[i].p != p:
        p = city_list[i].p
        rank = 1
    else:
        rank += 1
    city_list[i].rank = rank

city_list.sort(key=attrgetter('index'))

for city in city_list:
    print('{0:0>6}{1:0>6}'.format(city.p, city.rank))

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n;
    cin >> n;
    vi a(n);
    vi freq(maxn);
    int sum = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
        freq[a[i]]++;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        int f = freq[b];
        sum += f*(c - b);
        freq[c] += f;
        freq[b] -= f;
        cout << sum << "\n";
    }
    return 0;
}



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

int main()
{
    string s,t;
    int i,j;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();

    vector<vector<int>>dp(n+1,vector<int>(m+1,0));
    string p="";

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

            if(dp[i-1][j]>dp[i][j-1])i=i-1;
            else j=j-1;

        }
    }
    reverse(p.begin(),p.end());
    cout<<p<<endl;

}


Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int q; cin >> q;
    string ad[2];
    bool dir = false;
    rep (_, q) {
        int comm; cin >> comm;
        if (comm == 1) dir ^= true;
        else {
            int f; char c; cin >> f >> c;
            ad[(f - 1) ^ dir] += c;
        }
    }
    eprintf("0:%s 1:%s\n", ad[0].c_str(), ad[1].c_str());
    if (dir == false) {
        reprev (i, ad[0].size()) cout << ad[0][i];
        cout << s;
        cout << ad[1] << "\n";
    } else {
        reprev (i, ad[1].size()) cout << ad[1][i];
        reprev (i, s.size()) cout << s[i];
        cout << ad[0] << "\n";        
    }
    return 0;
}

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

void solve(long long N, long long C, long long K, std::vector<long long> T) {
    sort(T.begin(), T.end());
    ll ans = 1;
    ll beforeT = T[0];
    ll beforeC = 1;
    for (ll i = 1; i < N; i++) {
        if (((T[i] - beforeT) > K) || ((beforeC + 1) > C)) {
            ans++;
            beforeT = T[i];
            beforeC = 1;
        } else {
            beforeC += 1;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> T(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &T[i]);
    }
    solve(N, C, K, std::move(T));
    return 0;
}


Measured memory_bytes: 4028
#include<stdio.h>
#include<math.h>

int main(){

  double r;
  double l,s;

  double PI=acos(-1);
  scanf("%lf",&r);

  l=2*PI*r;
  s=PI*r*r;

  printf("%lf %lf\n",s,l);
  return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int left = a+b;
  int right = c+d;
  if(left > right){
    cout << "Left" << endl;
  }else if (left == right){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import deque

n = getN()
paths = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = getList()
    paths[a-1].append((b-1,c))
    paths[b-1].append((a-1,c))

def findroot(tree):
    for i, v in enumerate(tree):
        if len(v) == 1:
            return i

root = findroot(paths)


def getdist(tree, root):
    d = deque([root])
    dist = [-1 for i in range(len(tree))]
    dist[root] = 0
    while(d):
        #print(d, dist)
        nxt = d.pop()
        tmp = dist[nxt]
        for edge in tree[nxt]:
            v, c = edge
            if dist[v] == -1:
                d.append(v)
                dist[v] = tmp + c

    return dist

distlist = getdist(paths, root)
for i in distlist:
    print(i % 2)

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  
  if ( A + B < C ){
    cout << A * X + B * Y << endl;
  }
  else if ( X >= Y ){
    if ( A >= C ){
      cout << C * X << endl;
    }
    else{
      cout << ( X - Y ) * A + C * Y << endl;
    }
  }
    else if( B >= C ){
        cout << Y * C << endl;
      }
      else{
        cout << X * C + ( Y - X ) * B << endl;
      }
}
 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;

signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  rep(i,n)a[i]*=2;
  auto it=upper_bound(ALL(a),a[n-1]/2);
  int first=*it;
  --it;
  if(first*2-a[n-1]>=-*it*2+a[n-1]){
    first=*it;
  }
  cout<<a[n-1]/2<<" "<<first/2<<"\n";

  return 0;
}


Measured memory_bytes: 1024
h,w = map(int,input().split())
board = []
checkColumn = [False]*h
checkRow = [False]*w
for i in range(h):
    board.append(input())

for i in range(h):
        for j in range(w):
            if board[i][j] == "#":
                checkColumn[i] = True
                checkRow[j] = True
for i in range(h):
    if checkColumn[i]:
        for j in range(w):
            if checkRow[j]:
                print(board[i][j],end="")
        print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

int main(){
	int a, b, c; cin >> a >> b >> c;
	int d = (a%2 + b%2 + c%2);
	
	int ans = 0;
	if(d==1||d==2){
	    if(d==1){
	        if(a%2==0)a++;
	        if(b%2==0)b++;
	        if(c%2==0)c++;
	    }else if(d==2){
	        if(a%2==1)a++;
	        if(b%2==1)b++;
	        if(c%2==1)c++;
	    }
	    ans++;
	}
	int mx=max({a,b,c});
	ans += (mx-a)/2 + (mx-b)/2 + (mx-c)/2;
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) begin(x),end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << " " <<
using namespace std;
using ll=long long;

const int MXN=100005;

int n;
ll dp[20005];

struct block{
  int w,s,v;
}a[1005];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;++i){
    scanf("%d",&a[i].w);
    scanf("%d",&a[i].s);
    scanf("%d",&a[i].v);
  }
  sort(a,a+n,[](block a,block b){
    if(a.s+a.w==b.s+b.w)return a.v<b.v;
    return a.s+a.w<b.s+b.w;
  });
  for(int i=0;i<n;++i)
    for(int j=a[i].w+a[i].s;j>=a[i].w;--j)
      dp[j]=max(dp[j],dp[j-a[i].w]+a[i].v);
  printf("%lld\n",*max_element(dp,dp+20001));
}


Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve :: VU.Vector Int -> Int -> Int -> Double
solve xs n k = maximum $ [f i | i<-[k..n]]
  where
    f i = (table VU.! i) - (table VU.! (i-k))
    zs = VU.zip xs xs 
    table :: VU.Vector Double
    table = VU.scanl' step 0.0 zs
    step acc (p,q) = acc + r
      where
        p' = fromIntegral $ p * (p+1) `div` 2
        q' = fromIntegral q
        r = p' / q'

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve xs n k


Measured memory_bytes: 6908
import fractions


n,m=map(int,input().split())
A=list(map(lambda x: int(x)//2,input().split()))

lcm=A[0]
for i in range(1,n):
    lcm=lcm*A[i]//fractions.gcd(lcm,A[i])

if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

ans=m//(2*lcm)
print(ans if (m//lcm)%2==0 else ans+1)

Measured memory_bytes: 16320
#!/usr/bin/env python3


def main():
    x = int(input())
    lank: int = 0
    if 400 <= x <= 599:
        lank = 8
    elif x <= 799:
        lank = 7
    elif x <= 999:
        lank = 6
    elif x <= 1199:
        lank = 5
    elif x <= 1399:
        lank = 4
    elif x <= 1599:
        lank = 3
    elif x <= 1799:
        lank = 2
    else:
        lank = 1
    print(lank)


if __name__ == "__main__":
    main()


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

int dig(int n)
{
    int i=0;

    while(n>0)
    {
       n/=10;
       i++;
    }

    return i;
}
int main()
{

    int a,b,n,s,i,j;
    scanf("%d %d",&a,&b);
    i=dig(a);
    j=dig(b);

    for(int x=0; x<j; x++)
    {
        a*=10;
    }

    n=a+b;
    s=sqrt(n);

    if(s*s==n) printf("Yes");
    else printf("No");

    return 0;
}






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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

int main()
{

    //freopen("input.txt", "r", stdin);

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

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

    if (n < 3) {
        cout << "0\n";
        return 0;
    }

    int x0 = (1 + 2 + 3 + 8 + 9 + 10 + 15 + 16 + 17) % 11;

    ll ans = 0;

    for (int d = 0; d < 11; ++d) {
        if (3 + d > n) {
            continue;
        }
        int s = (n - 3 - d) / 11;
        int x = (x0 + 63 * d) % 11;
        for (int j = 3; j <= 7; ++j) {
            if (x == k) {
                ans += ll(s + 1);
            }
            x = (x + 9) % 11;
        }
    }

    cout << ans << "\n";

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int N = Integer.parseInt(br.readLine());
			int[] F = new int[N];
			for (int i = 0; i < N; i++) {
				int[] array = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
				int value = 0;
				for (int j = 0; j < 10; j++) {
					value |= array[j] << j;
				}
				F[i] = value;
			}

			int[][] P = new int[N][11];

			for (int i = 0; i < N; i++) {
				P[i] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			}

			int max = Integer.MIN_VALUE;

			for (int mask = 1; mask <= 0b1111111111; mask++) {
				int value = 0;
				for (int i = 0; i < N; i++) {
					int order = mask & F[i];
					value += P[i][Integer.bitCount(order)];
				}
				max = Math.max(max, value);
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5;

bitset<N + 1> is_prime;

void gen() {
	is_prime.set();
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= N; ++i) {
		if(is_prime[i]) {
			for(int j = 2 * i; j <= N; j += i)
				is_prime[j] = false;
		}
	}
}

int cum[N + 1]{0};
int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	gen();
	for(int i = 1; i <= N; ++i) {
		cum[i] = cum[i-1];
		if(is_prime[i] && is_prime[(i + 1)/2]) ++cum[i];
	}
	int q;
	cin >> q;
	while(q--) {
		int l, r;
		cin >> l >> r;
		cout << cum[r] - cum[l-1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}


int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

    string s;
    cin >> s;
    if(s.size() % 2 == 1)
        cout << "No\n";
    else
    {
        bool ok = 1;
        for(int i = 0; i < s.size(); i += 2)
            if(s[i] != 'h' || s[i+1] != 'i')
                ok = 0;
        cout << (ok == 1? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    let c = io.chars()[0];
    let vowels = vec!['a', 'i', 'u', 'e', 'o'];
    if vowels.contains(&c) {
        io.writeln("vowel");
    } else {
        io.writeln("consonant");
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352