akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

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

int n, m;
bool p[500][500];
int l[500];
bool f[500];

int main() {
	ios::sync_with_stdio(false);
	
	while(cin>>n>>m,n|m) {
		rep(i, n) {
			f[i]=false;
			rep(j, n) {
				p[i][j]=false;
			}
		}
		
		int a, b;
		rep(i, m) {
			cin>>a>>b;
			p[a-1][b-1]=true;
			p[b-1][a-1]=true;
		}
		int t=0;
		rep(i, n) {
			if(p[0][i]) {
				l[t]=i;
				f[i]=true;
				t++;
			}
		}
		rep(i, t) {
			repi(j, 1, n) {
				if(p[l[i]][j])f[j]=true;
			}
		}
		int s=0;
		rep(i, n) {
			if(f[i])s++;
		}
		cout << s << endl;
	}
	
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

double dp[3005][3005];
double a[3005];
int n;

double f(int i, int h){
	if(i == n && h > n / 2) return 1.0;
	if(i == n) return 0.0;
	if(dp[i][h] != -1.0) return dp[i][h];
	return dp[i][h] = a[i] * f(i + 1, h + 1) + (1 - a[i]) * f(i + 1, h);
}

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

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i <= 3000; i++){
		for(int j = 0; j <= 3000; j++){
			dp[i][j] = -1.0;
		}
	}
	cout << fixed << setprecision(10) << f(0, 0);
}

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


