akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll X;
    cin >> X;

    ll ans = 0;
    ans = X/500*1000;
    X %= 500;
    ans += X/5*5;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#define forn(i,n) rep(i,1,n)
#define rep0(i,n) rep(i,0,n-1)
using namespace std;
typedef pair<int,int>pii;
int n,a,b;
int get(int x,int y){
	return abs(x-y)/2LL;
}
signed main(){
	cin>>n>>a>>b;
	if((a+b)%2LL==0LL){
		cout<<get(a,b)<<endl;
	}else{
		int dx=0,dy=0;
		int px=1,py=abs(b-a)+1;
		dx=min(a,b)+get(px,py);
		int qx=n,qy=n-abs(b-a);
		dy=min(n-a+1,n-b+1)+get(qx,qy);
		cout<<min(dx,dy);
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.IntSet as IS

solve :: Int -> [Int] -> Int
solve n xs = minimum [sumA, sumB, sumM]
  where
    ys = addlab 0 xs
    (as, bs) = partition ((== 'a') . getT) ys
    sumA = sum $ map getX as
    sumB = sum $ map getX bs
    (smalls, bigs) = splitAt n $ sort $ ys
    isDup = n > (IS.size $ IS.fromList $ map getI smalls)
    sumSmalls = sum $ map getX smalls
    (xP1,iP1,_):(xP2,_,_):_ = bigs
    (xQ1,iQ1,_):(xQ2,_,_):_ = reverse smalls
    sumM = sumSmalls + diff
    diff | isDup      = 0
         | iP1 /= iQ1 = xP1 - xQ1
         | otherwise  = min (xP2 - xQ1) (xP1 - xQ2)

addlab _ [] = []
addlab !i (x1:x2:xs) = (x1,i,'a'):(x2,i,'b'):(addlab (i+1) xs)

getX (x,_,_) = x
getI (_,i,_) = i
getT (_,_,t) = t

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

tmain :: B.ByteString -> Int
tmain cont =
  let n : xs = bsReadInts cont
  in solve n xs

main = putStrLn . show . tmain =<< B.getContents


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

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

vector<ll> prime_factor(ll n){
    vector<ll> pf;
    for(ll i = 2; i*i <= n; i++){
        if(n%i == 0){
            pf.push_back(i);
            while(n%i == 0){
                n /= i;
            }
        }
    }
    if(n != 1) pf.push_back(n);
    return pf;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll g = a[0];
    rep(i, 1, n) g = gcd(g, a[i]);
    if(g != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    map<ll, bool> mp;
    rep(i, 0, n){
        vector<ll> p;
        p = prime_factor(a[i]);
        for(auto v : p){
            if(mp[v]){
                cout << "setwise coprime" << endl;
                return 0;
            }
            mp[v] = true;
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}


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

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		int n = h[0], t = h[1];
		var ds = new int[n].Select(_ => read()).OrderBy(x => x[0]).ToArray();

		var M = 0;
		var dp = Enumerable.Repeat(-1, t).ToArray();
		dp[0] = 0;

		foreach (var d in ds)
			for (int i = t - 1; i >= 0; i--)
			{
				if (dp[i] == -1) continue;
				var i2 = i + d[0];
				var v = dp[i] + d[1];
				if (i2 < t) dp[i2] = Math.Max(dp[i2], v);
				M = Math.Max(M, v);
			}
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 13664
#include<bits/stdc++.h>
#define maxn 400005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

int n,fa[maxn];
int info[maxn],Prev[maxn<<1],to[maxn<<1],cnt_e=1;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int ar[maxn],onc[maxn],a[maxn];
int vis[maxn],sta[maxn],tp;
void dfs0(int u,int ff){
	vis[u] = 1;
	sta[++tp] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(i^ff){
		v=to[i];
		if(!vis[v]) dfs0(v,(i^1));
		else if(!onc[v]){
			for(int t=-1;t!=v;){
				t = sta[tp--];
				ar[++ar[0]] = t;
				onc[t] = 1;
			}
			per(i,ar[0],1) sta[++tp] = ar[i];
		}
	}
	if(sta[tp] == u) tp--;
}

void dfs1(int u,int ff){
	static int vis[maxn],tim;
	for(int i=info[u],v;i;i=Prev[i]) if((v=to[i]) ^ ff && !onc[v])
		dfs1(v,u);
	++tim;
	for(int i=info[u],v;i;i=Prev[i]) if((v=to[i]) ^ ff && !onc[v])
		vis[a[v]] = tim;
	a[u] = 0;
	for(;vis[a[u]] == tim; a[u]++);
}

int main(){
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&fa[i]);
		Node(fa[i],i),Node(i,fa[i]);
	}
	dfs0(1,0);
	rep(i,1,ar[0]) dfs1(ar[i],0);
	set<int>st;
	rep(i,1,ar[0]) st.insert(a[ar[i]]);
	if((ar[0] & 1) && st.size() == 1)
		puts("IMPOSSIBLE");
	else 
		puts("POSSIBLE");
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

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

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int need = 1;

    int ans = 0;
    set<int> get;
    for(int i = 0; i < n; i++){
        if(a[i] == need){
            get.insert(a[i]);
            need++;
        } else {
            ans++;
        }
    }

    if(!get.size() or (int) get.size() != need - 1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10368
# coding:utf-8

import sys
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, p = LI()

prime_cnt = defaultdict(int)
i = 2
while i * i <= p:
    if p % i == 0:
        cnt = 0
        while p % i == 0:
            cnt += 1
            p //= i
        prime_cnt[i] += cnt
    i += 1

if p != 1:
    prime_cnt[p] += 1

ans = 1
for num, cnt in prime_cnt.items():
    while cnt >= n:
        ans *= num
        cnt -= n

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

int x,y,n,m;

/* add your algorithm here */

int main() {
  cin >> n >> m >> x >> y;
  vector<ll> xx(n,0);
  vector<ll> yy(m,0);
  rep(i,n) cin >> xx[i];
  rep(i,m) cin >> yy[i];
  sort(xx.begin(), xx.end());
  sort(yy.begin(), yy.end());

  for (int i = x+1; i <= y; ++i) {
    if (i > xx.back() and i <= yy.front()) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> ok(n+5, true);
    while(m-- > 0){
        int x;
        cin >> x;
        ok[x] = false;
    }
    vector<ll> dp(n+5, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        if(ok[i+1]) dp[i+1] = (dp[i+1]+dp[i])%mod;
        if(ok[i+2]) dp[i+2] = (dp[i+2]+dp[i])%mod;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import deque

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

graph=[[]for _ in range(N+1)]

for _ in range(M):
    A,B=map(int,input().split()) # 入力に合わせて適宜変更
    graph[A].append(B)
    graph[B].append(A)

dist=[-1]*(N+1) # 出力に合わせて適宜変更
dist[0]=0
dist[1]=0

D=deque()
D.append(1)

while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=dist[V]+1 # 出力に合わせて適宜変更（答えに直結するので最重要）
        D.append(i)

print(['IMPOSSIBLE','POSSIBLE'][dist[N]==2])

Measured memory_bytes: 43868
N,K = map(int, open(0).read().split())
ans = 0
if K == 0:
    print(pow(N,2))
else:
    for b in range(K+1,N+1):
        d, m = divmod(N,b)
        ans += d * (b-K) + max(0,(m-K+1))
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;


long long int numNum(long long int A,long long int B, long long int C){
    if(A%C!=0)
        A = A + (C - A%C);
    B = B - B%C;
    return (B - A)/C + 1;
}


int main(){
    long long int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(C < D){
        long long int tmp = C;
        C = D;
        D = tmp;
    }
    long long int r = C%D;
    long long int c=C,d=D;
    while(r!=0){
        c = d;
        d = r;
        r = c%d;
    }
    long long int lubCD = C*D/d;
    long long int aaa = numNum(A,B,C) + numNum(A,B,D) - numNum(A,B,lubCD);
    cout << B - A + 1 - aaa  << endl;
}

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

using namespace std;

int N;
int A[100001];

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d", A+i);
    vector<int> B, C;
    for(int i=0; i<N; i++)
    {
        if(i%2==0)
            B.push_back(A[i]);
        else
            C.push_back(A[i]);
    }
    sort(B.begin(), B.end());
    //sort(C.begin(), C.end());
    sort(A, A+N);
    int cnt=0;
    for(int i=0; i<N; i++)
    {
        if(i%2==0 && !binary_search(B.begin(), B.end(), A[i]))
        {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  int N; cin >> N;
  map<ll,ll> mp;
  ll ans = 0;
  ll A[N];
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A[i] = a;
    ans += mp[a];
    mp[a]++;
   
  }
  for(int i=0;i<N;i++){
    cout << ans-mp[A[i]]+1<< endl;
  }
}

Measured memory_bytes: 13072
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long X = Long.parseLong(scanner.next());
        long K = Long.parseLong(scanner.next());
        long D = Long.parseLong(scanner.next());
        long div = 0;
        long left = 0;
        long right = 0;
        scanner.close();

        X = Math.abs(X);
        div = X / D;

        if (div > K){
            X -= K * D; 
        } else {
            X -= div * D;
            left = D - X;
            right = X;

            if ((K - div) % 2 == 0){
                X = right;
            } else {
                X = left;
            }
        }
        
        System.out.println(Math.abs(X));
    }
}




Measured memory_bytes: 26984
N,T = map(int,input().split())
tau = list(map(int,input().split()))
answer = 0
cont = 0
for i in range(N):
	if tau[i] < cont:
		dif = cont - tau[i]
		answer += T - dif
	else:
		answer += T
	cont =tau[i] + T
print(answer)


Measured memory_bytes: 25196
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n;
   cin >> n;
   int x=0;
   string s;
   cin >> s;
   int ans=0;
   rep(i,n){
      if(s.at(i)=='I')x++;
      else if(s.at(i)=='D')x--;
      ans=max(ans,x);
   }
   cout << ans << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var hs = new HashSet<long>();
		foreach(var n in A) hs.Add(n);
		foreach(var n in B) hs.Add(n);
		var hl = hs.ToList();
		hl.Sort();
		var di = new Dictionary<long, int>();
		foreach(var n in hl) di.Add(n, di.Count);
		
		var la = A.ToList();
		la.Sort();
		var lb = B.ToList();
		lb.Sort();
		
		
		if(N % 2 == 1){
			var ma = la[N / 2];
			var mb = lb[N / 2];
			Console.WriteLine(mb - ma + 1);
		} else {
			var ma = la[N / 2] + la[N / 2 - 1];
			var mb = lb[N / 2] + lb[N / 2 - 1];
			Console.WriteLine(mb - ma + 1);
		}
		
		
		
		
	}
	int N;
	long[] A,B;
	public Sol(){
		N = ri();
		A = new long[N];
		B = new long[N];
		for(int i=0;i<N;i++){
			var d = ria();
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 64944
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#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(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int A,B;
    cin >> A >> B;
    if(A>=13){
        cout << B << endl;
    }else if(A>=6){
        cout << B/2 << endl;
    }else cout << 0 << endl;
    return 0;
}

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

int main() {
  int k, x; cin >> k >> x;
  for (int i = x + 1 - k; i < x + k; i++) {
    if (i > x + 1 - k) cout << " ";
    cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
    #include <unordered_map>
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef unsigned long long int128;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
#define mod1 1000000007
#define mod2 998244353
#define eps 1e-10
#define pi acos(-1)
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1^1)
#define abs(x) ((x)>0?(x):(-(x))) 
const int maxn=2e5+10;
ll A[maxn],sum[maxn];
ll B[maxn],sum2[maxn];
struct cut
{
	ll mx,mn;
}f1[maxn],f2[maxn];
int n;
ll ans;
int main()
{
	scanf("%d",&n);
	ans=linf;
	rep(i,n)scanf("%lld",A+i),B[i]=A[i];
	reverse(B,B+n);
	sum[0]=A[0];
	for1(i,1,n)sum[i]=sum[i-1]+A[i];
	sum2[0]=B[0];
	for1(i,1,n)sum2[i]=sum2[i-1]+B[i];
	int posa=0,posb=0;
	ll suma=A[0],sumb=B[0],summa=0,summb=0;
	bool flag;
	for(int f=1;f<n;f++)
	{
		summa+=A[f];
		if(suma>=summa)
		{
			f1[f].mn=summa;
			f1[f].mx=suma;
		}
		else
		{
			while(posa+1<f&&suma+A[posa+1]<summa-A[posa+1])
			{
				suma+=A[posa+1];
				summa-=A[posa+1];
				posa++;
			}
			if(posa+1==f)
			{
				f1[f].mn=suma;
				f1[f].mx=summa;
			}
			else
			{
				if(summa-suma<suma+A[posa+1]*2-summa)
				{
					f1[f].mn=suma;
					f1[f].mx=summa;
				}
				else
				{
					suma+=A[posa+1];
					summa-=A[posa+1];
					posa++;
					f1[f].mn=summa;
					f1[f].mx=suma;
				}
			}
		}
		summb+=B[f];
		if(sumb>=summb)
		{
			f2[f].mn=summb;
			f2[f].mx=sumb;
		}
		else
		{
			while(posb+1<f&&sumb+B[posb+1]<summb-B[posb+1])
			{
				sumb+=B[posb+1];
				summb-=B[posb+1];
				posb++;
			}
			if(posb+1==f)
			{
				f2[f].mn=sumb;
				f2[f].mx=summb;
			}
			else
			{
				if(summb-sumb<sumb+B[posb+1]*2-summb)
				{
					f2[f].mn=sumb;
					f2[f].mx=summb;
				}
				else
				{
					sumb+=B[posb+1];
					summb-=B[posb+1];
					posb++;
					f2[f].mn=summb;
					f2[f].mx=sumb;
				}
			}
		}
	//	cout<<posa<<" "<<f<<" "<<f1[f].mn<<" "<<f1[f].mx<<endl;
	//	cout<<posb<<" "<<f<<" "<<f2[f].mn<<" "<<f2[f].mx<<endl; 
	//	system("pause");
	}
	for(int f=1;f<n-2;f++)
	ans=min(ans,max(f1[f].mx,f2[n-2-f].mx)-min(f1[f].mn,f2[n-2-f].mn));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


typedef long long int ll;

int n;

string s[300];
static ll rowhash[300][300], colhash[300][300];

int main(void){
	cin >> n;
	for(int i=0;i<n;i++) cin >> s[i];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll x = 0; int jj = j;
			for(int k=0;k<n;k++){
				x += 26LL * x + (s[i][jj] - 'a');
				jj++; if (jj==n) jj=0;
			}
			rowhash[i][j] = x;
			//cerr << rowhash[i][j] << "   ";
		}//cerr << endl;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll x = 0; int ii = i;
			for(int k=0;k<n;k++){
				x += 26LL * x + (s[ii][j] - 'a');
				ii++; if (ii==n) ii=0;
			}
			colhash[i][j] = x;
			//cerr << colhash[i][j] << "    ";
		}//cerr << endl;
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			bool ok = true;
			int ii = i, jj = j;
			for(int k=0;k<n;k++){
				//if (rowhash[ii][jj] != colhash[ii][jj]) {ok = false; break;}
				if (rowhash[ii][j] != colhash[i][jj]) {ok = false; break;}
				ii++; if (ii==n) ii = 0;
				jj++; if (jj==n) jj = 0;
			}
			if (ok) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1920
#include "stdio.h"

int main(void)
{
    int a,b,c;
    int swap;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    swap = a;
    a = b;
    b = swap;
    swap = a;
    a = c;
    c = swap;
    printf("%d %d %d",a,b,c);
}

Measured memory_bytes: 1696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int target = s.nextInt(),n = s.nextInt();
        int arr[] = new int[n];
        int freq[] = new int[102];

        for(int i=0;i<n;i++){
            arr[i] = s.nextInt();
            freq[arr[i]]++;
        }



        int ans = 0,min = Integer.MAX_VALUE;

        for(int i=target;i>=0;i--){
            if(freq[i]==0&&Math.abs(target-i)<=min){
                min = Math.abs(target-i);
                ans = i;
                break;
            }
        }
        for(int i=target+1;i<=101;i++){
            if(freq[i]==0&&Math.abs(target-i)<min){
                ans = i;
                break;
            }
        }
        System.out.println(ans);

    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main(void){
  int N;
  cin >> N;
  int A;
  REP(int,i,0,N){
  	cin >> A;
    if ( A % 2 == 0 ){
    	if ( A % 3 == 0 || A  % 5 == 0 ){
        	continue;
        } 
      	else{
        	cout << "DENIED" << endl;
            return 0;
        }
    }
    else continue;
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

if N == 1:
    print(1)
    quit()

if A[0] < A[1]:
    tend = 1
elif A[0] > A[1]:
    tend = -1
else:
    tend = 0

count = 1
prev = A[1]

for a in A[2:]:
    if prev < a and tend < 0:
        tend = 0
        count += 1
    elif prev > a and tend > 0:
        tend = 0
        count += 1
    elif tend == 0:
        if prev < a:
            tend = 1
        elif prev > a:
            tend = -1
        else:
            tend = 0

    prev = a

print(count)


Measured memory_bytes: 14436
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
    string s;
    int a=0,b=0;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0') a++;
        if(s[i]=='1') b++;
    }
    cout<<2*min(a,b)<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <array>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    ll x, k, d, ans;
    cin >> x >> k >> d;
    ll minmove = abs(x) / d;
    if(x>=0){
        if(minmove>k){
            ans = x - k * d;
        }
        else{
            if((k-minmove)%2==0){
                ans = x - minmove * d;
            }
            else{
                ans = abs(x - minmove * d - d);
            }
        }
    }
    else{
        if(minmove>k){
            ans = abs(x + k * d);
        }
        else{
            if((k-minmove)%2==0){
                ans = abs(x + minmove * d);
            }
            else{
                ans = abs(x + minmove * d + d);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

double bitToJPN(double bit) {
    return bit * 380000.0;
}

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

    double sum = 0.0;
    rep(_, n) {
        double bit;
        cin >> bit;

        string curr;
        cin >> curr;

        if (curr == "BTC") {
            sum += bitToJPN(bit);
        } else {
            sum += bit;
        }
    }
    cout << precise(6) << sum << endl;
}

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

using namespace std;

vector<vector<int>> g;
vector<int> pr;
vector<char> clr;

void dfs1(int v, int p = -1) {
    for (int to : g[v]) {
        if (to != p) {
            pr[to] = v;
            dfs1(to, v);
        }
    }
}

int cnt = 0;
void dfs2(int v, int color, int p = -1) {
    if (clr[v] == 0)
        ++cnt;
    for (int to : g[v]) {
        if (to != p) {
            if (clr[to] != color)
                dfs2(to, color, v);
        } 
    }
}

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

    int n;
    scanf("%d", &n);
    g.resize(n);
    pr.resize(n, -1);
    clr.resize(n);
    for (int i = 1; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs1(0);
    clr[0] = 2;
    clr[n - 1] = 1;
    vector<int> path;
    for (int i = n - 1; i != -1; i = pr[i]) {
        path.push_back(i);
    }
    int x = path.size() / 2;
    for (int i = 0; i < path.size(); ++i) {
        if (i < x)
            clr[path[i]] = 1;
        else
            clr[path[i]] = 2;
    }
    dfs2(0, 1);
    int p1 = cnt;
    cnt = 0;
    dfs2(n - 1, 2);
    int p2 = cnt;
    if (p1 == p2) {
        p1 = p2 = 0;
        if (path.size() % 2 == 1)
            p1 = 1;
        else
            p2 = 1;
    }
    if (p1 > p2)
        printf("Fennec");
    else
        printf("Snuke");
    return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define db double
#define N 1005
using namespace std;
struct P{
    int x,y,r;
}p[N];
int tot=0,px,py,pr,n,vis[N];
struct edge{
    int to,nxt;
    db w;
}e[N*N*2];
int head[N],cnt=0;
inline void add(register int u,register int v,register db w)
{
    ++cnt;
    e[cnt].to=v,e[cnt].nxt=head[u],e[cnt].w=w;
    head[u]=cnt;
}
db dis[N];
struct node{
    int pos;
    db dis;
    bool operator < (const node &x)const{
        return x.dis<dis;
    }
};
priority_queue<node> q;
inline void dij()
{
    for(register int i=1;i<=tot;++i)
        dis[i]=114514191981.0;
    dis[1]=0.0;
    node tmp;
    tmp.pos=1,tmp.dis=0.0;
    q.push(tmp);
    while(!q.empty())
    {
        int u=q.top().pos;
        q.pop();
        if(vis[u])
            continue;
        vis[u]=1;
        for(register int i=head[u];i;i=e[i].nxt)
        {
            int v=e[i].to;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                tmp.pos=v,tmp.dis=dis[v];
                q.push(tmp);
            }
        }
    }
}
int main()
{
    for(register int i=1;i<=2;++i)
    {
        scanf("%d%d",&px,&py);
        p[++tot]=(P){px,py,0};
    }
    scanf("%d",&n);
    for(register int i=1;i<=n;++i)
    {
        scanf("%d%d%d",&px,&py,&pr);
        p[++tot]=(P){px,py,pr};
    }
    for(register int i=1;i<tot;++i)
        for(register int j=i+1;j<=tot;++j)
        {
            db w=sqrt(1.0*(p[i].x-p[j].x)*(p[i].x-p[j].x)+1.0*(p[i].y-p[j].y)*(p[i].y-p[j].y))-1.0*p[i].r-1.0*p[j].r;
            if(w<0)
                w=0.0;
            add(i,j,w),add(j,i,w);
        }
    dij();
    printf("%.10lf\n",dis[2]);
    return 0;
}


Measured memory_bytes: 22768
#include <stdio.h>

int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if(x >= r && w >= x + r && y >= r && h >= y + r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 21 + 5, Maxs = (1 << 21) + 100, Mod = 1e9 + 7;

int N;
int A[Maxn][Maxn], Dp[Maxn][Maxs];
int Vis[Maxn][Maxn];

inline void Add (int &a, int b) { a += b; if (a >= Mod) a -= Mod; }

inline void Solve ()
{
	int ALL = (1 << N) - 1;
	Dp[0][0] = 1;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = 0; j <= ALL; ++j)
		{
			if (!Dp[i - 1][j]) continue;
			for (int k = 1; k <= N; ++k) 
				if (A[i][k] && !(j & (1 << (k - 1)))) 
					Add (Dp[i][j | (1 << (k - 1))], Dp[i - 1][j]);
		}
	}
	cout<<Dp[N][ALL]<<endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) 
		for (int j = 1; j <= N; ++j) 
			A[i][j] = read<int>();
}

int main()
{
#ifdef hk_cnyali
	freopen("O.in", "r", stdin);
	freopen("O.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 164096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for(int i=0;i<N;i++)
    cin >> A.at(i);
  
  int i,s=0;
  
  while(1){
    
    for(int j=0;j<N;j++){
      s+=A.at(j)%2;
    }
    
    if(s==0){
      for(int j=0;j<N;j++)
        A.at(j)/=2;
      i++;
    }
    
    else
      break;
    
  }
  cout << i;
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int M = sc.nextInt();


		int minA = 100000;
		int[] arrayA = new int[A];
		for(int i=0;i<A;i++) {
			arrayA[i] = sc.nextInt();
			minA = Math.min(minA, arrayA[i]);
		}

		int minB = 100000;
		int[] arrayB = new int[B];
		for(int i=0;i<B;i++) {
			arrayB[i] = sc.nextInt();
			minB = Math.min(minB, arrayB[i]);
		}

		int[] arrayX = new int[M];
		int[] arrayY = new int[M];
		int[] arrayC = new int[M];
		for(int i=0;i<M;i++) {
			arrayX[i] = sc.nextInt();
			arrayY[i] = sc.nextInt();
			arrayC[i] = sc.nextInt();
		}

		sc.close();

		int ans = minA + minB;
		for(int i=0;i<M;i++) {
			int a = arrayA[arrayX[i]-1]+arrayB[arrayY[i]-1]-arrayC[i];
			ans = Math.min(ans,a);

		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 136876
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[3010][3010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int n1 = S.length();
    int n2 = T.length();
    rep(i, n1) {
        rep(j, n2) {
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            if(S[i] == T[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
        }
    }

    string K;
    int i = n1, j = n2;
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i][j - 1]) {
            j--;
        } else if(dp[i][j] == dp[i - 1][j]) {
            i--;
        } else if(dp[i][j] == dp[i - 1][j - 1] + 1) {
            K = T[j - 1] + K;
            i--; j--;
        } else {
            return 0;
        }
    }
    cout << K << endl;

    return 0;
}


Measured memory_bytes: 38952
/*
 * 16-12-4_AOJ064_E.cpp
 *
 *  Created on: 2016/12/04
 *      Author: ryoma
 */
#include<iostream>
#include<algorithm>
#include<queue>
#include<limits.h>
#include<math.h>
#include<iomanip>
using namespace std;

typedef pair<double,int> Pdi;

const long long INF = (long long)1e9*4+1;

double G[1010][1010];
int xs,ys,xt,yt;
int N;
int x[1010],y[1010],r[1010];
double d[1010];

void dijkstra(){
	fill(d,d+N+2,INF);
	d[0] = 0;
	priority_queue<Pdi> que;
	que.push(make_pair(0,0));
	while(!que.empty()){
		Pdi p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < -p.first)
			continue;
		for(int i=0;i<=N+1;i++){
			if(i==v)
				continue;
			if(d[i] > d[v] + G[v][i])
			{
				d[i] = d[v] + G[v][i];
				que.push(make_pair(-d[i],i));
			}
		}
	}
}

int main(){
	cin >> xs >> ys >> xt>> yt;
	x[0] = xs;
	y[0] = ys;
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> x[i] >> y[i] >> r[i];
	}
	x[N+1] = xt;
	y[N+1] = yt;
	for(int i=0;i<=N+1;i++){
		for(int j=i+1;j<=N+1;j++){
			double dis=sqrt((long long)(x[i]-x[j])*(x[i]-x[j])+(long long)(y[i]-y[j])*(y[i]-y[j]));
			dis -= r[i]+r[j];
			G[j][i] = G[i][j] = max(dis,0.);
		}
	}
	dijkstra();
	cout << fixed<<setprecision(11) << d[N+1] << endl;
	return 0;
}




Measured memory_bytes: 12400
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int N,M,a[100000];
LL x[100000],d[100000],e[100000];
int sw[62][100000];
int ansp[100000];
int ansq[100000];
LL K;

int main(void){
    cin>>N;
    REP(i,N){
        cin>>x[i];
        if(0<i)
            d[i-1]=x[i]-x[i-1];
    }
    cin>>M>>K;
    REP(i,M){
        cin>>a[i];
        a[i]--;
    }

     REP(i,62){
         if(i==0){
             REP(j,N-1)
                 sw[i][j]=j;
             REP(j,M){
                 swap(sw[i][a[j]],sw[i][a[j]-1]);
             }
         }else{
             REP(j,N-1)
                 sw[i][j]=sw[i-1][sw[i-1][j]];
         }
     }
     REP(i,N-1)
         ansp[i]=i;
     REP(i,62)
         if((1LL<<(LL)i)&K){
             REP(j,N-1)
                 ansq[j]=sw[i][ansp[j]];
             REP(j,N-1)
                 ansp[j]=ansq[j];
         }
     REP(j,N-1)
         e[j]=d[ansp[j]];
     LL y=x[0];
     cout<<y<<endl;
     REP(i,N-1){
         y+=e[i];
         cout<<y<<endl;
     }
     return 0;
}


Measured memory_bytes: 28928
n = int(input())
as_ = map(int, input().strip().split())

num_mul2 = 0
num_mul4 = 0

for a in as_:
    if a % 4 == 0:
        num_mul4 += 1
    elif a % 2 == 0:
        num_mul2 += 1

d = n - num_mul4 * 2 - (num_mul2 // 2) * 2
if num_mul4 > 0:
    d -= 1

if d <= 0:
    print('Yes')
else:
    print('No')


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

int main(){
string S;cin>>S;
vector<bool> alphabets(26,false);
for(int i=0;i<S.size();i++){
if(!alphabets[S[i]-'a'])alphabets[S[i]-'a']=true;
}
for(int i=0;i<26;i++)if(!alphabets[i]){printf("%c",'a'+i);return 0;}
cout<<"None";
}

Measured memory_bytes: 3752
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	using P = pair<int, int>;
	for (int h, w, c; cin >> h >> w >> c&&h;) {
		int ans = 1;
		static int p[10][10];
		rep(i, 0, h)rep(j, 0, w) {
			cin >> p[i][j];
		}
		auto inrange = [&](int i, int j) { return i >= 0 && i < h && j >= 0 && j < w; };
		static const int di[] = { 1,0,-1,0 };
		static const int dj[] = { 0,1,0,-1 };
		rep(i, 0, 6 * 6 * 6 * 6 * 6) {
			static bool f[10][10];
			memset(f, 0, sizeof(f));
			set<P> st;
			st.emplace(0, 0);
			f[0][0] = true;
			queue<P> q;
			q.emplace(0, 0);
			while (q.size()) {
				int ci, cj;
				tie(ci, cj) = q.front(); q.pop();
				int color = p[ci][cj];
				rep(k, 0, 4) {
					int ni = ci + di[k], nj = cj + dj[k];
					if (!inrange(ni, nj))continue;
					if (p[ni][nj] != p[ci][cj])continue;
					if (f[ni][nj])continue;
					q.emplace(ni, nj);
					st.emplace(ni, nj);
					f[ni][nj] = true;
				}
			}
			if (i == 0) {
				dump(st);
			}
			int ti = i;
			rep(j, 0, 5) {
				int color = ti % 6 + 1;
				if (j == 4)if (color != c) {
					st.clear();
					break;
				}
				ti /= 6;

				queue<P> q;
				for (auto &e : st)
					q.emplace(e);
				while (q.size()) {
					int ci, cj;
					tie(ci, cj) = q.front(); q.pop();
					rep(k, 0, 4) {
						int ni = ci + di[k], nj = cj + dj[k];
						if (!inrange(ni, nj))continue;
						if (p[ni][nj] != color)continue;
						if (f[ni][nj])continue;
						st.emplace(ni, nj);
						q.emplace(ni, nj);
						f[ni][nj] = true;
					}
				}
			}
			chmax(ans, (int)st.size());
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
import java.io.BufferedReader
import java.util.*

fun main() = nomura2020b()

@OptIn(ExperimentalStdlibApi::class)
fun nomura2020b() = SimpleFastIOWithToken_nomura2020b().exec {
    val t = readString()

    val answer = t.replace('?', 'D')

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_nomura2020b(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readStringList(size: Int): List<String> = List(size) { readString() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readIntList(size: Int): List<Int> = List(size) { readInt() }
    fun readLong(): Long = java.lang.Long.valueOf(readString())
    fun readLongList(size: Int): List<Long> = List(size) { readLong() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }
    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)

    fun exec(action: SimpleFastIOWithToken_nomura2020b.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 41212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    s.erase(unique(ALL(s)), s.end());
    cout << SZ(s) << "\n";
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> v;
    char pre = s[0];
    int cnt = 1;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (s[i] == pre)
            cnt++;
        else
        {
            v.emplace_back(cnt);
            ans += cnt - 1;
            cnt = 1;
            pre = s[i];
        }
    }
    v.emplace_back(cnt);
    ans += cnt - 1;
    cout << min(n - 1, ans + k * 2);
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll A; 
    long double B;
    cin>>A>>B;
    cout<<(ll)floor(A*B)<<endl;
}


Measured memory_bytes: 3732
while line = STDIN.gets
  line.chomp!
  x1, y1, x2, y2, xq, yq = line.split(',').map { |item| item.to_f }
  vx=x2-x1
  vy=y2-y1
  t=(vx*(xq-x1)+vy*(yq-y1))/(vx*vx+vy*vy)
  xp=x1+t*vx
  yp=y1+t*vy
  x=2*xp-xq
  y=2*yp-yq
  puts "#{x} #{y}"
end

Measured memory_bytes: 8636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b +c >= 22){
    cout << "bust"  << endl;
  }else{
        cout << "win"  << endl;
  }
}


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

using namespace std;

void Main() {
    vector<int> A(9, 0);
    for (int i = 0; i < 9; ++i) {
        cin >> A[i];
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        for (int j = 0; j < A.size(); ++j) {
            if (A[j] == b) {
                A[j] = 0;
            }
        }
    }

    bool bingo = false;
    if ((A[0] == 0 && A[3] == 0 && A[6] == 0)
        || (A[1] == 0 && A[4] == 0 && A[7] == 0)
        || (A[2] == 0 && A[5] == 0 && A[8] == 0)
        || (A[0] == 0 && A[1] == 0 && A[2] == 0)
        || (A[3] == 0 && A[4] == 0 && A[5] == 0)
        || (A[6] == 0 && A[7] == 0 && A[8] == 0)
        || (A[0] == 0 && A[4] == 0 && A[8] == 0)
        || (A[2] == 0 && A[4] == 0 && A[6] == 0)) {
        bingo = true;
    }
    //for (int i = 0; i < 9; ++i) {
    //    cout << A[i] << " ";
    //}
    //cout << endl;
    cout << (bingo ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int N, M, AN, K;
  cin >>N >>M;
  vector<int> A(M+1, 0);
  for (int i=0; i<N; i++) {
    cin >> K;
    //cout << "line:" << K << endl;///////
    for (int j=0; j<K; j++) {
      cin >> AN;
      //cout << "Line:" << K << " Item:" << AN << endl;//////
      A.at(AN)++;
    }
  }
  int NN=0;
  for (int i=1; i<M+1; i++) {
    //cout << i << ":" << A.at(i) << endl;/////
    if (N == A.at(i)) NN++;
  }
  cout << NN << endl;
  return 0;
}
	

Measured memory_bytes: 256
#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;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll foo = n / (a + b);
    ll bar = n % (a + b);
    ll res = 0;
    res += foo * a;
    if(bar >= a)  res += a;
    else    res += bar;
    cout << res << endl;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> x(k);
	for (int i = 0; i < k; i++)
		cin >> x[i];
	sort(x.begin(), x.end());
	while (true)
	{
		bool a = true;
		int i = n;
		while (i and a)
		{
			int g = i % 10;
			if (binary_search(x.begin(), x.end(), g))
				a = false;
			i /= 10;
		}
		if (a)
		{
			cout << n << endl;
			break;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
if A < B:
    gcd = gcd(B,A)
    print(int(A*B//gcd))
else:
    gcd = gcd(A,B)
    print(int(A*B//gcd))


Measured memory_bytes: 2940