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

int N, K;
vector<int> a;

bool check(int p) {
  vector<vector<bool>> dp(N + 1, vector<bool>(K + 1, false));
  dp[0][0] = true;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K + 1; j++) {
      dp[i + 1][j] = (i != p && j >= a[i]) ? dp[i][j] | dp[i][j - a[i]] : dp[i][j];
    }
  }
  bool res = false;
  for (int i = max(0, K - a[p]); i < K; i++) {
    res |= dp[N][i];
  }
  return res;
}

main() {
  cin >> N >> K;
  a.resize(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());

  int ng = -1, ok = N, mid;
  while (ok - ng > 1) {
    mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
}


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

using namespace std;

long long int dp[20004];
int H, N, A[1003], B[1003];

long long int INF = 9999999999;

int main(void) {
	cin >> H >> N;

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

	for (int j = 1; j <= H+10000; j++) { dp[j] = INF; }

	for (int i = 1; i <= N; i++) {

		for (int j = 0; j <= H; j++) {
			dp[j + A[i]] = min(dp[j + A[i]], dp[j] + B[i]);
		}
	}

	/*for (int i = 0; i <= H; i++) {
		cout << "dp[" << i << "]= " << dp[i] << endl;
	}*/
	
	long long  int ans = INF;

	for (int j=H; j <= H+10000; j++) {
		ans = min(ans, dp[j]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,a[100010],b[100010],x[100010],f[100010],p=1,w[100010],u[100010];
vector<int> y[100010];
inline int C(int n,int m)
{
	return (L)a[n]*b[m/2]%q*b[n-m]%q;
}
inline void calc(int i)
{
	int j,k=0,l,v,e;
	for(j=i;w[j]<2;j=x[j])
	  {
	   w[j]=2;
	   u[++k]=j;
	  }
	if(j!=i || k==0)
	  return;
	for(i=2;i<k+2-i;i++)
	  swap(u[i],u[k+2-i]);
	u[k+1]=u[1];
	for(j=1,l=0,v=1;j<=k;j++,l--)
	  {
	   if(y[u[j]].size()>2)
	     v=0;
	   if(y[u[j]].size()==2)
	     {
		  if(l>0)
		    v=0;
		  if(l<0)
		    v=(v<<1)%q;
		  for(l=1,e=y[u[j]][0]^y[u[j]][1]^u[j+1];y[e].size()==1;e=y[e][0],l++);
		  if(y[e].size()>1)
		    v=0;
		 }
	  }
	if(l>0)
	  v=0;
	if(l<0)
	  v=(v<<1)%q;
	p=(L)p*v%q;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  {
	   scanf("%d",&x[i]);
	   y[x[i]].push_back(i);
	  }
	b[1]=1;
	for(i=2;i<=n;i++)
	  b[i]=q-(L)q/i*b[q%i]%q;
	a[0]=b[0]=1;
	for(i=1;i<=n;i++)
	  {
	   a[i]=(L)a[i-1]*i%q;
	   b[i]=(L)b[i-1]*b[i]%q;
	  }
	for(i=1;i<=n;i++)
	  if(!w[i])
	    {
		 for(j=i,k=0,l=0;!w[j];j=x[j],k++)
		   {
		    w[j]=1;
		    if(y[j].size()>1)
		      l=1;
		   }
	     if(j==i)
	       {
			if(!l)
		      f[k]++;
		   }
		 else
		   calc(j);
		}
	for(i=1;i<=n;i++)
	  {
	   if(i&1 && i>1)
	     for(j=1,l=1;j<=f[i];j++)
	       l=(l<<1)%q;
	   else
	     l=1;
	   for(j=0,k=0;j*2<=f[i];j++,l=(L)l*i%q)
	     {
	      k=(k+(L)C(f[i],2*j)*l)%q;
	      l=(L)l*(q+1>>1)%q;
	      if(i&1 && i>1)
	        l=(L)l*(q+1>>1)%q*(q+1>>1)%q;
		 }
	   p=(L)p*k%q;
	  }
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
int main(){
    ll k,t;cin>>k>>t;
    vector<ll> a(t);rep(i,t)cin>>a[i];
    ll ans=0;
    sort(a.begin(),a.end());
    ll b =k-a[t-1];
    ans=max(a[t-1]-1.0-b,0.0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let it = s.trim().split_whitespace();
    let mut a: Vec<usize> = it.map(|s| s.parse().unwrap()).collect();
    a.swap(0, 1);
    a.swap(0, 2);
    for a in a {
        print!("{} ", a);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    string s;
    cin>>s;
    int n = s.size();
    map<int, int> mp;
    int curr = 0;
    int to = 1;
    mp[0] = 1;
    r(s);
    int ans = 0;
    f(i, n) {
        int num = mul(to, s[i] - '0', 2019);
        curr = add(curr, num, 2019);
        ans += mp[curr];
        mp[curr]++;
        to = mul(to, 10, 2019); 
    }
    cout<<ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3736
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double area = w * h;
  cout << area / 2.0 << " " << (x == w / 2.0 && y == h / 2.0) << endl;
  return 0;
}


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

long long int N, a, i;
unordered_set<long long int> s;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", &a);
        if(s.count(a))s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, a;

int main() {
	cin >> s;
	s += "@";
	string a = "AKIHABARA@";
	
	bool ans = true;
	int j = 0;
	inc(i, a.size()) {
		// cout << a[i] << " " << s[j] << endl;
		if(a[i] != s[j]) {
			if(a[i] == 'A') { continue; } else { ans = false; break; }
		}
		j++;
	}
	
	cout << (ans ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    L, R, d = LI()
    ans = 0
    for i in range(L, R+1):
        if i % d == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 72448
s = input()

ans_0 = 0

for i in range(len(s)):
	if int(s[i]) != i%2:
		ans_0 += 1

ans_1 = 0

for i in range(len(s)):
	if int(s[i]) != (i+1)%2:
		ans_1 += 1

print(min(ans_1,ans_0))

	

Measured memory_bytes: 3188
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int distance = s.nextInt();
    int timeRequired = s.nextInt();
    int speed = s.nextInt();
    s.close();
    System.out.println(
      isHeOnTime(distance, speed, timeRequired) ? "Yes" : "No"
    );
  }

  private static boolean isHeOnTime(int distance, int speed, int timeRequired) {
    int calculatedDistance = speed * timeRequired;
    return distance <= calculatedDistance;
  }
}


Measured memory_bytes: 35324
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

char c;
string s;

int main(){
	while(cin>>s){
		if(s=="0")return 0;
		int h=3,f=0;
		while(h--){
			if(f)cin>>s;
			int cur=1,a=0,b=0;
			while(cur<s.size()){
				if(s[cur++]=='A')a++;
				else b++;
			}
			if(a>b)a++;
			else b++;
			cout<<a<<" "<<b<<endl;
			f=1;
		}
	}
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] A = new int[400][400];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    if (H <= 2 || W <= 2) {
      int ans = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          ans += A[i][j];
        }
      }
      System.out.println(ans);
      return;
    }
    int[][][] dp = new int[2][H + W][H + W];
    dp[0][0][1] = A[0][0] + A[1][0] + A[0][1];
    int t = 1;
    for (int i = 1; i < H + W - 3; i++) {
      int len = i + 1;
      for (int j = 0; j < dp[0].length; j++) {
        Arrays.fill(dp[t][j], 0);
      }
      for (int j = 0; j < len; j++) {
        for (int k = j + 1; k < len; k++) {
          dp[t][j][k] = Math.max(dp[t][j][k], dp[1 - t][j][k] + A[i + 1 - j][j] + A[i + 1 - k][k]);
          dp[t][j][k + 1] = Math.max(dp[t][j][k + 1], dp[1 - t][j][k] + A[i + 1 - j][j] + A[i - k][k + 1]);
          if (k > j + 1) {
            dp[t][j + 1][k] = Math.max(dp[t][j + 1][k], dp[1 - t][j][k] + A[i - j][j + 1] + A[i + 1 - k][k]);
          }
          dp[t][j + 1][k + 1] = Math.max(dp[t][j + 1][k + 1], dp[1 - t][j][k] + A[i - j][j + 1] + A[i - k][k + 1]);
        }
      }
      t = 1 - t;
    }
    System.out.println(dp[1 - t][W - 2][W - 1] + A[H - 1][W - 1]);
  }
}


Measured memory_bytes: 32220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int a[55][55];
int n;

map<ll,ll> mp[55][55];

ll rec(int x,int y,ll k){
    if(mp[x][y][k]!=0)return mp[x][y][k];
    if(k==0)return x==y;
    if(k%2){
        ll ret=0;
        rep(i,n)if(a[x][i])ret+=rec(i,y,k-1);
        mp[x][y][k]=mod+ret%mod;
        return ret%mod;
    }
    else {
        ll ret=0;
        rep(i,n){
            ret+=rec(x,i,k/2)*rec(i,y,k/2);
            ret%=mod;
        }
        mp[x][y][k]=mod+ret%mod;
        return ret%mod;
    }
}

int main(){
    ll k;
    cin>>n>>k;
    rep(i,n)rep(j,n)cin>>a[i][j];
    ll ans=0;
    rep(i,n)rep(j,n)ans+=rec(i,j,k);
    cout<<ans%mod<<endl;    
    return 0;
}

Measured memory_bytes: 18816
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-6;

class mycmp{
public:
	bool operator() (const P p1,const P p2){
		if(p1.second == p2.second) return p1.first < p2.first;
		else return p1.second > p2.second;
	}
};

vector<int> split(string delim,string str){
	vector<int> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				int num = atoi(str.substr(i,j-1).c_str());
				if(str.substr(i,j-1).size() >0 ) res.push_back(num);
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){

	string str;
	while(getline(cin,str)){
		int n = atoi(str.c_str());
		if(n==0) break;

		vector<P> board;
		for(int t=0;t<n;t++){
			
			getline(cin,str);
			vector<int> data = split(" ",str);

			int num = data[0];
			int score = 0;
			for(int i=1,j=1;i<data.size();){
				if(j==10){
					if(data[i] == 10){
						score += data[i] + data[i+1] + data[i+2];
						i+=3;
					}

					else if(i+2< data.size() && data[i] + data[i+1] == 10){
						score += data[i] + data[i+1] + data[i+2];
						i+=3;
					}

					else if(i+1< data.size() && data[i] + data[i+1] < 10){
						score += data[i] + data[i+1];
						i+=2;
					}
				}

				else if(data[i] == 10) {
					score += 10;
					if(i+1 < data.size()) score += data[i+1];
					if(i+2 < data.size()) score += data[i+2];
					j++;
					i++;
				}
				else if(i+1< data.size() && data[i] + data[i+1] == 10){
					score += 10;
					if(i+1 < data.size()) score += data[i+2];
					j++;
					i+=2;
				}
				else if(i+1< data.size() && data[i] + data[i+1] < 10){
					score += data[i] + data[i+1];
					j++;
					i+=2;
				}

			}
			board.push_back(P(num,score));
		}

		sort(board.begin(),board.end(),mycmp());

		for(int i=0;i<board.size();i++){
			printf("%d %d\n",board[i].first,board[i].second);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>

using namespace std;

long long n, a, b, c, d, e;

int main()
{
    cin >> n >> a >> b >> c >> d >> e;
    cout << (n - 1) / min(a, min(b, min(c, min(d, e)))) + 5 << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    int sum = 0;
    rep(i, m){
        sum += a[i];
    }
    int ans = n-sum;
    if(ans>=0) cout << ans << endl;
    else cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<iostream>

using namespace std;

typedef struct{
  char suit, value;
}Card;

void output(Card *card, int N){
  for(int i = 0; i < N; i++){
    printf("%c%c", card[i].suit, card[i].value);
    if(i < N - 1){
      printf(" ");
    }
  }

  printf("\n");
}

void copy(Card *card1, Card *card2, int N){
  for(int i = 0; i < N; i++){
    card1[i] = card2[i];
  }
}

void bubble_sort(Card *card, int N){
  for(int i = 0; i < N; i++){
    for(int j = N - 1; j >= i; j--){
      if(card[j].value < card[j - 1].value){
        Card tmp = card[j];
        card[j] = card[j - 1];
        card[j - 1] = tmp;
      }
    }
  }
}

void selection_sort(Card *card, int N){
  for(int i = 0; i < N; i++){
    int minj = i;
    for(int j = i + 1; j < N; j++){
      if(card[j].value < card[minj].value){
        minj = j;
      }
    }
    if(i != minj){
      Card tmp = card[i];
      card[i] = card[minj];
      card[minj] = tmp;
    }
  }
}

int is_stabled(Card *card1, Card *card2, int N){
  int S[10][N][N] = {0};
  for(int i = 0; i < N; i++){
    if(card1[i].suit != card2[i].suit){
      printf("Not stable\n");
      return 0;
    }
  }
  printf("Stable\n");
  return 1;
}

int main(void){
  int N;
  Card card1[37], card2[37];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> card1[i].suit >> card1[i].value;
  }
  
  copy(card2, card1, N);

  bubble_sort(card1, N);
  output(card1, N);
  is_stabled(card1, card1, N);

  selection_sort(card2, N);
  output(card2, N);
  is_stabled(card1, card2, N);

  return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%mod*res%mod)%mod;
    x=(x%mod*x%mod)%mod;    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,mod-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/
// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/

void solve(){
    int n,m;
    cin>>n>>m;
    int ans=(n*(n-1))/2+(m*(m-1))/2;   
    cout<<ans;
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i = 0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    if(n == 1)
    {
        cout<<0<<"\n";
        return 0;
    }
    for(int i = 1;i<n;i++)
    {
        int j = max(0, i-k);
        for(;j<i;j++)
        {
            dp[i] = min(dp[i], abs(h[i]- h[j]) + dp[j]);
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 3972
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    vector<ll> sa(n+1);
    sa[0] = 0;
    REP(i,n){
        sa[i+1] = sa[i] + a[i];
    }
    ll res = LLONG_MAX;
    FOR(i,1,n){
        ll temp = abs(sa.back()-sa[i]*2);
        chmin(res,temp);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
int main(void){
  char str[10001];
  int i,j,a,b;

  while(scanf("%[^\n]%*c",str)!=EOF){
    a=b=0;
    for(i=0;i<strlen(str);i++){
      if(str[i+1]=='O' && str[i+2]=='I'){
	if(str[i]=='J')a++;
	else if(str[i]=='I')b++;
      }
    }
    printf("%d\n%d\n",a,b);
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#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 <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

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

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {

    REP(i, 5) {
        int tmp;
        cin >> tmp;
        if (tmp == 0) {
            cout << i + 1 << endl;
            return;
        }
    }

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> p(N);
	for (Int i = 0; i < N; i++) {
		cin >> p[i];
	}

	Int ans = 0;
	for (Int i = 1; i < N-1; i++) {
		if (p[i - 1] == p[i] && p[i] == p[i + 1])continue;
		if (p[i - 1] <= p[i] && p[i] <= p[i + 1]) {
			ans++;
			continue;
		}
		if (p[i - 1] >= p[i] && p[i] >= p[i + 1]) {
			ans++;
			continue;
		}
	}
	cout << ans << "\n";
}

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

using namespace std;

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

	vector<Int> A(N);
	vector<pair<int, int>> X(N);
	int n = 50;
	vector<vector<int>> d(n, vector<int>(n, 0));
	for (int i = 0; i < N; ++i) {
		int idx = sA[i].size();
		for (int j = 0; j < sA[i].size(); ++j) {
			if (sA[i][j] == '.') { idx = j; }
		}
		A[i] = stoi(sA[i].substr(0, idx++));
		for (int j = 0; j < 9; ++j) {
			A[i] *= 10;
			if (idx + j < sA[i].size()) {
				A[i] += sA[i][idx + j] - '0';
			}
		}

		int x2 = 0, x5 = 0;
		while (A[i] % 2 == 0) { A[i] /= 2; ++x2; }
		while (A[i] % 5 == 0) { A[i] /= 5; ++x5; }
		X[i] = { x2, x5 };
		++d[x2][x5];
	}
	for (int i = n - 1; i >= 0; --i) {
	   for (int j = n - 1; j > 0; --j) { d[i][j - 1] += d[i][j]; }
	}
	for (int j = n - 1; j >= 0; --j) {
		for (int i = n - 1; i > 0; --i) { d[i - 1][j] += d[i][j]; }
	}

	Int ans = 0;
	for (int i = 0; i < N; ++i) {
		int x2 = max(0, 18 - X[i].first);
		int x5 = max(0, 18 - X[i].second);
		ans += d[x2][x5];
		if (x2 <= 9 and x5 <= 9) { --ans; }
	}
	cout << ans / 2 << "\n";

	return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string sOP;
	int iNum1, iNum2;
	cin >> iNum1 >> sOP >> iNum2;
	if (sOP == "+")
		cout << iNum1 + iNum2 << endl;
	else if (sOP == "-")
		cout << iNum1 - iNum2 << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

string S, T;
vector<int> start(26, -1);
vector<int> goal(26, -1);

int main()
{
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++) {
    int a = S[i] - 'a';
    int b = T[i] - 'a';
    if (start[a] != -1 || goal[b] != -1) {
      if (start[a] != b || goal[b] != a) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      start[a] = b;
      goal[b]  = a;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();
	    String[] metaStr = inputs[0].split(" ");

	    int n = Integer.parseInt(metaStr[0]);
	    int k = Integer.parseInt(metaStr[1]);

	    int tmp = n - k;
	    int cnt = 1;

	    float mod = tmp % (k - 1);
	    cnt += tmp / (k - 1);

	    if (mod > 0) cnt++;

	    Io.write(cnt);
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    }

    /**
     * 標準出力
     * @param answer
     */
    public static void write(int answer)
    {
        System.out.println(answer);
    }
}

Measured memory_bytes: 27568
from collections import deque


N, M = map(int, input().split())
A = deque(sorted(list(map(int, input().split()))))
B = deque()

coupon = M
while coupon:
    try:
        if B:
            if A[-1] >= B[-1]:
                B.appendleft(A.pop() // 2)
            else:
                B.appendleft(B.pop() // 2)
        else:
            B.append(A.pop() // 2)
        coupon -= 1
    except IndexError:
        A, B = B, A


ans = sum(int(i) for i in A) + sum(int(i) for i in B)
print(ans)


Measured memory_bytes: 93244
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"math.h"



int main()
{
    int i,j,k,n;
    scanf("%d",&n);
    while(n>9)
    {
        n=n%10;
    }
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        printf("hon");
    else if(n==0 || n==1 || n==6 || n==8)
        printf("pon");
    else if(n==3)
        printf("bon");
    return 0;
}


Measured memory_bytes: 1736
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, A;
    scan(N, A);
    auto X = aryread();
    long S = X.sum();
    auto dp = new long[][][](N + 1, N + 1, S + 1);
    dp[0][0][0] = 1;
    foreach (i; 0 .. N)
        foreach (j; 0 .. N)
            foreach (k; 0 .. S + 2)
            {
                if (0 <= k - X[i])
                    dp[i + 1][j + 1][k] += dp[i][j][k - X[i]];
                dp[i + 1][j][k] += dp[i][j][k];
            }
    // foreach (row; dp[0])
    //     writeln(row);
    // writeln();
    // foreach (row; dp[N])
    //     writeln(row);
    long ans;
    foreach (i; 1 .. N + 1)
    {
        ans += dp[N][i][A * i];
    }
    writeln(ans);
}


Measured memory_bytes: 52476
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    int n; cin >> n;
    
    set<string> s;
    while(n--){
        string u; cin >> u;
        s.insert(u);
    }

    int m; cin >> m;
    bool isO = false;
    while(m--){
        string t; cin >> t;
        if(s.find(t) != s.end()){
            if(isO){
                cout << "Closed by " << t << endl;
                isO = false;
            }
            else{
                cout << "Opened by " << t << endl;
                isO = true;
            }
        }
        else{
            cout << "Unknown " << t << endl;
        }
    }

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 2e15+7;
const ll mod = 1e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

UnionFind uf;

int main() {
	int n = in(),m = in();
	uf.init(m);
	vector<int> KK[n];
	int L[m];REP(i,m) L[i]=0;
	REP(i,n) {
		int K = in();
		REP(j,K) {
			int IN = in() - 1;
			L[IN]++;
			KK[i].pb(IN);
			if (j) uf.unite(KK[i][j-1],KK[i][j]);
		}
	}
	bool ok = true;
	int par = uf.find(KK[0][0]);
	REP (i,n) {
		REP (j,KK[i].size()) {
			if (uf.find(KK[i][j]) != par) ok = false;
		}
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 8576
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
// ll int n;
// string s;
// cin>>n;
// cin>>s;
// char w='z';
// cout<<int(w)<<endl;
// for (int i = 0; i < s.length(); ++i)
// {
// 	 code 
// 	if(int(s[i])>90){
// 		cout<<char(int(s[i]+n)-25 );
// 	}
// 	else{
// 	cout<<char(int(s[i]+n));

// 	}
// }
// cout<<endl;
ll int n;
string s;
cin>>n;
cin>>s;
for (int i = 0; i <s.length(); ++i)
{
	int x=int(s[i])-'A';
	//cout<<x<<endl;
	int y=(x+n)%26;
	putchar('A'+y);
	/* code */
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl



signed main(){
    string S;
    cin >> S;
    string T;
    int N=S.size();
    for(int i=0;i<N;i++){
        for(int j=0;i+j<N;j++){
            T=S;
            T.erase(i,j);
            if(T=="keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=998244353;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL dp[3333][3333];

int main(){
	int n,m;
	LL i,j,k;
	LL a,b,c;
	int x,y;
	cin>>x>>y>>n>>m;
	dp[x][y]=1;
	for(i=x;i<=n;i++){
		for(j=y;j<=m;j++){
			if(dp[i][j])continue;
			dp[i][j]=dp[i][j-1]*i+dp[i-1][j]*j-dp[i-1][j-1]*(i-1)*(j-1);
			if(dp[i][j]<0)dp[i][j]+=((-dp[i][j])/MAX+1)*MAX;
			dp[i][j]%=MAX;
		}
	}
	cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 81620
#include <vector>
#include <iostream>
using namespace std;
struct edge{
    int to;
    int cap;
    long long cost;
    int inv;
};
struct primal{
    long long INF;
    int V;
    vector<int> prevv, preve;
    vector<vector<edge>> G;
    primal(int N){
        V = N;
        prevv.resize(V);
        preve.resize(V);
        G.resize(V);
        INF = 1e18;
    }
    void add(int s, int t, int cap, long long cost){
        edge e1 = {t, cap, cost, (int)G[t].size()};
        G[s].push_back(e1);
        edge e2 = {s, 0, -cost, (int)G[s].size() - 1};
        G[t].push_back(e2);
    }
    long long solve(int s, int t, int f){
        long long res = 0;
        while(f > 0){
            vector<long long> d(V, INF);
            bool update = true;
            d[s] = 0;
            while(update){
                update = false;
                for(int i = 0; i < V; i++){
                    if(d[i] == INF) continue;
                    for(int j = 0; j < (int)G[i].size(); j++){
                        edge e = G[i][j];
                        if(e.cap > 0 && d[e.to] > d[i] + e.cost){
                            d[e.to] = d[i] + e.cost;
                            prevv[e.to] = i;
                            preve[e.to] = j;
                            update = true;
                        }
                    }
                }
            }
            if(d[t] == INF) return 1;
            int dmin = f;
            for(int v = t; v != s; v = prevv[v]){
                dmin = min(dmin, G[prevv[v]][preve[v]].cap);
            }
            f -= dmin;
            res += d[t] * dmin;
            for(int v = t; v != s; v = prevv[v]){
                edge &e = G[prevv[v]][preve[v]];
                e.cap -= dmin;
                G[v][e.inv].cap += dmin;
            }
        }
        return res;
    }
};

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<long long>> A(N, vector<long long>(N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cin >> A[i][j];
    }
    primal pd(N * N + 2*N + 2);
    const int start = N * N + 2 * N, goal = N * N + 2 * N + 1;
    for(int i = 0; i < N; i++){
        pd.add(start, N * N + i, K, 0);
        pd.add(N * N + N + i, goal, K, 0);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            pd.add(N * N + i, i * N + j, 1, 0);
            pd.add(i * N + j, N * N + N + j, 1, -A[i][j]);
        }
    }
    long long ans = 0;
    vector<vector<edge>> g;
    while(1){
        long long temp = pd.solve(start, goal, 1);
        if(temp > 0) break;
        ans += -temp;
        g = pd.G;
    }
    cout << ans << endl;
    vector<vector<char>> judge(N, vector<char>(N, '.'));
    for(int i = 0; i < N; i++){
        for(edge e: g[N * N + i]){
            if(e.to == start || e.cap > 0) continue;
            if(e.cap == 0){
                int x = e.to / N, y = e.to % N;
                judge[x][y] = 'X';
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cout << judge[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 4428
import sys

while True:
	data = map(int, raw_input().split())
	H = data[0]
	W = data[1]
	
	if H == 0 and W == 0:
		break
	else:
		for i in range(H):
			for j in range(W):
				sys.stdout.write("#")
			print("")
		print("")

Measured memory_bytes: 6420
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define inf 0x3f3f3f3f3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define int long long
#define all(x) x.begin(), x.end()
#ifdef ONLINE_JUDGE
const int maxn = 3e5 + 10;
#else
const int maxn = 1e3 + 10;
#endif
//__builtin_popcount
int L;
double ans;
signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    // freopen("C:\Users\hjw\Downloads\testdata (4).in", "r", stdin);
    cin >> L;
    double a = L / 3.0;
    cout << fixed << setprecision(8) << a * a * a << endl;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 504
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll       long long
#define ull       unsigned long long
#define  si(x)   scanf("%d", &x)
#define  sll(x)   scanf("%lld", &x)
#define  sd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100000
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007

int ans=0;
void dfs(ll n,ll m){
  if(n>m) return;
  vector<int> c(10);
  ll x=n;
  while(x>0){
    c[x%10]++;
    x/=10;
  }
  if(c[3]>0 && c[5]>0 && c[7]>0) ans++;
  dfs(n*10+3,m);
  dfs(n*10+5,m);
  dfs(n*10+7,m);
  return;
}

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
	    ll m,n=0;
	    sll(m);
	    dfs(n,m);
	    cout << ans << endl;
		return 0;
}


Measured memory_bytes: 3732