int main(){
  int n;
  cin>>n;
  int a[1000],b[1000],c[1000],d[1000],g[1000];

  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    g[i]=a[i]*c[i]+b[i]*d[i];
    int p,q;
    p=5-c[i];
    q=2-d[i];
    if(p<=0 && q<=0){g[i]=g[i]*4/5; continue;}
    if(p<0){p=0;}
    if(q<0){q=0;}
    g[i]=min(g[i],(g[i]+p*a[i]+q*b[i])*4/5);
  }


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



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  while(cin>>s){
    vector<int> t;
    REP(i,9){
      char a=s[i]-'0';
      char b=s[i+1]-'0';
      int tmp=(a+b)%10;
      t.PB(tmp);
    }
    REP(j,9){
      vector<int> u;
      REP(i,t.size()-1){
        u.PB((t[i]+t[i+1])%10);
      }
      t=u;
    }
    cout<<t[0]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3132
# coding: utf-8
# Your code here!

def find(num):
    if num==root[num]:
        return root[num]
    else:
        return find(root[num])

N,M=map(int,input().split())

root=[i for i in range(N)]

clash=[]
for _ in range(M):
    a,b=map(int,input().split())
    a,b=min(a,b)-1,max(a,b)-1
    clash.append([a,b])
    
lis=[1]*N
lis2=[(N-1)]*N
ans=N*(N-1)
ans_lis=[]
root=[i for i in range(N)]
#print(wa)
while clash:
    

    ans_lis.append(ans)
    a,b=clash.pop(-1)
    """
    print(a,b)
    print(lis)
    print(lis2)
    print(root)
    print(ans)
    """
    root[a]=find(root[a])
    root[b]=find(root[b])
    #root[a]=min(root[a],root[b])
    a,b=min(root[a],root[b]),max(root[a],root[b])
    #print(a,b)
    #print("_____________________________")
    if a==b:
        continue
    if root[a]<=root[b]:
        root[b]=root[a]
    else:
        root[a]=root[b]
    
    ans-=lis[a]*lis2[a]
    ans-=lis[b]*lis2[b]
    lis[a]+=lis[b]
    lis2[a]-=lis[b]
    lis[b]-=lis[b]
    lis2[b]-=lis2[b]
    ans+=lis[a]*lis2[a]


for item in ans_lis[::-1]:
    print(item//2)

    
    

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

int main() {
  string s, t, key = "keyence";
  cin >> s;

  int n = s.size();

  for (int i = 0; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (s.substr(0, i) + s.substr(j) == key) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
n1 = int(input())

n2 = [int(i) for i in input().split()]

r1 = 0
m1 = n1 + 1

for i1 in range(n1):
    if n2[i1] < m1:
        r1 +=1
        m1 = n2[i1]

print(r1)

Measured memory_bytes: 25768
fun main(args: Array<String>) {
    val q = readLine()!!.split(' ')[1].toInt()
    var sum = 0
    var pre = ' '
    val totals = readLine()!!.map { c ->
        if (pre == 'A' && c == 'C') sum++
        pre = c
        sum
    }
    repeat(q) {
        val (l, r) = readLine()!!.split(' ').map { it.toInt() - 1 }
        println(totals[r] - totals[l])
    }
}


Measured memory_bytes: 67700
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int[] heap = new int[h + 1];
		for (int i = 1; i <= h; i++)
			heap[i] = scan.nextInt();
		buildMaxHeap(heap);
		for (int i = 1; i <= h; i++)
			System.out.print(" " + heap[i]);
		System.out.println();
	}
	
	void maxHeapify(int[] a, int i) {
		int left = 2 * i;
		int right = 2 * i + 1;
		int largest = 0;
		if (left <= (a.length - 1) && a[left] > a[i])
			largest = left;
		else
			largest = i;
		if (right <= (a.length - 1) && a[right] > a[largest])
			largest = right;
		if (largest != i) {
			int tmp = a[i];
			a[i] = a[largest];
			a[largest] = tmp;
			maxHeapify(a, largest);
		}
	}
	
	void buildMaxHeap(int[] a) {
		for (int i = (a.length - 1) / 2; i >= 1; i--)
			maxHeapify(a, i);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 167636
#include<cstdio>
long long a,b,x;
long long s,e;
int main() {
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a%x==0)s=a/x;
	else s=a/x+1;
	e=b/x;
	printf("%lld",e-s+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
string s;
int main()
{
    cin>>s;
    int ans=1;
    if(s=="SSS")ans=0;
    if(s=="RRS"||s=="SRR")ans=2;
    if(s=="RRR")ans=3;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
memo = {}

def fib(n):
    key = n
    
    if key in memo:
        return memo[key]
    
    if n == 0:
        return 1
    if n == 1:
        return 1
    if n > 1:
        memo[key] = fib(n-1) + fib(n-2)
    
    return memo[key]

n = int(input())
print(fib(n))

Measured memory_bytes: 7728
#include<stdio.h>

int main(void){

  int i;
  char moji;

  scanf("%c", &moji);

  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
  return 0;
}



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

using namespace std;
int main(){
	string a;
	string b;
	int counter = 0;
	cin >> a;
	int l = a.size();

	while(1){
		cin >> b;
		if(b == "END_OF_TEXT"){
			break;
		}
		int lb= b.size();
		for(int i=0;i<l;i++){
			if(l !=lb){
				break;
			}
			if(a[i] != tolower(b[i])){
				break;
			}
			if(i == l-1){
				counter++;
			}
		}

	}
	cout << counter <<"\n";
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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() {
	string S;
	cin >> S;

	int N = S.length();
  int getted = 0;
  rep(i,N){
  	if(S[N-1-i]=='B'){
  		getted ++ ;
  	}else{
    break;
    }
    
  }

	int cnt = 0;
	rep(i,N){
		if(S[N-1-i] == 'B' && getted < i+1){
			cnt += (i-getted);
			getted++;
		}
	}


	ll ans = 0;
	ll th_W = 0; 
rep(i,N){
	if(S[i] == 'W'){
		ans += (i-th_W++);
	}
}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 640
N = int(input())
p = list(map(int,input().split()))

cnt = 0
i = 0
while i < N:
    if p[i] == i+1:
        cnt += 1
        if i < N-1:
            if p[i+1] == i+2:
                i += 1
    i += 1

print(cnt)

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

int main(){
    int N, K;
    cin >> N >> K;
    int a = N / K;
    if (K % 2 == 1) {
        long long ans = pow(a, 3);
        cout << ans << endl;
    }
    else{
        int b = a;
        if (N % K >= K / 2) b++;
        long long ans = pow(a, 3) + pow(b, 3);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int s;cin>>s;
    int so = 0;
    if(s == 4||s==2||s==1){
      cout<<"4";
      return 0;
    }
    for(int i = 1;;i++){
      if(s%2 == 0) s=s/2;
      else s = 3*s+1;
      if(s == 4){
        so+= 1;
        if(so == 2){
          cout<<i+1;
          return 0;
        }
      }
    }
    return 0;
}

Measured memory_bytes: 3624
A,B,C = map(int, input().split())

count = 0
while(A%2==0 and B%2==0 and C%2==0):
  if A==B==C:
    count = -1
    break
    
  tot = A+B+C
  A = (tot-A)/2
  B = (tot-B)/2
  C = (tot-C)/2
  count+=1

print(count)

Measured memory_bytes: 9200
XY = input().split(" ")

X = int(XY[0])
Y = int(XY[1])
ans = "No"
for i in range(X + 1):
    crane = 2 * (X - i)
    turtle = 4 * i
    if crane + turtle == Y:
        ans = "Yes"
        break
    
print(ans)

Measured memory_bytes: 9068
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;


int main(void){
	int n;
	cin>>n;
	vector<ll> a;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	ll cost1=0,cost2=0;
	ll check=1,now=0;
	ll hoge;
	for(int i=0;i<n;i++){
		now=now+a[i];
		hoge=max((ll)0,(check-now)*check);
		now=now+check*hoge;
		cost1=cost1+hoge;
		check=check*(ll)-1;
	}
	check=-1,now=0;
	for(int i=0;i<n;i++){
		now=now+a[i];
		hoge=max((ll)0,(check-now)*check);
		now=now+check*hoge;
		cost2=cost2+hoge;
		check=check*(ll)-1;
	}
	cout<<min(cost1,cost2)<<endl;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        System.out.println(d[n / 2] - d[n / 2 - 1]);
    }

}


Measured memory_bytes: 50108
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;
int n, a[100009][3], dp[100009][3];


int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
	//memset(dp, 0x3f, sizeof(dp));
	for (int j = 0; j < 3; j++) dp[0][j] = a[0][j];
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i + 1][(j + 1) % 3] = max(dp[i + 1][(j + 1) % 3], dp[i][j] + a[i + 1][(j + 1) % 3]);
			dp[i + 1][(j - 1 + 3) % 3] = max(dp[i + 1][(j - 1 + 3) % 3], dp[i][j] + a[i + 1][(j - 1 + 3) % 3]);
		}
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 2560
n = input()
last_word = raw_input()
arr = [last_word]
f = 0
for i in range(n-1):
    str = raw_input()
    if str in arr:
        f = 1
        break
    elif str[0] == last_word[-1]:
        last_word = str
        arr.append(str)
    else:
        f = 1
        break
if f == 0:
    print "Yes"
else:
    print "No"


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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int n;cin>>n;
    vector<int> leaf(n+1);
    vector<int> nonLeaf(n+1);
    vector<int> pref(n+1,0);
    for(int i=0;i<=n;i++){
        cin>>leaf[i];
    }
    for(int i=1;i<=n;i++){
        pref[i]=pref[i-1]+leaf[i];
    }
    if(leaf[0]>1){
        cout<<-1;
    } else {
        nonLeaf[0]=1-leaf[0];
        bool wrn=false;
        for(int i=1;i<=n;i++){
            int x=2*nonLeaf[i-1]-leaf[i];
            x=min(x,pref[n]-pref[i]);
            if(x<0){
                wrn=true;
                break;
            }
            nonLeaf[i]=x;
        }
        if(wrn)cout<<-1;
        else {
            int sum=0;
            for(int i=0;i<=n;i++){
                sum+=leaf[i]+nonLeaf[i];
            }
            cout<<sum;
        }
    }
}


Measured memory_bytes: 5616
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int m,d,ans;
int main()
{
	scanf("%d%d",&m,&d);
	for(int i=22;i<=d;i++)
	{
		int a=i/10,b=i%10;
		if(a>=2&&b>=2&&1<=a*b&&a*b<=m)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        char ch[n+1][m+1];
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
                cin>>ch[i][j];
        }
        ll dp[n+1][m+1]={0};
        dp[1][1]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(ch[i][j]=='#')
                dp[i][j]=0;
            else{

                if(i-1>=1)
                    {
                        dp[i][j]+=dp[i-1][j];
                        dp[i][j]%=mod;
                    }
                if(j-1>=1)
                {
                    dp[i][j]+=dp[i][j-1];
                    dp[i][j]%=mod;
                }
            }

                // cout<<dp[i][j]<<" ";

            }
            // cout<<endl;
        }

        cout<<dp[n][m];
    }

    return 0;
}

Measured memory_bytes: 12420
import sys
from pprint import pprint
from operator import add, sub

from collections import deque

s =[int(s_i) for s_i in sys.stdin.readline().strip()] 
# pprint(s)

for op1 in (add, sub):
    for op2 in (add, sub):
        for op3 in (add, sub):
             if op3 ( op2 ( op1 (s[0], s[1]), s[2]), s[3]) == 7:
                 tmp1 = "+" if op1 == add else "-"
                 tmp2 = "+" if op2 == add else "-"
                 tmp3 = "+" if op3 == add else "-"
                 print(str(s[0]) + tmp1 + str(s[1]) + tmp2 + str(s[2]) + tmp3 + str(s[3]) + "=7")
                 sys.exit()

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

using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

typedef long long int64;

int main() {
  int n, d;
  cin >> n >> d;

  auto range = d * 2 + 1;

  if(n%range > 0) {
    cout << n/range + 1 << endl;
  } else {
    cout << n/range << endl;
  }

  return 0;
}

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

int main() {
  vector<vector<int>> bingo(3, vector<int> (3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo.at(i).at(j);
    }
  }
  
  int n;
  cin >> n;
  vector<int> suji(n);
  for(int i = 0; i < n; i++) {
    cin >> suji.at(i);
  }
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < n; k++) {
        if (bingo.at(i).at(j) == suji.at(k)) {
          bingo.at(i).at(j) = 0;
          break;
        }
      }
    }
  }
  
  vector<int> sum(8);
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      sum.at(i) += bingo.at(i).at(j);
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      sum.at(i + 3) += bingo.at(j).at(i);
    }
  }
  for (int i = 0; i < 3; i++) {
    sum.at(6) += bingo.at(i).at(i);
    sum.at(7) += bingo.at(i).at(2 - i);
  }
  
  int pro = 1;
  for (int i = 0; i < 8; i++) {
    pro *= sum.at(i);
  }
  if (pro == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
        a := make([]int, 3)
        for i := range a {
                fmt.Scan(&a[i])
        }

        mincost := abs(a[1]-a[0]) + abs(a[2]-a[1])
        for i := 0; i < 6; i++ {
                b := []int{
                        a[i/2],
                        a[(i/2+i%2+1)%3],
                        a[(i/2+(i+1)%2+1)%3],
                }
                cost := abs(b[1]-b[0]) + abs(b[2]-b[1])
                if cost < mincost {
                        mincost = cost
                }
        }
        fmt.Println(mincost)
}

