akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define big 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define mem0(a) memset(a,0,sizeof(a))
    #define memf(a) memset(a,false,sizeof(a))
    #define mem1(a) memset(a,1,sizeof(a))
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
	{ 
    	if (y == 0) 
        	return 1; 
    	int p = power(x, y/2, m) % m; 
    	p = (p * p) % m; 
  
 	   return (y%2 == 0)? p : (x * p) % m; 
	} 
	int modInverse(int a, int m) 
	{   
    	return power(a, m-2, m);
	}
    signed main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll t=1;
    	// cin >> t;
    	/*SAARE INPUTS LENA*/
    	/*VARIABLES KI RANGE DEKHLENA*/
    	while(t-->0)
    	{
    		ll n=0,k=0,s=0;
    		cin>>n>>k;
    		for(int i=k;i<=(n+1);i++)
    		{
    			s+=(i*n+1-(i)*(i-1))%M;
    			s=s%M;
    			// cout<<s<<endl;
    		}
    		cout<<s;
    	}    	
    	return 0;
    }

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
long long a[1000], mon = 1;
int main() {
	int n; 
    cin >> n;
	for (int i = 2; i <= n; ++i) {
		int k = i;
		for (int j = 2; j <= k; ++j) {
			while (k % j == 0) {
				++a[j];
				k /= j;
			}
		}
	} 
	for (int i = 2; i <= n; ++i) {
		mon = mon * (a[i] + 1) % 1000000007;
	}
	cout << mon << endl;
}


Measured memory_bytes: 256
L,R = map(int,input().split())

def mfnc():
  m = 2018
  for i in range(L,R):
    for j in range(i+1,R+1):
      if i*j%2019<m:
        m = i*j%2019
  return m      

if L//2019 == R//2019:
  print(mfnc())
else:
  print(0)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n,m,i,j,ans=0,c;
  char s[101][11],t[101][11];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%s",s[i]);
  scanf("%d",&m);
  for(i=1;i<=m;i++)scanf("%s",t[i]);
  for(i=1;i<=n;i++){
    c=0;
    for(j=1;j<=m;j++)
      if(strcmp(s[i],t[j])==0)c--;
    for(j=1;j<=n;j++)
      if(strcmp(s[i],s[j])==0)c++;
    if(ans<c)ans=c;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <unordered_map>

using namespace std;

constexpr long MAXC = 2E9;

void finddist(int pwd, int parent, vector<unordered_map<int, long>> &edge, vector<long> &kdistance) {
    kdistance[pwd] = kdistance[parent] + edge[parent][pwd];
    for (auto&& itr : edge[pwd]) {
        if (itr.first == parent) continue;
        finddist(itr.first, pwd, edge, kdistance);
    }
}

int main() {
    int nodes;
    cin >> nodes;
    vector<unordered_map<int, long>> edge(nodes + 1);
    for (int i = 0; i < nodes - 1; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        edge[a].emplace(b, c);
        edge[b].emplace(a, c);
    }

    int problems, k;
    cin >> problems >> k;
    vector<long> kdistance(nodes + 1, MAXC);
    kdistance[k] = 0;

    for (auto&& itr : edge[k]) {
        finddist(itr.first, k, edge, kdistance);
    }

    for (int i = 0; i < problems; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        cout << kdistance[x] + kdistance[y] << endl;
    }
}


Measured memory_bytes: 25216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;

    cout << S.substr(0,4) << " " << S.substr(4,12) << endl;
}

Measured memory_bytes: 256
import Data.Char
main=getLine>>=print.f
f [] = 0
f (a:r)
 |null r=digitToInt a
 |all(=='9')r=digitToInt a + 9*length r
 |a=='9' && head r=='9'=9+f r
 |otherwise=(digitToInt a - 1) + 9*length r


Measured memory_bytes: 380
import math

M, D = map(int, input().split())

