akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct node_t
{
	node_t *pre, *next;
	int value;
}node;

node *nil;

void list_init(){
	nil = (node *)malloc(sizeof(node));
	nil->pre = nil->next = nil;
}

void insert(int key){
	node *x = (node *)malloc(sizeof(node));
	x->value = key;
	x->next = nil->next;
	nil->next->pre = x;
	x->pre = nil;
	nil->next = x;
}

node* search(int key){
	node *start = nil->next;
	while(start != nil){
		if(start->value == key) {
			//printf("i find\n");
			break;
		}
		start = start->next;
	}
	return start;
}

void deleteNode(node *n){
    if(n==nil) return;
	n->pre->next = n->next;
	n->next->pre = n->pre;
	free(n);
}

void deleteKey(int key){
	node *n = search(key);
	deleteNode(n);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->pre);
}

void printList(){
	node *n = nil->next;
	while(1){
		printf("%d",n->value);
		n = n->next;
		if(n == nil) break;
		printf(" ");
	}
	printf("\n");
}

int main(int argc, char const *argv[])
{
	list_init();
	int num_operation, key;
	scanf("%d",&num_operation);
	char operation[20];
	for(int i=0;i<num_operation;++i){
		scanf("%s",operation);
		//printf("len of operation %d\n",(int)strlen(operation));
		if(operation[0]=='i'){
			scanf("%d",&key);
			insert(key);
		}
		else if(operation[0]=='d'){
            if(strlen(operation)>6){
                if(operation[6]=='F') deleteFirst();
                else if(operation[6]=='L') deleteLast();
            }
			else{
				scanf("%d",&key);
				deleteKey(key);
			}
		}
	}
	printList();
	return 0;
}



Measured memory_bytes: 33828
//#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define int LL
#define db double
using namespace std;
const int N   = 1e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max()>>2;
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int a[N],n,C,x[N],v[N],X,Y,f[N],g,r[N],l[N];
int p[N][20],q[N][20];
int ans;

int query(int l,int r)
{
	if (l>r) return -INF;
	int len=log((double)r-l+1)/log(2.0);
	return max(p[l][len],p[r-(1<<len)+1][len]);
}

signed main()
{
	read(n);read(C);
	rep(i,1,n) read(x[i]),read(v[i]),f[i]=f[i-1]+v[i],l[i]=max(l[i-1],f[i]-2*x[i]);x[n+1]=C;
	for (int i=1;i<=n;++i) r[i]=p[i][0]=f[i]-x[i];
	for (int j=1;j<20;++j)
	  for (int i=1;(i+(1<<j-1))<=n;++i)
	    p[i][j]=max(p[i][j-1],p[i+(1<<j-1)][j-1]);
	for (int i=n+1;i>=1;--i)
	{
		g+=v[i];
		X=C-x[i];
		int pos=lower_bound(x+1,x+i,X)-x;
		ans=max(ans,g-X+max(-X+query(pos,i-1),l[pos-1]));
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 21120
N = int(input())
A = list(map(int,input().split()))
LEFT = A[0]
RIGHT = sum(A[1:])
MIN = abs(LEFT-RIGHT)
for i in range(1,N-1):
    LEFT += A[i]
    RIGHT -= A[i]
    MIN = min(MIN,abs(LEFT-RIGHT))
print(MIN)

Measured memory_bytes: 26268
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        bridges.append((A,B))

    ans = [0] * M
    ans[M-1] = N * (N - 1) // 2
    uni = UnionFind(N)
    for i in range(M-1,0,-1):
        a, b = bridges[i]
        if not uni.same(a, b):
            ans[i-1] = ans[i] - (uni.size(a) * uni.size(b))           
            uni.union(a,b)
        else:
            ans[i-1] = ans[i]
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()

Measured memory_bytes: 98392
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		for(int i=0;i<t;i++){
			BigInteger b = s.nextBigInteger().add(s.nextBigInteger());
			if(b.toString().length()>80){
				System.out.println("overflow");
			}
			else{
				System.out.println(b.toString());
			}
		}
	}
}

Measured memory_bytes: 12000
N,M = (int(i) for i in input().split())
min = 1
max = N

for i in range(M):
    L = list(map(int,input().split()))
    if L[0] > min:
        min = L[0]
    if L[1] < max:
        max = L[1]

if min > max :
    print(0)
else:
    print(max-min+1)