func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

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

int main()
{
	int a, b; cin >> a >> b;
	
	int ans = 0;

	if (a <= b) {
		ans = a;
	}
	else {
		ans = a - 1;
	}
		
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S[0] == 'S') {
    cout << "Cloudy" << endl;
  } else if (S[0] == 'C') {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   vector<int> num(26);
   rep(i, 0, s.size()) { num[s[i] - 'a']++; }
   rep(i, 0, 26) {
      if (!num[i]) {
         cout << (char)('a' + i) << endl;
         return 0;
      }
   }
   cout << "None" << endl;
   return 0;
}

Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline

    AB = input().split(" ")
    A = int(AB[0])
    B = int(AB[1])
    if (A + B) % 2 == 1:
        res = 'IMPOSSIBLE'
    else:
        res = int((A + B) / 2)
    print(res)

if __name__ == '__main__':
    main()

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 1e5 + 5;

int n, a[N], b[N];

int lmao() {
    int cnt = 2, id = n;
    while(cnt <= n) {
        b[cnt] = a[id];
        id -= 1;
        cnt += 2;
    }
    id = 1;
    cnt = 3;
    while(cnt <= n) {
        b[cnt] = a[id];
        cnt += 2;
        id++;
    }
    b[1] = a[id];
    long long sum = 0;
    for(int i = 1; i < n; i++)
        sum += abs(b[i] - b[i + 1]);
    return sum;
}
int lmao1() {
    if(n % 2 != 0) {
        memset(b, 0, sizeof(b));
        int id = 1;
        int cnt = 2;
        while(cnt <= n) {
            b[cnt] = a[id];
            id++;
            cnt += 2;
        }
        b[n] = a[id]; id++;
        cnt = 1;
        while(cnt < n) {
            b[cnt] = a[id];
            id++;
            cnt += 2;
        }
        long long sum = 0;
        for(int i = 1; i < n; i++)
            sum += abs(b[i] - b[i + 1]);
        return sum;
    }
    else return 0;
}

