akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) cout << "Left" << endl;
	else if (A + B == C + D) cout << "Balanced" << endl;
	else cout << "Right" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m = mod){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m = mod){
    return pow_mod(a, m - 2, m);
}
template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<ll> dp(S + 1, 0); // i個つかって和がjになる組み合わせの個数
    dp[0] = pow_mod(2, N);
    ll ans = 0;
    rep(i, N) {
        for(ll j = S; j >= 0; j--) {
            ll half = dp[j] * inv_mod(2) % mod;
            if(j + A[i] <= S) (dp[j + A[i]] += half) %= mod;
        }
        (ans += dp[S]) %= mod;
//        cout << i << ": ";
//        voutput(dp);
    }
    output(dp[S]);
    
    
    
    
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int num[N];
    int i;
    for(i=0;i<N;i++){cin>>num[i];}
    
    int j,h,max,min;
    max=num[0];
    min=num[0];
    for(j=0;j<N-1;j++){if(max<num[j+1]) max=num[j+1];}
    for(h=0;h<N-1;h++){if(min>num[h+1]) min=num[h+1];}
    cout<<max-min;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll Q = 1000000007;

vector<ll> v(100001);

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, m;
    cin >> n >> m;
    
    v[0] = 0; v[1] = 1; v[2] = 1;
    
    for ( ll i = 3; i <= n + 1; i++ ){
        v[i] = v[i-1] + v[i-2];
        v[i] %= Q;
    }
    
    vector<ll> a(m+2), b(m+1);
    
    a[0] = -1;
    for ( ll i = 1; i <= m; i++ )
        cin >> a[i];
    
    a[m + 1] = n + 1;
    
    for ( ll i = 0; i <= m; i++ )
        b[i] = a[i+1] - a[i] - 1;
    
    ll ans = 1;
    for ( ll i = 0; i <= m; i++ ){
        ans *= v[b[i]];
        ans %= Q;
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  
	int N;
  	long long int sum = 0;
  	cin >> N;
  
  	for(int i = 1; i <= N; i++){
    	if((i % 3 != 0) && (i % 5 != 0)){
        	sum += i;
        }
    }
  
  	cout << sum << endl;
  
  	return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  string s;cin>>s;
  for(int i=0;i<n;i++){
    if(i+1==k){
      if(s[i]=='A')cout<<'a';
      else if(s[i]=='B')cout<<'b';
      else if(s[i]=='C')cout<<'c';
    }
    else cout<<s[i];
  }
  cout<<endl;

  return 0;
}


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

int n;
ll l,x[300000];
ll a[300000];

