akhauriyash/Code-Regression huggingface dataset:
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


void solve()
{ 
  int n,k;
  cin >> n >> k;
  map<int,int> m;
  while(k--)
  {
      int d;
      cin >> d;
      while(d--)
      {
          int x;
          cin >> x;
          m[x]=1;
      }
  }
  int x=(int)m.size();
  cout << n-x << '\n';
  return;
}

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3652
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


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

	sort(a, a + 3);
	int b = a[2] * 10 + a[1];
	cout << b + a[0] << endl;
}

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

int main(){
    int n,k;string s;
    cin >> n >> k >> s;
    int score = 0;
    rep(i,n-1) if(s.at(i) == s.at(i+1)) score++;
    int ans = min(score+2*k,n-1);
    cout << ans << endl; 
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int n,k;
int d[100005];
int main(void)
{
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	reverse(d,d+n);
	
	int ans=2e9;
	for(int i=0;i<=n-k;i++) ans=min(ans,d[i]-d[i+k-1]);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
#define DIM 100007
#define INF 2E60
#define MAXN 1023
#define LG 18

typedef long long  ll;
typedef long double ld;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pair<ll, ll> pll;
typedef pll parr[DIM];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};


ll n, w;
parr A;
ll D[107][DIM];
int main()
{
	cin >> n >> w;
	for (int i = 1; i <= n; i++)cin >> A[i].first >> A[i].second;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {

		for (int j = 1; j <= w; j++)D[i][j] = -INF;
	}
	D[0][0] = 0;
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		sum += A[i].first;
		//cout << A[i].first << ' '<<A[i].second<<endl;
		ll to = min(w, sum);
		for (int j = 0; j <= to; j++) {
			ll p = D[i - 1][j];
			if (j >= A[i].first && D[i - 1][j - A[i].first] != -INF)
				p = max(p, (D[i - 1][j - A[i].first] + A[i].second));
				//cout << D[i - 1][j - A[i].first] <<' '<<i<<' '<<j <<' '<<A[i].second<<' '<<p<< endl;
			
			D[i][j] = p;
			if (j<=w)
			res = max(res, p);
		}
	}
	cout << res << endl;
}
// 11
// 

Measured memory_bytes: 81408
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    pbds;
    // pbds p;(declare like this inside main)
    // *p.find_by_order(3) : value at 3rd index in a sorted array
    // p.order_of_key(6) : index of number 6 (if it is present or assume it to be //present) or no of elements strictly smaller than 6
    // erase and find can also be used similar to set !!!

ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >> n >> k;
    double ans=0;
    for(ll i=1;i<=n;i++)
    {
    	ll d=i;double dans=(double)1/(double)n;
    	if(d<k)
    	{
    		while(d<k){d*=2;dans/=2;}
    	}
    	ans+=dans;
    }
    cout << setprecision(20) << ans;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <string>

using namespace std;


const int N = 2e5 + 10;
int n, m, X, Y;
char col[N];
unordered_map<int, unordered_set<int> > ds[2];
unordered_map<int, int> test[2];
unordered_set<int> checked[2];
unordered_set<int> path[2];

bool walk(int a, int depth) {
    //printf("%d\n", a);
    checked[depth].insert(a);
    if (ds[depth].find(a) == ds[depth].end()) {
        //printf("1 %d\n", a);
        return false;
    }
    int n_d = (depth+1) % 2;
    for(auto itr = ds[depth][a].begin(); itr != ds[depth][a].end(); itr++) {
        //printf("search%d\n", *itr);
        if (path[n_d].find(*itr) != path[n_d].end()) {
            //printf("end");
            return true;
        }
        if (checked[n_d].find(*itr) == checked[n_d].end()) {
            path[n_d].insert(*itr);
            if (walk(*itr, n_d)){
                return true;
            }
            path[n_d].erase(*itr);
        }
    }
    return false;
}