int lo() {
    int cnt = 2, id = 1;
    while(cnt <= n) {
        b[cnt] = a[id];
        id += 1;
        cnt += 2;
    }
    cnt = 1;
    while(cnt <= n) {
        b[cnt] = a[id];
        id += 1;
        cnt += 2;
    }
    long long sum = 0;
    for(int i = 1; i < n; i++)
        sum += abs(b[i] - b[i + 1]);
    return sum;
}

int min1 = 0;
signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    if(n == 2) {
        cout << abs(a[1] - a[2]);
        exit(0);
    }
    min1 = max(min1, lmao());
    min1 = max(min1, lo());
    min1 = max(min1, lmao1());
    //cout << lmao1() << "\n";
    //cout << lo() << " " << lmao() << "\n";
    cout << min1;
}


Measured memory_bytes: 1792
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
# define pi           3.14159265358979323846
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	double n;
	cin>>n;
	cout<<setprecision(20)<<2*n*pi<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

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

 
int main() {
	int  n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	double sum = 1;
	for(int i=0; i<n; i++){
		sum *= a.at(i);
	}
	double tmp = 0;
	for(int i=0; i<n; i++){
		tmp += sum / a.at(i); 
	}

	cout << fixed << setprecision(10) << sum/tmp << endl;
}


