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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	int n = ri();
	string s;
	cin >> s;
	vector<vector<bool>> dp(n + 1, vector<bool>(n + 1)); 
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {

			int len = 0, ir = i, jr = j;
			while(s[ir] == s[jr] && ir < j && jr < n && !dp[ir][jr]) {
				dp[ir][jr] = true;
				ir++, jr++, len++;
			}
          
			ans = max(ans, len);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){
	int n,i,j;
	int hairetu[3][202]={0};
	int check[3][150]={0};
	int player[202]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&hairetu[j][i]);
			check[j][hairetu[j][i]]++;
		}
	}
	/*for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			printf("%4d",hairetu[i][j]);
		}
		printf("\n");
	}*/
	for(i=0;i<3;i++){
		for(j=0;j<n;j++){
			if(check[i][hairetu[i][j]]<2){
				player[j]+=hairetu[i][j];
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",player[i]);
	}
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a >= k){
        cout << k << endl;
        return 0;
    }else{
        ans = a;
        k -= a;
        if(b >= k){
            cout << ans << endl;
            return 0;
        }else{
            k -= b;
            ans += ((-1) * k);
            cout << ans << endl;
        }
    }

}

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

int n, k;
int d[10];
void solve(){
    cin >> n >> k;
    for(int i=0;i<k;++i) {
        int  t;
        cin >> t;
        d[t] = 1;
    }
    bool fl = 1;
    auto ok = [&](int x) {
        while(x) {
            if(d[x%10])
                return 0;
            x/=10;
        }
        return 1;
    };
    while(fl) {
        if(ok(n))
            fl = 0;
        else 
            n ++;
    }
    cout << n << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3580
N=int(input())
hlist=list(map(int,input().split()))

declist=[0]*N
for i in reversed(range(1,N)):
  if hlist[i-1]>=hlist[i]:
    declist[i-1]=declist[i]+1
  else:
    declist[i-1]=0
    
#print(declist)
print(max(declist))

Measured memory_bytes: 14252
alp=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
N=int(input())
S=input()
ans=''
for i in S:
    ans+=alp[(alp.index(i)+N)%26]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, X;
  cin >> N >> X;
  int x[N];
  REP(i, N) { cin >> x[i]; }

  int diff[N];
  REP(i, N) { diff[i] = abs(x[i] - X); }
  int D = diff[0];
  REP(i, N) { D = __gcd(D, diff[i]); }
  cout << D;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    map<char, int> C;
    map<char, int>::iterator itr;
    for(int i=0; i<s.length(); i++){
        C[s[i]] += 1;
    }

    ll ans = 1;
    for(itr = C.begin(); itr != C.end(); itr++){
        ans *= (itr->second + 1);
        ans %= mod;
    }
    ans -= 1;
    cout << ans;
    return 0;
}
// sの上を這い回って見つけようとしてもぐちゃぐちゃっすね
// 各文字を使うか使わないかという全探索を考える(bit全探索みたいな感じに考える)
// 各部分列を全探索することを考えたが、そこから進まなかった。

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b;
  c = a + b;
  int sq = stoi(c);
  string r = "No";
  rep(i, sq) {
    if ((i * i) == sq) r = "Yes";
    if (i * i > sq) break;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int p[n];
    int temp[n];
    int swap;
    int ans =0;
    int count = 0;
    REP(i,n)cin >> p[i];
    
    REP(i,n){
        
        REP(j,n){
            ans = 0;
            REP(k,n){
                temp[k] = p[k];
            }
            swap = temp[i];
            temp[i] = temp[j];
            temp[j] = swap;
            REP(k,n-1){
                if(temp[k] > temp[k+1])ans = 1;
            }
            if(ans == 0)break;
        }
        if(ans == 0)break;
    }
    if(ans==0)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int h,w;
  cin>>h>>w;
  if(h>w) swap(h,w);

  if(h==1) cout<<1<<endl;
  else cout<<(h*w+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    N++;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    if(N == 1) {
        if(A[0] != 1) {
            cout << -1 << endl;
            return 0;
        } else {
            cout << 1 << endl;
            return 0;
        }
    }
    vector<lint> mx(N);
    mx[N-1] = A[N-1];
    IREP(i, N-1) {
        mx[i] = mx[i+1] + A[i];
    }
    lint ans = 0;
    lint now = 1;
    REP(i, N-1) {
        //cout << i << " " << now << endl;
        if(now <= A[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans += now;
        now -= A[i];
        now *= 2;
        if(now > mx[i+1]) {
            now = mx[i+1];
        }
    }
    if(now < A[N-1]) {
        cout << -1 << endl;
        return 0;
    }
    ans += A[N-1];
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=3e3+10;

const int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main(){
	cin>>k;
	cout<<a[k-1]; 
	return 0;
}


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

int main(){
	int n; cin>>n;
	int ac=0;
	int wa=0;
	int tl=0;
	int re=0;
	rep(i,n){
		string s; cin>>s;
		if(s=="AC") ac++;
		else if(s=="WA") wa++;
		else if(s=="TLE") tl++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tl<<endl;
	cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3632
K,N = input().split()
K = int(K)
N= int(N)
A = [int(x) for x in input().split()]

dis=[]
now = 0

for i in range(N):
    dis.append(A[i] - now)
    now = A[i]

dis.append(K-A[N-1]+dis[0])

distance = K - max(dis)

print(distance)

Measured memory_bytes: 26420
N = int(input())
A = list(map(int, input().split()))
A.sort()
Alice = 0
Bob = 0
while 1:
    try:
        Alice += A.pop(-1)
    except IndexError:
        break
    try:
        Bob += A.pop(-1)
    except IndexError:
        break
print(Alice-Bob)

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

bool s[100010], dp[100010];

bool satisfies(int N) {
  for (int i = 2; i < N; i++) {
    dp[i] = dp[i-1] ^ dp[i-2] ^ s[i-1];
  }
  return (dp[N-1] ^ dp[N-2] ^ s[N-1] == dp[0] && dp[0] ^ dp[N-1] ^ s[0] == dp[1]);
}

void print_dp(int N) {
  for (int i =0; i < N; i++) {
    cout<<(dp[i] ? 'W' : 'S');
  }
  cout<<endl;
}

int main() {
  int N; cin>>N;
  string S; cin>>S;
  for (int i = 0; i < N; i++) s[i] = (S[i] == 'x');
  dp[0]=dp[1]=0;
  if (satisfies(N)) { print_dp(N); return 0;}
  dp[1] = 1;
  if (satisfies(N)) { print_dp(N); return 0;}
  dp[0] = 1;
  if (satisfies(N)) { print_dp(N); return 0;}
  dp[1] = 0;
  if (satisfies(N)) { print_dp(N); return 0;}
  cout<<-1<<endl;
}

Measured memory_bytes: 3860
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

data = []
for i in range(1, N+1):
    data.append(i)

list_data = []
for val in itertools.permutations(data):
    list_data.append(val)

list_data.sort()

a = 0
b = 0
i = 1
for val in list_data:
    if val == P:
        a = i
    if val == Q:
        b = i
    i += 1

if a >= b:
    print(a-b)
else:
    print(b-a)

Measured memory_bytes: 7924
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <limits>
#include <ctype.h> 
#include <stdio.h> 
#include <set> 
#include <iomanip>
#include <vector>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '


int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    vector<ll> m(n);
    for(int i = 0; i < n; ++i){
        cin >> m[i];
    }
    sort(m.rbegin(), m.rend());
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }
    m.erase(m.begin(), m.begin()+k);
    ll res = 0;
    for(int i = 0; i < m.size(); ++i){
        res+=m[i];
    }
    cout << res << endl;
    

    return 0;
} 


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

void chmin(int &a, int b){
  if (a > b){
    a = b;
  }
}

int INF = 1000000000;
vector<int> dp(100010), h(100010);

int rec(int i){
  if(dp.at(i) < INF){
    return dp.at(i);
  }
  if(i == 0){
    return 0;
  }
  int res = INF;
  chmin(res, rec(i - 1) + abs(h.at(i - 1) - h.at(i)));
  if(i > 1){
    chmin(res, rec(i - 2) + abs(h.at(i - 2) - h.at(i)));
  }
  return dp.at(i) = res;
}

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> h.at(i);
    dp.at(i) = INF;
  }
  cout << rec(N - 1) << endl;
}

Measured memory_bytes: 7296
h,w,a,b=map(int,input().split())

#行に含まれる数はa、列に含まれる数はb
#行の並び替えは可能
#列の並び替えも可能

if b>h//2:
    print("No")
    exit()
if a>w//2:
    print("No")
    exit()


mapss=[[0]*w for _ in range(h)]

for y in range(b):
    for x in range(a):
        mapss[y][x]=1

for y in range(b,h):
    for x in range(a,w):
        mapss[y][x]=1


for item in mapss:
    print("".join(map(str,item)))

Measured memory_bytes: 51292
#include<stdio.h>
#define N 100

int p[ N ],m[ N ][ N ];
int n;

void MatrixChainOrder(){
 
  int i,j;
  int l,k,q;
 
  for(i=1;i<=n;i++){
    
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
     
      j=i+l-1;
      m[i][j]=100000;
      
      for(k=i;k<=j-1;k++){
        q=m[i][k]+m[k+1][j]+p[i]*p[k+1]*p[j+1] ;
    
        if(q<m[i][j]){
          m[i][j]=q;
        }
      }
    }
  }

  printf("%d\n",m[1][n]);

}
 
int main(){
   
  int i,a,count;
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++){

    scanf("%d %d",&p[i+1],&a);
     
  }

  p[i+1]=a;
   
  MatrixChainOrder();
   
  return 0;
}