ll calc(){
	ll Max=0,cnt=0;
	for(int i=0,c=n;c>=0;i++,c-=2){
		cnt+=a[i]*c;
	}
	for(int i=n,c=n-1;c>=0;i--,c-=2){
		cnt+=a[i]*c;
	}
	Max=cnt;
	rep(i,n){//どこまで直進するか?
		cnt-=x[i];
		int d=(n-i)/2+i;
		cnt+=x[d]-x[i];
		int e=n-(n-i)/2;
		cnt-=l-x[e];
		Max=max(Max,cnt);
	}
	return Max;
}
int main(){
	scanf("%lld%d",&l,&n);
	rep(i,n){
		scanf("%lld",&x[i]);
		a[i]=x[i];
		if(i)a[i]-=x[i-1];
	}
	ll ans=0;
	a[n]=l-x[n-1];
	ans=calc();
	reverse(x,x+n);
	rep(i,n){
		x[i]=l-x[i];
		a[i]=x[i];
		if(i)a[i]-=x[i-1];
	}
	a[n]=l-x[n-1];
	ans=max(ans,calc());
	cout<<ans<<endl;
}

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

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<PP> C(M);
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        C[i] = PP(P(p, y), i);
    }
    sort(C.begin(), C.end());

    vector<P> res(M);
    int pre = 0, cnt = 0;
    for (int i = 0; i < M; i++) {
        PP c = C[i];
        if (c.first.first == pre) {
            cnt++;
        } else {
            cnt = 1;
        }
        pre = c.first.first;
        res[c.second] = P(pre, cnt);
    }

    for (int i = 0; i < M; i++) {
        printf("%.6d%.6d\n", res[i].first, res[i].second);
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	int a[4][3][10];
	std::fill( (int*)a, (int*)( a+4 ), 0 );

	cin >> n;
	for( int i=0; i<n ; i++ ) {
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] = std::max( a[b-1][f-1][r-1] + v, 0 );
	}

	for( int i=0; i<4; i++ ) {
		if( i>0 ) { cout << "####################" << endl; }
		
		for( int j=0; j<3; j++ ) {
			for( int k=0 ; k<10; k++ ) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3124
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nck = readln.split.to!(int[]);
    auto N = nck[0];
    auto C = nck[1];
    auto K = nck[2];

    int[] TS;
    TS.length = N;
    foreach (i; 0..N) TS[i] = readln.chomp.to!int;
    sort(TS);

    int cnt, last_t, bs;
    foreach (t; TS) {
        if (!last_t) last_t = t;
        if (t > last_t + K || cnt == C) {
            ++bs;
            cnt = 0;
            last_t = t;
        }
        ++cnt;
    }
    writeln(bs+1);
}

Measured memory_bytes: 3452
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  var R = parseInt(input[0].split(" ")[2]);
  r= input[1].split(" ");
  for(i=0;i<R;i++){
    r[i]=parseInt(r[i])-1;
  }
  map=new Array(N);
  for(i=0;i<N;i++){
    map[i]=new Array(N).fill(Number.MAX_VALUE);
  }
  for(i=0;i<M;i++){
    map[parseInt(input[i+2].split(" ")[0]-1)][parseInt(input[i+2].split(" ")[1]-1)]=parseInt(input[i+2].split(" ")[2]);
    map[parseInt(input[i+2].split(" ")[1]-1)][parseInt(input[i+2].split(" ")[0]-1)]=parseInt(input[i+2].split(" ")[2]);
  }
  for(k=0;k<N;k++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        if(map[i][j]>map[i][k]+map[k][j]){
          map[i][j]=map[i][k]+map[k][j];
        }
      }
    }
  }
  perm = generatePermutation([],[],r,r.length);
  var ans=Number.MAX_VALUE;
  while(perm.length!=0){
    var dist=0;
    for(i=0;i<r.length-1;i++){
      dist+=map[perm[0][i]][perm[0][i+1]];
    }
    ans=Math.min(ans,dist);
    perm.shift();
  }

  function generatePermutation(perm, pre, post, n){
    var elem, i, rest, len;
    if (n > 0){
      for (i = 0, len = post.length; i < len; ++i) {
        rest = post.slice(0);
        elem = rest.splice(i, 1);
        generatePermutation(perm, pre.concat(elem), rest, n - 1);
      }
    }else{
      perm.push(pre);
    }
    return perm;
  }


  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[k] + l[j] > l[i] && l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) ans++; 
            }
        }
    }
    cout << ans << endl;
}

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

#include <algorithm>

