akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %1d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int n;
int s[100];
bool dp[101][10001];

int main(){
	cin>>n;
	int a=0;
	rep(i,n) {
		cin>>s[i];
		a+=s[i];
	}
	rep(i,n+1)
			dp[i][0]=true;
	int ans=0;
	rep(i,n)
		rep(j,a+1){
			dp[i+1][j]=dp[i][j];
			if(j>=s[i]&&dp[i][j-s[i]]){
				dp[i+1][j]=true;
				if(j%10!=0)ans=max(j,ans);
			}
		}
	//debugarr(dp,n,a+1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        String s = stdin.readLine();
        List<String> weathers = Arrays.asList("Sunny", "Cloudy", "Rainy");
        int x = (weathers.indexOf(s) + 1) % 3;
        System.out.println(weathers.get(x));
    }
}


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

int main()
{
	int n;

	while( cin >> n && n ){
		vector< pair< int, int > > list;
		for( int i = 0; i < n; ++i ){
			int id, m, s, time = 0;
			cin >> id;
			for( int j = 0; j < 4; ++j ){
				cin >> m >> s;
				time += ( m * 60 + s );
			}
			list.push_back( make_pair( time, id ) );
		}
		sort( list.begin(), list.end() );

		cout << list[ 0 ].second << endl;
		cout << list[ 1 ].second << endl;
		cout << list[ list.size() - 2 ].second << endl;
	}

	return 0;
}

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