Measured memory_bytes: 636
s=input()
ans1=0
ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            ans1+=1
    else:
        if s[i]=="1":
            ans1+=1
for k in range(len(s)):
    if k%2==0:
        if s[k]=="1":
            ans2+=1
    else:
        if s[k]=="0":
            ans2+=1
print(min(ans1,ans2))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    int v[n];
    int c[n];
    for(int i =0;i<n;i++) cin>>v[i];
    for(int i = 0;i<n;i++) cin>>c[i];
    int vg=0;
    int cg=0;
    for(int i = 0;i<n;i++){
     if(v[i] >= c[i]){
       vg+=v[i];
       cg+=c[i];
     }
    }
    cout<<vg-cg;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) {
        cin >> s[i];
    }

    int ans = 0;
    rep(i, n) {
        rep(j, s[i].size()-1) {
            if(s[i][j] == 'A' and s[i][j+1] == 'B') {
                ans++;
            }
        }
    }
    int coua=0, coub=0, coux = 0;
    rep(i, n) {
        if(s[i][0] == 'B') {
            coub++;
        }
        if(s[i][s[i].size()-1] == 'A') {
            coua++;
        }
        if(s[i][0] == 'B' and s[i][s[i].size()-1] == 'A') {
            coux++;
        }
    }

    ans += min(coua, coub);
    if(coua == coub and coua == coux and coux != 0) ans--;

    cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    
    if(arr[0] == arr[1]){
        cout << arr[2] << endl;
    }
    if(arr[1] == arr[2]){
        cout << arr[0] << endl;
    }
    if(arr[2] == arr[0]){
        cout << arr[1] << endl;
    }
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a;
    a = N % 2;
    if(a == 0){
        cout << N / 2 << endl;
    }
    else{
        cout << N / 2 + 1 << endl;
    }
    return 0;
}

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