Measured memory_bytes: 256
import sys, bisect
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def lis_(a):
    dp = [INF]*len(a)
    for i in a:
        dp[bisect.bisect_left(dp, i+1)] = i
    return bisect.bisect_left(dp, INF)

def resolve():
    N = I()
    A = [I() for _ in range(N)]
    A = A[::-1]

    print(lis_(A))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 7856
n=int(input())
s=input()
a=[0]*n
if(s[0]=='W'):
  a[0]=1
for i in range(1,n):
  if(s[i]=='W'):
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
ans=min(n-a[n-1]+a[0]-1,a[n-2])
for j in range(1,n-1):
  x=a[j-1]+(n-j-1)-(a[n-1]-a[j])
  if(x<ans):
    ans=x
print(ans)

Measured memory_bytes: 15180
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, k;
ll h[100000];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h,h+n);
    ll minh=10000000000;
    for(int i=0;i<n-k+1;i++){
        ll temp=h[i+k-1]-h[i];
        if(temp<minh) minh=temp;
    }
    cout << minh << "\n";
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
ans = []

while N != 0:
	N -= 1
	p, r = divmod(N, 26)
	ans.append(ascii_lowercase[r])
	N = p

print("".join(ans[::-1]))

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
static const llint MOD = 2019;

bool compPair(const pint& arg1, const pint& 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) {
    string s;
    cin >> s;

    llint n;
    n = s.size();

    map<llint, llint> mp;
    mp[0] = 1;
    llint now = 0, ten = 1;
    for(int in=1;in<=n;in++) {
        now += ten*(s.at(n-in)-'0');
        now %= MOD;
        ten *= 10;
        ten %= MOD;
        mp[now]++;
    }

    llint ans=0;
    for(auto im:mp) {
        ans += im.second*(im.second-1)/2;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3684
n = int(input())
s = input()
ans = 0

while True:
    if not ('R' in s and 'W' in s): break
    r = s.rindex('R')
    w = s.index('W')
    if r < w:
        break
    s = s[:w] + 'R' + s[w+1:r] + 'W' + s[r+1:]
    ans += 1
print(ans)

Measured memory_bytes: 9828
//052
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, x=0, ans=0;
    string s;
    cin >> n;
    cin >> s;
    rep(i,n){
        if(s[i]=='I') x+=1;
        if(s[i]=='D') x-=1;
        if (ans< x) ans = x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//beautiful Sets

#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e3+10;
int dp[N][N];
char s[N][N];
int32_t main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>s[i][j];
		}
	}
	dp[1][1]=(s[1][1]=='#');
	for(int j=2;j<=m;j++)
	{
		dp[1][j]=dp[1][j-1];
		if(s[1][j]!=s[1][j-1]&&s[1][j]=='#')
		{
			dp[1][j]+=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		dp[i][1]=dp[i-1][1];
		if(s[i][1]!=s[i-1][1]&&s[i][1]=='#')
		{
			dp[i][1]+=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=2;j<=m;j++)
		{
			int x=dp[i][j-1];
			int y=dp[i-1][j];
			if(s[i][j-1]!=s[i][j]&&s[i][j]=='#')
			{
				x+=1;
			}
			if(s[i-1][j]!=s[i][j]&&s[i][j]=='#')
			{
				y+=1;
			}
			dp[i][j]=min(x,y);
		}
	}
	cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    int dis = 0;
    set<int> large, small;
    rep(i, n) cin >> a[i];
    int me = M;
    rep(i, n)
    {
        me = min(me, a[i]);
        b[i] = me;
    }
  /*  rep(i, n)
    {
        int l = *upper_bound(a.begin() + i - 1, a.end() - 1, a[i]);
        //cout<<a[i]<<" "<<l<<" ";
        int tmp = l - a[i];
        //cout<<tmp<<endl;
        if (dis < tmp)
        {
            dis = tmp;
            large.clear();
            large.insert(l);
        }
        else if (dis == tmp)
        {
            large.insert(l);
        }
        // cout<<large.size()<<endl;
    }*/
    rep(i, n)
    {
        int tmp = a[i]-b[i];
        //cout<<tmp<<endl;
        if (dis < tmp)
        {
            dis=tmp;
            small.clear();
            small.insert(b[i]);
        }else if(dis==tmp){
            small.insert(b[i]);
        }
    }
    cout << small.size() << endl;
}


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

vector <int> p(0);

void Prime(int n){

  bool flg[(int)sqrt( pow(10,9) ) +1];
  int indx=2;

  flg[0]=flg[1]=0;
  for(int i=0; i<sqrt(n)+1; i++)flg[i]=0;
  

  while(indx<=sqrt(n)){
    flg[indx]=1;
    p.push_back(indx);
    for(int i=2; i*indx<sqrt(n); i++){
      flg[indx]=1;
    }

    while(flg[indx]==1 && indx<=sqrt(n))indx++;

  }
  

}


int main(){

  int n;

  cin >> n;

  Prime(n);

  cout << n << ':';

  int i=0;
  while(n!=1 && i<(int)p.size()){
    
    while(n%p[i]==0){
      cout << ' ' << p[i];
      n /= p[i];
    }

    i++;
    
  }

  if(i==(int)p.size() && n!=1)cout << ' '<<n;
  cout << endl;

  return 0;
}

Measured memory_bytes: 1376
n = int(input())
a_list = []
for i in range(n):
    a_list.append(int(input()))
cnt = 1
i = 0
while a_list[i] != 2:
    i = a_list[i] - 1
    cnt += 1
    if len(a_list) < cnt:
        cnt = -1
        break

print(cnt)

Measured memory_bytes: 7084
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
has = set()
for _ in range(k):
    input()
    has.update(map(int, input().split()))

no_has = set(range(1, n+1)) - has
print(len(no_has))


Measured memory_bytes: 65448
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,H,W;
    cin>>N>>H>>W;
    cout<<(N-H+1)*(N-W+1)<<endl;
}


