akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Solve
{
    static void Main(string[] args)
    {
        new ABC_D();
    }
}

public class ABC_A
{
    public ABC_A()
    {
        int[] arr = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

        var line = Console.ReadLine().Trim();
        int k = Int32.Parse(line);
        Console.WriteLine(arr[k - 1]);
    }
}
public class ABC_B
{
    public ABC_B()
    {
        var line = Console.ReadLine().Trim().Split(' ').ToArray();
        ulong h = ulong.Parse(line[0]);
        ulong w = ulong.Parse(line[1]);

        if (h == 1 || w == 1)
        {
            Console.WriteLine(1);
            return;
        }

        ulong odd = h / 2 + h % 2;
        ulong a = h - odd;

        ulong ww = w / 2 + w % 2;
        ulong aw = w - ww;

        ulong res = odd * ww + a * aw;
        Console.WriteLine(res);
    }
}
public class ABC_C
{
    public ABC_C()
    {
        var line = Console.ReadLine().Trim().Split(' ').ToArray();
        ulong a = ulong.Parse(line[0]);
        ulong b = ulong.Parse(line[1]);
        ulong c = ulong.Parse(line[2]);

        if (c < (a + b)) Console.WriteLine("No");
        else if ((4 * a * b) < ((c - a - b) * (c - a - b))) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}
public class ABC_D
{
    int n;
    char[] arr;

    public ABC_D()
    {
        var line = Console.ReadLine().Trim();
        n = int.Parse(line);
        arr = new char[n];
        dfs(0, 0);
    }

    void dfs(int idx, int t)
    {
        if (idx == n)
        {
            Console.WriteLine(new string(arr));
            return;
        }

        for (int i = 0; i < t; i++)
        {
            arr[idx] = (char)('a' + i);
            dfs(idx + 1, t);
        }

        arr[idx] = (char)('a' + t);
        dfs(idx + 1, t + 1);
    }
}
public class ABC_E
{
    public ABC_E()
    {

    }
}
public class ABC_F
{
    public ABC_F()
    {

    }
}

Measured memory_bytes: 14412
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=1e9+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{

    int n;
    cin>>n;
    map<int, int> cnt;
    for(int i=0;i<n;i++)
    {
        int p;
        cin>>p;
        cnt[p]++;
    }
    vector<int> good_guys;
    for(auto i:cnt)
    {
        if(i.se>=4)
            good_guys.pb(i.fi), good_guys.pb(i.fi);
        else if(i.se>=2)
            good_guys.pb(i.fi);
    }
    sort(all(good_guys));
    reverse(all(good_guys));
    if(good_guys.size()>=2)
    {
        cout<<good_guys[0]*good_guys[1]<<endl;
    }
    else
        cout<<0<<endl;


}
signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 6528
//https://atcoder.jp/contests/abc128/tasks/abc128_a
#include<bits/stdc++.h>
using namespace std;
#define aakriti int
#define ayush main()
aakriti ayush
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     aakriti a , p ;
     cin >> a >> p ;
     cout << ( (a * 3) + p ) / 2 << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int cnt[64]={0},u[64];
void judge(int n){
    int pos=0;
    while(n){
        cnt[pos++]+=n%2;
        n/=2;
    }
}
void judge2(int n){
    int pos=0;
    while(n){
        u[pos++]=n%2;
        n/=2;
    }
}
main(){
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i],judge(a[i]);
for(int i=0;i<n;i++){
    ll ans=0;
    memset(u,0,sizeof(u));
    judge2(a[i]);
    for(int j=0;j<64;j++){
        if((cnt[j]-u[j])%2) ans+=(1LL<<j);
    }
    cout<<ans<<" ";
}
}


Measured memory_bytes: 4332
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Measured memory_bytes: 8940
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Ruiwa():
    def __init__(self, a):
        self.H = h = len(a)
        self.W = w = len(a[0])
        self.R = r = a
        for i in range(h):
            for j in range(1,w):
                r[i][j] += r[i][j-1]

        for i in range(1,h):
            for j in range(w):
                r[i][j] += r[i-1][j]

    def search(self, x1, y1, x2, y2):
        if x1 > x2 or y1 > y2:
            return 0

        r = self.R
        rr = r[y2][x2]
        if x1 > 0 and y1 > 0:
            return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
        if x1 > 0:
            rr -= r[y2][x1-1]
        if y1 > 0:
            rr -= r[y1-1][x2]

        return rr

def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        w,h = LI()
        xy = [LI_() for _ in range(n)]
        s,t = LI()
        a = [[0]*w for _ in range(h)]
        for x,y in xy:
            a[y][x] = 1
        rui = Ruiwa(a)
        r = 0
        for i in range(h-t+1):
            for j in range(w-s+1):
                tr = rui.search(j,i,j+s-1,i+t-1)
                if r < tr:
                    r = tr
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9208
#include<stdio.h>
     
#define MAX 100
#define INF 1000000
#define white 0
#define gray 1
#define black 2
      