cnt = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        a = d//10
        b = d - a*10
        if a>=2 and b>=2 and a*b == m:
            cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    vector<string> s(3);
    int i;
    for(i = 0;i < 3;++i){
        cin >> s.at(i);
    }
    int temp = 0;
    int temp1;
    while(true){
        if(s.at(temp).size() == 0){
            break;
        }else{
            temp1 = (int)(s.at(temp).at(0)) - 97;
            s.at(temp).erase(s.at(temp).begin());
            temp = temp1;
        }
    }
    if(temp == 0){
        cout << 'A' << endl;
    }else if(temp == 1){
        cout << 'B' << endl;
    }else if(temp == 2){
        cout << 'C' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int getRank(char rank){
    if(isdigit(rank)) return rank-'0';
    if(rank == 'T') return 10; 
    if(rank == 'J') return 11; 
    if(rank == 'Q') return 12; 
    if(rank == 'K') return 13; 
    if(rank == 'A') return 14; 
    return -1;
}
 
int getSuit(char suit){
    if(suit == 'C') return 0; 
    if(suit == 'H') return 1; 
    if(suit == 'D') return 2; 
    if(suit == 'S') return 3; 
    return -1;
}
 
int main(){
    char T;
    while(cin >> T, T != '#'){
	string Card;
	int Trump = getSuit(T);
	int rank[4][13],suit[4][13];
	for(int i = 0 ; i < 4 ; i++){
	    for(int j = 0 ; j < 13 ; j++){
		cin >> Card;
		rank[i][j] = getRank(Card[0]);
		suit[i][j] = getSuit(Card[1]);
	    }
	}
	int dealer = 0;
	int team[2] = {0};
	for(int turn = 0 ; turn < 13 ; turn++){
	    int winner = dealer;
	    int s = suit[dealer][turn];
	    int r = rank[dealer][turn];
	    if(s == Trump){ r += 13; }
	    for(int i = 1 ; i < 4 ; i++){
		int player = (dealer+i) % 4;
		int ns = suit[player][turn];
		int nr = rank[player][turn];
		if(ns == Trump){ nr += 13; }
		if(ns != s && ns != Trump){
		    continue;
		}
		if(r < nr){
		    r = nr;
		    winner = player;
		}
	    }
	    team[winner%2]++;
	    dealer = winner;
	}
	for(int i = 0 ; i < 2 ; i++){
	    team[i] -= 6;
	}
	if(team[0] < team[1]){
	    cout << "EW " << team[1] << endl;
	}else{
	    cout << "NS " << team[0] << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 2964
import sys
import math
import bisect

def solve(A):
    for a in A:
        if a % 2 == 0:
            if a % 3 != 0 and a % 5 != 0:
                return False
    return True

def main():
    n = int(input())
    A = list(map(int, input().split()))
    if solve(A):
        print('APPROVED')
    else:
        print('DENIED')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for aa in range(a+1):
    ay = 500*aa
    if ay <= x:
        for bb in range(b+1):
            by = 100*bb
            if ay + by <= x:
                for cc in range(c+1):
                    cy = 50*cc
                    if ay + by + cy ==x:
                        count += 1
                        break
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    int N;
    cin>>N;
    VECi(string,v,1,"");
    
    string bef="";
    map<string,int> t;
    REP(i,N){
        string s;
        cin>>s;
        //auto t = find(ALL(v),s);
        //v.push_back(s);
        t[s]=1;
        //sl(s,bef[0],s[0],bef[0]!=s[0],t.size());
        if(i>0&&(s[0] != bef[0] || t.size()!=i+1)){
            cout<<"No";return 0;
        }
        bef=s[s.length()-1];
    }
    
    
    cout<<"Yes";
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main() {
  ll x;
  cin >> x;
  ll base = 100;
  int n = 0;
  for (; base < x; n++) {
    base += base/100;
  }
  cout << n << endl;
}


Measured memory_bytes: 3644
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000, mod = 1_000_000_007;



    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    long[] toLongArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        long[] ary = new long[n];
        for(int i = 0; i < n; i++) ary[i] = Long.valueOf(sp[i]);
        return ary;
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }


    long pow(long a, int pow)
    {
        long res = 1;
        while(pow > 0)
        {
            if(pow % 2 != 0) {
                res *= a;
                res %= mod;
            }
            a = a * a;
            a %= mod;
            pow /= 2;
        }

        return res;
    }

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");
        char[] gg = in.readLine().toCharArray();}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        
        new Main().a();

        
        out.flush();
    }


    void a() throws Exception
    {
        char[] chs = in.readLine().toCharArray();
        if(chs[2] == chs[3] && chs[4] == chs[5]) 
        {
            out.println("Yes");
        }
        else out.println("No");
    }
}