int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  int l[102];
  int cnt = 0;
  int flg[102];
  int f = 0;
  for(int i = 0; i < n; ++i){
    cin >> l[i];
  }
  sort(l, l + n);
  for(int i = 0; i < n; ++i){
    int a = l[i];
    for(int j = i + 1; j < n; ++j){
      if(a == l[j]){ continue; }
      int b = l[j];
      for(int k = j + 1; k < n; ++k){
        if(a == l[k]){ continue; }
        if(b == l[k]){ continue; }
        int c = l[k];
        if(a + b > c && b + c > a && c + a > b){
          /*bool che = true;
          for(int x = 0; x < f; ++x){
            if(flg[x] == a * 100 + b * 10 + c){
              che = false; break;
            }
          }
          if(che){
            cout << a * 100 + b * 10 + c << endl;
            flg[f] = a * 100 + b * 10 + c;
            f++;*/
            cnt++;
          //}
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a%b); 
} 
// Use __gcd(int, int) as inbuilt function.
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p) 
{ 
    long long int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1;  
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p; 
}*/

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    if((s[2]==s[3])&&(s[4]==s[5])){
    	cout<<"Yes";
    }
    else{
    	cout<<"No";
    }
   	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    x <- getInt
    let (a,b) = head [(a,b)| a <- [0..200], b <- [-200..200], a^5 - b^5 == x]
    putStr $ show a
    putStr " "
    putStrLn $ show b

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
while(1){
cin >> x >> y;
if(x==0&&y==0){
break;
  }else if(x<y){
cout << x << " " << y << endl ;
  }else{
cout << y << " " << x << endl ;
}
}
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int color[112345] = {};
vector<PII> adlist[112345];

void bfs(int pos, int col){
    if(color[pos] == -1) color[pos] = col;
    queue<PII> que;
    que.push(make_pair(pos,col));

    while(!que.empty()){
        auto u = que.front(); que.pop();
        dump(u.first)
        dump(u.second)

        for(auto p : adlist[u.first]){
            if(color[p.first] == -1){
                int newcol;
                if(p.second % 2 != 0){
                    dump("odd")
                    newcol = u.second * -1 + 1;
                    dump(newcol)
                    color[p.first] =  newcol;
                }
                else{
                    dump("even")
                    newcol = u.second;
                    dump(newcol)
                    color[p.first] = newcol;
                }
                dump(p.first)
                dump(p.second)
                dump(color[p.first])

                que.push(make_pair(p.first,newcol));
            }
        }
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i,112345) color[i] = -1;
    int N; cin >> N;
    REP(i,N-1){
        int u,v,w; cin >> u >> v >> w;
        u--; v--;
        adlist[u].eb(v,w);
        adlist[v].eb(u,w);
    }
    bfs(0,0);
    REP(i,N){
        cout << color[i] <<endl;
    }


}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  ll ans = 0;
  for(int i=0; i<n; ++i){
    int bcnt = 0, acnt = 0;
    for(int j=0; j<n; ++j){
      if(an[i] > an[j]){
        if(i>j) ++bcnt;
        else ++acnt;
      }
    }
    ans += (ll)k *(k-1)/2 %MOD *(acnt +bcnt);
    ans += (ll)k *acnt;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import sys
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
city = {}
yton = {}
for i in range(m):
    p,y = map(int, sys.stdin.readline().rstrip("\n").split())
    if p not in city.keys():
        city[p] = []
        city[p].append(y)
        yton[y] = i
    else:
        city[p].append(y)
        yton[y] = i
ans = [None]*m
for p in city.keys():
    city[p].sort()
    for i,y in enumerate(city[p]):
        ans[yton[y]] = str(p*(10**6)+i+1).zfill(12)
print(*ans, sep = '\n') 

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    int A, B;
    if(N==1) cout << "Hello World" << endl;
    else{
        cin >> A >> B;
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/tasks/abc137_b
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i < x + k; i++) {
        cout << i << " ";
    }

    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.List
import Data.Char (digitToInt)
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

fastPowerMod :: Int -> Int -> Int -> Int
fastPowerMod b 0 _ = 1
fastPowerMod b 1 modnum = b `mod` modnum
fastPowerMod b n modnum
            | even n = (fastPowerMod b (n `div` 2) modnum ^ 2) `mod` modnum
            | otherwise = (fastPowerMod b (n - 1) modnum * b) `mod` modnum


solve :: [Int] -> Int
solve ns = case findNum of
                1 -> -1
                _ -> break
    where
    inner (findNum, break) num
            | findNum == num = (findNum + 1, break)
            | otherwise = (findNum, break + 1)
    (findNum, break) = foldl' inner (1, 0) ns

main = do
    _ <- readInt
    ns <- readInts
    print $ solve ns



Measured memory_bytes: 4348
#include <queue>
#include <iostream>
#include <map>
using namespace std;
typedef vector<int> A;
typedef vector<A> M;
#define REP(i,x)for(int i=0;i<x;i++)
int d[4]={0,1,0,-1};
int main() {
	queue<M> que;
	map<M,int> mindist;
	M m(2,A(4));
	REP(i,2)REP(j,4)m[i][j]=i*4+j;
	que.push(m);
	while(!que.empty()){
		M now=que.front();que.pop();
		int time=mindist[now];
		REP(i,2)REP(j,4)if(now[i][j]==0)REP(k,4){
				int ni=i+d[k],nj=j+d[k^1];
				if(ni>=0&&ni<2&&nj>=0&&nj<4){
					swap(now[i][j],now[ni][nj]);
					if(mindist.count(now)==0){
						mindist[now]=time+1;
						que.push(now);
					}
					swap(now[i][j],now[ni][nj]);
				}
			}
	}
	while(cin>>m[0][0]>>m[0][1]>>m[0][2]>>m[0][3]>>m[1][0]>>m[1][1]>>m[1][2]>>m[1][3]){
		cout<<mindist[m]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
// Hint: Don't look, No need, Let'em Play.

#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

using hr_clock = chrono::high_resolution_clock;

struct Timer_ {
    private: chrono::time_point<hr_clock> start_;
    public: Timer_(); ~Timer_();
}_;

#define single_test

void solve() {
    string a, b;
    int ans = 0;
    cin >> a >> b;
    for (int i = 0; i < (int)a.size(); ++i) {
        ans += a[i] != b[i];
    }
    cout << ans << '\n';

}

signed main() {
    fast;
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    while (t--) {
        // Timer_ _;
        solve();
    }

    return 0;
}

Timer_::Timer_() {
    start_ = hr_clock::now();
}

Timer_::~Timer_() {
    #ifdef bhupixb
    cerr << "took: " << chrono::duration_cast<chrono::microseconds>(hr_clock::now() - start_).count() / 1000 << " ms\n";
    #endif
}


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

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

    string ans = "";
    if (n == 0)
        ans = "0";
    else {
        while (n != 0) {
            int d = (n % -2 + 2) % 2;
            ans += char('0' + d);
            n -= d;
            n /= -2;
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int n, t, a;
    int h[1010];
    cin >> n >> t >> a;
    for (int i=0; i<n; i++) cin >> h[i];
    
    int idx = 0;
    float best = abs(a - (t - h[0] * 0.006));
    for (int i=1; i<n; i++) {
        if (abs(a - (t - h[i] * 0.006)) < (best)) {
            idx = i;
            best = abs(a - (t - h[i] * 0.006));
        } 
    }
    cout << idx + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.append(0)
for i in range(n):
    if l[i]>x:
        ans+=l[i]-x
        l[i]=x
    if l[i]+l[i+1]>x:
        ans+=l[i]+l[i+1]-x
        l[i+1]-=l[i]+l[i+1]-x
print(ans)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	string a,b,c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] and b[i] != c[i] and a[i] != c[i]) {
			ans += 2;
		}
		else if (a[i] != b[i] or b[i] != c[i] or c[i] != a[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    Count = [0] * N
    for k in range(K):
        d = int(input())
        A = [int(a) - 1 for a in input().split()]
        for a in A: Count[a] += 1
    print(Count.count(0))

    return 0

if __name__ == "__main__":
    solve()

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B, R = C + D;
  if (L == R) cout << "Balanced" << endl;
  else if (L > R) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 3632
def solve(xs):
	if xs == []:
		return 0
	m = min(xs)
	ans = m
	ys = []
	for i in xs:
		if i == m:
			ans = ans + solve(ys)
			ys = []
		else:
			ys.append(i - m)
	ans = ans + solve(ys)
	return ans

N = int(input())
h = list(map(int, input().split()))
print(solve(h))

Measured memory_bytes: 38768
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

long long mod = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long N, answer = 1;
    cin >> N;
    for (long long i = 1; i <= N; ++i) {
        answer = (answer * i) % mod;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 50005

struct Point{
	double x,y;
};

struct Circle{
	Point center;
	double r;
};

struct Info{
	Info(double arg_loc,int arg_value){
		loc = arg_loc;
		value = arg_value;
	}
	bool operator<(const struct Info &arg) const{
		return loc < arg.loc; //場所の昇順
	}
	double loc;
	int value;
};

int N;
Circle circle[NUM];
vector<Info> V;

bool is_ok(double tmp_height){

	V.clear();
	double tmp_diff;

	for(int i = 0; i < N; i++){
		if(2.0*circle[i].r > tmp_height){
			//数直線上でimos
			tmp_diff = sqrt(circle[i].r*circle[i].r-(tmp_height*tmp_height)/4.0);
			V.push_back(Info(circle[i].center.x-tmp_diff,1));
			V.push_back(Info(circle[i].center.x+tmp_diff,-1));
		}
	}

	sort(V.begin(),V.end());

	int tmp_sum = 0;
	double pre_loc = 999999999.0,tmp_max = 0;

	for(int i = 0; i < V.size(); i++){

		if(tmp_sum == 0){ //重み区間外から、左端に遭遇

			pre_loc = V[i].loc;
		}

		tmp_sum += V[i].value;

		if(tmp_sum == 0){ //線分完成
			/*★高さは条件を満たしているので、幅の最大値がtmp_height以上であれば良い★*/
			tmp_max = max(tmp_max,V[i].loc-pre_loc);
		}
	}

	if(tmp_height <= tmp_max){

		return true;

	}else{
		return false;
	}
}

void func(){

	double maximum = 0;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&circle[i].center.x,&circle[i].r);
		maximum = max(maximum,2.0*circle[i].r); //仮の最大長
	}

	double left = 0,right = maximum,mid = (left+right)/2.0;
	double ans = -1;

	for(int loop = 0; loop < 50; loop++){

		if(is_ok(mid)){

			ans = mid;
			left = mid+EPS; //より大きく

		}else{

			right = mid-EPS;
		}
		mid = (left+right)/2.0;
	}
	printf("%.10lf\n",ans);
}

int main(){

	while(true){

		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 6088
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const ll MOD = 1e9 + 7;
void add(ll& x, ll y) { x += y; if (x >= MOD) x -= MOD; }
void take(ll& x, ll y) { x -= y; if (x < 0) x += MOD; }

ll sum(ll a, ll b) { add(a, b); return a; }
ll sub(ll a, ll b) { take(a, b); return a; }
ll mul(ll x, ll y) { return (x * y) % MOD; }

ll fact(ll a) {
    ll ans = 1;
    for (ll i = 2; i <= a; ++i) {
        ans *= i;
        ans %= MOD;
    }
    ans %= MOD;
    return ans;
}

ll ans = 1;
void foo(ll x) { ans = mul(ans, x); }

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    string s;
    cin >> n >> s;

    ll started = 0;
    ll curr = 1;
    for (int i = 0; i < 2 * n; ++i) {
        ll t = s[i] == 'W' ? 0 : 1;
        if (t == curr) {
            ++started;
        } else {
            if (started <= 0) {
                cout << 0 << endl;
                return 0;
            }
            foo(started--);
        }
        curr = 1 - curr;
    }
    if (started != 0) {
        cout << 0 << endl;
        return 0;
    }

    foo(fact(n));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
import sys
from heapq import heappush,heappop
r=sys.stdin.readline
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=[*map(int,r().split())]
  if f[0]:
   c,d,e=f[1:]
   E[c]+=[(e,d)];E[d]+=[(e,c)]
  else:print(g(*f[1:]))


Measured memory_bytes: 6268
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
		if( (xa1<xb1 && xa2<xb1) || (xa1>xb2 && xa2>xb2) || (ya1<yb1 && ya2<yb1) || (ya1>yb2 && ya2>yb2))printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,W;
  cin >> n >> W;
  vector<ll>w(n+1),v(n+1);
  for(i=1;i<=n;i++)cin >> w[i] >> v[i];
  ll dp[n+1][W+1];
  for(i=0;i<=W;i++)dp[0][i]=0;
  for(i=1;i<=n;i++){
    for(j=0;j<=W;j++){
      if(j-w[i]<0)dp[i][j]=dp[i-1][j];
      else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<int> s = {1, 2, 3};
	int a, b;
	cin >> a >> b;
	s.erase(a);
	s.erase(b);
	cout << *s.begin();
	return 0;
}

Measured memory_bytes: 256
S = input()
lcnt = 0
for i in range(len(S)):
    if "A" <= S[i] and S[i] <= "Z":
        lcnt += 1
ccnt = 0
for i in range(2, len(S) - 1):
    if S[i] == "C":
        ccnt += 1
if S[0] != "A":
    print("WA")
elif ccnt != 1:
    print("WA")
elif lcnt != 2:
    print("WA")
else:
    print("AC")


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
#define SZ(x) ((int)(x).size())

class Bsearch {
public:
	int  n;
	int  q;
	int right;
	int left;
	int middle;
	int S[100000];
	int T[100000];
	void input();
	bool BinaryS(int i);
	void init();

};

void Bsearch::input() {
	
	cin >> n;
	rep(i, n) cin >> S[i];
	cin >> q;
	rep(i, q) cin >> T[i];
	
}

void Bsearch::init() {
	right = n;
	left = 0;
}
bool Bsearch::BinaryS(int i) {
	int key = T[i];
		while (left<right) {
			middle = (left+ right) / 2;
			if (S[middle] == key) {
				return true;
			}
			else if (S[middle]>key) {
				right = middle;
			}
			else{
				left= middle + 1;
			}
		}
		return false;
	}



int main()
{
	int cnt = 0;
	Bsearch b;
	b.input();
	rep(i, b.q) {
		b.init();
		if (b.BinaryS(i)) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


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

int N;

int In() {
  string s;
  cin >> s;
  if (s[0] == 'V') return 2;
  if (s[0] == 'M') return 0;
  if (s[0] == 'F') return 1;
}

int ans = 0;
int Less(int pos, int yes) {
  cout << pos << endl;
  ans = In();
  if (ans == 2) exit(0);
  return ans == yes;
}

int main() {
  cin >> N;
  cout << 0 << endl;
  int state = In();
  if (state == 2) return 0;
  
  int lo = 0;
  int hi = N;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if (Less(mid, (!state) ^ ((mid - lo) % 2))) {
      hi = mid;
    } else {
      lo = mid;
      state = ans;
    }
  }
  
  return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	cout << a + (b / 2);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 36 

typedef struct{
    char shape; 
    int  value;
}Data;

int main(){

  int i;
  int j;
  int n;
  int min;
  int judge=0;
  Data b_data[N];
  Data s_data[N];
  Data buf[N];
  Data tmp;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c%d",&buf[i].shape,&buf[i].value);
  }

  for(i=0;i<n;i++){
    s_data[i] = buf[i];
    b_data[i] = buf[i];
  }
  
  for(i=0;i<n-1;i++){
    for(j=n-1;j>=1;j--){
      if(b_data[j].value<b_data[j-1].value){
	tmp = b_data[j];
	b_data[j] = b_data[j-1];
	b_data[j-1] = tmp;
    }
   }
  }

  for(i=0;i<n-1;i++){
    min = i;
    for(j=i+1;j<n;j++){
      if(s_data[j].value<s_data[min].value){
	min = j;
      }
    }
      if(min!=i){
	tmp = s_data[i];
	s_data[i] = s_data[min];
	s_data[min] = tmp;
   }
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ",b_data[i].shape,b_data[i].value);
  }
  printf("%c%d\n",b_data[i].shape,b_data[i].value);

  printf("Stable\n");
    
  for(i=0;i<n-1;i++){
    printf("%c%d ",s_data[i].shape,s_data[i].value);
  }
  printf("%c%d\n",s_data[i].shape,s_data[i].value);

  judge=0;
  
  for(i=0;i<n-1;i++){
    if(b_data[i].value == s_data[i].value && b_data[i].shape != s_data[i].shape){
    judge=1;
    break;
   }
  }
  
  if(judge==0) printf("Stable\n");
  else printf("Not stable\n");
    
  return 0;
}

Measured memory_bytes: 608
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n; int h[101];
int solve(int l, int r){
	if(l>r) return 0;
	int mn=101, mni=-1;
	for(int i=l; i<=r; i++){
		if(mn>h[i]){
			mn=h[i], mni=i;
		}
	}
	for(int i=l; i<=r; i++) h[i]-=mn;
	return solve(l, mni-1)+solve(mni+1, r)+mn;
}
int main()
{
	cin>>n; for(int i=0; i<n; i++) cin>>h[i];
	cout<<solve(0, n-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
# 042a

def atc_042a(input_value: str) -> str:
    ABC = input_value.split(" ")
    if ABC.count("5") == 2 and ABC.count("7") == 1:
        return "YES"
    return "NO"

input_value_1 = input()
print(atc_042a(input_value_1))


Measured memory_bytes: 8928
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define ll long long
#define pii pair < ll , ll >
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;


int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ll temp = 100;
    while(temp < x){
        temp = temp * (1.01);
        ans++;
    }
    cout << ans;


}

Measured memory_bytes: 3616
#include <stdio.h>

int partition(int[], int, int);

int main()
{


  int i,j,A[100000],n,m;

  scanf("%d",&n);

  for(i=0;i<n;i++)  scanf("%d",&A[i]);

  m = partition(A,0,n-1);

  for(i=0;i<n;i++){

    if(i) printf(" ");

    if(i == m) printf("[");

    printf("%d",A[i]);

    if(i == m) printf("]");
  }
  printf("\n");
 


  return 0;
}
 
 int partition(int A[] ,int p,int r)
  {
    int tmp,i,j,x;
  x = A[r];
  i = p-1;

  for(j=p;j<r;j++){
    if(A[j] <= x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;


  return i+1;
  }

Measured memory_bytes: 996
K, S = map(int, input().split())

c = 0
for x in range(K + 1):
    if x > S:
        break
    for y in range(K + 1):
        if x + y > S:
            break
        z = S - x - y
        if 0 <= z <= K:
            c += 1

print(c)

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

char A[200];

void solve(){
    string s; cin >> s;
    for(char c : s)
        A[c]++;
    for(int i = 0; i < 200; i++){
        if(A[i]%2 != 0){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}


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

    bool multitest = false;
    //multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3588
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int h, w;
string s[505], t[505];

int main() {
  scanf("%d%d",&h,&w);
  rep(i,h) cin >> s[i], t[i] = s[i];
  rep(i,w) s[0][i] = '#', t[h-1][i] = '#';
  rrep(i,h-2)rep(j,w) if (j&1) s[i][j] = '#'; else t[i][j] = '#';
  rep(i,h) cout<<s[i]<<endl;
  cout<<""<<endl;
  rep(i,h) cout<<t[i]<<endl;
  return 0;
}







Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std; using ll = long long;
#define REP(i,n) for(int i=0,i##__=(n);i<i##__;++i)
#define ALL(o) (o).begin(),(o).end()
#define PUT(a) cout<<a<<"\n"
#define VEC2D(v,y,x,s) vector<vector<int>> v(y, vector<int>(x, s))
//ここまでテンプレ
int main() {
    priority_queue<int> pq; 
    int N,M;
    cin>>N>>M;
    VEC2D(AB,M,0,0);

    REP(i,N){
        int A,B;
        cin>>A>>B;
        if(A<=M)AB.at(A-1).push_back(B);
    }

    REP(i,M) sort(ALL(AB[i]));
    
    int ans = 0;
    REP(i,M){
        REP(j,AB[i].size()){
            pq.push(AB[i][j]);
        }
        if(pq.size()>0){
            ans += pq.top();
            pq.pop();
        }    
    }

    PUT(ans);
}

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

int main()
{
	int H, W;
	int j;

	while (1)
	{
		cin >> H >> W;

		if (H == 0 && W == 0)
		{
			return 0;
		}

		for (int i = 1; i <= H; i++)
		{
			if (i % 2 == 0)//??????H?????¶??°????????¨???
			{
				for (j = 1; j <= W; j++)
				{
					if (j % 2 == 0)//??????W?????¶??°????????¨???
					{
						cout << "#";
					}
					else//??????W????\???°????????¨???
					{
						cout << ".";
					}
				}
			}
			else//??????H????\???°????????¨???
			{
				for (j = 1; j <= W; j++)
				{
					if (j % 2 == 0)//??????W?????¶??°?????¨???
					{
						cout << ".";
					}
					else//??????W????\???°?????¨???
					{
						cout << "#";
					}
				}
			}
			cout << "\n";
		}
		cout << "\n";

	}
	return 0;
}

Measured memory_bytes: 3028
import sys
readline = sys.stdin.readline
N = int(readline())
a = list(map(int, readline().split()))

aa = []
for i in range(N):
    tmp = [a[i], i]
    aa.append(tmp)

aa.sort(key=lambda x: x[0])

aaa = []
for i in range(N):
    aaa.append(str(aa[i][1] + 1))

print(' '.join(aaa))

Measured memory_bytes: 28900
def len_LCS(X,Y):
    lcs_row = [0 for _ in range(len(X)+1)]
    for yc in Y:
        lcs_row_p = lcs_row[:]
        # lcs_row_p: [i] [i+1]
        # lcs_row  : [i] [i+1]
        for (i,xc) in enumerate(X):
            if xc == yc:
                lcs_row[i+1] = lcs_row_p[i] + 1
            elif lcs_row[i] > lcs_row_p[i+1]:
                lcs_row[i+1] = lcs_row[i]
    return lcs_row[-1]
        
if __name__=='__main__':
    n = int(input())
    for _ in range(n):
        X = input()
        Y = input()
        print(len_LCS(X,Y))

Measured memory_bytes: 7740
fun main(args:Array<String>){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map {((it.toInt() + 1) / 2.0) }
    var sum = list.take(k).sum()
    var max = sum
    for(i in 0 until n-k){
        sum += list[i+k] - list[i]
        if(max < sum) max = sum
    }
    println(max)
}

Measured memory_bytes: 61596
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
string s,s1;
int ans[100005];
vector <int> v,p;
main(){
cin>>s;
n=s.size();
for(int k=s.size()-1;k>=0;k--){
   s1+=s[k];
}
s='%'+s;
s1='%'+s1;
for(int k=2;k<=n;k++){
    if(s[k]!=s[k-1] && s[k]=='L'){
        v.push_back(k);
    }
}
for(int k=2;k<=n;k++){
    if(s1[k]!=s1[k-1] && s1[k]=='R'){
        p.push_back(k);
    }
}

for(int k=1;k<=n;k++){
        int i=k;
        int t=0;

vector <int>::iterator it;
int tt;
if(s[k]=='R'){
it=lower_bound(v.begin(),v.end(),i);
tt=*it;
}
else{
  it=lower_bound(p.begin(),p.end(),n-i+1);
  tt=*it;
  tt=n-tt+2;
}
if(tt%2!=i%2)
    t=1;
    i=tt;
    if(t%2==1){
        if(s[i]=='L')
            ans[i-1]++;
        else ans[i+1]++;
    }
    else{
       ans[i]++;
    }
}
for(int k=1;k<=n;k++)
    cout<<ans[k]<<' ';
return 0;
}


Measured memory_bytes: 2268
def squareArea(x, y)
	return x * y
end
def squareSide(x, y)
	return (x * 2) + (y * 2)
end

input = gets.chomp
a, b = input.split(' ').map(&:to_i)

puts sprintf('%d %d', squareArea(a, b), squareSide(a, b))

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

typedef pair<long, long> pll;

long n, m, a[100010], b, c, l, r, ans;
pll bc[100010];

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	for (int i = 0; i < m; ++i){
		cin >> b >> c;
		bc[i] = {b, c};
	}
	sort(a, a+n);
	sort(bc, bc+m, [](pll x, pll y){return x.second > y.second;});

	l = 0;
	r = n;
	ans = 0;
	for (int i = 0; i < m; ++i){
		if (bc[i].second <= a[l]) break;
		r = upper_bound(a+l, a+n, bc[i].second) - a;
		r = min(r, l+bc[i].first);
		ans += (r - l)*bc[i].second;
		l = r;
	}
	for (int i = l; i < n; ++i) ans += a[i];
	cout << ans;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String a = sc.next();
		String b = sc.next();
		String str = "";
		if (a.length() > b.length()) {
			str = "GREATER";
		} else if (a.length() < b.length()) {
			str = "LESS";
		} else {
			boolean t = true;
			for (int i = 0; i < a.length(); i++) {
				if (a.charAt(i) > b.charAt(i)) {
					str = "GREATER";
					t = false;
					break;
				} else if (a.charAt(i) < b.charAt(i)) {
					str = "LESS";
					t = false;
					break;
				}
			}
			if (t) {
				str = "EQUAL";
			}
		}
		System.out.println(str);
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
vector<vector<int>> graph(200010);
vector<bool> seen;
vector<int> depth;
queue<int> que;

int main(){
    int N, M;
    cin >> N >> M;
    seen.resize(N);
    depth.resize(N);
    seen[N-1]=false;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        seen[a] =false;
        seen[b] =false;
    }
    for(auto x : graph[0]){
        que.push(x);
        depth[x]=1;
        seen[0]=true;
    }
    while(!que.empty()){
        int v = que.front();
        que.pop();
        seen[v]=true;
        //cout << v << endl;
        for(auto x: graph[v]){
            //cout << v << x << depth[v] << endl;
            if(seen[x]==false){
                depth[x] = depth[v]+1;
                que.push(x);
            }
        }
    }
    //rep(i,N) cout << i << depth[i] << endl;
    //cout << depth[N-1] << endl;
    if(seen[N-1] && depth[N-1]<3){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 13168
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
const int N=1e3+10;
int main(){
    int q,n,mid,ans=0,a,b,t,m;
    char c[N][N];
    set<pair<int,int>> l,r;
    scanf("%d%d",&q,&n);
    mid=n/2;
    for(int i=0;i<n;i++)scanf("%s",c[i]);
    for(int i=0;i<n;i++){
        for(int j=0;j<mid;j++){
            if(c[i][j]!=c[i][n-j-1])l.insert({i,j});
            if(c[j][i]!=c[n-j-1][i])r.insert({j,i});
        }
    }
    if(l.empty()&&r.empty())ans++;
    q--;
    while(q--){
        scanf("%d",&m);
        while(m--){
            scanf("%d%d",&a,&b);
            a--;
            b--;
            if(b>=mid)t=n-1-b;
            else t=b;
            if(l.find({a,t})!=l.end())l.erase({a,t});
            else l.insert({a,t});
            if(a>=mid)t=n-1-a;
            else t=a;
            if(r.find({t,b})==r.end())r.insert({t,b});
            else r.erase({t,b});
        }
        if(l.empty()&&r.empty())ans++;
    }
    printf("%d\n",ans);
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> R, G, B;
    rep(i,n){
        if(s[i] == 'R') R.push_back(i);
        if(s[i] == 'G') G.push_back(i);
        if(s[i] == 'B') B.push_back(i);
    }
    ll ans = 0;
    for(auto r : R){
        for(auto g : G){
            int i, j, k;
            if(r < g){
                i = (r-(g-r));
                if((r+g)%2 == 0) j = (r+g)/2;
                else j = -1;
                k = g + (g-r);
            }
            else{
                i = (g - (r-g));
                if((r+g)%2 == 0) j = (r+g)/2;
                else j = -1;
                k = r + (r-g);
            }
            if(i >= 0){
                if(s[i] == 'B') ans--;
            }
            if(j >= 0 && j <= n-1){
                if(s[j] == 'B') ans--;
            }
            if(k <= n-1){
                if(s[k] == 'B') ans--;
            }
            ans += B.size();
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656