akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
} 
void solve()
{
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)
  {
    cin>>a[i];  
  }
 // cout<<a.size()<<endl;
  ll dp[n][n];fll(dp);
  rep(i,n){dp[i][i]=a[i];}
  rep(i,n-1){dp[i][i+1]=dp[i][i]+dp[i+1][i+1];}
  ll b[n];b[0]=a[0];repA(i,1,n){b[i]=b[i-1]+a[i];}
  repA(len,3,n+1)
  {
    rep(i,n-len+1)
    {
      dp[i][i+len-1]=9e18;
      repA(j,i,i+len-1)
      {
        dp[i][i+len-1]=min(dp[i][i+len-1],dp[i][j]+dp[j+1][i+len-1]+b[j]-b[i]+(abs(j-i)?a[i]:0)+b[i+len-1]-b[j+1]+(abs(i+len-1-j-1)?a[j+1]:0));
      }
    }
  }
  cout<<dp[0][n-1];
  //rep(i,n){rep(j,n){cout<<dp[i][j]<<" ";}cout<<endl;}
}
int main()
{
  fastio;
//fopen();
  int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>
int main(void){
    int n,i,tp=0,hp=0;
    char s[128],t[128];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s %s",s,t);
        
        if(strcmp(s,t)>0){
            tp+=3;
        }else if(strcmp(s,t)<0){
            hp+=3;
        }else{
            tp++;
            hp++;
        }
        
    }
    
    printf("%d %d\n",tp,hp);
    
    return 0;
}



Measured memory_bytes: 2088
H, W = map(int, input().split())
a = []
for i in range(H):
    a_i = [i for i in input()]
    a.append(a_i)
dp = [[0 for i in range(W)] for j in range(H)]
# init
for h in range(H):
    if a[h][0] == "#":
        break
    dp[h][0] = 1
for w in range(W):
    if a[0][w] == "#":
        break
    dp[0][w] = 1

for h in range(1, H):
    for w in range(1, W):
        dp[h][w] = dp[h][w - 1] + dp[h - 1][w] if a[h][w] == "." else 0
print(dp[-1][-1] % (10 ** 9 + 7))


Measured memory_bytes: 166100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string S;
    cin >> S;
    vector<bool> c(4,false);
    for (char i : S) {
        if(i == 'N'){
            c[0]=true;
        }else if(i == 'S'){
            c[1]=true;
        }else if(i == 'E'){
            c[2]=true;
        }else if(i == 'W'){
            c[3]=true;
        }
    }

    if(c[0] ^ c[1]){
        printf("No\n");
    }else if(c[2] ^ c[3]){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }

}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			int i, j;
			if (H == 0 && W == 0) break;
			for (i = 1; i <= H; i ++) {
				if (i % 2 == 1) for (j = 1; j <= W; j ++) {
					if (j % 2 == 1) System.out.print("#");
					else System.out.print(".");
				}
				if (i % 2 == 0) for (j = 1; j <= W; j ++) {
					if (j % 2 == 1) System.out.print(".");
					else System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}

	}
}