Measured memory_bytes: 45728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
struct UnionFind {
  vector<long> par; 
  vector<long> siz; 
  UnionFind(long N) : par(N),siz(N,1) { 
    rep(i,N) par[i] = i;
  }
  void init(long n) {
    par.resize(n);
    siz.assign(n, 1LL);
    for (long i = 0; i < n; ++i) par[i] = i;
  }
  long root(long x) { 
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(long x, long y) {
    long rx = root(x); 
    long ry = root(y);
    if (rx == ry) return;  
    if (siz[rx] < siz[ry]) swap(rx, ry);
    siz[rx] += siz[ry];
    par[ry] = rx;  
  }
  bool same(long x, long y) {
    long rx = root(x);
    long ry = root(y);
    return rx == ry;
  }
  
  long size(long x) { 
    return siz[root(x)];
  }
};

int main() {
  long n,m,k;
  cin >> n>>m>>k;
  UnionFind tree(n);
  vector<int>d(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    d[a]++;
    d[b]++;
    tree.unite(a,b);
  }
  rep(i,k){
    int c,e;
    cin>>c>>e;
    c--;
    e--;
    if(tree.same(c,e)){
      d[c]++;
      d[e]++;
    }
  }
  rep(i,n){
    cout<<tree.size(i)-d[i]-1<<" ";
  }
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int n,tmp;
	std::vector<int> v;

	std::cin >> n;

	for (int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		v.push_back(tmp);
	}

	sort(v.rbegin(), v.rend());
	if(v[0] < accumulate(next(v.begin()), v.end(), 0)){
		cout << "Yes" << '\n';
	}else{
		cout << "No" << '\n';
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int sumd(int n){
    int res=0;
    while(n>0){
        res=n%10;
        n/=10;
    }
    return res;
}

int main(){
    int N,Y;cin>>N>>Y;
    for(int x=0;x<=N&&10000*x<=Y;x++){
        for(int y=0;x+y<=N&&10000*x+5000*y<=Y;y++){
            int z=N-x-y;
            if(10000*x+5000*y+1000*z==Y){
                cout<<x<<' '<<y<<' '<<z<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
    return 0;
}    

Measured memory_bytes: 504
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
 
(defvar *n* (read))
(defvar *in* (make-array (list *n* 3) :initial-element nil))

(dotimes (i *n*)
  (dotimes (j 3)
    (setf (aref *in* i j) (read))
    ))

;dp[i][j]→i日目に行動jを行うときの最大幸福度
(defvar *dp* (make-array (list *n* 3) :initial-element -1))

(defun ans (i j)
  (cond
    ((< i 0) 0)
    ((<= 0 (aref *dp* i j)) (aref *dp* i j))
    (t (setf (aref *dp* i j) (max
                              (if (equal j 0) 0 (+ (ans (1- i) 0) (aref *in* i j)))
                              (if (equal j 1) 0 (+ (ans (1- i) 1) (aref *in* i j)))
                              (if (equal j 2) 0 (+ (ans (1- i) 2) (aref *in* i j)))
                              )))
    ))
  
(print (max (ans (1- *n*) 0)
			(ans (1- *n*) 1)
			(ans (1- *n*) 2)))


Measured memory_bytes: 70648
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int l[500005],r[500005];
char s[500005];

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,k,c;
	cin>>n>>k>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	int now=-c-1,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(!(s[i]=='x'||i-now<c+1))
		{
			l[++cnt]=i;
			now=i;
		}
	}
	now=n+c+1;
	if(cnt>k)
		return 0;
	int t=cnt;
	for(int i=n;i>=1;i--)
	{
		if(!(s[i]=='x'||now-i<c+1))
		{
			r[cnt--]=i;
			now=i;
		}
	}
	for(int i=1;i<=t;i++)
	{
		if(l[i]==r[i])
		{
			cout<<l[i]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4608
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using i64 = int_fast64_t;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

void solve() {
    int n, k;
    cin >> n >> k;
    V<int> A(n);
    V<int> B(n + 1, 0);
    rep(i, n) {
        cin >> A[i];
        B[A[i]]++;
    }
    V<int> C(0);
    for (auto &b : B) {
        if (b != 0) {
            C.push_back(b);
        }
    }
    sort(C.begin(), C.end());
    int ans = 0;
    if (C.size() <= k) {
        ans = 0;
    } else {
        rep(i, C.size() - k) ans += C[i];
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 5808
N, M = map(int, input().split())
a = []
b = []
ans = 0
for i in range(M):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

current_num = 1
fin_li = [1]
s_li = [[current_num,fin_li]]
while len(s_li) > 0:
    if len(s_li[0][1]) == N:
        ans += 1
    else:
        next_li = [b[i] for i, x in enumerate(a) if x == s_li[0][0]]
        next_li += [a[i] for i, x in enumerate(b) if x == s_li[0][0]]
        next_li = [[x, s_li[0][1]+[x]] for x in next_li if not x in s_li[0][1]]
        s_li += next_li
    s_li.pop(0)

print(ans)

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
ll mod=1e9+7;
using P=pair<int,int>;
struct op{int a,b,c,d;};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,y;cin>>n>>y;
    int d[3]={10000,5000,1000};
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++){
        if(n<i+j)break;
        int k=n-i-j;
        if(10000*i+5000*j+1000*k==y){
            cout<<i<<' '<<j<<' '<<k<<endl;
            return 0;
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll X; cin >> X;
  ll ans = (X / 500) * 1000;
  X %= 500;
  ans += (X / 5) * 5;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main()
{
  int tmp;
  int N;
  int p;
  int i,k = 0;
  scanf("%d/n",&N);
  int K = N;
  int X[N];
  int Y[101];
  while (i < N)
  {
    scanf("%d ",&X[i]);
    i++;
  }
  i = 0;
  while (i < N)
  {
    k = i + 1;
    while (k < N)
    {
      if (X[i] > X[k])
      {
        tmp = X[k];
        X[k] = X[i];
        X[i] = tmp;
      }
      k++;
    }
    i++;
  }
  i = 0;
  k = 0;
  while (i < N)
  {
    //printf("%d\n",X[i]);
    i++;
  }
  K = X[0];
  p = 0;
  while (K <= X[N - 1])
  {
    i = 0;
    Y[p] = 0;
  	while (i < N)
  	{
    	Y[p] += (X[i] - K) * (X[i] - K);
      	//printf("%d\n",Y[K]);
    	i++;
  	}
    //printf("%d\n",Y[p]);
    p++;
    K++;
  }
  i = 0;
  while (i < X[N-1] - X[0])
  {
    k = i + 1;
    while (k < X[N-1] - X[0])
    {
      if (Y[i] > Y[k])
      {
        tmp = Y[k];
        Y[k] = Y[i];
        Y[i] = tmp;
      }
      k++;
    }
    i++;
  }
  printf("%d",Y[0]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin >>N>>X;
  vector<int> LLL(N);
  for(int i=0 ; i<N ;i++){
    cin>>LLL.at(i);
  }
  int count=0;
  int zahyo=0;
  for(int j=0;j<N;j++){
    if(zahyo<=X){
      count++;
    }
    else{
      break;
    }
    zahyo = zahyo + LLL.at(j);
  }
  if(zahyo <= X){
    count ++;
  }
  cout<< count <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s[k-1]=='A') s[k-1] = 'a';
    else if(s[k-1]=='B') s[k-1] = 'b';
    else s[k-1] = 'c';
    OUT(s);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;

int levenshtein_distance(string &S, string &T) {
    int N = sz(S);
    int M = sz(T);
    vvi dp(N + 1, vi(M + 1, INF));
    rep(i, 0, N + 1) dp[i][0] = i;
    rep(i, 0, M + 1) dp[0][i] = i;
    rep(i, 1, N + 1) {
        rep(k, 1, M + 1) {
            dp[i][k] = min({
                dp[i - 1][k] + 1,
                dp[i][k - 1] + 1,
                dp[i - 1][k - 1] + (S[i - 1] != T[k - 1])
            });
        }
    }
    return dp[N][M];
}

signed main() {
    string S, T;
    cin >> S >> T;
    cout << levenshtein_distance(S, T) << endl;
}



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

#define int long long

const long long inf = 1e18;

int solve(vector<deque<int>> &A){
  int N = A.size(), M = A[0].size();
  int res = N;
  vector<int> del(M);

  while(true){
    vector<pair<int,int>> con(M+1);

    con[M] = {-1, M};
    for(int i = 0; i < M; i++){
      con[i].second = i;
    }

    for(int i = 0; i < N; i++){
      // cout<<"<> "<<i<<" "<<A[i].front()<<" size "<<A[i].size()<<endl;
      while(true){
        if(A[i].size() == 0) return res;
        if(del[A[i].front()] == true) {
          A[i].pop_front();
        } else break;
      }

      // cout<<"<> "<<i<<" "<<A[i].front()<<endl;
      con[A[i].front()].first++;
    }

    //string hogehoge; cin>>hogehoge;
    sort(con.begin(), con.end(), greater<pair<int,int>>());
    res = min(res, con.front().first);

    //cout<<"res "<<res<<" con "<<con.front().first<<" size "<<A[0].size()<<endl;

    for(int i = 0; i < M; i++){
      // cout<<"i = "<<i<<" con "<<con[i].first<<" "<<con[i].second<<endl;
      del[con[i].second] = true;
      if(con[i].first != con[i+1].first) break;
    }
  }

  return res;
}

signed main(){

  vector<deque<int>> A;
  int N, M;

  cin>>N>>M;

  A.resize(N, deque<int>(M));

  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin>>A[i][j];
      A[i][j]--;
    }
  }

  cout<<solve(A)<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n, x;
    cin >> n >> x;
    int a[n];
    rep(i, n) cin >> a[i];
    int ans = 0;
    
    rep(i, n-1) {
        if(a[i] + a[i+1] > x) {
            int cur = a[i] + a[i+1] - x;
            if(cur > 0) {
                ans += cur;
                if(a[i] > x) a[i+1] = 0;
                else a[i+1] -= cur;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAXN = 405;

ll n, d, cnt;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> d;
	for(int i=1; i<=n; i++) {
		ll x, y; cin >> x >> y;
		if(d*d >= x*x + y*y) cnt++;
	}
	cout << cnt;
}

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

int main() {
	int h,w,x;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0)
            break;
        while(h > 0){
            x = w;
            while(x > 0){
                cout <<"#";
                x--;
            } 
            cout <<endl;
            h--;
        }
        cout <<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteString(" ")
		}
		fmt.Fprintf(io.writer, "%v", v)
	}
	io.writer.WriteString("\n")
}

func (io *Io) Printfln(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format + "\n", a...)
}

func hasPrefix(s, t string) bool {
	if len(s) < len(t) {
		return false
	}
	return s[:len(t)] == t
}

func main() {
	io := NewIo()
	defer io.Flush()
	s := io.Next()
	kws := []string{"dream", "dreamer", "erase", "eraser"}
	dp := make([]bool, len(s) + 1)
	dp[0] = true
	for i := range s {
		for _, kw := range kws {
			if dp[i] && hasPrefix(s[i:], kw) {
				dp[i + len(kw)] = true
			}
		}

	}
	//io.Println(dp)
	if dp[len(s)] {
		io.Println("YES")
	} else {
		io.Println("NO")
	}
}


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

int main(){
    int n;cin >> n;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int dp[n+1];
    for(int i=0;i<n+1;i++){
        dp[i] = 0;
    }
    dp[1] = abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k,l, tmp, cnt, N, M, cnt2;
LL ans;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;




int main(void) {

	vector<vector<int>> s;
	vector<int> p;


	scanf("%d %d", &N, &M);

	REP(i, M) {
		scanf("%d", &k);
		vector<int> t;
		REP(j, k) {
			scanf("%d", &tmp);
			t.push_back(tmp - 1);
		}
		s.push_back(t);
	}
	REP(i, M) {
		scanf("%d", &tmp);
		p.push_back(tmp);
	}
	int bit;
	FOR(bit, 0, (1 << N)) {
		cnt2 = 0;
		REP(k, M) {//縦方向
			cnt = 0;
			REP(l, s.at(k).size()) {//横方向
				if (((1 << s.at(k).at(l)) & bit) > 0) {
					cnt++;
				}
			}
			if ((cnt % 2) == p.at(k)) {
				cnt2++;
			}
		}

		if (cnt2 == M) {
			ans++;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};
/*_________________________________________________________*/

const long long MOD=1e9+7,N=1e5+5;
int solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	int ans=ceil(n*1.0/x)*t;
	return ans;
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--) 
	//solve();
	cout<<solve()<<endl;
	//cout<<(solve()?"YES":"NO")<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <pll>
#pragma 03
using namespace std;
ll dp[3005][3005];
int main(){
	string s, t;
	cin >> s >> t;
	ll q = s.length(); 
	ll w = t.length();
	for (int i = 0; i<3005; i++){
		for (int j = 0; j<3005; j++) dp[i][j] = 0;
	}
	for (int i = 1; i <= q; i++){
		for (int j = 1; j <= w; j++){
			if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			dp[i][j] = max(dp[i][j], dp[i][j-1]);
		}
	}
	ll index = dp[q][w]; 
   	char lcs[index + 1]; 
   	lcs[index] = '\0'; 
  	int i = q, j = w; 
   	while (i > 0 && j > 0){ 
      	if (s[i-1] == t[j-1]){ 
          	lcs[index-1] = s[i-1]; 
          	i--; j--; index--;    
      	} 
      	else if (dp[i-1][j] > dp[i][j-1]) i--; 
      	else j--; 
   	} 
   	cout << lcs; 
	return 0;
}
 


Measured memory_bytes: 70784
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char f(const char *d, int a){
	while(a!=0){
		int b=a%10;
		if(d[b]!=0) return -1;
		a=a/10;
	}
	return 0;
}

int main(void){
	int n, k, i;
	char d[10];
	memset(d, 0, sizeof(d));
	scanf("%d%d", &n, &k);
	for(i=0; i<k; i++){
		int D;
		scanf("%d", &D);
		d[D]=1;
	}
	for(i=n; ; i++){
		if(f(d, i)==0){
			printf("%d\n", i);
			return 0;
		}
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int M, D;
  cin >> M >> D;
  int result = 0;
  for (int i = 1; i <= M; ++i) {
    for (int j = 22; j <= D; ++j) {
      int num = j;
      int d10 = num / 10;
      int d1 = num - d10 * 10;
      if (d10 < 2 || d1 < 2) {
        continue;
      }
      if (d10 * d1 == i) {
        ++result;
      }
    }
  }
  cout << result << endl;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;

int n;
int a[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	ll res = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i && a[i])
			a[i] += a[i - 1] % 2;
		res += a[i] / 2;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] arrayInput = new  int[r][c];

		int x = r+1;
		int y = c+1;

		int[][] arrayOutput = new  int[x][y];


		//?????????????????\???????????????
		for(int i = 0; i < r; i++) {
			for(int j = 0; j < c; j++) {
				arrayInput[i][j] = sc.nextInt();
			}
		}


		//??????????¨?????±???????
		int Sum = 0;
		int Num = 0;
		for(int i = 0; i < x; i++) {
			for(int j = 0; j < y; j++) {

				if(!(i+1 == x) && !( j+1 == y )) {
					arrayOutput[i][j] = arrayInput[i][j];
				}

				else if(j+1 == y) {
					for(int k=0; k < y-1; k++) {
						Num = arrayOutput[i][k];
						Sum = Sum + Num;
					}
					arrayOutput[i][j] = Sum;
					Num = 0;
					Sum = 0;
				}
			}
		}

		//??????????¨?????±???????
				int Sum1 = 0;
				int Num1 = 0;
				for(int j = 0; j < y; j++) {
					for(int i = 0; i < x; i++) {

						if(i+1 == x) {
							for(int k=0; k < x-1; k++) {
								Num1 = arrayOutput[k][j];
								Sum1 = Sum1 + Num1;
							}
							arrayOutput[i][j] = Sum1;
							Num1 = 0;
							Sum1 = 0;
						}
					}
				}

		//?????????????????????
		for(int i = 0; i < x; i++) {
			for(int j = 0; j < y; j++) {

				if(j+1 == y) {
					System.out.print(arrayOutput[i][j]);
				}
				else {
					System.out.print(arrayOutput[i][j]+" ");
				}

			}
			System.out.println("");
		}


	}
}

Measured memory_bytes: 42300
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <vector>

using namespace std;

int main(){

  int n;
  cin >> n;
  int* x = new int[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }

  int m=1;
  int count=1;
  while(true){
    m = m*2;
    if(m>n/2) break;
    count++;
  }
  int* g = new int[count];
  int gi = 1;
  g[0] = gi;
  for(int i=1;i<count;i++){
    gi *= 2;
    g[i] = gi;
  }

  m = count;
  count = 0;
  for(int i=0;i<m;i++){
    for(int j=g[m-1-i];j<n;j++){
      int v = x[j];
      int k = j - g[m-1-i];
      while( k>=0 && x[k] > v){
        x[k+g[m-1-i]] = x[k];
        k = k - g[m-1-i];
        count++;
      }
      x[k+g[m-1-i]] = v;
    }
  }

  cout << m << endl;
  for(int i=0;i<m;i++){
    cout << g[m-1-i];
    if(i == m-1 ) cout << endl;
    else cout << " ";
  }
  cout << count << endl;
  for(int i=0;i<n;i++){
    cout << x[i] << endl;
  }

}



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

int
main(int argc, char *argv[])
{
  ll n, a[6];
  scanf("%lld", &n);
  for(int i = 0; i < 5; ++i) scanf("%lld", &a[i]);

  ll m = a[0];
  int k = 0;
  for(int i = 1; i < 5; ++i){
    if(m > a[i]){
      m = a[i];
      k = i;
    }
  }

  ll t = (ll)k + (n - 1)/m + (5 - (ll)k);
  printf("%lld\n", t);

  return 0;

}
  


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

using namespace std;

int main() {
	int n;
	cin >> n;
	int R[n];
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}

	//?????????????°??????????
	int minv = R[0];
	//???????????§????????§??????
	int maxv = -1000000001;
	for (int i = 1; i < n; i++) {
		if (maxv < R[i] - minv) {
			maxv = R[i] - minv;
		}
		if (R[i] < minv) {
			minv = R[i];
		}
	}

	cout << maxv << endl;
}

Measured memory_bytes: 3824
# dp[i][j]=(i枚目のコインまで投げたとき、表がj枚でる確率)

# dp[i][j]=(i−1枚目のコインまで投げたとき、表がj枚でる確率)
# 								×(i枚目のコインが裏である確率)
# 		+(i−1枚目のコインまで投げたとき、表がj−1枚でる確率)
# 								×(i枚目のコインが表である確率)

N = int(input())
p = [0] + list(map(float, input().split()))
dp = [[0 for _ in range(N + 1)]for _ in range(N + 1)]
# print(dp)

# 0枚投げた時、表が0枚出る確率
dp[0][0] = 1

for i in range(1, N + 1):
    for j in range(0, i + 1):

        if j > 0:  # i枚目が裏の場合, i枚目が表の場合
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i]
        else:
            dp[i][j] = dp[i - 1][j] * (1 - p[i])

ans = 0
# 条件を満たす表の数は、(N+1)//2, ..., N
for j in range((N + 1) // 2, N + 1):
    ans += dp[N][j]

print(ans)


Measured memory_bytes: 223932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

template<typename T> inline void chmin(T &a, T b){
	if(a > b) a = b;
}


int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	const int inf = 1001001001; 
	vector<int> dp(h+1, inf); // dp[i] : HPがiのときの最小消費魔力
	dp[h] = 0;
	for(int i = h; i >= 0; i--){ // 各HPについて
		if(dp[i] == inf) continue;
		rep(j, n){ // 各魔法を試す
			int next_hp = i - a[j];
			if(next_hp < 0) next_hp = 0;
			chmin(dp[next_hp], dp[i] + b[j]);
		}
	}
	
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
int main() {
	int w[100] = {};
	int n = 0;
	int a = 0;//goukei
	int ans[2] = {};
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
		a += w[i];
	}
	int half = a / 2;
	int i = 0;
	for (i = 0; half > 0; ++i) {
		half -= w[i];
		ans[0] += w[i];
	}
	half = a / 2;
	for (i = n-1; half > 0; --i) {
		half -= w[i];
		ans[1] += w[i];
	}
	if (abs(ans[0] - (a - ans[0])) < abs(ans[1] - (a - ans[1]))) {
		cout << abs(ans[0] - (a - ans[0]));
	}
	else {
		cout << abs(ans[1] - (a - ans[1]));
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200005
using namespace std;
int main() {
	int r,d,x;
	cin>>r>>d>>x;
	ll ans=r*x-d;
	rep(i,1,10){
		cout<<ans<<"\n";
		ans=ans*r-d;
	}
	re 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long n, a, b, K; vector<pair<long long, long long>>vec;
int main() {
	cin >> n >> K;
	for (int i = 0; i < n; i++) {
		cin >> a >> b; vec.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < vec.size(); i++) {
		K -= vec[i].second;
		if (K <= 0) { cout << vec[i].first << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 3444
#include <stdio.h>

struct DICE {
int mark1,mark2,mark3,mark4,mark5,mark6;
};

void MoveDice(struct DICE *p,char c);
void SpinDice(struct DICE *p,char c);

int main()
{
struct DICE p;int cnt,flagup,flagah,up,ahead,num,i;

scanf("%d %d %d %d %d %d",&p.mark1,&p.mark2,&p.mark3,&p.mark4,&p.mark5,&p.mark6);
scanf("%d", &num);
i=1;
while(i<=num){
 scanf("%d %d",&up,&ahead);
 cnt=0;flagup=0;

 while((flagup==0)&&(cnt<=3)){
  if(p.mark1==up){
   flagup=1;
  }else{
   MoveDice(&p,'W');
   cnt++;
  }
 }
 if(flagup==0){
  MoveDice(&p,'N'); 
  if(p.mark1==up){
   flagup=1;
  }else{
   MoveDice(&p,'N'); 
   MoveDice(&p,'N'); 
   flagup=1; 
  }
 }
 flagah=0;
 while(flagah==0){
  if(p.mark2==ahead){
   flagah=1;
  }else{
   SpinDice(&p,'R');
  }
 }
printf("%d\n",p.mark3);
i++;
}

return 0;
}

void MoveDice(struct DICE *p,char c){
int tmp;
tmp=p->mark1;
switch(c){
case 'W':
p->mark1=p->mark3;p->mark3=p->mark6;p->mark6=p->mark4;p->mark4=tmp;
break;
case 'E':
p->mark1=p->mark4;p->mark4=p->mark6;p->mark6=p->mark3;p->mark3=tmp;
break;
case 'N':
p->mark1=p->mark2;p->mark2=p->mark6;p->mark6=p->mark5;p->mark5=tmp;
break;
case 'S':
p->mark1=p->mark5;p->mark5=p->mark6;p->mark6=p->mark2;p->mark2=tmp;
break;
}
}
void SpinDice(struct DICE *p,char c){
if (c=='R'){
MoveDice(p,'W');
MoveDice(p,'S');
MoveDice(p,'E');
}else{
MoveDice(p,'W');
MoveDice(p,'N');
MoveDice(p,'E');
}
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
char s[210];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int i,j,k,m,n;
    int a,b;
    ll cnt=1;
    cin>>a>>b;
    if(abs(a-b)>1)
        cnt=0;
    else if(a==b)
    {
        for(i=1;i<=a;i++)
        {
            cnt=(cnt*i)%mod;
        }
        cnt=(cnt*cnt)%mod;
        cnt=(cnt*2)%mod;
    }
    else if(a==b+1)
    {
        for(i=1;i<=b;i++)
        {
            cnt=(cnt*i)%mod;
        }
        cnt=(cnt*cnt)%mod;
        cnt=(cnt*(b+1))%mod;
    }
    else if(a+1==b)
    {
        for(i=1;i<=a;i++)
        {
            cnt=(cnt*i)%mod;
        }
        cnt=(cnt*cnt)%mod;
        cnt=(cnt*(a+1))%mod;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[100];
  int alice=0;
  int bob=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1;j++){
      if(a[j]>a[j+1]){
        int s=a[j];
        a[j]=a[j+1];
        a[j+1]=s;
      }
    }
  }
  
  
  if(n%2==0){
    for (int i=0;i<n;i++){
      if(i%2==1) alice+=a[i];
      else bob+=a[i];
    }
  }
  
  else{
    for (int i=0;i<n;i++){
      if(i%2==0) alice+=a[i];
      else bob+=a[i];
    }
  }
  
  cout << alice-bob << endl;
}
    
    
    
    
    
  

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	int payed;
	int min;
	int max;
	int price;
	
	cin >> payed;
	price = payed /1.08;
	min = (price - 1);
	max = (price + 1);
	int price1 = price*1.08;
	int max1 = max*1.08;
	int min1 = min*1.08;
	if(price1 == payed){
		cout << price << "\n";
	}
	else if(max1 == payed){
		cout << max << "\n";
	}
	else if(min1 == payed){
		cout << min << "\n";
	}
	else{
		cout << ":(\n";
	}
	
}


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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9+7;
const ll INF = 1<<30;

ll x, y;

ll extended_euclid(ll a, ll b){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	else{
		ll g = extended_euclid(b, a%b);
		/*
			bx + y(a-a/b*b)
			ay + b(x-a/b*y)

		*/
		ll tmp = x;
		x = y;
		y = tmp-a/b*y;
		return g;
	}
}

ll inverse(ll a){
	ll g = extended_euclid(a, MOD);
	while(x<0)
		x+=MOD;
	return x;
}

int main(){
	vector<ull> f;
	int r1, r2, c1, c2;
	
	cin>>r1>>c1>>r2>>c2;
	
	f.assign(r2+c2+5, 1);
	for(int i=1;i<=r2+c2+4;i++)
		f[i] = (f[i-1]*i)%MOD;

	ull ans = 0;
	for(int r=r1;r<=r2;r++){

		//cout<<r<<" : ";

		ull tmp1 = f[r+c2+1];
		//cout<<tmp1<<" ";
		tmp1 = (tmp1*inverse(f[r+1]))%MOD;
		//cout<<tmp1<<" ";
		tmp1 = (tmp1*inverse(f[c2]))%MOD;
		//cout<<tmp1<<" ";

		ull tmp2 = f[r+c1];
		//cout<<tmp2<<" ";
		tmp2 = (tmp2*inverse(f[r+1]))%MOD;
		//cout<<tmp2<<" ";
		tmp2 = (tmp2*inverse(f[c1-1]))%MOD;
		//cout<<tmp2<<"\n";

		ans = (ans+tmp1)%MOD;
		while(ans<tmp2)
			ans += MOD;

		ans = (ans-tmp2)%MOD;
	}

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 15872
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!int;
    auto a = readln.split.to!(long[]);
    sort(a).group.map!(g => g[1] >= g[0] ? g[1] - g[0] : g[1]).sum.writeln;
}



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

#define ipow(a,b)+0.5 (int)pow(a,b)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fi first
#define se second

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

using namespace std;
typedef long long ll;
typedef long double ld;

class Task
{
public:
    void solve(istream& in,ostream& out)
    {
        int n,l;
        in>>n>>l;
        string a[n];

        rep(i,n)
        {
            in>>a[i];
        }

        sort(a,a+n);
        string res="";

        rep(i,n)
        {
            res+=a[i];
        }

        out<<res<<endl;
    }
};


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in,out);
	out.flush();

    return 0;
}





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

const ll INF = 1e+18;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    ll ans = INF;
    ll sum = 0;
    ll cnt = 0;
    // S_odd > 0, S_even < 0
    for(int i = 1; i <= n; i++){
        sum += a[i-1];
        if(i % 2 && sum <= 0){
            cnt += -sum + 1;
            sum = 1;
        } else if(i % 2 == 0 && sum > 0){
            cnt += sum + 1;
            sum = -1;
        }
    }
    ans = min(ans, cnt);

    sum = cnt = 0;
    // S_odd < 0, S_even > 0
    for(int i = 1; i <= n; i++){
        sum += a[i-1];
        if(i % 2 && sum >= 0){
            cnt += sum + 1;
            sum = -1;
        } else if(i % 2 == 0 && sum <= 0){
            cnt += -sum + 1;
            sum = 1;
        }
    }
    ans = min(ans, cnt);

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char s[12345];
int main(){
	scanf("%s",s);
	int len = strlen(s);
	long long ans =0;
	for(int t =0;t<(1<<(len-1));t++){
		long long num=s[0]-'0';
		for(int i= 0;i<len-1;i++){
			if(t&(1<<i)){
				ans+=num;
				num = 0;
			}
			num = num*10+s[i+1]-'0';
		}
		ans+=num;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<set>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(){
  ll h,w;
  string ah,aw;
  cin >> h >> w;
  string s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
      if(s[i][j]=="snuke"){
        ah = to_string(i+1);
        aw = 'A'+j;
      }
    }
  }
  cout << aw<<ah<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a > b) cout << b;
    else cout << n*a;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

string s;

int main(){
  while(cin >> s){
    for(int i = 0; i < s.length(); i+=2){
      char c1 = s[i], c2 = s[i+1];
      
      if(c1 == '0' && c2 == 'U') cout << "nn";
      else{
	if(c1 == '2') cout << "k";
	if(c1 == '3') cout << "s";
	if(c1 == '4') cout << "t";
	if(c1 == '5') cout << "n";
	if(c1 == '6') cout << "h";
	if(c1 == '7') cout << "m";
	if(c1 == '8') cout << "y";
	if(c1 == '9') cout << "r";
	if(c1 == '0') cout << "w";

	if(c2 == 'T') cout << "a";
	if(c2 == 'L') cout << "i";
	if(c2 == 'U') cout << "u";
	if(c2 == 'R') cout << "e";
	if(c2 == 'D') cout << "o";
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
from collections import defaultdict,Counter

N = int(input())
S = [str(input())for _ in range(N)]
D = defaultdict(int)

for s in S:
  cur = sorted(s)
  cur = "".join(map(str,cur))
  D[cur] += 1
cnt = 0
for c in D.values():
  cnt += c*(c-1)//2
ans = cnt
print(ans)

Measured memory_bytes: 29468
wo=0
ho=0
w,h,n=map(int, input().split())

for i in range(n):
    x,y,a=map(int, input().split())
    if a==1: wo=max(wo, x)
    if a==2: w=min(w, x)
    if a==3: ho=max(ho, y)
    if a==4: h=min(h, y)

ans=(w-wo)*(h-ho)

if wo>=w or ho>=h: print(0)
else: print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(void){
 
  char str[1000];
  long axisa, axisb, movea, moveb, time, judge = 0;
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld %ld", &axisa, &movea);
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld %ld", &axisb, &moveb);
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld", &time);
  
  if(axisa < axisb) {
    if(axisa + movea * time >= axisb + moveb * time ){
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  } else {
    if(axisa - movea * time <= axisb - moveb * time ){
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1604
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll M;
    cin >> M;
    ll x, y;
    ll ketasu = 0, sum = 0;
    REP(i, M) {
        cin >> x >> y;
        ketasu += y;
        sum += x*y;
    }

    cout << (ketasu-1) + (sum-1)/9 << endl;




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

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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	string s;
	cin >> s;
	int ans = sz(s) - 1;
	for (char i = 'a'; i <= 'z'; i ++)
	{
		vector <int> v;
		for (int j = 0; j < sz(s); j ++)
			if (s[j] == i)
				v.PB(j);
		if (!sz(v))
			continue;
		int x = max(v[0], sz(s) - v[sz(v) - 1] - 1);
		for (int j = 1; j < sz(v); j ++)
			smax(x, v[j] - v[j - 1] - 1);
		smin(ans, x);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256