akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	string k = "keyence";
	int n = s.size();
	int cnt = 0;
	rep(i, 7) {
		if (s[i] == k[i]) cnt++;
		if (s[n - 1 - i] == k[6 - i]) cnt++;
	}
	cout << (cnt >= 7 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
let () =
  let rec read () =
    let hit = ref 0 and
        blow = ref 0 and
        (x,y) = Scanf.scanf " %s %s\n" (fun x y -> (x,y)) in
    if x = "0" && y = "0" then ()
    else
      begin
        for i = 0 to (String.length x)-1 do
          if x.[i] = y.[i] then incr hit
          else
            for j = 0 to (String.length y)-1 do
              if x.[i] = y.[j] then incr blow
            done
        done;
        Printf.printf "%d %d\n" (!hit) (!blow);
        read ()
      end
  in read ()
;;

Measured memory_bytes: 4544
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n],b[n],max=0;
	int count=0;
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			if(i==0){
				cin >> a[j];
			}else{
				cin >> b[j];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int k=0;k<=i;k++){
			count+=a[k];
		}
		for(int j=i;j<n;j++){
			count+=b[j];
		}
		if(max<count){
			max=count;
		}
		count=0;
	}
	cout << max << endl;
}
			

Measured memory_bytes: 256
n, k = map(int,input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = "a"
    print("".join(s))
elif s[k-1] == "B":
    s[k-1] = "b"
    print("".join(s))
else:
    s[k-1] = "c"
    print("".join(s))

Measured memory_bytes: 61768
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ld> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    ld now = v[0];
    rep(i, n - 1){
        now = (now + v[i + 1]) / 2.0;
    }
    cout << fixed << setprecision(17) << now << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,d,x,y,sum=0,i;
    scanf("%lld%lld",&n,&d);
    for(i=0;i<n;i++)
    {
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d)
            sum++;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cmath>
using namespace std;


int main(void) {

  int m, f, r;
  while(cin >> m >> f >> r){

    if( m == -1 && f == -1 && r == -1 ) break;

    if( m == -1 || f == -1 ) cout << "F" << endl;
    else if( m+f >= 80 ) cout << "A" << endl;
    else if( m+f >= 65 ) cout << "B" << endl;
    else if( m+f >= 50 || (m+f >= 30 && r >= 50) ) cout << "C" << endl;
    else if( m+f >= 30 ) cout << "D" << endl;
    else cout << "F" << endl;

  }


  return 0;
}

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

int main(void){
	double x1, y1, x2, y2, d;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	d = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	printf("%f\n", d);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  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);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n = (int)s.sz();
	if(n <= k)
	cout<<s<<"\n";
	else cout<<(s.substr(0, k) + "...")<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3540
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const LLONG GCM(const LLONG a, const LLONG b)
{
    if (b == 0) return a;
    return GCM(b, a % b);
}

const LLONG LCM(const LLONG a, const LLONG b)
{
    return a / GCM(a, b) * b;
}

int main()
{
    LLONG K; cin >> K;
    LLONG ans = 0;
    for (LLONG a = 1; a <= K; ++a)
    {
        for (LLONG b = 1; b <= K; ++b)
        {
            LLONG gcmAB = GCM(a, b);
            for (LLONG c = 1; c <= K; ++c)
            {
                ans += GCM(gcmAB, c);
            }
        }
    }
    cout << ans << endl;
}


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

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string T[3] = {"Sunny", "Cloudy", "Rainy"};
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s == T[i]) cout << T[(i+1) % 3] << endl;
    }
    return 0;
}


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

using namespace std;

int main(void){
    int r,g,b;

    cin>>r>>g>>b;

    int sum = 100 * r + 10 * g + b;

    if(sum % 4 == 0)
	cout<<"YES"<<endl;
    else
	cout<<"NO"<<endl;

    return 0;
}


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

int main(){
	int n,m=0,tmp = 0;
  	cin >> n;
  	vector<int> a(n);
  	vector<int> b(n);
  	for(int i = 0; i<n;i++) {
      	cin >> a[i];
      	tmp += a[i];
    }
  	for(int i = 0; i<n;i++)
      	cin >> b[i];
  	tmp += b[n-1];
  	m = tmp;
  	for(int i = n-2; i>=0; i--) {
		tmp -= a[i+1];
     	tmp += b[i];
      	m = max(m,tmp);
    }
   	printf("%d\n", m);
}


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

using namespace std;


