akhauriyash/Code-Regression huggingface dataset:
# A - Frog 1

N = int(input())
h = list(map(int, input().split()))

cost = [0] + [abs(h[0] - h[1])] + [float("inf")] * (N-2)

for i in range(2, N):
    cost[i] = min(cost[i], cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]))

print(cost[-1])

Measured memory_bytes: 13980
#include <iostream>
#define SIZE 100000
using namespace std;

void copy(int *res, int *ori, int n){
    for(int i=0;i<n;i++){
        *(res+i) = *(ori+i);
    }
}

void mult(int *res, int *a, int n){
    for(int i=0;i<n;i++){
        *(res+i) = *(a + *(res+i));
    }
}

void pow(int *res, int *a, long long b, int n){
    int base[SIZE], tmp[SIZE];
    for(int i=0;i<n;i++){
        *(base+i) = *(a+i);
        *(res+i) = i;
    }
    while(b > 0){
        if(b%2 == 0){
            copy(tmp, base, n);
            mult(tmp, base, n);
            copy(base, tmp, n);
            b /= 2;
        }else{
            mult(res, base, n);
            b--;
        }
    }
}

int main(void){
    int n, m, p[SIZE], q[SIZE];
    long long k;
    long long x[SIZE], y[SIZE];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i];
        p[i] = i;
        if(i>0){
            y[i-1] = x[i] - x[i-1];
        }
    }
    cin >> m >> k;
    for(int i=0;i<m;i++){
        int a, t;
        cin >> a;
        a--;
        t = p[a];
        p[a] = p[a-1];
        p[a-1] = t;
    }
    pow(q, p, k, n-1);

    for(int i=0;i<n;i++){
        if(i > 0){
            x[i] = x[i-1] + y[q[i-1]];
        }
        cout << x[i] << endl;
    }/*
    for(int i=0;i<n;i++){
        cout << i << " : " << q[i] << endl;
        cout << i << "y : " << y[i] << endl;
    }*/
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{
	static ArrayList<Long> l = new ArrayList<>();
	
	static void goo(long now, int dig, int curdigs)
	{
		if(curdigs == dig)
		{
//			System.out.println(now);
			l.add(now);
			return;
		}
		
		long lastdig = now%10;
		
		if(curdigs == 0)
		{
			for(int i = 1; i <= 9; i++)
			{
				goo(now*10 + i, dig, curdigs+1);
			}
		}
		else if(lastdig == 0)
		{
			goo(now*10 + 0, dig, curdigs+1);
			goo(now*10 + 1, dig, curdigs+1);
		}
		else if(lastdig == 9)
		{
			goo(now*10 + 8, dig, curdigs+1);
			goo(now*10 + 9, dig, curdigs+1);
		}
		else
		{
			goo(now*10 + lastdig, dig, curdigs+1);
			goo(now*10 + lastdig-1, dig, curdigs+1);
			goo(now*10 + lastdig+1, dig, curdigs+1);
		}
		
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		for(int i = 1; i <= 10; i++) //10
		{
			goo(0, i, 0);
		}
		l.sort(null);
		
//		for(int i = 0; i < 100; i++)
//			System.out.println(l.get(i));
		
		int n = sc.nextInt();
		System.out.println(l.get(n-1));
		
	}

}


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

const int INF = 100000000;
typedef pair<int, int> P;
const int MAX_H = 50, MAX_W = 50;
int H, W;
int sy, sx;
int gy, gx;
char maze[MAX_H][MAX_W];

int d[MAX_H][MAX_W];

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

int bfs();

int main()
{
  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> maze[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (maze[i][j] == '#')
        cnt++;
    }
  }
  int res = bfs();
  if (res == INF)
    cout << -1 << endl;
  else
  {
    int ans = H * W - (cnt + res + 1);
    cout << ans << endl;
  }
}

