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

int n, q;
char s[200010];
struct th
{
    char c;
    int x;
} a[200010];

int chk(int x)
{
    for (int i = 1; i <= q; i++)
        if (s[x] == a[i].c)
            x += a[i].x;
    return x;
}
int main()
{
    scanf("%d%d%s", &n, &q, s + 1);
    for (int i = 1; i <= q; i++)
    {
        char s1[3], s2[3];
        scanf("%s%s", s1, s2);
        a[i].c = s1[0];
        a[i].x = s2[0] == 'L' ? -1 : 1;
    }
    int l = 1, len = n;
    while (len)
    {
        int md = l + (len >> 1);
        if (chk(md) == 0)
        {
            l = md + 1;
            len = len - (len >> 1) - 1;
        }
        else len >>= 1;
    }
    int ll = l;
    l = 1, len = n;
    while (len)
    {
        int md = l + (len >> 1);
        if (chk(md) != n + 1)
        {
            l = md + 1;
            len = len - (len >> 1) - 1;
        }
        else len >>= 1;
    }
    printf("%d\n", l - ll);
}

Measured memory_bytes: 2048
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
for i in range(1,N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[-1])


Measured memory_bytes: 13980
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<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<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
using namespace std;
int n,la[100005],lb[100005],na[100005],nb[100005];
ll a[100005],A,B,fa[100005],fb[100005],sa[100005],sb[100005];
ll t(ll x){return (x%orz+orz)%orz;}
int main(){
    scanf("%d%lld%lld",&n,&A,&B);
    for(int i=1;i<=n;++i)scanf("%lld",a+i+1);
    a[n+2]=a[n+1]+max(A,B)+1;
    n+=2;
    la[1]=na[1]=lb[1]=nb[1]=1;
    int k=2;
    for(int i=2;i<=n;++i){
        while(a[i]-a[k]>=A)++k;
        la[i]=k;
        if(k==i)na[i]=na[i-1];
        else na[i]=i;
    }
    k=2;
    for(int i=2;i<=n;++i){
        while(a[i]-a[k]>=B)++k;
        lb[i]=k;
        if(k==i)nb[i]=nb[i-1];
        else nb[i]=i;
    }
    sa[1]=sb[1]=fa[1]=fa[2]=fb[1]=fb[2]=1;
    sa[2]=sb[2]=2;
    for(int i=3;i<=n;++i){
        if(la[i]<i-1&&lb[i-1]<i-1)fa[i]=0;
        else if(lb[i-1]<i-1)fa[i]=fb[i-1];
        else if(la[i]>=i-1)fa[i]=t(sa[i-2]-sa[na[i-2]-1]+sb[i-2]-sb[nb[i-2]-1]);
        else fa[i]=t(sb[la[i]]-sb[min(la[i],nb[i-2]-1)]);
        sa[i]=(sa[i-1]+fa[i])%orz;
        if(lb[i]<i-1&&la[i-1]<i-1)fb[i]=0;
        else if(la[i-1]<i-1)fb[i]=fa[i-1];
        else if(lb[i]>=i-1)fb[i]=t(sb[i-2]-sb[nb[i-2]-1]+sa[i-2]-sa[na[i-2]-1]);
        else fb[i]=t(sa[lb[i]]-sa[min(lb[i],na[i-2]-1)]);
        sb[i]=(sb[i-1]+fb[i])%orz;
    }
    ll o=t(fa[n]+fb[n]);
    if(o&1)o+=orz;
    printf("%lld\n",o/2);
    //system("pause");
    return 0;
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *left;
	struct node *right;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
	while (x->left!=NIL){
		x = x->left;
	}
	return x;
}

Node treeSearch(Node u, int k){
	if (u == NIL){return NIL;}
	if (u->key == k){ return u; }
	else if (u->key > k){
		return treeSearch(u->left, k);
	}
	else{
		return treeSearch(u->right, k);
	}
}

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y

	if (z->left == NIL && z->right == NIL){//子なし
		if (z->parent->left == z){
			z->parent->left = NIL;
		}
		else{
			z->parent->right = NIL;
		}
		free(z);
	}
	else if (z->left != NIL && z->right != NIL){//子2人
		x = z->right;
		while (x->left != NIL){
			x = x->left;
		}
		z->key = x->key;
		treeDelete(x);
		
	}
	else{//子1人
		if (z->left!=NIL){//左に子がいたら
			if (z->parent->left == z){//zが親の左側にいたら
				z->parent->left = z->left;
				z->left->parent = z->parent;
			}
			else{//zが親の右側にいたら
				z->parent->right = z->left;
				z->left->parent = z->parent;
			}
		}
		else{//右に子がいたら
			if (z->parent->left == z){//zが親の左側にいたら
				z->parent->left = z->right;
				z->right->parent = z->parent;
				free(z);
			}
			else{//zが親の右側にいたら
				z->parent->right = z->right;
				z->right->parent = z->parent;
			}
		}
	}
}