Measured memory_bytes: 36984
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,char> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  // ios::sync_with_stdio(false);
  while(1){
    int n,l;
    cin>>n>>l;
    if(n==0) break;
    vector<pair<PII,int> > ant;
    ant.resize(n);
    rep(i,n){
      cin>>ant[i].F.S>>ant[i].F.F;
      ant[i].S=i+1;
    }
    
    int ans1=0;
    pair<int,int> ans2={0,0};
    bool x=true;
    sort(ant.begin(),ant.end());
    while(x){
      ans1++;
     
      
      
      rep(i,ant.size() ){
	if(ant[i].F.S=='R'){
	  ant[i].F.F++;
	  if(ant[i].F.F==l && ans2.F<ans1){
	    ans2=make_pair(ans1,ant[i].S);
	  }
	}else{
	  ant[i].F.F--;
	  if(ant[i].F.F==0){
	    ans2=make_pair(ans1,ant[i].S);
	  }
	}
      }
       sort(ant.begin(),ant.end());
      rep(i,ant.size()-1 ){
	if(ant[i].F.F==ant[i+1].F.F){
	  // cout<<i<<endl;
	  if(ant[i].F.S=='R'){
	    ant[i].F.S='L';
	    ant[i+1].F.S='R';
	  }else{
	    ant[i].F.S='R';
	    ant[i+1].F.S='L';
	  }
	}
      }
      /*rep(i,ant.size() ){
	cout<<"("<<ant[i].F.F<<ant[i].F.S<<" "<<ant[i].S<<") ";
	}
	cout<<endl;*/
      rep(i,ant.size() ){
	if(ant[i].F.F > 0 && ant[i].F.F < l) break;
	else if(i == ant.size()-1){
	  //cout<<"A"<<endl;
	  x=false;
	}
      }
    }
    cout<<ans1<<" "<<ans2.S<<endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#!/usr/bin/env python3.4

# abc128_d

import collections
import itertools

def find_index(iterable, func):
    i = 0
    for it in iterable:
        if func(it):
            break
        i += 1
    return i

def slice_deq(deq, n):
    return itertools.islice(deq, 0, n)

def main():
    # Input
    n, k = [int(s) for s in input().split()]
    vs = (int(s) for s in input().split())
    # Get ans
    vs = collections.deque(vs)
    R = min(n, k)
    def gene_tv():
        for i in range(1, R+1):
            vs.rotate(-1)
            vs.reverse()
            for _ in range(i+1):
                temp = list(slice_deq(vs, i))
                temp.sort()
                l = find_index(temp, lambda x: x>0)
                l = min(l, k-i)
                yield sum(temp[l:])
                vs.rotate(-1)
            vs.rotate(-(i-1))
    ans = max(gene_tv())
    ans = max(ans, 0)
    # Output
    print(ans)

if __name__ == '__main__':
    main()



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

int main(){
    string s;
    while(cin>>s){
        int JOI=0,IOI=0;
        for(int i=0;i<s.size();i++){
            if(!s.compare(i,3,"JOI")) JOI++;
            if(!s.compare(i,3,"IOI")) IOI++;
        }
        printf("%d\n%d\n",JOI,IOI);
    }
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;

int main(){
  long long a,b,q;
  cin>>q;
  for(long long i=0;i<q;i++){
    cin>>a>>b;
    if(a>b) swap(a,b);
    if(a==b||b==a+1){
      cout<<2*a-2<<endl;
    }else{
      long long c;
      c=sqrt(a*b);
      if(a*b==c*c) c--;
      if(c*(c+1)>=a*b){
        cout<<2*c-2<<endl;
      }else{
        cout<<2*c-1<<endl;
      }
    }
  }
  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[101];
void solve(){
	cin >> n;
	bool ok = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 0) ok = 0;
	}
	
	if(n > 23 || !ok){
		cout << 0 << endl;
		return;
	}
	
	int ma = 0;
	for(int i = 0; i < (1<<n); i++){
		bool b[24] = {};
		bool lp = 0;
		b[0] = 1;
		for(int j = 0; j < n; j++){
			if(i >> j & 1){
				if(b[24-a[j]]){
					lp = 1;
					break;
				}
				b[24-a[j]] = 1;
			}
			else{
				if(b[a[j]]){
					lp = 1;
					break;
				}
				b[a[j]] = 1;
			}
		}
		if(lp) continue;
		
		int mi = 1;
		bool fin = 0;
		for(int i = 1; i < 24; i++){
			mi = i;
			for(int j = 0; j < 24; j++){
				if(b[j] && b[(j+i)%24]){
					fin = 1;
					break;
				}
			}
			if(fin) break;
		}
		chmax(ma,mi);
	}
	cout << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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;

int N, c[51], v[51];

int main() {
    cin >> N;
    rep(i, N) cin >> v[i];
    rep(i, N) cin >> c[i];
    int ans = 0;
    rep(i, N) {
        int diff = v[i] - c[i];
        if (diff>0) ans += diff;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));


    int n = sc.nextInt();
    char[] s = sc.next().toCharArray(), t = sc.next().toCharArray();

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      sb.append(s[i]).append(t[i]);
    }
    out.println(sb);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

ll n, d;
ll a[200200];
vector< pair< ll, pair<ll, ll> > > edge;

void solve(int l, int r){
	if(l >= r) return ;
	int mid = (l+r) >> 1;
	solve(l, mid);
	solve(mid+1, r);
	int mnpos1 = l;
	for(int i = l; i <= mid; i++){
		if(a[i] + (mid - i) * d < a[mnpos1] + (mid - mnpos1) * d) mnpos1 = i;
	}
	ll mnpos2 = mid+1;
	for(int i = mid+1; i <= r; i++){
		if(a[i] + (i - mid) * d < a[mnpos2] + (mnpos2 - mid) * d) mnpos2 = i;
	}
	for(int i = l; i <= mid; i++) edge.push_back(make_pair(a[mnpos2] + a[i] + (mnpos2 - i) * d, make_pair(i, mnpos2)));
	for(int i = mid+1; i <= r; i++) edge.push_back(make_pair(a[i] + a[mnpos1] + (i - mnpos1) * d, make_pair(i, mnpos1)));
}

int par[200200];
int get_par(int now){
	return par[now] = ((par[now] == now) ? now : get_par(par[now]));
}
void unite(int a, int b){
	par[get_par(a)] = get_par(b);
}
ll ans = 0;

int main(){
	scanf("%lld%lld", &n, &d);
	rep(i, n) par[i] = i;
	rep(i, n) scanf("%lld", &a[i]);
	solve(0, n-1);
	sort(edge.begin(), edge.end());
	rep(i, edge.size()){
		if(get_par(edge[i].second.first) != get_par(edge[i].second.second)){
			ans += edge[i].first;
			unite(edge[i].second.first, edge[i].second.second); 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 103008
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define size sz
using namespace std;
const int mod = 998244353, N = 210000;

int n, c[N], dfn[N], size[N], top[N], son[N], fa[N], dep[N], cnt, f[N], stck[N], tp;
ll g[N], ans;
vector<int> to[N], pos[N];
vector<pii> ito[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

ll comb(ll x) {
	return x * (x + 1) / 2;
}

inline void addEdg(int x, int y) {
	to[x].push_back(y), to[y].push_back(x);
	return;
}

void dfs1(int now) {
	size[now] = 1, dep[now] = dep[fa[now]] + 1;
	for (auto &v : to[now]) {
		if (v == fa[now]) continue;
		fa[v] = now, dfs1(v), size[now] += size[v];
		g[now] += comb(size[v]);
		if (size[son[now]] < size[v]) son[now] = v;
	}
	return;
}

void dfs2(int now) {
	dfn[now] = ++cnt;
	top[now] = now == son[fa[now]] ? top[fa[now]] : now;
	for (auto &v : to[now]) {
		if (v == fa[now]) continue;
		dfs2(v);
	}
	return;
}

inline int getLca(int x, int y) {
	while (top[x] != top[y])
		dep[top[x]] >= dep[top[y]] ? x = fa[top[x]] : y = fa[top[y]];
	return dep[x] >= dep[y] ? y : x;
}

inline int getSon(int x, int anc) {
	if (top[x] == top[anc]) return son[anc];
	x = top[x];
	while (top[fa[x]] != top[anc]) x = top[fa[x]];
	return fa[x] == anc ? x : son[anc];
}

inline bool cmp(int x, int y) {
	return dfn[x] < dfn[y];
}

inline void insrt(int x) {
	stck[++tp] = x, ito[x].clear(), f[x] = 0;
	return;
}

void addIEdg(int x, int y) {
	ito[x].emplace_back(y, getSon(y, x));
	return;
}

void dfs3(int now, int col) {
	if (c[now] == col) {
		ans += g[now];
		for (auto &v : ito[now]) {
			dfs3(v.first, col);
			ans -= comb(size[v.second]);
			ans += comb(size[v.second] - size[v.first] + f[v.first]);
		}
		return;
	}
	f[now] = size[now];
	for (auto &v : ito[now]) {
		dfs3(v.first, col);
		f[now] -= size[v.first] - f[v.first];
	}
	return;
}

int main() {
	int x, y;
	read(n);
	for (R int i = 1; i <= n; ++i)
		read(c[i]), pos[c[i]].push_back(i);
	for (R int i = 1; i < n; ++i)
		read(x), read(y), addEdg(x, y);
	dfs1(1), dfs2(1);
	for (R int i = 1; i <= n; ++i) {
		if (c[1] != i) pos[i].push_back(1);
		sort(pos[i].begin(), pos[i].end(), cmp);
		tp = 0, insrt(1);
		for (auto &v : pos[i]) {
			if (v == 1) continue;
			int lca = getLca(stck[tp], v);
			while (tp > 1 && lca != stck[tp]) {
				int tmp = stck[tp--];
				if (dep[lca] > dep[stck[tp]]) insrt(lca);
				addIEdg(stck[tp], tmp), lca = getLca(stck[tp], v);
			}
			insrt(v);
		}
		while (tp > 1) addIEdg(stck[tp - 1], stck[tp]), --tp;
		ans = 0, dfs3(1, i);
		printf("%lld\n", comb(n) - ans - comb(f[1]));
	}
	return 0;
}

Measured memory_bytes: 61236
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#define x first
#define y second
#define m_p make_pair
using namespace std;
int n,m;
inline int gao(int a,int b,int k){
	return min((b>a)?b-a:b-a+m,((b>=k)?b-k:b-k+m)+1);
}
int a[100010];
int main(void){
	scanf("%d%d",&n,&m);
	set<pair<int,int> > s;
	long long sum=0,res;
	int cnt=0;
	scanf("%d",&a[1]);
	s.insert(m_p(a[1],1));
	for (int i=2;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=gao(a[i-1],a[i],1);
		if (a[i]>=1&&a[i-1]>a[i]) cnt++;
		s.insert(m_p(a[i],i));
	}
	res=sum;
	set<pair<int,int> >::iterator it=s.begin(),t;
	for (int i=2;i<=m;i++){
		while(it!=s.end()&&it->x<i){
			int val=it->x,id=it->y;
			t=it;
			it++;
			s.erase(t);
			if (id>1){
				cnt--;
				if (a[id-1]<a[id]){
					sum+=(a[id]-a[id-1])-1;
				}
				else{
					sum+=(a[id]-a[id-1]+m)-1;
				}
			}
			if (id<n){
				cnt++;
				sum++;
			}
		}
		sum-=cnt;
		res=min(res,sum);
	}
	printf("%lld\n",res);
	return 0;
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var list2 = list.Distinct().ToList();
            Console.WriteLine(list.Count == list2.Count ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 55196
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if b < c || d < a {
		fmt.Println(0)
		return
	}

	if a < c {
		if b < d {
			fmt.Println(b - c)
		} else {
			fmt.Println(d - c)
		}
	} else {
		if b < d {
			fmt.Println(b - a)
		} else {
			fmt.Println(d - a)
		}
	}
}


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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 998244353;
using modint = ModInt<mod>;

modint fact[200010];
modint pow_m[200010];

modint nCk(int n, int k) {
  return fact[n] / fact[k] / fact[n - k];
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  fact[0] = fact[1] = 1;
  for (int i = 2; i < 200010; i++) {
    fact[i] = fact[i - 1] * i;
  }
  pow_m[0] = 1;
  for (int i = 1; i < 200010; i++) {
    pow_m[i] = pow_m[i - 1] * (M - 1);
  }

  modint ans = 0;
  for (int i = 0; i <= K; i++) {
    if (i >= N) break;
    modint a = pow_m[N - i - 1] * M * nCk(N - 1, i);
    ans += a;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll cnt(ll x) {
  ll c = 0;
  FOR(i, 1, x) {
    if (x % i == 0) c++;
  }
  return c;
}

ll fact(ll x) {
  ll ans = 1;
  FOR(i, 1, x) {
    ans *= i;
  }
  return ans;
}

ll c(ll left, ll right) {
  if (left < 1) return 0;
  return fact(left) / (fact(right) * fact(left - right));
}

int main() {
  ll input(n);

  vector<ll> primes(100, 1);
  FOR(i, 2, n) {
    for (ll j = 2, p = i; p != 1;) {
      if (p % j == 0) {
        primes[j]++;
        p /= j;
      } else {
        j++;
      }
    }
  }

  ll cnt75 = 0;
  ll cnt25 = 0;
  ll cnt15 = 0;
  ll cnt5 = 0;
  ll cnt3 = 0;
  for(auto v: primes) {
    if (v >= 75) cnt75++;
    if (v >= 25) cnt25++;
    if (v >= 15) cnt15++;
    if (v >= 5) cnt5++;
    if (v >= 3) cnt3++;
  }
  /* print(c(cnt5, 2) * c(cnt3 - 2, 1)); */
  /* print(c(cnt15, 1) * c(cnt5 - 1, 1)); */
  /* print(c(cnt25, 1) * c(cnt3 - 1, 1)); */
  /* print(c(cnt75, 1)); */
  /*  */
  /* print(primes); */
  /* print(cnt3, cnt5, cnt25, cnt75); */


  ll ans = 0
  + (c(cnt5, 2) * c(cnt3 - 2, 1))
  + (c(cnt15, 1) * c(cnt5 - 1, 1))
  + (c(cnt25, 1) * c(cnt3 - 1, 1))
  + (c(cnt75, 1))
  ;
  print(ans);
}


Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
  char s[4];
  scanf("%s",&s);
  int ans=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+') ans+=1;
    else ans-=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
const int MAXN = 2050;
const ll INF = 1e15;

int n, k, q, A[MAXN];

ll getY(){
    vector<int> V, M;
    forn(i, n){
        if(A[i])V.pb(A[i]);
        else{
            if(V.size() >= k){
                sort(V.begin(), V.end());
//                printf("V:");forn(i, V.size())printf(" %d", V[i]);puts("");
                forn(cnt, (k-1))V.pop_back();
                forn(i, V.size())M.pb(V[i]);
            }V.clear();
        }
    }
    if(V.size() >= k){
//        printf("V:");forn(i, V.size())printf(" %d", V[i]);puts("");
        sort(V.begin(), V.end());
        forn(cnt, (k-1))V.pop_back();
        forn(i, V.size())M.pb(V[i]);
    }
//    printf("M:");forn(i, M.size())printf(" %d", M[i]);puts("");
    if(M.size())sort(M.begin(), M.end());
    return (M.size() < q ? INF : M[q-1]);

}

set<int> S;
int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d %d %d", &n, &k, &q) == 3){
        S.clear();
        forn(i, n){scanf("%d", &A[i]); S.insert(A[i]);}
        ll ans = INF;
        forall(it, S){
            ll X = *it; forn(i, n)if(A[i] < X)A[i] = 0;
            ll Y = getY();
//            printf("%lld %lld\n", X, Y);
            ans = min(ans, Y - X);
        }
        printf("%lld\n", ans);
    }
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,x,sum;
int main()
{
  cin>>m>>n;
  for(int i=0;i<n;i++) cin>>x,sum+=x;
  if(m>=sum) cout<<m-sum;
  else cout<<-1;
  


return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>

using namespace std;

double dp[3005][3005];
double p[3000];

int main() {
    int n;
    cin >> n;
    int maxB = n / 2;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) dp[i][0] = dp[i - 1][0] * p[i];
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= i && j <= maxB; ++j) {
            dp[i][j] = dp[i - 1][j] * p[i] + dp[i - 1][j - 1] * (1 - p[i]);
        }
    }
    double res = 0;
    for (int i = maxB; i >= 0; --i) res += dp[n][i];
    cout << setprecision(15) << res << endl;
}

Measured memory_bytes: 68736
n=input()

n1,n2=int(n[:2]),int(n[2:])
#if (n1>12 and n2>12) or (n1==0 and n2==0):
#   print("NA")
if (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")





Measured memory_bytes: 9164
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;

map<string, long long> p;

int q[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};

long long f(string s, int d) {
    if (p[s])
        return p[s];
    long long res = stoll(s);
    if (d == 1) {
        p[s] = stoll(s);
        return p[s];
    }

    for (int i = 1; i < d; i++) {
        res += (stoll(s.substr(0, i)) * q[d - i - 1]);
        res += f(s.substr(i), d - i);
    }

    p[s] = res;
    return res;
}

int main() {
    string s;
    cin >> s;
    cout << f(s, s.length()) << endl;
    return 0;
}


Measured memory_bytes: 256
a=[]

for i in range(0,10):
    a.append(input())
inp = list(map(int,a))

INP=[0,0,0,0,0,0,0,0,0,0]

for i in range(0,10):
    for j in range(i+1,10):
        if inp[i]<inp[j]:
            INP[j]+=1
        elif inp[i]>inp[j]:
            INP[i]+=1
        else:
            INP[i]+=1
            INP[j]+=1

z = 0

for i in range(9,-1,-1):
    if z >= 3:
        break
    for j in range(0,10):
        if i == INP[j]:
            print(inp[j])
            z+=1
        if z >= 3:
            break

Measured memory_bytes: 7648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), q = in.nextInt();

        RAddQ rAddQ = new RAddQ(n);

        for (int i = 0; i < q; i++) {
            int cmd = in.nextInt();
            if (cmd == 0) {
                int s, t, x;
                s = in.nextInt();
                t = in.nextInt();
                x = in.nextInt();
                rAddQ.add(s, t, x);
            } else if (cmd == 1) {
                int t = in.nextInt();
                rAddQ.get(t);
            }
        }
    }
}


class RAddQ {
    int n, heap[];

    RAddQ(int n) {
        this.n = n;

        int heapLen = 1;
        while (heapLen < n) {
            heapLen *= 2;
        }
        heapLen = 2 * heapLen;

        heap = new int[heapLen];
    }

    void add(int s, int t, int x) {
        add(0, n, 0, s-1, t, x); // try start from 0, 1-n->0-n-1
    }

    private void add(int l, int r, int ih, int s, int t, int x) {
        if (s >= t) {
            return;
        }
        if (s == l && t == r) {
            heap[ih] += x;
            return;
        }

        int mid = (l + r) / 2;
        add(l, mid, ih * 2 + 1, Math.max(s, l), Math.min(t, mid), x);
        add(mid, r, ih * 2 + 2, Math.max(s, mid), Math.min(t, r), x);
    }

    void get(int t) {
        System.out.println(get(0, n, 0, t-1));
    }

    private int get(int l, int r, int ih, int t) {
        if (r - l == 1) {
            return heap[ih];
        }

        int mid = (l + r) / 2;
        if (t < mid)
            return heap[ih] + get(l, mid, ih * 2 + 1, t);
        else
            return heap[ih] + get(mid, r, ih * 2 + 2, t);
    }
}



Measured memory_bytes: 113208
<?php
$N = intval(fgets(STDIN));
//10*10の配列作成
$h = array_fill(0,10,array_fill(0,10,0));
for($i = 1; $i <= $N; $i++){
    $si = "$i";
    $top = $si[0];
    $bottom = $si[strlen($si)-1];
    $h[$top][$bottom]++;
}
$sum = 0;
for($i = 1; $i <= 9; $i++){
    for($j = 1; $j <= 9; $j++){
        $sum+=$h[$i][$j]*$h[$j][$i];
    }
}
echo $sum;

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int h,w,n;cin>>h>>w>>n;

    if(h<w)swap(h,w);

    cout<<(n+h-1)/h;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(a, b) << " ";
    if (a + b >= n) {
        cout << a + b - n << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
 
using namespace std;
 
int main(int argc, char** argv) {
  int n;
  cin >> n;
  int a[n];
  bool okay = true;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
   	int x = a[i];
    if ((x % 2 == 0) &&
        ((x % 3 != 0) &&
         (x % 5 != 0))) {
      okay = false;
    }
  }
  cout << (okay ? "APPROVED\n" : "DENIED\n");
  return 0;
}

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

int main() {
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  rep(i, 0, T) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  rep(i, 0, T - 1) sum += a[i];
  int ans = max(0, a[T-1] - sum - 1);
  cout << ans << endl;
}


Measured memory_bytes: 256
PROGRAM-ID.                      ABC_052_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N       PIC 9(3).
    01 S1.
        03 S PIC X(1) OCCURS 100.

    01 tmp     PIC S9(3).
    01 mx      PIC S9(3).

    01 ans     PIC X(18).

    01 ZS      PIC -(3)9.
    01 DUMMY   PIC X(1).

    01 i       PIC 9(3).

PROCEDURE                        DIVISION.
    ACCEPT N.

    ACCEPT S1.

    MOVE ZERO TO mx.
    MOVE ZERO TO tmp.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        IF S(i) = 'I' THEN
            ADD 1 TO tmp
        ELSE
            SUBTRACT 1 FROM tmp
        END-IF
        COMPUTE mx = FUNCTION MAX(mx, tmp)
    END-PERFORM.

    MOVE mx TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

using namespace std;

long C(int m, int n)
{
  int d = m - n;
  if (d < n) swap(d, n);
  // cerr << m << ", " << n << endl;
  int j = 2;
  long long value = 1;
  for (int i = 0; i < d; ++i) {
    value *= m - i;
    while (j <= d and value % j == 0) {
      value /= j;
      ++j;
    }
  }
  return value;
}

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  vector<long> v(N);
  for (int i = 0; i < N; ++i) cin >> v[i];
  sort(v.begin(), v.end(), [](long a, long b) { return b < a; });
  long sum = accumulate(v.begin(), v.begin() + A, 0l);
  auto last = v[A - 1];
  if (v[0] == last) {
    int n = count(v.begin(), v.end(), last);
    long result = 0;
    for (int i = A; i <= n and i <= B; ++i) result += C(n, i);
    cout << last << endl << result << endl;
  } else {
    long double avg = static_cast<long double>(sum) / A;
    int n = count(v.begin(), v.end(), last);
    int n2 = count(v.begin() + A, v.end(), last);
    // cerr << n << ", " << n2 << endl;
    cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1) << avg << endl << C(n, n - n2) << endl;
  }
  return 0;
}

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

signed main() {
  ll n;
  cin >> n;
  for(ll i = sqrt(n); ; i--) {
    if(n % i == 0) {
      cout << ll(log10(n / i)) + 1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,x,a[100005];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
        m=max(m,x);
    }
    if((a[m]==n&&(m==n-1||m*2<=n))||(a[m]+a[m-1]==n&&2*m-n<=a[m-1]&&a[m-1]<m))cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 640
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,w=MI()
lis=[LI() for i in range(n)]
u=lis[0][0]
vals=[[] for i in range(4)]
for i in range(n):
    if lis[i][0]==u:
        vals[0].append(lis[i][1])
    elif lis[i][0]==u+1:
        vals[1].append(lis[i][1])
    elif lis[i][0]==u+2:
        vals[2].append(lis[i][1])
    else:
        vals[3].append(lis[i][1])
#print(vals)
for i in range(4):
    vals[i].sort(reverse=True)
    vals[i]=list(accumulate(vals[i]))
    vals[i]=[0]+vals[i]
mx=0
#print(vals)
for i in range(len(vals[0])):
    for j in range(len(vals[1])):
        for k in range(len(vals[2])):
            for l in range(len(vals[3])):
                if u*i+(u+1)*j+(u+2)*k+(u+3)*l>w:
                    continue
                V=vals[0][i]+vals[1][j]+vals[2][k]+vals[3][l]
                if V>mx:
                    mx=V
print(mx)
            
        

    

        
        
        
            
        

                


Measured memory_bytes: 9516
// problem: "https://atcoder.jp/contests/abc148/tasks/abc148_d"

#include<bits/stdc++.h>

using namespace std;

int minBreak(vector<int>&V,int n)
{
    int i,j,c;
    j = 1;
    c = 0;

    for(i=0;i!=n;i++)
    {
        if(V[i] == j)
            j++;
        else
            c++;
    }

    if(c == n)
        return -1;
        
    return c;
}

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

    int i,x;
    vector<int>V;

    for(i=0;i!=n;i++)
    {
        cin>>x;
        V.push_back(x);
    }

    cout<<minBreak(V,n);        // define

    return 0;
}


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

int main(){
   vector<int> A(9);
   vector<bool> result(9);
   for (int i=0; i<9; i++)
      cin >> A.at(i);

   int N;
   cin >> N;
   vector<int> b(N);
   for (int i=0; i<N; i++)
      cin >> b.at(i);

   for (int x: b){
      for (int i=0; i<9; i++){
         if (x == A.at(i))
            result.at(i) = true;
      }
   }

   if (result.at(0) && result.at(1) && result.at(2))
      cout << "Yes" << endl;
   else if (result.at(3) && result.at(4) && result.at(5))
      cout << "Yes" << endl;
   else if (result.at(6) && result.at(7) && result.at(8))
      cout << "Yes" << endl;
   else if (result.at(0) && result.at(3) && result.at(6))
      cout << "Yes" << endl;
   else if (result.at(1) && result.at(4) && result.at(7))
      cout << "Yes" << endl;
   else if (result.at(2) && result.at(5) && result.at(8))
      cout << "Yes" << endl;
   else if (result.at(0) && result.at(4) && result.at(8))
      cout << "Yes" << endl;
   else if (result.at(2) && result.at(4) && result.at(6))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;

}



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

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	char ar[MaxN ],br[MaxN] ,cr[MaxN];
	cin >> ar >> br >> cr;
	char next;
	int i = 0 , j = 0 , z = 0;
	int len1 = strlen(ar) , len2 = strlen(br) , len3 = strlen(cr);
	next = 'a';
	while(i <= len1 && j <= len2 && z <= len3)
	{
		if(next == 'a'){
			next = ar[i];
			i++;
			}
		if(next == 'b'){
			next = br[j];
			j++;
			}
		if(next == 'c'){
			next = cr[z];
			z++;
			}
		}
	if(i == len1 + 1)cout << "A" << endl;
	if(j == len2 + 1)cout << "B" << endl;
	if(z == len3 + 1)cout << "C" << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n;
		cin >> n;
		ll d;
		cin >> d;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ll x, y;
			cin >> x >> y;
			if(x*x + y*y <= d*d) {
				ans++;
			}
		
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
  printf("%d\n%d\n",(a+b+c+d)/60,(a+b+c+d)%60);
  return 0;
}

Measured memory_bytes: 0
//file_name:ABC94_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll b[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        b[i] = a[i];
    }
    sort(b,b+n);

    rep(i,n){
        if(a[i]<=b[n/2-1]){
            cout << b[n/2] << endl;
        }else{
            cout << b[n/2-1] << endl;
        }
    }


    return 0;
}



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