int main() {
    int n;
    cin >> n;
    
    for(int i = 1; i <= 9; i++) {
        if(n % i == 0 && n / i >= 1 && n / i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    
    return 0;
}




Measured memory_bytes: 3580
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int floor(long long a, long long b) { return a / b; }
int main() {
    int a,b,c,d,e,f,g,h,i;
    
        cin >> a>>b>>c>>d>>e>>f>>g>>h>>i;
     
    if(a-b==d-e&&d-e==g-h&&b-c==e-f&&e-f==h-i&&a-d==b-e&&b-e==c-f&&d-g==e-h&&e-h==f-i){
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3520
N = int(input())
n = N
if N % 2 == 1: # 奇数のときは偶数がかけられていないので0は並ばない．
    print(0)
else:
    # 1回分は割り算しておく．最初に2で割ることによって1,2,3,4,5,6,7,8...という数列の積になる．
    cnt = N // 10
    N //= 10
    while N > 0:
        cnt += N // 5
        N //= 5
    print(cnt)

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

int main(){
    int n; cin>>n;
    vector<int> tako(n);
    int ans = 0;
    for (int i=0; i<n; i++){
        cin>>tako[i];
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans +=tako[i]*tako[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m=list(map(int,input().split()))
a=list(input() for _ in range(n))
b=list(input() for _ in range(m))
c=0
if a==b:
    c=1
for i in range(n-m):
    for j in range(n-m):
        if all(a[i+k][j:j+m]==b[k]  for k in range(m)):
            c=1
            break
print('Yes' if c==1 else 'No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int men[100] = {}, a[100] = { 0 };
	for (int i = 0; i < 28; i++){
		cin >> a[i];
		men[a[i]] = 1;
	}
	for (int i = 1; i <= 30; i++){
		if (men[i] != 1){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int win[1000010][20];
string S;

int winner(int x,int y){
    if(x<y){
        if(S[y-x-1]=='0') return x;
        else return y;
    }else{
        if(S[x-y-1]=='0') return y;
        else return x;
    }
}

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

  int N;
  cin>>N;
  cin>>S;
  int M=pow(2,N);
  vector<int> P(M);
  rep(i,M) cin>>P[i];

  vector<int> A(2*M);
  rep(i,2*M) A[i]=P[i%M];

  for(int i=0;i<2*M;i++) win[i][0]=A[i];

  for(int k=1;k<=N;k++){
      for(int j=0;j+k-1<2*M;j++){
          int rig=j+(1<<(k-1));
          win[j][k]=winner(win[j][k-1],win[rig][k-1]);
      }
  }

  for(int i=0;i<M;i++) cout<<win[i][N]<<"\n";

  return 0;
}



Measured memory_bytes: 47728
n = int(input())
ld = list(map(int,input().split()))

pnt = 0
r = int((n * (n-1)) / 2)
cnt2 = 0

for i in range(r):
	cnt = i + 1
	cnt2 = 0
	for ii in range(n-cnt):
		cnt2 += 1
		pnt += ld[i] * ld[i+cnt2]
print(pnt)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		if(X >= 400 && X <= 599) {
			System.out.println(8);
		}else if(X <= 799) {
			System.out.println(7);
		}else if(X <= 999) {
			System.out.println(6);
		}else if(X <= 1199) {
			System.out.println(5);
		}else if(X <= 1399) {
			System.out.println(4);
		}else if(X <= 1599) {
			System.out.println(3);
		}else if(X <= 1799) {
			System.out.println(2);
		}else if(X <= 1999) {
			System.out.println(1);
		}
	}
}

Measured memory_bytes: 26936
n = int(input())
nSum = 0
for i in range(n):
    cnt = 0
    if (i + 1) % 2 != 0:
        for j in range(i + 1):
            if (i + 1) % (j + 1) == 0:
                cnt += 1
        if cnt == 8:
            nSum += 1

print(nSum)


Measured memory_bytes: 2940
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int n,ii,max=0,pos=0;
  vector<int> p;
  long sum = 0;
  cin >> n;
  p.resize(n);
  for(ii=0;ii<n;ii++){
	cin >> p[ii];
	if(p[ii] > max){
	  max=p[ii];
	  pos = ii;
	}
  }
  for(ii=0;ii<n;ii++){
	if(pos != ii){
	  sum += p[ii];
	}
	else{
	  sum += p[ii]/2;
	}
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
prog=<<EOS
def getints
  gets.split.map(&:to_i)
end

n, m = getints
$g = Array.new(n) { [] }
m.times do
  a, b = getints
  a -= 1
  b -= 1
  $g[a] << b
  $g[b] << a
end

$vis = Array.new(n, false)

def dfs v, ans
  ans << v
  $vis[v] = true
  $g[v].each do |w|
    unless $vis[w] 
      dfs w, ans
      break
    end
  end
end

a = []
b = []
dfs 0, a
dfs 0, b
b.reverse!.pop
ans = b + a
puts ans.size
puts ans.map(&:succ).join " "
EOS

open('prog.rb', 'w') { |f| f.puts prog }
puts `RUBY_THREAD_VM_STACK_SIZE=200000000 ruby prog.rb`


Measured memory_bytes: 205392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

const ll MOD = 1000000007;

vector<int>V;

void solve()
{
	string S,T;
	cin>>S>>T;

	int count = 0, c = 0;

	for(int i = 0; i <= S.length() - T.length(); i++)
	{
		for(int j = 0; j < T.length(); j++)
		{
			if(S[i+j] == T[j])
				c++;
		}

		count = max(count,c);
		c = 0;
	}

	cout<<T.length() - count<<endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// > (digits(m: 2000)+1)*200
#define BUF_SIZE 1030

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define ARR_MAX 20
#define ELEM_MAX 2000
#define NUM_MAX (ARR_MAX*ELEM_MAX)
#define QUERY_MAX 200
#define SET_MAX 20000

int main(void) {
    int n = get_int();
    int i, j;
    static int arr[ARR_MAX];
    fget_array(arr, n);
    static char dp[ARR_MAX+1][NUM_MAX+1];
    // initialization
    dp[0][0] = 1;

    int max = 0;
    for(i = 1; i <= n; i++) {
        int elem = arr[i-1];
        max += elem;
        for(j = 0; j <= max; j++) {
            dp[i][j] |= dp[i-1][j];
            if(j>=elem) dp[i][j] |= dp[i-1][j-elem];
        }
    }
    int qs = get_int();
    static int queries[QUERY_MAX];
    fget_array(queries, qs);

    for(i = 0; i < qs; i++) {
        printf("%s\n", dp[n][queries[i]] ? "yes" : "no");
    }
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n];
	set<int> st;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
	}

	cout << (st.size() % 2 ? st.size() : st.size()-1) << endl;
}


Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var S = GetString();

		var front = count(S.Substring(0, (int)N));
		var back = count(S.Substring((int)N, (int)N));
		long ans = 0;
		foreach(var key in front.Keys)
		{
			var r = key.Item1;
			var b = key.Item2;
			back.TryGetValue((b, r), out long c);
			ans += front[key] * c;
		}
		WriteLine(ans);
	}
	
	private Dictionary<(string, string), long> count(string S)
	{
		long N = S.Length;
		var cnt = new Dictionary<(string, string), long>();
		for(long i = 0, E = leftShift(1, N); i < E; i++)
		{
			string r = "";
			string b = "";
			for(int j = 0; j < N; j++)
			{
				if(contains(i, j))
					r += S[j];
				else
					b += S[j];
			}
			b = string.Concat(b.Reverse());

			cnt.TryGetValue((r, b), out long c);
			cnt[(r, b)] = c + 1;
		}
		return cnt;
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 122276
#include <iostream>
#include <climits>
#include <vector>

using namespace std;

int main() {
    int n = INT_MIN;
    long d = LONG_MIN;
    cin >> n; cin >> d;
    vector<long> x(n);
    vector<long> y(n);
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
	cin >> x[i];
	cin >> y[i];
	if (x[i]*x[i] + y[i]*y[i] <= d*d) {
	    ++cnt;
	}
    }
    cout << cnt << "\n";
}


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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int q;
  scanf("%d", &q);
  while(q--){
    int n, i = 0;
    vector<int>v;
    scanf("%d", &n);
    v.push_back(n);
    while(n/10){
      int lerge = 0, split = 10;
      while(n / split){
	lerge = max(lerge, (n / split) * (n % split));
	split*=10;
      }
      n = lerge;
      if(find(v.begin(), v.end(), n) != v.end()){
	i = -1;
	break;
      }
      v.push_back(n);
      i++;
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 1208
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			}
			for(int i = 0; i < H; ++i) {
				for(int j = 0; j < W; ++j) {
					System.out.print((i == 0 || i == H - 1 || j == 0 || j == W - 1 ? "#" : "."));
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 32188
import collections
n = int(input())
l = []
for i in range(n):
    l.append(input())
c = collections.Counter(l)
t = sorted(c.most_common())
t.sort(key=lambda x: x[1],reverse=True)
ma = t[0][1]
for i in range(len(t)):
    if t[i][1] < ma:
        break
    print(t[i][0])


Measured memory_bytes: 47636
f=lambda:map(int,input().split());n,m=f();g=[[] for _ in range(n)]
for _ in [0]*m:a,b=f();g[a-1]+=[b-1];g[b-1]+=[a-1]
p=[0]*n;from collections import*;q=deque([0])
while q:
    v=q.popleft()
    for c in g[v]:
        if p[c]<1:p[c]=v+1;q.append(c)
print('Yes',*p[1:],sep='\n')

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N, M, X; cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N, vector<ll>(M));
  REP(i, N) {
    cin >> C[i];
    REP(k, M) {
      cin >> A[i][k];
    }
  }

  vector<ll> ans(M); REP(i, M) ans[i] = 0;
  ll res = pow(10, 18);
  for(int bit = 0; bit < (1 << N); ++bit) {
    int sum = 0;
    for(int i = 0; i < N; ++i) {
      if(bit & (1 << i)) {
        sum += C[i];
        for(int k = 0; k < M; ++k) {
          ans[k] += A[i][k];
        }
      }
    }
    for(int i = 0; i < M; ++i) {
      if(ans[i] < X) break;
      if(i == M - 1) {
        if(res > sum) {
          res = sum;
        }
      }
    }

    REP(i, M) ans[i] = 0;
  }
  if(res == pow(10, 18)) res = -1;
  cout << res << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int num(int N){
int a = 0 , b = 1, c;
for(int i = 0 ; i < 9 ; i++){
a += N / b % 10;
b *= 10;
}
c = N % a;
return c;
}
int main(){
  int N;
  cin >> N;
      if(num(N) == 0){
        cout << "Yes" <<endl;
      }
      else if(num(N) != 0){
        cout << "No" << endl;
      }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  double sum=0;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){cin >> A.at(i); sum = sum+A.at(i);}
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  double bunnbo = sum/(4*M);
  
  if(A.at(M-1)>=bunnbo){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  
    
}

Measured memory_bytes: 3636
from collections import Counter
n,p = map(int,input().split())
s = input()
n = len(s)
mod = [0] * (n+1)
ten = [0] * n

a = 1
for i in range(n):
    ten[i] = a
    a = a * 10 % p

ans = 0
if p != 2 and p != 5:
    rui = 0
    for i in range(n):
        rui = (int(s[n-1-i]) * ten[i] + rui) % p
        mod[n-1-i] = rui

    b = Counter(mod)
    c = list(b.values())
    c.sort(reverse = True)

    for i in c:
        if i > 1:
            ans += i * (i-1) // 2
        else:
            break
            
elif p == 2:
    for i in range(n):
        if int(s[i]) % 2 == 0:
            ans += i+1
else:
    for i in range(n):
        if int(s[i]) % 5 == 0:
            ans += i+1

print(ans)

Measured memory_bytes: 45900
#include <iostream>
#include <climits>
#include <algorithm>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    int count[2 * 1000] = {0};
    rep(i, N - 1) count[i] = 0;
    rep(i, N - 1) {
        for (int j = i + 1; j < N; j++) {
            int k = min({ j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j), abs(Y - 1 - i) + 1 + abs(X - 1 - j) });
            count[k] += 1;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << count[i] << endl;
    }
     return 0;
}


Measured memory_bytes: 384
//Problem A
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int n,k;
ll x[100007],ans=-1;

int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%lld",&x[i]);
    for(int i=1;i<=n-k+1;i++){
        ll a1=-min(0ll,x[i]),a2=max(0ll,x[i+k-1]);//printf("%lld %lld\n",a1,a2);
        ll v=a1+a2+min(a1,a2);
        if(ans==-1||v<ans)ans=v;
    }
    //cnt=k;ll cur=0;for(int i=id;i;i--)mv(a1,cur,x[i]);for(int i=id+1;i<=n;i++)mv(a1,cur,x[i]);
    //cnt=k;   cur=0;for(int i=id+1;i<=n;i++)mv(a2,cur,x[i]);for(int i=id;i;i--)mv(a2,cur,x[i]);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n = 200000;
long long x,n,h,D=0,amax=1;
pair<long long, long long> itv[max_n];
long long a[max_n],b[max_n];
void solve(){
    long long count = 0;
    sort(b, b+n);
    reverse(b,b+n);
    int ii = 0;
    while(b[ii] > amax && h>0){
        h -= b[ii++];
        count++;
    }
    if(h>0){
        count += h/amax;
        if(h % amax != 0)   count++;
    }
    cout << count << endl;
}
int main(){
    cin >> n >> h;
    for(int i=0 ; i<n ; i++){
        cin >> a[i] >> b[i];
        amax = max(amax, a[i]);
    }
    solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N%10==3) {
    cout << "bon" << endl;
  } else {
    if(N%10==0||N%10==1||N%10==6||N%10==8) {
      cout << "pon" << endl;
    } else {
      cout << "hon" << endl;
    }
  }
}


Measured memory_bytes: 3588
def linear_search array, val
  array.each_with_index{|n, index|
    return index if n == val
  }
  nil
end

def main array, target_values
  puts target_values.select{|target_value|
    linear_search array, target_value
  }.size

end

size, array, size_2, values = STDIN.read.split(/\n/)
array = array.split(' ')
values = values.split(' ')

main(array, values)

Measured memory_bytes: 9068
#include <iostream>
#include <set>

using namespace std; 

int
main(int argc, char const *argv[])
{
    uint64_t height, width;
    cin >> height >> width;
    uint64_t h, w;
    cin >> h >> w;
    uint64_t ans;
    ans = (height -h ) * (width - w);
    cout << ans << endl;
    return 0;
}


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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}


void solve() 
{ 
int h,a;
cin>>h>>a;
cout<<h/a+(h%a!=0);


}
 

int main(){


		solve();
		cout<<endl;
		


	
					
}
		

	

		

 



Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    ans = 0
    for k in range(61):
        x = 0
        for i in range(N):
            if (A[i] >> k) & 1:
                x += 1
        y = N - x
        tmp = x * y
        tmp %= MOD
        for _ in range(k):
            tmp *= 2
            tmp %= MOD
        ans += tmp
        ans %= MOD
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 123732
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}



int main(){
    int x,y,z; cin >> x >> y >> z;
    
    x -= z;
    
    cout << x/(y+z) << endl;
}



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

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

    string s;
    cin >> s;

    stack<char> st;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(st.size() > 0){
            if(st.top() != s[i]){
                st.pop();
                continue;
            }
        }
        st.push(s[i]);
    }

    cout << n - st.size() << endl;

    return 0;
}

Measured memory_bytes: 512
n,m=map(int,input().split())
a=[]
b=[]
ok=False
for i in range(n):
    a+=[input()]
for i in range(m):
    b+=[input()]

for y in range(n-m+1):
    for x in range(n-m+1):
        aa=[a[i][x:x+m] for i in range(y,y+m)]
        if aa==b:
            ok=True
            break
    if ok:
        break
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n, p = map(int, input().split())
s = input()
count = 0
if p == 2 or p == 5:
  for i in range(n):
    if int(s[i]) % p == 0:
      count += i + 1
  print(count)
else:
  mod = [0] * p
  mod[0] = 1
  tmp = 0
  ten = 1
  for i in s[::-1]:
    ten = ten * 10 % p
    tmp = (tmp + int(i) * ten) % p
    mod[tmp] += 1
  for m in mod:
    count += m * (m - 1) // 2
  print(count)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
bool check(int x)
{
    int b=x%10;
    while(x)
    {
        if(x%10!=b)
            return 0;
        x/=10;
    }
    return 1;
}
int main()
{
    int n;
    cin>>n;
    for(;!check(n);n++);
    cout<<n;
    return 0;
}



Measured memory_bytes: 256
N = int(input())

if N<=111:
    print(111)
elif 111<N<=222:
    print(222)
elif 222<N<=333:
    print(333)
elif 333<N<=444:
    print(444)
elif 444<N<=555:
    print(555)
elif 555<N<=666:
    print(666)
elif 666<N<=777:
    print(777)
elif 777<N<=888:
    print(888)
else:
    print(999)

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

const int maxn = 1e6 + 5;

int a[maxn];
int g[maxn];

vector<int >G;
int cnt = 0;

int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		scanf("%d",&a[i]);
	}
	for(int i = 1;i <= n; i = i*3+1)G.push_back(i);
	int sk = G.size();
	printf("%d\n",sk);
	for(int i = G.size()-1;i >= 0; i--){
		printf("%d",G[i]);
		if(i)printf(" ");
	}
	for(int k = G.size()-1;k >= 0; k--){
		int g = G[k];
		for(int i = g;i <= n; i++){
			int v = a[i];
			int j = i - g;
			while(j >= 1 && a[j] > v){
				a[j+g] = a[j];
				j -= g;
				cnt++;
			}
			a[j+g] = v;
		}
	}
	printf("\n%d\n",cnt);
	for(int i = 1;i <= n; i++)printf("%d\n",a[i]);
}

