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

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_FRONT=2;
const int ONLINE_BACK=-2;
const int ON_SEGMENT=0;

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

#define EQ(a,b) (abs((a)-(b))<EPS)

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,const Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}



D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}

Point projection(const Line &l,const Point &a){
    return l.p1+projection(l.p2-l.p1,a-l.p1);
}

Point reflection(const Line &l,const Point &a){
    Point p=projection(l,a);
    return 2.0*p-a;
}

int ccw(Point a,Point b,Point c){
    b-=a;c-=a;
    if(cross(b,c)>EPS)return COUNTER_CLOCKWISE;
    if(cross(b,c)<-EPS)return CLOCKWISE;
    if(dot(b,c)<-EPS)return ONLINE_BACK;
    if(norm(b)+EPS<norm(c))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool isOrthogonal(const Point &a,const Point &b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isOrthogonal(a2-a1,b2-b1);
}

bool isOrthogonal(const Line &l,const Line &m){
    return isOrthogonal(l.p1,l.p2,m.p1,m.p2);
}

bool isParallel(const Point &a,const Point &b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(const Line &l,const Line &m){
    return isParallel(l.p1,l.p2,m.p1,m.p2);
}


int main(){
    int Q;cin>>Q;
    while(Q--){
        Line l,m;
        cin>>l>>m;
        if(isOrthogonal(l,m))cout<<1<<endl;
        else if(isParallel(l,m))cout<<2<<endl;
        else cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int>cnt[200005];
void dfs(int now,vector<int> &ans,vector<bool> &flag) {
    flag[now] = true;
    for(int i = 0; i < cnt[now].size(); i++) {
        if(flag[cnt[now][i]] == false) {
            ans[cnt[now][i]]+=ans[now];
            dfs(cnt[now][i],ans,flag);
        }
    }
    return;
}
signed main()  {
    int N,Q;
    cin >> N >> Q;
    for(int i = 0; i < N-1; i++) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        cnt[a].push_back(b);
        cnt[b].push_back(a);
    }
    vector<int>ans(N);
    for(int i = 0; i < Q; i++) {
        int p,x;
        cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    vector<bool>flag(N,false);
    dfs(0,ans,flag);
    for(int i = 0; i < N; i++) {
        cout << ans[i];
        if(i+1 != N) {
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 28348
from sys import maxsize
import numpy as np


def check(ls, x):
    for i in range(1, len(ls)):
        if ls[i] < x:
            return False
    return True


def convert(b, n):
    diff = n - len(b)
    return ('0' * diff + b)[::-1]


n, m, x = map(int, input().split())
ls = []
a = [i for i in range(n)]
for i in range(n):
    ls.append(list(map(int, input().split())))
dp = [0] * ((1 << n) + 1)
for i in range(n):
    dp[1 << i] = np.array(ls[i])
total_cost = maxsize
for subset in range(1, (1 << n)):
    b = bin(subset)[2:]
    b = convert(b, n)
    a = np.zeros(m + 1)
    for i in range(n):
        if int(b[i]):
            a += dp[1 << i]
    dp[subset] = a
    if check(dp[subset], x):
        total_cost = min(total_cost, dp[subset][0])
if total_cost ==maxsize:
    print(-1)
else:  
    print(int(total_cost))


Measured memory_bytes: 28008
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>

#define DEBUG false

typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);
int make9(string);
int addAllDigit(string s );
/*************Global variable  **************/
int N ;
string S ;

int ans = 0 ;

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

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  int i,j ;
  cin >> S;
  N = S.length();
  cout << max(make9(S) ,addAllDigit(S) ) <<'\n' ;



  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

int make9(string s){
 int d = s[0] - '0' - 1 ;
 d += 9 * (s.length() - 1 );
 return d ;
}

int addAllDigit(string s ){
  int d = 0 ;
  for(int c : s ) d += c - '0';
  return d;
}
//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}
/******** scan **************/
int scanInt(void ){
  int n ;
  if(std::scanf("%d",&n)){
  }else{
    std::printf("scanN error\n");
    std::exit(1);
  }
  return n ;
}
void scanLlArr(ll *a , int n){
  int ireadA ; 
  for (ireadA =  0 ; ireadA < n ; ireadA++){
    if(std::scanf("%lld",&a[ireadA])){
    }else{
      std::printf("readA error\n");
      std::exit(1);
    }
  }
}

string scanString(void){
  string s ;
  if(cin >> s){ 
  }
  else{
    std::printf("scanString error\n");
    std::exit(1);
  }
  return s;
}

void scanCharArr(char *string){
  if(scanf("%s",string))
  {}
  else{
    std::printf("scanCharStr error\n");
    std::exit(1);
  }
}
/************* print **************/
void printInt(int p){
  if(std::printf("%d\n",p)){
  }else{
    std::printf("intPrintf Error\n");
    std::exit(1);
  }
}

void printLlArr(ll *a){
  int i ;
  for(i = 0 ; i < sizeof(a)/sizeof(ll) ; i++){
    if(std::printf("%lld ",a[i] )){
    }else{
      std::printf("intPrintN Error i = %d stopped \n",i);
      std::exit(1);
    }
  }
  std::printf("\n");
}
void printCharArr(char *string){
 for(int i = 0 ; i < sizeof(string)/sizeof(char); i++){
   if(printf("%c",string[i])){
     }
   else{
      std::printf("charStrPrint Error i = %d stopped \n",i);
      std::exit(1);
   }
 }
 printf("\n");
}

Measured memory_bytes: 256
N, x = gets.split.map(&:to_i)
children = gets.split.map(&:to_i).sort

count = 0

children.each.with_index do |num, id|
  if id == children.size-1
    if num == x
      x -= num
      count += 1
    end
  else
    if num <= x
      x -= num
      count += 1
    else
      break
    end
  end
end

puts count

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

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{
  int N; cin >> N;
  int M; cin >> M;
  vector<vector<int>> arr(N + 1);
  vector<int> original(N);
  int city[M];
  int id[M];
  rep(i, 0, M){
    int P, Y;
    cin >> P >> Y;
    city[i] = P;
    id[i] = Y;
    arr[P].push_back(Y);
  }
  
  repe(i, 1, N){
    sort(arr[i].begin(), arr[i].end());
  }

  rep(i, 0, M){
      printf("%06d", city[i]);
      printf("%06d\n", 1 + lower_bound(arr[city[i]].begin(), arr[city[i]].end(),id[i]) - arr[city[i]].begin());
}

}



Measured memory_bytes: 8192
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

const long long INF = LLONG_MAX;
const long long MOD = 1000000007;
const long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//long double d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

int main() {
    cin >> k >> n;
	vi a(n); veccin(a);
	a.push_back(k+a[0]);
	m = 0;
    REP(i,n) {
    	if (a[i+1]-a[i]>m){m=a[i+1]-a[i];}
    }
    cout << k-m << endl;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int n,l,r,sum[100001];
bool p[100001];
bool pd(int x)
{
	if (x==1) return false;
	for (int i=sqrt(x);i>=2;i--)
	  if (x%i==0) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=100000;i++)
	  p[i]=pd(i);
	for (int i=1;i<=100000;i++)
	{
		sum[i]=sum[i-1];
		if (p[i]==true&&p[(i+1)/2]==true) sum[i]++;
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		printf("%d\n",sum[r]-sum[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B, T;
  rd(A);
  rd(B);
  rd(T);
  wt_L(T / A * B);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190601-1

// --- original code ---
// {
//   int A, B, T;
//   rd(A, B, T);
//   wt(T / A * B);
// }


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

alias min = binaryFun!"a < b ? a : b";

void main() {
  long[] NM = readln.chomp.split.to!(long[]);
  long N = NM[0],
      M = NM[1];
  Tuple!(long, long)[] AB;

  foreach (_; 0..N) {
    long[] _AB = readln.chomp.split.to!(long[]);
    AB ~= tuple(_AB[0], _AB[1]);
  }

  AB.sort!((a, b) => a[0] < b[0]);

  long ans;
  long have;

  foreach (ab; AB) {
    long a = ab[0],
        b = ab[1];
    long t = min(M - have, b);
    ans += a * t;
    have += t;
  }

  writeln(ans);
}

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

int main() {
 long long int n,m=0,a=0,r=0,c=0,h=0;cin>>n;string s[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i].at(0)=='M')m++;
   else if(s[i].at(0)=='A')a++;
   else if(s[i].at(0)=='R')r++;
 else if(s[i].at(0)=='C')c++;
 else if(s[i].at(0)=='H')h++;
  }
//  cout<<m<<a<<r<<c<<h;
  cout<<m*a*r +m*a*c +m*a*h +m*r*c +m*r*h +m*c*h +a*r*c +a*r*h +a*c*h +r*c*h;
}

Measured memory_bytes: 6144
#include <stdio.h>

int main(){
  int i,j,n,q,count = 0;
  int S[10001],T[500];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  for(i = 0; i < q; i++){
    j = 0;
    S[n] = T[i];
    
    while(S[j] != T[i]){
      j++;
    }

    if(j != n) count++;
  }

  printf("%d\n",count);

  return 0;
}



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

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  int ans = 1;
  
  for(int i = 0;i < a;i++){
    if(ans < b) ans *= 2;
    else ans += b;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int main() {
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;
}

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

int main() {
  string S, myString = "SunnyCloudyRainy";
  cin >> S;
  int n = myString.find(S);
  if(n == 0) cout << "Cloudy";
  else if(n == 5) cout << "Rainy";
  else if(n == 11) cout << "Sunny";
  return 0;
}

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

const int MOD = 1000000007;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> dp(H + 1, vector<int>(W));
    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            for (int k = 0; k < (1 << (W - 1)); k++) {
                bool ok = true;
                for (int l = 0; l < W - 2; l++) {
                    if ((k >> l) & 1 && (k >> (l + 1)) & 1) {
                        ok = false;
                    }
                }
                if (ok) {
                    if (j >= 1 && ((k >> (j - 1)) & 1)) {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= MOD;
                    } else if (j < W - 1 && ((k >> j) & 1)) {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= MOD;
                    } else {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }
                }
            }
        }
    }

    cout << dp[H][K - 1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

int n, m;
vector<vector<int>> g;

vector<int> ans;

void bfs(int src_v) {
  vector<int> dist(n, -1);
  dist[src_v] = 0;
  queue<int> q;
  q.push(src_v);
  while (!q.empty()) {
    int cur_v = q.front();
    q.pop();
    for (int i = 0; i < (int)g[cur_v].size(); i++) {
      int next_v = g[cur_v][i];
      if (dist[next_v] != -1) {
        continue;
      }
      ans[next_v] = cur_v + 1;
      dist[next_v] = dist[cur_v] + 1;
      q.push(next_v);
    }
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  cin >> n >> m;

  ans = vector<int>(n);
  g = vector<vector<int>>(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bfs(0);

  cout << "Yes\n";
  for (int i = 1; i < n; i++) {
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 10480
#include<cstdio>
int main()
{
	int n,ans=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,t=0;scanf("%d",&x);
		while(!(x&1)) x>>=1,t++;
		ans+=t;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <complex>

using namespace std;

int main() {
	int n,k,coun,a=0;
	cin >> n >> k;
	for (int x = 0; x < n; ++x) {
		cin >> a;
		if (a < (abs(a - k)))coun = coun + a;
		else coun = coun + abs(a - k);
		
	}
	cout <<2*coun<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, a[300005], cnt[300005] = {0}, b[300005], tot = 0;
int ans[300005] = {0}, st[300005];
int sum[300005] = {0};
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read(), ++cnt[a[i]];
    for (int i = 1; i <= n; ++i)
        if (cnt[i]) b[++tot] = cnt[i];
    // > tot: 0
    sort(b + 1, b + tot + 1);
    int cur = 1;
    for (int i = 1; i <= n; ++i){
        while (cur <= tot && b[cur] < i)
            ++cur;
        st[i] = cur;
        sum[i] = sum[i - 1] + b[i];
    }
}
void solve(){
    for (int i = 1; i <= tot; ++i){
        int l = 0, r = n / i;
        while (r > l){
            int mid = (l + r + 1) >> 1;
            if (sum[st[mid] - 1] + mid * (tot - st[mid] + 1) < i * mid)
                r = mid - 1;
            else l = mid;
        }
        ans[i] = l;
    }
    for (int i = 1; i <= n; ++i)
        printf("%d\n", ans[i]);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 7936
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
       if(b<c)
           if(a+b<c)
                 printf("%d\n",c-(a+b));
            else
                printf("%d\n",0);
        else
            if(c+a<b)
                printf("%d\n",b-(a+c));
            else
                printf("%d\n",0);
    }
    return 0;
}


Measured memory_bytes: 128
Module Module087B
    Sub Main(ByVal args() As String)
        Dim A As Integer : A = 0
        Dim B As Integer : B = 0
        Dim C As Integer : C = 0
        Dim X As Integer : X = 0
        Dim result As Integer : result = 0
        Dim i, j, k

        A = Console.ReadLine()
        B = Console.ReadLine()
        C = Console.ReadLine()
        X = Console.ReadLine()

        For i = 0 To A
            If X < 500 * i Then
                Exit For
            End If

            For j = 0 To B
                If X < 500 * i + 100 * j Then
                    Exit For
                End If

                For k = 0 To C
                    If X = 500 * i + 100 * j + 50 * k Then
                        result = result + 1
                    End If
                Next
            Next
        Next

        Console.Write(result)
    End Sub
End Module


Measured memory_bytes: 24652
/* ex5_3
   masaaki52	*/
#include <stdio.h>
int main(void){
  int row,column,i,j,rblack[100]={0},cblack[100]={0};//rblack,cblackは各行・列の＃数を数える配列
  char matrix[100][100];
  scanf("%d %d",&row,&column);//行数、列数を入力
  for(i=0;i<row;i++){//matrix内全てに
    for(j=0;j<column;j++){
      scanf(" %c",&matrix[i][j]);//.#の入力
      if(matrix[i][j] == '#'){//matrix内のあるマスが#のとき
        rblack[i] += 1;//配列rblackの、＃のあった行番目に＋１
        cblack[j] += 1;//配列cblackの、＃のあった列番目に＋１
      }
    }
  }
  for(i=0;i<row;i++){//matrix内の全マス目について
    for(j=0;j<column;j++){
      if(rblack[i] != 0 && cblack[j] != 0){//そのマスのある行と列のどちらにも＃があれば
        printf("%c",matrix[i][j]);//マスの値を出力
      }
    }
    if(rblack != 0){//ある行が全て.でなければ
      printf("\n");//改行
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

vector<int> G[200010];
int seg[524288], A[200010], FA[200010];

int rmq(int s, int t, int k = 1, int l = 0, int r = 262143) {
	if (t < l || r < s)return 0;
	if (s <= l && r <= t) {
		return seg[k];
	}
	int lv = rmq(s, t, k * 2, l, (l + r) / 2);
	int rv = rmq(s, t, k * 2 + 1, (l + r) / 2 + 1, r);
	return max(lv, rv);
}

int upd(int x, int v) {
	x += 262144;
	int bef = seg[x];
	seg[x] = v;
	while (x) {
		x /= 2;
		seg[x] = max(seg[x * 2], seg[x * 2 + 1]);
	}
	return bef;
}

void dfs(int c, int p) {
	int bef = upd(A[c], rmq(0, A[c] - 1) + 1);
	FA[c] = seg[1];
	for (int i : G[c]) {
		if (i == p)continue;
		dfs(i, c);
	}
	upd(A[c], bef);
}

int main() {
	for (int i = 0;i < 262144;i++)seg[i] = 0;
	for (int i = 0;i < 200010;i++)A[i] = FA[i] = 0;
	int N;
	cin >> N;
	map<int, int> zat;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		zat.insert({ A[i],0 });
	}
	int a = 1, b;
	for (auto& x : zat) {
		x.second = a;
		a++;
	}
	for (int i = 0;i < N;i++) {
		A[i] = zat[A[i]];
	}

	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0, -1);
	for (int i = 0;i < N;i++) {
		cout << FA[i] << endl;
	}
}

Measured memory_bytes: 36820
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	s := getNextString(scanner)
	cc := make([]int, 26)
	n := len(s)
	for i := 0; i < n; i++ {
		cc[s[i]-'a']++
	}

	if len(s) < 26 {
		fmt.Print(s)
		for i := 0; i < 26; i++ {
			if cc[i] == 0 {
				fmt.Println(fmt.Sprintf("%c", 'a'+i))
				break
			}
		}
		return
	}
	end := n - 2

	for i := n - 2; i >= 0 && s[i] > s[i+1]; i-- {
		end = i - 1
	}

	if end == -1 {
		fmt.Println(-1)
		return
	}
	fmt.Print(s[0:end])
	for i := n - 1; i > end; i-- {
		if s[end] > s[i] {
			continue
		}
		fmt.Println(fmt.Sprintf("%c", s[i]))
		return
	}
	writer.Flush()
}


Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	writeln(N / 3);
	stdout.flush();
	debug readln();
}

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    int n;
    cin>>n;

    vector<ll> A(n,0);

    for(int i=0;i<n;++i)    cin>>A[i];

    ll ans = A[0];

    for(int i=1;i<n;++i)    ans = gcd(ans, A[i]);

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 3932
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        
        
        while(true) {
            
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if(op.equals("?")) break;
            int ans =0;
            
            switch(op) {
                case "+":
                    ans = a+b;
                    break;
                case "-":
                    ans = a-b;
                    break;
                case "*":
                    ans = a*b;
                    break;
                case "/":
                    ans= a/b;
                    break;
            }
            System.out.println(ans);
        }

    }
}



Measured memory_bytes: 26288
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
//orz mqy
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int Maxn=55;
char c[Maxn][Maxn],d[Maxn][Maxn];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=0;i<n;i++){
		scanf("%s",c[i]);
	}
	for (int i=0;i<m;i++){
		scanf("%s",d[i]);
	}
	for (int i=0;i<=n-m;i++){
		for (int j=0;j<=n-m;j++){
			bool flag=true;
			for (int ii=i;ii<i+m;ii++){
				for (int jj=j;jj<j+m;jj++){
					if (c[ii][jj]!=d[ii-i][jj-j]){
						flag=false;
					}
				}
			}
			if (flag){
				printf("Yes\n");return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println(lcm(A, B));
	}

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 23764
#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 (3e9)

using namespace std;
typedef long long int ll;

string s;
int main(void){
    cin >> s;
    for(int i=0;i<s.length();i++){
        if((i+1)%2==1 and (s[i]=='R' or s[i]=='U' or s[i] == 'D')) continue;
        if((i+1)%2==0 and (s[i]=='L' or s[i]=='U' or s[i] == 'D')) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}



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

template <class InputIterator, class OutputIterator>
OutputIterator RLE(InputIterator start, InputIterator end, OutputIterator result)
{
    InputIterator cmp = start;
    size_t cnt = 0;

    while (start != end) {
        start++;
        cnt++;
        if (start == end || *start != *cmp) {
            *result++ = { *cmp, cnt };
            cmp = start;
            cnt = 0;
        }
    }

    return result;
}

void main_()
{
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<pair<char, ll>> rle_v;
    RLE(begin(S), end(S), back_inserter(rle_v));

    if (K < (ll)rle_v.size() / 2) {
        ll ans = accumulate(
                     begin(rle_v), end(rle_v), 0LL,
                     [](auto acc, auto&& p) {
                         return acc + p.second - 1;
                     })
            + K * 2;
        cout << ans << endl;
    } else {
        cout << N - 1 << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2500
k,a,b = map(int,input().split())
if b <= a+1:
  print(1+k)  
else:
  if k <= a:
    print(1+k)
  else:   
    ans = (k-a+1)//2*(b-a) + (k-a+1)%2 + a
    print(ans)    

Measured memory_bytes: 9156
#include <stdio.h>
void bubbleSort(int *, int);
int main(){
  int A[100],N=0;
  int i,j;
  
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  bubbleSort(A, N);
  
  return 0;
}

void bubbleSort(int *A, int N){
  int v=0,j=0,i;
  int t;
  int cnt=0;
  for(i=0; i<=N-1; i++){
    for(j = N-1; j >= 1; j--){
      if(A[j] < A[j-1]){
	v = A[j-1];
	A[j-1] = A[j];
	A[j] = v;
	cnt+=1;
      }
    }
  }
  for(t=0; t<N-1; t++){
    printf("%d ",A[t]);
  }
  if(t==N-1){
    printf("%d",A[t]);
  }
  printf("\n");
  printf("%d\n",cnt);
}



Measured memory_bytes: 2108
N,M=map(int,input().split(' '))
PY=[tuple(map(int,input().split(' '))) for _ in range(M)]
P=[[] for i in range(N)]
num = []
for n,i in enumerate(PY):
    P[i[0]-1].append((i[1],n))
for n0,i in enumerate(P):
    for n,j in enumerate(sorted(i)):
        num.append((j[1],format(n0+1,'06')+format(n+1,'06')))
for i in sorted(num):
    print(i[1])

Measured memory_bytes: 100056
# A - Weather Prediction
# 1日毎に　晴れ（Sunny） 曇り（Cloudy） 雨（Rainy） の順に変化する
# 晴 → 曇 → 雨 → 晴 → 曇 → 雨 → ...

# 文字列 S の入力
S = input()
# print(S)

# 明日の天気を表示させる
# 今日の天気で分岐し、printで表示
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
elif S == 'Rainy':
    print('Sunny')


Measured memory_bytes: 8884
N = gets.to_i
S = gets.chomp
Q = gets
Qs = readlines.map(&:split)
A = 'a'.ord

class ST
  def initialize
    @a = S.chars.map{|c| c.ord - A}
    @n = 2**N.bit_length
    @t = Array.new(2*@n - 1, 0)
    (0 ... N).each{|i| @t[i + @n - 1] = 1<<@a[i]}
    (@n - 2).downto(0){|i| @t[i] = @t[2*i + 1] | @t[2*i + 2]}
  end

  def update(i, x)
    @t[i + @n - 1] -= 1<<@a[i]
    @a[i] = x
    @t[i + @n - 1] += 1<<x
    i += @n - 1
    while i > 0
      i = (i - 1)/2
      @t[i] = @t[2*i + 1] | @t[2*i + 2]
    end
  end

  def query(a, b, k = 0, l = 0, r = -1)
    r = @n if r < 0
    return 0 if b <= l || r <= a
    return @t[k] if a <= l && r <= b
    query(a, b, 2*k + 1, l, (l + r)/2) | query(a, b, 2*k + 2, (l + r)/2, r)
  end
end

s = ST.new
Qs.each do |a, b, c|
  if a == '1'
    s.update(b.to_i - 1, c.ord - A)
  else
    puts s.query(b.to_i - 1, c.to_i).to_s(2).count('1')
  end
end

Measured memory_bytes: 52896
#include <bits/stdc++.h>
using namespace std;
const int INF= 100100;
   
int main(){
  int n, m;
  cin >> n >> m;  
  vector<vector<int>> road(n);
for (int i = 0; i < m; i++) {
  int a, b;
    cin >> a >> b;
  	a--; b--;
    road.at(a).push_back(b);
    road.at(b).push_back(a);
  }

  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  queue<int> q;
  dist.at(0) = 0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : road.at(v)){
      if (dist.at(u) != INF) continue;
      else
        dist.at(u) = dist.at(v) + 1;
        pre.at(u) = v;
      q.push(u);
    }
  }
  
  cout << "Yes" << endl;
  for(int i=1; i<n; i++){
    cout << pre.at(i)+1 << endl;
  }
  
  return 0;
}

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

int main() {
    int A,B;
  cin >> A >> B;
  
  int C,D,F;
  C = A + B;
  D = A - B;
  F = A*B;
  int answer = max(max(C,D),F);
  cout << answer << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int ans;

int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  // cout << "Yes" << endl;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a,a+N);

  int count = 1;
  FOR(i,0,N-2){
    if(a[i]!=a[i+1]){
      if(count%2==1) ++ans;
      count = 1;
    }
    else count++;
  }

  if(a[N-1]!=a[N-2]) ++ans;
  else{
    if(count%2==1) ++ans;
  }

  cout << ans << endl;



}



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

int main() {
  int a = 0;
  string s;
  cin >> s;
  vector<int> v;
  rep(i, s.size()) v.push_back(s[i]-'0');
  vector<vector<vector<int>>> dp(v.size()+1, vector<vector<int>>(2, vector<int>(9, 0)));
  dp[0][1][0] = 1;
  rep(i, s.size()){
    rep(j, 8){
      rep(k, 10){
        if(k == 3) dp[i+1][0][(j|1<<0)] += dp[i][0][j];
        else if(k == 5) dp[i+1][0][(j|1<<1)] += dp[i][0][j];
        else if(k == 7) dp[i+1][0][(j|1<<2)] += dp[i][0][j];
        else dp[i+1][0][8] += dp[i][0][j];
      }
    }
    rep(j, 8){
      rep(k, 10){
        if(k < v[i]){
          if(k == 3) dp[i+1][0][(j|1<<0)] += dp[i][1][j];
          else if(k == 5) dp[i+1][0][(j|1<<1)] += dp[i][1][j];
          else if(k == 7) dp[i+1][0][(j|1<<2)] += dp[i][1][j];
          else dp[i+1][0][8] += dp[i][1][j];
        }
        else if(k == v[i]){
          if(k == 3) dp[i+1][1][(j|1<<0)] += dp[i][1][j];
          else if(k == 5) dp[i+1][1][(j|1<<1)] += dp[i][1][j];
          else if(k == 7) dp[i+1][1][(j|1<<2)] += dp[i][1][j];
          else dp[i+1][1][8] += dp[i][1][j];
          break;
        }
      }
    }
  }
  a += dp[s.size()][0][7] + dp[s.size()][1][7];
    rep(i, max(0, int(s.size()-3))){
    a += (pow(3, i+3) - 3 - 6 * (pow(2, i+2)-1));
    }
  cout << a << endl;
  return 0;
}

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


	char b;
	cin >> b;
	if (b =='A') {
		cout << "T" << endl;
	} else if (b=='C') {
		cout << "G" << endl;
	} else if (b=='G') {
		cout << "C" << endl;
	} else if (b=='T') {
		cout << "A" << endl;
	}
}


Measured memory_bytes: 256
//わからん！！！難しすぎる！！！！
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const long long INF=1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
long long n,w,weight[110],value[110];
long long dp[110][100100];
int main(){
cin>>n>>w;
  rep(i,n) cin>>weight[i]>>value[i];
  rep(i,n){
  	for(int sum_w=0;sum_w<=w;sum_w++){
    	if(sum_w-weight[i]>=0){
        	chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
          
        }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  cout<<dp[n][w];
}

Measured memory_bytes: 81576
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

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

	int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i > 0) cout << " ";
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String str = sc.next();
			int order = sc.nextInt();

			while(order != 0) {
				String data = sc.next();
				int a = sc.nextInt();
				int b = sc.nextInt();

				if(data.equals("replace")) {
					String st = sc.next();
					str = str.substring(0,a) + st + str.substring(b + 1);
				}else if(data.equals("reverse")) {
					String s = str.substring(a,b + 1);
					StringBuffer sb = new StringBuffer(s);
					s = sb.reverse().toString();
					str = str.substring(0,a) + s + str.substring(b + 1);
				}else if(data.equals("print")) {
					String s = str.substring(a,b + 1);
					System.out.println(s);
				}
				order--;
			}
		}
	}
}


Measured memory_bytes: 30108
IDENTIFICATION DIVISION.
 PROGRAM-ID.     TEST108.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
  01 INP        PIC 9(3).
  01 SHO        PIC 9(2).
  01 AMA        PIC 9(1).
  01 WANS       PIC 9(4).
  01 ANS        PIC ZZZ9.

 PROCEDURE DIVISION.
  ACCEPT INP.
  DIVIDE INP BY 2 GIVING SHO REMAINDER AMA.
  COMPUTE WANS = SHO * (SHO + AMA).
  MOVE WANS       TO ANS.
  DISPLAY FUNCTION TRIM(ANS).

 STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    const str s="keyence";
    str t; cin>>t;
    if(t==s){puts("YES");return 0;}
    else{
        ll n=t.size();
        rep0(i,n){
            for(ll j=i;j<n;j++){
                str S="";
                rep0(k,n){
                    if(i<=k&&k<=j){
                        continue;
                    }
                    else{
                        S+=t[k];
                    }
                }
                //cout<<S<<endl;
                if(S==s){puts("YES");return 0;}
            }
        }
    }
    puts("NO");
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

Q = [0]*N
for i in range(N):
    p = int(input())
    Q[p-1] = i

cnt = 0
now_idx = -1
ans = 0
for i in range(N):
    idx = Q[i]
    if idx>now_idx:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 1
    now_idx = idx

print(N-ans)

Measured memory_bytes: 75168
#include<cstdio>

using namespace std;

int main(){
    int h, n;

    scanf("%d %d", &h, &n);

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

    int d[h+1];

    d[0] = 0;

    for(int i = 0; i <= h; i++){
        int mn = 100000000;
        for(int j = 0; j < n; j++){
            int ma = 0;
            ma = b[j];
            if (i > a[j]){
                ma += d[i - a[j]];
            }
            if (ma < mn) mn = ma;
        }
        d[i] = mn;
    }
    printf("%d\n", d[h]);
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, d; 
    cin >> n >> d ;
    int cnt = 0 ;
    for(int i=1; i<=n;) {
        if(i+2*d <= n) {
            i = 1+i+2*d;
            cnt++ ;
        }
        else {
            cnt++ ;
            break ;
        }
    }
    cout << cnt << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {    
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K<=A) cout << K << endl;
    else if(K<=A+B) cout << A << endl;
    else cout << A-(K-A-B) << endl;
}


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

int main() {
  string S, T, U;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  cin >> U;
  
  if (U==S)
    cout << A-1 << " " << B << endl;
  else
    cout << A << " " << B-1 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[99];
map <char, int> mp;

int main() {
	bool flg = 1;
	mp.clear();
	scanf("%s", s);
	int l = strlen(s);
	for(int i = 0; i < l; i++) mp[s[i]]++;
	for(int i = 0; i < l; i++) {
		if(mp[s[i]] > 1) {
			flg = 0;
			break;
		}
	}
	if(flg) puts("yes");
	else puts("no");
}

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

#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
string s;

bool pal(int i, int j){
    while (i < j){
        if (s[i] != s[j]) return false;
        i++; j--;
    }
    return true;
}


integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n;
    unordered_map<int, int> M;
    for (int i = 0; i < n; i++){
        cin >> ar[i];
        M[ar[i]]++;
    }
    int total = 0;
    for (auto kv : M){
        int num = kv.first;
        int cnt = kv.second;
        total += (cnt * (cnt - 1)) / 2;
    }
    for (int i = 0; i < n; i++){
        int tmp = total;
        int cnt = M[ar[i]];
        tmp -= (cnt * (cnt - 1)) / 2;
        cnt--;
        tmp += (cnt * (cnt - 1)) / 2;
        cout << tmp << endl;
    }

}


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;
  long long int K;
  cin >> N >> K >>Q;
  int A[Q];
  long long int point[N];
  for(int i=0;i<N;i++) point[i]=0;
  for (int i=0;i<Q;i++){
    cin >> A[i];
    point[A[i]-1]++;
  }
  for(int i=0;i<N;i++){
    if (K+point[i]-Q<=0)cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


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



int main() { 
  int n;
  cin >>n;
  vector<int>x(n);
  vector<int>y(n);
  vector<int>h(n);
  int X,Y,H;
  for(int i=0;i<n;i++){
    cin >>x.at(i)>>y.at(i)>>h.at(i);
    if(h.at(i)>0){
      H=h.at(i);
      X=x.at(i);
      Y=y.at(i);
    }
  }
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
          bool ans =true;
      int hi=H+abs(i-X)+abs(j-Y);
      for(int k=0;k<n;k++){
        if(h.at(k)==max( hi -abs(x.at(k)-i) - abs(y.at(k)-j),0) ){
        }       
        else{
          ans =false;
          break;
        }
        
      }
      if(ans==true){
        cout << i<<" "<<j << " " <<hi;
        return 0;
      }
    }
     
  }
}

Measured memory_bytes: 256
//Tuvshee
 
#include<iomanip>
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define anD &&
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
int main()
{
	I x;
	cin>>x;
	cout<<x*x*x<<eL;
	rtn 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 3, Mod = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
	int n;
	cin>>n;
	if(n)cout<<0<<endl;
	else cout<<1<<endl;
}


Measured memory_bytes: 3644
<?php
    fscanf(STDIN, "%d %d %d", $a, $b, $c);
    
    $cnt5 = 0;
    $cnt7 = 0;
    
    for ($i = 0; $i < 3; $i++) {
        if (${chr(ord("a")+$i)} == 5) {
            $cnt5++;
        } elseif(${chr(ord("a")+$i)} == 7) {
            $cnt7++;
        }
    }
    
    if ($cnt5 == 2 && $cnt7 == 1) {
        echo "YES";
    } else {
        echo "NO";
    }
?>

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int a = 0;
			for (int i = 0; i < 3; i++) {
				a += sc.nextInt();
			}
			System.out.println(a >= 22 ? "bust": "win");

		sc.close();
	}
}

Measured memory_bytes: 22740
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ios;
	ll n;cin>>n;
	ll a[n][n];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++)cin>>a[i][j];
	}
	ll N=(1<<n);
	ll dp[N];
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(ll i=0;i<N;i++){
		int x=__builtin_popcount(i);
		for(int j=0;j<n;j++){
			//cout<<(i&(1<<j))<<" "<<a[x][j]<<" 2"<<endl;
			if((i&(1<<j))==0&&a[j][x]==1){
				//cout<<"x"<<endl;
				//cout<<i<<" "<<dp[i]<<endl;
				dp[(i|(1<<j))]=(dp[(i|(1<<j))]+dp[i])%hell;
			}
		}
	}
	//for(int i=0;i<N;i++)cout<<dp[i]<<" ";cout<<endl;
	cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 16640