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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

string l = "qwertasdfgzxcvb";

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s && s != "#"){
    bool f = find(all(l),s[0]) != l.end();
    ll cnt = 0;
    rep(i,s.size()){
      if(f != (find(all(l),s[i]) != l.end())){
        f = !f;
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 1000;
    ans = min(ans, abs(a-b)+abs(c-b));
    ans = min(ans, abs(b-a)+abs(c-a));
    ans = min(ans, abs(a-c)+abs(b-c));
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	double p = 1. / n, ans = 0.;
	double log2k = log2(k);
	if (n >= k) {
		ans += (n - k + 1) * p;
		for(int i = 1;i < k;++i) {
			double q = p, e = log2k - log2(i);
			int a = ceil(e);
			q *= pow(1 / 2., a);
			ans += q;
		}
	}
	else {
		for(int i = 1;i <= n;++i){
			double q = p, e = log2k - log2(i);
			int a = ceil(e);
			q *= pow(1 / 2., a);
			ans += q;
		}
	}
	cout << setprecision(9) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	s_list = list(S())
	x = 0
	x_max = 0
	for s in s_list:
		if s == 'I':
			x += 1
		else:
			x -= 1
		x_max = max(x, x_max)
	print(x_max)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27064
#include <stdio.h>
#include <stdlib.h>
#define K 10000

int main(){

  int i,j;
  int len,C[K+1];
  unsigned short *A,*B;

  scanf("%d",&len);
  A=malloc(sizeof(short)*len+1);
  B=malloc(sizeof(short)*len+1);

  for(i=0;i<=K;i++) C[i]=0;

  for(i=0;i<len;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
}

  for(i=0;i<=K;i++){
  C[i]+=C[i-1];
}

  for(j=1;j<=len;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=len-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);

  /*for ( i = 1; i <= len; i++ ){
  if ( i > 1 ) printf(" ");
  printf("%d", B[i]);
}
printf("\n");*/
  return 0;
}

Measured memory_bytes: 8460
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b>=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m,c=gets.split.map(&:to_i)
bNumbers = gets.split.map(&:to_i)
correctCount = 0
n.times do
  tempNumbers = gets.split.map(&:to_i)
  sum = c
  m.times.map{|index| sum += tempNumbers[index] * bNumbers[index]}
  correctCount += 1 if sum > 0
end
puts correctCount

Measured memory_bytes: 1788
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node{int p,l,r;};
struct Node T[MAX];
int n;
void preParse(int u){
 if(u==NIL)return;
 printf(" %d",u);
 preParse(T[u].l);
 preParse(T[u].r);
}
void inParse(int u){
 if(u==NIL)return;
 inParse(T[u].l);
 printf(" %d",u);
 inParse(T[u].r);
}
void postParse(int u){
 if(u==NIL)return;
 postParse(T[u].l);
 postParse(T[u].r);
 printf(" %d",u);
}
int main(){
 int i,v,l,r,root;
 scanf("%d",&n);
 for(i=0;i<n;i++)T[i].p=NIL;
 for(i=0;i<n;i++){
  scanf("%d %d %d",&v,&l,&r);
  T[v].l=l;
  T[v].r=r;
  if(l!=NIL)T[l].p=v;
  if(r!=NIL)T[r].p=v;
 }
 for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
 printf("Preorder\n");
 preParse(root);
 printf("\n");
 printf("Inorder\n");
 inParse(root);
 printf("\n");
 printf("Postorder\n");
 postParse(root);
 printf("\n");
 return 0;
}


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

int main()
{
   int a,b;
   cin>>a>>b;
   
   if(a==b){
   	cout<<"Draw";
   	return 0;
   }
   
   if(a==1 && b!=1){
   	cout<<"Alice";
   	return 0;
   }
   
   if(b==1 && a!=1){
   	cout<<"Bob";
   	return 0;
   }
   
   if(a>b){
   	cout<<"Alice";
   	return 0;
   }
   else
   cout<<"Bob";
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;
using ll = long long;


int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());

    ll s = accumulate(all(a), 0ll);
    ll border = (s + 4 * m - 1) / (4 * m);
    bool ok = true;
    rep(i, m) {
        if (a[i] < border) ok = false;
    }
    Yes(ok);
}


Measured memory_bytes: 256
from collections import deque


def main():
    n, m = map(int, input().split())
    adj = [[] for _ in range(n)]

    for _ in range(m):
        a, b = map(int, input().split())
        adj[a - 1].append(b - 1)
        adj[b - 1].append(a - 1)

    ans = 0
    visited = [False] * n

    for i in range(n):
        if visited[i]:
            continue

        q = deque()
        q.append(i)
        cnt = 1
        visited[i] = True

        while q:
            u = q.popleft()
            for v in adj[u]:
                if not visited[v]:
                    q.append(v)
                    cnt += 1
                    visited[v] = True
            ans = max(ans, cnt)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
int main()
{
	int n, q,t;
	int elaps = 0;
	string name;
	queue< pair<string,int> > Q;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		cin >> name >> t;
		Q.push(make_pair(name,t));
	}
	pair<string,int> u;
	while(!Q.empty()){
		u = Q.front(); Q.pop();
		int cost = min(q,u.second);
		u.second -= cost;
		elaps += cost;
		if(u.second <= 0){
			cout << u.first << " " << elaps << endl;
		}
		else{
			Q.push(u);
		}
	}
	
 } 


Measured memory_bytes: 6292
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, st, dr, mid, i, j, sol;
int v[200005];
int verif(int p){
    for(int i = p * 2 + 1, j = 2 * n; i < j; i++, j--){
        if(v[i] + v[j] < m){
            return 0;
        }
    }
    return 1;
}
int main(){
    cin>> n >> m;
    for(i = 1; i <= n + n; i++){
        cin>> v[i];
    }
    sort(v + 1, v + 2 * n + 1);
    st = 0;
    dr = n;
    while(st <= dr){
        mid = (st + dr) / 2;
        if(verif(mid)){
            dr = mid - 1;
        }
        else{
            st = mid + 1;
        }
    }
    for(i = 1, j = 2 * st; i < j; i++, j--){
        sol = max(sol, v[i] + v[j]);
    }
    for(i = 2 * st + 1, j = 2 * n; i < j; i++, j--){
        sol = max(sol, v[i] + v[j] - m);
    }
    cout<< sol;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

int n;
ll a[220000];
vector<int> g[220000];

int dp[220000];
int ans[220000];

void dfs(int now, int par = -1)
{
    if (ans[now] != -1) return;
    auto it = lower_bound(dp, dp + n, a[now]);
    int tmp = *it;
    *it = a[now];
    ans[now] = lower_bound(dp, dp + n, inf) - dp;
    for (auto &nxt: g[now]) {
        if (nxt == par) continue;
        dfs(nxt, now);
    }
    *it = tmp;
}

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

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v; u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    memset(dp, 0x3f, sizeof(dp));
    memset(ans, 0xff, sizeof(ans));

    dfs(0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 29728
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#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 RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  cout << n*(n-1)/2 + m*(m-1)/2 << endl;

  return 0;
}

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

const int N = 200000;

int n, a[N];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
        a[i] -= i;
    }
    std::sort(a, a + n);
    long long result = 0;
    int mid = a[n / 2];
    for (int i = 0; i < n; ++ i) {
        result += std::abs(a[i] - mid);
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 1024
N,M,L = map(int, input().split())
A = [0]*M
B = [0]*M
C = [0]*M
for i in range(M):
    A[i], B[i], C[i] = map(int, input().split())
    
Q = int(input())
qlist = [[int(q) for q in input().split()] for _ in range(Q)]

INF = 10**18
d = [[INF]*N for _ in range(N)]
for i in range(M):
    d[A[i]-1][B[i]-1] = C[i]
    d[B[i]-1][A[i]-1] = C[i]

for i in range(N):
    d[i][i] = 0
        

# Warshall-Floyd法
# DP
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

d2 = [[INF]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            d2[i][j] = 0
        elif d[i][j] <= L:
            d2[i][j] = 1
            
for k in range(N):
    for i in range(N):
        for j in range(N):
            d2[i][j] = min(d2[i][j], d2[i][k]+d2[k][j])
                
for i in range(Q):
    s = qlist[i][0]-1
    t = qlist[i][1]-1
    ans = d2[s][t]
    if ans >= INF:
        print(-1)
    else:
        print(ans-1)

Measured memory_bytes: 77272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i=0; i < N ; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans =0;
  for (int i=0; i < N ; i++){
    x -= a.at(i);
    if ( x >= 0){
      ans++;
    }
    else break;
  }
  if (x > 0 ) ans--;
  
  cout << ans << endl;
} 


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

using namespace std;

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

    int N;
    cin >> N;

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

    sort(A, A + N, greater<int>());

    int alice = 0, bob = 0;
    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 <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n,a,ans = 0;
	cin >> n;
	REP(i, n) {
		cin >> a;
		while (a % 2 == 0) {
			ans++;
			a = a / 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n,W=map(int,input().split())
w_list=[0]
v_list=[0]
for i in range(n):
    w,v=map(int,input().split())
    w_list.append(w)
    v_list.append(v)
dp=[]
for i in range(n+1):
    sub_list=[]
    for j in range(W+1):
        sub_list.append(0)
    dp.append(sub_list)
for i in range(1,n+1):
    for j in range(W+1):
        if j>=w_list[i]:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w_list[i]]+v_list[i])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[n][W])


Measured memory_bytes: 142412
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, m;
bool z[100005];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    int a, b;
    cin >> a >> b;
    z[a] ^= true;
    z[b] ^= true;
  }
  FOR(i, 1, n+1){
    if(z[i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 384
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,pll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
ld m = 1;

void solve(){
    cin>>n>>m;
    ll ans = n*m;
    deb1(ans)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }

}

Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <stdlib.h>
#define inf 1e9

using namespace std;

int n;
int c[4];
int l[10];
vector<int> vec[4];

int main(void)
{
	cin >> n;
	cin >> c[1] >> c[2] >> c[3];
	for(int i = 0; i < n; i++) cin >> l[i];
	
	int ans = inf;
	int N = (1 << (2*n));
	for(int i = 0; i < N; i++){
		for(int j = 1; j < 4; j++) vec[j].clear();
		for(int t = i, j = 0; t; t/=4, j++){
			if(t%4) vec[t%4].push_back(l[j]);
		}
		int tmp = 0;
		for(int j = 1; j < 4; j++){
			int sum = 0;
			if(vec[j].size() == 0) goto end;
			for(int k = 0; k < vec[j].size(); k++) sum += vec[j][k];
			tmp += abs(sum - c[j]) + 10 * (vec[j].size()-1);
		}
		ans = min(ans, tmp);
		end:;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import math

while True:
    n = int(input())
    if n == 0:
        break
    data = list(map(int,input().split()))
    m = sum(data)
    m = m / n
    
    x = 0
    a = 0
    for i in range(n):
        S = data[x]
        X = (S - m)**2 / n
        a = a + X
        x = x + 1
    
    print(math.sqrt(a))


Measured memory_bytes: 5700
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
  
int main() {
  	int m,f,r;
 	while(true){
    	cin>>m>>f>>r;
    	if(m==-1 && f==-1 && r==-1) break;
    	if(m==-1 || f==-1){ cout<<"F"<<endl; continue;}
      	if(m+f>=80){ cout<<"A"<<endl; continue;}
        if(m+f>=65 && m+f<80 ){ cout<<"B"<<endl; continue;}
        if(m+f>=50 && m+f<65 ){ cout<<"C"<<endl; continue;}
        if(m+f>=30 && m+f<50 && r>=50){ cout<<"C"<<endl; continue;}
        if(m+f>=30 && m+f<50 && r<50){ cout<<"D"<<endl; continue;}
        if(m+f<30 && m+f>=0){ cout<<"F"<<endl; continue;}
    }
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main() {
	char a[100],x;
	bool r = true;
	for (int i = 0; i < 4; i++)
		cin >> a[i];
	x = a[0];
	for (int i = 1; i < 4; i++) {
		if (x == a[i]) {
			r = false;
			break;
		}
		else x = a[i];
	}
	cout << (r ? "Good" : "Bad") << endl;
	return 0;
}

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

import sys, os
def ac_input(*args):
    return map(int, input().split())


def main():
    a = input()
    ans = int(a) * int(a) * int(a)
    print(ans)

if __name__ == "__main__" :
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int l,r,ll,rr,x,min=2020;
    int i,j;
    scanf("%d %d",&l,&r);
    ll=l%2019;
    rr=r%2019;
    if(ll>=rr||(r-l)>=2019)rr+=2019;

    for(int i=ll;i<=rr;i++)
    {
        for(j=i+1;j<=rr;j++)
        {
            x=(i*j)%2019;
            if(x<=min)min=x;
        }
    }

    printf("%d",min);
}



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

int main(){
    long long A; cin >> A;
    double B; cin >> B;

    B *= 100;
    long long hoge = B+0.9;

    A *= hoge;
    A /= 100;
    cout << A << endl;

}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

intt N;

intt func(intt& p) {
	return p * (p - 1) / 2;
}

int main() {
	std::cin >> N;
	intt ans = 0;
	std::vector<intt> A(N);
	std::map<intt, intt> MAP;
	for (auto& r : A) {
		std::cin >> r;
		++MAP[r];
	}
	for (auto& r : MAP)
		if (r.second > 1) {
			ans += func(r.second);
		}
	for (intt i = 0; i < N; ++i) {
		if (MAP[A[i]] > 1) {
			intt l = func(MAP[A[i]]);
			--MAP[A[i]];
			intt r = func(MAP[A[i]]);
			std::cout << ans - l + r << std::endl;
			++MAP[A[i]];
		}
		else
			std::cout << ans << std::endl;
	}


	return 0;
}

Measured memory_bytes: 12724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node(i);

    for (int i = 0; i < N - 1; i++) {
      int x = scanner.nextInt() - 1;
      int y = scanner.nextInt() - 1;
      nodes[x].adjacent.add(nodes[y]);
      nodes[y].adjacent.add(nodes[x]);
    }

    long[] dp = new long[N];
    dfs1(nodes[0], dp, M);
    for (int i = 0; i < N; i++) nodes[i].visited = false;
    dfs2(nodes[0], 1, dp, M);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) sb.append(dp[i]).append('\n');
    System.out.println(sb.toString());
  }

  private static void dfs2(Node node, long parent, long[] dp, long M) {
    node.visited = true;
    dp[node.id] = parent;
    for (Node a : node.adjacent) {
      if (!a.visited) {
        dp[node.id] *= (dp[a.id] + 1) % M;
        dp[node.id] %= M;
      }
    }
    List<Node> children = node.adjacent.stream().filter(n -> !n.visited).collect(Collectors.toList());
    long[] acc1 = new long[children.size() + 1];
    long[] acc2 = new long[children.size() + 1];
    acc1[0] = 1;
    acc2[children.size()] = 1;
    for (int i = 1; i <= children.size(); i++) {
      acc1[i] = acc1[i - 1] * ((dp[children.get(i - 1).id] + 1) % M);
      acc1[i] %= M;
      acc2[children.size() - i] = acc2[children.size() - i + 1] * ((dp[children.get(children.size() - i).id] + 1) % M);
      acc2[children.size() - i] %= M;
    }
    for (int i = 0; i < children.size(); i++) {
      long a = acc1[i] * acc2[i + 1];
      a %= M;
      a *= parent;
      a %= M;
      a++;
      a %= M;
      dfs2(children.get(i), a, dp, M);
    }
  }

  private static void dfs1(Node node, long[] dp, long M) {
    node.visited = true;
    dp[node.id] = 1;
    for (Node a : node.adjacent) {
      if (!a.visited) {
        dfs1(a, dp, M);
        dp[node.id] *= (dp[a.id] + 1) % M;
        dp[node.id] %= M;
      }
    }
  }

  private static class Node {
    public final int id;
    public boolean visited;
    public List<Node> adjacent = new ArrayList<>();

    private Node(int id) {
      this.id = id;
    }
  }
}


Measured memory_bytes: 133588
#include<iostream>
#include<string>
#include<algorithm>
 
int main(){
  int count=0;
  std::string W;
  std::cin>>W;
  std::string str;
  while(1){
    std::cin>>str;
    if(str=="END_OF_TEXT")break;
    std::transform(str.begin(),str.end(),str.begin(),tolower);
    if(str==W){
      count++;
    }
  }
  std::cout<<count<<std::endl;
  return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b;
  int x,y,z;
  cin >> a >> b;
  x = (a + b) * 10 / 2;
  y = x % 2;
  z = x/10;
  cout << z+y << endl;
}

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

int main(){
    
    size_t n;
    std::cin >> n;

    std::vector<size_t> a(n);

    for(auto&& e : a){
        std::cin >> e;
    }

    auto tmp = a;
    std::sort(tmp.begin(), tmp.end());
    auto max = tmp.at(tmp.size() - 1);
    auto max_1 = tmp.at(tmp.size() - 2);

    for(const auto& e : a){
        if(e == max){
            std::cout << max_1 << std::endl;
        }else{
            std::cout << max << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int big = 200;
int small = 195;

int CalcTime(int y,int m,int d){
	int sum = 0;
	//??´
	for (int i = 1; i < y; i++){
		if (i%3 == 0){
			sum += 200;
		}
		else{
			sum += 195;
		}
	}
	//???
	if (y%3 == 0){
		sum += 20 * (m - 1);
	}
	else{
		for (int i = 1; i < m; i++){
			if (i%2 == 0){
				sum += 19;
			}
			else{
				sum += 20;
			}
		}
	}
	//??\
	sum += d;
	return sum;
}

int main(){
	int n;
	int y, m, d;
	int millennium = CalcTime(1000,1,1);
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> y >> m >> d;
		cout << millennium - CalcTime(y,m,d) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cstdint>

template<std::uint_fast64_t Mod>
class ModInt{
    using u64 = uint_fast64_t;
public:
    u64 num;
    constexpr ModInt(const u64 x = 0) noexcept : num(x % Mod) {}
    constexpr u64 &value() noexcept { return num; }
    constexpr const u64 &value() const noexcept { return num; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        num += rhs.num;
        if (num >= Mod) {
            num -= Mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (num < rhs.num) {
            num += Mod;
        }
        num -= rhs.num;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        num = num * rhs.num % Mod;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Mod - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr ModInt &operator=(const u64 num) noexcept {
        this->num = num % Mod;
        return this->num;
    }
};

template<std::uint_fast64_t Mod>
std::ostream &operator<<(std::ostream &out, const ModInt<Mod> &m)
{
    out << m.num;
    return out;
}

template<std::uint_fast64_t Mod>
std::istream &operator>>(std::istream &in, ModInt<Mod> &m)
{
    in >> m.num;
    if(m.num >= Mod){
        m.num %= Mod;
    }
    return in;
}

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    constexpr int MOD = 1e9 + 7;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    ModInt<MOD> ans = 0;
    for(int i = 0; i < n; i++){
        ModInt<MOD> left = 0, right = 0;
        for(int j = 0; j < i; j++){
            left += a[j] < a[i];
        }
        for(int j = i + 1; j < n; j++){
            right += a[j] < a[i];
        }
        ModInt<MOD> add = (left + right) * (k - 1) * k / 2;
        add += right * k;
        ans += add;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i
h = gets.split.map(&:to_i)

ary = []
sum = Array.new(n,0)

(0..n-2).each do |i|
  if h[i] >= h[i+1]
    ary.push('T')
  else
    ary.push('F')
  end
end

(1..n-1).each do |i|
  if ary[i-1] == 'T'
    sum[i] = sum[i-1] + 1
  else
    sum[i] = 0
 end
end

#p ary
#p sum

puts sum.max

Measured memory_bytes: 18564
import java.util.Scanner;

public class Main{
public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 || W == 0) break;
			for (int i = 1; i <= H; i ++) {
				for (int j = 1; j <= W; j ++) System.out.print("#");
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 38080
#include<iostream>
#include<string>

using namespace std;

int main(){
 int n,m;
  cin >> n >> m;
 string a[n],b[m];
 
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<m;i++) cin >> b[i]; 
  
  
    bool res=false;
    for(int i=0;i<n-m+1;i++){
   for(int j=0;j<n-m+1;j++){
      bool dis=true;
     for(int k=0;k<m;k++){
     if(a[i+k].substr(j,m)!=b[k]) dis=false;
    }
     if(dis) {
       res=true;
      break;
     }
     }
  }

  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

typedef pair<int,int> pii;

bool used[1001];
int n;
vector<int> G[1001];
pii costs[1001];
int idx=0;
map<string,int> indices;
int nxt[1001];
int in[1001];
int sumCosts=0;
bool used2[1001];

// üü0Ìm[hÉÂ¢ÄTõ(ÂHÍ¶Ýµ¦È¢)
void search1(int s){
	used[s]=true;
	for(int i=0;i<(int)G[s].size();i++){
		int to=G[s][i];
		if(!used[to]){
			nxt[s]=to;
			sumCosts+=costs[to].second;
			search1(to);
		}
	}
}
// ü_ª ém[h©çTõðnßé
void search2(int s){
	used[s]=true;
	used2[s]=true;
	for(int i=0;i<(int)G[s].size();i++){
		int to=G[s][i];
		if(!used[to]){
			nxt[s]=to;
			sumCosts+=costs[to].second;
			search2(to);
		}
		// ÂHð­©µ½êAÂHÌÅÅàRXg·Ì¬³¢àÌðÌp
		else{
			// ¡ñÊßµ½êÅÍÈ¢ê
			if(!used2[to])continue;
			vector<pii> v;
			int cur=to;
			while(1){
				v.push_back(pii(costs[cur].first-costs[cur].second,cur));
				if(cur==s)break;
				int tto=nxt[cur];
				cur=tto;
			}
			sort(v.begin(),v.end());
			sumCosts+=costs[v[0].second].first;
			sumCosts-=costs[v[0].second].second;
		}
	}
}

int main(){

	while(cin>>n&&n){
		sumCosts=0;
		memset(in,0,sizeof(in));
		memset(used,0,sizeof(used));
		indices.clear();
		idx=0;
		for(int i=0;i<1001;i++)G[i].clear();
		for(int i=0;i<n;i++){
			string a,b;
			int c,d;
			cin>>a>>c>>b>>d;
			if(indices.find(a)==indices.end())indices[a]=idx++;
			if(indices.find(b)==indices.end())indices[b]=idx++;
			if(a!=b){
				G[indices[b]].push_back(indices[a]);
				in[indices[a]]++;
			}
			costs[indices[a]]=pii(c,d);
		}
		// ü_ª³¢¨ðTõ
		for(int i=0;i<idx;i++){
			if(in[i]==0&&!used[i]){
				// ÅÌvfÍK¸æé
				sumCosts+=costs[i].first;
				search1(i);
			}
		}
		// Ü¾TõµÄ¢È¢àÌð·×ÄTõ
		for(int i=0;i<idx;i++){
			if(!used[i]){
				memset(used2,0,sizeof(used2));
				sumCosts+=costs[i].second;
				search2(i);
			}
		}
		cout<<sumCosts<<endl;
	}

	return 0;
}

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

long long int mem[100];

long long int lucas(int x)
{
    long long int ans = 0;
    if (x == 0)
    {
        return 2;
    }
    else if (x == 1)
    {
        return 1;
    }
    else if (mem[x] != 0)
    {
        return mem[x];
    }
    return mem[x] = lucas(x - 1) + lucas(x - 2);
}

int main()
{

    int N;
    cin >> N;
    if (N == 1)
    {
        cout << 1;
    }
    else
    {
        cout << lucas(N);
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int n, d, x;
char s[20000];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	for (int i = 0; i < 20000; i++) {
		if (s[i] == NULL) {
			d = i;
			break;
		}
	}
	for (int i = 0; i < d; i++) {
		x = s[i] - 'A';
		x += n;
		x %= 26;
		printf("%c", x + 'A');
	}
	printf("\n");
}

Measured memory_bytes: 128
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array([lr() for i in range(N)])
INF = 10 ** 9
np.fill_diagonal(A, INF)
answer = 0
for i in range(N):
    for j in range(i+1, N):
        detour = np.min(A[i] + A[j])
        if A[i, j] < detour:
            # 最短距離としてこの道路は必要
            answer += A[i, j]
        elif A[i, j] > detour:
            print(-1)
            exit()

print(answer)
# 05 hint


Measured memory_bytes: 17076
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  LL n;
  cin >> n;
  string s;
  cin >> s;
  char prev = '0';
  LL ans = 0;
  REP(i, n) {
    if(s[i] != prev) {
      ans += 1;
      prev = s[i];
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
#include <array>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> mp(100100);
    int tmp;
    while(n--){
        cin>>tmp;
        mp[tmp+2]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 640
a[1<<20];n=1<<20;main(i,c){*a=a[1]=1;for(;++i<n;)if(!a[i])for(c=2;c*i<n;)a[i*c++]=1;for(;scanf("%d",&n),n;){c=0;for(i=n;++i<=2*n;)!a[i]&&c++;printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=60;
int n,m,a[N],max1;
long long ans,d[N*N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);max1+=a[i];}
	d[0][0]=1;
	for(int k=1;k<=n;k++)for(int i=max1;i>=0;i--)for(int j=0;j<=n;j++)d[i+a[k]][j+1]+=d[i][j];
	for(int i=1;i<=n;i++)ans+=d[i*m][i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

bool check_prime(int x) {
    int s = (int) ceil(sqrt(x));
    for (int a = 2; a < s; a++) {
        if (x % a == 0) return false;
    }
    return true;
}

int main() {
    int X;
    cin >> X;
    while (true) {
        if (check_prime(X)) {
            break;
        }
        X += 1;
    }
    cout << X << endl;
}


Measured memory_bytes: 256
A, B, H, M = gets.split.map(&:to_i)


rad = 2 * Math::PI * (
  H / 12.0 + M / 60.0 / 12.0 - M / 60.0
)

rsq = A * A + B * B - 2 * A * B * Math::cos(rad)

ans = Math.sqrt(rsq)

puts ans

Measured memory_bytes: 14712
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
ll n;
ll dp[100010];
vector<ll> vt;
vector<ll> vt1;
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		ll q;
		scanf("%lld", &q);
		vt.push_back(q);
	}
	vt.push_back(1234567890);
	sort(vt.begin(), vt.end());
	for (int i = 0; i < n; i++)
	{
		ll q;
		scanf("%lld", &q);
		vt1.push_back(q);
	}
	vt1.push_back(1234567890);
	sort(vt1.begin(), vt1.end());
	for (int i = 0; i < n; i++) {
		int t = lower_bound(vt.begin(), vt.end(), vt1[i]) - vt.begin();
		dp[i] = t;
		if (i)
			dp[i] += dp[i - 1];
	}
	ll dap = 0;
	for (int i = 0; i < n; i++)
	{
		ll q;
		scanf("%lld", &q);
		int t = lower_bound(vt1.begin(), vt1.end(), q) - vt1.begin();
		if (t)
			dap += dp[t - 1];
	}
	printf("%lld", dap);
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> H(N+1);
    for(int i=1; i<=N; i++){
        cin >> H[i];
    }

    vector<vector<ll>> dp1(N+1, vector<ll>(N+1, 1e18));
    vector<vector<ll>> dp2(dp1);
    dp1[0][0] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<=i; j++){
            for(int k=0; k<N; k++){
                dp2[j][k] = dp1[j][k];
                dp2[i+1][k+1] = min(dp1[j][k]+max(0ll, H[i+1]-H[j]), dp2[i+1][k+1]);
            }
        }
        dp1 = dp2;
    }

    ll ans=dp1[N][N-K];
    for(int j=0; j<=N; j++){
        for(int k=N-K; k<=N; k++){
            ans = min(ans, dp1[j][k]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n,l;
	cin>>n>>l;
	int arr[n];
	int origisum=0;
	for(int i=0;i<n;i++)
	{
		arr[i]=l+i;
		origisum+=arr[i];
	}
	//cout<<origisum<<endl;
	int ans=INT_MIN;
	int mini_diff=INT_MAX;
	for(int  i=0;i<n;i++)
	{
		//cout<<origisum-arr[i]<<endl;
		//cout<<abs(origisum-(origisum-arr[i]))<<endl;
		if(abs(origisum-(origisum-arr[i]))<mini_diff)
		{
			ans=origisum-arr[i];
			mini_diff=abs(origisum-(origisum-arr[i]));
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S,T;
  cin >> S >> T;
  for (int i = S.length()-T.length(); i+1>0; i--) {
    bool valid = true;
    for (int j = 0; j < T.length() && valid; j++) {
      if (S[i+j] != T[j] && S[i+j] != '?') {
        valid = false;
      }
    }
    if (valid) {
      for (int j = 0; j < T.length(); j++) {
        S[i+j] = T[j];
      }
      for (int j = 0; j < S.length(); j++) {
        if (S[j] == '?') {
          S[j] = 'a';
        }
      }
      cout << S <<endl;;
      return 0;
    }
  }

  
  cout << "UNRESTORABLE"<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int A[3];
	for (int i = 0; i < 3; i++) {
		cin >> A[i];
	}
	int diff[3];
	diff[0] = abs(A[0] - A[1]);
	diff[1] = abs(A[1] - A[2]);
	diff[2] = abs(A[2] - A[0]);

	int diff_sum = 0;
	int diff_max = 0;
	for (int i = 0; i < 3; i++) {
		diff_sum += diff[i];
		if (diff_max < diff[i]) {
			diff_max = diff[i];
		}
	}
	cout << diff_sum - diff_max;


	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	string s;
	cin >> s;
	int cnt[26] = {};
	for(auto c:s)cnt[c-'a']++;

	rep(i,26){
		if(cnt[i] == 0){
			cout << (char)('a'+i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;

	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc071.contest.atcoder.jp/tasks/abc071_b

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

class UnionFind{
public:
    int n, c;
    vector<int> par;
    UnionFind(int n) : n(n), c(0), par(n, -1){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    bool Unite(int x, int y){
        if((x = Find(x)) == (y = Find(y)))
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        ++c;
        return true;
    }
};

signed main(){
    int n, m, q;
    cin >> n >> m;
    vector<vector<pair<int,int>>> edges(n);
    priority_queue<pair<int, pair<int,int>>, vector<pair<int, pair<int,int>>>, greater<pair<int, pair<int,int>>>> que;
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        edges[--a].emplace_back(--b, c);
        edges[b].emplace_back(a, c);
        que.emplace(c, make_pair(a, b));
    }
    i64 mst_cost = 0;
    UnionFind uni(n);
    vector<vector<pair<int,int>>> tr(n);
    while(uni.c != n - 1){
        int cost;
        pair<int,int> p;
        tie(cost, p) = que.top();
        que.pop();
        if(uni.Unite(p.first, p.second)){
            mst_cost += cost;
            tr[p.first].emplace_back(p.second, cost);
            tr[p.second].emplace_back(p.first, cost);
        }
    }
    vector<vector<int>> v(n, vector<int>(n, -1));
    function<void(int,int, int)> max_cost = [&](int from, int pos, int ma){
        for(auto& e : tr[pos]){
            if(v[from][e.first] == -1){
                int nex = max(e.second, ma);
                v[from][e.first] = nex;
                max_cost(from, e.first, nex);
            }
        }
    };
    for(int i = 0; i < n; ++i){
        v[i][i] = 0;
        max_cost(i, i, 0);
    }
    cin >> q;
    for(int i = 0; i < q; ++i){
        int s, t;
        cin >> s >> t;
        cout << mst_cost - v[--s][--t] << endl;
    }
}


Measured memory_bytes: 79020
#include <stdio.h>
#include <stdlib.h>
#define MAX 100

typedef struct node
{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
} Node;

Node *root, *NIL;

void insert(int);
Node *find(int, Node *);
void inorder(Node *);
void preorder(Node *);
void delete(Node *);
Node *successor(Node *);
Node *min(Node *);

int main()
{
    int m, i, k, j, con;
    char com[MAX], judge[MAX];
    char y = 'y', n = 'n';

    scanf("%d", &m);
    for (i = 0; i < m; i++)
    {
        scanf("%s", com);
        if (com[0] == 'f')
        {
            scanf("%d", &k);
            Node *u = find(k, root);
            if (u != NIL)
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
        else if (com[0] == 'i')
        {
            scanf("%d", &k);
            insert(k);
        }
        else if (com[0] == 'p')
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if (com[0] == 'd')
        {
            scanf("%d",&k);
            delete(find(k,root));
        }
    }
    return 0;
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node)); //ノードを作る
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
            x = x->right;
    }

    z->parent = y; //insertした値の親を設定する
    if (y == NIL)
    { //親がない場合insertした値がそのままroot
        root = z;
    }
    else
    {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
    }
}

Node *find(int k, Node *u)
{
    while (u != NIL && k != u->key)
    {
        if (k < u->key)
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

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

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

void delete(Node *z)
{
    Node *y; //削除する対象
    Node *x;//yの子
    
    if(z->left == NIL || z->right == NIL){
        y=z;
    }else y = successor(z);

    // yの子xを決める
    if(y->left != NIL){
        x=y->left;
    }else {
        x=y->right;
    }
    if(x!=NIL){
        x->parent=y->parent;
    }
    if(y->parent==NIL){
        root = x;
    }
    else{
        if(y==y->parent->left){
            y->parent->left = x;
        }
        else {
            y->parent->right = x;
        }
    }
    if(y!=z){
        z->key=y->key;
    }
    free(y);
}

Node *successor(Node *x){
    if(x->right != NIL) return min(x->right);
    Node *y=x->parent;
    while(y!=NIL && x==y->right){
        x=y;
        y=y->parent;
    }
    return y;
}

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


Measured memory_bytes: 20552