int main()
{
    int N;
    int P[200005];
    cin >> N;
    REP(i, N)
        cin >> P[i];
    int min, ans;
    ans = 1;
    min = P[0];
    REP(i, N-1){
        if(min >= P[i+1])
            ans++;
        if(min > P[i+1])
            min = P[i+1];
    }
    cout << ans << endl;
    
    return 0;
}



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

int main(){
	int n, m, l, a[105][105], b[105][105];
	cin >> n >> m >> l;
	for(int i = 0;i < n;i++)
	for(int j = 0;j < m;j++)cin >> a[i][j];
	for(int i = 0;i < m;i++)
	for(int j = 0;j < l;j++)cin >> b[i][j];
	
	for(int i = 0;i < n;i++){
		for(int j = 0;j < l;j++){
			long long t = 0;
			for(int k = 0;k < m;k++){
				t += a[i][k]*b[k][j];
			}
			if(j)cout << " ";
			cout << t;
		}
		cout << endl;
	}
	
	return 0;
}

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

int N;

struct shop 
{
	int id;
	string name;
	int point;
};

vector<shop> shoplist;


bool cmp(const shop& a, const shop& b)
{
	if (a.name == b.name)
	{
		return a.point > b.point;
	}

	return a.name < b.name;
}

int main()
{
	cin >> N;

	int idx = 1;
	shop s;
	for (int i = 0; i < N * 2; ++i) 
	{
		if (i % 2 == 0)
		{
			s.id = idx;
			cin >> s.name;
		}
		else 
		{
			cin >> s.point;
			shoplist.push_back(s);
			idx++;
		}
	}

	sort(shoplist.begin(), shoplist.end(), cmp);
	//sort(shoplist.begin(), shoplist.end(), [](const shop & x, const shop & y) {return x.point > y.point; });
	//sort(shoplist.begin(), shoplist.end(), [](const shop & x, const shop & y) {return x.name < y.name; });
	
	for (shop shp : shoplist) {
		cout << shp.id << endl;
	}
	
	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);
        while (true) {
            String line = sc.nextLine();
            String[] data = line.split("");
            if (data[0].equals("0")) {
                break;
            }
            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += Integer.parseInt(data[i]);
            }
            System.out.println(sum);
        }
        sc.close();
    }    
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int X, N;
    cin >> X >> N;
    set<int> st;
    rep(i, N) {
        int a;
        cin >> a;
        st.insert(a);
    }

    pii ans(100000, 100000);
    for (int i = -300; i <= 300; ++i) {
        if (!st.count(i)) {
            chmin(ans, mp(abs(i - X), i));
        }
    }
    cout << ans.se << endl;

    return 0;
}

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