int n,u,M[MAX][MAX];
      
void dijkstra(void);
      
int main(){
    int i,j,k,v,c;
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            M[i][j] = INF;
        }
    }
     
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d %d",&v,&c);
            M[u][v] = c;
        }
    }
  
    dijkstra();
  
    return 0;
}
  
void dijkstra(){
    int i,min,d[MAX],color[MAX];
  
    for(i=0;i<n;i++){
        d[i] = INF;
        color[i] = white;
    }
     
    d[0] = 0;
    color[0] = gray;
     
    while(1){
        min = INF;
        u = -1;
        for(i=0;i<n;i++){
            if(min > d[i] && color[i] != black){
                u = i;
                min = d[i];
            }
        }
         
        if(u == -1)break;
        color[u] = black;
         
        for(i=0;i<n;i++){
            if(color[i] != black && M[u][i] != INF){
                if(d[i] > d[u] + M[u][i]){
                    d[i] = d[u] + M[u][i];
                    color[i] = gray;
                }
            }
        }
    }
     
    for(i=0;i<n;i++){
        printf("%d ",i);
        if( d[i] == INF ){
            d[i] = -1;
        }
        printf("%d\n", d[i]);
    }
  
}



Measured memory_bytes: 2052
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

struct Edge {
    int src, to;
    i64 cost;
    Edge(int src,  int to, i64 cost) : src(src), to(to), cost(cost) {}
    Edge(int to, i64 cost = 0) : Edge(-1, to, cost) {}
    bool operator< (const Edge &o) const { return cost < o.cost; }
    bool operator> (const Edge &o) const { return cost > o.cost; }
};
using Edges = vector<Edge>;
using WGraph = vector<vector<Edge>>;
using Ugraph = vector<vector<int>>;

vector<i64> bellmanFord(const Edges &es, int V, int src)
{
    vector<i64> dist(V, LINF);
    dist[src] = 0;

    bool updated = true;
    for (int i = 0; updated && i < V-1; ++i) {
        updated = false;
        for (const auto &e : es) {
            if (dist[e.src] == LINF) continue;
            updated |= chmin(dist[e.to], dist[e.src] + e.cost);
        }
    }

    return dist;
}

vector<uint8_t> checkNegativeCycle(const Edges &es, int V, const vector<i64> &dist)
{
    vector<uint8_t> negative(V, 0);
    for (int i = 0; i < V; ++i) {
        for (const auto &e : es) {
            if (dist[e.src] >= LINF) continue;
            negative[e.to] |= negative[e.src] |= (dist[e.to] > dist[e.src] + e.cost);
        }
    }
    return negative;
}

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

    int V, E;
    cin >> V >> E;

    Edges es;
    for (int i = 0; i < E; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        --s, --t;
        es.emplace_back(s, t, -c);
    }

    const auto dist = bellmanFord(es, V, 0);

    if (checkNegativeCycle(es, V, dist)[V-1]) {
        cout << "inf" << endl;
    } else {
        cout << -dist[V-1] << endl;
    }
    return 0;
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    string result = "dangerous";
    
    if ((a - b) >= 0) {
        result = "delicious";
    } else if ((b - a) <= x){
        result = "safe";
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
implicit none
integer(8) :: i,j,k,n
 
read(5,*) n

if (n==2) then
write(6,"(i0,1x,i0,1x,i0)") 1,2,2

else
do i = int(3*n/4),1,-1
  do j = int(3*n/4), 3500
          if (mod(N*i*j,4*i*j-N*i-N*j)==0 .and. (N*i*j)/(4*i*j-N*i-N*j)>0) then

            goto 100
          endif
enddo
enddo
 
100 write(6,"(i0,1x,i0,1x,i0)") i,j,(N*i*j)/(4*i*j-N*i-N*j)

endif

end


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
  ll n,m,k;cin>>n>>m>>k;
  COMinit();
  ll ans=0;
  rep(i,1){
    ans+=(n*(n+1)*(2*n+1)/12-n*(n+1)/4)*m*m;
    ans%=mod;
  }
    
  rep(i,1){
    ans+=(m*(m+1)*(2*m+1)/12-m*(m+1)/4)*n*n;
    ans%=mod;
  }
  ans*=COM(n*m-2,k-2);
  ans%=mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 12160
c=0
m, d = [int(i) for i in input().split()]
for i in range(1, m+1):
    for j in range(1, d+1):
        if 10 <= j <= 99:
            if int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0])*int(str(j)[1])==i:
                c += 1

print(c)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[1000001];
int main(void)
{
	int n,k,i,j,w,x,m,cnt,cnt2;
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		scanf("%d",&m);
		scanf("%s",s);
		cnt2=0;
		for(i=0;i<m;i++)	{
			if(s[i]=='I')	{
				cnt=0;
				for(j=i+1;j<m;j+=2)	{
					if(s[j]=='O' && s[j+1]=='I')	{
						cnt++;
						if(cnt>=n)	cnt2++;
					}
					else {
						break;
					}
				}
				i=j-1;
			}
		}
		printf("%d\n",cnt2);
	}
	return 0;
}