Node sss(int k, Node x){
	if (x == NIL){ return x; }
	if (k < x->key){
		if (x->left != NIL){
			return sss(k, x->left);
		}
		else{
			return x;
		}
	}
	else{
		if (x->right != NIL){
			return sss(k, x->right);
		}
		else{
			return x;
		}
	}
}

void insert(int k){
	Node y = sss(k,root);
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	z->parent = y;

	if (y == NIL){ root=z; }
	else if (y->key < k){
		y->right = z;
	}
	else{
		y->left = z;
	}
}

void inorder(Node u){
	if (u->left != NIL)
		inorder(u->left);
	printf(" %d", u->key);
	if (u->right != NIL)
		inorder(u->right);	
}
void preorder(Node u){
	printf(" %d", u->key);
	if (u->left != NIL)
		preorder(u->left);
	if (u->right != NIL)
		preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}


Measured memory_bytes: 20472
import java.util.*;
import java.util.stream.*;

public class Main {
	Scanner sc;
	int N, NN;
	Integer[] S;
	TreeSet<Slime> slimes;
	Slime[] indices;
	Comparator<Slime> order;
	
	static class Slime {
		int id, val;
		Slime(int id) {
			this.id = id;
		}
	}
	
	public Main() {
		sc = new Scanner(System.in);
		order = Comparator.comparingInt( (Slime s) -> (0x7fffffff & (-lsb(s.id))) ).
				thenComparingInt( s -> countOnes(s.id) ).
				thenComparingInt( s -> s.id );
	}
	
