akhauriyash/Code-Regression huggingface dataset:
import Data.Char
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V

readInt = B.readInt . B.dropWhile isSpace

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

getIntList = unfoldr readInt <$> B.getLine

main = do
  n <- getInt
  ds <- getIntList
  let es = go [0..] (group (sort ds))
  if head ds == 0 && all (/= 0) es
    then print . solve $ es
    else print 0
    where
      go _ [] = []
      go (n:ns) sss@(s:ss)
        | n == head s = length s : go ns ss
        | otherwise   = 0 : go ns sss
      solve ns
        | head ns /= 1 = 0
        | otherwise = foldr (((`mod` modInt) .) . (*)) 1 . zipWith pow' ns $ tail ns

modInt = 998244353
pow' x y
  | y == 0 = 1
  | even y = ((pow' x (y `div` 2)) ^ 2) `mod` modInt
  | otherwise = x * (pow' x (y - 1)) `mod` modInt


Measured memory_bytes: 16764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

bool used[105];

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

    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; ++i){
        cin >> b[i];
        if(b[i] > i + 1){
            cout << -1 << endl;
            return 0;
        }
    }
    SegmentTree<int> seg(n, [](int a, int b){return a + b;}, 0);
    vector<int> ans;
    bool update = true;
    while(update){
        update = false;
        for(int i = n - 1; i >= 0; --i){
            if(used[i]) continue;
            if(seg.query(0, i) < b[i] - 1)  continue;
            update = true;
            used[i] = true;
            ans.push_back(b[i]);
            seg.update(i, 1);
            break;
        }
    }
    for(int i = 0; i < n; ++i)  cout << ans[i] << "\n";
}

Measured memory_bytes: 256
import Control.Monad
import Data.Char
import Data.List
import qualified Data.Vector.Mutable as MV
import Text.Printf

solve c = trans codePoint
  where
    codePoint = fromEnum c
    trans codePoint
      | 97 <= codePoint && codePoint <= 122 = toEnum (codePoint - 32) :: Char
      | 65 <= codePoint && codePoint <= 90 = toEnum (codePoint + 32) :: Char
      | otherwise = c

main1 = do
  string <- getLine
  putStrLn $ map solve string

solve2 :: String -> Int
solve2 numbers = sum $ map (\n -> (fromEnum n) - (fromEnum '0')) numbers
  -- foldr (\n m -> m + ((fromEnum n) - 48)) 0 numbers

main2 = do
  strings <- fmap (takeWhile (/= "0") . lines) getContents
  let ints = map solve2 $ strings
  mapM_ (putStrLn . show) $ ints

main3 = do
  strings <- getContents
  vector <- MV.replicate 26 0
  solve3' strings vector
  forM_ (zip [0..25] ['a'..'z']) $ \ia -> do
    let (i,a) = ia
    count <- MV.read vector i
    putStrLn $ [a] ++ " : " ++ (show count)

solve3 list = map (\(n:ns) -> (n,length (n:ns))) list'
  where
    list' = group . sort . filter isAlpha . map toLower $ list

solve3' list vector = do
  forM_ list $ \n -> do
    when (isAlpha n) $ do
      let c = fromEnum n
      if 97 <= c
        then do
        MV.read vector (c-97) >>= (\v -> MV.write vector (c-97) (v+1))
        else do
        MV.read vector (c-65) >>= (\v -> MV.write vector (c-65) (v+1))


main = do
  s <- getLine
  p <- getLine
  putStrLn $ if solve4 s p then "Yes" else "No"

solve4 s p = p `elem` ringStrings
  where
    pLength = length p
    ringStrings = map (take pLength) $ genRingStrings s

genRingStrings list = loop list (length list) []
  where
    loop (p:ps) n list
      | n == 0 = list
      | otherwise = loop psp (n-1) (list ++ [(p:ps)])
      where
        psp = ps ++ [p]



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

#define l 	long
#define ll 	long long
#define vll vector<ll> 
#define vi 	vector<int>
#define pb push_back
#define pi 3.14159265358979323846

// #define rep(j,n,s)  for(long i=j;i<=n;i+=s)
#define forn(j,n,s) for(long i=j; i<n; i+=s)
#define rep(i,n,s) 	for(		; i<n; i+=s)

#define read(k)		ll k; cin>>k;
#define range(v)	begin(v), end(v)
#define X first
#define Y second

vll g[100005], d(100005);

void bfs(ll node, ll dist=0)
{
	queue<ll> q;
	q.push(node);
	d[node]= dist;

	while(!q.empty())
	{
		ll cur = q.front();	q.pop();

		for(auto ver:g[cur])
			if(d[ver]==0)
			{
				d[ver] = cur;//d[cur]+1;
				q.push(ver);
			}
	}
}

void solve() 
{
    //Answer here.
    read(n);	read(m);
    while(m--)
    {
    	read(a);	read(b);
    	g[a].pb(b);
    	g[b].pb(a);
    }

    bfs(1);

    forn(2,n+1,1)
    	if(!d[i])
    	{	cout<<"No\n";	return ;}

    cout<<"Yes\n";
    forn(2,n+1,1)
    	cout<<d[i]<<endl;
    

}

int main(){

	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);	cin.tie(NULL);	cout.tie(0);
    int t=1;  //cin>>t;
    while(t--)  solve();

    return 0;
}