int main() {
    scanf("%d%d", &n, &m);
    scanf("%s", col);
    for (int i = 1, x, y; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        x = x-1;y = y-1;
        X = col[x] == col[y] ? 0 : 1;
        Y = col[x] == col[y] ? 1 : 0;
        //if (ds[X].find(x) == ds[X].end()){
        //    ds[X][x] = {};
        //}
        //if (ds[X].find(y) == ds[X].end()){
        //    ds[X][y] = {};
        //}
        ds[X][x].insert(y);
        ds[X][y].insert(x);
        test[0][x] = y;
        test[0][x] = 4;
    }
    string result = "No";
    for(auto itr = ds[0].begin(); itr != ds[0].end(); itr++) {
        auto isitr = checked[0].find(itr->first);
        //printf("%d\n", itr->first);
        //printf("----------\n", itr->first);
        if (isitr == checked[0].end()){
            path[0].insert(itr->first);
            if (walk(itr->first, 0)) {
                result = "Yes";
            }
            path[0].erase(itr->first);
        }
    }
    printf("%s", result.c_str());
}


Measured memory_bytes: 84788
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int inf = 1001001001;
int e[1000][1000];
int e2[1000][1000];
int a[100000],b[100000];
int main() {
    int n,m,l;
    int p,q,s;
    int r;
    scanf("%d %d %d",&n,&m,&l);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j<=n;j++){
            if(i == j) {e[i][j] =0;e2[i][j] = 0;}
            else{ e[i][j] = inf;e2[i][j] = inf;}
            
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d %d %d",&p,&q,&s);
        e[p][q] = s;
        e[q][p] = s;
    }
    scanf("%d",&r);
    for(int i = 1; i <= r; i++){
        scanf("%d %d",&a[i],&b[i]);
    }    
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                e[i][j] = min(e[i][j],e[i][k] + e[k][j]);
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++){
            if(e[i][j] <= l) {
                e2[i][j] = 1;
            }
        }
    }
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                e2[i][j] = min(e2[i][j],e2[i][k]+e2[k][j]);
            }
        }
    }
    for(int i = 1; i <= r ;i++){
        if(e2[a[i]][b[i]] == inf) {
            printf("-1\n");
        }
        else {printf("%d\n",e2[a[i]][b[i]] - 1);}
    }
    return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;


const double EPS = 1e-9;
const double PI = 3.14159265359;

int main(){
	string s;

	while(getline(cin, s)){
		for(int i = 0; i < s.size(); i++){
			if(s[i] == '@'){
				i+=2;
				for(int j = 0; j < s[i-1] - '0'; j++){
					cout << s[i];
				}
			}else{
				cout << s[i];
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
    int t;
    cin >> t;

    for(int tt=0; tt<t; tt++){
        int n;
        cin >> n;

        long long int score = 0;
        int a = 0, b = 0;
        vector<vector<long long int>> camel1(n+1), camel2(n+1);
        for(int i=0; i<n; i++){
            int k; long long int l, r;
            cin >> k >> l >> r;

            score += min(l,r);
            if(l >= r){ camel1[k].push_back(l-r); a += 1; }
            if(l <  r){ camel2[n-k].push_back(r-l); b += 1; }
        }

        priority_queue<long long int> pq1;
        for(int j=n; j>=a; j--){
            for(long long int c : camel1[j]) pq1.push(c);
        }
        if(pq1.empty() == false){
            score += pq1.top(); pq1.pop();
        }

        for(int j=a-1; j>=1; j--){
            for(long long int c : camel1[j]) pq1.push(c);
            if(pq1.empty() == false){
                score += pq1.top(); pq1.pop();
            }
        }

        priority_queue<long long int> pq2;
        for(int j=n; j>=b; j--){
            for(long long int c : camel2[j]) pq2.push(c);
        }
        if(pq2.empty() == false){
            score += pq2.top(); pq2.pop();
        }

        for(int j=b-1; j>=1; j--){
            for(long long int c : camel2[j]) pq2.push(c);
            if(pq2.empty() == false){
                score += pq2.top(); pq2.pop();
            }
        }
        cout << score << endl;
    }
    return 0;
}

Measured memory_bytes: 18396
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    private static int h[] = new int[(int) (1e5 + 1)];
    private static int dp[] = new int[(int) (1e5 + 1)];
    private static int n,k;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 0;i < n;i++)
            h[i] = sc.nextInt();
        Arrays.fill(dp,0,n,Integer.MAX_VALUE);
        System.out.println(dp(0));
    }

    private static int dp(int idx) {
        if(idx == n - 1)
            return 0;
        if(dp[idx] != Integer.MAX_VALUE)
            return dp[idx];
        for (int kk = 1;kk <= k;kk++){
          if(idx + kk < n)
             dp[idx] = Math.min(dp[idx], Math.abs(h[idx] - h[idx + kk]) + dp(idx + kk));
        }
        return dp[idx];
    }
}