int main() {

  int n;
  vector<int> pages;

  int count;
  int flag;
  int temp;
  vector<int> pair;


  while(cin >> n) {

    if(n==0) break;

    pages.clear();

    pair.clear();

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

      cin >> temp;

      pages.push_back(temp);

    }

    count=0;
    flag=0;
    
    for(int i=0;i<=pages.size();i++) {

      if(i==0) {

	pair.push_back(pages[i]);

	count++;

      }

      else if(i==pages.size()) {

	if(flag==0) {

	  if(count==1) cout << pair[0];
	  
	  else cout << pair[0] << "-" << pair[pair.size()-1];

	  flag=1;

	}

	else {

	  if(count==1) cout << " " << pair[0];

	  else cout << " " << pair[0] << "-" << pair[pair.size()-1];

	}

      }

      else if(pages[i]==pages[i-1]+1) {

	pair.push_back(pages[i]);

	count++;

      }

      else {

	if(flag==0) {

	  if(count==1) cout << pair[0];

	  else cout << pair[0] << "-" << pair[pair.size()-1];

	  flag=1;

	}

	else {

	  if(count==1) cout << " " << pair[0];

	  else cout << " " << pair[0] << "-" << pair[pair.size()-1];

	}

	pair.clear();

	pair.push_back(pages[i]);

	count=1;

      }

    }

    cout << endl;

  }

  return 0;

}

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

using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    auto dy = ty - sy;
    auto dx = tx - sx;
    string ans = "";
    ans += string(dy, 'U');
    ans += string(dx, 'R');
    ans += string(dy, 'D');
    ans += string(dx, 'L');
    ans += "L";
    ans += string(dy + 1, 'U');
    ans += string(dx + 1, 'R');
    ans += "D";
    ans += "R";
    ans += string(dy + 1, 'D');
    ans += string(dx + 1, 'L');
    ans += "U";

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    max_a2, max_a = sorted(a)[-2:]
    print('\n'.join(map(str, [max_a if i != max_a else max_a2 for i in a])))

if __name__ == '__main__':
    main()


Measured memory_bytes: 25220
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

int main() {
	int N;
	cin >> N;
	int minim = 100;
	int maxim = 0;
	vector<int> cnt(101, 0);
	for(int i=0; i<N; i++) {
		int p;
		cin >> p;
		cnt[p]++;
		minim = min(minim, p);
		maxim = max(maxim, p);
	}
	bool ok = true;
	if(cnt[minim] >= 3) ok = false;
	for(int i=minim+1; i<=maxim; i++) {
		if(cnt[i] < 2) ok = false;
	}
	if(cnt[minim] == 2 && maxim != minim * 2 - 1) ok = false;
	if(cnt[minim] == 1 && maxim != minim * 2) ok = false;
	
	if(ok) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	
	return 0;
}






Measured memory_bytes: 384
n=gets.to_i
a=gets.split.map(&:to_i)
c4,c1=0,0
f=true
a.each do |b|
  if b%4==0
    c4+=1
  elsif b.odd?
    c1+=1
  elsif f
    c1+=1
    f=false
  end
end
puts c4>c1-2 ? :Yes : :No


Measured memory_bytes: 8452
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int T;
	cin>>T;
	for(int t=0;t<T;t++) //the number of dataset
	{
		int n,k;
		cin>>n>>k;
		int min_Length;
		vector<int> x(100001);
		for(int i = 0;i < n ; i++)
		{
			cin>>x[i];
		}
		if(k >= n)
		{
			min_Length = 0;
		}
		else
		{
			vector<int> A(n);
			for(int i = 0 ; i < n-1 ; i++)
			{
				A[i]=x[i+1]-x[i];
			}
			sort(A.begin(),A.end());
			min_Length = x[n-1]-x[0];
			for(int m = n-1 ; m >= n-k+1 ; m--)
			{
				min_Length -= A[m];
			}	
		}
		cout<<min_Length<<endl;
	}
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e12)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<class T>void prarr(vector<vector<T>>& a){
rep(i, a.size()){
rep(j, a[i].size()){
cout << a[i][j]; printf(" ");}
printf("\n");} printf("\n");}


 
int main()
{
    int n, k; cin >> n >> k;
    vector<ll> a(n+1);
    a[0] = 0;
    rep(i, n) cin >> a[i+1];
    arr<ll> dp(n+1, vector<ll>(k+1));
    rep(i, n+1) rep(j, k+1) dp[i][j] = 0;
    rep(i, n+1) dp[i][0] = 1;

    FOR(i, 1, n+1){
        // prarr(dp);
        FOR(j, 1, k+1){
            dp[i][j] += (dp[i][j-1] + dp[i-1][j])%MOD;
            if(j - a[i] - 1 >= 0) dp[i][j] -= dp[i-1][j-a[i]-1];
            dp[i][j] %= (ll)MOD;
            if(dp[i][j] < 0) dp[i][j] += MOD;
        }
    }

    pr(dp[n][k]);
    return 0;}