	private void calc() {
		N = sc.nextInt();
		NN = 1<<N;
		S = new Integer[NN];
		for (int i = 0; i < NN; i++) S[i] = sc.nextInt();
		Arrays.sort(S, Comparator.reverseOrder());
		slimes = new TreeSet<Slime>(order);
		indices = new Slime[NN];
		for (int i = 0; i < NN; i++) indices[i] = new Slime(i);
		slimes.add(indices[0]);
		indices[0].id = NN;
		Iterator<Slime> it = null;
		int lasts = Integer.MAX_VALUE;
		List<Slime> next = new ArrayList<>();
	lp:
		for (int j = 0; j < NN; j++) {
			if (lasts != S[j]) {
				slimes.addAll(next);
				next.clear();
				it = slimes.iterator();
			}
			while (it.hasNext()) {
				Slime s = it.next();
				if (j == 0 || indices[s.id ^ lsb(s.id)].val > S[j]) {
					s.val = S[j];
					it.remove();
					lasts = S[j];
					for (int l = (lsb(s.id) >>> 1); l > 0; l = l >>> 1)
						next.add(indices[(s.id | l)&(NN-1)]);
					continue lp;
				}
			}
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
	
	static int countOnes(int t) {
		t = (t & 0x55555555) + (t >> 1 & 0x55555555);
		t = (t & 0x33333333) + (t >> 2 & 0x33333333);
		t = (t & 0x0f0f0f0f) + (t >> 4 & 0x0f0f0f0f);
		t = (t & 0x00ff00ff) + (t >> 8 & 0x00ff00ff);
		return (t & 0x0000ffff) + (t >>16 & 0x0000ffff);
	}
	
	static int lsb(int t) {
		return t&(-t);
	}
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 109264
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int a;
  cin >> a;
  if(a<1000)cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}


Measured memory_bytes: 256
count = input()
Ss = []
Hs = []
Cs = []
Ds = []
for i in range(int(count)):
    mark, num = input().split()
    if mark is 'S':
        Ss.append(num)
    elif mark is 'H':
        Hs.append(num)
    elif mark is 'C':
        Cs.append(num)
    elif mark is 'D':
        Ds.append(num)

for i in range(1,14):
    if not(str(i) in Ss):
        print("S {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Hs):
        print("H {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Cs):
        print("C {0}".format(str(i)))
for i in range(1,14):
    if not(str(i) in Ds):
        print("D {0}".format(str(i)))

Measured memory_bytes: 7708
using System;
using System.Collections.Generic;

class MainClass
{
    public static void Main(string[] args)
    {
        var _ = LnInts();
        var A = _[0]; var B = _[1]; var C = _[2]; var D = _[3]; var E = _[4]; var F = _[5];
        var X = new HashSet<int>();
        var Y = new HashSet<int>();
        var maxCon = 0f;
        var mX = 0; var mY = 0;
        for (int i = 0; i < 10000; i++)
        {
            var a = A * i * 100;
            for (int j = 0; j < 10000; j++)
            {
                var v = a + B * j * 100;
                if (v != 0)
                    X.Add(v);
                if (B * j * 100 + A * i > F) break;
            }
            if (A * i * 100 > F) break;
        }
        for (int i = 0; i < 10000; i++)
        {
            var a = C * i;
            for (int j = 0; j < 10000; j++)
            {
                Y.Add(a + D * j);
                if (D * j + C * i > F) break;
            }
            if (C * i > F) break;
        }
        var Xs = new int[X.Count]; X.CopyTo(Xs);
        var Ys = new int[Y.Count]; Y.CopyTo(Ys);
        for (var i = 0; i < Xs.Length; i++)
        {
            for (var j = 0; j < Ys.Length; j++)
            {
                if (Xs[i] + Ys[j] > F || Ys[j] * 100 > Xs[i] * E) continue;
                var con = (float)Ys[j] / (float)(Xs[i] + Ys[j]);
                if (con >= maxCon) { maxCon = con; mX = Xs[i]; mY = Ys[j]; }
            }
        }

        Console.WriteLine((mX + mY) + " " + mY);
    }


    public static int[] LnInts()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        var ins = new int[vs.Length];
        for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);
        return ins;
    }

    public static int LnInt()
    {
        var vs = Console.ReadLine().Trim();
        return int.Parse(vs);
    }

    public static string[] LnStrs()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        return vs;
    }
    public static string LnStr()
    {
        var vs = Console.ReadLine().Trim();
        return vs;
    }
}

Measured memory_bytes: 13404
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e2+10;
double pi=acos(-1.0);
double tmp[maxn];
int x[maxn],y[maxn];
int num;
int main(){
	int n=read();
	REP(i,1,n) x[i]=read(),y[i]=read();
	REP(i,1,n){
		num=0;
		REP(j,1,n) if(i!=j) tmp[++num]=atan2(y[j]-y[i],x[j]-x[i]);
		sort(tmp+1,tmp+num+1);
		tmp[n]=tmp[1]+2*pi;
		double Mx=0;
		REP(j,1,n-1) Mx=max(Mx,tmp[j+1]-tmp[j]);
		Mx=max(Mx-pi,0.0);
		printf("%.10lf\n",Mx/(2*pi));
	}
	return 0;
}


Measured memory_bytes: 768
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    string s;
    cin>>s;
    ll sum=0;
    for(auto &I:s){
        if(I=='('){sum++;}
        else if(I==')'){sum--;}
        else{cout<<sum<<endl; return 0;}
    }
    

    return 0;
}



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