Measured memory_bytes: 64272
def abc150c_count_order():
    import bisect, itertools
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    pattern = list(itertools.permutations(range(1, n+1)))
    p_idx = bisect.bisect(pattern, p)
    q_idx = bisect.bisect(pattern, q)
    print(abs(p_idx-q_idx))
abc150c_count_order()

Measured memory_bytes: 13952
package main

import (
    "fmt"
)

func main() {
    var n, k int 
    fmt.Scan(&n, &k) 
    var cnt int 
    for i := 0; i < n; i++ {
        var h int 
        fmt.Scan(&h)
        if h >= k { 
            cnt++
        }   
    }   
    fmt.Println(cnt)
}


Measured memory_bytes: 5504
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    if(n % 1000 != 0){
        cout << 1000 - n%1000 << endl;
    }
    else cout << 0 << endl;

return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = 800*n;
		int y = 200*(n/15);
		System.out.println(x-y);
	}

}


Measured memory_bytes: 21460
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = n%10;
      int l = (n-m)/10;
      if(m == 9||l == 9)System.out.println("Yes");
      else System.out.println("No");
    }
}

Measured memory_bytes: 19796
#include<iostream>
using namespace std;
 
int main()
{
    int A, B;
    cin>>A;
    cin>>B;

    if (A == 0)
        cout<<B - A<<endl;
    else
    {
        if (B % A == 0)
            cout<<A + B<<endl;
        else   
            cout<<B - A<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

int bs_lower_bound(int a[], int n, int x) {
    int l = 0;
    int h = n; // Not n - 1
    while (l < h) {
        int mid = (l + h) / 2;
        if (x <= a[mid]) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}
void solve(){
	int n;
	cin>>n;
	int arr[n];
	FOR(i, 0, n)cin>>arr[i];
	sort(arr, arr+n);
	int cnt=0;
	FOR(i, 0, n) {
		FOR(j, i+1, n){
			FOR(k, j+1, n){
				if(arr[i]<arr[j]+arr[k] && arr[j]<arr[i]+arr[k] && arr[k]<arr[i]+arr[j]) cnt++;
			}
		}
	}
	cout<<cnt;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 384
N = int(input())
A = []  # (index, Ai)
m = 0
m2 = 0
for i in range(N):
    a = int(input())
    A.append(a)
    if a > m:
        m2 = m
        m = a
    elif m >= a and a >= m2:
        m2 = a

for i in range(N):
    if A[i] == m:
        print(m2)
    else:
        print(m)


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

int main(void)
{
    int N;
    cin >> N;
    int A[2][N];
    for (int i = 0 ; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    long long maxSum = 0;
    for (int i = 0; i < N; i++) {
        long long tmpSum = 0;
        // A[0][0]~A[0][i]
        for (int j = 0; j <= i; j++) {
            tmpSum += A[0][j];
        }
        // A[1][i]~A[1][N-1]
        for (int j = i; j < N; j++) {
            tmpSum += A[1][j];
        }
        if (maxSum < tmpSum) {
            maxSum = tmpSum;
        }
    }
    cout << maxSum << endl;
}


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

int main(void)
{
    int i, j;
    int N, Ai;
    int dp[2] = {0,1};  /* 0 is even, 1 is odd */
    scanf("%d", &N);
    for(i = 0;i < N;++i)
    {
        int ndp[2] = {0,0};
        scanf("%d", &Ai);
        for(j = Ai-1;j <= Ai+1;++j)
        {
            ndp[0] += (j&1) ? (dp[0]) : (dp[0]+dp[1]);
            ndp[1] += (j&1) ? (dp[1]) : 0;
        }
        dp[0] = ndp[0]; dp[1] = ndp[1];
    }
    printf("%d\n", dp[0]);
    return 0;
}


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

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

using namespace std;

inline bool Get_bit(int a, int i){
    return (a >> i) & 1;
}

inline int Change_bit(int a, int i){
    return a ^ (1 << i);
}

inline int MSB(int a, int i){
    while (!Get_bit(a, i))
        i++;
    return i;
}

vector<int> ans;
bool if_exists = true;

void Solve_simple(int a, int change, int cur_change, int change_count){
    if (change_count == 1){
        ans.push_back(a);
        ans.push_back(Change_bit(a, cur_change));
        return;
    }
    change_count--;
    int old_change = cur_change;
    change = Change_bit(change, cur_change);
    cur_change = MSB(change, cur_change);
//    while (!Get_bit(change, cur_change))
//        cur_change++;
    Solve_simple(a, change, cur_change, change_count);
    a = Change_bit(ans.back(), old_change);
    Solve_simple(a, change, cur_change, change_count);
}

void Solve(int n, int a, int b){
    int change = (1 << n) - 1, change_count = n - 1;
    while (change_count > 0){
        if (a == b){
            if_exists = false;
            return;
        }
        FOR (i, n)
            if (Get_bit(change, i) && Get_bit(a, i) != Get_bit(b, i)){
                change = Change_bit(change, i);
                Solve_simple(a, change, MSB(change, 0), change_count);
                a = Change_bit(ans.back(), i);
                change_count--;
                break;
            }
    }
    if (a == b){
        if_exists = false;
        return;
    }
    ans.push_back(a);
    ans.push_back(b);
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
//    int a = 0, change = 5, cur_change = 0, change_count = 2;
//    Solve_simple(a, change, cur_change, change_count);
//    FOR (i, ans.size())
//        cout << ans[i] << ' ';
//    cout << endl;
    int n, a, b;
    cin >> n >> a >> b;
    Solve(n, a, b);
    if (if_exists){
        cout << "YES" << '\n';
        FOR (i, ans.size())
            cout << ans[i] << ' ';
        cout << '\n';
    }
    else
        cout << "NO" << '\n';
}


Measured memory_bytes: 1656
def main():
    N, M = map(int, input().split())
    num = [-1] * N
    
    err = False

    for i in range(M):
        d, n = map(int, input().split())
        if (num[d - 1] == n or num[d - 1] == -1) and not(N >= 2 and d == 1 and n == 0):
            num[d - 1] = n
        else:
            err = True
            break
    
    if err:
        print(-1)
    else:
        num = [str(n) if n != -1 else "1" if (N >= 2 and i == 0) else "0" for i,n in enumerate(num)]
        print("".join(num))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    string res = "";
    char c = 'A' + (s1[0] - 'a');
    res += c;
    c = 'A' + (s2[0] - 'a');
    res += c;
    c = 'A' + (s3[0] - 'a');
    res += c;
    print(res);
    

}

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

const ll MOD=1000000007;
ll inv[200100];
ll x, y;

ll extgcd ( ll a, ll b, ll &x, ll &y){ 
    ll d = a;
    if(b!=0){
        d = extgcd(b,a%b,y,x);
        y -=(a/b)*x;
    } else{
        x=1; y=0;
    }
    return d;    
}

void init(){
    for(ll i=1LL; i<200100; i++){
        extgcd(i,MOD,x,y);
        if(x <0) x+=MOD;
        inv[i] = x;
    }
}



ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res = modpow(x*x%MOD, n/2);
    if(n&1) res = res * x % MOD;
    return res;
}

int main(){
    init();
    ll N, A, B, C; cin >> N >> A >> B >> C;

    ll ans =0;

    ll numA = ( modpow(B,N)*modpow(inv[A+B],N)%MOD ) *N % MOD;
    ll sumA = numA;
    for(ll K=0LL; K<=N-2; K++){
        ll a0 = (N+K)*inv[K+1] %MOD;
        ll a1 = A * inv[A+B] %MOD;
        ll a2 = (N+K+1) * inv[N+K] %MOD;
        numA = ((numA * a0 )%MOD) * ( (a1*a2)%MOD ) %MOD;
        sumA +=numA; sumA %=MOD;
    }

    ll numB = ( modpow(A,N)*modpow(inv[A+B],N)%MOD ) *N % MOD;
    ll sumB = numB;
    for(ll K=0LL; K<=N-2; K++){
        ll a0 = (N+K)*inv[K+1] %MOD;
        ll a1 = B * inv[A+B] %MOD;
        ll a2 = (N+K+1) * inv[N+K] %MOD;
        numB = ((numB * a0 )%MOD) * ( (a1*a2)%MOD ) %MOD;
        sumB +=numB; sumB %=MOD;
    }

    cout << ( (sumA+sumB)*100 %MOD) *inv[100-C] %MOD << endl;


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// ll t;
	// cin>>t;
	// whln(t){
	
	// }
	ll cur_t=INT_MIN,req,n,temp=0;
	cin>>n;
	vector<ll>v(n);
	rep(i,n){
		cin>>v[i];
		cur_t=cur_t>v[i]?cur_t:v[i];
		req = cur_t - v[i];
		temp+=req;
	}

	cout<<temp;


	

}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

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

int main(){
    int N, D, X;
    int res = 0;
    cin >> N >> D >> X;
    int A[N];

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

    for (int j=0; j<N; j++) {
        for (int i=0; i*A[j]+1<=D; i++) {
            res++;
        }
    }

    res += X;
    
    cout << res << endl;
}

Measured memory_bytes: 256
s = input()
a = int(s[0:2])
b = int(s[2:4])

if a > 0 and a < 13 and b > 0 and b < 13:
    print("AMBIGUOUS")
elif a > 0 and a < 13:
    print("MMYY")
elif b > 0 and b < 13:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    cin>>a>>b;
    if(a==b){
        cout<<a+b;
    }
    else{
        cout<<max(a,b)+max(a,b)-1;
    }
    return(0);
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();

    int p=0,g=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='g'){
            if(g>p){
                p++;
                ans++;
            }
            else g++;
        }
        else{
            if(g>p) p++;
            else{
                g++;
                ans--;
            }
        }
        
    }
    cout<<ans<<endl;

}

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

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

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			var s = cin.ReadString().ToCharArray();
			s[5] = ' ';
			s[13] = ' ';
			Console.WriteLine(string.Concat(s));
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));


	}
}