int bfs()
{
  queue<P> que;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      d[i][j] = INF;
    }
  }
  sy = 0, sx = 0;
  gy = H - 1, gx = W - 1;
  que.push(P(sy, sx));
  d[sy][sx] = 0;
  while (que.size())
  {
    P p = que.front();
    que.pop();
    if (p.first == gy && p.second == gx)
    {
      break;
    }
    for (int i = 0; i < 4; i++)
    {
      int ny = p.first + dy[i], nx = p.second + dx[i];
      if (0 <= ny && ny < H && 0 <= nx && nx < W && maze[ny][nx] != '#' && d[ny][nx] == INF)
      {
        que.push(P(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
  return d[gy][gx];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<ll> v(N+1);
  v[0] = 0;
  rep(i,N)cin >> v[i+1];
  rep(i,N+1) v[i] += v[i-1];
  sort(all(v));
  v.push_back(MAX_LL);
  ll pre = MAX_LL;
  ll count = 0;
  ll sum = 0;
  rep(i,N+2){
    if(pre==v[i])++count;
    else{
      sum += count*(count-1)/2;
      count = 1;
    }
    pre = v[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		while(true) {
			c -= b;
			if(c<=0) {
				System.out.println("Yes");
				System.exit(0);
			}
			
			a -= d;
			if(a<=0) {
				System.out.println("No");
				System.exit(0);
			}
			
		}
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}


Measured memory_bytes: 35852
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=1;i<=100;i++){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int d[SIZE];
char s[SIZE];
int main(){
    int N,K,C;
    R(N,K,C);
    RS(s);
    int lt=-SIZE;
    int dn=0;
    REP(i,N){
        if(s[i]!='x'&&i>lt+C){
            d[dn++]=i;
            lt=i;
        }
    }
    lt=SIZE;
    VI res;
    dn=1;
    for(int i=N-1;i>=0;i--){
        if(s[i]!='x'&&i<lt-C){
            if(i==d[K-dn])res.PB(i+1);
            dn++;
            if(dn>K)break;
            lt=i;
        }
    }
    sort(ALL(res));
    W(res);
    return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 110;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int x, n, a, v[MX] = {0};
    cin>>x>>n;
    loop(i,0,n)
    {
        cin>>a;
        v[a] = 1;
    }

    int mn = INF, ans = -1, d;
    loop(i,0,MX)
    {
        if(v[i]) continue;
        d = abs(x - i);
        if(d < mn) {mn = d; ans = i;}
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3668
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000];
int C[100000], D[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    cin >> A[i];
    int x = A[i];
    while (x>=2) C[i]++, x/=2;
    if (A[i] != (1<<C[i])) D[i] = 1;
  }
  //rep(i, N) cout<<C[i]<<"("<<D[i]<<"),";cout<<"\n";
  int s = 0;
  rep(left, N) {
    while (C[left]+D[left] > 0) {
      s++;
      if (C[left] > 0) C[left]--;
      else D[left]--;
      for (int x=left+1; x<N; x++) {
        if (C[x]>0) C[x]--;
        else {
          if (D[x]>0) D[x]--;
          break;
        }
      }
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var left = 0;
        var right = nk[1] - 1;
        var min = long.MaxValue;
        for(var i = 0; right + i < nk[0]; i++)
        {
            var d = Min(Abs(ar[left + i]) + Abs(ar[right + i] - ar[left + i]), Abs(ar[right+i]) + Abs(ar[right + i] - ar[left + i]));
            min = Min(min, d);
        }
        WriteLine(min);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int main(){
  string S;
  cin >> S;
  for(int i=0;i<3;i++){
    if(S.at(i) == S.at(i+1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int i,Count=0,a,b,x;
    cin>>a>>b>>x;
    for(i=a;i<=b;i++)
    {
        if(i%x==0)
        {
            Count++;
        }
    }
    cout<<Count<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=2*1e5+100;
int n,k,sz[N],son[N],id[N],ans[N];
int c[N],d[N],cnt,ti[N],dfn;
int tot,first[N],nxt[N*2],point[N*2];
namespace dsu
{
	struct node
	{
		int x,y,e,sz,T;//x->y
	};
	int fa[N],e[N],sz[N];
	stack <node> s;
	int nowtime()
	{
		if (s.empty()) return 0;
		else return s.top().T;
	}
	inline int find(int x)
	{
		if (fa[x]==x) return fa[x];
		return fa[x]=find(fa[x]);
	}
	void init()
	{
		for (int i=1;i<=k;i++) fa[i]=i,sz[i]=1;
	}
	void connect(int x,int y)
	{
		int fax=find(x),fay=find(y),T=nowtime()+1;
		if (fax==fay)
		{
			s.push((node){fax,fay,e[fax],sz[fax],T});
			cnt-=sz[fax]-(e[fax]==sz[fax]-1);
			e[fax]++;
			cnt+=sz[fax]-(e[fax]==sz[fax]-1);
			return;
		}
		if (sz[fax]>sz[fay]) swap(fax,fay);
		cnt-=sz[fax]-(e[fax]==sz[fax]-1);
		cnt-=sz[fay]-(e[fay]==sz[fay]-1);
		s.push((node){fax,fay,e[fay],sz[fay],T});
		fa[fax]=fay,sz[fay]+=sz[fax],e[fay]+=e[fax]+1;
		cnt+=sz[fay]-(e[fay]==sz[fay]-1);
	}
	void back(int T)
	{
		while (!s.empty() && s.top().T>T)
		{
			node tmp=s.top();
			s.pop();
			cnt-=sz[tmp.y]-(e[tmp.y]==sz[tmp.y]-1);
			fa[tmp.x]=tmp.x,e[tmp.y]=tmp.e,sz[tmp.y]=tmp.sz;
			cnt+=sz[tmp.x]-(e[tmp.x]==sz[tmp.x]-1);
			if (tmp.x!=tmp.y) cnt+=sz[tmp.y]-(e[tmp.y]==sz[tmp.y]-1);
		}
	}
}
void add_edge(int x,int y)
{
	tot++;
	nxt[tot]=first[x];
	first[x]=tot;
	point[tot]=y;
}
void dfs(int x,int fa)
{
	sz[x]=1;
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa) continue;
		dfs(u,x);
		sz[x]+=sz[u];
		if (sz[u]>sz[son[x]]) son[x]=u;
	}
}
void dfs1(int x,int fa)
{
	dsu::connect(c[x],d[x]);
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa) continue;
		dfs1(u,x);
	}
}
void dfs2(int x,int fa)
{
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i],t=dsu::nowtime();
		if (u==fa || u==son[x]) continue;
		dfs2(u,x);
		dsu::back(t);
	}
	if (son[x]) dfs2(son[x],x);
	dsu::connect(c[x],d[x]);
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa || u==son[x]) continue;
		dfs1(u,x);
	}
	ans[x]=cnt;
}
signed main()
{
	tot=-1;
	memset(first,-1,sizeof(first));
	memset(nxt,-1,sizeof(nxt));
	scanf("%d%d",&n,&k);
	for (int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for (int i=1;i<=n;i++) scanf("%d%d",&c[i],&d[i]);
	dfs(1,1);
	dsu::init();
	dfs2(1,1);
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 16840
from itertools import product
import numpy as np


def solve(string):
    n, *fp = map(int, string.split())
    # f = np.asarray(fp[:10 * n]).reshape((n, 10))
    f = fp[:10 * n]
    p = fp[10 * n:]
    ans = -n * 10**7
    """
    for o in product([0, 1], repeat=10):
        if sum(o) == 0:
            continue
        # tmp = np.dot(f, np.asanyarray(o).T)
        tmp = [sum([for ]) for _f in f]
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)
    """
    int_f = [int("".join(map(str, f[10 * i:10 * (i + 1)])), 2) for i in range(n)]
    for o in range(1, 2**10):
        tmp = [sum(map(int, "{:b}".format(o & _f))) for _f in int_f]
        ans = max(ans, sum([p[11 * i + t] for i, t in enumerate(tmp)]))
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2 * n)])))


Measured memory_bytes: 12700
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8");

const args = input.split("\n")[1].split(" ").map(x => +x).filter(x => !(x % 2))
const nums = args.filter(n => !(n % 3) || !(n % 5))

console.log(args.length === nums.length ? "APPROVED" : "DENIED")


Measured memory_bytes: 9420
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    int M = 1;
    rep(i, N) M *= 2;
    multiset<int> S;
    int max_s = 0;
    rep(i, M) {
        int s;
        cin >> s;
        S.insert(-s);
        max_s = max(max_s, s);
    }

    vint slim_set, new_slim_set;
    slim_set.push_back(max_s);
    S.erase(S.find(-max_s));
    rep(i, N) {
        vint new_slim_set = slim_set;
        for (auto &slm : slim_set) {
            auto it = S.upper_bound(-slm);
            if (it == S.end()) {
                cout << "No" << endl;
                return 0;
            }
            new_slim_set.push_back(-*it);
            S.erase(it);
            
        }
        slim_set = new_slim_set;
    }
    cout << "Yes" << endl;
    return 0;
}

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

// int ans(){
    
// }

int main() {
	ll n;
    cin>>n;
    ll a[n],cnt=0;
    for(int i=0;i<n;i++)cin>>a[i];
    
    for(int i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
            cnt+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<cnt<<endl;
}

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

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

fn main() {
    let h: usize = read();
    let n: usize = read();

    let mut s: usize = 0;
    for i in 0..n {
        let v: usize = read();
        s += v;
    }

    println!("{}", if h <= s { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<double, pair<int, int> > P; //コスト、現在地、どこからきたか

//int dy[5] = { 0,0,1,-1,0 };
//int dx[5] = { 1,-1,0,0,0 };

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

struct edge
{
	int to;
	double cost;
};

int main(void)
{
	while(1){
		long long int n, q;
		string tmp;
		long long int a, b;
		cin >> n >> q;

		if(n==0&&q==0){
			break;
		}
		vector<string> s(n);
		vector<long long int> first(n), second(n);
		FOR(i, 0, n - 1)
		{
			cin >> tmp >> a >> b;
			s[i] = tmp;
			first[i] = b - a + 1;
			second[i] = b;
		}
		bool flag = false;
		FOR(i, 1, q)
		{
			cin >> a;
			flag = false;
			FOR(j, 0, n - 1)
			{
				if(first[j]<=a&&second[j]>=a){
					cout << s[j] << " " << a - first[j] + 1 << endl;
					flag = true;
				}
			}
			if(flag==false){
				cout << "Unknown" << endl;
			}
		}
	}
	return 0;
}



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

int main()
{
    string s;
    cin>>s;

    if(s=="SAT")
    {
        cout<<"1"<<endl;
    }
     else if(s=="SUN")
    {
         cout<<"7"<<endl;
    }
     else if(s=="MON")
    {
         cout<<"6"<<endl;
    }
     else if(s=="TUE")
    {
         cout<<"5"<<endl;
    }
      else if(s=="WED")
    {
         cout<<"4"<<endl;
    }
      else if(s=="THU")
    {
         cout<<"3"<<endl;
    }
     else if(s=="FRI")
    {
         cout<<"2"<<endl;
    }


      return 0;
}


Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local n = io.read("*n")
local r = 0
local max = 0
for i = 1, n do
  local a = io.read("*n")
  if a < max then r = r + max - a
  elseif max < a then max = a
  end
end
print(r)

Measured memory_bytes: 2740
var
	ch:ansistring;
	i,l,t:longint;
function _to(x:char):char;
begin
	case x of
		'b':exit('d');
		'd':exit('b');
		'p':exit('q');
		'q':exit('p');
	end;
end;
procedure error;
begin
	writeln('No');
	halt;
end;
begin
	readln(ch);
	l:=length(ch);
	if l mod 2=1 then error;
	t:=l div 2;
	for i:=1 to t do 
		if _to(ch[i])<>ch[l-i+1] then error;
	writeln('Yes');
end.

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
ll a[10000], b[10000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) cin >> b[i];
	ll s = 0;
	ll A = 0, B = 0;
	for (int i = 0; i < N; i++) {
		ll c = b[i] - a[i];
		s += c;
		if (c >= 0) {
			A += (c + 1) / 2;
			B += c % 2;
		}
		else {
			c *= -1;
			B += c;
		}
	}
	if (s<0 || A>s || B > s || 2 * (s - A) != (s - B)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 512
use std::io::{self};

fn main() {
    let mut buffer1 = String::new();
    let a: u32 = match io::stdin().read_line(&mut buffer1) {
        Ok(_) => {
            buffer1.trim().parse::<u32>().ok().expect("woops")
        },
        Err(_) => 0
    };

    let ans = exec_calc(a);

    println!("{:?}", ans);
    return;
}

fn exec_calc(a: u32) -> u32 {
    return a + (a * a) + (a * a * a)
}

#[test]
fn test_exec_calc() {
    let ans = exec_calc(2);
    assert_eq!(ans, 14);
}

Measured memory_bytes: 2112
n = int(input())
w = list(map(int, input().split()))

m = 10**18
'''
for i in range(1, n):
    d = abs(sum(w[0:i]) - sum(w[i:n]))
    m = min(d, m)
'''

a, b = 0, sum(w)
for i in range(n):
    a += w[i]
    b -= w[i]
    m = min(abs(a-b), m)

print(m)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

// #define int long long

signed main(){
  int n=0;
  long long ans=1;
  string S;
  cin >> n >> S;
  int data[200]={};
  LOOP(i,S.length()){
    data[S[i]]++;
  }
  FOR(i,'a','z'+1){
    ans*=(data[i]+1);
    ans %= 1000000007;
    // cerr << data[i] << endl;
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c - (a - b);
    if (ans > 0) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N;
    cin>>N;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    vector<ll> s;
    rep(i,N){
        auto ite = lower_bound(s.begin(),s.end(),v[i]);
        if(ite==s.begin()) s.insert(s.begin(),v[i]);
        else{
            ite--;
            *ite=v[i];
        }
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 5036
import java.util.*;

public class Main{
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  sc.nextLine();
	  String str = sc.nextLine();
	  char[] c = str.toCharArray();
	  if(c[b-1] == 'A') {
		  c[b-1] = 'a';
	  }
	  else if(c[b-1] == 'B') {
		  c[b-1] = 'b';
	  }
	  else {
		  c[b-1] = 'c';
	  }
	  for(int i=0; i<c.length; i++) {
		  System.out.print(c[i]);
	  }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=2e5+5;
int h,n;
vector<int>a,b;
vector<int> cache(N);
int dp(int h){
	if(h<=0){
		return 0;
	}
	if(cache[h]!=1e18){
		return cache[h];
	}
	for(int i=0;i<n;i++){
		cache[h]=min( b[i]+ dp(h-a[i]), cache[h]);
	}
	return cache[h];
}

int32_t main(){
	IOS;
	
	//code

	cin>>h>>n;
	a.resize(n);
	b.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	
	for(int i=0;i<=h;i++){
		cache[i]=1e18;
	}
	int cost=dp(h);
	cout<<cost<<endl;
	//code
	
	return 0;

}

Measured memory_bytes: 2304
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys


S = input()

prev_one = ''
prev_two = ''

length = len(S)
dp_one = [0] * length
dp_two = [0] * length

for i, ch in enumerate(S):
    if i == 0:
        dp_one[0] = 1
    else:
        prev_one = S[i - 1]
        if prev_one != ch:
            dp_one[i] = max(dp_one[i-1], dp_two[i-1]) + 1
        else:
            dp_one[i] = dp_two[i-1] + 1

    if i >= 2:
        two = S[i - 1] + S[i]
        prev_two = S[i - 3] + S[i - 2]
        if prev_two != two:
            dp_two[i] = max(dp_two[i - 2], dp_one[i - 2]) + 1
        else:
            dp_two[i] = dp_one[i - 2] + 1
    elif i == 1:
        dp_two[i] = 1
    else:
        dp_two[i] = 0

    # print("i = ", i)
    # print("  ", dp_one)
    # print("  ", dp_two)

print(max(dp_one[-1], dp_two[-1]))

            
            

            
        
    


Measured memory_bytes: 23284
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#define int long long
#define mp make_pair
using namespace std;
int n,a[20];
std::map<pair<int,int>,int> dp[20][20];
int dfs(int l,int r,int x,int y){
	if(l>r)return 0;
	if(l==r)return a[l]*(x+y);
	if(dp[l][r].count(mp(x,y)))
		return dp[l][r][mp(x,y)];
	int ans=0x3f3f3f3f3f3f3f3f;
	for(int i=l;i<=r;i++)
		ans=min(ans,a[i]*(x+y)+dfs(l,i-1,x,x+y)+dfs(i+1,r,x+y,y));
	return dp[l][r][mp(x,y)]=ans;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	printf("%lld\n",a[1]+a[n]+dfs(2,n-1,1,1));
}

Measured memory_bytes: 8448
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(7).
f(5).
f(3).

main :-
    get_number(X),
    f(X) -> writeln("YES") ; writeln("NO").


Measured memory_bytes: 8072
#include <bits/stdc++.h>
using namespace std;
int H,W,sx,sy,gx,gy;
string s[1000];
int d[1000][1000];
int INF=1<<30;
main()
{
    cin>>H>>W;
    cin>>sx>>sy;
    cin>>gx>>gy;
    --sx;--sy;--gx;--gy;
    for(int i=0;i<H;++i)cin>>s[i];
    for(int i=0;i<H;++i)for(int j=0;j<W;++j)d[i][j]=INF;
    d[sx][sy]=0;
    deque<pair<int,int>> q;
    q.push_back({sx,sy});
    while(!q.empty())
    {
        int x=q.front().first;
        int y=q.front().second;
        q.pop_front();
        for(int i=-2;i<=2;++i)for(int j=-2;j<=2;++j)
        {
            int nx=x+i;
            int ny=y+j;
            if(nx<0||ny<0||nx>=H||ny>=W||s[nx][ny]=='#')continue;
            if(abs(i)+abs(j)<=1)
            {
                if(d[nx][ny]>d[x][y])
                {
                    d[nx][ny]=d[x][y];
                    q.push_front({nx,ny});
                }
            }else if(d[nx][ny]>d[x][y]+1)
            {
                d[nx][ny]=d[x][y]+1;
                q.push_back({nx,ny});
            }
        }
    }
    cout<<(d[gx][gy]==INF?-1:d[gx][gy])<<endl;
}

Measured memory_bytes: 9448
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple


int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];

    // 累積
    ll s = 0;
    map<ll, ll> cnt;
    vector<ll> sums(N);
    REP(i, N) {
        auto a = As[i];
        s += a;
        ++cnt[s % M];
        sums[i] = s;
    }

    // for(auto s: sums) cout << s << " "; cout << endl;
    // for(auto s: sums) cout << (s % M) << " "; cout << endl;

    ll ans = 0;
    for(auto kv: cnt) {
        auto k = kv.first;
        auto v = kv.second;
        auto tmp = v * (v - 1) / 2;
        if (k == 0) {
            tmp += v;
        }
        // cout << k << ", " << v << ": " << tmp << endl;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int i = 1;
  while (++i <= n) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    }
    while (x) {
      if (x % 10 == 3) {
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3112
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A, K));

        sc.close();
    }

    static int solve(int[] A, int K) {
        int index1 = IntStream.range(0, A.length).filter(i -> A[i] == 1).findAny().getAsInt();

        return 1 + IntStream.rangeClosed(index1 - K + 1, index1)
                .filter(beginIndex -> beginIndex >= 0 && beginIndex + K <= A.length)
                .map(beginIndex -> (beginIndex + K - 2) / (K - 1) + (A.length - beginIndex - 2) / (K - 1)).min()
                .getAsInt();
    }
}

Measured memory_bytes: 48752
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;

int main(){
int A, B, C;
cin >> A >> B >> C;
cout << min(B/A,C) << endl;
return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  int b[N];
  for(int i=0;i<N;i++){
    cin >>a[i];
  }
  for(int i=N/2+1;i<N;i++){
    b[i]=a[i];
  }

  int ex;
  for(int i=N/2;i>=0;i--){
    ex=0;
    //for(int j=((i+1)*2)-1;j<N;j+=i+1){
    for(int j=2*i+1;j<N;j+=i+1){
      ex^=b[j];
    }
    b[i]=a[i]^ex;
  }
  int M=0;
  for(int i=0;i<N;i++){
    M += b[i];
  }
  cout << M << endl;
  if(M==0)exit(0);
  int bout[M];
  int cnt=0;
  for(int i=0;i<N;i++){
    if(b[i]==1){
      bout[cnt]=i+1;
      cnt++;
    }
  }
  for(int i=0;i<M-1;i++){

      cout <<bout[i]<< " ";

  }
  cout<<bout[M-1]<<endl;
}


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


int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  char M[H][W];
  for (int i=0; i<H; i++){
  	for (int j=0; j<W; j++){
		cin >> M[i][j];
    }
  }
  
  for (int i=0; i<H; i++){
  	for (int j=0; j<W; j++){
   		if (M[i][j]=='.'){
        	int count=0;          
            for (int dx=-1; dx<2; dx++){
  				for (int dy=-1; dy<2; dy++){
                  	if((0<=i+dx && i+dx<H)&& (0<=j+dy && j+dy<W) &&(M[i+dx][j+dy]=='#')){
                    	count++;
                    }
                }
            }
          M[i][j]=char(count)+'0';
        }
    }
  }

  for (int i=0; i<H;i++){
  	for (int j=0; j<W;j++){
    	cout << M[i][j];
      	if (j==W-1) cout << endl;
    } 
  }
}


Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 1000003
    Q = int(file())
    ans = ""
    nfact = [1] * mod
    nrev = [1] * mod
    for i in range(2, mod):
        nfact[i] = (nfact[i-1] * i) % mod
    nrev[mod - 1] = pow(nfact[mod - 1], mod - 2, mod)
    for i in reversed(range(1, mod - 1)):
        nrev[i] = (nrev[i+1] * (i + 1)) % mod
    ans = ""
    for i in range(Q):
        x, d, n = map(int, file().split())
        if d == 0: ans += str(pow(x, n, mod)) + "\n"
        else:
            k = (x * nfact[d-1] * nrev[d]) % mod
            if k + n > mod: ans += "0\n"
            elif k == 0: ans += str((pow(d, n, mod) * nfact[n-1]) % mod) + "\n"
            else:
                f = (pow(d, n, mod) * nfact[k + n - 1] * nrev[k - 1]) % mod
                ans += str(f) + "\n"

    print(ans)

    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 84724
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>

using namespace std;

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  if (a <= b * 2) {
    cout << 0 << endl;
  } else {
    cout << (a - b * 2) << endl;
  }
}


Measured memory_bytes: 768
m, d = map(int, input().split())
cnt = 0
for i in range(1, m+1):
  for j in range(1, d+1):
    if j < 10:
      continue
    d10 = j // 10
    d1 = j % 10
    if d10 < 2 or d1 < 2:
      continue
    if i == d10 * d1:
      cnt += 1
print(cnt)

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

int main() {
  int n,k;
  cin >> n >> k;
  double x,ex[n];
  for(int i=0;i<n;i++){cin >> x; ex[i] = (x+1)/2;}
  double acc[n+1];
  acc[0]=0;
  for(int i=1;i<=n;i++) acc[i] = acc[i-1] + ex[i-1];
  double ans=0;
  for(int i=0;i<=(n-k);i++) ans = max(ans,acc[i+k]-acc[i]);
  printf("%.8lf\n",ans);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
char s[200001];
int sum=0,ans=0;
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for (int i=0;i<len;i++)
	{
		if (s[i]=='S') sum++;
		else if (sum>0)
		{
			ans+=2;
			sum--;
		}
	}
	printf("%d",len-ans);
}

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

int main() {
  int N;
  cin>>N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin>>A[i];
  }
  int sw=0;
  bool f=true;
  for (int i=0; f; i++) {
    f=false;
    for (int j=N-1; j>=i+1; j--) {
      if (A[j]<A[j-1]) {
        swap(A[j],A[j-1]);
        f=true;
        sw++;
      }
    }
  }
  for (int i=0; i<N; i++) {
    cout<<(i==0?"":" ")<<A[i]<<flush;
  }
  cout<<endl;
  cout<<sw<<endl;
  return 0;
}



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

int INF =12345678;
int main(){
    int N,M;
    cin>>N>>M;
    // <<はビットシフト(2進数に変換し後ろにn個0を付ける)
    // 1<<n = 2のn乗
    vector<int>dp(1<<N);
    for(int i=0;i<(1<<N);i++) dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      int bit = 0;
      for(int j=0;j<b;j++){
        int c;
        cin>>c;
        // bitを鍵が開けられるフラグとする
        // sample1 なら
        // 00 -> 宝箱を1つもを開けられない
        // 01 -> 宝箱1のみ開けることができる
        // 10 -> 宝箱2のみ開けることができる
        // 11 -> 宝箱1と宝箱2を開けることができる
        // (a|b) = a or b
        int x = 1<<(c-1);
        bit = bit|x;
      }
      for(int j=0;j<(1<<N);j++){
        // 鍵を開けられる状態j(jは2進表記)
        // すべてのjに対し,追加コストaを支払うことによって
        // j -> j|bitに遷移するかしないかを決める
        dp[j|bit] = min(dp[j|bit],dp[j]+a);
      }
    }
    // 1<<N-1 111...つまり全てのかぎが開けられる状態
    //　存在しないなら-1を出力
    if(dp[(1<<N)-1]==INF) cout<<-1<<endl;
    else cout<<dp[(1<<N)-1]<<endl;

  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char A[5]={0};
    char B[5]={0};
    scanf("%s",A);
    scanf("%s",B);
    int ans=0;
    for(int i=0;i<3;i++)
    {
        if(A[i] == B[i])
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1],b[n+1],c[n];
  for(int j=1;j<=n;j++)
    cin>>a[j];
  for(int j=1;j<=n;j++)
    cin>>b[j];
  for(int j=1;j<n;j++)
    cin>>c[j];
  long long int sum=0;
  for(int i=1;i<=n;i++)
  {
    if(a[i]==n)
    {
      sum+=b[a[i]];
    }
    else
    if(a[i]+1==a[i+1])
      sum+=b[a[i]]+c[a[i]];
    else
      sum+=b[a[i]];
  }
  cout<<sum;
  return 0; 
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

import collections

cnt = collections.Counter(A)

minval = min(A)
maxval = max(A)

ret = 0
for i in range(minval, maxval+1):
    s = cnt[i - 1] + cnt[i] + cnt[i + 1]
    ret = max([ret, s])

print(ret)



Measured memory_bytes: 13964
#include <cstdio>
#include <cstring>

using namespace std;

int main(void)
{
	char word[10001];
	int n;
	long long sum = 1;

	gets(word);
	n = strlen(word);

	for(int f1 = 0; f1 < n; f1++){
		if('a' <= word[f1] && word[f1] <= 'z')
		{
			word[f1] = word[f1] - ('a' - 'A');
		}
	}

	printf("%s\n", word);
	return 0;
}

Measured memory_bytes: 924
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, snuke[101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 0, K) {
		int d; cin >> d;
		rep(j, 0, d) {
			int A;
			cin >> A;
			A--;
			snuke[A]++;
		}
	}

	int ans = 0;
	rep(i, 0, N) if (snuke[i] == 0) ans++;
	cout << ans << endl;
}







Measured memory_bytes: 3652
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
from itertools import permutations
import itertools
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
def print_red(field, high):
    for i in range(len(high)):
        if high[i] == 1:
            field[i] = ['X' for _ in range(len(field[0]))]
    return field

def count_sharp_without_width(field, width):
    count = 0
    for i in range(len(field)): #高さ(横線)
        for j in range(len(width)): #横(縦ライン)
            if width[j] == 1:
                continue
            if field[i][j] == '#':
                count += 1
    return count

def main():
    h, w, k = list(map(int,input().split()))
    field = [list(input()) for _ in range(h)]
    #print(field)

    ans = 0

    for high in itertools.product([1, 0], repeat=h):
        field_temp = deepcopy(field)
        field_temp = print_red(field_temp, high)
        count_k = 0
        #print(field_temp)
        for i in range(h):
            count_k += field_temp[i].count('#') 
        #print(count_k)
        if count_k < k: continue # kを下回ったらブレイク
        
        for width in itertools.product([1, 0], repeat=w):
            #print(width)
            count_k = count_sharp_without_width(field_temp, width)
            if count_k == k:
                ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Graph vector<vector<ll>>
constexpr ll INF=(1ll<<60);
constexpr ll mod=1000000007;
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll a,b;cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}

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


int main(){
  long long int X;
  cin >> X;

  for(long long int A = -1000; A<=1000; A++){
    long long int tmp = A*A*A*A*A - X;
    for(long long int B = -1000; B<=1000; B++){
      if(B*B*B*B*B==tmp){
        cout << A << " " << B << endl;
        return 0;
      }
    }    
  }
  return 0;
}


Measured memory_bytes: 3592
n = gets.to_i

max_1 = [-1,0]
max_2 = [-1,0]
n.times do |i|
    x = gets.to_i
    if x >= max_1[1] then
        max_2 = max_1
        max_1 = [i,x]
    elsif x >= max_2[1]
        max_2 = [i,x]
    end
end

n.times do |i|
    if max_1[0] == i then
        puts max_2[1]
    else
        puts max_1[1]
    end
end

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

using namespace std;
typedef long long lint;
typedef long double ldb;
typedef unsigned long long uli;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define I(i, a) for(auto i : a)
#define pb push_back
#define rs resize
#define mk make_pair
#define asg assign
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define era erase
#define fi0(x) memset(x, 0, sizeof(x))
#define finf(x) memset(x, 127, sizeof(x))
#define y1 adjf

const int MAXN = 2e5 + 5;

int cnt[MAXN];
int cov[MAXN];
int n, m;
int a[MAXN];

multiset<int, greater<int> > ex;

int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	scanf("%d%d", &n, &m);
	F(i, 0, n){
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	int car = 0;
	int uc = 0;
	Df(i, n, -1){
		cov[i] = car;
		if(cov[i] == 0 && i != n)uc++;
		while(!ex.empty() && *ex.begin() == i){car--; ex.era(ex.begin());}
		if(cnt[i] != 0){
			car++; ex.ins(max(0, i - cnt[i]));
		}
	}
	F(i, 0, m){
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		if(a[x] - cnt[a[x]] >= 0){cov[a[x] - cnt[a[x]]]--; if(cov[a[x] - cnt[a[x]]] == 0)uc++;}
		cnt[a[x]]--;
		a[x] = y;
		cnt[a[x]]++;
		if(a[x] - cnt[a[x]] >= 0){cov[a[x] - cnt[a[x]]]++; if(cov[a[x] - cnt[a[x]]] == 1)uc--;}
		printf("%d\n", uc);
	}
	ret 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
    using namespace std;
    signed main(){
    int n,s,c[100005];
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>s;
    c[s-1]=i+1;
    }
    for(int i=0;i<n;i++){
    cout<<c[i];
    if(i<n-1)
    cout<<' ';
    else
    cout<<endl;
    }
    return 0 ;
    }

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

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


Measured memory_bytes: 3624
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <queue>
#include <string.h> 
using namespace std;
const int N = 1000+5;
int a[N];
int main() 
{
    int m,n,b,c,sum=0;
    cin>>m;
	while(m--)
	{
		cin>>n>>b;
		c=b-n+1;
		sum+=c;
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256