Measured memory_bytes: 7188
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		int id;
		long height;
		int group = -1;
		Set<Integer> conns = new HashSet<>();

		Node(int id, long height) {
			this.id = id;
			this.height = height;
		}
	}

	int N, M;
	Node[] nodes;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		nodes = new Node[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			long height = Long.parseLong(tokens[i]);
			nodes[i] = new Node(i, height);
		}
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			int A = Integer.parseInt(tokens[0]) - 1;
			int B = Integer.parseInt(tokens[1]) - 1;
			nodes[A].conns.add(B);
			nodes[B].conns.add(A);
		}
	}

	boolean isGood(int nodeId) {
		boolean result = true;
		for (Integer i : nodes[nodeId].conns) {
			if (nodes[nodeId].height <= nodes[i].height) {
				result = false;
				break;
			}
		}
		return result;
	}

	long getMaxHeight(int current, int parent, int groupId) {
		long maxHeight = nodes[current].height;
		if (nodes[current].group >= 0) {
			return maxHeight;
		}
		nodes[current].group = groupId;
		for (Integer i : nodes[current].conns) {
			if (parent != i) {
				maxHeight = Math.max(maxHeight, getMaxHeight(i, current, groupId));
			}
		}
		return maxHeight;
	}

	void calc() {
		int count = 0;
		for (int i = 0; i < N; ++i) {
			if (isGood(i)) {
				++count;
			}
		}
		System.out.println(count);
	}

	void showResult() {
	}

}