Measured memory_bytes: 80256
//ABC100C
int main(void) {
  int n, a, i, cou=0;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf(" %d", &a);
    while(a%2==0)
      a/=2, cou++;
  }
  printf("%d", cou);
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
int n,m,ans,f[233333],num[233333];
inline int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)f[i]=i,num[i]=1;
	while(m--){
		int x,y;cin>>x>>y;
		int fx=find(x),fy=find(y);
		if(fx!=fy)f[fx]=fy,num[fy]+=num[fx],num[fx]=0;
	}
	for(int i=1;i<=n;i++)ans=max(ans,num[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 5216
while True:
    m, n_min, n_max = map(int, raw_input().split())

    if m == 0 and n_min == 0 and n_max == 0:
        break

    P = [int(raw_input()) for _ in range(m)]

    ans, t = 0, 0

    for i in range(n_min, n_max+1):
        if t <= P[i-1] - P[i]:
            ans = i
            t = P[i-1] - P[i]
    print ans



Measured memory_bytes: 4656
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=2e5+5;

int ara[mx];

void solve()
{
	int n;
	cin>>n;
	
	for(int i=1;i<n;i++)
	{
		int x;
		cin>>x;
		ara[x]++;
	}
	
	for(int i=1;i<=n;i++) cout<<ara[i]<<"\n";
	
}

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

	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int H,W;
	cin>>H>>W;
	vector<string> A(H);
	int i=0;
	int n=0;
	for (i=0;i<H;i++){
		cin>>A[i];
		int j=0;
		while (A[i][j]!='\0'){
			if (A[i][j]=='#'){
				n++;
			}
			j++;
		}
	}
	if (n==H+W-1){
		cout<<"Possible"<<endl;
		return 0;
	}else{
		cout<<"Impossible"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define vvll(name, M, N, val) vector<vector<long long>> name(M, vector<long long>(N, val))

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<long long> v(N);
    map<long long, int> num;
    for (int i = 0; i < N; i++) {
        cin >> v[i]; num[v[i]]++;
    }

    sort(v.begin(), v.end(), greater<long long>());

    double ave = 0;
    for (int i = 0; i < A; i++) {
        ave += (double)v[i];
    }
    ave /= (double)A;

    vvll(comb, N + 1, N + 1, 0);
    for (int i = 0; i <= N; i++) {
        comb[i][0] = 1;
        comb[i][i] = 1;
    }
    for (int i = 2; i <= N; i++) {
        for (int j = 1; j < i; j++) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }

    long long ch = 0;
    if (v[0] == v[A - 1]) {
        for (int i = A; i <= B; i++) {
            ch += comb[num[v[0]]][i];
        }
    } else {
        int pos = A;
        while (pos > 0) {
            if (v[A - 1] != v[pos - 1]) break;
            pos--;
        }
        ch = comb[num[v[A - 1]]][A - pos];
    }

    cout << fixed << ave << endl;
    cout << ch << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

const int N_MAX = 2000;
const int INF = 1e9;

int N, K, Q;
int A[N_MAX];

pair<int, int> ps[N_MAX];
map<int, int> ss;
vector<int> vs;
vector<int> ws;

void solve() {
  REP(i, N) ps[i] = make_pair(A[i], i);
  sort(ps, ps + N);
  ss[N] = 0;
  int ans = INF;
  int i = 0;
  while (i < N) {
    // printf("i: %d\n", i);
    vs.clear();
    ITR(ss, it) {
      int l = it->second;
      int r = it->first;
      int w = r - l;
      // printf(" l: %d, r: %d, w: %d", l, r, w);
      if (w >= K) {
        ws.clear();
        ws.insert(ws.end(), A + l, A + r);
        sort(ws.begin(), ws.begin() + w);
        vs.insert(vs.end(), ws.begin(), ws.begin() + w - K + 1);
        // printf(" : add %d items", w - K + 1);
      }
      // puts("");
    }
    // printf(" vs.size(): %d\n", vs.size());
    if (vs.size() < Q) break;
    sort(vs.begin(), vs.end());
    // printf(" vs[0]: %d, vs[%d]: %d\n", vs[0], Q - 1, vs[Q - 1]);
    ans = min(ans, vs[Q - 1] - vs[0]);
    int ai = ps[i].first;
    while (ps[i].first == ai) {
      int ap = ps[i].second;
      auto it2 = ss.lower_bound(ap);
      int l = it2->second;
      int r = it2->first;
      // printf(" x: %d, l: %d, r: %d\n", x, l, r);
      ss.erase(r);
      if (ap > l) ss[ap] = l;
      if (ap + 1 < r) ss[r] = ap + 1;
      i++;
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d%d", &N, &K, &Q);
  REP(i, N) scanf("%d", A + i);
}

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


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

max_d = A[0] + (K-A[-1])
for n in range(1,N):
  _ = A[n-1]
  __ = A[n]
  max_d = max(__-_, max_d)

ans = K-max_d
print(ans)

Measured memory_bytes: 78540
from numpy import*
n,a=open(0)
n=int(n)
a=cumsum(int64([0]+a.split()))
dp=zeros((n,n+1),'i8')
for k in range(1,n):
  l=arange(n-k)
  r=arange(k+1,n+1)
  m=(arange(1,k+1)+l[:,newaxis]).T
  dp[l,r]=amin(dp[l,m]+dp[m,r],0)+a[r]-a[l]
print(dp[0,n])

Measured memory_bytes: 15276
#include <stdio.h>
#include <string.h>
  
#define M 1046527
#define L 14
  
char H[M][L];
  
int char2int(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
  
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * char2int(str[i]);
    p *= 5;
  }
  return ret;
}
  
int h1(int key) {
  return key % M;
}
  
int h2(int key) {
  return 1 + (key % (M - 1));
}
  
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
  
int insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
  
int main(void) {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
  
    if(cmd[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 16952
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll s, c;
  cin >> s >> c;
  if (2*s >= c) {
    cout << c/2 << endl;
    return 0;
  }
  ll ans = s;
  c -= s*2;
  ans += c/4;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Author :
// Date :
// Problem:
// Solution:
// Comment:

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

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

map <char,int> mpp;

void play(string str){
    int start = 0;
    
    for(int i = 1 ; i < str.size() ; i++){
        if(mpp[str[i]] != mpp[str[i-1]]) start++;
    }
    
    cout << start << endl;
}
main(){
    mpp['q']=1;
    mpp['w']=1;
    mpp['e']=1;
    mpp['r']=1;
    mpp['t']=1;
    mpp['a']=1;
    mpp['s']=1;
    mpp['d']=1;
    mpp['f']=1;
    mpp['g']=1;
    mpp['z']=1;
    mpp['x']=1;
    mpp['c']=1;
    mpp['v']=1;
    mpp['b']=1;
    mpp['y']=2;
    mpp['u']=2;
    mpp['i']=2;
    mpp['o']=2;
    mpp['p']=2;
    mpp['h']=2;
    mpp['j']=2;
    mpp['k']=2;
    mpp['l']=2;
    mpp['n']=2;
    mpp['m']=2;
    
    string str;
    
    while(cin >> str){
        if(str == "#") break;
        play(str);
    }
    
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

Measured memory_bytes: 1192
n = int(input())
s = input()

rc = s.count('R')
gc = s.count('G')
bc = s.count('B')
ans = rc * gc * bc

for i in range(n-1):
  for j in range(i+1,n):
    k = j*2 - i
    if k >= n:
      continue
    if len(set([s[i],s[j],s[k]])) == 3:
      ans -= 1
      
print(ans)      

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

using namespace std;

const int N = 2e5+5;

int cm[N];

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        if(i == 0){
            cm[i] = (s[i] == 'R');
            continue;
        }
        cm[i] = cm[i - 1] + (s[i] == 'R');
    }
    int bst = cm[n - 1];
    for(int i = 0; i < n; i++){
        int reds = (cm[n - 1] - cm[i]);
        int alre = cm[i];
        if(alre == i+1){
            bst = min(bst , reds);
        } if(cm[n-1] - cm[i] - ((i+1) - cm[i]) >= 0) {
            bst = min(bst , ((i+1) - cm[i]) + (cm[n - 1] - cm[i] - ((i+1) - cm[i]) ));
            //cout << i << " : " << bst << "\n";
        }
    }
    cout << bst << "\n";
}


Measured memory_bytes: 4488
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n,k;
    string s;
    cin>>n>>s>>k;
    char q=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]!=q)s[i]='*';
    }
    cout<<s<<endl;
}

   


Measured memory_bytes: 888
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  map<ll, ll> m;
  ll ans = 0;
  rep(i, n) {
    ans += m[a[i]]++;
  }
  rep(i, n) {
    cout << ans - m[a[i]] + 1 << endl;
  }




  
  return 0;
}

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

int ans[365];

int main(){
	int N,x,y;	//日数、値段
	int b,p;	//買う枚数(0〜6枚)
	int i;
	cin >> N;
	for(i = 0;i < N;i++){
		cin >> x >> y >> b >> p;
		int sum;
		if(b >= 5 && p >= 2){
			sum = ((x*b+y*p)*80)/100;
		}
		else if(b >= 5){
			sum = x*b+y*p;
			if(sum > ((x*b+y*2)*80)/100)
				sum = ((x*b+y*2)*80)/100;
		}
		else if(p >= 2){
			sum = x*b+y*p;
			if(sum > ((x*5+y*p)*80)/100)
				sum = ((x*5+y*p)*80)/100;
		}
		else{
			sum = x*b+y*p;
			if(sum > ((x*5+y*2)*80)/100)
				sum = ((x*5+y*2)*80)/100;
		}
		ans[i] = sum;
	}
	for(i = 0;i < N;i++)
		cout << ans[i] << endl;
	return 0;				
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int H, W, res;
char c;
vector<int>v[1000];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			if (c == 'B') {
				v[i].push_back(j);
			}
		}
	}
	for (int i = 0; i < H; ++i) {
		if (!v[i].empty()) {
			for (int j = 0; j < H; ++j) {
				if (!v[j].empty()) {
					res = max(res, abs(i - j) + max(abs(v[i].front() - v[j].back()), abs(v[i].back() - v[j].front())));
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 6592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int gcd(ll a, ll b) {
	
	if (b == 0)return a;	
		return gcd(b, a % b);
}

int main() {
	ll a,b;
	cin >> a >> b;
	ll ans = a * b / gcd(a, b);
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29



def main():
    S = sRaw()

    ans = "Yes" if S[2]==S[3] and S[4]==S[5] else "No"
    return ans

if __name__ == "__main__":
    print(main())


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

int main(){
  int w;
  int n;
  vector<int> vertical;
  int a,b;

  cin>>w;

  for(int i=1;i<=w;++i)
    vertical.push_back(i);

  cin>>n;

  for(int i=0;i<n;++i){
    scanf("%d,%d",&a,&b);
    swap(vertical[a-1],vertical[b-1]);
  }

  for(auto i:vertical)
    cout<<i<<endl;

}

Measured memory_bytes: 3216
N = gets.to_i

data = []
(N - 1).times do
  data << gets.split.map(&:to_i)
end

(N - 1).times do |i|
  t = data[i][1]

  i.upto(N - 2) do |j|
    if t < data[j][1]
      t = data[j][1]
    end
    unless t % data[j][2] == 0
      t += data[j][2] - t % data[j][2]
    end

    t += data[j][0]
  end

  p t
end

p 0


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s[5000];
ll ans(ll a,ll b,ll c)
{
ll x=max({a,b,c});
    ll y=min({a,b,c});
    return x-y;
}
ll test(ll x,ll y)
{
    ll z=INT_MAX,a,b,c;
    for(int i=1; i<y; i++)
    {
        a=i*x;
        ll rem=y-i;
        if(rem==1)
        {
            ll mul=x/2;
            b=mul*rem;
            if(x%2)
                mul++;
            c=mul*rem;
            z=min(z,ans(a,b,c));
        }
        else
        {
            ll mul=x/2;
            b=mul*rem;
            if(x%2)
                mul++;
            c=mul*rem;
            z=min(z,ans(a,b,c));
            mul=rem/2;
            b=x*mul;
            if(rem%2)
                mul++;
            c=x*mul;
            z=min(z,ans(a,b,c));
        }
    }
    return z;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,x,y,z=INT_MAX;
    cin>>x>>y;
    cout<<min(test(x,y),test(y,x))<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

int main()
{
    int N;
    cin >> N;
    vi brick(N);
    rep(i, N)
        cin >> brick[i];

    int pointer = 1;
    rep(i, N)
    {
        if(brick[i] == pointer)
            pointer++;
    }
    if(pointer == 1)
        cout << -1 << endl;
    else
        cout << N - (pointer - 1) << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		
		long money = 1000;
		long stock = 0;
		
		for(int i=0; i<N; i++) {
			if(i<N-1 && A[i]<A[i+1]) {
				long buy = money/A[i];
				money -= buy*A[i];
				stock += buy;
			} else {
				money += stock*A[i];
				stock = 0;
			}
		}
		
		System.out.println(money);
		
		sc.close();

	}
	
}


Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
const int mod = 1000000007;
//const int mod = 998244353;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    
    for(ll i=k; i<=n+1; i++){
        ans += (2*n -(i-1))*i/2;
        ans -= (i-1)*i /2;
        ans += 1;
        ans %= mod;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N = 250001;
const long long M = (long double)1e18 + 31,b = 1e9 + 7;
long long cs[N],p[N],n;
map<long long,int>mp;
void add(long long &a,long long b){
	a+=b;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
long long power(long long base,long long to){
	long long ret = 1;
	while(to){
		if(to&1)ret = (__int128)ret*base%M;
		to>>=1;
		base = (__int128)base*base%M;
	}
	return ret;
}
int main(){
//	freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	p[0] = 1;
	char c;
	long long inv = power(b,M - 2);
	for(int i = 1;i <= n;i++){
		scanf(" %c",&c);
		cs[i] = cs[i - 1];
		p[i] = p[i - 1];
		if(c == '+')add(cs[i],p[i]);
		else if(c == '-')add(cs[i],-p[i]);
		else if(c == '>')p[i] = (__int128)p[i]*b%M;
		else if(c == '<')p[i] = (__int128)p[i]*inv%M;
	}
	long long ans = 0;
	for(int i = 0;i <= n;i++){
		ans+=mp[cs[i]];
		mp[((__int128)cs[n]*p[i]%M + cs[i] + M)%M]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 35328
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){

    long long int n, a, b, x;
    
    scanf("%lld %lld %lld", &n, &a, &b);
    if (a > b || n == 1 && a != b) {
        x = 0;
    }
    else{
        x = (b - a) * (n - 2) + 1;
    }
    printf("%lld", x);
}

Measured memory_bytes: 1716
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let _ = lines.next();
    let a_line = lines.next().unwrap().unwrap();
    let splited = a_line.trim().split_whitespace();
    let mut ls: Vec<i32> = splited.map(|s| s.parse().unwrap()).collect();
    ls.sort();

    let mut ans = 0;
    for i in 0..ls.len() {
        for j in i + 1..ls.len() {
            let k = bin_search(&ls[j + 1..], (ls[i] - ls[j]).abs(), ls[i] + ls[j]);
            ans += k;
        }
    }

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn bin_search(ls: &[i32], n0: i32, n1: i32) -> i32 {
    let mut ans = 0;
    for i in 0..ls.len() {
        if ls[i] <= n0 {
            continue;
        }
        if n1 <= ls[i] {
            break;
        }
        ans += 1;
    }
    ans
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"4
3 4 2 1",
            br"1
",
        ),
        (
            br"3
1 1000 1",
            br"0
",
        ),
        (
            br"7
218 786 704 233 645 728 389",
            br"23
",
        ),
    ];

    #[test]
    fn test_d() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}
signed main(){
  int n;cin>>n;
  int res=inf;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int buf=a[0];
  rep1(i,n-1){
    buf=gcd(buf,a[i]);
  }
  cout<<buf<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
void swap(int *x,int *y){
int k;
k=*x;
*x=*y;
*y=k;
}
int func(int a){
int i,j,x[8],max,min;
x[0]=a%10;
x[1]=a/10%10;
x[2]=a/100%10;
x[3]=a/1000%10;
x[4]=a/10000%10;
x[5]=a/100000%10;
x[6]=a/1000000%10;
x[7]=a/10000000%10;
for(j=0;j<8;j++)
for(i=0;i<7;i++)
if(x[i]<x[i+1])swap(&x[i],&x[i+1]);
min=10000000*x[7]+1000000*x[6]+100000*x[5]+10000*x[4]+1000*x[3]+100*x[2]+10*x[1]+x[0];
max=10000000*x[0]+1000000*x[1]+100000*x[2]+10000*x[3]+1000*x[4]+100*x[5]+10*x[6]+x[7];
return max-min;
}
int main(){
int n,a;
scanf("%d",&n);
while(n-->0){
scanf("%d",&a);
printf("%d\n",func(a));
}
return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}
}

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

int main()
{
    int k,x;
    cin>>k>>x;
    vector <int>vec;
    for(int i=0;i<k;i++)
    {
       vec.push_back(x-i);
    }
    for(int i=1;i<k;i++)
    {

       vec.push_back(x+i);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<vec.size();i++)
        {
        cout<<vec[i]<<" ";
        }
    return 0;
}


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

bool able;
void rec(queue<int> A,stack<int> B,stack<int> C){
	if( A.empty() ){
		able = true;
		return;
	}
	
	int tp = A.front();
	
	A.pop();
	
	if(tp > B.top() ){
	 	B.push(tp);
	 	rec(A,B,C);
	}
	if(tp > C.top() ){
	 	C.push(tp);
	 	rec(A,B,C);
	}
	
	return ;
}
int main(){
	int n,t;
	stack<int>a,b;
	a.push(0);
	b.push(0);
	cin >> n;
	while(n--){
		queue<int>input;
			able = false;
		for(int i=0;i<10;i++){
			cin >> t;
			input.push(t);
		}
		rec(input,a,b);
		cout << (able?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    
    //縦の変数：H と 横の変数：W を宣言する
    int H, W;
    
    //縦の変数：H と 横の変数：W に値を代入する
    cin >> H >> W;
    
    //縦の変数：H と 横の変数：W の値が両方とも 0 になるまで繰り返す。
    while(H != 0 && W != 0){
        
        //一行づつ「 # or . 」を置いて行くから繰り返し処理を使用する。
        //今回は繰り返し処理の中に繰り返し処理がある！!　➡　考えよう！！！！！
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                
                //枠の条件を考える。
                if(i == 0 || i == H-1 || j==0 || j == W-1) cout << "#";
                else cout << ".";
            }
            
            // 1行が終了したら改行が必要なので、改行を出力する。
            cout << endl;
        }
        
        // 1つの四角形が終了したら改行が必要なので、改行を出力する。
        cout << endl;
        
         //縦の変数：H と 横の変数：W に値を代入する
        cin >> H >> W;

    }
    
    return 0;
}



/****************************************　for文　***************************************************


☆繰り返し処理をしたいときは「　for文　」を使用する


    〇書き方
    for(始まりの値； 条件式；　増加 or 減少の式){
        
    }
        
    
*********************************************************************************************************/



/****************************************　コメント無し回答　***************************************************

#include <iostream>
using namespace std;
int main(void){
    
    int H, W;
    cin >> H >> W;
    。
    while(H != 0 && W != 0){
  
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
            
                if(i == 0 || i == H-1 || j==0 || j == W-1) cout << "#";
                else cout << "*";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    
    return 0;
}
    
*********************************************************************************************************/


Measured memory_bytes: 3032
class SegmentTree:
    def __init__(self, a: list, e: 'default', f: 'function'):
        n = len(a)
        size = 1 << (n - 1).bit_length()  # 元の配列サイズ以上の最小の二冪 == 最下段
        v = [e] * (size * 2 - 1)
        for i in range(n):
            # size-1個の上段の次、size個目からn個が元の配列の代入位置
            v[size - 1 + i] = a[i]
        for i in range(size - 2, -1, -1):
            v[i] = f(v[i * 2 + 1], v[i * 2 + 2])

        self.n = n  # 元の配列の長さ
        self.size = size  # 元の配列サイズ以上の最小の二冪 == 最下段の要素数
        self.v = v  # Segtreeの配列
        self.e = e  # 初期値
        self.f = f  # 比較関数

    def update(self, k: 'index', x: 'val'):
        k += self.size - 1  # 最下段のindexに変更する
        self.v[k] = x  # 値を更新する
        while k > 0:
            k = (k - 1) // 2  # 親のindex
            self.v[k] = self.f(self.v[k * 2 + 1], self.v[k * 2 + 2])

    def get(self, a, b, k=0, l=0, r=-1):
        # [a,b)区間の処理結果を返す
        # 注目区間[l,r)
        if r < 0:
            r = self.size

        if r <= a or b <= l:
            return self.e
        # 区間が重ならない

        if a <= l and r <= b:
            return self.v[k]
        # 完全被覆

        m = (l + r) // 2
        vl = self.get(a, b, k * 2 + 1, l, m)
        vr = self.get(a, b, k * 2 + 2, m, r)
        return self.f(vl, vr)
        # 部分被覆


def solve(n, h, a):
    seg = SegmentTree([0] * (n + 1), 0, max)
    for i in range(n):
        tmp = seg.get(0, h[i])
        seg.update(h[i], tmp + a[i])
        # 1回あたり更新するのは1箇所だから、iを状態にもつ必要はなくて、配列を使い回すことができる
        # 区間maxが高速に計算できればいいから、セグメント木を使えばできる
    return seg.get(0, n + 1)


if __name__ == '__main__':
    import sys

    input = sys.stdin.readline

    n = int(input())
    h = tuple(map(int, input().rstrip().split()))
    a = tuple(map(int, input().rstrip().split()))
    print(solve(n, h, a))

# https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035


Measured memory_bytes: 126956
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun func (p l c)
  (if (> c (expt 10 5))
	-1
	(if (= p 1)
	  c
	  (func (aref l p) l (1+ c)))))

(let* ((n (read))
	   (l (concatenate 'vector
					   (loop for i from 1 to n collect(1- (read))))))
  (princ (func 0 l 0)))


Measured memory_bytes: 63544
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

const int MAX_C = 100;
ll Com[MAX_C][MAX_C];
void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]) ;
        }
    }
}