Measured memory_bytes: 21844
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B = map(int,input().split())

if A==B:
    print("Draw")
else:
    if A == 1:
        A = 14
    if B == 1:
        B = 14
    print("Alice" if A > B else "Bob")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

vector<int> G[N];
int vl[5005];
int arr[5005],tmp[5005];
pii dfs(int v){
	vector<pii> ak;
	REP(i,G[v].size()){
		ak.pb(dfs(G[v][i]));
	}
	if(ak.size()==0){
		return mp(vl[v],0);
	}
	REP(i,5005) arr[i]=tmp[i]=mod;
	arr[0]=0;
	REP(i,ak.size()){
		REP(j,5005) if(arr[j]<mod){
			if(ak[i].X+j<5005){
				tmp[ak[i].X+j]=min(tmp[ak[i].X+j],ak[i].Y+arr[j]);
			}
			if(ak[i].Y+j<5005){
				tmp[ak[i].Y+j]=min(tmp[ak[i].Y+j],ak[i].X+arr[j]);
			}
		}
		REP(j,5005) arr[j]=tmp[j],tmp[j]=mod;
	}
	int bst = mod;
	REP(j,vl[v]+1) bst = min(bst,arr[j]);
	if(bst == mod){
		printf("IMPOSSIBLE\n");
		exit(0);
	}
	return mp(vl[v],bst);
}
int main(){
	int n;
	scanf("%d",&n);
	REP(i,n-1){
		int x; scanf("%d",&x); x--;
		G[x].pb(i+1);
	}
	REP(i,n) scanf("%d",&vl[i]);
	dfs(0);
	printf("POSSIBLE\n");
	return 0;
}


Measured memory_bytes: 23808
#include <stdio.h>
#include <vector>
typedef long long ll;

int main(void) {
  ll i, j, k, n, f[26], l[26], now = 26;
  char s[200010];
  std::vector<bool> ans[26][26];
  bool flg[26], b;
  scanf("%s", s);
  for(i = 0; i < 26; ++i) f[i] = l[i] = -1;
  for(i = 0; s[i]; ++i) {
    if(f[s[i] - 'a'] == -1) --now, f[s[i] - 'a'] = i;
    l[s[i] - 'a'] = i;
    if(!now) {
      for(j = 0; j < 26; ++j) for(k = 0; k < 26; ++k) {
        if(f[j] < l[k]) ans[j][k].push_back(false);
        else ans[j][k].push_back(true);
      }
      for(j = 0; j < 26; ++j) f[j] = l[j] = -1;
      now = 26;
    }
  }
  n = ans[0][0].size();
  if(n) for(i = 0; i < 26; ++i) if(f[i] != -1) for(j = 0; j < 26; ++j) ans[j][i][n - 1] = false;
  if(n) for(i = n - 1; i; --i) {
    for(j = 0; j < 26; ++j) {
      b = false;
      for(k = 0; k < 26; ++k) b = b | ans[j][k][i];
      if(!b) for(k = 0; k < 26; ++k) ans[k][j][i - 1] = false;
    }
  }
  for(i = 0; i < 26; ++i) flg[i] = true;
  for(i = 0; i < n; ++i) {
    for(j = 0; j < 26; ++j) if(flg[j]) {
      b = false;
      for(k = 0; k < 26; ++k) b = b | ans[j][k][i];
      if(b) {
        printf("%c", j + 'a');
        for(k = 0; k < 26; ++k) flg[k] = ans[j][k][i];
        break;
      }
    }
  }
  for(i = 0; i < 26; ++i) if(flg[i] && f[i] == -1) {
    printf("%c", i + 'a');
    break;
  }
  return 0;
}

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