Measured memory_bytes: 13268
s = input()

flag = True
odd = ["R", "U", "D"]
even = ["L", "U", "D"]

for i in range(0, len(s), 2):
    if s[i] in odd:
        continue
    else:
        flag = False

for i in range(1, len(s), 2):
    if s[i] in even:
        continue
    else:
        flag = False

print("Yes" if flag else "No")


Measured memory_bytes: 3060
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,K = inpl()
MAX = (N-1)*(N-2)//2

def solve(lines):
    print(M)
    for a,b in lines:
        print(a,b)

if MAX < K:
    print(-1)
else:
    M = N-1 + (MAX-K)
    lines = []
    for i in range(N-1):
        lines.append([1,i+2])

    cnt = 0
    if cnt == (MAX-K):
        solve(lines)
        exit()
        
    for i in range(2,N+1):
        for j in range(i+1,N+1):
            lines.append([i,j])
            cnt += 1
            if cnt == (MAX-K):
                solve(lines)
                exit()


Measured memory_bytes: 5092
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
bool st[N];
int prime[N];
int cnt;
int psum[N];

void gets_prime()
{
    for(int i=2;i<=N;i++)
    {
        if(!st[i])
        {
            for(int j=i+i;j<=N;j+=i)
            {
                st[j]=true;
            }
        }
    }
}

