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

using namespace std;

int main()
{
	int n;

	while (cin >> n, n) {
		int s = 0;

		for (int i = 1; i * i <= n; ++i) {
			if (n % i == 0) {
				s += i;
				if (n / i != n && i * i != n) s += n / i;
			}
		}

		cout << ((s < n || n == 1) ? "deficient number" : s > n ? "abundant number" : "perfect number") << endl;
	}
}

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

int main() {
    int N,M;
    cin >> N >> M;
    int answer = 0;
    vector<int> v_1(N);
    vector<int> v_s(M);
    vector<int> v_c(M);

    for (int l = 0; l < M ; ++l) {
        cin >> v_s.at(l);
        cin >> v_c.at(l);
    }

    if (N > 1) {
        v_1.at(0) = 1;
    }

    for (int k = 0; k < M ; ++k) {
        v_1.at((v_s.at(k) - 1)) = v_c.at(k);
    }


    if ( N == 1) {
        answer = v_1.at(0);
    }
    else if ( N == 2 ) {
        answer = v_1.at(0) * 10 + v_1.at(1);
    }
    else {
        answer = v_1.at(0) * 100 + v_1.at(1) * 10 + v_1.at(2);
    }

    if (N > 1) {
        for (int i = 0; i < M ; ++i) {
            if (v_s.at(i) == 1 && v_c.at(i) ==0) {
                answer = -1;
            }
        }
    }


    for (int i = 0; i < M ; ++i) {
        for (int j = 0; j < M ; ++j) {
            if (i == j) {
                //なんもない
            }
            else if (v_s.at(i) == v_s.at(j) && v_c.at(i) != v_c.at(j)){
                answer = -1;
            }
        }

    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 2e5 + 10;
int f[maxn];
int main(){
	int n,ans;
	scanf("%d",&n);ans = n - 1;
	for(int i = 1;i <= n;i++){
		int x;
		scanf("%d",&x);
		f[x] = f[x - 1] + 1;
		ans = min(ans,n - f[x]);
	} 
	printf("%d",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    cout << (N - A) % B << endl;
}


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

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

	vector<int> a(m,0);
	for(int i=0; i<n; i++){
		int k;
		cin >> k;
		while(k--){
			int b;
			cin >> b;
			a[b-1]++;
		}
	}

	int ans = 0;
	for(int i=0; i<m; i++) if(a[i]==n) ans++;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		int a = in.nextInt(), b = in.nextInt();
		int c = in.nextInt(), d = in.nextInt();
		int ans = a * b;
		
		if (c*d > ans)
			ans = c * d;
		
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21460
#include <iostream>

using namespace std;

long long int n,a[5000];

int main(){

	long long int i,j,t,tmp;

	while(cin >> n && n){

		tmp = 0;

		t = -1000000;

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

			cin >> a[i];

		}

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

			tmp += a[i];

			if(t < tmp) t = tmp;

			if(i!=n-1){

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

					tmp += a[j];

					if(t < tmp) t = tmp;

				}

			}

			tmp = 0;

		}

		cout << t << endl;

	}

	return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int N;	cin >> N;
  int tmp = N;
  int count = 0;
  
  while(tmp != 0){
    count += 1;
    tmp /= 10;
  }

  int ans = 0;
  if(count == 6){
    ans = 90909;
  }else if(count == 5){
    ans += 909;
    ans = ans + N - 10000 + 1;
  }else if(count == 4){
    ans = 909;
  }else if(count == 3){
    ans += 9;
    ans = ans + N - 100 + 1;
  }else if(count == 2){
    ans += 9;
  }else if(count == 1){
    ans = N;
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  CIN(h,w);
  M m;
  REP(i,h){
    SCIN(s);
    REP(j,w)
      m[s[j]]++;
  }
  ll ky=0;
  ll kyy=0;
  if(h&1)ky+=w;
  if(w&1)ky+=h;
  if(h&1&&w&1){kyy++;ky-=2;}
  ll kyyy=h*w-ky-kyy;
  //dump(kyyy);dump(ky);dump(kyy);
  FOREACH(xx,m){
    ll t = min(xx.second/4*4,kyyy);
    xx.second-=t;
    kyyy-=t;
  }
  FOREACH(xx,m){
    ll t = min(xx.second/2*2,ky);
    xx.second-=t;
    ky-=t;
  }
  FOREACH(xx,m){
    ll t = min(xx.second,kyy);
    xx.second-=t;
    kyy-=t;
  }
  if(ky||kyy||kyyy)EN(No);

  Yes(1);
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int N;
vector<vector<int> > G;

int dfs(int x, int pr){
    int ret = 0;
    for(auto next : G[x]){
        if(next==pr) continue;
        ret += dfs(next, x);
    }

    if(ret>=2){
        cout << "First" << endl;
        exit(0);
    }
    if(ret==0) return 1;
    return 0;
}

int main(){
    cin >> N;
    G.resize(N);
    FOR(i,0,N-1){
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //１個だけの時?
    if(dfs(0,0)){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
# coding: utf-8
import numpy as np
N, S = list(map(int, input().split()))
A = [0]+list(map(int, input().split()))

dt = np.array([[0 for _ in range(S+1)] for x in range(N+1)])

for n in range(1, N+1):
  if A[n] <= S:
    dt[n,A[n]] += n
  if A[n] < S:
    dt[n, A[n]+1:] += dt[n-1,1:S-A[n]+1] - dt[n-2,1:S-A[n]+1]
  dt[n,:] += dt[n-1,:] * 2 - dt[n-2,:]
  dt[n,:] %= 998244353
print(dt[N,S] % 998244353)

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

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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

double dis(double x1, double y1, double x2, double y2){
    double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
    return d;
}
int main()
{
    ll n;
    double dsum = 0;
    cin >> n;
    vector<double> x(n),y(n);
    rep(i,n)cin >> x[i] >> y[i];
    rep(i,n-1)REP(j,i+1,n)dsum += dis(x[i],y[i],x[j],y[j]);
    printf("%.10f\n", dsum*2 / n);

    return 0;
}

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

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int N;
    cin >> N;
    int X = 0;
    while (1) {
        ++X;
        if (X * X > N) { break; }
    }
    cout << (X - 1) * (X - 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	int n;
	cin >> n;

	cout << pow(n, 3)<< endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int H, W;
string bo[110];
bool gx[110], gy[110];

int main()
{
        //input->compute->output//

        cin >> H >> W;

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

                cin >> bo[i];
        }

        for (int i = 0; i < H; i++)
        {
                for (int j = 0; j < W; j++)
                {
                        if (bo[i][j] == '#')
                        {
                                gx[i] = true;
                                gy[j] = true;
                        }
                }
        }

        for (int i = 0; i < H; i++)
        {
                if (gx[i])
                {
                        for (int j = 0; j < W; j++)
                        {
                                if (gy[j])
                                {

                                        cout << bo[i][j];
                                }
                        }
                        cout << endl;
                }
        }

        return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int p[55],copy[55];
int main(){
	int n,num=0,flag=0;
	cin>>n;
	while(n--){
		cin>>p[num++];
	//	copy[num-1]=p[num-1]; 
	}
	for(int i=1;i<=num;i++){
		if(i!=p[i-1])flag++;
	}
	if(flag==2||flag==0)printf("YES\n");
	else printf("NO\n");
}

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

using namespace std;

int n, p;
int a, b[53];

int main(){
	while (cin >> n >> p){
		if (!n&!p) break;
		for (int i = 0; i < 53; i++) b[i] = 0;
		int i = 0;
		a = p;
		while (true){
			if (a > 0) {
				b[i]++; a--;
			}
			else if (a == 0){
				a = b[i]; b[i] = 0;
			}
			if (b[i] == p) break;
			if (i == n - 1) i = 0;
			else i++;
		}
		cout << i << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    double input[n];
    rep(i, n) cin >> input[i];
    sort(input, input+n);
    double res = input[0];
    for(int i=0; i<n; i++) res = (res + input[i])/2;
    cout << res << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = n; i >= 1; i--) {
    // i以下の数とiの組み合わせで条件を満たすものを数える
    int m = to_string(i).size();
    int first = i / pow(10, m - 1);
    int last = i % 10;
    if (last == 0) continue;
    if (i < 10) {
      ans++;
    } else if (first == last) {
      // 桁が同じもの
      int add = (i - first * pow(10, m - 1)) / 10;
      ans += 2 * add;
      // i以外
      ans += 1;  // i自身との組み合わせ
      // 桁が違うもの
      for (int l = m - 1; l >= 1; l--) {  // l:桁数
        if (l <= 2) {
          ans += 2;
        } else {
          ans += 2 * pow(10, (l - 2));
        }
      }
    } else if (first > last) {
      // 桁数が同じものも含む
      for (int l = m; l >= 1; l--) {  // l:桁数
        if (l == 1) continue;
        if (l == 2) {
          ans += 2;
        } else {
          ans += 2 * pow(10, (l - 2));
        }
      }
    } else {
      for (int l = m - 1; l >= 1; l--) {  // l:桁数
        if (l == 1) continue;
        if (l == 2) {
          ans += 2;
        } else {
          ans += 2 * pow(10, (l - 2));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4112
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

long long int optimalBST_KY(vector<long long int>&nums) {
	vector<long long int>sums(nums.size()+1);
	vector<vector<long long int>>anss(nums.size(), vector<long long int>(nums.size()+1));
	vector<vector<int>>ks(nums.size(), vector< int>(nums.size()+1));
	sums[0] = 0;
	for (int i = 0; i < nums.size(); ++i) {
		sums[i+1] = sums[i]+nums[i];
		
	}
	
	for (int i = 0; i < nums.size(); ++i) {
		for (int j = 0; j <= nums.size(); ++j) {

			anss[i][j] = 1e18;
		}
		anss[i][i+1] = 0;
		ks[i][i+1] = i; // +
	}
	//for (int w = 1; w <= n; ++w)
	//	for (int i = 0, j; (j = i + w) <= n; ++i)
	//		for (int r = K[i][j - 1]; r <= K[i + 1][j]; ++r) { // c
	//			int c = X[i][r] + X[r + 1][j] + W[i][j];
	//			if (X[i][j] > c) { X[i][j] = c; K[i][j] = r; } // c
	//		}

	for (int len =2; len <= nums.size(); ++len) {
		for (int l = 0; l + len <= nums.size(); ++l) {
			const int r = l + len;
			for (int c = ks[l][r - 1]; c <= ks[l + 1][r]; ++c) {
				const long long int ans = anss[l][c] + anss[c][r] + sums[r]-sums[l];
				if (anss[l][r] > ans) {
					anss[l][r] = ans;
					ks[l][r] = c;
				}
			}
		}
	}
	return anss[0][nums.size()];
}
int main() {
	int N; cin >> N;
	vector<long long int>ws(N);
	for (int i = 0; i < N; ++i)cin >> ws[i];
	const long long int ans = optimalBST_KY(ws);
	cout << ans << endl;
	return 0;
}

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

string s, t;
int n;

bool check(){
	for (int i=0; i<n; ++i)
		if (s[i] != t[i])
			return false;
	return true;
}

void solve(){
	for (int i=1; i<=n; ++i){
		if (check()){
			cout << "Yes";
			return;
		}
		string tmp;
		tmp += s[n-1];
		for (int j=0; j<n-1; ++j) tmp += s[j];
		s = tmp;
	}
	cout << "No";
}

int main(){
	getline(cin, s);
	getline(cin, t);
	n = s.length();
	solve();
	return 0;
}

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

void ratio(int t, int a, long long* sumt, long long* suma){
  long long sumT = *sumt, sumA = *suma;
  while(sumT % t != 0){
    sumT ++;
  }
  if(sumT / t * a < sumA){
    while(sumA % a != 0){
      sumA ++;
    }
    sumT = sumA / a * t;
  }
  else sumA = sumT / t * a;
  *suma = sumA;
  *sumt = sumT;
}




int main(){
  int N, i;
  scanf("%d", &N);
  int T[N], A[N];
  for(i = 0; i < N; i ++){
    scanf("%d %d", &T[i], &A[i]);
  }
  long long sumT, sumA;
  sumT = T[0];
  sumA = A[0];
  for(i = 1; i < N; i ++){
    ratio(T[i], A[i], &sumT, &sumA);
  }
  printf("%lld\n", sumT + sumA);
  return 0;
}




Measured memory_bytes: 128
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (n, k) = {
        let vec = read_vec::<usize>();
        (vec[0], vec[1])
    };
    let dices = read_vec::<f64>();
    let mut sum = 0.0f64;
    let mut result = 0.0f64;
    for i in 0..n {
        sum += (dices[i] * (dices[i] + 1f64) / 2f64) / dices[i];
        if i < k - 1 { continue; }
        if i >= k {
            sum -= (dices[i - k] * (dices[i - k] + 1f64) / 2f64) / dices[i - k];
        }
        result = if sum > result { sum } else { result };
    }
    println!("{}", result);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 8444
"""
from functools import reduce
from operator import mul

N = int(input())
A = list(map(int, input().split()))

result = reduce(mul, A)
print(result if result <= 10**18 else -1)
"""
import sys

N = int(input())
A = list(map(int, input().split()))
A.sort()

result = 1
for a in A:
    result *= a
    if result > 10**18:
        print(-1)
        sys.exit()
else:
    print(result)

Measured memory_bytes: 21748
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18
 
 
using namespace std;
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i;
    cin>>n;
    vi a(n),b(n);
    for(i=0;i<n;i++) cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==1) cout<<b[n/2]-a[n/2]+1<<endl;
    else
    {
        int p,q,r,s;
        p=a[n/2-1];
        q=b[n/2-1];
        r=a[n/2];
        s=b[n/2];
        cout<<q+s-r-p+1;
    }
}

Measured memory_bytes: 6340
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,m,i,j,c,ans=0;
  cin>>n>>m>>c;
  int b[m];
  int codes[n][m];
  for(i=0;i<m;i++)
  {
  	cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
  	int temp=0;
  	for(j=0;j<m;j++)
  	{
  		cin>>codes[i][j];
  		temp+= (b[j]*codes[i][j]);
  	}
  	temp+=c;
  	if(temp>0)
  		ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB_tmp solver = new TaskB_tmp();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB_tmp {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();

            String substr = new String();
            int maxLen = 0;
            for (int i = 1; i <= str.length(); i++) {
                for (int j = 0; j < str.length() - i + 1; j++) {
                    //strからj~ i文字の部分文字列
                    substr = str.substring(j, j + i);
                    if (isAGCT(substr) && substr.length() > maxLen) {
                        //System.out.println(substr);
                        maxLen = substr.length();
                    }
                }
            }
            out.println(maxLen);
        }

        private boolean isAGCT(String target) {
            for (int i = 0; i < target.length(); i++) {
                //System.out.println(target.charAt(i));
                if (target.charAt(i) != 'A' && target.charAt(i) != 'G' && target.charAt(i) != 'C' && target.charAt(i) != 'T') {
                    return false;
                }
            }
            return true;
        }

    }
}



Measured memory_bytes: 23252
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let x: u32 = s.trim().parse().unwrap();
	let mut sieve = vec![true; 100003 + 1];
	sieve[0] = false;
	sieve[1] = false;
	for i in (2..).take_while(|i| i * i < 100004) {
		if sieve[i] {
			for j in (2..).map(|j| j * i).take_while(|j| *j < 100004) {
				sieve[j] = false;
			}
		}
	}
	for x in x as usize.. {
		if sieve[x] {
			println!("{}", x);
			break;
		}
	}
}


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

bool all123(int t){
    bool flag[4];
    for(int i=0; i<4; i++){
        flag[i]=false;
    }
    while(t>0){
        int a = t%4;
        flag[a]=true;
        t=t/4;
    }
    return flag[1]&&flag[2]&&flag[3];
}

int main(){
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int l[10];
    for(int i=0; i<N; i++){
        cin >> l[i];
    }

    int INF = pow(10,7);
    int cost = INF;

    int D[4];
    for(int i=0; i<pow(4,N); i++){
        if(!all123(i)) continue;
        int k=i;
        int cnt=0;
        D[0]=0; D[1]=0; D[2]=0; D[3]=0;
        for(int j=0;j<N;j++){
            int b = k%4;
            if(b>0) cnt++;
            D[b] += l[j];
            k =k/4;
        }
        cost = min(cost, 10*(cnt-3) +abs(A-D[1])+abs(B-D[2])+ abs(C-D[3]));
    }

    cout << cost << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
public class Main{
	static ArrayList<Integer>[] list;
	static boolean[] check;
	static int n;
	static int count;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();
		int m=sc.nextInt();
		list=new ArrayList[n];
		check=new boolean[n];
		for(int i=0; i<n; i++){
			list[i]=new ArrayList<>();
		}
		int[][] ab=new int[m][2];
		for(int i=0; i<m; i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			list[a].add(b);
			list[b].add(a);
			ab[i][0]=a;
			ab[i][1]=b;
		}
		int ans=0;
		for(int i=0; i<m; i++){
			count=0;
			Arrays.fill(check,false);
			if(dfs(ab[i][0],ab[i][1],0)){
				ans++;
			}
		}
		System.out.println(ans);
	}
	static boolean dfs(int a,int b,int now){
		count++;
		if(count==n){
			return false;
		}
		check[now]=true;
		for(int i:list[now]){
			if(!check[i] && !(now==a && i==b) && !(now==b && i==a)){
				if(!dfs(a,b,i)){
					return false;
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define wh while
#define db double
#define pb .push_back
#define sz .size()
#define vc vector
#define vcd vector <double>
#define vcf vector <float>
#define vci vector <int>
#define vcs vector <string>
#define sti set <int>
#define fi .first
#define se .second
#define yes true
#define no false
#define bg .begin()
#define ed .end()
#define ad a,b,c,d
#define till n i<n.size();
set <int> A;
vector <int> B;
vector <int> C;
vector <int> D;
sti G;
bool t;
bool f;
int cnt=0;
int main(){
    int n,cnt=0,mx=0;
    string a;
    cin>>n>>a;
    for(int i=0;i<n;i++){
        if(a[i]=='I'){
            cnt++;
            if(mx<cnt){
                mx=cnt;
            }
        }
        else
            cnt--;
    }
    cout<<mx;
















}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
  long long h, copy, count = 1, ans = 1;
  cin >> h;
  copy = h;
  while(copy > 1){
    count*= 2;
    copy /= 2;
    ans += count;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            if x != y:
                self.size[y] += self.size[x]
        else:
            self.par[y] = x
            if x != y:
                self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]


u = UnionFind(n)
for a, b in ab:
    u.union(a, b)

removes = [0] * (n + 1)
for a, b in ab:
    if u.same_check(a, b):
        removes[a] += 1
        removes[b] += 1
for c, d in cd:
    if u.same_check(c, d):
        removes[c] += 1
        removes[d] += 1

ans = ''
for i in range(1, n + 1):
    tmp = u.get_size(i) - removes[i] - 1
    ans += str(tmp) + ' '
print(ans[:-1])


Measured memory_bytes: 60232
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

map<string, int> M;

void input(string &s, string &a, string &b, string &c, string &d){
  int i = 0;
  while(s[i] != '.' && s[i] != ' ') a += s[i++];
  if(s[i] == '.'){
    ++i;
    while(s[i] != ' ') b += s[i++];
  }
  ++i;
  while(i < s.length() && s[i] != ' ') c += s[i++];
  if(i < s.length() && s[i] == ' '){
    ++i;
    while(i < s.length()) d += s[i++];
  }
  if(d == ""){ d = c; c = ""; }
}

void shift_left(string &a, string &b){
  if(b == "") a += "0";
  else{
    a += b.substr(0, 1);
    b = b.substr(1);
  }
  while(a.length() > 0 && a[0] == '0') a = a.substr(1);
}

void shift_right(string &a, string &b){
  if(a == "") b = "0" + b;
  else{
    b = a.substr(a.length() - 1) + b;
    a = a.substr(0, a.length() - 1);
  }
}

int check(string a, string b){
  int res = a.length() + b.length();
  bool f = false;
  for(int i = 0; i < a.length(); ++i, --res) if(a[i] != '0') { f = true; break; }
  if(!f) for(int i = 0; i < b.length(); ++i, --res) if(b[i] != '0') { f = true; break; }
  return res;
}

int main() {
  M["yotta"] = 24; M["zetta"] = 21; M["exa"] = 18; M["peta"] = 15; M["tera"] = 12; M["giga"] = 9; M["mega"] = 6; M["kilo"] = 3; M["hecto"] = 2; M["deca"] = 1;
  M["deci"] = -1; M["centi"] = -2; M["milli"] = -3; M["micro"] = -6; M["nano"] = -9; M["pico"] = -12; M["femto"] = -15; M["ato"] = -18; M["zepto"] = -21; M["yocto"] = -24;
  int T; cin >>T;
  string s, a, b, c, d;
  getline(cin, s);
  while(T--){
    a = b = c = d = "";
    getline(cin, s);
    input(s, a, b, c, d);
    int n = check(a, b);
    if(c != ""){
      REP(i, abs(M[c])){
        if(M[c] >= 0) shift_left(a, b);
        else shift_right(a, b);
      }
    }
    while(a.length() > 0 && a[0] == '0') a = a.substr(1);
    int ans = 0;
    while(a.length() != 1){
      if(a.length() == 0) { ans--; shift_left(a, b); }
      else { ans++; shift_right(a, b); }
    }
    while(n != check(a, b)) b = b.substr(0, (int)b.length() - 1);
    cout <<a <<(b == "" ? "" : ".") <<b <<" * 10^" <<ans <<" " <<d <<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b); for(ll i=(a); i<=ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double



int main(){
  int n,k;
  cin >>n>>k;
  if(n<=k){
    cout<< 0 << endl;
    return 0;
  }
  vector<ll> h(n);
  rep(i,n){
    cin >>h[i];
  }
  sort(h.begin(),h.end());
  ll ans=0;
  rep(i,n-k){
    ans+=h[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

const int N = 3e5 + 5;
vi gr[N], gc[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    map<int, int> cntr, cntc;
    map<pii, bool> ada;
    for (int i = 0; i < m; i++) {
        int th, tw;
        cin >> th >> tw;
        gr[th].pb(tw);
        gc[tw].pb(th);
        cntr[th]++;
        cntc[tw]++;
    }
    set<pii> sr, sc;
    for (auto it: cntr) {
        sr.insert({it.se, it.fi});
    }
    for (auto it: cntc) {
        sc.insert({it.se, it.fi});
    }
    int ans = 0;
    for (auto r: sr) {
        for (auto c: gr[r.se]) {
            sc.erase(mp(cntc[c], c));
            cntc[c]--;
            sc.insert(mp(cntc[c], c));
        }
        ans = max(ans, r.fi + (*(sc.rbegin())).fi);
        for (auto c: gr[r.se]) {
            sc.erase(mp(cntc[c], c));
            cntc[c]++;
            sc.insert(mp(cntc[c], c));
        }
    }
    for (auto c: sc) {
        for (auto r: gc[c.se]) {
            sr.erase(mp(cntr[r], r));
            cntr[r]--;
            sr.insert(mp(cntr[r], r));
        }
        ans = max(ans, c.fi + (*(sr.rbegin())).fi);
        for (auto r: gc[c.se]) {
            sr.erase(mp(cntr[r], r));
            cntr[r]++;
            sr.insert(mp(cntr[r], r));
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 92548
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(char c='a';c<='z';c++){
    bool appear=false;
    for(int i=0;i<s.size();i++){
      if(s.at(i)==c){
        appear=true;
      }
    }
    if(!appear){
      cout << c;
      return 0;
    }
  }
  cout << "None";
}
        
      


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
    int n,min=100000000,i,j,sum=0;
    scanf("%d",&n);
    int x[n+1];
    for(i=1;i<n+1;i++){
        scanf("%d",&x[i]);
    }
    
    for(i=1;i<101;i++){
        for(j=1;j<n+1;j++){
            sum += (x[j]-i)*(x[j]-i);
        }
        //printf("sum = %d\n",sum);
        if(sum<min){
            min = sum;
        }
        sum = 0;
    }
    printf("%d\n",min);
    return 0;
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll a, b;
	cin >> a >> b;

	if(a > b) swap(a, b);

	if( (b - a) % 2 != 0 ) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << (a + b) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    answers=[]

    if n<=3:
        print(n)
        exit()

    for b in range(2,n):
        #b**2からb**10まで調べる
        for p in range(2,11):
            if b**p > n:
                break
            elif b**p <=n:
                answers.append(b**p)
            else:
                continue
    print(max(answers))
                

if __name__=="__main__":
    main()

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    string s;
    cin>>s;
    for(i=1;i<4;i++) if(s[i]==s[i-1]) break;
    if(i>=4) cout<<"Good"<<endl;
    else cout<<"Bad"<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())

X = []

for i in range(k):
    if a+i <= b:
        X.append(a+i)
    if a <= b-i:
        X.append(b-i)
        
X = sorted(set(X))

for i in range(len(X)):
    print(X[i])

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int> > a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i].first.first >> a[i].first.second;
        a[i].second = i;
        a[i].first.second *= -1;
    }
    sort(a.begin(), a.end());
    for(int i = 1; i <= n; i++){
        cout << a[i].second << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

ll S;
int main(void){
    cin >> S;
    ll lower = S % (ll)pow(10,9);
    ll upper = S / (ll)pow(10,9);
    if(S==(ll)pow(10,18))
        cout << 0 << " " << 0 << " " << (ll)pow(10,9) << " " << 0 << " " << 0 << " " << (ll)pow(10,9) << endl;
    else
        cout << 0 << " " << 0 << " " << upper+1 << " " << 1 << " " << (ll)pow(10,9) - lower << " " << (ll)pow(10,9) << endl;
    //cout << (upper+1)*(ll)pow(10,9) - ((ll)pow(10,9) - lower) << endl;
    //if((upper+1)*(ll)pow(10,9) - ((ll)pow(10,9) - lower)==S) puts("A");
    return 0;
}



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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;
    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
    }

    long long int d[3][214514] = {};
    d[0][0] = v[0];
    d[1][1] = v[1];

    for ( long long int i = 1; i < n; i++ ) {
        if ( i >= 2 ) {
            d[0][i] = d[0][i-2] + v[i];
            d[1][i] = d[1][i-2] + v[i];
            d[2][i] = d[2][i-2] + v[i];
        }
        if ( i >= 3 ) {
            d[1][i] = max( d[0][i-3] + v[i], d[1][i] );
            d[2][i] = max( d[1][i-3] + v[i], d[2][i] );
        }
        if ( i >= 4 ) {
            d[2][i] = max( d[0][i-4] + v[i], d[2][i] );
        }
    }

    long long int ans = 0;
    if ( ( n % 2 ) == 0 ) {
        ans = max( d[0][n-2], d[1][n-1] );
    } else {
        ans = max( d[0][n-3], d[1][n-2] );
        ans = max( ans      , d[2][n-1] );
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 10060
//
//  main.cpp
//  Algorithm
//
//  Created by chemistrae on 27/10/2018.
//  Copyright © 2018 chemistrae. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    string s;
    
    cin >> s;
    
    if (s.size() == 2) cout << s;
    else {
        reverse(s.begin(), s.end());
        cout << s;
    }
    cout << '\n';
    
    return 0;
}


Measured memory_bytes: 256
/*
 * Created by Dipta Das on 09-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

int n, m;
int cnt = 0;
vector<string> ar;
bool vis[3000][3000];

int l[3000][3000];
int r[3000][3000];
int u[3000][3000];
int d[3000][3000];

void dfs (int i, int j) {
    if (i < 0 || j < 0) return;
    if (i >= n) return;
    if (j >= m) return;
    if (vis[i][j]) return;
    vis[i][j] = true;
    if (ar[i][j] == '#') return;
    ++cnt;
    cout << i << " " << j << endl;
    dfs (i + 1, j);
    dfs (i - 1, j);
    dfs (i, j + 1);
    dfs (i, j - 1);
}


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

    cin >> n >> m;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        ar.push_back(s);
    }

    /* int ans = 0; */
    /* for (int i = 0; i < n; ++i) { */
    /*     for (int j = 0; j < m; ++j) { */
    /*         if (!vis[i][j] && ar[i][j] == '.') { */
    /*             cnt = 0; */
    /*             dfs(i, j); */
    /*             ans = max(ans, cnt); */
    /*         } */
    /*     } */
    /* } */

    /* cout << ans << endl; */

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            l[i][j] = ar[i][j] == '.';
            r[i][j] = ar[i][j] == '.';
            u[i][j] = ar[i][j] == '.';
            d[i][j] = ar[i][j] == '.';
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (ar[i][j] == '.' && j != 0) {
                l[i][j] += l[i][j-1];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = m-1; j >= 0; --j) {
            if (ar[i][j] == '.' && j != m-1) {
                r[i][j] += r[i][j+1];
            }
        }
    }
    for (int j = 0; j < m; ++j) {
        for (int i = 1; i < n; ++i) {
            if (ar[i][j] == '.') {
                u[i][j] += u[i-1][j];
            }
        }
    }
    for (int j = 0; j < m; ++j) {
        for (int i = n-1; i >= 0; --i) {
            if (ar[i][j] == '.') {
                d[i][j] += d[i+1][j];
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (ar[i][j] != '.') continue;
            int temp = l[i][j] - 1 + r[i][j] - 1 + u[i][j] - 1 + d[i][j] - 1;
            ans = max (ans, temp+1);
        }
    }

    cout << ans << endl;


    


    return 0;
}



Measured memory_bytes: 102912
n = int(input())
p = list(map(int,input().split()))

count = 0
for i in range(1,n-1):
    p1 = p[i-1]
    p2 = p[i]
    p3 = p[i+1]
    if (p2 >= p1 and p3 >= p2) or (p2 >= p3 and p1 >= p2):
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int fr[205];
int main()
{   init();
    int n,k,ans=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<k;i++)ans+=arr[i];
    cout<<ans;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
    int i,j,k,H,W;
    for ( k = 0; k < 300; k++ ){

    scanf("%d",&H);
    scanf("%d",&W);
    if(H == 0&&W == 0)break;
    for ( i = 0; i < H; i++ ){
        for ( j = 0; j < W; j++ ){
            if(i==0)
            printf("#");
            else if(j==0)
            printf("#");
            else if(i==(H-1))
            printf("#");
            else if(j==(W-1))
            printf("#");
    else
    printf(".");
    }
    printf("\n");
  }
    printf("\n");
}
return 0;
}


Measured memory_bytes: 2064