int main() {
    int n;
    cin>>n;
    int c[n-1],s[n-1],f[n-1];
    for (int i=0;i<n-1;i++)
        cin>>c[i]>>s[i]>>f[i];
    for (int i=0;i<n-1;i++) {
        int t=s[i]+c[i];
        for (int j=i+1;j<n-1;j++) {
            if (t<s[j])
                t=s[j];
            else if (t%f[j])
                t+=f[j]-t%f[j];
            t+=c[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

flag = True

for i in range(1,len(H)):
    if H[i-1] > H[i]:
        H[i] += 1

    if H[i-1] > H[i]:
        flag = False
        break
        
        
if flag == True:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, 1, 0, -1, -1, -1, 1, 1},
          dy[] = {1, 0, -1, 0, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

void Solve() {
  int n;
  cin >> n;
  int res = 0;
  vector<vector<pair<int, int>>> r(n);
  int m;
  int x, v;
  for (int i = 0; i < n; i++) {
    cin >> m;
    vector<pair<int, int>> tmp;
    for (int j = 0; j < m; j++) {
      cin >> x >> v;
      x--;
      tmp.emplace_back(x, v);
    }
    r[i] = tmp;
  }
  vector<int> a(n);
  for (int t = 0; t < (1 << n); t++) {
    int v = t;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      a[i] = v % 2;
      sum += v % 2;
      v /= 2;
    }
    bool valid = true;
    for (int i = 0; i < n; i++) {
      if (!valid) break;
      for (int j = 0; j < r[i].size(); j++) {
        if (a[i] == 1 && r[i][j].second != a[r[i][j].first]) {
          valid = false;
          break;
        }
      }
    }
    if (valid) {
      res = max(res, sum);
    }
  }
  cout << res << '\n';
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Prepare();
  // int t, T;
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  Solve();
  // }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    vi cnt(n), ok(n);
    for (int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "WA" && !ok[p])
            cnt[p]++;
        else
            ok[p] = 1;
    }
    for (int i = 0; i < n; i++)
        if (!ok[i])
            cnt[i] = 0;
    cout << accumulate(all(ok), 0) << ' ' << accumulate(all(cnt), 0) << endl;
    GAME_OVER;
}

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

int main(){
  string s;
  cin >> s;
  int a = s.size();
  vector<string>dna(a);
  int count = 0;
  for(int i = 0; i < a; i++){
    if (s.at(i) == 'A'||s.at(i) =='C'||s.at(i) =='G'||s.at(i) =='T'){
      dna.at(count) = dna.at(count) + s.at(i);
    }
    else
      count++;
  }
  vector<int>number(a);
  for(int i = 0; i < a; i++){
    number.at(i) = dna.at(i).size();
  }
  sort(number.begin(),number.end());
  cout << number.at(a-1) << endl;
}

    
    
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

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

int main(){
    double a, b, x; cin >> a >> b >> x;
    double s = x/a;
    double rad = 0;
    if(s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h,a);
    }else{
        double w = s*2/b;
        rad = atan2(b,w);
    }
    double pi = acos(-1);
    double deg = rad/(2*pi)*360;
    printf("%.10f\n", deg);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N;
    int i, j;
    int B;
    int ans = 0;
    int dp[10][10];

    cin >> N;

    memset(dp, 0, sizeof(dp));

    rep(i, 1, N)
    {
        int tmp = i;
        while (tmp >= 10)
        {
            tmp /= 10;
        }

        dp[tmp % 10][i % 10]++;
    }

    rep(i, 0, 9)
    {
        rep(j, 0, 9)
        {
            ans += dp[j][i] * dp[i][j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def derangement(N: int, P: list)->int:
    count = 0
    for i in range(N-1):
        if P[i] == i+1:
            count += 1
            P[i], P[i+1] = P[i+1], P[i]

    if P[-1] == N:
        count += 1
    return count


if __name__ == "__main__":
    N = int(input())
    P = [int(s) for s in input().split()]
    ans = derangement(N, P)
    print(ans)


Measured memory_bytes: 13880
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
template<typename T, typename E>
struct SegmentTree_ {
  function<T(T, T)> f;
  function<T(T, E)> g;
  int n;
  T def;
  vector<T> vec;
  SegmentTree_(){}
  SegmentTree_(int n_, function<T(T, T)> f_, function<T(T, E)> g_, T def_, vector<T> v=vector<T>()){
    f = f_;
    g = g_;
    def = def_;

    // initialize vector
    n = 1;
    while(n < n_){
      n *= 2;
    }
    vec = vector<T>(2*n -1, def);

    // initialize segment tree
    for(int i = 0; i < v.size(); i++){
      vec[i + n - 1] = v[i];
    }
    for(int i = n - 2; i >= 0; i--){
      vec[i] = f(vec[2*i+1], vec[2*i+2]);
    }
  }
  void update(int k, E val){
    k = k + n - 1;
    vec[k] = g(vec[k], val);
    while(k > 0){
      k = (k - 1) / 2;
      vec[k] = f(vec[2*k+1], vec[2*k+2]);
    }
  }
  // [l, r) -> [a, b) (at k)
  T query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l)return def;
    if(a <= l && r <= b)return vec[k];
    T ld = query(a, b, 2*k+1, l, (l+r)/2);
    T rd = query(a, b, 2*k+2, (l+r)/2, r);
    return f(ld, rd);
  }
  T query(int a, int b){
    return query(a, b, 0, 0, n);
  }
};

template<typename T, typename E>
using SegmentTree = struct SegmentTree_<T, E>;
using SegmentTreeI = SegmentTree<int, int>;

ll dp[200001];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<int> h(n);
  vector<ll> a(n);
  rep(i, n)cin >> h[i];
  rep(i, n)h[i]--;
  rep(i, n)cin >> a[i];
  SegmentTree<ll, ll> seg = SegmentTree<ll, ll>(n, [](ll a, ll b){return max(a, b);},
        [](ll a,ll b){return b;}, 0, vector<ll>(n, 0));
  rep(i, n){
    dp[i+1] = a[i] + seg.query(0, h[i]);
    seg.update(h[i], dp[i+1]);
  }
  ll res = 0;
  rep(i, n){
    res = max(res, dp[i+1]);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 8320
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
const int N =  1e5 + 11;
bool isprime[N];

void gen_primes(){
  fill(isprime + 2, isprime + N, true);
  for(int i = 2; i < N; i++){
	 if (isprime[i]){
		for(int j = 2; i *j < N; j++){
		  isprime[i * j] = false;	
	   } 
	 }  
   }	
}

void solve(){
  gen_primes();
  int n;
  while(cin >> n, n){
	  int ret = 0;
	  bool visited[n] = {false};
	  for(int i = 1; i  <= n; i++){
		 if(!visited[i] || !visited[n - i]){
		 if (isprime[i] && isprime[n - i]) ret++;
	       visited[i] = true, visited[n - i] = true;
	      }  
		}
	 cout << ret << endl;  
	}	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3276
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int K=sc.nextInt();
    Queue queue=new PriorityQueue();
    Long Ans=0L;
    
    for(int i=0;i<N;i++){
      queue.add(sc.nextInt());
    }
    
    for(int i=0;i<N-K;i++){
   	  Ans+=(int)(queue.poll());
    }
    
    System.out.print(Ans);
  }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2) {
        cout << "Borys" << "\n";
    } else {
        cout << "Alice" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int D 	  = Integer.parseInt(scanner.nextLine());
		int ans   = 0;
		int point = 0;

		String[] clist = scanner.nextLine().split(" ");
		int[] clis = new int[26];
		int[] list = new int[26 * D];

		for(int i = 0; i < 26 ; i++)clis[i] = Integer.parseInt(clist[i]);

		for(int i = 0; i < D; i++) {

			String[] slist = scanner.nextLine().split(" ");
			int count = i * 26;

			for(int j = 0; j < 26; j++) {

				list[count] = Integer.parseInt(slist[j]);
				count++;

			}
		}//1373

		int[] day = new int[26];
		for(int i = 0; i < 26; i++) day[i] = 0;


		for(int i = 0; i < D;i++) {

			int kai = i * 26;
			int max = list[kai];
			int t   = 0;


			for(int j = 0; j < 26; j++) {

				max = Math.max(max, list[kai + j]);

				if(max == list[kai + j]) {
					t = j + 1;
				}
			}
			/**
			point = i * 26 + t;

			ans += list[point];
			day[t] = i + 1;
			for(int j = 0; j < 26; j++) {

				ans -= clis[j] * (i + 1 - day[j]);

			}
			**/
			System.out.println(t);
		}
	}
}

Measured memory_bytes: 39532
INF = 100000
dp = [INF]*100002
count = 0

index = [[0, 0]]
while index:
    x, count  = index[0]
    count += 1
    index.pop(0)
    dp[x+1] = count
    i = 1
    while x + 6**i < INF:
        if dp[x+6**i] > count:
            dp[x+6**i] = count
            index.append([x+6**i, count])
        i += 1
    i = 1
    while x + 9**i < INF:
        if dp[x+9**i] > count:
            dp[x+9**i] = count
            index.append([x+9**i, count])
        i += 1

n = int(input())
for i in range(n, 0, -1):
    if dp[i] < INF:
        print(dp[i]+n-i)
        break


Measured memory_bytes: 4840
#include<iostream>
#include<cmath>
#include<vector>
long long gcd(long long a,long long b){
    while(a && b){
        if(a > b)a%=b;
        else b%=a;
    }
    return a+b;
}

int main(){
    long long a,b;
    long long ans=0; 
    std::cin>>a>>b;

    const long long C = gcd(a,b);
    long long c = C;

    for(int i=2;i<std::sqrt(C);i++){
        if(c%i==0){
            ans++;
            while(c%i==0)c/=i;
        }
    }
    if(c!=1)ans++;
    std::cout<<ans+1<<std::endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int a[105];
int main()
{
	int ans=0,jl=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==a[i-1])
			jl++;
		else
		{
			ans+=jl/2;
			jl=1;
		}
	}
	ans+=jl/2;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans, adj
for adj in graph:
    ans.push_back(adj.size())

print(*ans, sep='\n')

'''

    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 10088
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;

int main(){
	while(true){
		int n, w, d;
		cin >> n >> w >> d;
		if(n == 0 && w == 0 && d == 0){ break; }
		vector<pii> rects;
		rects.push_back(pii(w, d));
		for(int i = 0; i < n; ++i){
			int p, s;
			cin >> p >> s;
			const int lw = rects[p - 1].first;
			const int lh = rects[p - 1].second;
			s %= (lw + lh);
			if(s < lw){
				const int t = lw - s;
				rects.push_back(pii(min(s, t), lh));
				rects.push_back(pii(max(s, t), lh));
			}else{
				s -= lw;
				const int t = lh - s;
				rects.push_back(pii(lw, min(s, t)));
				rects.push_back(pii(lw, max(s, t)));
			}
			rects.erase(rects.begin() + p - 1);
		}
		vector<int> pieces(rects.size());
		for(int i = 0; i < rects.size(); ++i){
			pieces[i] = rects[i].first * rects[i].second;
		}
		sort(pieces.begin(), pieces.end());
		for(int i = 0; i < pieces.size(); ++i){
			if(i != 0){ cout << " "; }
			cout << pieces[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define ll long long int

using namespace std;



int main()
{
    ll n,t;
    string s3,s4;
    cin>>s3;
    cin>>s4;
    if(s4.size()==s3.size()+1){
        s4.erase(s4.size()-1,1);
        if(s4==s3)cout<<"Yes\n";
        else cout<<"No\n";
    }
    else cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3596
import itertools

N = int(input())
L = list(map(int, input().split()))
count = 0

def has_duplicates(seq):
    return len(seq) != len(set(seq))


for pair in itertools.combinations(L, 3):
    # print(list(pair))
    if has_duplicates(pair) == False:

        if (pair[0] + pair[1] > pair[2]) and (pair[1] + pair[2]) > pair[0] \
                and (pair[2] + pair[0] > pair[1]):
            count += 1





print(count)


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

int main()
{
    string S;
    cin >> S;
    if (S == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[110][15],b[110][15],li[110],ma=-INF;
 
int main(){
	cin >> n;
	REP(i,0,n) REP(j,0,10) cin >> a[i][j];
	REP(i,0,n) REP(j,0,11) cin >> b[i][j];
	REP(i,1,(1<<10)){
		int s=0;
		REP(j,0,n){
			int c=0;
			REP(k,0,10) if((i>>k)&1 and a[j][k]) c++;
			s+=b[j][c];
		}
		
		ma=max(ma,s);
	}
	
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
        int H,W;
        while(1) {
                cin>>H>>W;
                if (H==0 and W==0) {
                        return 0;
                }
                for(int j=0; j<W; j++) {
                        printf("#");
                }
                printf("\n");
                for(int i=0; i<H-2; i++) {
                        printf("#");
                        for(int j=0; j<W-2; j++) {
                                printf(".");
                        }
                        printf("#\n");
                }
                for(int j=0; j<W; j++) {
                        printf("#");
                }
                printf("\n\n");
        }
}



Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long n;
int main() {
	vector<pair<long long, int> > vr;
	for (int i = 0; i < 1000000; i++) {
		string s = to_string(i);
		int sum = 0;
		for (int j = 0; j < s.size(); j++) sum = sum * -10 + (s[j] - 48);
		vr.push_back(make_pair(sum, i));
	}
	sort(vr.begin(), vr.end());
	vector<long long> vr2;
	for (pair<long long, int> i : vr) vr2.push_back(i.first);
	while (cin >> n, n) {
		for (int i = 0; ; i++) {
			long long sum = 0;
			string s = to_string(i);
			for (int j = 0; j < s.size(); j++) sum = sum * -10 + (s[j] - 48);
			sum *= 1000000;
			int ptr = lower_bound(vr2.begin(), vr2.end(), n - sum) - vr2.begin();
			if (ptr < vr2.size() && vr2[ptr] == n - sum) {
				cout << i * 1000000 + vr[ptr].second << endl;
				break;
			}
		}
	}
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

struct job {
    int a, b;

    bool operator<(const job& other) const {
        if(a != other.a) return a < other.a;
        return b > other.b;
    }
};

int32_t main() {

    int n, m; cin >> n >> m;
    vector<job> jobs(n);
    for(int i = 0; i < n; ++i) {
        cin >> jobs[i].a >> jobs[i].b;
    }

    sort(jobs.begin(), jobs.end());

    int ans = 0;

    priority_queue<int> rewards;

    int index = 0;
    
    for(int room = 1; room <= m; ++room) {
        while(index < n && jobs[index].a <= room) {
            rewards.push(jobs[index].b);
            index++;
        }
        if(!rewards.empty()) {
            ans += rewards.top();
            rewards.pop();
        }
    }

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


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n, x, y;
    cin >> n >> x >> y;
    vector<pair<pair<ll, ll>, ll>>z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i].first.first >> z[i].first.second >> z[i].second;
    }
    vector<vector<ll>>dp(430,vector<ll>(430,123456789));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        ll a = z[i].first.first;
        ll b = z[i].first.second;
        for (int j = 400; j > -1; j--) {
            for (int k = 400; k > -1; k--) {
                dp[j + a][k + b] = min(dp[j + a][k + b], dp[j][k] + z[i].second);
            }
        }
    }
    ll ans = 1234567;
    for (int i = 1; i < 12345678; i++) {
        if (i * x > 400 || i * y > 400)break;
        ans = min(ans, dp[i * x][i * y]);
    }
    if (ans == 1234567)cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 5096
def ss(n):
   r = 0
   while n:
       r, n = r + n % 10, n // 10
   return r
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
  sr = ss(i)
  if sr <= b and sr >=a: ans += i
print(ans)

Measured memory_bytes: 3060
#include <cstdio>

int main() {
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    int num;
    int ac = 0, wa = 0;
    char ans[10];

    int WA[100007];
    bool AC[100007];
    for(int i = 1; i <= n; i++) {
        AC[i] = 0;
        WA[i] = 0;
    }
    for(int i = 0 ; i < m ; i++){
        scanf("%d", &num);
        scanf("%s", ans);
        if (AC[num]) {
            continue;
        }
        if (ans[0] == 'A') {
            AC[num] = true;
        } else { // if (ans[0] == 'W'){
            WA[num] += 1;
        }
    }
    for(int i = 1; i <= n; i++) {
        if(AC[i]) {
            ac++;
            wa += WA[i];
        }
    }
    printf("%d %d\n", ac, wa);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int  mod = 1e9 +7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);



  
    int n , k ;
    cin >> n >> k;
    vector<int> dp (k + 1);
    dp[0] = 1;
    for(int child = 1 ; child <= n ; ++child){
      int a;
      cin >> a;

    vector<int> pref(k+1);
      for(int j = k ; j >= 0;--j){
        int tmp = dp[j];
        int L = j + 1;
        int R = j + min(a,k-j);
        if(L <= R){
         add_self(pref[L],tmp);
          if(R + 1 <= k){
            sub_self(pref[R+1],tmp);
          }
        }
      }



    int pref_sum = 0;
    for(int i = 0 ; i <= k ; ++i){
      pref_sum += pref[i];
      pref_sum %=mod;
      dp[i] += pref_sum;
      dp[i] %=mod;

    }
    // for(auto it : dp) cout << it ;cout << endl;
    // for(auto it : pref) cout << it << " " ;cout << endl;

    }
  
    cout << dp[k] << endl;

  return 0;
}

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

int n,num,a[100010];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>num;
        a[num]=i;
    }
    for(int i=1;i<=n;++i){
        if(i!=n)
            cout<<a[i]<<" ";
        else
            cout<<a[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod(ll n,ll m)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*m)%1000000007;
    }
    return ans;
}
int main()
{
    ll n;cin>>n;
    ll ans=(((mod(n,10)-2*mod(n,9)+mod(n,8))%1000000007)+1000000007)%1000000007;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
<?php
//https://atcoder.jp/contests/abc073/submissions/8379970
fscanf(STDIN, "%d%d%d", $N, $M, $R);
$rArray = array_map("intval", explode(" ", trim(fgets(STDIN))));
$wf = new Wf($N);
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d%d", $a, $b, $c);
  $wf->connect2($a, $b, $c);
}
$d = $wf->solve();
echo dfs($rArray, -1);
function dfs($rArray, $current){
  global $d;
  if(!$rArray)return 0;
  $min = 10**10;
  foreach($rArray as $i => $p){
    $array = $rArray;
    unset($array[$i]);
    $dist = dfs($array, $p);
    if($current != -1){
      $dist += $d[$current][$p];
    }
    if($dist < $min){
      $min = $dist;
    }
  }
  return $min;
}
/**
 * Warshall–Floyd
 * Attention: 1-origin
 **/
class Wf{
  public $d;
  public $n;
  function __construct($n)	{
    $this->n = $n;
    for($i = 1; $i <= $this->n; $i++){
      for($j = 1; $j <= $this->n; $j++){
        $this->d[$i][$j] = 10**18;
      }  
    }
  }
  function connect($a, $b, $c){
    $this->d[$a][$b] = $c;
  }
  function connect2($a, $b, $c){
    $this->d[$a][$b] = $c;
    $this->d[$b][$a] = $c;
  }
  function solve(){
    for($k = 1; $k <= $this->n; $k++){
      for($i = 1; $i <= $this->n; $i++){
        for($j = 1; $j <= $this->n; $j++){
          if($this->d[$i][$j] > $this->d[$i][$k] + $this->d[$k][$j]){
            $this->d[$i][$j] = $this->d[$i][$k] + $this->d[$k][$j];
          }
        }
      }
    }
    return $this->d;
  }
}

Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
int main()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<queue>
using namespace std;
int map[101][101];
int all = 0;
int search_2[101];
int n;
void bfs(int k, int m) {
	search_2[k] = m;
	queue<int>q;
	for (int i = 2; i <= n; i++) {
		if (map[k][i] && (search_2[i] == 0 || search_2[i] > m + 1)) {
			q.push(i);
		}
	}
	while (!q.empty())
	{
		bfs(q.front(), m + 1);
		q.pop();
	}
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		int m;
		cin >> m;
		for (int j = 0; j < m; j++) {
			int b;
			cin >> b;
			map[a][b] = 1;
		}
	}
	bfs(1, 0);
	cout << 1 << " " << 0 << endl;
	for (int i = 2; i <= n; i++) {
		cout << i << " ";
		if (search_2[i] == 0) cout << -1 << endl;
		else cout << search_2[i] << endl;
	}
}


Measured memory_bytes: 3208
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e12;//ごめん
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	//適当にやってもそんなに大きくならない説
	ios::sync_with_stdio(false);
	std::cin.tie(0);
	llint n,q,i;cin>>n>>q;
	llint oldn=n;
	vector<llint>kaz;kaz.pub(n);
	for(i=0;i<q;i++){
		llint a;cin>>a;
		while(kaz.size()>0&&kaz.back()>=a){kaz.pob();}
		kaz.pub(a);
	}
	//for(auto it:kaz){cerr<<it<<" ";}cerr<<endl;
	//kazは操作の列単調増加
	llint m=kaz.size();
	n=kaz[0];
	vector<llint>kri(m+1);//kri回だけ加算
	vector<llint>wa(n+2);
	kri[m-1]=1;
	for(i=m-1;i>0;i--){
		if(kri[i]==0){continue;}
		llint gen=kaz[i];
		int mae=i;
		while(gen>n){
			llint bas=lower_bound(kaz.begin(),kaz.begin()+mae,gen)-kaz.begin()-1;
			kri[bas]+=kri[i]*(gen/kaz[bas]);//1以上
			gen%=kaz[bas];
			mae=bas;
		}
		wa[gen]+=kri[i];
	}
	wa[n]+=kri[0];
	for(i=n-1;i>=0;i--){wa[i]+=wa[i+1];}
	for(i=1;i<=n;i++){cout<<wa[i]<<"\n";}
	for(i=n+1;i<=oldn;i++){cout<<0<<"\n";}
	RE;
}


Measured memory_bytes: 4212
n = int(input().rstrip())
xs = list(map(int, input().rstrip().split(' ')))

result = float('inf')

i = 0
while True:
    point = i + 1
    current_sum = sum([(x-point) * (x-point) for x in xs])
    if result > current_sum:
        result = current_sum
        i += 1
    else:
        break

print(result)


Measured memory_bytes: 3060
C=input()
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(A)-1):
    if A[i]==C:
        print(A[i+1])
        break

Measured memory_bytes: 8996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), m = in.nextInt();;
			long[] a = new long[n+1];
			long[] rui = new long[n+1];
			long[] rui2 = new long[n+1];
			Map<Long, Long> map = new HashMap<>();
			for (int i = 1; i <= n; i++) {
				a[i] = in.nextLong();
				rui[i] += rui[i-1] + a[i];
				rui2[i] = rui[i] % m;
			}

			for (long l : rui2) {
				map.merge(l, 1L, Long::sum);
			}

			long ans = 0;
			for (int i = 1; i <= n; i++) {
				ans += map.get(rui2[i-1]) - 1L;
				if (map.containsKey(rui2[i-1])) {
					long v = map.get(rui2[i-1]);
					map.put(rui2[i-1], --v);
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 44788
#include <stdio.h>

int main() {
    int n;
    int p[50];
    int i;
    int count = 0;

    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        scanf("%d",&p[i]);
        if(p[i] != i){
            count++;
        }
    }

    if(count<=2){
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128