Measured memory_bytes: 3636
import bisect


def count(text, s, rgb_bag):
    ans = 0
    for i in rgb_bag[text[0]]:
        jst = bisect.bisect_left(rgb_bag[text[1]], i)
        if jst == len(rgb_bag[text[1]]):
            continue
        for j in rgb_bag[text[1]][jst:]:
            k = bisect.bisect_left(rgb_bag[text[2]], j)
            ans += len(rgb_bag[text[2]]) - k
            ng_idx = j + (j - i)
            if ng_idx >= len(s):
                continue
            if s[ng_idx] == text[2]:
                ans -= 1
    return ans


def main():
    n = int(input())
    s = input()
    rgb_bag = {'R': [], 'G': [], 'B': []}
    for i, v in enumerate(s):
        rgb_bag[v].append(i)
    ans = 0

    for r in 'RGB':
        for g in 'RGB':
            for b in 'RGB':
                if r == g or g == b or b == r:
                    continue
                ans += count(r+g+b, s, rgb_bag)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72452
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	char N[4];

	scanf("%s", N);
	if ((N[0] == N[1] && N[1] == N[2]) || (N[3] == N[1] && N[1] == N[2])) {
		printf("Yes");

	}
	else printf("No");





}

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

int SumOfDigit(int n) {
    int sum = 0;
    while(n>0) {
        sum += n%10;
        n/=10;
    }
    return sum;
}