int main()
{
    gets_prime();
    for (int i = 3; i <= N;i+=2)
    {
        if(!st[i]&&!st[(i+1)/2])
            psum[i]++;
    }
    for (int i = 3; i < N;i++)
    {
        psum[i] += psum[i - 1];
    }

    int q;
    cin >> q;
    while(q--)
    {
        int l, r;
        cin >> l >> r;
        cout << psum[r] - psum[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf          INT_MAX
#define zer          INT_MIN
#define nl cout<<'\n' ; 
void prl(ll x) {cout << x <<'\n';}
void speed() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void checker(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

void solve()
{
	//let dp[i] denote the minimum cost to land at a stone i 
	// so dp[i]= min(dp[i-1]+ abs(h[i]-h[i-1]) , dp[i-2] + abs(h[i]- h[i-2])) ;
	
	int n ; cin>>n ;
	int h[n] ; for(int i=0 ; i<n ; i++) cin>>h[i] ; 
	
	vector<int> dp(n+1 , 0) ; 
	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] ; 
}

int main()
{
	speed(); 
    int T = 1;
   // cin >> T;
    while (T--){
    solve();
}
}




Measured memory_bytes: 4044
N, K = map(int, input().split())
X = list(map(int, input().split()))

neg = sorted(-v for v in X if v < 0)
pos = sorted(v for v in X if v > 0)
nonneg = sorted(v for v in X if v >= 0)

cnt_neg = len(neg)
cnt_pos = len(pos)

pair_pos = cnt_pos * (cnt_pos - 1) // 2 + cnt_neg * (cnt_neg - 1) // 2
pair_neg = cnt_pos * cnt_neg
pair_zro = N * (N - 1) // 2 - pair_pos - pair_neg

if pair_neg >= K:
    # Negative
    ub = 10 ** 18 + 1
    lb = 0
    while ub - lb > 1:
        mid = (ub + lb) // 2

        # Count
        cnt = 0
        j = 0
        for v in reversed(neg):
            while j < cnt_pos and v * pos[j] < mid:
                j += 1
            cnt += cnt_pos - j

        if cnt < K:
            ub = mid
        else:
            lb = mid

    print(-lb)
elif pair_neg + pair_zro >= K:
    print(0)
else:
    # Non-negative
    ub = 10 ** 18 + 1
    lb = 0
    while ub - lb > 1:
        mid = (ub + lb) // 2
        cnt = 0

        # Negative count
        j = 0
        for v in reversed(neg):
            if v ** 2 <= mid:
                cnt -= 1
            while j < cnt_neg and v * neg[j] < mid:
                j += 1
            cnt += j

        # Positive count
        j = 0
        for v in reversed(pos):
            if v ** 2 <= mid:
                cnt -= 1
            while j < cnt_pos and v * pos[j] < mid:
                j += 1
            cnt += j

        # Remove duplicate
        cnt //= 2

        if cnt + pair_neg + pair_zro < K:
            lb = mid
        else:
            ub = mid

    print(lb)


Measured memory_bytes: 97532
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CPeaks solver = new CPeaks();
    solver.solve(1, in, out);
    out.close();
  }

  static class CPeaks {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt(), m = in.nextInt();

      List<Integer> h = new ArrayList<>();
      List<Boolean> V = new ArrayList<>();
      for (int i = 0; i < n; i++) {
        h.add(in.nextInt());
        V.add(true);
      }

      while (m > 0) {
        int u = in.nextInt() - 1, v = in.nextInt() - 1;
        if (h.get(u) >= h.get(v))
          V.set(v, false);
        if (h.get(u) <= h.get(v))
          V.set(u, false);
        m--;
      }

      int ans = V.stream().mapToInt(x -> x ? 1 : 0).sum();
      out.println(ans);
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

  }
}



Measured memory_bytes: 54304
# coding: utf-8

a = list(int(input()) for i in range(5))
k = int(input())

# print(a, k)
for i in range(5):
    for j in range(4):
        if a[j + 1] - a[i] > k:
            print(':(')
            exit()
else:
    print('Yay!')

Measured memory_bytes: 3060
import Text.Printf
import Data.List

main = do
  s1 <- getLine
  s2 <- getLine
  let l = map (read :: String->Int) $ words s2
  putStr $ show $ minimum l
  ;putStr " "
  ;putStr $ show $ maximum l
  ;putStr " "
  ;putStrLn $ show $ sum l

Measured memory_bytes: 11116
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      char[] str = sc.next().toCharArray();
      int n = 0;
      while(n < str.length){
      	System.out.print(str[n]);
        n += 2;
      }
    }
}