Measured memory_bytes: 87284
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        long x = sc.nextLong();
        sc.close();

        Algae(r, D, x, 2000);
    }
    public static void Algae(int r, int D, long x, int index) {
        if (index >= 2010) {
            return;
        }
        long x1 = (r * x - D);
        System.out.println(x1);
        Algae(r, D, x1, index + 1);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void){
   int n,m,l;
   unsigned long a[100][100],b[100][100],c[100][100];
   int i,j,k;

   scanf("%d%d%d",&n,&m,&l);
   for(i=0;i<n;i++){
      for(j=0;j<m;j++){
         scanf("%lu",&a[i][j]);
      }
   }
   for(i=0;i<m;i++){
      for(j=0;j<l;j++){
         scanf("%lu",&b[i][j]);
      }
   }
   for(i=0;i<n;i++){
      for(j=0;j<l;j++){
         c[i][j]=0;
         for(k=0;k<m;k++){
            c[i][j]+=a[i][k]*b[k][j];
         }
         if(j!=l-1)printf("%lu ",c[i][j]);
         else printf("%lu",c[i][j]);
      }
      printf("\n");
   }
   return 0;
}

Measured memory_bytes: 844
N = int(input())
A = list(map(int, input().split()))

A.insert(0,0)
A.append(0)