int main() {
    int n;
    cin >> n;
    int sum = SumOfDigit(n);
    if(n%sum==0) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<list>
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
#define _GLIBCXX_DEBUG

using namespace std;


int main() {
    string S;
    cin >> S;
    char Ci;
    bool rev = true;
    list<char> li;
    for (int i = 0; i < S.size(); i++) {
        li.push_back(S[i]);
    }
    int Q;
    int Ti,Fi;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> Ti;
        if (Ti == 1) {
            //反転
            if (rev == true) {
                rev = false;
            }
            else {
                rev = true;
            }
        }
        else {
            cin >> Fi >> Ci;
            if (Fi == 1) {
                if (rev == true) {
                    li.push_front(Ci);
                }
                else {
                    li.push_back(Ci);
                }
            }
            else {
                if (rev == true) {
                    li.push_back(Ci);
                }
                else {
                    li.push_front(Ci);
                }
            }
        }
    }
    if (rev == true) {
        for (list<char>::iterator itr = li.begin(); itr != li.end(); itr++) {
            cout << *itr;
        }
    }
    else {
        for (list<char>::iterator itr = prev(li.end()); itr != li.begin(); itr--) {
            cout << *itr;
        }
        auto itr = li.begin();
            cout << *itr;
    }
    cout << endl;
}


Measured memory_bytes: 9984
h, w = map(int, input().split())
A = [input() for i in range(h)]

dp = [[float("inf")]*w for _ in range(h)]
dp[0][0] = 0 if A[0][0] == "." else 1
for i in range(1, w):
    dp[0][i] = dp[0][i-1]+1 if A[0][i] == "#" and A[0][i-1] == "." else dp[0][i-1]
for i in range(1, h):
    dp[i][0] = dp[i-1][0]+1 if A[i][0] == "#" and A[i-1][0] == "." else dp[i-1][0]

for i in range(1, h):
    for j in range(1, w):
        left = dp[i][j-1]+1 if A[i][j] == "#" and A[i][j-1] == "." else dp[i][j-1]
        right = dp[i-1][j]+1 if A[i][j] == "#" and A[i-1][j] == "." else dp[i-1][j]
        # print(i, j, left, right)
        dp[i][j] = min(left, right)
# print(dp)

print(dp[-1][-1])

Measured memory_bytes: 42352
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,c;