Measured memory_bytes: 2008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  
  if(b == 'A'){
  	cout << 'T' << endl;
  }else if(b == 'T'){
  	cout << 'A' << endl;
  }else if(b == 'G'){
  	cout << 'C' << endl;
  }else if(b == 'C'){
  	cout << 'G' << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define re register
using namespace std;
int n,fa[100002],ans,mxd[100002],dep[100002],u,v,a,b,cnt,son[100002],head[100002];
struct edge{
	int to,next;
}e[200002];
inline void add(re int x,re int y){
	e[++cnt].to=y;
	e[cnt].next=head[x];
	head[x]=cnt;
}
inline void dfs(re int x,re int y){
	fa[x]=y;dep[x]=dep[y]+1;
	for(re int i=head[x];i;i=e[i].next){
		if(e[i].to!=y)dfs(e[i].to,x);
	}
}
inline void dfs1(re int x,re int y){ 
	mxd[x]=dep[x];
	for(re int i=head[x];i;i=e[i].next){
		if(e[i].to!=y&&e[i].to!=son[x]){
			dfs1(e[i].to,x);
			mxd[x]=max(mxd[x],mxd[e[i].to]);
		}
	}
	if(son[x])dfs1(son[x],x);
}
inline void find(re int x){
	if(dep[x]>(dep[v])/2)return;
	ans=max(ans,mxd[x]+dep[v]-2*dep[x]);
	if(son[x])find(son[x]);
}
signed main(){
scanf("%d%d%d",&n,&u,&v);
for(re int i=1;i<n;++i){
	scanf("%d%d",&a,&b);
	add(a,b);
	add(b,a);
}
dfs(u,u);
int tmp=v;
while(tmp!=u)son[fa[tmp]]=tmp,tmp=fa[tmp];
dfs1(u,u);
find(u);
--ans;
printf("%d",ans);
}

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

int main(){
  string s; cin >> s;
  if((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector <string> s(n);
    REP(i,n)cin >> s[i];
    string answer;
    REP(i,n)sort(s[i].begin(),s[i].end());
    int count;
    int min = 51;
    REP(i,26){
        min = 51;
        REP(j,n){
            count = 0;
            REP(k,s[j].length()){
                if(s[j].at(k)=='a'+i)count++;
            }
            //cout << min << " " << count << endl;
            if(count<min){
                min = count;
            }
        }
        REP(j,min){
            //answer += std::string('a'+i);
            printf("%c",'a'+i);
        }
    }

    cout << endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1e9 + 7; // have to be a prime

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

long long nCr(int n, int r) {
    long long ret = 1;
    r = max(r , n - r);
    for (int i = 1; i <= n - r; ++i) {
        ret = mul(ret , r + i);
        ret = mul(ret , mod_inv(i));
    }
    return ret;
}

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

    int n , k;
    cin >> n >> k;

    int blue = k , red = n - k;

    for (int i = 1 ;i <= k ;i++) {
        if (i > red + 1) {
            cout << 0 << '\n';
            continue;
        }

        int boxes = i;
        int balls = blue;
        int ways = nCr(balls - 1 , boxes - 1);

        boxes = i + 1;
        balls = red - i + 1;

        if (balls)
            ways = mul(ways , nCr(balls - 1 + boxes , boxes - 1));

        cout << ways << '\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long P = 998244353; 
long long inv[1000010]; 
int N; 
long long A[200010]; 
long long cnt[1000010]; 
long long sum[1000010]; // sum[i] := iの倍数の総和
long long keisuu[1000010]; 
bool isprime(int num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	for(int i = 3; i * i <= num; i++){
		if(num % i == 0) return false; 
	}
	return true; 
}
void init() {
	inv[1] = 1;
	for(int i = 2; i < 1000005; i++) {
		inv[i] = P - inv[P % i] * (P / i) % P;
	}
}
int main(){
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; cnt[A[i]] ++; 
	}
	for(int i = 1; i <= 1000000; i++){
		for(int j = 1; i * j <= 1000000; j++){
			sum[i] += (cnt[i*j] * i * j) % P; sum[i] %= P; 
		}
	}
	init(); 
	fill(keisuu, keisuu+1000005, 1); 
	for(long long i = 2; i <= 1000000; i++){
		if(!isprime((int) i)) continue; 
		long long mul = (P + 1 - i) % P; 
		for(int j = 1; i * j <= 1000000; j++){
			keisuu[i*j] *= mul; 
			keisuu[i*j] %= P; 
		}
	}
	long long ans = P; 
	ans -= sum[1] % P; 
	for(int i = 1; i <= 1000000; i++){
		if(!sum[i]) continue; 
		ans += (((sum[i] * sum[i] % P) * keisuu[i] % P) * inv[i]) % P; 
		if(ans >= P) ans -= P; 
	}
	ans *= inv[2]; ans %= P; 
	cout << ans << endl; 
}

Measured memory_bytes: 33024
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e17;																									
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             

int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
////freopen("input.txt", "r", stdin);
ll n;
cin>>n;
if(n%2==0)
{
	cout<<n;
}
else 
{
	cout<<n*2;
}
return 0;    
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define LEN 500000
#define SENTINEL 2000000000

int L[LEN/2+2], R[LEN/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0; i<n1; i++) L[i]=A[left+i];
    for(int i=0; i<n2; i++) R[i]=A[mid+i];
    L[n1]=R[n2]=SENTINEL;
    int i=0, j=0;
    for(int k=left; k<right; k++){
        cnt++;
        if(L[i]<=R[j]) A[k]=L[i++]; //Stable
        else A[k]=R[j++];
    }
}
void mergeSort(int A[],int n, int left, int right)
{
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int main()
{
    int A[LEN],n,i;
    cnt=0; cin>>n;
    for(i=0;i<n;i++) cin>>A[i];
    mergeSort(A,n,0,n);
    for(i=0;i<n;i++)
    {
        if(i) cout<<" ";
        cout<<A[i];
    }
    cout<<endl<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 6924
import numpy as np
MOD = 998244353
n, m = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in [0]*n])
if n > m:
	a = a.T
	n, m = m, n
#a[:, [0, 1]] = a[:, [1, 0]]
#print(a)
r = 0
for i in range(n):
	if a[i][i] != 1:
		for j in range(i+1, m):
			if a[i][j] == 1:
				a[:, [i, j]] = a[:, [j, i]]
				break
		else:
			for j in range(i+1, n):
				if a[j][i] == 1:
					a[[i, j]] = a[[j, i]]
				break
			else:
				break
	if a[i][i] == 0:
		continue

	r += 1
	for j in range(i+1, m):
		a[:, j] += a[i][j] * a[:, i]
		a[:, j] %= 2
	for j in range(i+1, n):
		a[j] += a[j][i] * a[i]
		a[j] %= 2
#print(r)
print((pow(2, n+m-1, MOD) - pow(2, n+m-r-1, MOD)) % MOD)

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

using ll=long long;
bool neg(ll x){return x<0;}
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    
    if(all_of(a.begin(),a.end(),neg)){
        int idx=max_element(a.begin(),a.end())-a.begin();
        cout<<a[idx]<<endl;
        cout<<n-1<<endl;
        int len=n;
        while(idx+1<len){
            cout<<len<<endl;
            len--;
        }
        for(int i=0;i<idx;i++){
            cout<<1<<endl;
        }
        return 0;
    }
    
    ll sume=0;
    ll sumo=0;
    for(int i=0;i<n;i++){
        if(i&1){
            if(a[i]>0) sumo+=a[i];
        }
        else{
            if(a[i]>0) sume+=a[i];
        }
    }
    
    vector<int> res;
    int len=n;
    int idxh=0;
    int idxt=2;    
    if(sume<sumo){
        res.push_back(1);
        len--;
        idxh=1,idxt=3;
    }

    while(len>1){
        if(len==2){
            res.push_back(2);
            len--;
        }
        else if(a[idxh]<0){
            res.push_back(1);
            res.push_back(1);
            len-=2;
            idxh+=2,idxt+=2;
        }
        else if(a[idxt]<0){
            if(len<=4){
                while(len>1){
                    res.push_back(len);
                    len--;
                }
            }
            else{
                res.push_back(3);
                len-=2;
                idxt+=2;
            }
        }
        else{
            res.push_back(2);
            idxt+=2;
            len-=2;
        }
        
    }
    cout<<max(sume,sumo)<<endl;
    cout<<res.size()<<endl;
    for(int i=0;i<res.size();i++) cout<<res[i]<<endl;
    return 0;
}

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

using namespace std;

long long int get_number_of_evens_range(long long int l, long long int r)
{
	long long int num = r-l+1;
	if((num%2)==0)
		return num/2;
	else
	{
		if((l%2)==0)
			return (num+1)/2;
		else
			return (num-1)/2;
	}
}

long long int get_number_of_odds_range(long long int l, long long int r)
{
	long long int num = r-l+1;
	if((num%2)==0)
		return num/2;
	else
	{
		if((l%2)==0)
			return (num-1)/2;
		else
			return (num+1)/2;
	}
}

int main()
{
	long long int n,k,ans,t1,num_evens,num_odds,upper_bound;
	cin >> n >> k;
	upper_bound = (2*n)/k;
	ans = 0;
	for(t1=1; t1<=upper_bound; t1++)
	{
		if((k%2)!=0)
		{
			if((t1%2)==0)
			{
				// t2 and t3 must be even
				num_evens = get_number_of_evens_range(1, upper_bound);
				ans += (num_evens * num_evens);
			}	
		}
		else
		{
			if((t1%2)==0)
			{
				// t2 and t3 must be even
				num_evens = get_number_of_evens_range(1, upper_bound);
				ans += (num_evens * num_evens);
			}
			else
			{
				// t2 and t3 must be odd
				num_odds = get_number_of_odds_range(1, upper_bound);
				ans += (num_odds * num_odds);	
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
data = {}
ans = 0
for i in a:
    if i not in data:
        data[i] = 1
    else:
        data[i] += 1

for k,v in data.items():
    if k > v:
        ans += v
    else:
        ans += v-k

print(ans)

Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n],b[n],c[n],sum=0;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        cin>>b[i];
    for(i=1;i<n;i++)
        cin>>c[i];
    sum+=b[a[1]];
    for(i=2;i<=n;i++)
    {
        sum+=b[a[i]];
        if(a[i]==a[i-1]+1)
            sum+=c[a[i-1]];
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int A, B;
void input() {
  cin >> A >> B;
  ;

  ;
}
void solve() {
  if (A < B) {
    swap(A, B);
  }

  int mini = A * B / gcd(A, B);
  cout << mini << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int **arr = new int *[n];
    for(int i=0;i<n;i++)
    {
        arr[i] = new int[3]();
        for(int j=0;j<3;j++) cin >> arr[i][j];
    }
    int **dp = new int*[2];
    for(int i=0;i<2;i++)
    {
        dp[i] = new int[3]();
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if (i==0) dp[0][j] = arr[0][j];
            else
            {
                if (j==0) dp[1][j] = arr[i][j] + max(dp[0][j+1],dp[0][j+2]);
                else if (j==1) dp[1][j] = arr[i][j] + max(dp[0][j-1],dp[0][j+1]);
                else dp[1][j] = arr[i][j] + max(dp[0][j-1],dp[0][j-2]);
            }
        }
        if(i!=0)
        {
            for(int j=0,i=0;j<3;j++) 
            {
                dp[i][j] = dp[1][j];
                dp[1][j] = 0;
            }
        }
        
    }
    
    cout<<*max_element(dp[0],dp[0]+3);
    
    return 0;
}

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

using namespace std; 

typedef long long ll;

typedef long double ld;

#define pb push_back

#define fi first

#define se second

const ll mod = 1e9+7;

const int N = 2e5+5;

void solve(){

	int x; 	cin>>x; 

	cout<<360/__gcd(360,x)<<endl;

}

///  z = 180*(n-2)

/// z/n = 1

/// z = 1*n = 180*(n-2)

///  180*n-1*n = 360

/// n = 360/(180-60)

/// n = 

int main(){

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	int t=1; 

//	cin>>t; 

	while(t--){

		solve();

	}

	return 0;

}

Measured memory_bytes: 3560
#include<stdio.h>
int main(){
int b,a[10],i,c,j;
while(1){
scanf("%d\n",&b);
if(b==0){
break;
}
else{
for(i=0;i<10;i++){
a[i]=0;
}
for(i=0;i<b;i++){
scanf("%d\n",&c);
a[c]++;
}
for(i=0;i<10;i++){
if(a[i]==0){
printf("-");
}
else{
for(j=0;j<a[i];j++)
printf("*");
}
printf("\n");
}
}
}
return 0;
}



Measured memory_bytes: 2004
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

type Scanner struct {

    reader *bufio.Reader
    buffer []string
    pointer int
}

func NewScanner() *Scanner {
    return &Scanner{
        reader: bufio.NewReaderSize(os.Stdin,4096),
        pointer: 0,
    }
}

func (self *Scanner) NextLine () string {
    var buffer []byte
    for {
        line,isPrefix,_ := self.reader.ReadLine()
        buffer = append(buffer, line...)
        if !isPrefix {
            break
        }
    }
    return string(buffer)
}

func (self *Scanner) Next () string {
    if self.pointer >= len(self.buffer) {
        line := self.NextLine()
        self.buffer = strings.Fields(line)
        self.pointer = 0
    }
    self.pointer++
    return self.buffer[self.pointer-1]
}

func (self *Scanner) NextInt () int {
    s := self.Next()
    i,_ := strconv.ParseInt(s,10,32)
    return int(i)
}

func (self *Scanner) NextLong () int64{
    s := self.Next()
    l,_ := strconv.ParseInt(s,10,64)
    return int64(l)
}

func (self *Scanner) NextFloat () float32 {
    s := self.Next()
    f,_ := strconv.ParseFloat(s,32)
    return float32(f)
}

func (self *Scanner) NextDouble () float64 {
    s := self.Next()
    d,_ := strconv.ParseFloat(s,64)
    return float64(d)
}

func Calc (array []int,mod int) int {
	length := len(array)

	ret := 0
	for i := 0; i < length; i++ {
		ret = (ret * 4 + array[i]) % mod
	}

	return ret
}

func main () {
	cin := NewScanner()

	S := cin.Next();
	ans := 0
	for _, s := range S {
		if s == '1' {
			ans++;
		}
	}

	fmt.Println(ans);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int c[510][510];
int d[510][510];
int deque[300000],*p0=deque,*p1=deque;

void push(int n,int f){
	if(f==0){
		if(p0==deque)p0=deque+29000-1;
		else p0--;
		*p0=n;
	}else{
		*p1=n;
		p1++;
		if(p1==deque+29000)p1=deque;
	}
}

int pop(){
	int ret=*p0;
	p0++;
	if(p0==deque+29000)p0=deque;
	return ret;
}

#define chmin(x,y)(x>y?x=y,1:0)
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)rep(j,0,n){
		c[i][j]=1;
		d[i][j]=min(min(i,n-1-i),min(j,n-1-j));
	}
	
	ll ans=0;
	rep(_,0,n*n){
		int t;
		scanf("%d",&t);
		t--;
		int x=t/n;
		int y=t%n;
		ans+=d[x][y];
		c[x][y]=0;
		push(x*n+y,0);
		while(p0!=p1){
			int tt=pop();
			int xx=tt/n;
			int yy=tt%n;
			if(xx!=  0&&chmin(d[xx-1][yy],d[xx][yy]+c[xx][yy]))push((xx-1)*n+yy,c[xx-1][yy]);
			if(xx!=n-1&&chmin(d[xx+1][yy],d[xx][yy]+c[xx][yy]))push((xx+1)*n+yy,c[xx+1][yy]);
			if(yy!=  0&&chmin(d[xx][yy-1],d[xx][yy]+c[xx][yy]))push(xx*n+(yy-1),c[xx][yy-1]);
			if(yy!=n-1&&chmin(d[xx][yy+1],d[xx][yy]+c[xx][yy]))push(xx*n+(yy+1),c[xx][yy+1]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3812
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	
	
	
	string x,y,z;
	cin>>x>>y>>z;
	for(int i=0;i<100;i++)
	if (65<=(int)y[i]<=90)
	{
		cout<<"A"<<y[0]<<"C";
		break;
	}
}

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

const int N = 5005;
int f[N][N], g[N][N];
int n, ans, mod;

inline void add(int &x, int y)
{
	x += y;
	x >= mod ? x -= mod : 0;
}

int main()
{
	scanf("%d%d", &n, &mod);
	
	int k = n - 1 >> 1;
	f[0][0] = g[0][0] = 1;
	for (int c = n; c >= 0; --c)
		for (int i = 0, im = !c ? n : n / c; i <= im; ++i)
			for (int j = 0; j <= n - c; ++j)
				add(f[i + 1][j + c], f[i][j]);
	for (int c = k; c >= 0; --c)
		for (int i = 0, im = !c ? n : n / c; i <= im; ++i)
			for (int j = 0; j <= n - c; ++j)
				add(g[i + 1][j + c], g[i][j]);
	for (int i = 0; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			add(g[i][j], g[i][j - 1]);
	if (!(n & 1))
	{
		for (int x = 1; x <= n; ++x)
			for (int j = 0; j < x; ++j)
				ans = (1ll * f[k + 1][j] * g[n - x][x - j - 1] + ans) % mod;
	}
	else
	{
		for (int x = 1; x <= n; ++x)
			for (int j = 0; j < x; ++j)
				ans = (1ll * f[k][j] * g[n - x][x - j - 1] + ans) % mod;
	} 
	printf("%d\n", ans);
}

Measured memory_bytes: 195840
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S;
	cin >> S;

	int len = S.length();

	int s_max = 0;
	for (int i = 0; i < len; ++i)
	{
		for (int j = 1; j <= (len - i); ++j)
		{
			string ls = S.substr(i, j);
			bool judge = true;
			int l_max = 0;
			for (auto e : ls)
			{
				if (e != 'A' && e != 'C' && e != 'G' && e != 'T')
				{
					judge = false;
					break;
				}
			}

			if (judge)
			{
				s_max = max(s_max, (int)ls.length());
			}
		}
	}

	cout << s_max << endl;

	return 0;
}

Measured memory_bytes: 3620
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>c(26);
	for (auto &i : c)cin >> i;
	vector<vector<int>>v(N, vector<int>(26));
	for (auto &i : v)for (auto &j : i)cin >> j;
	vector<long long int>bef(26, -1);
	vector<long long int>t(N);
	for (int i = 0; i < N; i++) {
		cout << i % 26 + 1 << endl;
	}
	
}

Measured memory_bytes: 3708
# C - *3 or /2
# https://atcoder.jp/contests/abc100/tasks/abc100_c

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

ans = 0
for a in A:
  while a % 2 == 0:
    a //= 2
    ans += 1

print(ans)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
//#include <time.h>
// #include<set>
// #include<vector>
// #include<algorithm>
// #include<iostream>
using namespace std;
#include <math.h>
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 50001
 
#define ll long long int


 
int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	if(x>=0){
		ll stps=x/d;
		if(stps>=k){
			cout<<x-k*d<<endl;
		}
		else{
			ll ans1=x-stps*d;
			ll ans2=abs(ans1-d);
			k-=stps;
			if(k%2==1){
				cout<<ans2<<endl;
			}
			else{
				cout<<ans1<<endl;
			}
		}
	}
	else{

		ll stps=abs(x/d);
		if(stps>=k){
			cout<<abs(x+k*d)<<endl;
		}
		else{
			ll ans1=x+stps*d;
			ll ans2=abs(ans1+d);
			k-=stps;
			if(k%2==1){
				cout<<ans2<<endl;
			}
			else{
				cout<<abs(ans1)<<endl;
			}
		}

	}
 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll R; cin >> R;
  cout << R * 6.28 << endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
using namespace std;
#define MAXN 55
#define MOD m
int m;
struct Matrix
{
    int data[MAXN][MAXN];
    int n;
    void init()
    {
        for(int i=0;i<MAXN;i++)
            for(int j=0;j<MAXN;j++)
            data[i][j]=0;
        n=0;
    }
};

Matrix Multy(Matrix m1,Matrix m2)
{
    Matrix r;
    r.init();
    int n=m1.n;
    r.n=n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
            r.data[i][j]=(r.data[i][j]+m1.data[i][k]*m2.data[k][j])%MOD;
    return r;
}

Matrix Fast_mi(Matrix ma,int m)
{
    Matrix r;
    r.init();
    r.n=ma.n;
    int n=ma.n;
    for(int i=0;i<n;i++)
        r.data[i][i]=1;
    while(m)
    {
        if(m&1)r=Multy(r,ma);
        ma=Multy(ma,ma);
        m=m>>1;
    }
    return r;
}

int Tr(Matrix ma)
{
    int sum=0;
    for(int i=0;i<ma.n;i++)
        sum=(sum+ma.data[i][i])%MOD;
    return sum;
}

int main()
{
    int n,a,b,c,t;
    while(scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t)!=EOF)
    {
        if(n==0&&m==n&&a==n&&b==n&&c==n&&t==n)break;
        Matrix ma,s;
        ma.init();s.init();
        ma.n=n;s.n=n;
        for(int i=0;i<n;++i)
            scanf("%d",&s.data[0][i]);
        for(int i=0;i<n;i++)
        {
            if(i-1>=0)ma.data[i-1][i]=a;
            ma.data[i][i]=b;
            if(i+1<n)ma.data[i+1][i]=c;
        }
        s=Multy(s,Fast_mi(ma,t));
        printf("%d",s.data[0][0]);
        for(int i=1;i<n;++i)
            printf(" %d",s.data[0][i]);
        printf("\n");
    }
    return 0;
}

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

from pprint import pprint as pp
from pprint import pformat as pf

import math

def calc(a, b, x):
    return math.floor(a * x / b) - a * math.floor(x / b)

if __name__ == '__main__':
    a, b, n = map(int, input().split())
    if b > n:
        m = calc(a, b, n)
    else:
        m = calc(a, b, b - 1)
    print(m)


Measured memory_bytes: 68616
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
char str[120][110];
int cnt[120][3];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(str[i][j]=='W')cnt[i][0]++;
		if(str[i][j]=='B')cnt[i][1]++;
		if(str[i][j]=='R')cnt[i][2]++;
	}
	int ret=mod;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a-1;j++){
			int tmp=0;
			for(int l=0;l<a;l++){
				if(l<=i)tmp+=b-cnt[l][0];
				else if(l<=j)tmp+=b-cnt[l][1];
				else tmp+=b-cnt[l][2];
			}
			ret=min(ret,tmp);
		}
	}
	printf("%d\n",ret);
}

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

int main(){
    int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    string s;cin>>s;

    bool judgement = true;
    bool rock = false;
    bool adjascent_three_free_space = false;
    a--;
    b--;
    c--;
    d--;

    if (c < d){
        for (int i=a;i<d;i++){
            if (rock){
                if (s[i] == '#'){
                    judgement = false;
                    break;
                }
            }
            if (s[i]=='#'){
                rock = true;
            } else {
                rock = false;
            }
        }
        if (judgement){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        for (int i=a;i<c;i++){
            if (b <= i && i <= d){
                if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
                    adjascent_three_free_space = true;
                }
            }
            if (rock){
                if (s[i] == '#'){
                    judgement = false;
                    break;
                }
            }
            if (s[i]=='#'){
                rock = true;
            } else {
                rock = false;
            }
        }
        if (judgement && adjascent_three_free_space){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	int n, x, sum;
	while(1){
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		sum = 0;
		for (int i = 1; i <= n ; i++){
			for (int j = i + 1; j <= n ; j++){
			    int k = x - i - j;
                if(k <= n && k > j) sum++;
			}
		}
        cout << sum << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  unsigned long long n; cin >> n;
  unsigned long long ans = 1;
  bool zero = false;
  bool flag = true;
  rep(i,n){
    unsigned long long a; cin >> a;
    unsigned long long ans_b = ans;
    ans *= a;
    if(ans > 1000000000000000000 || a > 1000000000000000000){
      flag = false;
    }
    if(a == 0){
      zero = true;
    }
    else if(ans_b > ans) {
      flag = false;
    }
    
  }

  if(flag) cout << ans << endl;
  else if(zero) cout << 0 << endl;
  else if(!flag) cout << -1 << endl;
}



Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

#単入力
n=int(input())

#リスト入力
h = [int(i) for i in input().split()]
ans=0
l=[]
for i in range(n):
    if h[i]>h[i-1]:
        l.append(ans)
        ans=0
    elif h[i]<=h[i-1]:
        ans+=1
    if i ==0:
        ans=0
l.append(ans)
print(max(l))

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

typedef long long ll;
const double PI = 3.1415926535897932384626433;
const int MOD = 1e9+7;
const int INF = 1e9;
#define rep(i, n) for(int i=0;i<(n);++i)

//prototype declaration

//gloval variable

int min(int x, int y){
  if(x < y) return x;
  else return y;
}

int main(void){
  char s[200000];
  scanf("%s", s);
  int red=0, blue=0;
  for(int i = 0; s[i]!='\0'; i++){
    if(s[i]=='0') red++;
    else blue++;
  }
  printf("%d\n", 2*min(red, blue));
  return 0;
}


Measured memory_bytes: 1840
#include "bits/stdc++.h"
using namespace std;

typedef pair<int, int> pii;

struct edge_t {
    int u, v, w;
    edge_t (const int _u, const int _v, const int _w) {
        this->u = _u;
        this->v = _v;
        this->w = _w;
    }
};

int main() {
    int l;
    while (scanf("%d", &l) != EOF) {
        vector<edge_t> edges;
        int n = 0;
        for (int i = 1; i <= l; i <<= 1) {
            n++;
        }
        int m = 1 << (n - 1);
        for (int i = 2; i <= n; i++) {
            m >>= 1;
            edges.push_back(edge_t(i, i + 1, 0));
            edges.push_back(edge_t(i, i + 1, m));
        }
        int p = 0;
        m = 1 << (n - 1);
        for (int i = 1; i <= n; ++i) {
            if (l & m) {
                edges.push_back(edge_t(1, i + 1, p));
                p |= m;
            }
            m >>= 1;
        }
        if (n + 1 > 20) {
            vector<pii> x, y, xy;
            for (vector<edge_t>::iterator it = edges.begin(); it != edges.end(); ) {
                if (it->v == n) {
                    x.push_back(make_pair(it->u, it->w));
                    it = edges.erase(it);
                } else if (it->v == n + 1) {
                    if (it->u != n) {
                        y.push_back(make_pair(it->u, it->w));
                    } else {
                        xy.push_back(make_pair(it->u, it->w));
                    }
                    it = edges.erase(it);
                } else {
                    it++;
                }
            }
            for (const pii &lhs : x) {
                for (const pii &rhs : xy) {
                    y.push_back(make_pair(lhs.first, lhs.second + rhs.second));
                }
            }
            for (const pii &combined : y) {
                edges.push_back(edge_t(combined.first, n, combined.second));
            }
            n--;
        }
        printf("%d %lu\n", n + 1, edges.size());
        for (const edge_t &e : edges) {
            printf("%d %d %d\n", e.u, e.v, e.w);
        }
    }
    return 0;
}


Measured memory_bytes: 256
p=input().rstrip().split(' ')
L=[]
for i in range(0,1000000):
    L.append(i**2)
l=[]
q=[]
w=[]
S=[]
D=[]
V=0;
for i in range(0,int(p[0])):
    u=input().rstrip().split(' ')
    l.append(u)
for i in range(0,len(l)-1):
    A=l[i]
    for j in range(i+1,len(l)):
        B=l[j]
        T=0;
        for k in range(0,len(A)):
            T+=(abs(int(A[k])-int(B[k]))**2)
        if T in L:
            V+=1;
print(V)


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

int main() {
    int N; cin >> N;
    vector<long long> Q(N), X(N);
    rep(i, 0, N) cin >> Q[i] >> X[i];
    long long A = 0, B = 1;
    for(int i = N - 1; i >= 0; --i) {
        if(Q[i] == 1) B *= X[i];
        else if(Q[i] == 2) A += X[i] * B;
        else if(Q[i] == 3) A -= X[i] * B;
    }
    cout << -A << " " << B << '\n';
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    map<string, int> s;
    int ans = 0;
    for(int i = 0; i< n; i++){
        string t;
        cin >> t;
        s[t]++;
        if(s[t] == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19124
def main():
    S = input()

    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return

    if len(S) < 26:
        for i in range(97, 123):
            if chr(i) not in S:
                print(S + chr(i))
                break
    else:
        for i in range(24, -1, -1):
            if S[i] != 'z':
                s = ord(S[i]) + 1
                for j in range(s, 123):
                    if chr(j) not in S[:i]:
                        print(S[:i] + chr(j))
                        return

main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;


int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    map<string, int> mp;
    REP(i, n){
        ll a, c; string b; cin >> a;
        if(a==0){
            cin >> b >> c;
            mp[b] = c;
        }else if(a==1){
            cin >> b;
            cout << mp[b] << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 25856