B = [0]*(N+2)
C = [0]*(N+2)
total=0
last=0
simb=1

for i in range(1,N+2):
    if((A[i]-A[i-1])>0):
        C[i]=1
    elif((A[i]-A[i-1])==0):
        C[i]=C[i-1]
    else:
        C[i]=-1

for i in range(1,N+1): 
    if(C[i+1]==C[i]):
        B[i]=1
    else:
        B[i]=-1
        total+=abs(last-A[i])
        last=A[i]

total+=abs(last)

for i in range(1,N+1):
    if(B[i]==1):
        print(total)
    else:
        print(total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))


Measured memory_bytes: 14048
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll dp[2001][2001][2], n, m;
bool a[2001], b[2001];
unordered_map<bool, int>v;
ll solve(ll i, ll j, bool s) {
	ll sum = 0;
	if (i < n&&a[i] == s) {
		if (dp[i + 1][j][v[!s]] != -1)
			sum = 1 + dp[i + 1][j][v[!s]];
		else
			sum = 1 + (dp[i + 1][j][v[!s]] = solve(i + 1, j, !s));
	}
	if (j < m&&b[j] == s) {
		if (dp[i][j + 1][v[!s]] != -1)
			sum = max(sum, 1 + dp[i][j + 1][v[!s]]);
		else
			sum = max(sum, 1 + (dp[1][j + 1][v[!s]] = solve(i, j + 1, !s)));
	}
	if (sum == 1) {
		if (!s) sum = 0;
	}
	return sum;
}
int main() {
	string u, w;
	v.insert(map<bool, int>::value_type(true, 0));
	v.insert(map<bool, int>::value_type(false, 1));
	while (cin >> n >> m) {
		cin >> u >> w;
		ll sum = 0;
		for (ll i = 0; i < n; i++) {
			if (u[i] == 'I') {
				a[i] = true;
			}
			else a[i] = false;
		}
		for (ll i = 0; i <= n; i++) {
			for (ll j = 0; j <= m; j++) {
				dp[i][j][0] = -1;
				dp[i][j][1] = -1;
			}
		}
		for (ll i = 0; i < m; i++) {
			if (w[i] == 'I') {
				b[i] = true;
			}
			else b[i] = false;
		}
		for (ll i = 0; i < n; i++) {
			for (ll j = 0; j < m; j++) {
				if (a[i]||b[j]) {
					if (dp[i][j][0] != -1) {
						sum = max(sum, dp[i][j][0]);
					}
					else
						sum = max(sum, (dp[i][j][0] = solve(i, j, true)));
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 66076
#include <bits/stdc++.h>
#define five 100005
#define six 1000006
#define seven 10000007
#define eight 100000008
#define ll long long
#define nl '\n'
const int inf = 0x3f3f3f3f;
const ll ll_inf = 0x3f3f3f3f3f3f3f3f;
using namespace std;

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios_base::sync_with_stdio(0);

    int a, b;
    cin >> a >> b;

    if( a+b < 3 ) cout << "Impossible" << nl;
    else if( a%3 == 0 ) cout << "Possible" << nl;
    else if( b%3 == 0 ) cout << "Possible" << nl;
    else if( (a+b)%3 == 0 ) cout << "Possible" << nl;
    else cout << "Impossible" << nl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5005;
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

int main()
{
    int n,m,k;


    cin>>n>>m>>k;

    cout<<min(m/n,k);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s;

    for(int i=0; i<s.size(); i++) {
        t += (char)(s.at(i) + n);

        if(t.at(i) > 'Z') {
            t.at(i) = (char)(t.at(i) - 26);
        } 
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b >> c; //3つの整数を入力
  int x; //計算結果はxに入れる
  x = (b + c) - a;
  if (x > 0) {
    cout << x;
  } else {
      cout << 0;
    }
}

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

int N;

void solve() {
    cin >> N;
    bool flag = false;
    rep2(i, 10) {
        rep2(j, 10) {
            if(i*j == N) {
                flag = true;
                break;
            }
        }
    }
    if(flag==true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return; 
}

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


Measured memory_bytes: 256