akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
#include<deque>
using namespace std;

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define vvi                vector<vector<int>>
#define mi                map<int,int>
#define pq                priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //for defining the precision of the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)      type *a=new type[n];
#define test(t)           int t; cin>>t; while(t--)
#define no                cout<<"No\n";
#define yes               cout<<"Yes\n";
#define NO                cout<<"NO\n";
#define YES               cout<<"YES\n";
//#define for(i,n)          for(int i=0;i<n;i++)
//#define for(j,n)          for(int j=0;j<n;j++)
// #define forn(i,n)               for(int i=0;i<n;i--)



//**********************************************************************************************************
struct custom_hash
{
  static uint64_t splitmix64(uint64_t x)
  {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

#define safemap               unordered_map<int,int,custom_hash>

//*********************************************************************************************************

void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);
}


int32_t main()
{
  int n, k, m, p, q, x, y;
  int small = INT_MIN;

  cin >> n >> k;
  
  int l[k] = {0};
  int r[k] = {0};

  for (int i = 0; i < k; i++)
    cin >> l[i] >> r[i];


//Now creating DP
// Now creating prefix array for storing the sum of all possible combinations to reach the cell ith

  vi dp(n + 1, 0);
  vi psum(n + 1, 0);

  dp[1] = 1;
  psum[1] = 1;

  int mood = 998244353;


  for (int i = 2; i <= n; i++)
  {
    for (int j = 0; j < k; j++)
    {
      if (i <= l[j])
        continue;

      int start = l[j];
      int end = min(i - 1, r[j]);

      int val = (psum[i - start] - psum[i - end - 1] + mood ) % mood;
      dp[i] = (val + dp[i]) % mood;

    }
    psum[i] = (dp[i] % mood + psum[i - 1] % mood) % mood;
  }

  cout << dp[n]  << "\n";


  return 0;
}


Measured memory_bytes: 6372
#include <stdio.h>

int main(void)
{
	int i, unit, num, total, numsum, numavr;
	
	total = 0;
	numsum = 0;
	numavr = 0;
	
	i = 0;
	while (scanf("%d,%d", &unit, &num) != EOF){
		total += unit * num;
		numsum += num;
		i++;
	}
	
	if (numsum % i != 0 && 2 * (numsum % i) >= i){
		numavr = 1;
	}
	
	numavr = numavr + numsum / i;
	
	printf("%d\n%d\n", total, numavr);
	
	return (0);
}

Measured memory_bytes: 588
A,B,K = map(int,input().split())
if 2*K >= B-A+1:
    for i in range(A,B+1):
        print(i)
