akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#define MN 200000
#define mod 1000000007
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m,a[MN+5],num[MN+5];
struct data{int x,num;
data operator + (const data&b)
{
if(x==b.x) return (data){x,num+b.num};
else return x<b.x?*this:b;	
}
};
struct Tree{int l,r,val;data x;}T[MN*4+5];
void Build(int x,int l,int r)
{
if((T[x].l=l)==(T[x].r=r)){T[x].x=(data){0,1};return;}
int mid=l+r>>1;
Build(x<<1,l,mid);Build(x<<1|1,mid+1,r);
T[x].x=T[x<<1].x+T[x<<1|1].x;
}
inline void Mark(int x,int v){T[x].val+=v;T[x].x.x+=v;}
inline void pushdown(int x){Mark(x<<1,T[x].val),Mark(x<<1|1,T[x].val);T[x].val=0;}
void Modify(int x,int l,int r,int v)
{	
if(T[x].l==l&&T[x].r==r) return Mark(x,v);
int mid=T[x].l+T[x].r>>1;
if(T[x].val) pushdown(x);
if(r<=mid) Modify(x<<1,l,r,v);
else if(l>mid) Modify(x<<1|1,l,r,v);
else Modify(x<<1,l,mid,v),Modify(x<<1|1,mid+1,r,v);
T[x].x=T[x<<1].x+T[x<<1|1].x;
}
int main()
{
n=read();m=read();Build(1,1,n);
for(int i=1;i<=n;++i) ++num[a[i]=read()];
for(int i=1;i<=n;++i) if(num[i]) Modify(1,max(1,i-num[i]+1),i,1);
for(int i=1;i<=m;++i)
{
int x=read(),v=read();
--num[a[x]];if(a[x]-num[a[x]]>0) Modify(1,a[x]-num[a[x]],a[x]-num[a[x]],-1);
if(v-num[v]>0) Modify(1,v-num[v],v-num[v],1);++num[a[x]=v];
printf("%d\n",T[1].x.x>0?0:T[1].x.num);
}
return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N, K;

	cin >> N >> K;

	vector<pair<ll,ll>> a(N + 1);
	repn(i, N) cin >> a[i].first >> a[i].second;

	sort(++a.begin(), a.end());

	ll t = 0;

	while (K > 0) {
		t++;
		K -= a[t].second;
		
	}

	cout << a[t].first;
	
	system("PAUSE");
}


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

const int moder = int(1e9) + 7;
const int inv2 = (moder + 1) / 2;