int main(){
	cin>>a>>b>>c;
	cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
N = int( input())
h = list( map( int, input().split()))

D = [ 0 ] + [ abs( h[1] - h[0] ) ]+[ 0 for i in range( N - 2 ) ]
for i in range( 1, N - 1):
  if i - 1 >= 0:
    D[ i + 1 ] = min( abs( h[ i + 1 ] - h[ i ] ) + D[ i ],
                      abs( h[ i + 1 ] - h [ i - 1 ] ) + D[i - 1 ])

print( D[ -1 ] )

Measured memory_bytes: 20432
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	string n;
	cin >> n;

	int sum = 0;
	REP(i, n.size()) {
		sum += n[i] - '0';
		sum %= 9;
	}
	if (sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a[4];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 3){
    int b, c;
    cin >> b >> c;
    a[b-1]++;
    a[c-1]++;
  }
  sort(a, a+4);
  cout << ((a[0]==1 && a[3]==2) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,c;
ll a[300005],b[300005];
ll x,y,ans=INF,look;
bool flag;
char s[300005];
ll e,w,ee,ww;

int main(){
	cin>>n;
	cin>>s;
	for(i=0;i<n;i++){
		if(s[i]=='E')e++;
		if(s[i]=='W')w++;
	}
	for(i=0;i<n;i++){
		if(s[i]=='E'){
			e--;
			ans = min(ans,e+ww);
			ee++;
		}else{
			w--;
			ans = min(ans,e+ww);
			ww++;
			
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
const int mx = 100005;
int n, m, a[mx], i, j;
long long ans;
pair<int, int> pr[mx];
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++){
        scanf("%d", a+i);
        ans += a[i];
    }
    for(int i = 0; i < m; i++) scanf("%d%d", &pr[i].second, &pr[i].first);
    sort(a, a+n);
    sort(pr, pr+m, greater<pair<int, int>>());
    while(i < n && j < m && a[i] < pr[j].first){
        ans += pr[j].first - a[i++];
        if(--pr[j].second == 0) j++;
    }
    printf("%lld\n", ans);
}

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

int main() {
    int r, D, x[11];   cin >> r >> D >> x[0];

    for (int i = 1; i < 11; ++i) {
        x[i] = r * x[i-1] - D;
    }

    for (int j = 1; j < 11; ++j) {
        cout << x[j] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int MAX = 2e5+10;
char s[MAX];
int n;

int main(){
    scanf("%d%s\n", &n, s);
    int ans = 0, cnt = 0;
    for (int i = 0; i < n; i++) if (s[i] == 'R') cnt++;
    for (int i = 0; i < cnt; i++) if (s[i] == 'W') ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1912
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 11:48:32 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll	n;
	cin >> n;
	ll	i;
	i = 0;
	ll	sum;
	sum = 0;
	while (sum < n)
	{
		i++;
		sum += i;
	}
	ll	skip;
	skip = sum - n;
	rep2(j, 1, i + 1)
	{
		if (j == skip)
			continue;
		cout << j << endl;
	}

}
// END

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


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

int main()
{
    int n;
    cin>>n;
    int *a=new int [n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int SortDone=0;
    int temp=0;
    for(int i=0;i<n;i++){
        temp=a[i];
        for(int j=0;j<SortDone;j++){
            if(a[i]<=a[j]){
                for(int k=i;k>j;k--){
                    a[k]=a[k-1];
                }
                a[j]=temp;
                break;
            }
        }
        for (int p=0;p<n-1;p++)
            cout<<a[p]<<" ";
        cout<<a[n-1];
        if(SortDone!=n)
            cout<<endl;
        SortDone++;
    }
    return 0;
}



Measured memory_bytes: 3092
n = int(input())
count = {}
for i in range(n):
    s = input()
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
m = int(input())

for i in range(m):
    t = input()
    if t in count:
        count[t] -= 1
    else:
        count[t] = -1
max_v = max(count.values())
if max_v < 0:
    max_v = 0
print(max_v)

Measured memory_bytes: 9208
def ascend(x,y):
    mini = min(A[x:x+L])
    ans[x] = mini
    for i in range(x+1,y):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini
 
def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
     
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])


Measured memory_bytes: 121152