else:
    for j in range(A,A+K):
        print(j)
    for v in range(B-K+1,B+1):
        print(v)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let mut c: Vec<u64> = (0..5).map(|_| 0).collect();

    for _ in 0..n {
        let tmp: Vec<char> = read::<String>().chars().collect();
        let s = tmp[0];
        match s{
            'M' => { c[0] += 1; },
            'A' => { c[1] += 1; },
            'R' => { c[2] += 1; },
            'C' => { c[3] += 1; },
            'H' => { c[4] += 1; },
            _ => (),
        }
    }

    let mut ret = 0;
    for i in 0..5 {
        for j in 0..i {
            for k in 0..j {
                ret += c[i] * c[j] * c[k];
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2192
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    H, W, K = map(int, input().split())
    c_list = [input() for i in range(H)]
    c_list_list = [ [(0 if c[j]=="." else 1) for j in range(W) ] for c in c_list]

    counter = 0
    for i in range(pow(2, H+W)):
        bin_i = format(i, "b").zfill(H+W)
        this_c_list_list = [c_list[:] for c_list in c_list_list]
        for row in range(H):
            if bin_i[row] == "1":
                this_c_list_list[row] = [0]*W
        for column in range(W):
            if bin_i[H+column] == "1":
                for j in range(H):
                    this_c_list_list[j][column] = 0
        sum_1 = sum([sum(c_list) for c_list in this_c_list_list])
        #print(this_c_list_list)
        if sum_1 == K:
            counter += 1
        #print(bin_i, sum_1)
    print(counter)

if __name__ == "__main__":
    main()



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

using namespace std;

const int INFTY = 1 << 30;
int n, m;
int d[21];
int dp[50001];

int main() {

	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		dp[i] = INFTY;
	for (int i = 0; i<m; i++) {
		cin >> d[i];
		dp[d[i]] = 1; //d[i]円にするのに何枚必要か.最初から与えられている金額であれば１枚.ｎ円以下のそのほかの金額にするには何枚必要か分からないので次で算出する。(初期ではINFIが入ってる）
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j<m; j++) {
			if (i - d[j] >= 0)
				dp[i] = min(dp[i], dp[i - d[j]] + dp[d[j]]);
			//i=3　３円を作るには、現状のINFI枚数のほうが最小か、1円と2円の2枚を使ったほうが最小枚数か比較する。3-1＝i-d[j]=2 すでに1円と2円にするのに必要な最小枚数は決まっているはず。
		}
	}

	//for(int i=0;i<=n;i++)
	//cout<<i<<": "<<dp[i]<<endl;
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3292
#include <stdio.h>
int main(){
  int inputNum;
  scanf("%d", &inputNum);
  int rest = inputNum % 10;
  if(rest == 3){
    printf("bon");
  }else if(rest == 0 || rest == 1 || rest == 6 || rest == 8){
    printf("pon");
  }else if(rest == 2 || rest == 4 || rest == 5 || rest == 7 || rest == 9){
    printf("hon");
  }
}


Measured memory_bytes: 1736
n = int(input())
a = []
b = []
for _ in range(n):
    aa, bb = list(map(int, input().split()))
    a.append(aa)
    b.append(bb)


import numpy as np

if n%2 == 0:
    print(int((np.median(b) - np.median(a)) / 0.5) + 1)
else:
    print(int((np.median(b) - np.median(a))) + 1)

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

class UnionFindTree {
  private:
    vector<int> par;   // 親
    vector<int> depth; // 木の深さ

  public:
    // n要素で初期化
    UnionFindTree(int n) {
        for (int i = 0; i < n; i++) {
            par.push_back(i);
            depth.push_back(0);
        }
    }

    // 木の根を求める
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (depth[x] < depth[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) { return find(x) == find(y); }
};

#include <algorithm>

// u,v : 始点と終点
struct Edge {
    int u, v, cost;
};

bool comp(const Edge &e1, const Edge &e2) { return e1.cost < e2.cost; }

vector<Edge> es;
int V, E; // 頂点数と辺数

int kruskal() {
    sort(es.begin(), es.end(), comp); // Edge.costが小さい順にソートする
    UnionFindTree uft = UnionFindTree(V); // Union-Findの初期化
    int res = 0;
    for (auto e : es) {
        if (!uft.same(e.u, e.v)) {
            uft.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


int main(){
    cin >> V >> E;
    for(int i=0;i<E;++i){
        int s, t, w;
        cin >> s >> t >> w;
        es.push_back((Edge){s, t, w});
    }

    cout << kruskal() << endl;

    return 0;
}



Measured memory_bytes: 4592
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

const ll N = 222222;
ll mp[N];
ll now[N];

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

	ll n, k;cin >> n >> k;
	REP(i, n)cin >> now[i];

	REP(_i_, k){
		REP(i, N)mp[i] = 0;
		REP(i, n){
			mp[max(0LL, i - now[i])]++;
			mp[min(N-1, i + now[i] + 1)]--;
		}
		REP(i, N-1)mp[i+1] += mp[i];
		ll mi = INF;
		REP(i, n){
			now[i] = mp[i];
			mi = min(mi, now[i]);
		}

		if(mi == n)break;
	}

	REP(i, n)cout << now[i] << " ";cout << endl;

	return 0;
}


Measured memory_bytes: 6964
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int dfs(string t){
	if(t.size()==0) return 0;
	if(t[0]=='0') return dfs(t.substr(1));
	int mn=1e8;
	char s=t[0];
	rep(i,t.size()){
		t[i]=(t[i]-s+10)%10+'0';
		mn=min(mn,dfs(t.substr(1)));
	}
	return mn+1;
}
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		string s,t;
		cin >> s >> t;
		rep(i,n) t[i]=(t[i]-s[i]+10)%10+'0';
		cout<<dfs(t)<<endl;
	}
}

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

int main(){
  int x; cin >> x;
  int a,b; cin >> a >> b;
  bool ans = false; 
  for(int i=0; i<=b; i+=x)
    if(i>=a) ans = true;
  if(ans) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
void DFS(int u);
int G=1,n,x[101][101],y[101]={0};
int d[101],f[101];

int main(void){
  int i,j,u,t,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      x[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&t);
    for(j=0;j<t;j++){
      scanf("%d",&v);
      x[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(y[i]==0){
      DFS(i);
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void DFS(int id){
  int v;
  d[id]=G++;
  y[id]=1;
  for(v=0;v<n;v++){
    if(x[id][v]==1&&y[v]==0){
      DFS(v);
    }
  }
  f[id]=G++;
}



Measured memory_bytes: 2104
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
D=[[]for i in range(N)]
for i in range(M):
  D[A[i][0]-1].append(A[i][1]-1)
  D[A[i][1]-1].append(A[i][0]-1)
a=len(D[-1])
b=len(D[0])
c=len(set(D[-1]+D[0]))
if a+b==c:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Measured memory_bytes: 87952
n = int(input())
arr = map(int,raw_input().split())

n4 = 0
n1 = 0
for i in arr:
	if i%4 == 0 :
		n4 += 1
	elif i%2 == 1:
		n1 += 1

if len(arr) - n4 - n1 > 0 :
	if n4 >= n1 :
		print "Yes"
	else :
		print "No"

else :
	if n4 >= n1 - 1:
		print "Yes"
	else :
		print "No"

Measured memory_bytes: 11320
N, M, Q = [int(i) for i in input().split()]
abcd = [[int(i) for i in input().split()] for _ in range(Q)]
ans = 0
ary = [1]*N
while True:
    cnt = 0
    for l in abcd:
        a, b, c, d = l
        if ary[b - 1] - ary[a - 1] == c:
            cnt += d
    ans = max(ans, cnt)
    ary[-1] += 1
    i = len(ary)-1
    try:
        while ary[i] > M:
            ary[i - 1] += 1
            i -= 1
    except IndexError:
        break
    i += 1
    while i < len(ary):
        ary[i] = ary[i - 1]
        i+=1
print(ans)

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

int next(int now, int s, int f) {
  if (now <= s)
    return s;
  else
    return (now + f - 1) / f * f;
}

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

  vector<int> C(N - 1), S(N - 1), F(N - 1);
  rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

  rep(i, N - 1) {
    int ans = 0;
    for (int j = i; j < N - 1; j++)
      ans = C[j] + next(ans, S[j], F[j]);
    cout << ans << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 int t=1;
    // cin>>t;
  while(t--){
   
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    int cnt=0;
    for(int i=0;i<n;i++){

        if(cnt==3){

            break;
        }
        if(v[i].first==v[i].second){
            cnt++;
        }else{
            cnt=0;
        }
    }
    if(cnt==3){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    
  }
}

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

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

    int sum = 0;
    int power_sum = 0;
    rep(i,n) {
        int d;
        cin >> d;
        sum += d;
        power_sum += d*d;
    }

    int ans = sum * sum - power_sum;
    ans /= 2;

    cout << ans << endl;

    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
typedef long long LL;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n;
  cin >> n;
  map <string, int> cnt;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  int mx = 0;
  for (auto x: cnt) {
    mx = max(mx, x.second);
  }
  for (auto x: cnt) {
    if (x.second == mx) cout << x.first << endl;
  }
  return 0;
}



Measured memory_bytes: 23808
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

bool str_comp(string s, string t) {
	if (s.size() != t.size()) return false;
	for (int i = 0; i < s.size(); i++) if (s[i] != t[i]) return false;
	return true;
}

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
	}
	if (n == 1) {
		cout << s[0] << endl;
		return 0;
	}
	sort(s.begin(), s.end());
	vector<int> poll(n, 0);
	int i = 0; int k = 1;
	while(k < n){
		if (str_comp(s[i], s[k])) {
			poll[i]++;
			k++;
		}
		else {
			i = k;
			k++;
		}
	}
	int mx = 0;
	rep(i, n) {
		if (poll[i] > mx) mx = poll[i];
	}
	rep(i, n) {
		if (poll[i] == mx) {
			cout << s[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int x, n;
  cin >> x >> n;
  set<int> p;
  rep(i, n) {
    int a; cin >> a;
    p.insert(a);
  }

  int ans = -100;
  int diff = INF;

  for (int i = -100; i <= 200; i++) {
    if (p.count(i) != 0) continue;
    if (abs(i - x) < diff) {
      ans = i;
      diff = abs(i - x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>

const int p=998244353;
const int N=3000000;

int fac[5000000],inv[5000000];
int i,m,n,s;

inline int power(int x,int y)
{
	int s=1;
	for (int i=30;i>=0;i--)
	{
		s=1LL*s*s%p;
		if ((1<<i)&y)
			s=1LL*s*x%p;
	}
	return s;
}

inline void pre_C()
{
	fac[0]=1;
	for (int i=1;i<=N;i++)
		fac[i]=1LL*fac[i-1]*i%p;
	inv[N]=power(fac[N],p-2);
	for (int i=N-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(i+1)%p;
	return;
}

inline int C(int x,int y)
{
	if ((y<0) || (y>x))
		return 0;
	else
		return 1LL*fac[x]*inv[y]%p*inv[x-y]%p;
}

int main()
{
	pre_C();
	scanf("%d%d",&n,&m);
	for (i=m;i<=m+m/2;i++)
		s=(s+1LL*C(i+n-1,n-1)*C(n,3*m-2*i))%p;
	for (i=m+1;i<=m+m/2;i++)
		s=(s-1LL*C(i-m+n-2,n-1)*C(n,3*m-2*i)%p*n%p+p)%p;
	for (i=m;i<=m+m/2;i++)
		s=(s-1LL*C(i-m+n-2,n-2)*C(n-1,3*m-2*i-1)%p*n%p+p)%p;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 27384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;


vi table(100010, 0);

void create(){
    for(ll i=1; i<100; i++){
        for(ll j=1; j<100; j++){
            for(ll k=1; k<100; k++){
                ll tmp = i*i+j*j+k*k+i*j+j*k+k*i;
                if(tmp > 10000) break;
                table[tmp]++;
            }   
        }    
    }
}

int main(){
    Init();
    ll n; cin >> n;
    create();
    repf(i, n) cout << table[i] << endl;
}

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

using ll = long long;

ll N;

ll digit(ll x) {
   ll ret = 0;
   while (x > 0) {
      ret++;
      x /= 10;
   }
   return ret;
}

ll F(ll A, ll B) {
   return max(digit(A), digit(B));
}

int main() {
   cin >> N;
   ll ans = 1e18;
   for (ll a = 1; a*a <= N; a++) {
      if (N % a == 0) {
         ans = min(ans, F(a, N/a));
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;

int main() {
    int grid[3][3];
    int a[3] = {0}, b[3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> grid[i][j];
        }
    }

    rep(i, 3) {
        b[i] = grid[0][i];
    }
    rep(i, 3) {
        a[i] = grid[i][0] - b[0];
    }

    rep(i, 3) {
        rep(j, 3) {
            if (grid[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,m,s,t,c4,c2,c1;
char ss[200];
int c[200];//char!!!!
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n){
		scanf("%s",ss+1);
		fo(j,1,m) c[ss[j]]++;
	}
	fo(i,'a','z'){
		c4+=c[i]/4;
		c[i]%=4;
		c2+=c[i]/2;
		c[i]%=2;
		c1+=c[i];
	}
	if (c1>1){
		printf("No\n");
		return 0;
	}
	s=n*m;
	t=(n/2)*(m/2);
	if (c4>=t){
		c4-=t;
		s-=t*4;
	}else{
		printf("No\n");
		return 0;		
	}
	c2+=c4*2;
	t=s/2;
	if (c2>=t){//>=
		c2-=t;
		s-=t*2;
	}else{
		printf("No\n");
		return 0;
	}
	c1+=c2*2;
	if (c1>s)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn factorial_2_prime_factorize(n: usize) -> HashMap<usize, usize> {
    let mut factors = HashMap::new();
    for i in 2..n + 1 {
        let mut a = 2;
        let mut temp_i = i;
        while a * a <= temp_i {
            while temp_i % a == 0 {
                let exp = factors.entry(a).or_insert(0);
                *exp += 1;
                temp_i /= a;
            }
            a += 1;
        }
        if temp_i != 1 {
            let exp = factors.entry(temp_i).or_insert(0);
            *exp += 1;
        }
    }
    factors
}
fn main() {
    let n: usize = read();
    let enums = factorial_2_prime_factorize(n);
    let mut ans = 1;
    for (_, v) in enums {
        ans *= v + 1;
        ans %= 1000_000_000 + 7;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2124
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    int[] primes = primes(1_000_001);
    Map<Integer, Integer> lcm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      Map<Integer, Integer> factors = primeFactors(A[i], primes);
      for (Map.Entry<Integer, Integer> e : factors.entrySet()) {
        lcm.put(e.getKey(), Math.max(e.getValue(), lcm.getOrDefault(e.getKey(), 0)));
      }
    }

    long AB = 1;
    for (Map.Entry<Integer, Integer> e : lcm.entrySet()) {
      AB *= modpow(e.getKey(), e.getValue(), M);
      AB %= M;
    }
    long sum = 0;
    for (int i = 0; i < N; i++) {
      sum += AB * inverse(A[i], M) % M;
      if (sum >= M) sum -= M;
    }
    System.out.println(sum);
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }

  public static int[] primes(int n) {
    boolean[] isNotPrime = new boolean[n + 1];
    isNotPrime[0] = isNotPrime[1] = true;
    for (int i = 2; i < Math.sqrt(n); i++) {
      if (!isNotPrime[i]) {
        for (int j = 2; i * j <= n; j++) {
          isNotPrime[i * j] = true;
        }
      }
    }
    final List<Integer> ls = new ArrayList<>();
    for (int i = 2; i <= n; i++) if (!isNotPrime[i]) ls.add(i);
    int[] res = new int[ls.size()];
    for (int i = 0; i < ls.size(); i++) res[i] = ls.get(i);
    return res;
  }

  public static Map<Integer, Integer> primeFactors(int n, int[] primes) {
    Map<Integer, Integer> map = new HashMap<>();
    for (int p : primes) {
      if (p * p > n) break;
      while (n % p == 0) {
        map.put(p, map.getOrDefault(p, 0) + 1);
        n /= p;
      }
    }
    if (n > 1) map.put(n, 1);
    return map;
  }
}


Measured memory_bytes: 46016
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        # print(i, th, bus_cnt, person_cnt)
        if i <= th:
            if person_cnt + 1 > c:
                bus_cnt += 1
                th = i + k
                person_cnt = 1
            else:
                person_cnt += 1
        else:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
    print(bus_cnt)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 8240
#include <bits/stdc++.h>
#define modp 1000000007
#define Maxn 4007
using namespace std;
int p[Maxn][Maxn],A,B;
int main()
{
	memset(p,0,sizeof(p));
	p[0][0]=1;
	for (int i=1;i<=4000;i++)
	{
		p[i][0]=1;
		for (int j=1;j<=i;j++)
			p[i][j]=(p[i-1][j-1]+p[i-1][j])%modp;
	}
	scanf("%d%d",&A,&B);
	int ans=0;
	for (int i=1;i<B;i++)
		for (int j=1;j<=B-i;j++)
			if ((B-i)+(B-i-j)<=A)
			{
				int del=(1LL*p[B-1][i-1]*p[B-i-1][j-1])%modp;
				del=(1LL*del*p[A-(B-i)-(B-i-j)+2][2])%modp;
				ans=(ans+del)%modp;
			}
	ans=(ans+A+1)%modp;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 63104
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    let operator;
    from_line!(a: i32, b: i32);
    if a < b {
        operator = "<";
    }
    else if a == b {
        operator = "==";
    }
    else {
        operator = ">";
    }
    println!("a {} b", operator);
}



Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int takaBeats = ceil(c*1.0/b);
	int aokiBeats = ceil(a*1.0/d);
	if(takaBeats <= aokiBeats)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3636
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = []
    phU.append(P[0])
    phU.append(P[1])
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = []
    phL.append(P[-1])
    phL.append(P[-2])
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break
      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
P = P[idx:] + P[:idx]
for p in P : print(p[0],p[1])

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


int main() {
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(abs(a-b) <= d && abs(b-c) <= d || abs(a-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int W=sc.nextInt();
		int[][] prods=new int[N][2];
		for(int i=0; i<N; i++) {
			prods[i][0]=sc.nextInt();//重さ
			prods[i][1]=sc.nextInt();//価値
		}
		long[][] dp=new long[N+1][W+1];
		for(int i=0; i<=W; i++) {
			dp[0][i]=0;
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<=W; j++) {
				if(j<prods[i][0]) {
					dp[i+1][j]=dp[i][j];
				}
				else {
					dp[i+1][j]=Math.max(dp[i][j], dp[i][j-prods[i][0]]+prods[i][1]);
				}
			}
		}
		pl(dp[N][W]);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

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

int main(void) {
	int N;
	int cylinders[512];
	int i, j;
	double cylinders_pos[512];
	double max, current;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &cylinders[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		max = cylinders[i];
		for (j = 0; j < i; j++) {
			current = cylinders_pos[j] + sqrt(
				(cylinders[j] + cylinders[i]) * (cylinders[j] + cylinders[i]) -
				(cylinders[j] - cylinders[i]) * (cylinders[j] - cylinders[i]));
			if (current > max) max = current;
		}
		cylinders_pos[i] = max;
	}
	max = 0;
	for (i = 0; i < N; i++) {
		current = cylinders_pos[i] + cylinders[i];
		if (current > max) max = current;
	}
	printf("%.15f\n", max);
	return 0;
}

Measured memory_bytes: 644
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N;
	cin >> N;
	cout << (N - 2) * 180 << endl;

	return 0;
}


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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<long> as(N*2), acc(2*N+1);
	long total = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> as[i];
		as[i+N] = as[i];
		total += as[i];
	}
	//sum[i..j) = acc[j] - acc[i]
	for (int i = 0; i < 2*N; i++) acc[i+1] = acc[i] + as[i];
	long ok = 0, ng = total;
	while(ok+1<ng)
	{
		long x = (ok+ng)/2, sum = 0;
		int t = 0;
		vector<int> nxt(2*N+1, -1);
		for (int s = 0; s < N; s++)
		{
			while(t < 2*N && sum < x)
			{
				sum += as[t++];
			}
			if (sum >= x) nxt[s] = t;
			if (s != t)
			{
				sum -= as[s];
			}
			else t++;
		}
		bool f = 0;
		for (int s = 0; s < N; s++)
		{
			int t = nxt[s];
			if (t == -1) continue;
			int u = nxt[t];
			if (u == -1) continue;
			//cout << x << ' ' << t << ' ' << u << ' ' << total - acc[u] + acc[s] << endl;
			f |= (total - acc[u] + acc[s] >= x);
		}
		(f ? ok : ng) = x;
	}
	cout << ok << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

struct item {
    long long b, l, r;
    item() = default;
};

int n;
long long X;
item f[N];

bool read() {
    if (!(cin >> n >> X))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> f[i].b >> f[i].l >> f[i].r;

    return true;
}

bool check(long long m) {
    if (m == n * X)
        return true;

    auto w = m / X;
    auto init = 0ll;

    auto add = [](long long a, item t) { return (a - t.b) * (a < t.b ? t.l : t.r); };

    for (int i = 0; i < n; ++i)
        init += add((i < w ? X : 0ll), f[i]);

    auto res = -1ll * MOD * MOD;

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

        if (i < w) {
            cur -= add(X, f[i]) + add(0, f[w]);
            cur += add(m % X, f[i]) + add(X, f[w]);
        } else {
            cur -= add(0, f[i]);
            cur += add(m % X, f[i]);
        }

        res = max(res, cur);
    }

    return res >= 0;
}

void solve() {
    sort(f, f + n, [](const item& a, const item& b) {
        return (X - a.b) * a.r + a.b * a.l > (X - b.b) * b.r + b.b * b.l;
    });

    auto l = 0ll;
    auto r = n * X;

    for (; l < r; ) {
        auto m = (l + r) / 2;

        if (check(m))
            r = m;
        else
            l = m + 1;
    }

    cout << l << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    long fib[3] = {1, 0, 0};
    for (int i = 0; i <= n; ++i) {
        fib[2] = fib[1] + fib[0];
        fib[0] = fib[1];
        fib[1] = fib[2];
    }
    cout << fib[2] << endl;
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 long long a[10005];
int main(){
	 long long n; cin>>n;
	 long long s=0;
	 
	 for(int i=0;i<n;i++){
		 cin>>a[i];
		 s=s+a[i];
	 }
	 long long mx=10000000;
	 for(long long i=0;i<n;i++){
	if (a[i]<mx){
		mx=a[i];
	}
}
long long ut=-100000000;
    for (long long i=0;i<n;i++){
		if	(a[i]>ut){
			ut=a[i];
		}
	}
 	 cout<<mx<<" "<<ut<<" "<<s<<endl;
	 
	 return 0;
}



Measured memory_bytes: 3156
N,M,X = map(int,input().split())
A = []
cost = []
for i in range(N):
    a = list(map(int,input().split()))
    A.append(a[1:])
    cost.append(a[0])
ans = float('inf')
for i in range(2**N):
    I = bin(i)[2:]
    I = I.zfill(N)
    tmp = [0]*M
    buy = 0
    for j in range(len(I)):
        if I[j]=='1':
            for k in range(len(A[j])):
                tmp[k] += A[j][k]
            buy += cost[j]
    if all(tmp[i]>=X for i in range(len(tmp))):
        ans = min(ans,buy)
ans = -1 if ans ==float('inf') else ans
print(ans)

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

using namespace std;

const int maxn = 1e5 + 1, maxa = 1e4 + 1, mina = -1e4-1;

int a[maxn];

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

	int n, mini = maxa, minp, maxi = mina, maxp;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < mini)
		{
			mini = a[i];
			minp = i;
		}
		else if (a[i] > maxi)
		{
			maxi = a[i];
			maxp = i;
		}
	}
	int t1 = maxi, t2 = mini;
	for (int i = 0; i < n; i++)
	{
		if (i == minp || i == maxp)
			continue;
		if (a[i] >= 0)
		{
			t2 -= a[i];
		}
		else
		{
			t1 -= a[i];
		}
	}
	cout << t1  - t2 << "\n";
	for (int i = 0; i < n; i++)
	{
		if (i == minp || i == maxp)
			continue;
		if (a[i] >= 0)
		{
			cout << mini << " " << a[i] << "\n";
			mini -= a[i];
		}
		else
		{
			cout << maxi << " " << a[i] << "\n";
			maxi -= a[i];
		}
	}
	cout << maxi << " " << mini << "\n";
}

Measured memory_bytes: 2304
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 2000000;
set < int > ms;
int used[N], t[N], color[N], r[N], cv, v[N], s[N], u[N], n, m, val[N];
pair < int, int > p[N];
vector < pair < int, int > > g[N];
pair < int, int > ans[N];
int res[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < (1 << n); i++){
        cin >> ans[i].F;
    }
    for (int j = 0; j < n; j++){
        for (int i = 0; i < (1 << n); i++){
            if (!((1 << j) & i)){
                int x = ans[i | (1 << j)].F;
                int y = ans[i | (1 << j)].S;
                int t = ans[i].F;
                int z = ans[i].S;
                multiset < int > s;
                s.insert(-x);
                s.insert(-y);
                s.insert(-t);
                s.insert(-z);
                auto it = s.begin();
                ans[i | (1 << j)].F = -(*it);
                it++;
                ans[i | (1 << j)].S = -(*it);
            }
        }
    }
    for (int i = 1; i < (1 << n); i++){
        res[i] = max(ans[i].F + ans[i].S, res[i - 1]);
        cout << res[i] << endl;

    }
}


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

bool p(int i){
  return (i / 10000 == i % 10 && (i / 1000 - i / 10000 * 10) == i % 100 / 10);
}

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for(int i = a; i <= b; i++){
    if(p(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3536
n = int(input())
num = list(map(int, input().split()))

q = int(input())
for _ in range(q):
    k = int(input())

    low = 0
    high = len(num)
    t = (low + high) // 2

    if k > num[-1]:
        print(0)
        continue

    while low <= high:
        if k == num[t]:
            break
        elif k > num[t]:
            low = t + 1
        elif k < num[t]:
            high = t - 1
        t = (low + high) // 2

    if k == num[t]:
        print(1)
    else:
        print(0)



Measured memory_bytes: 17192
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);

		String ringText =scan.nextLine();
		int ringLength = ringText.length();
		char[] ringChar = ringText.toCharArray();

		String target =scan.nextLine();
		int targetLength = target.length();

		String hikaku = "";

		boolean kai = false;

		for(int i=0; i<ringLength; i++){
			hikaku = "";
			for(int j=0; j<targetLength; j++){		//ring??????target???????????????????????????????????????
				int charPosition = j;
				if(i + charPosition >= ringLength){		//ring???????????????????????\?????????????????????????????????
					charPosition -= ringLength;
				}
				hikaku = hikaku + ringChar[i+charPosition];
			}
			if(target.equals(hikaku)){
				System.out.println("Yes");
				kai = true;
				break;
			}
		}

		if(kai == false){
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26624
n, h = gets.chomp.split.map(&:to_i)
b = []
a_max = 0
n.times do
  ai, bi = gets.chomp.split.map(&:to_i)
  a_max = [a_max, ai].max
  b << bi
end

cnt = 0
b.sort.reverse.each do |bi|
  if bi >= a_max
    h -= bi
    cnt += 1
    if h <= 0
      puts cnt
      exit
    end
  else
    break
  end
end
s, t = h.divmod(a_max)
s += 1 if t > 0
puts cnt + s

Measured memory_bytes: 16820
D = int(input())
cs = list(map(int, input().split()))
ss = [list(map(int, input().split())) for _ in range(D)]
ts = [int(input()) for _ in range(D)]

def calc(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))
            
    return sat

for i in range(len(ts)):   
    print(calc(ts[:i+1]))


Measured memory_bytes: 69160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif






int main(){
	string s;
	cin >> s;
	
	int len = s.size();
	s += "XX";
	
	ll a = 0;
	ll ct = 0;
	rep(i,len+1){
		if ( s[i] == 'A' ){
			a++;
		}
		else if ( s[i] == 'B' && s[i+1] == 'C' ){
			i++;
			ct += a;
		}
		else {
			a = 0;
		}
	}
	
	cout << ct << endl;
	
	return 0;
}




Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	for(int64 ii = 0;ii < ss.length() / 2;ii++)
	{
		if(ss[ii] != ss[ss.length() - ii - 1])
		{
			puts("No");
			return 0;
		}
	}
	for(int64 ii = 0;ii < (ss.length() / 2) / 2;ii++)
	{
		if(ss[ii] != ss[ss.length() / 2 - ii - 1])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


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

int a, b;

int main () {
	cin >> a >> b;
		if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
			cout << a * b << endl;
	}
				else {
				 	cout << -1 << endl;
				 }
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int K;
    cin >> K;
    cout << (K / 2) * ((K + 1) / 2) << endl;
}


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

const long long INF=10000000000000000ll;
int main()
{
  int n,K;
  scanf("%d%d",&n,&K);
  static long long a[100000];
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  static long long S[100010],S2[100010];
  S[0]=S2[0]=0;
  for(int i=0;i<n;i++){
    S[i+1]=S[i]+a[i];
    S2[i+1]=S2[i]+(a[i]<0?0:a[i]);
  }
  long long ans=-INF;
  for(int i=0;i+K<=n;i++){
    ans=max(ans,S2[i]+(S[i+K]-S[i])+(S2[n]-S2[i+K]));
    ans=max(ans,S2[i]+(S2[n]-S2[i+K]));
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int A,B,K;
   cin>>A>>B>>K;
   map<int,int> data;
   rep(i,K){
       if(A+i>B){
           continue;
       }
       if(B-i<A){
           continue;
       }
       data[A+i]++;
   
       data[B-i]++;
   }
   for(auto D:data){
       auto k=D.first;
       cout<<k<<endl;
   }
  
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    pair<pair<string, int>, int> p[110];
    rep(i, 0, N) {
        string a;
        int b;
        cin >> a >> b;
        p[i] = MP(MP(a, -b), i);  // 点数が高い順にするため
    }                             // -1倍を入れる
    sort(p, p + N);
    rep(i, 0, N) {
        cout << p[i].ss + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256