int main(){
    calc_com();
    
    int n,a,b;
    cin>>n>>a>>b;
    ll v[n];
    rep(i,n) cin>>v[i];
    sort(v,v+n,greater<ll>());
    //平均=でかいものからa個だけとったものの和/A
    ll suma=0;
    for(int i=0;i<a;i++){
        suma+=v[i];
    }
    double ans1=(double)((double)suma/(double)a);

    //a+1個目から見ていってa+1個目が平均と同じ値ならそれを付け加えてもいい
    ll ans2=0;
    ll c=0,ot=0;bool f=true;
    for(int i=0;i<n;i++){
        if(v[a-1]==v[i]){
            c++;
            f=false;
        }
        if(f) ot++;
    }
    if(ot!=0){
        ans2=Com[c][a-ot];
    }
    else{
        for(int i=a;i<=b;i++){
            ans2+=Com[c][i];
        }
    }
    printf("%f\n",ans1);
    cout<<ans2<<endl;
    
    return 0;
}

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

const int MOD = 1000000007;

void    Init(vector<vector<ll>> &DP) {
    for (ll i=0; i<DP.size(); i++) {
        DP.at(i).at(0)=0;
        DP.at(i).at(1)=1;
    }
    for (ll i=1; i<DP.at(1).size(); i++)
        DP.at(1).at(i)=1;
}

