akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007


int po(ll x,ll y)
{
	//ll y=mod-2;
	unsigned int res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}
ll md(ll a){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}
int main() {
	ll n,b;
	ll r;
	cin>>n>>b;
	r=n-b;
	ll f[2001],fi[2001];
	f[0]=1;
	fi[0]=1;
	for(int i=1;i<2001;i++)
	{
		f[i]=(f[i-1]*i)%mod;
		fi[i]=po(f[i],mod-2);

	}
	ll ans;
	for(int i=1;i<=b;i++)
	{
		if(r+1<i)
		{
			cout<<"0"<<endl;

		}
		else
		{
			ll ans=0;
			ans=md(fi[b-i]*md(fi[i-1]*md(f[b-1]*md(f[r+1]*md(fi[i]*fi[r+1-i])))));
			
			cout<<ans<<endl;
		}
	}


	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
  int A,B;
  cin >> A >> B;
  int K2 = A + B;
  if(K2 % 2 == 0){
    cout << K2/2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 764
#include<iostream>

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

int main(){
    
    int k,s;
    cin >> k >> s;
    int cnt =0;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int z = s-i-j;
                if(0 <= z && z<=k)cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
};



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using pos = pair<int, int>;
typedef long long ll;

int factorization(int k) {
  int sum = 1;
  for (int i = 1; i <= k; ++i) sum *= i;
  return sum;
}

int main() {
  int N;
  cin >> N;
  vector<pos> map(N);
  for (int i = 0; i < N; i++) {
    cin >> map[i].first >> map[i].second;
  }
  int factor = factorization(N);
  vector<int> v(N);
  vector<vector<int> > path;
  for (int i = 0; i < N; i++) v[i] = i;
  do {
    vector<int> l = v;
    path.push_back(l);
  } while (next_permutation(v.begin(), v.end()));
  double sum_path_length = 0.0;
  for (vector<int> l : path) {
    int cur_x = map[l[0]].first;
    int cur_y = map[l[0]].second;
    for (int j = 1; j < N; j++) {
      int x = map[l[j]].first;
      int y = map[l[j]].second;
      sum_path_length += sqrt(pow(cur_x - x, 2) + pow(cur_y - y, 2));
    }
  }
  cout << fixed << (sum_path_length / (double)factor) << endl;
  return 0;
}

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

int main(){
	std::string find_str, target_str;
	std::cin >> find_str;

	int n, len, t = 0;
	std::cin >> n;
	for(;n--;){
		std::cin >> target_str;
		len = target_str.length();
		target_str += target_str;
		int p = target_str.find(find_str);
		if(p != std::string::npos && p < len){
			t++;
		}
	}
	std::cout << t << std::endl;
}

Measured memory_bytes: 1212
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = [0] * (x * y)
for i in range(x):
  for j in range(y):
    D[i * y + j] = A[i] + B[j]
D.sort(reverse=True)
E = [0] * (z * k)
size = min(x * y, k)
for i in range(z):
  for j in range(size):
    E[i * size + j] = C[i] + D[j]
E.sort(reverse=True)
print(*E[:k], sep='\n')

Measured memory_bytes: 118376
while True:
  (n, x) = input().rstrip('\r\n').split(' ')
  n = int(n)
  x = int(x)

  if n == 0 and x == 0:
    break

  a = []
  for ii in range(n):
    a.append(ii + 1)

  c = 0
  for ii in range(len(a)):
    for jj in range(ii + 1, len(a)):
      for kk in range(jj + 1, len(a)):
        if a[ii] + a[jj] + a[kk] == x:
          c += 1
  print(c)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
    string s, t; cin >> s >> t; int ans = 1e9;
    for(int i = 0; i < s.size() - t.size() + 1; i++) {
        int nw = 0;
        for(int j = 0; j < t.size(); j++)
            nw += s[i + j] != t[j];
        ans = min(ans, nw);
    }
    printf("%d\n", ans);
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

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

using namespace std;

long long m[200005],a[200005],r[200005],c[200005],h[200005];

void is(char g,int b){
	if(g == 'M') m[b]++;
	else if(g == 'A') a[b]++;
	else if(g == 'R') r[b]++;
	else if(g == 'C') c[b]++;
	else if(g == 'H') h[b]++;
}

int main(){
	long long n;
	cin >> n;
	string x[200005];
	for(long long i = 0; i < n; i++){
		cin >> x[i];
		is(x[i][0],i);
	}
	for(long long i = n-2; i >= 0; i--){
		m[i] += m[i+1];
		a[i] += a[i+1];
		r[i] += r[i+1];
		c[i] += c[i+1];
		h[i] += h[i+1];
	}
	long long sol = 0;
	for(long long i = 0; i < n; i++){
		if(x[i][0] == 'M'){
			sol += a[i] * r[i];
			sol += a[i] * c[i];
			sol += a[i] * h[i];
			sol += r[i] * c[i];
			sol += r[i] * h[i];
			sol += c[i] * h[i];
		}
		else if(x[i][0] == 'A'){
			sol += m[i] * r[i] + m[i] * c[i] + m[i] * h[i] + r[i] * c[i] + r[i] * h[i] + c[i] * h[i];
		}
		else if(x[i][0] == 'R'){
			sol += m[i] * a[i] + m[i] * c[i] + m[i] * h[i] + a[i] * c[i] + a[i] * h[i] + c[i] * h[i]; 
		}
		else if(x[i][0] == 'C'){
			sol += m[i] * a[i] + m[i] * r[i] + m[i] * h[i] + a[i] * r[i] + a[i] * h[i] + r[i] * h[i];
		}
		else if(x[i][0] == 'H'){
			sol += m[i] * a[i] + m[i] * r[i] + m[i] * c[i] + a[i] * r[i] + a[i] * c[i] + r[i] * c[i];
		}
	}
	cout << sol;
}

Measured memory_bytes: 13056
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

const long long mod = 1e9+7;

int main()
{
  vector<int> dp(2004);
  int s;
  cin >> s;
  dp[0] = 1;
  for(int i = 1; i <= s; i++){
    for(int j = 0; j <= i-3; j++){
      dp[i] += dp[j];
      dp[i] %= mod;
    }
  }
  cout << dp[s] << endl;
}


Measured memory_bytes: 3608
program name

    implicit none
    integer n,i,ii,alice,bob,max_num
    integer,allocatable :: a(:)
    read*, n
    allocate(a(n))
    read*, a(:)
    alice = 0
    bob = 0
    do i = 1, n, 1
        max_num = maxval(a)
        if ( mod(i,2)==1 ) then
            alice = alice+max_num
        else
            bob = bob+max_num
        end if
        do ii = 1, size(a), 1
            if ( a(ii)==max_num ) then
                a(ii) = 0
                exit
            end if
        end do
    end do
print*, alice-bob
end program

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    cout << pow(n, 3) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, x, a, r;

signed main() {
	cin >> n >> x;
	cin >> a;
	r = abs(x-a);
	rep(i,n-1) {
		cin >> a;
		r = gcd(r,abs(a-x));
	}
	cout << r << endl;
}


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

#define PI 3.14159265358979323846

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 1000010
#define MOD 1000000007

int bexp(int a, int b)
{
    if (b < 0)
        return 0;
    int res = 1;
    while(b)
    { 
        if(b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;

    int ans = bexp(10, n);
    ans = (ans - 2 * bexp(9, n) + bexp(8, n) + 3ll * MOD) % MOD;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
let X = stdin.ReadLine() |> int

let s = 120

let pow5 x = x * x * x * x * x

let rec solver i j =
    if j = s then solver (i + 1) -s
    elif pow5 i - pow5 j = X then
        i.ToString() + " " + j.ToString() |> stdout.WriteLine
        ()
    else solver i (j + 1)

solver -s -s


Measured memory_bytes: 29308
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  int h,a ;
  cin >> h >> a;
  if (a>h)
    cout << 1 << endl;
  else
    {
      int ans=0;
      int q=h;
      for (int i=0; i<q; i++)
	{
	  h-=a;
	  if (h<=0)
	    break;
	  else
	    ans++;
	}
      cout << ans+1 << endl;
    }
  return 0;
}


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

int main(){
    string s,t="CODEFESTIVAL2016";
    cin >> s;
    int ans=0;
    for(int i=0;i<16;i++){
        if(s.at(i)!=t.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int gcd(int a,int b){
      /* 自然数 a > b を確認・入替 */
  int tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}

int main(void){
    int N,X;
    scanf("%d%d",&N,&X);
    int ans;
    scanf("%d",&ans);
    ans-=X;
    if(ans<0)ans*=-1;
    for(int i=0;i<N-1;i++){
        int unko;
        scanf("%d",&unko);
        unko-=X;
        if(unko<0)unko*=-1;
        ans=gcd(ans,unko);
    }
    printf("%d",ans);
    
    return 0;
}


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

using namespace std;

int main(){
    int m,f,b;
    cin>>m>>f>>b;
    int ans=0;
    if(m<b)ans=b-m;
    if(ans>f)cout<<"NA"<<endl;
    else cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){

  int n=1,kakaku=1,min1,min2=10000000,a,b,c,i,j,k=0;
  vector<int> min3(50000,10000000);
  while(n!=0&&kakaku!=0){
    min2=10000000;
    cin>>n;
    vector<int> s(n);
    cin>>kakaku;

    for(i=0;i<n;i++){
      cin>>s.at(i);
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i!=j){
	  a=s.at(i);
	  b=s.at(j);
	  c=a+b;
	  min1=kakaku-c;
	  if(min2>min1&&min1>=0){
	    min2=min1;
	    min3[k]=c;
	  }
	}
      }
    }
    k++;
  }
  for(i=0;i<k-1;i++){
    if(min3.at(i)==10000000){
      cout<<"NONE"<<endl;
    }else{
      cout<<min3.at(i)<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 2992
#include<stdio.h>

int wa=100,wb=0;

void swap(int x,int y){
  wa=x;
  wb=y;
}

void comp(int x,int y){
  if(wb<y){
    swap(x,y);
  }
  else if((wb==y)&&(wa>x)){
    swap(x,y);
  }
}

void winner(int n){
  int a,b;

  while(n>0){
    scanf("%d %d",&a,&b);
    comp(a,b);
    n--;
  }
  printf("%d %d\n",wa,wb);
}

int main(){
  int n;
  scanf("%d",&n);
  winner(n);
  return 0;
}

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

const int MOD = 1e9 + 7;

inline void mod(long long& x) {
	x = (x%MOD + MOD)%MOD;
}


long long dp[2][60] = {};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];

	for(int j = 0; j < n; ++j){
		for(int i = 0; i < 2; ++i){
			//no es el caso base
			if(i == 0 && j == 0) dp[i][j] = 3;
			//no es la sugunda parte de un palo vertical
			else if(i == 1 && s[0][j] == s[1][j]) dp[1][j] = dp[0][j];
			//no es la segunda parte de un palo horizontal
			else if(j and s[i][j] == s[i][j-1]) dp[i][j] = dp[i][j-1];
			else {
				//es la primera parte de uno vertical
				if(i == 0 && s[1][j] == s[0][j]) {
					if(j) {
						if(s[0][j-1] == s[1][j-1]) {
							dp[i][j] = dp[i][j-1] * 2;
						}
						else {
							dp[i][j] = dp[1][j-1];
						}
					}
				}

				else if(i == 0) {
					dp[i][j] = dp[i][j-1] * 2;
				}

				else if(i == 1) {
					if(j) {
						if(s[0][j-1] == s[1][j-1]) 	dp[i][j] = dp[i-1][j];
						else {
							dp[i][j] = (3*dp[i][j-1]);
						}
					}
					else dp[i][j] = dp[i-1][j] * 2;
				}
			}
			mod(dp[i][j]);
		}
	}

	cout << dp[1][n-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main() {
  int a,b;
  std::cin>>a>>b;
  
  if(a==1||b==1){
    if((a==1)&&!(b==1))	std::cout<<"Alice";
    else if(!(a==1)&&(b==1))std::cout<<"Bob";
    else std::cout<<"Draw";
  }else{
    if(a>b)	std::cout<<"Alice";
    else if(a<b) std::cout<<"Bob";
    else	std::cout<<"Draw";
  }
}

Measured memory_bytes: 256
n,l = map(int,input().split())
 
ll = []
p = []
for i in range(n):
    ll.append(l + i)
    p.append(abs(l + i))
sm = 0
ind = 0
a_min = 0
a_min = min(p)
ind = p.index(a_min)
ll.pop(ind)
sm = sum(ll)

print(sm)

Measured memory_bytes: 3064
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
# define ll unsigned long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 998244353
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)
const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
/*
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	a += mod;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}
*/
int mp[1000005]={0},mp1[1000005]={0};
signed main(){
   gok
   for(int i=0;i<=1000000;i++)
   {
       mp[i]=mp1[i]=0;
   }
   int n;
   cin>>n;
   int a[n];
   int cc=0;

   for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
    if(a[i]==1)
        cc++;
    }
   /* if(cc==1)
        cout<<1;
    else if(cc>1)
        cout<<0;
    else{*/
       sort(a,a+n);
       int an=0;
       for(int i=0;i<n;i++)
       {
           if(mp[a[i]]==1 && mp1[a[i]]==0)
           {
               an++;
           }
           if(mp1[a[i]]==0)
           {
               for(int j=a[i];j<=1000000;j+=a[i])
               {
                   mp1[j]=1;
               }
           }
       }
       cout<<an;
    //}
















 return 0;
}


Measured memory_bytes: 20832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e18;
    double start_temp = 3000, end_temp = 0;
    for (i = 0; i < 500000; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / 100000;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,x,cnt=INF,ans=0;
	cin >> n;
	rep(i,n){
		cin >> x;
		if(chmin(cnt,x))  ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def solve(N, A, B, C, D):

        # Nを0にするために必要なコインをメモ化再帰で求める
        @lru_cache(None)
        def f(N):
            # 再帰終了条件
            if N == 0:
                return 0
            if N == 1:
                return D

            ret = D * N

            q, r = divmod(N, 2)
            # Nが2で割り切れる場合、必要な追加コインはA枚
            if r == 0:
                ret = min(ret, f(q) + A)
            # Nが2で割り切れない場合、必要な追加コインはA+D枚
            else:
                # f(q) + A + D：qを2倍した後に1を足す
                # f(q + 1) + A + D：q+1を2倍した後に1を引く
                ret = min(ret, f(q) + A + D, f(q + 1) + A + D)

            q, r = divmod(N, 3)
            # Nが3で割り切れる場合、必要な追加コインはB枚
            if r == 0:
                ret = min(ret, f(q) + B)
            # Nが3で割った余りが1の時、qを3倍して1を足すのが、最もコインが少なくて済む為、必要な追加コインはB+D枚
            elif r == 1:
                ret = min(ret, f(q) + B + D)
            # Nが3で割った余りが2の時、q+1を3倍した後に1を引くのが、最もコインが少なくて済む為、必要な追加コインはB+D枚
            else:
                ret = min(ret, f(q + 1) + B + D)

            q, r = divmod(N, 5)
            # Nが5で割り切れる場合、必要な追加コインはC枚
            if r == 0:
                ret = min(ret, f(q) + C)
            # Nが5で割った余りが1の時、qを5倍して1を足すのが、最もコインが少なくて済む為、必要な追加コインはC+D枚
            elif r == 1:
                ret = min(ret, f(q) + C + D)
            # Nが5で割った余りが2の時、qを5倍して2を足すのが、最もコインが少なくて済む為、必要な追加コインはC+2D枚
            elif r == 2:
                ret = min(ret, f(q) + C + D + D)
            # Nが5で割った余りが3の時、q+1を5倍して2を引くのが、最もコインが少なくて済む為、必要な追加コインはC+2D枚
            elif r == 3:
                ret = min(ret, f(q + 1) + C + D + D)
            # Nが5で割った余りが3の時、q+1を5倍して1を引くのが、最もコインが少なくて済む為、必要な追加コインはC+D枚
            else:
                ret = min(ret, f(q + 1) + C + D)

            return ret

        return f(N)

    t = int(input())
    for _ in range(t):
        n, a, b, c, d = map(int, input().split())
        print(solve(n, a, b, c, d))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 20500
#include<iostream>

using namespace std;

int n, A[200];

int E_search(int x, int i) {
	if (x == 0) {
		return 1;
	}

	if (i == n) {
		return 0;
	}

	E_search(x, i + 1) || E_search(x - A[i], i + 1);

}

int main() {
	int q, M[200];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> M[i];
		if (E_search(M[i], 0)) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}

	}
	return 0;


}


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int N = 1e3 + 10;
char a[N], b[N];
int n, m;

int main() {
    ss(a + 1), ss(b + 1);
    n = strlen(a + 1), m = strlen(b + 1);
    int ans = INF;
    repi(i, 0, n - m) {
        int cnt = 0;
        repi(j, 1, m)if (a[i + j] != b[j])cnt++;
        ans = min(ans, cnt);
    }
    pi(ans);
    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;


struct NODE{

	int n;
	int solve;
	int score;
	vector<int> cnt;
	NODE(){ n = solve =  score = 0; cnt.clear();}
	NODE(int n, int solve, int score, int p): n(n), solve(solve), score(score){
		cnt.clear();
		cnt.resize(p);
	}
	
	bool operator<(const NODE r){
		if(solve != r.solve) return solve < r.solve;
		if(score != r.score) return score > r.score;
		return n < r.n;
	}
	bool operator==(const NODE r){
		if(solve != r.solve) return false;
		if(score != r.score) return false;
		return true;
	}
	
};


int main() {
	
	int M, T, P, R;
	while(cin >> M >> T >> P >> R, M){
		vector<NODE> v(T);
		rep(i, T){
			v[i] = NODE(i+1, 0, 0, P);
		}
		
		rep(i, R){
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			t--;
			p--;
			if(j == 0){
				v[t].solve++;
				v[t].score += (m + 20 * v[t].cnt[p]);
			}
			else{
				v[t].cnt[p]++;
			}
		}
		
		SORT(v);
		
		cout << v[T-1].n;
		for(int i = T-2; i >= 0; i--){
			cout << (v[i+1] == v[i] ? "=" : ",") << v[i].n;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
	int n,a,b;
	while(cin>>n>>a>>b)
	{
		if(a==0){cout<<0<<"\n";
		}
		else cout<<n/(a+b)*a+min(n%(a+b),a)<<"\n";
	}
} 

Measured memory_bytes: 256
#include <stdio.h>

void printOneLine(int A[], int N, int cnt)
{
	int i;
	
	for(i = 0; i < N; i++){
		if(i != 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);
}

void bubbleSort(int A[], int N)
{
	int i, j, cnt = 0;
	
	for(i = 0; i < N-1; i++){
		for(j = N-1; j >= i+1; j--){
			if(A[j] < A[j-1]){
				A[j]   ^= A[j-1];
				A[j-1] ^= A[j];
				A[j]   ^= A[j-1];
				cnt++;
			}
		}
	}
	printOneLine(A, N, cnt);
}

int main(void)
{
	int i, N, A[100];
	
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	
	bubbleSort(A, N);
	
	return(0);
}



Measured memory_bytes: 2072
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    a = (a == 1 ? 14 : a);
    b = (b == 1 ? 14 : b);
    if (a > b) {
        cout << "Alice\n";
    } else if (a < b) {
        cout << "Bob\n";
    } else {
        cout << "Draw\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, k;
int c[2005] = { 0 }, g[2005] = { 0 };
long long dp[15][2005] = { 0 };
vector<long long>sum[15];
int main() {
	//long long res = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> g[i];
		sum[g[i]].push_back(c[i]);
	}
	for (int i = 1; i <= 10; i++) {
		sort(sum[i].begin(), sum[i].end());
		reverse(sum[i].begin(), sum[i].end());
		for (int j = 1; j < sum[i].size(); j++) {
			sum[i][j] += sum[i][j - 1];
		}
	}
	/*for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < sum[i].size(); j++) {
			cout << sum[i][j] << endl;
		}
	}*/
	for (int i = 0; i < 15; i++) {
		for (int j = 0; j < 1005; j++) {
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j <= k; j++) {
			if (dp[i][j] == -1) continue;
			dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
			for (int m = 0; m < sum[i + 1].size(); m++) {
				dp[i + 1][j + (m + 1)] = max(dp[i + 1][j + (m + 1)], dp[i][j] + (m + 1)*m + sum[i + 1][m]);
			}
		}
	}
	long long res = 0;
	for (int i = 1; i <= 10; i++) {
		res = max(res, dp[i][k]);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3396
/*
      author : nishi5451
      created: 12.08.2020 11:31:13
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    vector<bool> dp(10,false);
    rep(i,4){
        int n;
        cin >> n;
        dp[n]=true;
    }
    if(dp[1] && dp[4]&& dp[7] && dp[9])
        cout << "YES" << endl;
    else cout <<"NO" << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner, M: Array[Int]): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      var i = 0
      var j = 0
      var count = 0
      while (i < M.size && j < M.size) {
        if (M(j) - M(i) == N) {
          count += 1
          i += 1
          j += 1
        } else if (M(j) - M(i) < N) {
          j += 1
        } else {
          i += 1
        }
      }
      println(count)
      solve(sc, M)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc, initialize())
  }

  def initialize(): Array[Int] = {
    val p = primes()
    for (i <- 1 until p.length - 1) {
      p(i) += p(i - 1)
    }
    p
  }

  def primes(): Array[Int] = {
    val ret = Array.fill(10001)(true)
    ret(1) = false
    for (i <- 2 until 10001) {
      if (ret(i)) {
        for (j <- 2 to 10001 / i) {
          if (i * j < 10001) {
            ret(i * j) = false
          }
        }
      }
    }
    ret.zipWithIndex.filter(A => A._1).map(A => A._2)
  }
}

Measured memory_bytes: 52856
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n ;
    int tmp;
  	cin >> n;
    pair<pair<string,int> , int> p[110];
    for(int i = 0 ;i < n ;i++){
        cin >> p[i].first.first;
        cin >> tmp;
        p[i].first.second = tmp*-1;
        p[i].second = i;
    }
    sort(p , p+n);
    for(int i = 0 ;i < n;i++){
        cout << p[i].second +1 << endl;
    }
} 


Measured memory_bytes: 256
#include <stdio.h>

int func(int x)
{
  return x * x;
}

int main ()
{
  int i, dist, tmp;
  int area = 0;

  while (scanf("%d", &dist) != EOF) {
    for (i = 0; i < 600/dist; i++) {
      tmp = dist * i;
      area += dist * func(tmp);
    }
    printf("%d\n", area);
    area = 0;
  }

  return 0;
}

Measured memory_bytes: 596
"""
n = int(sys.stdin.readline())
a, b = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

a = 100
b = 0.987654321
print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)


mod = 1000000007

if __name__ == "__main__":
    d = {"A":"T","T":"A","G":"C","C":"G"}
    print(d[input()])

Measured memory_bytes: 5356
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a < 10 && b < 10) cout << a*b << endl;
    else cout << "-1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}
int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>x(n);
  vector<int>s(n);
  for(int i=0;i<n;i++){
  	cin>>x[i];
  	s[i]=x[i];
  }
  int pivot = (n/2);
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
  	if(lower_bound(s.begin(),s.end(),x[i])-s.begin()<pivot){
  		cout<<s[pivot]<<endl;
  	}else{
  		cout<<s[pivot-1]<<endl;
  	}
  }
}  




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

template <int MOD_> struct modnum {
    static constexpr int MOD = MOD_;
    static_assert(MOD_ > 0, "MOD must be positive"); 
private:
    using ll = long long;
    int v;
    static int minv(int a, int m) {
        a %= m;
        assert(a);
        return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
    }
 
public:
    modnum() : v(0) {}
    modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
    friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; } 
    modnum inv() const {
        modnum res;
        res.v = minv(v, MOD);
        return res;
    }
    friend modnum inv(const modnum& m) { return m.inv(); }
    modnum neg() const {
        modnum res;
        res.v = v ? MOD-v : 0;
        return res;
    }
    friend modnum neg(const modnum& m) { return m.neg(); }
    modnum operator- () const {
        return neg();
    }
    modnum operator+ () const {
        return modnum(*this);
    }
    modnum& operator ++ () {
        v ++;
        if (v == MOD) v = 0;
        return *this;
    }
    modnum& operator -- () {
        if (v == 0) v = MOD;
        v --;
        return *this;
    }
    modnum& operator += (const modnum& o) {
        v += o.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    modnum& operator -= (const modnum& o) {
        v -= o.v;
        if (v < 0) v += MOD;
        return *this;
    }
    modnum& operator *= (const modnum& o) {
        v = int(ll(v) * ll(o.v) % MOD);
        return *this;
    }
    modnum& operator /= (const modnum& o) {
        return *this *= o.inv();
    }
 
    friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
    friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using Mint = modnum<1000000007>;

signed main () {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	
	vector<int> a(n);
	for (auto &it : a) {
		cin >> it;
	}
	
	Mint ans = 0;
	vector<Mint> pref (n + 5, 0);
	pref[0] = a[0];
	
	for (int i = 1; i < n; i++) {
		pref[i] = (pref[i - 1] + a[i]);
	}
	
	for (int i = 0; i < n; i++) {
		ans += a[i] * (pref[n - 1] - pref[i]);
	}
	
	std::cout << ans;
	
	return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

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

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

  cout << (k / 2) * ((k + 1) / 2) << endl;
  return 0;
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

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

int fact(ll n){
    if(n==1)
        return 1;
    else
        return n*fact(n-1);
}

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        string s;
        cin>>s;
        string s1;
        for(int i=0;i<n;i++){
            if(s[i]=='R')
                s1+=s[i];
        }
        for(int i=0;i<n;i++){
            if(s[i]=='W')
                s1+=s[i];
        }
        //cout<<s1<<" ";
        ll c=0;
        for(int i=0;i<n;i++){
            if(s[i]!=s1[i])
                c++;
        }
        cout<<c/2<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define pb push_back
#define all(c) c.begin(), c.end()

const int MAX_N=5000;

// win[i]にjが含まれるならiはjに勝った
// win[i]にjが含まれるならiはjに負けた
vector<int> win[MAX_N+1];
vector<int> lose[MAX_N+1];

vector<int> ord;
int used[MAX_N+1]={0};

// vがordに追加される時点で，
// vから到達可能な全ての頂点，すなわち，vより順位が低いチームは，必ずordに追加されている
void tsort(int v){
    used[v]=true;
    for(int i=0; i<lose[v].size(); i++){
        if(!used[lose[v][i]]) tsort(lose[v][i]);
    }
    ord.pb(v);
}

int main(){
    int n,m;cin>>n>>m;
    while(m--){
        //頂点w(winner), l(loser)を入力
        int w,l;cin>>w>>l;
        // win[w]にlを含める
        // lose[l]にwを含める
        win[w].pb(l);
        lose[l].pb(w);
    }
    // この時点では誰が1位か分からないので，
    // 誰かに勝っていれば，自分を1位としてトポロジカルソートを行う
    for(int i=1; i<=n; i++)
        if(!win[i].size()) tsort(i);

    // "他のソート結果が存在する"フラグ
    bool exi=0;
    for(int i=1; i<n; i++){
        // "i位のチームにi+1位のチームが勝った"という情報が与えられているか？
        bool ok=find(all(lose[ord[i]]), ord[i-1])==lose[ord[i]].end();
        exi|=ok;
    }
    // 順位を出力
    for(int i=0; i<ord.size(); i++){
        cout<<ord[i]<<endl;
    }
    // 存在するかどうかを出力
    cout<<exi<<endl;
}

Measured memory_bytes: 2796
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

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

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i = 0;i < n; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 26712
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{int n,i,j,a[200100],b[200100];
scanf("%d",&n);
  for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    b[i]=a[i];}
    sort(a,a+n);
    for(j=0;j<n;j++)  
    if(b[j]!=a[n-1])printf("%d\n",a[n-1]);
      else printf("%d\n",a[n-2]);


}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  int a,b,c,d;
  d=S%10;
  c=(S%100-d)/10;
  b=(S%1000-c*10-d)/100;
  a=S-b*100-c*10-d;
  if(a==b || b==c || c==d){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int max = 0;
        int dummy = 0;

        for (int i = 1; i < n; i++) {
            if (h[i-1] >= h[i]) {
                dummy++;
            } else {
                max = Math.max(max, dummy);
                dummy = 0;
            }
        }

        max = Math.max(max, dummy);
        System.out.println(max);
	}
}


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

string maps[13];
int d[13][13];
int dy[4]={-1,0,1,0};
int dx[4]={0,-1,0,1};

void bfs(int y,int x);
int main(){
    while(1){
      int co=0;
      for(int i=0;i<12;i++){
        cin>>maps[i];
      }
      if(cin.eof())break;
      for(int i=0;i<12;i++){
	for(int j=0;j<12;j++){
	  if(maps[i][j]=='1'){
	    co++;
	    bfs(i,j);
	  }
	}
      }
      cout<<co<<endl;
    }
}

void bfs(int y,int x){
  maps[y][x]='0'; 
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny>=0 && ny<12 && nx>=0 && nx<12 && maps[ny][nx]=='1'){
      bfs(ny,nx);
    }
  }
}

Measured memory_bytes: 1192
def main():
    n=int(input())
    keta=len(str(n))
    ary=[]
    cnt=0
    ary.append(0)
    ary.append([3,5,7])
    # ary[keta数][その桁数の357数]
    if keta<=2:
        print(0)
        return
    for i in range(2,keta+1):
        temp=[]
        for j in range(0,3**(i-1)):
            temp3=ary[i-1][j]*10+3
            temp5=ary[i-1][j]*10+5
            temp7=ary[i-1][j]*10+7
            if '3' in str(temp3) and '5' in str(temp3) and '7' in str(temp3) and temp3 <= n :
                cnt+=1
            if '3' in str(temp5) and '5' in str(temp5) and '7' in str(temp5) and temp5 <= n:
                cnt+=1
            if '3' in str(temp7) and '5' in str(temp7) and '7' in str(temp7) and temp7 <= n:
                cnt+=1
            temp.append(temp3)
            temp.append(temp5)
            temp.append(temp7)
        ary.append(temp)
    print(cnt)
    # print(ary)
    # print(len(ary))
if __name__=='__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ss;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>s>>ss;
    if(Size(s)>Size(ss))Cout("GREATER");
    else if(Size(s)<Size(ss))Cout("LESS");
    else{
        rep(i,Size(s)){
            if((s[i]-'0')>(ss[i]-'0')){
                Cout("GREATER");
                return 0;
            }
            else if((s[i]-'0')<(ss[i]-'0')){
                Cout("LESS");
                return 0;
            }
        }
        Cout("EQUAL");
    }
    return 0;
}


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

using namespace std;
const int maxn=1e5+5;
int mp[23][23];
char str[23][23];
int book[23][23];
int ans;
int gx, gy;
int dx[5]={-1,1,0,0};
int dy[5]={0,0, -1, 1};
int n, m;
int qx[4005], qy[4005], step[4005];
int bfs(int sx, int sy, int gx, int gy)
{

    memset(book, 0, sizeof(book));
    int head=0, tail=0;
    book[sx][sy]=1;
    qx[head]=sx, qy[tail]=sy, step[tail++]=0;
    while(head<tail)
    {
        int x=qx[head], y=qy[head];
        if(x==gx && y==gy)return step[head];
        int nowx, nowy;
        for(int i=0; i<4; i++)
        {
            nowx=x+dx[i], nowy=y+dy[i];
            if(nowx<0 || nowx>=n || nowy<0 || nowy>=m)continue;
            if(book[nowx][nowy]==0 && mp[nowx][nowy]==0)
            {
                book[nowx][nowy]=1;
                qx[tail]=nowx,qy[tail]=nowy,step[tail]=step[head]+1;
                tail++;
            }
        }
        head++;
    }
    return 0;
}
int main()
{
    int i, j;
    cin>>n>>m;
    for(i=0; i<n; i++)
    {
        scanf("%s", str[i]);
        for(j=0; j<m; j++)
        {
            mp[i][j]=str[i][j]=='#';
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            if(mp[i][j])continue;
            for(int l=0; l<n; l++)
            {
                for(int k=0; k<m; k++)
                {
                    if(mp[l][k])continue;
                    ans=max(ans, bfs(i, j, l, k));
//                    printf("%d %d %d %d %d\n", i, j, l, k, bfs(i,j,l,k));
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  if(n % 1000 != 0) {
    cout << ((n + 1000 - 1) / 1000) * 1000 - n << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MXX = 1e6 + 5;


int main ()
{
    int n,m; cin>>n>>m;
    vector<string>v;
    for(int i = 0; i<n; i++)
    {
        string s; cin>>s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(auto x: v)cout<<x;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256