akhauriyash/Code-Regression huggingface dataset:
//
// Created by 拓真 on 2018/06/30.
//

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

typedef pair<int,int> P;
typedef long long ll;
#define int long long
struct robot{
    robot(){};
    int x,y;
    int dir;
    robot(int x,int y,int dir){
        this->x=x;
        this->y=y;
        this->dir=dir;
    }
};

char toc(int x){
    if(x==0)return 'N';
    else if(x==1)return 'E';
    else if(x==2)return 'S';
    else return 'W';
}
int dp[110][110][5];
vector<string> maze;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int h,w;

bool inrange(int x, int y){ return x >= 0 && x < w && y >= 0 && y < h;}

signed main(){
    ll L;
    while(cin>>h>>w>>L,h){


        rep(i,110)rep(j,110)rep(k,5)dp[i][j][k]=-1;
        maze.clear();
        rep(i,h){
            string s;
            cin>>s;
            maze.push_back(s);
        }

        robot pre;
        rep(i,h)rep(j,w){
            if(maze[i][j]=='N'){
                pre=robot(j,i,0);
            }
            if(maze[i][j]=='E'){
                pre=robot(j,i,1);
            }
            if(maze[i][j]=='S'){
                pre=robot(j,i,2);
            }
            if(maze[i][j]=='W'){
                pre=robot(j,i,3);
            }
        }

        bool flag=false;
        dp[pre.y][pre.x][pre.dir]=0;
        ll turn=1;
        bool rooped = false;
        while(turn<=L){
            int nx,ny,ndir;
            rep(i,4){
                ndir = (pre.dir+i)%4;
                nx = pre.x + dx[ndir];
                ny = pre.y + dy[ndir];
                if(inrange(nx, ny) && maze[ny][nx] != '#'){
                    pre.x = nx; pre.y = ny; pre.dir = ndir;
                    break;
                }
            }
            if(!rooped && dp[pre.y][pre.x][pre.dir] >= 0){
                rooped = true;
                ll roop = turn -dp[pre.y][pre.x][pre.dir];
                turn += (L - turn) / roop * roop;
                turn++;
            }
            else{
                dp[pre.y][pre.x][pre.dir] = turn;
                turn++;
            }
        }





        cout<<pre.y+1<<' '<<pre.x+1<<' '<<toc(pre.dir)<<endl;



    }

}



Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

void mul(ll& a, ll& b) {
  a = a * b % MOD;
}

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

  sortd(a);
  sortd(b);

  a.pb(-1);
  b.pb(-1);

  ll apt = 0, bpt = 0, num = n * m;
  ll ans = 1;
  while (num > 0) {
    if (a[apt] == num and b[bpt] == num) {
      apt++;
      bpt++;
    } else if (a[apt] == num) {
      apt++;
      mul(ans, bpt);
    } else if (b[bpt] == num) {
      bpt++;
      mul(ans, apt);
    } else {
      ll tmp = apt * bpt - (n * m - num);
      mul(ans, tmp);
    }
    num -= 1;
  }
  cout << ans << endl;
}


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