int main() {
    ll n, k;
    cin >>n >>k;
    vector<vector<ll>> DP(n+1, vector<ll> (k+1, -1));
    Init(DP);
    for (ll i=2; i<=n; i++)
        for (ll j=2; j<=k; j++) {
            DP.at(i).at(j) = DP.at(i).at(j-1); //One more empty box
            DP.at(i).at(j) += DP.at(i-1).at(j-1)-DP.at(i-1).at(j-2)+MOD;
                // Full j-1 box w/i-1 balls, add box j w/ ball i
            DP.at(i).at(j) %=MOD;
            DP.at(i).at(j) += (DP.at(i-1).at(j)-DP.at(i-1).at(j-1)+MOD)*j%MOD;
                // Full j box w/i-1 balls, add ball i
            DP.at(i).at(j) %=MOD;
        }
    cout <<DP.at(n).at(k) <<endl;
    return 0;
}


Measured memory_bytes: 10804
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,K,Q;
  cin >> N >> K >> Q;

  vector<int> s(N,K),A(N,0);
  for(int i = 0;i < Q;i++) {
    int a;
    cin >> a;
    A.at(a-1)++;
  }

  for(int i = 0;i < N;i++) {
    s.at(i) -= (Q-A.at(i));
    if(s.at(i) <= 0) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }

  
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll dp[3002][3002][4];
ll mat[3002][3002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll R,C,k,r,c,v;
	cin>>R>>C>>k;
	for (int i = 0; i < k; i++)
	{
		cin>>r>>c>>v;
		mat[r][c]=v;
	}
	for (int i = R; i >=1; i--)
	{
		for (int j = C; j >=1; j--)
		{
			for (int a = 0; a <= 3; a++)
			{
				if (a==0)
				{
					dp[i][j][a] = max(dp[i][j+1][a], dp[i+1][j][3]);
				}
				else{
				dp[i][j][a]=max(dp[i][j+1][a], mat[i][j]+max(dp[i][j+1][a-1], dp[i+1][j][3]));
				}
			}
		}
	}
	// for (int i = 0; i <= 3; i++)
	// {
	// 		cout<<dp[R-1][C-1][i]<<endl;	
	// }	
	cout<<dp[1][1][3]<<endl;
	return 0;
}


Measured memory_bytes: 378516
N = int(input())
K = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(N):
    if(x[i] >= abs(x[i]-K)):
        ans += 2*abs(x[i]-K)
    else:
        ans += 2*x[i]
print(ans)

Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
        public static (long, long) Get2Longs()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            return (inputs[0], inputs[1]);
        }
    }

    public class Program
    {
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M) = CR.Get2Longs();
            A = CR.GetLongs();

            var studyDays = A.Sum();

            return studyDays > N ? -1 : (N - studyDays);
        }
    }
}


Measured memory_bytes: 29204
list = [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]
n = gets.to_i

puts list[n-1]

Measured memory_bytes: 1788