int main(){
    int n;
    scanf("%d", &n);
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < n; ++ i){
        int x;
        scanf("%d", &x);
        sum1 = (sum1 + x) % moder;
        sum2 = (sum2 + 1ll * x * x) % moder;
    }
    int ans = (1ll * sum1 * sum1 - sum2) % moder;
    ans = 1ll * ans * inv2 % moder;
    ans += ans < 0 ? moder : 0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin >> N;
  LL LCM=1;
  for(int i=0;i<N;i++){
	LL tmp;
	cin >>tmp;
	LCM=boost::math::lcm(LCM,tmp);
  }
  cout << LCM << endl;
  return 0;

}

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;
int main(){
  int a;
  cin >> a;
  vector<int>tako(a);
  rep(i,a)cin >> tako[i];
  ll sum = 0;
  rep(i,a)for(int j = i+1;j<a;j++)sum += tako[i] * tako[j];
  cout << sum << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc124/tasks/abc124_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    // 同じ数が連続したら1つとして扱う
    int seq = 0;
    char before = S.front();
    vector<pair<char, int>> v;
    if (S.front() == '0') {
        v.emplace_back('1', 0);
    }
    S += ' ';
    REP(i, S.size()) {
        if (S[i] != before) {
            v.emplace_back(before, seq);
            seq = 0;
        }
        seq++;
        before = S[i];
    }
    if (S.back() == '0') {
        v.emplace_back('1', 0);
    }
    // 1,[0,1,0..],1を探す
    int cnt0 = 0, cnt1 = 0, sum = 0, ans = 0;
    queue<int> st;
    REP(i, v.size()) {
        sum += v[i].second;
        st.push(v[i].second);
        if (v[i].first == '0') {
            cnt0++;
            if (cnt0 > K) {
                cnt0--;
                REP(i, 2) {
                    sum -= st.front();
                    st.pop();
                }
            }
        } else {
            cnt1++;
            if (cnt1 > K + 1) {
                cnt1--;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 5528
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin>>a>>b;
    
    ll dif=b-a;
    ll x=dif*(dif-1)/2;
    cout1(x-a)
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
c = (10**9)+7
s = list(set(list(range(n+1)))-set(a))
dp = [0 for i in range(n+1)]
for i in s:
    if i == 0:
        dp[i] = 1
    elif i == 1:
        dp[i] = 1
    else:
        dp[i] = dp[i-1]+dp[i-2]
print(dp[n]%c)

Measured memory_bytes: 463952
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

map<int, int> cnt;

int num(int m){
    int res = 0;
    for(auto p : cnt){
        if(p.second >= m-1) res++;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        map<ll, ll> pf = prime_factor(i);
        for(auto p : pf){
            cnt[p.first] += p.second;
        }
    }
    ll ans = num(75) + num(25)*(num(3)-1) + num(15) * (num(5)-1)
        + num(5) * (num(5)-1) * (num(3) - 2) / 2;
    cout << ans << endl;
	return 0;
}

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

int main() {
  int N,i,count=1;
  
  cin >> N;
  int d[N];
  
  for(i=0;i<N;i++) cin >> d[i];
  
  sort(d,d+N);
  
  for(i=0;i<N-1;i++) {
    if(d[i] != d[i+1]) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int a, b;
    cin >> a >> b;

    cout << (a-1)*(b-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
   
    char s[100];
    
    bool ans=false;

    cin >> s;
    for(int i=0;i<2;i++){
        if((s[i])!=s[i+1]){
            ans=true;
        }
        else continue;
    }
        
        if(ans==true) cout << "Yes" << endl;
        else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,m;
  bool kk[31][31];
  for (int i=0;i<31;i++) {
    for (int j=0;j<31;j++){
      kk[i][j] = false;
    }
  }

  cin >> n >> m;
  for (int i=0;i<n;i++) {
    int k;
    cin >> k;
    while (k>0) {
      int fav;
      cin >> fav;
      kk[i][fav] = true;
      k--;
    }
  }
  int fav_by_all = 0;
  for (int j=1;j<=m;j++) {
    int fav_total = 0;
    for (int i=0;i<n;i++) {
      if (kk[i][j]) {
	fav_total++;
      }
    }
    if (fav_total == n) {
      fav_by_all++;
    }
  }
  cout << fav_by_all << endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int k,x,m,i,j;
     cin>>k>>x;
     m=k-1;
     for(i=1;i<=(2*k-1);i++,m--)
     {

         j=x-m;
         cout<<j<<" ";
     }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll n, a[N];

void solve()
{
    cin >> n;
    for (int i=0; i<n; ++i) cin >> a[i];
    int ans=0, cnt=1;
    for (int i=1; i<n; ++i) {
        if (a[i]<=a[i-1]) cnt++;
        else{
            ans=max(ans,cnt); cnt=1;
        }
    }ans=max(ans,cnt);
    nout(ans-1);
}

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

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

const int MOD = 1e9 + 7;

int h, w, d[3] = {0, 1, 0};
int dp[1010][1010], grid[1010][1010];

int solve(int i, int j) {
	if (i == h && j == w) return 1;
	if (dp[i][j] != -1) return dp[i][j];
	
	int ans = 0;
	
	for (int k = 0; k < 2; ++k) {
		int ni = i + d[k], nj = j + d[k+1];
		if (ni <= h && nj <= w && grid[ni][nj]) {
			ans = (ans + solve(ni, nj)) % MOD;
		}
	}
	
	return dp[i][j] = ans%MOD;
}

int main() {
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			char c; cin >> c;
			grid[i][j] = (c=='.');
			dp[i][j] = -1;
		}
	}

	cout << solve(1, 1) << "\n";
	
	return 0;
}


Measured memory_bytes: 8320
n = int(input())
a = [(int(j), i) for i, j in enumerate(input().split())]
a.sort(reverse=1)
dp = [[0] * (n+1) for _ in range(n + 1)]

for i in range(1, n + 1):
    for j in range(i + 1):
        k = i - j
        if j != 0:
            dp[i][j] = dp[i - 1][j - 1] + a[i-1][0] * (abs(j - 1 - a[i-1][1]))
        if k != 0:
            dp[i][j] = max(dp[i][j],
                           dp[i - 1][j] + a[i-1][0] * (abs(n-k - a[i-1][1])))
print(max(dp[-1]))

Measured memory_bytes: 100252
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int flag=0;
		while(sc.hasNext())
		{
			int st = sc.nextInt();
			int fi = sc.nextInt();
			if(st==0 && fi==0)
				return;
			if(flag!=0)
				System.out.println();
			boolean judge = true;
			for(int i = st; i<=fi; i++)
			{
				if(i%4==0 && i%100!=0 || i%400==0)
				{
					System.out.println(i);
					judge = false;
				}
			}
			if(judge)
				System.out.println("NA");
			flag=1;
		}	
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll cntr = 0, cntg = 0, cntb = 0;
    rep(i, n){
        if(s.at(i) == 'R') cntr++;
        if(s.at(i) == 'G') cntg++;
        if(s.at(i) == 'B') cntb++;
    }
    ll sum = cntr * cntg * cntb;
    cntr = 0;
    cntg = 0;
    cntb = 0;
    REP(i, n){
        rep(k, i){
            cntr = 0;
            cntg = 0;
            cntb = 0;
            for(int j = 0; j+k < n; j += i){
                if(s.at(k+j) == 'R') cntr = 3;
                if(s.at(k+j) == 'G') cntg = 3;
                if(s.at(k+j) == 'B') cntb = 3;
                
                if(cntr > 0 && cntb > 0 && cntg > 0) sum--;
                //cout << cntr << cntg << cntb << endl;
                if(cntr != 0) cntr--;
                if(cntg != 0) cntg--;
                if(cntb != 0) cntb--;
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Linq;

namespace abc129
{
    class B
    {
        static void Main(string[] args)
        {
            var N = Input.Int();
            var W = Input.IntArray();

            var l = 0;
            var r = W.Sum();
            int min = r;

            for (int i = 0; i < N; i++)
            {
                l += W[i];
                r -= W[i];
                if (Math.Abs(l - r) < min) {
                    min = Math.Abs(l - r);
                } else {
                    break;
                }
            }

            Console.WriteLine(min);
        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }

    }
}

Measured memory_bytes: 13396
from sys import stdin

def main():
    readline = stdin.readline
    n = int(readline())
    s = tuple(readline().strip() for _ in range(n))

    plus, minus = [], []
    for c in s:
        if 2 * c.count('(') - len(c) > 0:
            plus.append(c)
        else:
            minus.append(c)

    plus.sort(key = lambda x: x.count(')'))
    minus.sort(key = lambda x: x.count('('), reverse = True)
    plus.extend(minus)
    sum = 0
    for v in plus:
        for vv in v:
            sum = sum + (1 if vv == '(' else -1)
            if sum < 0 : return print('No')
    if sum != 0:
        return print('No')

    return print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 47376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}
int fac[100001];
int inv[100001];
int comb(int a,int b){
    if(a<b)
        return 0;
    return ((fac[a] * inv[b] )%mod* inv[a - b]%mod);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;
    while (tc--)
    {
        int n, k;
        cin >> n>>k;
        int a[n];
        for (int i = 0; i < n;i++){
            cin >> a[i];
        }
        sort(a, a + n);
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= n;i++){
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = power(fac[i], mod - 2, mod);
        }
        int ans = 0;
        for (int i = 0; i < n;i++){
            ans = (ans + comb(i, k - 1) * a[i]) % mod;
            ans = (ans - comb(n-i-1, k - 1) * a[i]) % mod;
            //cout << ans << " ";
            if(ans<0){
                ans += mod;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
struct Card
{
	char suit, value;
};
void bubble(Card A[], int N)
{
	for (int i = 0; i<N; i++)
	{
		for (int j = N - 1; j>i; j--)
		{
			if (A[j].value<A[j - 1].value)
			{
				Card temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
			}
		}
	}
}
void selection(Card A[], int N)
{
	for (int i = 0; i<N; i++)
	{
		int minJ = i;
		for (int j = i + 1; j<N; j++)
		{
			if (A[minJ].value>A[j].value)
			{
				minJ = j;
			}
		}
		Card temp = A[minJ];
		A[minJ] = A[i];
		A[i] = temp;
	}
}
void print(Card A[], int N)
{
	for (int i = 0; i<N; i++)
	{
		cout << A[i].suit << A[i].value;
		if (i != N - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}
bool isStable(Card c1[],Card c2[], int N)
{
	for (int i = 0; i<N; i++)
	{
		if (c1[i].suit != c2[i].suit) return false;
	}
	return true;
}
int main()
{
	Card c1[100], c2[100];
	int N;
	cin >> N;
	for (int i = 0; i<N; i++)
	{
		cin >> c1[i].suit >> c1[i].value;
	}
	for (int i = 0; i<N; i++) c2[i] = c1[i];
	bubble(c1, N);
	selection(c2, N);
	print(c1, N);
	cout << "Stable" << endl;
	print(c2, N);
	if (isStable(c1, c2, N))
	{
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        string S;
        cin >> S;

        if (odd(N)) {
                cout << "No" << endl;
                return 0;
        }

        string T = S.substr(0, N/2);
        if (S == T+T) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 3608
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  string M;
  cin >> N>>M;
  if (N < 3200) {
    cout << "red";
  } else {
    cout << M;
  }


  
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
H, W, D = inpl()

L = [(0, 0) for _ in range(H*W + 1)]
DP = [0]*(H*W + 1)

for i in range(H):
    for j, a in enumerate(inpl()):
        L[a] = (i+1, j+1)

for x in range(D, H*W+1):
    DP[x] = DP[x-D] + abs(L[x][0] - L[x-D][0]) + abs(L[x][1] - L[x-D][1])

for _ in range(int(input())):
    l, r = inpl()
    print(DP[r] - DP[l])

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N, 0);  
  for(ll i = 1; i < N; i++) {
    cin >> A.at(i);
    B.at(A.at(i) - 1)++;
  }
  for(ll i = 0; i < N; i++) cout << B.at(i)<< endl;
}

Measured memory_bytes: 6428
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {

    int N;
    cin >> N;

    int L[2*N];

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

    sort(L,L+2*N);
    int sum = 0;

    for(int i=0;i<2*N;i+=2){
        sum += min(L[i],L[i+1]);
    }

    cout << sum << endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[3];	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<(a[2]*10+a[1])+a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        int a, b;
        cin >> a >> b;

        string u;
        cin >> u;

        if (s == u) {
                cout << a - 1 << " " << b << endl;
        } else {
                cout << a << " " << b - 1 << endl;
        }

        return 0;
}


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

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> a(M), b(M), c(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i]>> c[i];
        --a[i], --b[i];
    }

    const int inf = 1e18;
    vector<int> dist(N, -1e18);
    dist[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (dist[a[j]] == -inf) continue;
            if (dist[a[j]] + c[j] <= dist[b[j]]) continue;
            dist[b[j]] = dist[a[j]] + c[j];
            if (i == N - 1 && b[j] == N - 1) return cout << "inf" << endl, 0;
        }
    }
    cout << dist[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
ans=[["#"]*(w+2)]
for i in range(h):
  temp=list(map(str,input()))
  temp.insert(0,"#")
  temp.append("#")
  ans.append(temp)
ans.append(["#"]*(w+2))
for i in range(h+2):
  print("".join(ans[i]))

Measured memory_bytes: 3060
n,k,*v=map(int,open(0).read().split())
m=0
r=range
for i in r(n+1):
 for j in r(min(k-i+1,n-i+1)):
  t=sorted(v[:i]+v[-j:]*(j>0))[::-1];c=k-i-j
  while t and c and t[-1]<0:t.pop();c-=1
  m=max(m,sum(t))
print(m)

Measured memory_bytes: 3060
import math
a,b,x = map(int,input().split())
# 割合
l = x / (a*a*b)
c = b*l
if (b == c):
    print(0)
    exit()
elif(c>=b/2):
    t = a/(b-c)/2
else:
    t = 2*a*c/b**2

print('{:.8f}'.format(90-math.degrees(math.atan(t))))



Measured memory_bytes: 38256
#include <stdio.h>
#include <vector>
using namespace std;
int main(void){
    long long a,b,p,gcd,ans;
    scanf("%lld",&a);
    scanf("%lld",&b);
    ans = 0;
    if(b<a)
    {
        p=a;
        a=b;
        b=p;
    }
    while(a>0)
    {
        p=a;
        a=b%a;
        b=p;

    }
    gcd=b;
    //printf("%d\n1 ",gcd);
    for(long long i=2;i*i<gcd;i++)
    {
        if(b%i)
        {
            continue;
        }
        while(b%i==0)
        {
            b/=i;
            
        }
        //printf("%lld ",i);
        ans++;
    }
    if(b!=1)
    {
        //printf("%d",b);
        ans++;
    }
    printf("%lld",ans+1);

   return 0;
}

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

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

  int x;
  cin >> x;
  int q, r;
  q = x / 500;
  r = x % 500;
  int res = q * 1000 + r / 5 * 5;
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer a = Integer.parseInt(scan.next());
        Integer b = Integer.parseInt(scan.next());

        if(n * a < b)
            System.out.println(n*a);
        else
            System.out.println(b);
    }
}

Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
total1 = 0
total2 = sum(w)
diff = [0] * n
for i in range(n):
  total1 += w[i]
  total2 -= w[i]
  diff[i]= abs(total1 - total2)
print(min(diff))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
int main() {
    int i;
    int v[26] = {0};
    string s;
    cin >> s;
    for (i=0;i<s.size();i++) {
        v[(int) s[i] - 97]++;
    }
    for (i=0;i<26;i++) {
        if (v[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import itertools
from collections import defaultdict

N, X, Y = map(int, input().split())
ans = defaultdict(int)

def dis(x, y):
  d1 = abs(x - y)
  d2 = abs(X - x) + 1 + abs(Y - y)
  return min(d1, d2)

for p in itertools.combinations(range(1, N+1), 2):
  d = dis(p[0], p[1])
  ans[d] += 1

for i in range(1, N):
  if i in ans:
    print(ans[i])
  else:
    print(0)

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main(){
	while(true){
		int n, x, count = 0;
		cin >> n >> x;
		if(n == 0 && x == 0) break;
		for(int i = 1; i <= n - 2; i++){
			for(int j = i + 1; j <= n - 1; j++){
				for(int k = j + 1; k <= n; k++){
					if(i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
b = [a[i+1] - a[i] for i in range(len(a) - 1)]
b.sort()
if n == 1:
  print(sum(b))
elif len(b) <= n-1:
  print(0)
else:
  print(sum(b[0:-n+1]))


Measured memory_bytes: 13840
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  while(cin >> n, n != 0){
    string s;
    cin >> s;
    int ba = 0, p = 0, score[15] = {};
    rep(i, s.size()){
      p %= n;
      if(s[i] == 'M'){
	score[p] ++;
      } else if(s[i] == 'S'){
	score[p] ++;
	ba += score[p];
	score[p] = 0;
      } else {
	score[p] += 1 + ba;
	ba = 0;
      }
      p ++;
    }
    sort(score, score + n);
    rep(i, n){
      cout << score[i] << " ";
    }
    cout << ba << '\n';
  }
  return 0;
}



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

int main() {
    int H, W;
    std::cin >> H >> W;

    char c;
    bool S[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            std::cin >> c;
            if (c == '.') {
                S[i][j] = true;
            } else {
                S[i][j] = false;
            }
        }
    }

    const std::vector<std::pair<int, int>> directions = {
        {1, 0},
        {-1, 0},
        {0, 1},
        {0, -1}
    };

    int max = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == false) {
                continue;
            }

            std::queue<std::pair<int, int>> queue;
            queue.push({i, j});
            int dist[H][W];
            for (int k = 0; k < H; ++k) {
                for (int l = 0; l < W; ++l) {
                    dist[k][l] = -1;
                }
            }

            dist[i][j] = 0;
            while (queue.empty() == false) {
                const auto& p = queue.front(); 
                queue.pop();
                int cur_x = p.first,  cur_y = p.second;

                for (const auto& d : directions) {
                    int dx = cur_x + d.first;
                    int dy = cur_y + d.second;
                    if (dx < 0 || dx > (H-1) || dy < 0 || dy > (W-1)) {
                        continue;
                    }

                    if (S[dx][dy] == false) {
                        continue;
                    }

                    if (dist[dx][dy] != -1) {
                        continue;
                    }

                    dist[dx][dy] = dist[cur_x][cur_y] + 1;
                    queue.push({dx, dy});
                    max = std::max(dist[dx][dy], max);
                }
            }

        }
    }
   
    std::cout << max << std::endl; 

    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;
using VI = vector<int>;

int main() {
    int n;
    cin >> n;
    long ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main(){
  int n,k;
  cin >> n >> k;
  std::vector<int> vec(n,0);
  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int x;
      cin >> x;
      x--;
      vec.at(x) = 1;
    }
  }
  int cnt = 0;
  rep(i,n) {
    if (vec.at(i) == 0) cnt++;
  }
  cout << cnt << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

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


Measured memory_bytes: 3612
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
print("{} {} {} {}".format(x3,y3,x4,y4))


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

int main(){
  int N;cin>>N;
  N%=10;
  if (N==3){
    cout << "bon" << endl;
  }
  else if (N==0 || N==1||N==6||N==8){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;

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


Measured memory_bytes: 256
import sys
import bisect
r = sys.stdin.readline
N = int(r())
red = []
blue = []
for i in range(N):
    a, b = list(map(int, r().split()))
    red.append([a, b])
for i in range(N):
    c, d = list(map(int, r().split()))
    blue.append([c, d])

xblue = sorted(blue, key=lambda x: x[0])

i = 0
j = 0
ii = [True for i in range(2*N+1)]
jj = [True for i in range(2*N+1)]
ans = 0
for i in range(N):
    m = [-100000, -100000]
    for j in range(N):
        if ii[i] and jj[j] and red[j][0] < xblue[i][0] and red[j][1] < xblue[i][1]:
            if m[0] < red[j][1]:
                m[0] = red[j][1]
                m[1] = j
    if m[0] != -100000 and m[1] != -100000:
        ii[i] = False
        jj[m[1]] = False
        ans += 1

print(ans)

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

const int MAX_N = (int)1e5 + 5;
const lint MOD = (lint)1e9 + 7;
int A[MAX_N];
lint dp[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, M; cin>>N>>M;
    for(int i=0;i<M;i++){
        int a; cin>>a;
        A[a] = 1;
    }
    dp[0] = 1;
    dp[1] = A[1] ? 0 : 1;
    for(int i=2;i<=N;i++){
        if(!A[i]) dp[i] = (dp[i-1]+dp[i-2]) % MOD;
    }
    cout<<dp[N]<<endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	for(int z=0;z<n;z++){
		int t;
		cin >> t;
		int block[1000];
		for(int i=0;i<t;i++){
			cin >> block[i];
		}
		int ma=0,mi=0;
		for(int i=0;i<t-1;i++){
			ma = max(ma,block[i+1]-block[i]);
			mi = max(mi,block[i]-block[i+1]);
		}
		cout << ma << " " << mi << endl;
	}
	return 0;
}

	

Measured memory_bytes: 0
#!/usr/bin/env python3
import collections
N = int(input())
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]

if len(set(V1)) == 1 and len(set(V2)) == 1 and V1[0] == V2[0]:
    print(len(V1))
    exit()


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = sorted(C1.items(), key=lambda x:x[1])[::-1]
C2_s = sorted(C2.items(), key=lambda x:x[1])[::-1]

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    if len(set(V1)) == 1:
        ans = nokori2_2
    elif len(set(V2)) == 1:
        ans = nokori1_2
    else:
        ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)


Measured memory_bytes: 24196
using System;

namespace BeginnerContest_100_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hoge = Console.ReadLine().Split(' ');
            int d = int.Parse(hoge[0]);
            int n = int.Parse(hoge[1]);
            if (d == 0) {
                if (n == 100) { Console.WriteLine(101); }
                else Console.WriteLine(n); }
            else if (d == 1) {
                if (n == 100) { Console.WriteLine(10100); }
                else Console.WriteLine(n * 100); }
            else if (d == 2)
            {
                if (n == 100) { Console.WriteLine(1010000); }
                else Console.WriteLine(n * 10000);
            }

        }
    }
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    map <string,int> m;
    for(int i=0;i<n;i++){
        string st;
        cin >> st;
        m[st]++;
    }
    cout << "AC x " << m["AC"] << '\n';
    cout << "WA x " << m["WA"] << '\n';
    cout << "TLE x " << m["TLE"] << '\n';
    cout << "RE x " << m["RE"] << '\n';
}

Measured memory_bytes: 3664
def main():

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

    u = 0
    ans = 0
    for i in range(N):
        if u > A[i]:
            ans += u - A[i]
        u = max(A[i], u)
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 93908
#include <iostream>
using namespace std;
int main(){
  int n,r;
  cin >> n >> r;
  if (n >=10){
    cout << r;
  }
  else{
    int a = 10-n;
    int b= 100*a;
    int c= r+b;
    cout << c;
  }
    return 0;
}

Measured memory_bytes: 256
def main():
  while True:
    m, w = map(int, input().split())
    if m == 0:
      break
  
    if m >= w:
      long_lst = list(map(int, input().split()))
      short_lst = list(map(int, input().split()))
      rest = 2 ** m - 1
    else:
      short_lst = list(map(int, input().split()))
      long_lst = list(map(int, input().split()))
      rest = 2 ** w - 1
    mem = [None] * (rest + 1)
  
    def elec(bm, bw):
      bd = abs(bm - bw)
      return bd * (bd - 30) ** 2
  
    def score(rest, index):
      if mem[rest] != None:
        return mem[rest]
      if rest == 0 or index < 0:
        return 0
  
      mask = 1
      count = 0
      ret = 0
      while mask <= rest:
        if mask & rest:
          new_rest = rest & ~mask
          ret = max(ret, score(new_rest, index - 1) + elec(short_lst[index], long_lst[count]))
        mask <<= 1
        count += 1
  
      mem[rest] = ret
      return ret
  
    print(score(rest, min(m, w) - 1))
  
main()


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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))

typedef long long ll;


int main()
{
    FastRead

    ll n,k,cnt=0;

    cin>>n>>k;

    vector<ll>v(n+1,0);

    for(ll i=0;i<k;i++)
    {
        ll q,temp;

        cin>>q;

        while(q--)
        {
            cin>>temp;
            v[temp]++;
        }
    }

    for(ll i=1;i<=n;i++)
        if(v[i]==0)
            cnt++;

    cout<<cnt;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	cin >> s;
	int length = s.size();
	for (int i = 0; i < length; ++i)
	{
		cout << "x";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int main() {
	int a;
	cin >> a;
	int b = a / 1000;
	
	int c = a - b * 1000;

	
	if (c / 100 == b) {
		int d = c - (c / 100) * 100;
		
		if (d/10 == b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else {
		b = c / 100;
		c = c - b * 100;
		int d = c / 10;
		if (b == d) {
			c = c - d * 10;
			if (b == c) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

unsigned xor128() {
	static unsigned x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned t = x ^ (x << 11);
	x = y; y = z; z = w;
	return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}

typedef struct node_t {
	int val;
	struct node_t *lch, *rch;
	int size;
	unsigned int pri;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[200000];
	pool[it] = (node) { val, 0, 0, 1, xor128() };
	return &pool[it++];
}

int count(node *t) {
	return !t ? 0 : t->size;
}

node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	return t;
}

node *merge(node *l, node *r) {
	if (!l || !r) return !l ? r : l;
	if (l->pri > r->pri) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	r->lch = merge(l, r->lch);
	return update(r);
}

typedef struct{ node *a, *b; } pnode;

pnode split(node *t, int k) {
	if (!t) return (pnode) { 0, 0 };
	if (k <= count(t->lch)) {
		pnode s = split(t->lch, k);
		t->lch = s.b;
		return (pnode) { s.a, update(t) };
	}
	pnode s = split(t->rch, k - count(t->lch) - 1);
	t->rch = s.a;
	return (pnode) { update(t), s.b };
}

node* find(node *t, int val) {
	while (t) {
		if (t->val == val) break;
		t = val < t->val ? t->lch : t->rch;
	}
	return t;
}

int count_lower(node *t, int v) {
	if (!t) return 0;
	if (t->val < v) return count(t->lch) + 1 + count_lower(t->rch, v);
	if (t->val == v) return count(t->lch);
	return count_lower(t->lch, v);
}

node *insert(node *t, int val) {
	int k = count_lower(t, val);
	pnode s = split(t, k);
	return merge(merge(s.a, new_node(val)), s.b);
}

node *erase(node *t, int k) {
	pnode s1 = split(t, k), s2 = split(s1.b, 1);
	return merge(s1.a, s2.b);
}

void print(node *t) {
	if (!t) return;
	print(t->lch);
	printf("%d\n", t->val);
	print(t->rch);
}

int main(void)
{
	int q, com, x, l, r, cnt = 0;
	node *root = 0;
	pnode p1, p2;
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &com, &x);
		if (com == 0) {
			if (!find(root, x)) ++cnt, root = insert(root, x);
			printf("%d\n", cnt);
		}
		else if (com == 1) {
			puts(find(root, x) ? "1" : "0");
		}
		else if (com == 2) {
			if (find(root, x)) --cnt, root = erase(root, count_lower(root, x));
		}
		else {
			scanf("%d", &r);
			l = count_lower(root, x);
			r = count_lower(root, r + 1);
			p1 = split(root, l), p2 = split(p1.b, r - l);
			print(p2.a);
			root = merge(merge(p1.a, p2.a), p2.b);
		}
	}
	return 0;
}



Measured memory_bytes: 8044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n; cin>>n; ll a[n]; 
	map<ll,ll> m;
	ll s=0;
	for(int i=0;i<n;i++) cin>>a[i],m[a[i]]++,s+=a[i];
	ll q; cin>>q;
	while(q--){
		ll x,y; cin>>x>>y;
		s+=(y-x)*m[x];
		m[y]+=m[x];
		m[x]=0;
		cout<<s<<endl;
	}


}


Measured memory_bytes: 10188
#include <iostream>
#include <stdint.h>
using namespace std;

int main() {
  int64_t a, b, x;
  cin >> a;
  cin >> b;
  cin >> x;
  int64_t m = (a + (x - 1)) / x;
  int64_t n = b / x;
  cout << (((n - m) >= 0) ? (n - m + 1) : 0);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;
  for (int i = 0; i < int(s.length()) - 1; ++i) {
    if (s[i] == s[i + 1]) {
      std::cout << i + 1 << ' ' << i + 2 << std::endl;
      return 0;
    }
  }
  for (int i = 0; i < int(s.length()) - 2; ++i) {
    if (s[i] == s[i + 2]) {
      std::cout << i + 1 << ' ' << i + 3 << std::endl;
      return 0;
    }
  }
  std::cout << "-1 -1" << std::endl;
  return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, D;
    cin >> N >> D;
    vector<valarray<int>> X(N, valarray<int>(0, D));
    FOR(n, 0, N) {
        FOR(d, 0, D) {
            cin >> X.at(n)[d];
        }
    }
    int ans = 0;
    FOR(i, 0, N) {
        FOR(j, i + 1, N) {
            float x = sqrt(pow(X.at(i) - X.at(j), 2).sum());
            if (floor(x) == x) { ++ans; }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char S1[50],T[50];
    int i,j,o;
    int lenS1,lenT;
    int k,p,w=0;
    gets(S1);
    gets(T);
    lenS1=strlen(S1);
    lenT=strlen(T);
    for (i=0; i<=lenS1-lenT; i++)
    {
        k=0;
        p=1;
        for (j=i; j<i+lenT; j++)
        {
            if ((S1[j]!=T[k++])&&(S1[j]!='?'))
            {
                p=0;
            }
        }
        if (p==1)
        {
            o=i;
            w=1;
        }
    }
    if (w==1)
    {
        k=0;
        for (j=o; j<o+lenT; j++)
        {
            S1[j]=T[k++];
        }
        for (i=0; i<lenS1; i++)
        {
            if (S1[i]=='?')
            {
                S1[i]='a';
            }
        }
        puts(S1);
    }
    else
    {
        printf("UNRESTORABLE");
    }
    return 0;
}


Measured memory_bytes: 128