int main()
{
	int d, g; cin >> d >> g;
	
	vector<int> p(d), c(d); for (int i = 0; i < d; i++) cin >> p[i] >> c[i];

	int ans = 2147483647;
	for (int bit = 0; bit < (1<<d); bit++) {

		vector<bool> f(d, false);
		int tmp_score = 0;
		int tmp_ans = 0;
		int maxIndex = -1;
		for (int i = 0; i < d; i++) {			

			if (bit & (1 << i)) {
				tmp_score += c[i] + 100 * (i + 1) * p[i];
				tmp_ans += p[i];
				f[i] = true;
			}
			else {
				maxIndex = i;
			}

		}
		if (g <= tmp_score) {
			ans = min(ans, tmp_ans);
		}
		else {
			for (int i = 0; i < p[maxIndex] - 1; i++) {
				tmp_score += 100 * (maxIndex + 1);
				tmp_ans++;
				if (g <= tmp_score) {
					ans = min(ans, tmp_ans);
					break;
				}					
			}
		}
			
	}	

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

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc109/tasks/abc109_b
n = int(input())
w = []
for _ in range(n):
    w.append(input())
if len(w) != len(set(w)):
    print("No")
    exit()
for i in range(1, len(w)):
    if w[i][0] != w[i - 1][-1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;
long long N;
long long A[100005];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	long long cur = 1;
	long long ans = 0;

	for(int i = 0; i < N; i++){
		//cout << "i = " << i << " cur = " << cur << endl;
		if(A[i] < cur){
			continue;
		}
		if(A[i] == cur){
			cur++;
			continue;
		}
		//cout << "i=" << i << "A[" << i << "]=" << A[i] << " num = " << (A[i] - 1)/cur << endl;
		ans += (A[i] - 1)/cur;
		if(cur == 1){
			cur++;
		}
	}
	cout << ans << endl;




}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int n,m;
  scanf("%d%d",&n,&m);

  int i,j,k[n],a[n][m];
  int judge[m];
  for(i=0;i<m;i++)
    judge[i] = 0;
  for(i=0;i<n;i++){
    scanf("%d",&k[i]);
    for(j=0;j<k[i];j++){
      scanf("%d",&a[i][j]);
      judge[a[i][j]-1]++;
    }
  }

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

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100

int main(){

  int i, j, n, a[MAX + 1][MAX + 1], u, k, v;

  for(i = 1; i <= MAX; i++)
    for(j = 1; j <= MAX; j++)
      a[i][j] = 0;

  scanf("%d", &n);

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

    scanf("%d %d", &u, &k);

    for(j = 0; j < k; j++){
      scanf("%d", &v);
      a[u][v] = 1;
    }
  }

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

      if(n == j)
        printf("%d",a[i][j]);
      else
        printf("%d ", a[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
N=int(input())
A=[int(input()) for _ in range(N)]

A.sort()
B=[]
C=[]
if N%2==1:
    m=A[N//2]
    ans=0
    for i in range(N//2):
        B.append(A[i])
        C.append(A[-1-i])
        B.append(A[-1-i])
        C.append(A[i])
    dB=abs(m-B[0])
    dC=abs(m-C[0])
    for j in range(1,len(B)):
        dB+=abs(B[j]-B[j-1])
        dC+=abs(C[j]-C[j-1])
    ans=max(dB,dC)
else:
    for i in range(N//2):
        B.append(A[i])
        C.append(A[-1-i])
        B.append(A[-1-i])
        C.append(A[i])
    dB=abs(B[-1]-B[0])
    dC=abs(C[-1]-C[0])
    for j in range(1,len(B)-1):
        dB+=abs(B[j]-B[j-1])
        dC+=abs(C[j]-C[j-1])
    ans=max(dB,dC)
print(ans)

Measured memory_bytes: 15452
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N, K;
  cin >> N >> K;
  int digit = 1;
  while(N>1){
    int i = N%K;
    N /= K;
    digit++;
    // cout << i << endl;
  }
  if(N==0) digit--;
  
  cout << digit<< endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

int sumdiv(int n) {
  if (n == 1) return 0;
  int sum = 1;
  for (int k = 2; k * k <= n; k++)
    if (n % k == 0) {
      int m = n / k;
      if (k == m) sum += k;
      else sum += (k + m);
    }
  return sum;
}

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    int s = sumdiv(n);
    //printf("n=%d, s=%d\n", n, s);
    
    if (n == s) cout << "perfect number" << endl;
    else if (n > s) cout << "deficient number" << endl;
    else cout << "abundant number" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int cnt = 0;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(A%2 == 1) cnt++;
    }
    if(cnt%2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main(){
   
    stack<int> S;
    int a,b;
    string t;
    while(cin>>t){
        if(t[0]=='+'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a+b);
        }
        else if(t[0]=='-'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(b-a);
        }
        else if(t[0]=='*'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a*b);
        }
        else{
            S.push(atoi(t.c_str()));
        }
    }
    cout<<S.top()<<endl;
}



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

typedef long long ll;

const int N = 2e6 + 6;
const int MOD = 1e9 + 7;

ll f[N], inv[N];
int x, y;

ll fpow(int a, int n) {
    if (n == 0) return 1;
    ll ret = fpow(a, n / 2);
    ret = (ret * ret) % MOD;
    if (n & 1) ret = (ret * a) % MOD;
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0 << '\n';
        return 0;
    }
    if ((2*x - y) % 3 || (2*y - x) % 3) {
        cout << 0 << '\n';
        return 0;
    }
    f[0] = 1;
    inv[0] = fpow(f[0], MOD - 2);
    for (int i = 1; i <= N-6; i++) {
        f[i] = ((ll)i * f[i - 1]) % MOD;
        inv[i] = fpow(f[i], MOD - 2);
    }
    int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
    if (a < 0 || b < 0) {
        cout << 0 << '\n';
        return 0;
    }
    ll ans = (f[a + b] * inv[a]) % MOD;
    ans = (ans * inv[b]) % MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <string>

using namespace std;

const int MAX = 100005;
const int NIL = -1;

struct Node {int parent; int left_child; int right_brother;};

Node tree[MAX];

void print_node(Node node) {
    cout << "parent: " << node.parent
         << ", left_child: " << node.left_child
         << ", right_brother: " << node.right_brother << endl;
}

void print_tree(int number_of_nodes) {
    for (int n=0; number_of_nodes > n; n++) {
        cout << "Id: " << n << ", ";
        print_node(tree[n]);
    }
};

int get_depth(int id) {
    int temp, depth;
    depth = -1;

    temp = tree[id].parent;
    depth++;
    while (temp != -1) {
        temp = tree[temp].parent;
        depth++;
    };

    return depth;
}

string get_type(int id) {
    if (tree[id].parent == -1) return "root";
    else if (tree[id].left_child == -1) return "leaf";
    else return "internal node";
}

void print_child(int parent_id) {
    int children[MAX];
    int index = 0;
    if (tree[parent_id].left_child == -1) {
        cout << "[]" << endl;
        return;
    } else {
        children[index] = tree[parent_id].left_child;
        while (tree[children[index]].right_brother != -1) {
            children[index + 1] = tree[children[index]].right_brother;
            index+=1;
        }
    }
    cout << "[";
    for (int n=0; n <= index;n++) {
        cout << children[n];
        if (n != index) {
            cout << ", ";
        }
    }
    cout << "]" <<endl;
}

int main() {
    int number_of_node, id, number_of_children, child, last_time_child;
    cin >> number_of_node;


    for (int n=0; n < number_of_node; n++) {
        tree[n].parent = tree[n].left_child = tree[n].right_brother = -1;
    }


    for (int n=0; n < number_of_node; n++) {
        cin >> id;
        cin >> number_of_children;
        for (int j=0; j < number_of_children; j++) {
            cin >> child;
            if (j == 0) tree[id].left_child = child;
            else tree[last_time_child].right_brother = child;
            tree[child].parent = id;
            last_time_child = child;
        }
    }

    for (int n=0; n < number_of_node; n++) {
        cout << "node " << n << ": parent = " << tree[n].parent << ", depth = " << get_depth(n) << ", " << get_type(n) << ", ";
        print_child(n);
    }
    return 0;
}



Measured memory_bytes: 4660
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        cnt = 0
        for nxt_i in (i - 1, i, i + 1):
            for nxt_j in (j - 1, j, j + 1):
                if not(0 <= nxt_i < h) or not(0 <= nxt_j < w):
                    continue
                if s[nxt_i][nxt_j] == "#":
                    cnt += 1
        s[i][j] = str(cnt)

for res in s:
    print("".join(res))

Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)

typedef long long ll;
int A[510][510];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    int a, b;
    n = 100;
    cin>>a>>b;
    int fl=0;
    if (a>b)
    {
        swap(a,b);
        fl=1;
    }

    int start =1;
    cout<<"100 100\n";
    int reqd = a-1;
    for(int j=1;j<=100;j++)
    {
        if (j%2==0){for(int i=1;i<=100;i++)A[i][j]=1;
        }
        else
        {
            for(int i=1;i<=100;i++)
            {
                if (reqd && i%2==1)
                {   A[i][j]=0;
                    reqd --;
                }
                else A[i][j]=1;
            }
        }
        if (j%2 ==0 && reqd==0)
        {
            start = j+2;
            break;
        }

    }
    reqd = b-1;
    for(int j=start;j<=100;j+=2)
    {
        if (reqd ==0)break;
        for(int i=1;i<=100;i+=2)
        {    A[i][j]=1;
            reqd --;
            if (reqd==0)break;
        }
        if (reqd == 0)break;
    }
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
        if (!fl)
        {
        if (A[i][j])cout<<"#";
        else cout<<".";
        }
        else
        {
            if (A[i][j])cout<<".";
            else cout<<"#";
        }
        }
        cout<<"\n";
    }


    
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;



int main(){

	int a,b;
	cin>>a>>b;
	
	int num=a*b;
	
	for(int i=1;i<=3;i++){
		if((num*i)%2==1){
		cout<<"Yes"<<endl;
			break;
		}else{
			cout<<"No"<<endl;
			break;
		}
	}
	
	return 0;
	
	

}

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

int main(){
    int N, Y;
    scanf("%d %d", &N, &Y);

    for(int x = 0; x <= N; x++){
        for(int y = 0; y <= N-x; y++){
            int z = N - x - y;
            if(10000*x+5000*y+1000*z == Y){
                printf("%d %d %d\n", x,y,z);
                exit(0);
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,i,j,a[200005],ans;
set<pair<int,int> > s;
int read(){
	char ch=getchar();
	int xx=0;
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx;
}
int main(){
	n=read();
	set<pair<int,int> > :: iterator it;
	for(i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1);	
	s.insert(make_pair(2000000000,1000000));
	for(i=1;i<=n;i++)
		s.insert(make_pair(a[i],i));
	for(i=n;i>=1;i--){
		it=s.lower_bound(make_pair(a[i],i));
		if(it->second==i){
			s.erase(make_pair(a[i],i));
			for(j=1;j<=a[i];j<<=1);
			it=s.lower_bound(make_pair(j-a[i],0));
			if(it->first==j-a[i]){
				ans++;
				s.erase(make_pair(it->first,it->second));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10368
def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;cin>>n>>x;
  int m[n];int sum=0;
  int mi=100000000;
  for(int i=0;i<n;i++){
    cin>>m[i];
    sum+=m[i];
    mi=min(mi,m[i]);
  }
  x-=sum;
  cout<<n+x/mi<<endl;
}
  

Measured memory_bytes: 256
//
// Created by 10940 on 2020/7/11.
//

#include <bits/stdc++.h>
using namespace std;

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L ; i <= R; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int count = 0;
    int N;
    cin >> N;
    
    vector<int> P(N);
    priority_queue<int, vector<int>, greater<int>>  PRI;
    
    for(int i=0; i<N; i++){
        int p;
        cin >> p;
        P[i] = p;
        PRI.push(p);
    }
    
    for(int i=0; i<N; i++){
        if(P[i] != PRI.top()){
            count++;
        }
        PRI.pop();
    }
    if((count == 0) || (count == 2)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
  
using namespace std;
  
int main(){
 int a,b,c;
 cin >> a;
 cin >> b;
 cin >> c;
 if (a<b && b<c) {
  cout << "Yes" <<endl;
 } else {
  cout << "No" <<endl;
 }
 return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        if(a[i] % 2 == 0 && !((a[i] % 3 == 0) || (a[i] % 5 == 0))){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
    static void Main()
    {
#if DEBUG
        string exampleInput =
        @"4
1 1 1 1
";
        Console.SetIn(new System.IO.StringReader(exampleInput));
#endif

        long MOD = 998244353;

        var N = int.Parse(Console.ReadLine());
        var D = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        if (D[0] != 0) { Console.WriteLine(0); Console.Out.Flush(); return; }
        int next = 1;
        int prev = 1;
        long result = 1;
        foreach(var g in D.Skip(1).GroupBy(d => d).OrderBy(g => g.Key))
        {
            if(g.Key != next) { Console.WriteLine(0); Console.Out.Flush(); return; }
            foreach(var gg in g) result = (result * prev) % MOD;
            prev = g.Count();
            next++;
        }
        Console.WriteLine(result);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){cout << "No" << endl; return 0;}
  if(a==b||b==c||a==c){cout << "Yes" << endl; return 0;}

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


Measured memory_bytes: 256
// at_abc153c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int main()
{
    int n, k;cin >> n >> k;
    vector<int>v(n, 0);
    FOR(i, n) {
        cin >> v[i];
    }
    if (k >= n) {
        cout << "0\n";return 0;
    }
    sort(v.begin(), v.end());

    long long temp = 0;
    FOR(i, n-k) {
        temp += (long long)v[i];
    }
    cout << temp << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

int main()
{
  int w, a, b;
  cin >> w >> a >> b;
  a += w;
  if (b - a >= w * -1 && b - a <= 0) cout << '0' << endl;
  else if (b - a < w * -1) cout << ((a - w) - w) - b << endl;
  else cout << abs(b - a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c||a==c&&b!=c||b==c&&a!=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[100000];
  scanf("%s",&s);
  int a = 0,b = 0;
  for(int i = 0;i < strlen(s);i++){
    if(s[i] == '0'){
      a++;
    }else{
      b++;
    }
  }
  if(a < b){
    b = a;
  }
  printf("%d",b * 2);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

      System.out.println(arr[n-1]);
  }
}

Measured memory_bytes: 23764
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL 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] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL a;
	string s;
	cin >> a >> s;
	if (a >= 3200) {
		O(s);
	}
	else {
		O("red");
	}

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)
K = INT()

dp0 = list2d(N+1, 107, 0)
dp1 = list2d(N+1, 107, 0)
dp0[0][0] = 1
for i in range(N):
    num = int(S[i])
    for j in range(107):
        for k in range(10):
            nxt = j+1 if k != 0 else j
            if nxt == 107:
                continue
            if k < num:
                dp1[i+1][nxt] += dp0[i][j]
                dp1[i+1][nxt] += dp1[i][j]
            elif k == num:
                dp0[i+1][nxt] += dp0[i][j]
                dp1[i+1][nxt] += dp1[i][j]
            else:
                dp1[i+1][nxt] += dp1[i][j]
ans = dp0[N][K] + dp1[N][K]
print(ans)


Measured memory_bytes: 47344
#include<stdio.h>
int main(void){
  int i ,n,x,c=0,a=0;
  scanf("%d%d",&n,&x);
  int l[n];
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  for(i=0;i<n;i++){
    a+=l[i];
    if(a<=x)
      c++;
  }
  printf("%d",c+1);
  return 0;
}

Measured memory_bytes: 128
mod = 1_000_000_007

gets

h = Hash.new{|h, k| h[k] = [0, 0] }
genten_iwashi = 0

$<.read.split.map(&:to_i).each_slice(2) do |(a,b)|

  if a == 0 && b == 0
    genten_iwashi += 1
  else
    f = a.zero? || a * b > 0
    r = ( f ? Rational(a,b) : -Rational(b,a) )
    h[r][ f ? 0 : 1 ] += 1
  end
end

ans = 1
h.values.each do |(a, b)|
  ans = ans * ( 2.pow(a,mod) + 2.pow(b, mod) - 1) % mod
end

ans = ( ans - 1 + genten_iwashi ) % mod

puts ans

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

int main() {
  string S,T;
  cin >>S>>T;
  
  int Atari = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i))
      Atari++;
  }
  cout << Atari << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        final long MOD = 1000000007L;
        long result;
        result = powCalc(10, n) - (2 * powCalc(9, n) - powCalc(8, n));
        while(result < 0){
            result = result + MOD;
        }
        System.out.println(result % MOD);
    }

    public static long powCalc(long base, long n){
        final long MOD = 1000000007L;
        long ret = 1;
        for(int i = 0; i<n; i++){
            ret = ret * base % MOD;
        }
        return ret;
    }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  int a[220000];
  rep(i, n) cin >> a[i];
  sort(a, a+n);
  bool k[1000001];
  fill(k, k + 1000001, false);
  int ans = n;
  map<int, int> mp;
  pair<int, bool> p;
  rep(i, n){
    int t = a[i];
    int u = 1;
    if(p.first == t && !p.second){
      ans--;
      //cout << i <<endl;
      p = make_pair(t, true);
    }
    if(!mp.count(t)){
      if(k[t]) p = make_pair(t, true);
      else p = make_pair(t, false);
      mp[t] = 1;
    }
    if(k[t]){
      ans--;
      continue;
    }

    while(t * u <= 1000000){
      k[t*u] = true;
      u++;
    }
  }
  cout << ans <<endl;    
}

Measured memory_bytes: 14688
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N,M;
  cin>>N>>M;
  for(int i = 0;i<M;i++){
    int k;
    cin>>k;
    N-=k;
  }
  if(N>=0){
    cout << N << endl;
  }
  else{
    cout << "-1" << endl;
  }
  return 0;
}


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


int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i, N) {
    cin >> L[i];
  }

  int ans = 1;
  int pos = 0;
  rep(i, N) {
    pos += L[i];
    if (pos <= X) {
      ans++;
    } else {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    char a,b;
    cin >> a >> b;

    cout << ((a==b)?"H":"D") << endl;

    return 0;

}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> vll;

#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define fin(ans) cout << (ans) << endl;

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

void Main()
{
  string n; cin >> n;
  rrep(i, 4) if(n[i] == n[i - 1]) {fin("Bad") exit(0);}
  fin("Good")
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

using namespace std;

int N;
int A[202020];
int B[202020];


int main(int argc, const char * argv[]) {
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    for (int i = 0; i < N; ++i)
        cin >> B[i];

    int r = 0;
    for (int c = 1 << 28; 1 <= c; c >>= 1) {
        int msk = ~(c << 1);
        for (int i = 0; i < N; ++i) {
            A[i] &= msk;
            B[i] &= msk;
        }
        sort(A, A + N);
        sort(B, B + N);

        int cn = 0;
        int j0 = N;
        int j1 = N;
        int j2 = N;
        for (int i = 0; i < N; ++i) {
            int ai = A[i];
            int c0 = c - ai;
            int c1 = (c << 1) - ai;
            int c2 = c + (c << 1) - ai;
            while (0 < j2 && c2 <= B[j2 - 1])
                --j2;
            while (0 < j1 && c1 <= B[j1 - 1])
                --j1;
            while (0 < j0 && c0 <= B[j0 - 1])
                --j0;
            cn += N - j2 + j1 - j0;
            if (j2 == 0) {
                cn += (N - i - 1) * N;
                break;
            }
        }
        if (cn & 1) {
            r |= c;
        }
    }

    cout << r << endl;
    return 0;
}


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

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

fn main() {
    let n:u64 = read();
    let m:u64 = read();
    let mut multi_n = 1;
    let mut multi_m = 1;
    let MOD = 1_000_000_007;

    for i in 1..n+1{
        multi_n *= i;
        multi_n %= MOD;
    }
    for i in 1..m+1{
        multi_m *= i;
        multi_m %= MOD;
    }


    let sub = std::cmp::max(n,m) - std::cmp::min(n,m);
    if sub > 1 {
        println!("0");
    }else if sub == 1 {
        println!("{}",(multi_n*multi_m) % MOD);
    }else{
        println!("{}",(multi_n*multi_m) % MOD * 2 % MOD);
    }

}


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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
		String str=  br.readLine();
		int a = Integer.valueOf(str.split(" ")[0]);
		int b = Integer.valueOf(str.split(" ")[1]);
		char arr[][] = new char[a+5][b+5];
		for(int i=1;i<=a;i++){
			str = br.readLine();
			for(int ii=1;ii<=b;ii++){
				arr[i][ii] = str.charAt(ii-1);
			}
		}
		String ans = "Yes";
		big:
		for(int i=1;i<=a;i++){
			for(int ii=1;ii<=b;ii++){
				if(arr[i][ii] == '#'){
					if(arr[i][ii-1] == '#' || arr[i][ii+1] == '#' || arr[i-1][ii] == '#' || arr[i+1][ii] == '#'){
						ans = "Yes";
					} else {
						ans = "No";
						break big;
					}
				}
			}
		}
	
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
S = int(input())
count = 0
for size in range(1, S//3+1):
  extra = S - 3 * size # 0以上の値をどう分配するか？数列なので純不動ではない
  total = extra + size -1 # extra個の玉とsize-1個の棒の並び替え問題
  number = 1
  for n in range(extra+1, total+1):
    number *= n
  for n in range(1, size):
    number //= n
  count += number
#  print(size,number)
print(count % (10 ** 9 + 7))

Measured memory_bytes: 73240
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


// 最長共通部分列

// dp[決めた桁数][未満フラグ][1を含んでいたか否かフラグ]
#define MAX_LENGTH_S1 (1000)
#define MAX_LENGTH_S2 (1000)
// dp[i][j]:S1[i]までとS2[j]までの最長共通部分列
long long dp[MAX_LENGTH_S1 + 1][MAX_LENGTH_S2 + 1];

int main() {

	int set_num;
	cin >> set_num;
	for (int num = 0; num < set_num; num++) {

		string S1, S2;
		cin >> S1 >> S2;
		int len1 = S1.size();
		int len2 = S2.size();

		dp[0][0] = 0;
		for (int i = 0; i < len1; i++) {
			for (int j = 0; j < len2; j++) {
				if (S1[i] == S2[j]) dp[i + 1][j + 1] = max(dp[i][j] + 1, max(dp[i + 1][j], dp[i][j + 1]));
				else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
		int LCS_length = dp[len1][len2];
		cout << LCS_length << endl;
	}

	return 0;
}



Measured memory_bytes: 10988
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n,m;int anss=0;
    cin>>n>>m;VI ar(n);int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];sum+=ar[i];
    }
    int m1=4*m;if(sum%m1==0)sum=sum/m1;else sum=sum/m1+1;
    for(int i=0;i<n;i++)
    {
        if(ar[i]>=sum)anss++;
    }
    if(anss>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


return 0;
}





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

void fnInput(string& rsStr)
{
  cin >> rsStr;
}

int fnMaxStrAtoZ(string sStr)
{
  int nBgn, nEnd;
  for (int i = 0; i < sStr.size(); i++)
    if (sStr[i] == 'A')
    {
      nBgn = i;
      break;
    }

  for (int i = sStr.size() - 1; i >= 0; i--)
    if (sStr[i] == 'Z')
    {
      nEnd = i;
      break;
    }

  return (nEnd - nBgn + 1);
}

int main()
{
  string sStr;

  fnInput(sStr);
  cout << fnMaxStrAtoZ(sStr) << endl;

  return 0;
}

Measured memory_bytes: 772
#include<stdio.h>

int meter[200000];

int calculate(int circle, int house)
{ 
  int dis[200000];
  int max = 0;
  int i;

  for(i = 0; i < house; i++)
  {
    dis[i] = meter[i + 1] - meter[i];
    if((i + 1) == house)
      dis[i] = (circle - meter[i]) + meter[0];
    
    if(dis[i] > max)
      max = dis[i];
  }
  
  return max;
}

int main()
{
  int circle, house, i;
  int max = 0;
  int sum = 0;
  
  scanf("%d", &circle);
  scanf("%d", &house);
  
  for(i = 0; i < house; i++)
  {
    scanf("%d", &meter[i]);
  }
  
  max = calculate(circle, house);
  
  printf("%d\n", circle - max);
  
  return 0;
}

Measured memory_bytes: 896
/************************************************
*Author        :  lrj124
*Created Time  :  2019.08.04.20:07
*Mail          :  1584634848@qq.com
*Problem       :  b
************************************************/
#include <bits/stdc++.h>
using namespace std;
int n,ans;
inline int cnt(int x) {
	if (x < 10) return 1;
	return cnt(x/10)+1;
}
int main() {
	//freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	scanf("%d",&n);
	for (int i = 1;i <= n;i++) ans += cnt(i)&1;
	printf("%d",ans);
	//cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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




int main() {
  int a; // 変数の宣言
  cin >> a;// 標準入力
  int ans=0;
  ans = a + a*a + a*a*a;
  cout << ans << endl; // 標準出力
}


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

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

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	vector<int64> aa(nn);
	stack<int64> ans;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa[ii];
	}
	for(int64 ii = 0;ii < nn;ii++)
	{
		auto ite = aa.begin();
		auto itf = aa.end();
		for(int64 jj = 1;jj <= aa.size();jj++)
		{
			if(*ite == jj)
			{
				itf = ite;
			}
			ite++;
		}
		if(itf == aa.end())
		{
			puts("-1");
			return 0;
		}
		ans.push(*itf);
		itf = aa.erase(itf);
	}
	while(!ans.empty())
	{
		cout << ans.top() << endl;
		ans.pop();
	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    
    if (N <= K) {
        cout << N*X << "\n";
    } else {
        cout << K*X + (N-K)*Y << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin>>n;
    ll b = (ll)(sqrtl(n));
    for(int i=b;i>=1;--i)
    {
        if(n%i==0)
        {
            cout<<i+n/i-2<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int h, w, m, n;
   scanf("%d %d", &h, &w);

  while( h != 0 | w != 0){
      for(m=1;m<=h;m++){
         for(n=1;n<=w;n++){
            printf("#");
         }
         printf("\n");
      }
      printf("\n");
      scanf("%d %d", &h, &w);
   }
   return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int a;
    cin >> a;
    cout << a + pow(a,2) + pow(a,3) << endl;
    return 0;
}

Measured memory_bytes: 4284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18

#define nax 100005


void solve(){
	int x,y;
	cin>>x>>y;

	rep(i,0,x+1){
		int sum = i*4 + 2*(x-i);
		if(sum==y){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;

	

}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<ll,ll>;
 
int main() {
    ll X,K,D;
    cin>>X>>K>>D;
    X=abs(X);
    if(K>=X/D){
      K-=X/D;
      X-=X/D*D;
      K=K%2;
    }
    cout<<abs(X-D*K)<<endl;
    return 0;
}

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

int main()
{
  	int n, h;
	cin >> n >> h;
	int tmp;
	int ret = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		if (tmp >= h)
			ret++;
	}
	cout << ret;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct EDGE { int from, to, cost; };
bool operator < (const EDGE& a, const EDGE& b) {
    return a.cost < b.cost;
}
 
vector<EDGE> g;
int par[10000];
 
int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
 
bool _union(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
}
 
int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
     
    for (int i = 0; i < V; i++) par[i] = i;
     
    for (int i = 0; i < E; i++){
        int s, t, w;
        scanf("%d %d %d", &s, &t, &w);
        g.push_back((EDGE){s, t, w});
    }
     
    sort(g.begin(), g.end());
     
    int res = 0;
    for (int i = 0; i < g.size(); i++){
        EDGE &e = g[i];
        if (_union(e.from, e.to)) res += e.cost;
    }
     
    printf("%d\n", res);
     
    return 0;
}

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

int main(){
	ll n; cin >> n;
	ll c[10][10];
	memset(c,0,sizeof(c));
	for(int i=0;i<n;i++)
	{
		ll p = (i+1)%10;
		ll q = i+1;
		while(q>9)q/=10;
		c[p][q]++;
	}
	ll ans = 0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ans += c[i][j]*c[j][i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
grid = [input() for i in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == ".":
            continue

        nearby_sharp_counter = 0

        for a, b in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            if h+a < 0 or h+a >= H or w+b < 0 or w+b >= W:
                continue
            elif grid[h+a][w+b] == "#":
                nearby_sharp_counter += 1
        
        if nearby_sharp_counter == 0:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3064