Measured memory_bytes: 29512
function Main(input){
	input = input.split("\n");
  input.shift()
  input = input[0].split(" ").map(a=>~~a);
  
  return saiki(input,0);
}

function saiki(arr,zero){
	if(arr.length==0)return 0;
  var minInd = 0;
  var minVal = arr[0];
  var len = arr.length;
  for(var i = 1; i < len;i++){
  	var v = arr[i];
    if(minVal > v){
    	minInd = i;
      minVal = v;
    }
  }
  var left = arr.slice(0,minInd);
  var right = arr.slice(minInd+1);
  return (minVal-zero) + saiki(left,minVal) + saiki(right,minVal);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8
4 23 75 0 23 96 50 100
`);

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
   
struct node{
    int key;
    struct node *next;
    struct node *prev;
};
   
typedef struct node * NodePointer;
NodePointer nil;
 
void insert(int keydata){
    NodePointer x;
    x = malloc(sizeof(struct node));
    x->key = keydata;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
    x->next->prev = x;
}
 
int delete(int keydata){
    NodePointer p;
    p = nil->next;

    while(p != nil && p->key != keydata){
        p = p->next;
    }

    if(p == nil){
        return 0;
    }
    
    else{
        p->prev->next = p->next;
        p->next->prev = p->prev;
        free(p);

        return 0;
    }
}
 
int deleteFirst(){
    NodePointer p;
    p = nil->next;
    nil->next = p->next;
    p->next->prev = nil;
    free(p);

    return 0;
}

int deleteLast(){
    NodePointer p;
    p = nil->prev;
    p->prev->next = nil;
    nil->prev = p->prev;
    free(p);

    return 0;
}
 
void init(){
    nil->next = nil;
    nil->prev = nil;
}
 
int main(){
    int n, i, keydata;
    char com[12];

    NodePointer p;

    scanf("%d",&n);
    nil=malloc(sizeof(struct node));
    init();
    
    for(i=0;i<n;i++){
        scanf("%s",com);

        if(strlen(com)>6){
            if(com[6]=='F') {
                deleteFirst();
            }
            else{
                deleteLast();
            }
        }
        else{
            scanf("%d",&keydata);
            if(com[0]=='i'){
                insert(keydata);
            }
            else{
                delete(keydata);
            }
        }
    }
  
    for(p = nil->next; p != nil->prev; p = p->next){
        printf("%d ",p->key);
    }
    
    printf("%d\n",p->key);
    free(nil);
    
    return 0;
}

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

using namespace std;
using ll=long long;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 303; 
ll dp[N][N];

void solve() {
    int n, K;
    cin >> n >> K;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    if (n == K) {
        cout << 0; return;
    }
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        dp[i+1][1] = a[i];
        for (int j = 1; j <= i; j++) {
            for (int k = 0; k < i; k++) {
                dp[i+1][j+1] = min(dp[i+1][j+1], dp[k+1][j] + max(0, a[i] - a[k]));
            }
        }
    }
    ll res = INF;
    for (int i = 0; i <= n; i++) {
        res = min(res, dp[i][n-K]);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
# define ALL(x) (x).begin(), (x).end()
using namespace std;
int main()
{int a,b;
 cin>>a>>b;
 if (a<=8&&b<=8){cout<<"Yay!"<<endl;}
 else {cout<<":("<<endl;}
    

}


Measured memory_bytes: 256
# input = sys.stdin.readline

def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    cnt = [False] * 8
    tuyo = 0
    for i in range(N):
        if 1 <= A[i] <= 3199:
            cnt[A[i] // 400] = True
        else:
            tuyo += 1

    val = 0
    for i in cnt:
        if i:
            val += 1
    if val==0 and tuyo>0:
        print(1,tuyo)
    else:
        print(val, val + tuyo)


resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>
#include <list>
using namespace std;

int N;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N;
    int groupNum = N/3;
    cout << groupNum;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n,k;cin>>n>>k;
 ll md[k+10]={0};
 rep(i,1,n+1)md[i%k]++;
 ll ans=llpow(md[0],3);
 if(k%2==0)ans+=llpow(md[k/2],3);
 pr(ans);
return 0;}


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

int main() {
	int a[4][3][10]={0},n,b,f,r,v;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;++i) {
		for(int j=0;j<3;++j) {
			printf(" %d %d %d %d %d %d %d %d %d %d\n"
					,a[i][j][0]
					,a[i][j][1]
					,a[i][j][2]
					,a[i][j][3]
					,a[i][j][4]
					,a[i][j][5]
					,a[i][j][6]
					,a[i][j][7]
					,a[i][j][8]
					,a[i][j][9]);

		}
		if(i==3) break;
		printf("####################\n");
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std ;
double dp[4000][4000];

int main(){
    int n;cin>>n;
    double p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j)dp[i][j]+=dp[i-1][j-1]*p[i-1];
            dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++){
        if(i>n-i)ans+=dp[n][i];
    }
    cout.precision(15);
    cout<<ans;
    
}

Measured memory_bytes: 92800
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int64 X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<int64> A(X);
	vector<int64> B(Y);
	vector<int64> C(Z);
	rep (i, X) cin >> A[i];
	rep (i, Y) cin >> B[i];
	rep (i, Z) cin >> C[i];
	sort(all(A)); reverse(all(A));
	sort(all(B)); reverse(all(B));
	sort(all(C)); reverse(all(C));
	vector<int64> ans;
	rep (a, X) {
		rep (b, Y) {
			if ((a + 1) * (b * 1) > K) break;
			rep (c, Z) {
				if ((a + 1) * (b + 1) * (c + 1) > K) break;
				ans.push_back(A[a] + B[b] + C[c]);
			}
		}
	}
	sort(all(ans)); reverse(all(ans));
	rep (i, K) {
		cout << ans[i] << endl;
	}
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 1404
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int N, L[200];
	cin >> N;
	N *= 2;
	REP(i, N) cin >> L[i];
	sort(L, L + N);
	int res = 0;
	N /= 2;
	REP(i, N) res += L[i * 2];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1') cout<<"9";
        else cout<<"1";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
P = 10**9+7
ans = 1
X = [0, 0, 0]
for a in A:
    c = X.count(a)
    ans = ans * c % P
    if X[0] == a:
        X[0] += 1
    elif X[1] == a:
        X[1] += 1
    else:
        X[2] += 1
print(ans)


Measured memory_bytes: 53612
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    int n; cin >> n;
    vi p(n); cin >> p;

    int cnt = 0;

    rep(i,n){
        if(p[i] != i+1){
            cnt++;
        }
    }
    
    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256