Measured memory_bytes: 12876
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (a + b) % 24 << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int h,w;
char cc[101][101];
bool ci[101][101]={};
int cr[101][101]={};
cin >> h >> w;
memset(cr,-1,sizeof(cr));
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cin >> cc[i][j];
if(cc[i][j] == 'c') ci[i][j] = 1;
else ci[i][j] = 0;
}}
for(int k=0;k<=w;k++){
for(int i=1;i<=w;i++){
for(int j=1;j<=h;j++){
if(i-k>=0){
if(ci[j][i-k] && cr[j][i]==-1){ cr[j][i] = k;
}}}}}
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cout << cr[i][j] << (j==w?(char)10:' ');
}
}
return 0;
}

Measured memory_bytes: 1228
#include<iostream>

using namespace std;

typedef long long ll;
const int N = 110;

int a[N];

int main()
{
    ll n;
    cin >> n;
    
	int cnt = 0;
    while(n)
	{
		n--;
		a[cnt++] = n % 26;
        n /= 26;
    }
    
    for(int i = cnt - 1; i >= 0; i--)	cout << char(a[i] + 'a');
    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;


inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
ll s,ans,mo=1e9+7;
inline ll power(int a, int n) {
	ll res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo;
		n>>=1;
	}
	return res;
}
inline void solve1(int d) {
	if (d>=9) ans+=9*power(10,d-1)-s/d+1; //surely >0
	else ans+=max(0,9*power(10,d-1)-s/d+1);
	ans%=mo;
}
inline void solve2(int a) {
	if (a<=8&&a*9*power(10,a-1)+(a+1)*9*power(10,a)<s) return;
	ll ymin=s%a,ymax=(s/(a+1))/a*a+ymin; if (ymin==0) ymin+=a;
	if (ymax>s/(a+1)) ymax-=a; if ((s-(a+1)*ymax)==0) ymax-=a;
	if (a<=9) {
		ll tmp=9*power(10,a-1),t1=9*power(10,a);
		while ((s-(a+1)*ymin)/a>tmp) ymin+=a;
		while (ymax>t1) ymax-=a;
	}
//	printf("<%d %lld %lld>\n",a,ymin,ymax);
	if (ymax-ymin>=0) ans+=(ymax-ymin)/a+1;
}
inline void exgcd(ll a, ll b, ll &x, ll &y) {
	if (!b) {x=1; y=0;return;}
	exgcd(b,a%b,y,x); y-=a/b*x;
}
inline ll GCD(ll x, ll y) {return !y ? x : GCD(y,x%y);}
inline void solve3(int l, int r) {
	ll sum=s; rep(i,l+1,r-1) sum-=i*9*power(10,i-1);
	if (sum<0||sum>l*9*power(10,l-1)+r*9*power(10,r-1)) return;
	//lx+ry=sum,x<=s1,y<=s2
	ll x,y,gcd=GCD(l,r); exgcd(l,r,x,y); if (sum%gcd!=0) return;
	ll a=r/gcd,b=l/gcd; x=x*(sum/gcd); //x+=a*k, y-=b*k
	x%=a; if (x<=0) x+=a; y=(sum-l*x)/r;
	ll x1=x,y1=y; y1%=b; if (y1<=0) y1+=b; 
	x1=(sum-y1*r)/l;
 	if (y<=0||x1<=0) return;
 	int s1=9*power(10,l-1),s2=9*power(10,r-1);
	while (y>s2) {x+=a; y-=b;}
 	while (x1>s1) {x1-=a; y1+=b;}
 	ans+=(x1-x)/a+1;
}
ll ss[4];
inline int getg(int x) {
	int cnt=0;
	while (x) x/=10,cnt++;
	return cnt;
}
int main() { //freopen("1.in","r",stdin);
	read(s);
	/*rep(i,1,999999) rep(j,i,i+4) {
		int mn=getg(i),mx=getg(j),sum=0;
		rep(k,i,j) sum+=getg(k);
		if (sum==s) {
			if (mn==mx) ss[1]++;
			else if (mn+1==mx) ss[2]++;
			else ss[3]++;
		}
	}
	printf("%d %d %d\n",ss[1],ss[2],ss[3]);*/
	int mx=sqrt(s); rep(i,1,mx) if (s%i==0) {solve1(i); if (i!=s/i) solve1(s/i);}
//	printf("%lld\n",ans);
	rep(l,1,(s-1)/2) solve2(l);
//	printf("%lld\n",ans);
	rep(l,1,7) rep(r,l+2,8) solve3(l,r);
	printf("%lld",ans%mo);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		int count = 0;
		for(int i=0;i<3;i++){
			if(a.charAt(i)==b.charAt(i)){
				count++;
			}
		}	
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main (void){
  int a[100], b[100];
  char op[100];
  int i = 0, j;

  while(1){
    scanf("%d %c %d", &a[i], &op[i], &b[i]);
    if(op[i] == '?'){
      break;
    }
    i++;
  }

  for(j = 0; j < i; j++){
    if(op[j] == '+'){
      printf("%d\n", a[j] + b[j]);
    } else if(op[j] == '-'){
      printf("%d\n", a[j] - b[j]);
    } else if(op[j] == '*'){
      printf("%d\n", a[j] * b[j]);
    } else {
      printf("%d\n", a[j] / b[j]);
    }
  }

  return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define ctoi(x) ((x)-'0')
bool num[3][10];

void init(int a){
  rep(i,10){
    num[a][i]=0;
  }
}

int main() {
  int ans=0;
  int n;
  string s;
  cin>>n>>s;

  rep(i,3){
    init(i);
  }

  rep(i,n){
    if(num[0][ctoi(s[i])]){
      continue;
    }
    num[0][ctoi(s[i])]=1;
    rng(j,i+1,n){
      if(num[1][ctoi(s[j])]){
        continue;
      }
      num[1][ctoi(s[j])]=1;
      rng(k,j+1,n){
        if(num[2][ctoi(s[k])]){
          continue;
        }
        num[2][ctoi(s[k])]=1;
        ans++;
      }
      init(2);
    }
    init(1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a, b, c, d;
string s;

signed main() {
	cin >> n >> a >> b >> c >> d >> s;
	if (c < d) {
		for (int i = a; i < d; i++) {
			if (s[i] == '#'&&s[i - 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	for (int i = a; i < c; i++) {
		if (s[i] == '#'&&s[i - 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = b; i < d + 1; i++) {
		if (s[i] == '.'&&s[i] == s[i - 1] && s[i] == s[i - 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 640
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (N,M) = rd.readIntArray()
    val S = rd.readString()

    var len = 0
    var i = 0
    while (i < N) {
        var j = i+1
        var ln = 0
        while (S[j+ln] == '1') {
            ln++
        }
        i = j+ln
        len = max(len, ln)
    }
    if (len >= M) {
        println(-1)
        return
    }

    var goal = false
    var ans = ArrayList<Int>()

    fun dfs(n: Int) {
        if (n <= M) {
            if (n>0) ans.add(n)
            goal = true
            return
        }
        for (i in M downTo 1) {
            if (goal) break
            if (S[n-i] == '1') continue
            ans.add(i)
            dfs(n-i)
        }
    }

    dfs(N)

    if (goal) println(ans.reversed().joinToString(" "))
    else println(-1)

    return
}


//val rd = debug.Reader("abc", "146", "f", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long, val col: Int)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>
#define fi first
#define se second

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())

#define PF(a) push_front(a)
#define PB(a) push_back(a)
#define EMPF(...) emplace_front(__VA_ARGS__)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, -1, sizeof(a))

#define PW(n) (1LL << (n))
#define NUM(x) char(x + '0')
#define ALP(x) char(x + 'a')

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> void SORT(vector<T> &a) { sort(a.begin(), a.end()); }
template <class T> void SORTR(vector<T> &a) { sort(a.rbegin(), a.rend()); }
template <class T> void UNIQUE(vector<T> &a) { a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int gcd(int a,int b) { return b?gcd(b,a%b):a; }

int N;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  int g = 0;
  REP(i, N) {
    int A; cin >> A;
    g = gcd(g, A);
  }
  cout << g << endl;

  return 0;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()

cumu = [0]*(N+1)

for i in range(N):
    cumu[i+1] = cumu[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int,input().split())
    print(cumu[r-1]-cumu[l-1])

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

#define int long long

using namespace std;

const int MAXN = 8;

char A[MAXN][MAXN];

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

    int N, M, K;
    cin >> N >> M >> K;

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

    int res = 0;

    for(int mask = 0 ; mask < (1<<N) ; mask++)
    {
    	for(int mask2 = 0 ; mask2 < (1<<M) ; mask2++)
    	{
    		char temp[N][M];

    		for(int i = 0 ; i < N ; i++)
    		{
    			for(int j = 0 ; j < M ; j++)
    			{
    				temp[i][j] = A[i][j];
    			}
    		}

    		for(int i = 0 ; i < N ; i++)
    		{
    			if(mask&(1<<i))
    			{
    				for(int x = 0 ; x < M ; x++)
    				{
    					temp[i][x] = '.';
    				}
    			}
    		}

    		for(int i = 0 ; i < M ; i++)
    		{
    			if(mask2&(1<<i))
    			{
    				for(int x = 0 ; x < N ; x++)
    				{
    					temp[x][i] = '.';
    				}
    			}
    		}

    		int cont = 0;

    		for(int i = 0 ; i < N ; i++)
    		{
    			for(int j = 0 ; j < M ; j++)
    			{
    				if(temp[i][j] == '#')cont++;
    			}
    		}

    		if(cont == K)res++;
    	}
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3656
n = int(input())
arr = list(map(int,input().split()))

ct = [0 for i in range(10**5+1)]

ans = 0
for a  in arr:
    ct[a] += 1
    ans += a

q = int(input())

for i in range(q):
    b,c = map(int,input().split())
    bnum = ct[b]
    diff = c*bnum-b*bnum
    ans += diff
    print(ans)
    ct[b] = 0
    ct[c] += bnum


Measured memory_bytes: 88004
#include <cstdio>
#define NMAX 45

int main() {
    int n;
    scanf("%d", &n);

    if (n == 0 || n == 1) {
        printf("1\n");
    } else {
        int fib[NMAX];
        fib[0] = fib[1] = 1;
        for (int i = 2; i < NMAX; i++) {
            fib[i] = fib[i-1] + fib[i-2];
            if (i == n) {
                printf("%d\n", fib[i]);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2756
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let a = line[0]
    let b = line[1]
    let k = line[3]
    
    if k <= a {
        print(k)
    } else if k <= a + b {
        print(a)
    } else {
        print(a + a + b - k)
    }
}

main()


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

int main()
{
    int n;
    cin >> n;
    string x;
    set< string > s;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        s.insert(x);
    }
    int len = 0;
    for(auto it = s.begin(); it != s.end(); it++)
    {
        len++;
    }
    cout << len;




    return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, m;

vvi v;

map <pair <int, int>, int> mp;

void read() {
  cin >> n >> m;
  vi tmp;
  v.pb(tmp);
  for(int i = 0; i < n; ++i) {
    v.pb(tmp);
  }
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    mp[{x, y}] = i;
    v[x].pb(y);
  }
}

string toChar(int x) {
  string sol;
  int nr = 1;

  while (nr <= x)
    nr *= 10;

  int tmp = 1000000 / nr;
  while(tmp > 1) {
    tmp /= 10;
    sol += '0';
  }

  while(nr > 1) {
    sol += ('0' + (x % nr) / (nr / 10));
    nr /= 10;
  }

  return sol;
}

void solve() {
  vector <string> sol(m + 1);
  for(int i = 1; i <= n; ++i) {
    sort(v[i].begin(), v[i].end());
    for(int j = 0; j < v[i].size(); ++j) {
      string tmp = "";
      tmp += toChar(i);
      tmp += toChar(j + 1);
      sol[mp[{i, v[i][j]}]] = tmp;
    }
  }
  for(int i = 0; i < m; ++i) {
    cout << sol[i] << "\n";
  }
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 18672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775808;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second>b.second;
}

int main(){
    int a,b,ans;
    cin >> a >> b;
    if(b%a == 0) ans = a+b;
    else    ans = b-a;

    cout << ans << endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    cii(c);
    auto ans = (a + b + c > 21)
            ?"bust"
            :"win";
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n, x, t;
    cin >> n >> x >> t;
    // int mul = (n + x - 1) / x;
    int groups = n/x;
    if(n%x != 0)
    	groups++;
    cout << groups * t;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	char S[16];
	int i;
	int asumikana = 0;
	if (scanf("%15s", S) != 1) return 1;
	for (i = 0; S[i] != '\0'; i++) {
		if (S[i] == '1') asumikana++;
	}
	printf("%d\n", asumikana);
	return 0;
}


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

int main() {
	int N;
	string str;
	cin >> N >> str;
	bool flag = false;
	vector<int> line(N+1, 0);
	for (int i = 1; i <= N; ++i) {
		line[i] = line[i - 1] + (str[i-1] == '#' ? 1 : 0);
	}
	int ans = N;
	for (int i = 0; i <= N; ++i) {
		ans = min(ans, line[i] + N - i - (line[N] - line[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String S;

    private void solve() {
        S = next();

        char[] akihabara = "AKIHABARA".toCharArray();
        boolean[] use = new boolean[akihabara.length];

        for(int i = 0;i < 1 << 4;i++) {
            Arrays.fill(use,true);
            for(int j = 0;j < 4;j++) {
                if((i >> j & 1) == 0) {
                    if (j == 0) {
                        use[0] = false;
                    } else if (j == 1) {
                        use[4] = false;
                    } else if (j == 2) {
                        use[6] = false;
                    } else {
                        use[8] = false;
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for(int j = 0;j < akihabara.length;j++) {
                if (use[j]) {
                    sb.append(akihabara[j]);
                }
            }

            if (sb.toString().equals(S)) {
                out.println("YES");
                return;
            }
        }

        out.println("NO");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
n = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(n):
    now = A[i]
    if now == i + 1:
        cnt += 1
        if i + 1 < n:
            nex = A[i + 1]
            if nex == i + 2:
                A[i + 1] = now
                continue
print(cnt)


Measured memory_bytes: 14008
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N, M;

    std::cin >> N >> M;

    vector<vector<char>> grid(N, vector<char>(M));

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

    vector<vector<int>> dp(N, vector<int>(M, 0));
    if (grid[0][0] != '.') {
        dp[0][0] = 1;
    }

    for (int i = 1; i < N; ++i)
        dp[i][0] = grid[i][0] == '.' ? dp[i-1][0] : grid[i-1][0] == '#' ? dp[i-1][0] : dp[i-1][0] + 1;

    for (int j = 1; j < M; ++j)
        dp[0][j] = grid[0][j] == '.' ? dp[0][j-1] : grid[0][j-1] == '#' ? dp[0][j-1] : dp[0][j-1] + 1;

    for (int i = 1; i < N; ++i) {
        for (int j = 1; j < M; ++j) {
            dp[i][j] = std::min(dp[i-1][j] + (grid[i][j] == '#' && grid[i-1][j] != '#'),
                                dp[i][j-1] + (grid[i][j] == '#' && grid[i][j-1] != '#'));
        }
    }

    return dp[N-1][M-1];
}

int main()
{
    std::cout << solve() << std::endl;
    //solve();

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,count,N;
  char str[50];
  scanf("%d",&N);
  scanf("%s",str);
  for(i=0;i<N;i++){
    if(str[i]=='A'){
      if(str[i+1]=='B'){
        if(str[i+2]=='C'){
          count=count+1;
        }
      }
    }
  }
  printf("%d",count);
}
  


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

"""


Measured memory_bytes: 9392
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d ",&a);
  	scanf("%d",&b);
  	printf("\n");
  	int c=b;
  	int i=0;
  while(c>0){
	c=c/10;
    i++;
  }
  int j;
  for(j=0;j<i;j++){
    a=a*10;
  }
  int ans=0;
  ans=a+b;
  int k;
  for(k=1;k<1000;k++){
    if(k*k==ans){
      printf("Yes");
      break;
    }
       }
       if(k==1000){
         printf("No");
       }
       return 0;
       }


Measured memory_bytes: 128
<?php
/*
    Problem URL : http://abc044.contest.atcoder.jp/tasks/arc063_a
    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $S);

$Slen = strlen($S);
$ans = 0;

for ($i = 0; $i < $Slen-1; $i++) {
    if ($S[$i] != $S[$i+1]) $ans++;
}

echo $ans . PHP_EOL;


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

signed main() {
    int N;
    while (cin >> N){
        int M;
        cin >> M;
        vector<pair<int, int>> costs(N); // cost, num
        rep(i, N) {
            int a, b;
            cin >> a >> b;
            costs[i] = make_pair(a, b);
        }
        sort(all(costs));
        int rem = M;
        int ans = 0;
        rep(i, N) {
            int a, b;
            tie(a, b) = costs[i];
            int buy = min(rem, b);
            rem -= buy;
            ans += a * buy;
            if (rem == 0) break;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
		int n = sc.nextInt();
		String[] strs = new String[n];
		for(int i = 0; i < n; i++){
			String nowstr = sc.nextStr();
			char[] ch = nowstr.toCharArray();
			Arrays.sort(ch);
			strs[i] = new String(ch);
		}
		Arrays.sort(strs);
		long answer = 0;
		for(int i = 0; i < n; i++){
			long samecount = 0;
			for(int j = i + 1; j < n; j++){
				if(strs[i].equals(strs[j])){
					samecount++;
					if(j == n - 1){
						answer += (samecount * (samecount + 1)) / 2;
						i = j;
					}
				}else{
					answer += (samecount * (samecount + 1)) / 2;
					i = j - 1;
					break;
				}
			}
		}
		
		System.out.println(answer);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

int main() {
  
  string s,t,u;
  int a,b;
  
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if (u == s){
    cout << a - 1 << " " << b << endl;
  }else{
    cout << a << " " << b - 1 << endl;
  }
  
}


Measured memory_bytes: 256
n = int(input())
a =list(map(int, input().split()))
max_value = max(a)
max_index = a.index(max_value)
ans = 0
tmp_max = a[0]
for i in range(n):
    if tmp_max < a[i]:
        tmp_max = a[i]
    else:
        ans += tmp_max - a[i]
print(ans)

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
main()
{
	
	long long int n, i;
	cin >> n;
	long long int a[n];
	for(i=0;i<n;i++)
	cin >> a[i];
	sort(a, a+n);
	long long int sum = 0, j = 0,br = 1;
	vector<long long int>v;
	v.push_back(a[n-1]);
	for(i=n-2;i>=0;i--)
	{
		v.push_back(a[i]);
		br++;
		sum+=v[j];
		if(br == 2)
		{
		j++;
	    br = 0;
		}
	}
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 6892
//IOI 2021

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

const int MAXN = 2 * 1000 + 17;

int n;
string s, x, ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	cin >> s >> x;
	for (int i = 0; i < n; i++) {
		bool flag = true;
		for (int j = 0; j < n - i; j++)
			if (s[i + j] != x[j])
				flag = false;
		if (flag) {
			cout << n + i;
			return 0;
		}
	}
	cout << 2 * n << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
 
 
int main() {
	int n;
	cin >> n;
	//vector<ll> v(n);
	vector<ll> val(1e5 + 1);
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		val[x]++;
		sum += x;
	}
	int q;
	cin >> q;
	while (q--) {
		ll a, b;
		cin >> a >> b;
		sum += (b - a) * val[a];
		ll z = val[a];
		val[a] = 0;
		val[b] += z;
		cout << sum << endl;
	}
	
}


Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 998244353;

int main(){
    string S;
    while(cin >> S){
        const int N = S.size();
        vector<vector<int>> dp(2*N+1, vector<int>(2*N+1, 0));
        dp[0][0] = 1;
        vector<int> red(N+1, 0);
        vector<int> blue(N+1, 0);
        for(int i=0;i<N;i++){
            red[i+1] = red[i] + (2-(S[i]-'0'));
            blue[i+1] = blue[i] + (S[i]-'0');
        }
        int res = 0;
        for(int r=0;r<=2*N;r++){
            for(int b=0;b<=2*N;b++){
                int turn = r+b;
                if(turn == 2*N) res = (res + dp[r][b]) % MOD;
                if(turn >= 2*N) continue;
                if(turn >= N){
                    if(r+1 <= red[N] && b <= blue[N]) dp[r+1][b] = (dp[r+1][b] + dp[r][b]) % MOD;
                    if(r <= red[N] && b+1 <= blue[N]) dp[r][b+1] = (dp[r][b+1] + dp[r][b]) % MOD;
                } else {
                    if(r+1 <= red[turn] + (S[turn] != '2' ? 1 : 0) && b <= blue[turn]) dp[r+1][b] = (dp[r+1][b] + dp[r][b]) % MOD;
                    if(r <= red[turn] && b+1 <= blue[turn] + (S[turn] != '0' ? 1 : 0)) dp[r][b+1] = (dp[r][b+1] + dp[r][b]) % MOD;
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 62976
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a string
	fmt.Scan(&a)
	min := 753
	for i := 0; i < len(a)-2; i++ {
		b, _ := strconv.Atoi(a[i : i+3])
		var diff int
		if b > 753 {
			diff = b - 753
		} else {
			diff = 753 - b
		}
		if diff < min {
			min = diff
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  int h,w; 
  cin>>h>>w;
  
  char arr[h][w];
  
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
       cin>>arr[i][j];
  
   char arr1[2*h][w];
   
    for(int i=0;i<2*h;++i)
    for(int j=0;j<w;++j)
        arr1[i][j] = arr[(i)/2][j];

   for(int i=0;i<2*h;++i){
    for(int j=0;j<w;++j){
        cout<<arr1[i][j];
    }
    cout<<"\n";
   }
	return 0;
}

Measured memory_bytes: 256
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
d = []
for i in range(n):
    d.append(I())
s = set(d)
print(len(s))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) (n) % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std;
 
int main() { 
    IOS;
    ll n, m;
    cin >> n >> m;
    vector<string> grid(n);
    vector<vll> dp(n, vll(m, 0));
    for (int i = 0; i < n; i++) {
    	cin >> grid[i];
    }
    for (int i = n - 2; i >= 0; i--) {
    	if (grid[i][m - 1] == '#') break;
    	dp[i][m - 1] = 1;
    }
    for (int i = m - 2; i >= 0; i--) {
    	if (grid[n - 1][i] == '#') break;
    	dp[n - 1][i] = 1;
    }
    for (int i = n - 2; i >= 0; i--) {
    	for (int j = m - 2; j >= 0; j--) {
    		if (grid[i][j] == '.') {
    			dp[i][j] = mod(mod(dp[i + 1][j]) + mod(dp[i][j + 1]));
    		}
    	}
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 12444
n, d = map(int, input().split())
num_list = []
cnt = 0

#2次元リスト作成
for i in range(n):
    num_list.append(list(map(int, input().split())))

#j<kのもとでループ
for j in range(n):
    for k in range(j + 1, n):
        c = 0
        for l in range(d):
            c += (num_list[j][l] - num_list[k][l]) ** 2
    
        if (int(c**0.5))**2 == c :
            cnt += 1
        
print(cnt)

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

int main(){
    int N;
    cin >> N;
    int* d = new int[N];
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d, d+N);
    cout << (d[N/2] - d[N/2-1]);

    return 0;
}

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

#define MAX 3010
#define MOD 998244353

int N,S;

long long dp[MAX][MAX];
int l[MAX];

long long solve(int n, int soma){
	if (soma==S) return N-n+1;
	if (n==N) return 0;
	if (dp[n][soma]!=-1) return dp[n][soma];
	
	
	dp[n][soma]=0;
	
	if (soma+l[n]<=S) dp[n][soma]+=solve(n+1,soma+l[n]);
	
	dp[n][soma]+=solve(n+1,soma);
	
	return dp[n][soma]%MOD;

}




int main(){
	memset(dp,-1,sizeof(dp));

	cin>>N>>S;
	
	for (int i=0; i<N; i++) cin>>l[i];
	
	long long soma=0;
	
	for (int i=0; i<N; i++){
		soma=(soma%MOD+solve(i,0)%MOD)%MOD;
	
	}
	
	
	cout<<soma<<endl;


}


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

int main() {
	// your code goes here
	char m[2][3];
	int i,j,flag=1;
	for(i=0;i<2;i++)
	for(j=0;j<3;j++)
	{
	    cin>>m[i][j];
	}
	for(i=0;i<2;i++)
	for(j=0;j<3;j++)
	{
	    if(m[i][j]!=m[1-i][2-j])
	    flag=0;
	}
	if(flag==1)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
from collections import *
n=int(input())
l=[]
for i in range(n):
    l.append(input())
c=Counter(l)
m=max(c.values())
d=[]
for i in c:
    if(c[i]==m):
        d.append(i)
d.sort()
for i in d:
    print(i)


Measured memory_bytes: 154404
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	long sum = (long) 0;

      	for(int i=1; i<N+1;  i++){
			if((i%3==0)||(i%5==0)){
              	continue;
            }else{
            	sum += i;
            }
        }
      
      	System.out.println(sum);
        return;
	}
}


Measured memory_bytes: 35784
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main()
{

	ll i, j, k, l, m, flag, N, M,K,H,W,X,P;
	cin >> N ;
	vector<ll>a(N);
	REP(i, 0, N) {
		cin >> a[i];
	}
	REP(i, 0, N) {
		if (a[i] % 2 == 1) {
			output("first");
			return 0;
		}
	}
	output("second");
	

	return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
	int H, W;
	char ms[128][128];
	int dp[128][128];
	memset(ms, 0, sizeof(ms));
	memset(dp, 0, sizeof(dp));

	cin >> H >> W;

	for (int i = 0; i < H; i++) {
		scanf("%s", ms[i])+1;
	}

	if (ms[0][0] == '#') dp[0][0] = 1;
	for (int i = 1; i < W; i++) {
		if (ms[0][i] == ms[0][i-1]) dp[0][i] = dp[0][i-1];
		else dp[0][i] = dp[0][i-1] + 1;
	}

	for (int y = 1; y < H; y++) {
		if (ms[y][0] == ms[y-1][0]) dp[y][0] = dp[y-1][0];
		else dp[y][0] = dp[y-1][0] + 1;
		for (int x = 1; x < W; x++) {
			int tmpX, tmpY;
			if (ms[y][x] == ms[y][x-1]) tmpX = dp[y][x-1];
			else tmpX = dp[y][x-1] + 1;
			if (ms[y][x] == ms[y-1][x]) tmpY = dp[y-1][x];
			else tmpY = dp[y-1][x] + 1;
			if (tmpX < tmpY) dp[y][x] = tmpX;
			else dp[y][x] = tmpY;
		}
	}

	int ans = dp[H-1][W-1];
	if (ms[H-1][W-1] == '#') ++ans;

	cout << ((ans+1)/2) << endl;

	return 0;
}


Measured memory_bytes: 384