int main() {
int length;
cin >> length;
string text;
cin >> text;
long counter = 1;
for (int i=0; i<length-1;i++){
char now = text.at(i);
char follow = text.at(i+1);
if(now != follow){counter+=1;}
}
cout << counter << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;
using ll = long long;

int main() {
	string O, E;
	cin >> O >> E;
	
	for (int i = 0; i < O.size(); i++) {
		cout << O[i];

		if (i < E.size())cout << E[i];
	}
	
	cout << endl;
}

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

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // オーバーフローしないように先に割る

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("frog2.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n, k;
    cin >> n >> k;

    vector<ll> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    vector<ll> dp(n);

    rep(i, n)
    {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            if (i < j) break;
            chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[n-1];




    return 0;
}

/*
  - 最大値
    - long long : LLONG_MAX, LLONG_MIN, ULLONG_MAX(unsigned long long max)
  - vector
    vector<int> A(N);
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 1792
#!/usr/bin/env python3

x, k, d = list(map(int, input().split()))

if x < 0:
    x *= -1

num = x//d

if num >= k:
    print(x-d*k)
    exit()
else:
    tmp = k-num
    if tmp % 2 == 0:
        print(x-d*num)
    else:
        print(d*(num+1)-x)


Measured memory_bytes: 9152
/** MIT License Copyright (c) 2018-2019 Vasilev Daniil **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
typedef long long ll;
#define int ll
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-12;
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//code starts here
const int N = 100;
int dp[N][4][4][4];
const int mod = 1e9 + 7;

void add(int i, int j, int k, int l, int s) {
	dp[i][j][k][l] = (dp[i][j][k][l] + s) % mod;
}

bool cor(int a, int b, int c) {
	if (a == 0 && b == 1 && c == 2)
		return 0;
	swap(a, b);
	if (a == 0 && b == 1 && c == 2)
		return 0;
	swap(a, b);
	swap(b, c);
	if (a == 0 && b == 1 && c == 2)
		return 0;
	return 1;
}

void run() {
	int n;
	get n;
	memset(dp, 0, sizeof dp);

	rep(i, 2, n)
		rep(j, 0, 4)
			rep(k, 0, 4)
				rep(l, 0, 4) {//mlkj
					if (!cor(l, k, j))
						continue;
					if (i == 2)
						dp[i][j][k][l] = 1;
					else {
						rep(m, 0, 4) {//mlkj; lmkj; mklj; mljk
							if ((m == 0 && k == 1 && j == 2) || !cor(m, l, k) || (m == 0 && l == 1 && j == 2))
								continue;
                            //print(m, l, k, j); eol;
							add(i, j, k, l, dp[i - 1][k][l][m]);
						}
					}
				}
	int s = 0;
	rep(j, 0, 4)
		rep(k, 0, 4)
			rep(l, 0, 4)
				s = (s + dp[n - 1][j][k][l]) % mod;
	put s;
}

signed main() {ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run();}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> pt;

pt proj(pt a,pt to){
  return (conj(a)*to).real()/norm(to)*to;
}

pt refle(pt a,pt mirror){
  return pt(2)*proj(a,mirror)-a;
}

int main(){
  int i,j,k,n;
  pt o,p,q;
  cin>>o.real()>>o.imag()>>p.real()>>p.imag();
  cin>>n;
  rep(i,n){
    cin>>q.real()>>q.imag();
    q=refle(q-o,p-o)+o;
    printf("%.9f %.9f\n",q.real(),q.imag());
  }
  return 0;
}

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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n;
        cin>>n;
        cout<<fixed;
        cout<<setprecision(10);
        vector<double>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        vector<vector<double>>dp(n+1,vector<double>(n+1,0.0));
        dp[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=i;j++){
                if(j==0)
                    dp[i][j]=dp[i-1][j]*(1-a[i-1]);
                else
                    dp[i][j]=dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*(a[i-1]);
            }
        }
        double ans=0.0;
        for(int i=n;i>(n/2);i--)
            ans+=dp[n][i];
        cout<<ans;
        return 0;
    }


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
#include <math.h>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

inline void bfs(int start,int end,vector<vector<int> > G,int dist[]){
    //if (G[start].size() == 0) return;
    if (start == end) return;
    for(int i = 0; i < G[start].size(); i++){
        if (dist[G[start][i]] >= dist[start]+1){
            dist[G[start][i]] = min(dist[G[start][i]],dist[start]+1);
            bfs(G[start][i],end,G,dist);
        }
    }
}
int main(){
    while(true){
        string a; cin >> a;
        if (a == "0") break;
        int ans = 0;
        for(int i = 0; i < a.size(); i++){
            ans += (a[i]-'0');
        }
        cout << ans << endl;
    }
}








Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int Max=2e5+5;
int main()
{
	ll n,u=0;
	scl(n);
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll	num=1,cou=0;
			while(n%i==0){
				n/=i;cou++;
				if(cou==num){u++;cou=0;num++;}
			}	
		}
	}pf("%lld\n",u+(n==1?0:1));
}


Measured memory_bytes: 3820
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  string s;
  cin >> s;

  LL sum = 0;

  LL cnt = 0;

  REP(i,s.size()){
    if(s[i]=='W'){
      cnt++;
      sum -= cnt;
    }
  }

  REP(i,s.size()){
    if(s[i]=='W'){
      sum += i + 1;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 720
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;



int main(){

    int a,b;
    cin>>a>>b;
    cout<<6-(a+b)<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    use std::cell::Cell;

    let n: usize = parse_line();

    #[derive(Debug)]
    struct Point {
        x: i32,
        y: i32,
    }

    #[derive(Debug)]
    struct RedPoint {
        point: Point,
        used: Cell<bool>,
    }

    let red_points = {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let p = parse_vec::<i32>();
            v.push(RedPoint {
                point: Point { x: p[0], y: p[1] },
                used: Cell::new(false),
            });
        }
        v.sort_by_key(|p| p.point.x);
        v
    };

    let blue_points = {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let p = parse_vec::<i32>();
            v.push(Point { x: p[0], y: p[1] });
        }
        v.sort_by_key(|p| p.x);
        v
    };

    let mut pair_count = 0;

    for blue in blue_points {
        let r = red_points
            .iter()
            .take_while(|r| r.point.x < blue.x)
            .filter(|r| r.point.y < blue.y && !r.used.get())
            .max_by_key(|r| r.point.y);

        if let Some(r) = r {
            r.used.set(true);
            pair_count += 1;
        }
    }

    println!("{}", pair_count);
}

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

    #[test]
    fn test() {
        //
    }
}


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

int main() {
  int N = 3;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    ans += abs(A.at(i) - A.at(i + 1));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   string S;
   cin >> S;
   int l =S.length();
   if (S[l-1]=='1' || S[l-1]=='0' || S[l-1]=='6' || S[l-1]=='8') cout << "pon";
   else if (S[l-1]=='2' || S[l-1]=='4' || S[l-1]=='5' || S[l-1]=='7' || S[l-1]=='9') cout << "hon";
   else cout << "bon";
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  
  vector<int>C(100,1);
  for (int i = 1; i <= 100; i++) {
    if (A%i == 0 && B%i == 0){
      C.at(i-1) = i;
    }
  }
  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());
  cout << C.at(K-1) << endl;
}
  

Measured memory_bytes: 3632
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

module String =
    /// Converts a string into a list of characters.
    let explode (s:string) =
        [for c in s -> c]

    /// Converts a list of characters into a string.
    let implode (xs:char list) =
        let sb = System.Text.StringBuilder(xs.Length)
        xs |> List.iter (sb.Append >> ignore)
        sb.ToString()

let rec doit n sa sb sc =
    match (sa,sb,sc) with
    | ([],_,_) when n = 0 -> "A"
    | (h::t, _, _) when n = 0 -> doit h t sb sc
    | (_,[],_) when n = 1 -> "B"
    | (_, h::t, _) when n = 1 -> doit h sa t sc
    | (_,_,[]) when n = 2 -> "C"
    | (_, _, h::t) when n = 2 -> doit h sa sb t
    | _ -> "Error"

let sa = Console.ReadLine() |> String.explode |> List.map (fun c -> (int c) - (int 'a'))
let sb = Console.ReadLine() |> String.explode |> List.map (fun c -> (int c) - (int 'a'))
let sc = Console.ReadLine() |> String.explode |> List.map (fun c -> (int c) - (int 'a'))
doit 0 sa sb sc |> Console.WriteLine


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

const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

Measured memory_bytes: 11876
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;i=N)for(++d,F=1;i--;)u[i]<d&&(j=A[I[i]][i]-1)>=0&&u[F&=2,j]<d&&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}

Measured memory_bytes: 4096
#include <stdio.h>
   
typedef struct pair* ppair;
   
typedef struct pair {
  int first, second;
} pair;
   
   
int size;
pair v[1000000];
int psize;
pair preorder[1000000];
int sorted;
   
void swap(ppair a, ppair b) {
  pair t = *a;
  *a = *b;
  *b = t;
}
   
int getp(int begin, int end) {
  int i;
  int p = begin;
  for(i = begin+1; i < end; ++i) {
    if(v[i].first < v[p].first) {
      p = i;
    }
  }
  swap(&v[end-1], &v[p]);
  return end-1;
}
   
void qsort(int begin, int end) {
  int i, j;
  if(begin >= end) return;
  getp(begin,end);
  preorder[psize++] = v[end-1];
  if(begin+1 == end) return;
  for(i = begin, j = begin; i < end; ++i) {
    if(v[i].second < v[end-1].second) {
      swap(&v[i], &v[j++]);
    }
  }
  swap(&v[j],&v[end-1]);
  qsort(begin, j);
  qsort(j+1, end);
}
   
int binary_search(int k) {
  int l, r;
  l = 0;
  r = size;
  while(l < r) {
    int m = (l+r)/2;
    if(v[m].second == k) {
      return m;
    } else if(v[m].second < k) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return -1;
}
   
int main() {
  int i, j;
  int n, k;
  char s[100];
  size = 0;
  sorted = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    if(s[0] == 'i') {
      scanf("%d", &k);
      v[size] = (pair){size,k};
      ++size;
      sorted = 0;
    } else if(s[0] == 'p') {
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      for(j = 0; j < size; ++j) {
        printf(" %d", v[j].second);
      }
      printf("\n");
      for(j = 0; j < size; ++j) {
        printf(" %d", preorder[j].second);
      }
      printf("\n");
    } else {
      scanf("%d", &k);
      if(!sorted) {
        psize = 0;
        qsort(0, size);
        sorted = 1;
      }
      printf(binary_search(k)!=-1?"yes\n":"no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 7920
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;
    int a,b,c;
    cin>>a>>b>>c;

    if(a+b+c >= 22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
  rr;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e5 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    int n ;
    cin >> n ;
    int a[n] , p[n] , ans = 0;
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i] ;
        p[i] = a[i];
        if(i != 0) p[i] += p[i - 1];
    }
    for(int i = 0 ; i < n ; i ++) {
        int sum = p[n - 1];
        sum -= p[i];
        sum %= mod ;
        ans = (ans + (sum * a[i]) % mod + mod) % mod;
    }
    cout << ans << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}


Measured memory_bytes: 6740
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-06-13 17:18:28
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k , A[MAXN] , B[MAXN] , cnt[MAXN];

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

    cin >> n >> k;
    k = min(k , 500ll);
    for(int i = 0 ; i < n ; i++)    cin >> A[i];
    for(int i = 0 ; i < k ; i++){
        fill(B , B + n + 2 , 0);
        for(int j = 0 ; j < n ; j++){
            B[j + A[j] + 1]--;
            B[max(0ll , j - A[j])]++;
        }
        A[0] = B[0];
        for(int j = 1 ; j < n ; j++)    B[j] += B[j - 1] , A[j] = B[j];
    }
    for(int i = 0 ; i < n ; i++)    cout << A[i] << sep;

    return 0;
}
/*

*/


Measured memory_bytes: 8316
#include<iostream>
using namespace std;
int a[] = {1, 3, 5, 7, 8, 10, 12};
int b[] = {4, 6, 9, 11};
int c[] = {2};
int x, y;
bool in_arr(int* a, int x, int n){
  for(int i=0; i<n; i++){
    if(a[i] == x) return true;
    }
  return false;
  }

int main(){
  cin >> x >> y;
  if(in_arr(a, x, 7) && in_arr(a, y, 7))
    cout << "Yes" << endl;
  else if(in_arr(b, x, 4) && in_arr(b, y, 4))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,f[1005][1005];
char b[1005][1005];
void add(int &x,int v)
{
	x+=v;
	if(x>=mod) x-=mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",b[i]+1);
	}
	//int f[7][7];
	f[1][1]=1;
//	cout<<f[5][6];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(b[i][j]=='.')
			{
				
				add(f[i][j],f[i-1][j]);
				add(f[i][j],f[i][j-1]);
			}
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}


Measured memory_bytes: 5120
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let nums : Vec<i32> = input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    let max = nums[0];
    let sum = nums[1];

    println!("{}", count_func(max, sum));
}

fn count_func(max : i32, sum : i32) -> i32 {
    let mut result = 0;
    for x in 0..max + 1 {
        for y in 0..max + 1 {
            if x + y >= sum - max && x + y <= sum {
                result += 1;
            }
        }
    }

    result
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

vector<string> d(4);


int main(){
    string S;
    cin >> S;
    d.at(0)="dream";
    d.at(1)="dreamer";
    d.at(2)="erase";
    d.at(3)="eraser";
    int siz=S.size();
    while(1){
        //それそのものがdと完全に一致してたら最後まで来たのでYES出してreturn
        //最後尾がdのうちのどれかだったらそれ削って続行
        //違ったらNO出力してreturn
        rep(i,4){
            if(S==d.at(i)){
                cout << "YES" << endl;
                return 0;
            }
        }
        siz=S.size();
        if(siz<=9){
            cout << "NO" << endl;
            return 0;
        }

        if(S.substr(siz-5,siz)==d.at(0)){
            S=S.substr(0,siz-5);
        }else if(S.substr(siz-7,siz)==d.at(1)){
            S=S.substr(0,siz-7);
        }else if(S.substr(siz-5,siz)==d.at(2)){
            S=S.substr(0,siz-5);
        }else if(S.substr(siz-6,siz)==d.at(3)){
            S=S.substr(0,siz-6);
        }else{
            cout << "NO" << endl;
            return 0;
        }


    }
    return 0;
}

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

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

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

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;

    set<string>s;
    while(n--){
        string a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 19220
#include <stdio.h>

int p[15];
int c[15];
int used[15];
int D,G;
int ans;

void dfs(int depth){

	int i,j;

	if(depth==D){

		int cnt=0;
		int sum=0;

		for(i=0;i<D;i++){
			if(used[i]==1){
				cnt+=p[i];
				sum+=(100*(i+1)*p[i])+c[i];
			}
		}
		if(sum>=G){
			if(ans>cnt){ans=cnt;}
		}

		for(i=D-1;i>=0;i--){
			if(used[i]==0){
				for(j=0;j<p[i];j++){
					if(sum>=G){
						if(ans>cnt){ans=cnt;}
					}
					sum+=100*(i+1);
					if(j==p[i]-1){sum+=c[i];}
					cnt++;
				}
			}
		}
		return;
	}

	used[depth]=1;
	dfs(depth+1);
	used[depth]=0;
	dfs(depth+1);
}

int main(){


	scanf("%d %d",&D,&G);

	int i;

	for(i=0;i<D;i++){
		scanf("%d %d",&p[i],&c[i]);
	}

	ans=114514;

	dfs(0);

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

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
typedef long long ll;
#define for(i,x,y) for(ll i=0;i<x,i++)
ll N, M;
using namespace std;
int main()
{
	cin >> N >> M;
	
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256