using ll =long long;

int main() {
int N;
  cin>>N;
  
  vector<double> X(N);
  vector<string> U(N);
  
  for(int i=0;i<N;i++){
    cin>>X[i]>>U[i];
  }
  double sum=0;
  for(int i=0;i<N;i++){
    if(U[i]=="JPY"){
      sum+=X[i];
    }else if (U[i]=="BTC"){
      sum+=X[i]*380000.0;
    }
  }
  
  cout<<sum<<endl;
    
    
    
    
    
}

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

int main() {
    char str[1200];
    int i;
    gets(str);
    for (i = 0; str[i]; i++) {
        if (islower(str[i])) {
            printf("%c", toupper(str[i]));
        } else if (isupper(str[i])) {
            printf("%c", tolower(str[i]));
        } else {
            printf("%c", str[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592
#define pb push_back

int main(){
    ll n;
    cin >> n;
    vll cnt(5);
    rep(i,n){
        string S;
        cin >> S;
        switch(S[0]){
            case 'M':
                ++cnt[0];
                break;
            case 'A':
                ++cnt[1];
                break;
            case 'R':
                ++cnt[2];
                break;
            case 'C':
                ++cnt[3];
                break;
            case 'H':
                ++cnt[4];
        }
    }

    int A[]={0,0,0,0,0,0,1,1,1,2};
    int B[]={1,1,1,2,2,3,2,2,3,3};
    int C[]={2,3,4,3,4,4,3,4,4,4};

    ll ans=0;
    rep(i,10) ans+=cnt[A[i]]*cnt[B[i]]*cnt[C[i]];
    cout << ans << endl;
}


Measured memory_bytes: 384