int main(){
  int N,K,L,tmp;
  L=0;
  cin >> N >> K;
  int l[N];
  for(int i=0;i<N;i++){
  cin >> l[i];
  }

  for(int i=0; i<N; ++i) {
    for (int j=i+1; j<N; ++j) {
      if (l[i] < l[j]) {
        tmp =  l[i];
        l[i] = l[j];
        l[j] = tmp;
      }
    }
  }

  for(int i=0;i<K;i++){
  L=L+l[i];
  }

  cout << L << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct clear{
	int time;
	int bit;

	bool operator<(const clear& right) const {
		return time == right.time ? bit < right.bit : time > right.time;
	}
};

int main() {

	int n;
	while (cin >> n, n){
		int table[1 << 16] = {0};
		vector<vector<int>> vvi(n);
		REP(i, n){
			REP(j, n + 1){
				int k;
				cin >> k;
				vvi[i].push_back(k);
			}
		}

		int ans = 0;
		priority_queue<clear> P;
		REP(i, n){
			P.push({ vvi[i][0], 1 << i });
		}

		while (1){
			//cout << P.size() << endl;
			clear c;
			c = P.top(); P.pop();
			if (c.bit == (1 << n) - 1){
				ans = c.time;
				break;
			}
			REP(i, n){
				if (!(c.bit&(1 << i))){
					int min = INT_MAX;
					int j2;
					REP(j, n + 1){
						if (j == 0 || (((c.bit&(1 << (j - 1))) != 0) && min > vvi[i][j])){
							min = vvi[i][j];
							j2 = j;
						}
					}
					if ((table[c.bit | (1 << i)] == 0) || (table[c.bit | (1 << i)] > c.time + min)){
						table[c.bit | (1 << i)] = c.time + min;
						P.push({ c.time + min, c.bit | (1 << i) });
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmdG

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

    string st;
    cin >> st;

    if (st[0] == st[1] && st[0] == st[2] ||
            st[1] == st[2] && st[3] == st[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}



Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = input()
    c = n[-1]

    if c in ["2", "4", "5", "7", "9"]:
        print("hon")
    elif c in ["0", "1", "6", "8"]:
        print("pon")
    else:
        print("bon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61640
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static boolean route(int pos, boolean[] used, int[][] edges, boolean[] visited) {
		visited[pos] = true;
		boolean ok = true;
		for(final boolean b :visited) { ok &= b; }
		if(ok) { return ok; }
		
		//System.out.println(pos);
		
		for(int i = 0; i < edges.length; i++) {
			if(used[i]) { continue; }
			
			final int from = edges[i][0];
			final int to = edges[i][1];
			//System.out.println(from + " " + to);
			
			if(pos == from && !visited[to]) {
				used[i] = true;
				if(route(to, used, edges, visited)) { return true; }
				used[i] = false;
			}
			if(pos == to && !visited[from]) {
				used[i] = true;
				if(route(from, used, edges, visited)) { return true; }
				used[i] = false;
			}
		}
		
		visited[pos] = false;
		return false;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			int[][] edges = new int[3][2];
			for(int i = 0; i < 3; i++) {
				edges[i] = new int[2];
				edges[i][0] = sc.nextInt() - 1;
				edges[i][1] = sc.nextInt() - 1;
			}
			
			final int N = 4;
			for(int from = 0; from < N; from++) {
				if(route(from, new boolean[edges.length], edges, new boolean[N])) {
					System.out.println("YES");
					return;
				}
			}
			
			System.out.println("NO");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22484
n, m = map(int, input().split())
sum_n = [0] * m
sum = 0
for i in range(n) :
    lst = list(map(int, input().split()))
    sum_m = 0
    for j in range(m) :
        print(lst[j], end=" ")
        sum_m += lst[j]
        sum_n[j] += lst[j]
    print(sum_m)
    sum += sum_m
for i in range(m) :
    print(sum_n[i], end=" ")
print(sum)


Measured memory_bytes: 5632
#!/usr/bin/env python3
from collections import Counter

def main():
    N,K = map(int,input().split())
    array = list(map(int,input().split()))
    cnt = 0
    diff = 0

    #array.sort()
    CUNT = Counter(array)
    #print(CUNT)

    array = sorted(CUNT.values(),reverse=True)
    #print(array)

    ans = sum(array[K:])
    print(ans)

main()


Measured memory_bytes: 32564
def typical_stairs(n, m, ali):

    mod = 10**9+7
    flag = [True]*(n+1)
    for i in ali:
        flag[i] = False

    dp = [0]*(n+1)
    dp[0] = 1

    for i in range(1, n+1):
        if not flag[i]:
            continue
        dp[i] = dp[i-2] + dp[i-1]
        dp[i] %= mod

    return dp[i]

def main():
    n, m = map(int, input().split())
    ali = [int(input())for i in range(m)]
    print(typical_stairs(n, m, ali))

if __name__ == '__main__':
    main()

Measured memory_bytes: 8616
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int a,b,x;
	cin >> a >> b >> x;
	if(a<=x && x<=a+b)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N, K, A[100000];

  cin >> N >> K;
  int pos = -1;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(A[i] == 1) {
      pos = i;
    }
  }

  if(N == K) {
    cout << 1 << endl;
    return 0;
  } else {
    int ret = 0;
    for(int i = 0; i < N - 1; i += K - 1) {
      ++ret;
    }
    cout << ret << endl;
  }
}


Measured memory_bytes: 640
#include<string.h>
#include<unistd.h>
#include<stdio.h>

int main(){
  int i;
  int sum = 0;
  int divider = 10;
  int temp;
  scanf("%d",&i);
  temp = i;
  while(1){
    sum = sum + i % divider;
    i = i / divider ;
    if (i==0){
      break;
    }
  }
  if(temp%sum==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN
    ll n,t; cin>>n>>t;
    vector<pair<ll,ll>> v;
    REP(i,n){
        ll a,b;cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    VSORT(v);

    vll dp(t, -1e9);
    dp[0]=0;
    ll ans = 0;
    REP(i,n){
        FORR(j,t-1,0){
            if (dp[j]==-1e9) continue;
            if(j+v[i].first < t){
                dp[j+v[i].first] = max(dp[j+v[i].first], dp[j]+v[i].second);
            }
            ans = max(ans, dp[j] + v[i].second);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  ll H;
  cin >> H;
  int i =0;
 while(H >= 2){
   H /= 2;
   i++;
 }
  i++;
  ll ans = 1;
  rep(j,i){
    ans *= 2;
  }
  ans--;
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, T; cin >> N >> T;
    ll ans = 0, cnt = 0;
    vector<ll> A(N), acc_min(N);
    rep(i, N){
        cin >> A.at(i);
        if (i == 0){
            acc_min.at(i) = A.at(i);
        } else {
            acc_min.at(i) = (A.at(i) < acc_min.at(i - 1)) ? A.at(i) : acc_min.at(i - 1);
        }
    }
    ll zero = 0;
    rep(i, N - 1){
        ll tmp = max((ll) 0, A.at(i + 1) - acc_min.at(i));
        if (tmp > ans){
            ans = tmp; cnt = 1;
        } else if (tmp == ans){
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    bool flag = true;
    rep(i,n) {
        int a;
        cin >> a;
        if (a%2 == 0) {
            if (a%3 != 0 && a%5 != 0) flag = false;
        }
    }
    if (flag) puts("APPROVED");
    else puts("DENIED");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

ll N, M;
ll steps[1000001];
ll MOD = 1000000007;

priority_queue<ll, vector<ll>, greater<ll>> a;

void dp(ll current) {
    ll next;
    if (!a.empty()) {
        next = a.top();
    } else {
        next = -1;
    }
    if (current == next) {
        steps[current] = 0;
        a.pop();
    } else {
        steps[current] = (steps[current - 1] + steps[current - 2]) % MOD;
    }
    if (current == N) return;
    dp(current + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    REP(i, M) {
        ll tmp;
        cin >> tmp;
        a.push(tmp);
    }
    steps[0] = 1;
    if (M == 0) {
        steps[1] = 1;
    } else {
        if (a.top() == 1) {
            a.pop();
            steps[1] = 0;
        } else {
            steps[1] = 1;
        }
    }
    if (N == 1) {
        cout << steps[1] << endl;
    } else {
        dp(2);
        cout << steps[N] % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 1908
/* ABC135-A.c
   Takatan */

#include<stdio.h>
#include<math.h>

int main(void){
    int number1, number2;
    double answer;

    scanf( "%d %d" , &number1, &number2);
    answer = ((double)(number1+number2) )/ 2;
    if(floor(answer)==ceil(answer)){
        printf( "%1.f\n" , answer);
    }else{
        printf( "IMPOSSIBLE\n" );
    }
    return 0;
}

Measured memory_bytes: 128
main(i,n){
	double a[101];double m;
	for(;;){
		for(i=0;i<101;a[i++]=0);
		scanf("%d",&n);if(!n)break;
		for(i=1;i<=n;scanf("%lf",&a[i]),a[0]+=a[i++]);
		m=a[0]/n;a[0]=0;//
		
		for(i=1;i<=n;a[0]+=pow(a[i++]-m,2));//
		
		printf("%lf\n",sqrt(a[0]/n));//
	}
	exit(0);
}

Measured memory_bytes: 660
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int num[10];

bool f;
void dfs(int x, int l, int r) {
	if (x == 10) {
		f = true;
	}
	if (num[x] > l) {
		dfs(x + 1, num[x], r);
	}
	if (num[x] > r) {
		dfs(x + 1, l, num[x]);
	}
}

int main() {
	int T;
	cin >> T;
	cin.ignore();
	while (T--) {
		string line;
		getline(cin, line);
		stringstream ss(line);
		for (int i = 0; i < 10; i++) {
			ss >> num[i];
		}
		f = false;
		dfs(0, 0, 0);
		if (f) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	ll N; cin >> N;
	string S; cin >> S;
	ll M = S.size();
	vector<vector<ll>> dp(N+1,vector<ll>(5001,0));
	dp[N][M] = 1;
	for(int i = N; 0 < i; --i) {
		(dp[i-1][0] += dp[i][0]) %= MOD;
		(dp[i-1][1] += 2*dp[i][0]) %= MOD;
		
		for(int j = 1; j < 5000; ++j) {
			(dp[i-1][j-1] += dp[i][j]) %= MOD;
			(dp[i-1][j+1] += 2*dp[i][j]) %= MOD;
		}
		(dp[i-1][4999] += dp[i][5000]) %= MOD;
	}
	cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 195840
N = int(input())
a = list(map(int, input().split()))
cnt = 0
zcnt = a.count(0)
for i in range(N):
    if a[i] < 0:
        cnt += 1

total = 0
if cnt % 2 == 0 or (cnt % 2 != 0 and zcnt > 0):
    for i in range(N):
        total += abs(a[i])
else:
    tmp = 10 ** 9
    for i in range(N):
        total += abs(a[i])
        tmp = min(tmp, abs(a[i]))
    total -= 2 * tmp

print(total)

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

using namespace std;

int main()
{
  string s;
  cin>>s;
  int len = s.size();
  for(int i=0;i<len;i++)
  {
    if(s.at(i)=='?')
    {
      s.at(i)='D';
    }
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3760
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := a*b-a-b+1
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

int main()
{
	int ary[31];
	int n, w;

	cin >> w >> n;
	for (int i = 1; i <= w; i++)
	{
		ary[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(ary[a], ary[b]);
	}
	for (int i = 1; i <= w; i++)
	{
		cout << ary[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var s = int.Parse(line[1]);
        var a = new int[n + 1];
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var te = Array.ConvertAll(line2, int.Parse);
        for (int i = 0; i < n; i++)
            a[i + 1] = a[i] + te[i];
        if (a[n] < s) { Console.WriteLine(0); goto end; }
        var ans = GetAns(a, s, n);
        if (ans == 999999) Console.WriteLine(0);
        else Console.WriteLine(ans);
        end:;
    }
    public static int GetAns (int[] a ,int s ,int n)
    {
        var ans = 999999;
        for (int i = 0;  a[i] +s <= a[n]; i++)
            for (int j = i+1; j <= n ; j++)
                if (a[i] + s <= a[j]) { ans = Math.Min(ans, j - i); break; }
        return ans;
    }
}

Measured memory_bytes: 15684
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main()
{
  finp;
  vi v(4);
  afor(i,0,3)cin>>v[i];
  sort(v.begin(),v.end());
  if(v == vi{1,4,7,9})cout<<"YES\n";
  else cout<<"NO";

  
return 0;
}

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

int main(){
    int N; cin >> N;
    double ans;
    if(N % 2 == 0){
        ans = 0.5;
    }else{
        ans = (N - N / 2) / (double)N;
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
// Problem : D - 11
// Contest : AtCoder - AtCoder Beginner Contest 066
// URL : https://atcoder.jp/contests/abc066/tasks/arc077_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}
vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}
int ncr(int n,int r){
	if(r>n)return 0;
return (((fact[n]*inv[r])%md)*inv[n-r])%md;
}
void solve()
{
int n;cin>>n;
vi v(n+1);cin>>v;
factorial(n+1);
inverse(n+1);
int pos1,pos2;
map<int,int> mp;
for(int i=0;i<n+1;i++)
{
	if(mp.count(v[i]))
	{
		pos1=mp[v[i]];
		pos2=i;
		break;
	}
	else
	mp[v[i]]=i;
}
for(int k=1;k<=n+1;k++)
{
	if(k==1)
	cout<<n<<"\n";
	else
	{
		int ans=ncr(n+1,k);
		ans=(ans-ncr(n-(pos2-pos1),k-1)+md)%md;
		cout<<ans<<"\n";
	}
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 11788
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  char tmp;
  char re_tmp;
  int cnt=0;
  for(int i=0;i<s.size()/2;i++){
    tmp=s.at(i);
    re_tmp=s.at(s.size()-1-i);
    if(tmp!=re_tmp)cnt++;
  }
  cout<<cnt<<endl;
  
}

Measured memory_bytes: 764
c=[[int(x) for x in input().split()] for _ in range(3)]
ans="No"
for a1 in c[0]:
    for a2 in c[1]:
        for a3 in c[2]:
            b1=c[0][0]-a1
            b2=c[1][1]-a2
            b3=c[2][2]-a3
            if a1+b2==c[0][1] and a1+b3==c[0][2] and a2+b1==c[1][0] and a2+b3==c[1][2] and a3+b1==c[2][0] and a3+b2==c[2][1]:
                ans = "Yes"
                break
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 
import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    //================================================================================
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int K = Integer.parseInt(sc.next());
    	int[] X = new int[N];
    	int l = 0, r = 0, z = 0;
    	for (int i = 0; i < N; i++) {
			X[i] = Integer.parseInt(sc.next());
			if(X[i] < 0)		l++;
			else if(X[i] == 0)	z++;
			else 				r++;
		}
    	if(K <= z) {
    		out.println(0);
    		return;
    	}
    	K -= z;
    	long ans = 1000000000000000000L;
    	for (int i = 1; i <= K; i++) {
    		if(l < i)			break;
    		else if(i == K && K <= l)		ans = Math.min(ans, -X[l-i]);
    		else if(i + r < K)	continue;
    		else 	ans = Math.min(ans, -X[l-i]*2 + X[l+z+(K-i)-1]);
		}
    	for (int i = 1; i <= K; i++) {
    		if(r < i)			break;
    		else if(i == K && K <= r)		ans = Math.min(ans, X[l+z+i-1]);
    		else if(i + l < K)	continue;
    		else 	ans = Math.min(ans, X[l+z+i-1]*2 - X[l-(K-i)]);
		}
    	out.println(ans);
    }
}

Measured memory_bytes: 50628
import sys

import itertools
input = sys.stdin.readline
 
N=int(input())

ans=[0]*10050

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            v=i*i+j*j+k*k+i*j+i*k+j*k
            if v<10050:
                ans[v]+=1

for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 74936
N = int(input())

a, b, c, d = 0, 0, 0, 0
for _ in range(N):
    s = input()
    if s == "AC":
        a += 1
    elif s == "WA":
        b += 1
    elif s == "TLE":
        c += 1
    elif s == "RE":
        d += 1


def f(s, x):
    print(s, "x", x)


f("AC", a)
f("WA", b)
f("TLE", c)
f("RE", d)


Measured memory_bytes: 9136
def end_of_words?(cur)
  @lines[cur[0]].size == cur[1]
end

def last_line?(cur)
  cur[0] == @lines.size - 1
end

buf = ''
cur = [0, 0]
@lines = []
while l = gets.chomp
  break if l == 'END_OF_TEXT'
  @lines << l
end

loop do
  case gets.chomp
  when '-'
    break
  when 'a'
    cur[1] = 0
  when 'e'
    cur[1] = @lines[cur[0]].size
  when 'p'
    cur[0] == 0 ? cur[1] = 0 : cur = [cur[0] - 1, 0]
  when 'n'
    last_line?(cur) ? cur[1] = 0 : cur = [cur[0] + 1, 0]
  when 'f'
    unless end_of_words?(cur)
      cur[1] += 1
    else
      unless last_line?(cur)
        cur = [cur[0] + 1, 0]
      end
    end
  when 'b'
    if cur[1] != 0
      cur[1] -= 1
    else
      if cur[0] != 0
        cur = [cur[0] - 1, @lines[cur[0] - 1].size]
      end
    end
  when 'd'
    unless end_of_words?(cur)
      @lines[cur[0]].slice!(cur[1])
    else
      unless last_line?(cur)
        l = @lines.delete_at(cur[0] + 1)
        @lines[cur[0]] += l
      end
    end
  when 'k'
    unless end_of_words?(cur)
      buf = @lines[cur[0]].slice!(cur[1]..-1)
    else
      unless last_line?(cur)
        l = @lines.delete_at(cur[0] + 1)
        @lines[cur[0]] += l
        buf = '\\n'
      end
    end
  when 'y'
    if buf == '\\n'
      @lines.insert(cur[0] + 1, @lines[cur[0]].slice!(cur[1]..-1))
      cur = [cur[0] + 1, 0]
    elsif buf != ''
      @lines[cur[0]].insert(cur[1], buf)
      cur[1] += buf.size
    end
  end
end

puts @lines

Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int L[N] = {};
  int max = 0, l = 0, total = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    if (max < L[i]) {
      max = L[i];
    }
    total += L[i];
  }
  
  total = total - max;
  
  if (max < total) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;
using ll = long long;

void solve(long N, vector<long> a) {

  sort(a.rbegin(), a.rend());

  ll ans = 0;  
  REP(i, N)
    ans += a[2 * i + 1];
  cout << ans << endl;
}

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

  long N;
  cin >> N;
  vector<long> a(3*N);
  REP(i, 3*N)
    cin >> a[i];

  solve(N, move(a));

  return 0;
}


Measured memory_bytes: 2560
n, k = gets.chomp.split.map(&:to_i)
nums = gets.chomp.split.map(&:to_i)
 
nums_count = nums.group_by(&:itself).map{ |key, value| value.size }
nums_count.sort!
delete = 0

if nums_count.size > k
  (0...nums_count.size - k).each do |i|
    delete += nums_count[i]
  end
  puts delete
else
  puts 0
end

Measured memory_bytes: 47216
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

double f(int K) {
    double t = K;
    int s = 0;
    while(K > 0) {
        s += K % 10;
        K /= 10;
    }
    return t / s;
}

void solve(long long K){
    int a = 1;
    while(K>0){
        cout << a << endl;
        double mn = 1e15;
        int na = -1;
        int d = 1;
        while(a * 10 >= d) {
            int t = (a / d + 1) * d + d - 1;
            double sn = f(t);
            if (sn < mn) {
                na = t;
                mn = sn;
            }
            d *= 10;
        }
        a = na;
        --K;
    }
}

signed main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}

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

int main () {
int A;
int B;
cin >> A >> B;
  
if(6<=A&& A<=12){
cout << B/2<< endl;
}
else if(A<=5){
cout << 0 << endl;
}
else{
cout << B << endl;
}
 
}
 
  




Measured memory_bytes: 256
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
if n >= m:
    print(0)
    exit(0)
s = []
for i in range(m-1):
    s.append(x[i+1]-x[i])
s.sort(reverse=True)
print(x[-1]-x[0]-sum(s[0:n-1]))

Measured memory_bytes: 13964
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 200000

int n;
vector<int> a[3];

int main(){
	cin>>n;
	rep(i, 3) a[i] = vector<int>(n);
	rep(i, 3) rep(j, n)  cin>>a[i][j];
	rep(i, 3){
		sort(all(a[i]));
	}
	ll res = 0;
	for(int i = 0; i < a[1].size(); i++){
		ll x1 = lower_bound(all(a[0]), a[1][i])-a[0].begin();
		ll x2 = a[2].end()-upper_bound(all(a[2]), a[1][i]);
		res += x1*x2;
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
int main(){
	//freopen("in","r",stdin);
	int a=read(),b=read();
	printf("%d\n",max(0,a-2*b));
	return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

ll n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    cout << fixed << setprecision(6) << (ld)n * n * n / 27.0L;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100001],q,prime[100001]={0},isprime[100001]={1,1,0},total=0,i,j,a,b,c=0;
int main()
{ 	
	for(i=2;i<=100000;i++)
	{
		if(isprime[i]==0)
		{
			prime[c++]=i;
			if(isprime[(i+1)/2]==0)
			{
				total++;
			}
		}
		s[i]=total;
		for(j=0;j<c&&i*prime[j]<=100000;j++)
		{
		    isprime[i*prime[j]]=1;
		    if(i%prime[j]==0)
		        break;
		}
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",s[b]-s[a-1]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

const int N=2e5+10;
const int mod=1e9+7;
int n,k,m;
int a[N];
int b[N];
int ans[N];
string s;
int vis[N];
map<int,int> mp;

int cmp(int a, int b){
    return a>b;
}
int main()
{
    cin>>s;
    cout<<s;
    if(s[s.size()-1]=='s')cout<<"es";
    else cout<<"s"<<endl;

}



Measured memory_bytes: 3648
class Node:
    def __init__(self, value):
        self.value = value
        self.next = None


class List:
    def __init__(self):
        self.head = None
        self.tail = None

    def insert(self, v):
        node = Node(v)
        if self.tail is None:
            self.head = node
            self.tail = node
        else:
            self.tail.next = node
            self.tail = node

    def dump(self):
        node = self.head
        while node is not None:
            yield node.value
            node = node.next

    def splice(self, li):
        if self.head is None:
            self.head = li.head
            self.tail = li.tail
        else:
            self.tail.next = li.head
            self.tail = li.tail
        li.clear()

    def clear(self):
        self.head = None
        self.tail = None


def run():
    n, q = [int(x) for x in input().split()]
    ls = [List() for _ in range(n)]

    for _ in range(q):
        com = [int(x) for x in input().split()]
        c = com[0]
        if c == 0:
            t, v = com[1:]
            ls[t].insert(v)
        elif c == 1:
            t = com[1]
            values = []
            for v in ls[t].dump():
                values.append(str(v))
            print(" ".join(values))
        elif c == 2:
            s, t = com[1:]
            ls[t].splice(ls[s])
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



Measured memory_bytes: 143428
//In The Name Of God
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<vii> vvii;

#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define forne(i, x, n) for (int i = x; i < n; i++)
#define forre(i, x, n) for (int i = n; i >= x; i--)
#define all(a) (a).begin(), (a).end()
#define eps 1e-9

const int maxn = 1e5 + 10;
ll dp[maxn][2];
vi graph[maxn];
ll mod = 1e9 + 7;

void mul(ll &a, ll b) {
    (a *= b) %= mod;
}

ll dfs(int v, bool c, int p) {
    ll &ans = dp[v][c];
    if(ans != -1) return ans;
    ans = 1;
    for(auto &e: graph[v]) if(e != p) {
        ll cur = 0;
        cur += dfs(e, !c, v);
        if(c) cur += dfs(e, c, v);
        cur %= mod;
        mul(ans, cur);
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    forn(i, maxn) dp[i][0] = dp[i][1] = -1;
    int n; cin >> n;
    forn(i, n - 1) {
        int a, b; cin >> a >> b;
        a--, b--;
        graph[a].push_back(b), graph[b].push_back(a);
    }
    cout << (dfs(0, false, 0) + dfs(0, true, 0)) % mod << endl;

    return 0;
}


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

#define    ll     long long int

int n, m;
int g[55][55];
pair<int, int> edge[5005];
int vis[55];

int dfs(int u, int p)
{
    int i, v, c = 1;
    vis[u] = 1;
    for (i = 1; i <= n; i++) {
        if (vis[i] == 0 && g[u][i] == 1) {
            c += dfs(i, u);
        }
    }
    return c;
}

int main( )
{
    int i, j, k;
    cin >> n >> m;
    for (i = 1; i <= m; i++) {
        cin >> j >> k;
        edge[i] = make_pair(j, k);
        g[j][k] = 1;
        g[k][j] = 1;
    }
    int c = 0;
    for (i = 1; i <= m; i++) {
        j = edge[i].first;
        k = edge[i].second;
        g[j][k] = 0;
        g[k][j] = 0;
        memset(vis, 0, sizeof vis);
        int d = dfs(1, -1);
        //cout << i << ' ' << d << '\n';
        if (d != n) {
            c++;
        }
        g[j][k] = 1;
        g[k][j] = 1;
    }
    cout << c << '\n';
    return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin>>h[i];
  vector<int> dp(n);
  dp[0]=0; dp[1]=abs(h[1]-h[0]);
  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;
}


Measured memory_bytes: 4056
#include<iostream>
using namespace std;
int a,b;
int main()
{ 
  cin >> a >> b;
  if(a==1 | a==3 | a==5 | a==7 | a==8 | a==10 | a==12){a=13;
                                                      }
  if(b==1 | b==3 | b==5 | b==7 | b==8 | b==10 | b==12){b=13;
                                                      }
  if(a==4 | a==6 | a==9 | a==11){a=14;
                                }
  if(b==4 | b==6 | b==9 | b==11){b=14;
                                }
  if(a==b){printf("Yes");
          }else{printf("No");
               }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200050;
int n;
int last[maxn]={0},a[maxn],dp[maxn];
int main(){
	scanf("%d",&n);
	int mx=0;
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=n;i++){
		dp[i]=dp[last[a[i]-1]]+1;
		last[a[i]]=i;
		mx=max(mx,dp[i]);
	}
	printf("%d",n-mx);
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

vector<int64> factorial;

int64 modpow(int64 a, int64 r){
    if(r == 0)return 1;
    if(r % 2 == 0){
        int64 x = modpow(a, r / 2);
        return x * x % MOD;
    }else{
        return modpow(a, r-1) * a % MOD;
    }
}

int64 comb(int64 n, int64 r){
    r = min(r, n-r);
    int64 res = factorial[n] * modpow(factorial[n-r], MOD-2) % MOD * modpow(factorial[r], MOD-2) % MOD;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 h, w, a, b;
    cin >> h >> w >> a >> b;
    factorial.resize(h + w, -1);
    factorial[0] = 1;
    FOR(i,1,h+w){
        factorial[i] = factorial[i-1] * i % MOD;
    }
    vector<int64> x(h-a);
    REP(i,h-a){
        x[i] = comb(i + b - 1, i);
    }
    int64 ans = 0;
    REP(i,h-a){
        ans += comb(h-1-i + w-b-1, h-1-i) * x[i] % MOD;
        ans %= MOD;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 2560