akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
class node {
public:
    int id = 0;
    node *left = 0, *right = 0;
};
node* str_to_nod(string s) {
    node* ret = new node();
    int dep = 0, i = 0;
    for (; i < s.length(); ++i) {
        if (s[i] == '(') ++dep;
        if (s[i] == ')') --dep;
        
        if (!dep) {
            if (s[i] == ')') ret->left = (i > 1) ? str_to_nod(s.substr(1, i - 1)) : 0;
    
            if (s[i] == ']') {
                ret->right = (i + 3 < s.length()) ? str_to_nod(s.substr(i + 2, s.length() - i - 3)) : 0;
                return ret;
            }
            if (s[i] >= '0' && s[i] <= '9') ret->id = ret->id * 10 + s[i] - '0';
        }
    }
}
string nod_to_str(node* par) {
    return par ? "(" + nod_to_str(par->left) + ")[" + to_string(par->id) + "](" + nod_to_str(par->right) + ")" : "";
}
node* compo(node* a, node* b) {
    if (!a || !b) return 0;
    
    node* ret = new node();
    ret->id = a->id + b->id;
    ret->left = compo(a->left, b->left);
    ret->right = compo(a->right, b->right);
    return ret;
}
int main(){
    string a, b;
    cin >> a;
    cin >> b;
    cout << nod_to_str(compo(str_to_nod(a), str_to_nod(b))) + "\n";
    return 0;
}

Measured memory_bytes: 3280
n = int(input())
A = list(map(int,input().split()))

A.sort()
C = [0] * (max(A)+1)

for i in range(n):
    C[A[i]] += 1

ans = 0
for i in range(len(C)):
    ans += max(0, C[i]-1)

if ans % 2 == 1:
    ans += 1
print(n - ans)

Measured memory_bytes: 52916
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

#include <bits/stdc++.h>
using namespace std;
 
#define len(x) (int)((x).size())
#define endl '\n'
#define int long long
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(9);
    solve();
    return 0;
}
 
const int MOD = 998244353, MAXN = 3e5 + 10, INF = 1e18 + 10;
vector<int> g[MAXN];

void solve() {
	int n, x, y;
    cin >> n >> x >> y;

    for (int i = 1; i <= n - 1; ++i) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    vector<int> ans(n + 1);

    for (int st = 1; st <= n; ++st) {
        vector<int> d(n + 1, INF);
        d[st] = 0;
        deque<int> q;
        q.push_back(st);

        while (!q.empty()) {
            int v = q.front();
            q.pop_front();
            for (auto u : g[v]) {
                if (d[u] == INF) {
                    d[u] = d[v] + 1;
                    q.push_back(u);
                }
            }
        }

        for (int v = st + 1; v <= n; ++v) {
            ans[d[v]]++;
        }
    }

    for (int i = 1; i <= n - 1; ++i) {
        cout << ans[i] << endl;
    }
}	


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, k;
int v[MAX];

void solve() {
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> v[i];
	sort(v, v+n);
	long long ans = 0;
	for(int i=0; k; i++) {
		ans += v[i];
		k--;
	}
	cout << ans << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int n,m;
int used[50]={};

int calc(){
  int res=0;
  while(1){
    sort(used,used+50,greater<int>());
    int cnt=0;
    for(int i=0;i<50&&cnt<m;i++) if(used[i])cnt++, used[i]--;
    if(cnt==m)res++;
    else break;
  }
  return res;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    string str;
    cin>>str;
    used[str[0]-'A']++;
  }
  cout <<calc()<<endl;
  return 0;
}


Measured memory_bytes: 256
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(){
		
		int[] depth = new int[N];
		int[] parent = new int[N];
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=0;i<N-1;i++){
			E[A[i]].Add(B[i]);
			E[B[i]].Add(A[i]);
		}
		
		var Q = new Queue<int>();
		Q.Enqueue(0);
		depth[0] = 0;
		parent[0] = -1;
		
		while(Q.Count > 0){
			var now = Q.Dequeue();
			foreach(var nxt in E[now]){
				if(nxt == parent[now]) continue;
				parent[nxt] = now;
				depth[nxt] = depth[now] + 1;
				E[nxt].Remove(now);
				Q.Enqueue(nxt);
			}
		}
		
		int len = depth[N-1];
		// depth 1,2,3,4,5,6,7
		// climb 0,0,1,1,2,2
		int climb = (len - 1) / 2;
		int snuke = N - 1;
		while(climb > 0){
			snuke = parent[snuke];
			climb--;
		}
		
		int scnt = 0;
		Q.Enqueue(snuke);
		while(Q.Count > 0){
			var now = Q.Dequeue();
			scnt++;
			foreach(var nxt in E[now]) Q.Enqueue(nxt);
		}
		
		int fcnt = N - scnt;
		Console.WriteLine(fcnt > scnt ? "Fennec" : "Snuke" );
		
	}
	int N;
	int[] A,B;
	public Sol(){
		N = ri();
		A = new int[N-1];
		B = new int[N-1];
		for(int i=0;i<N-1;i++){
			var d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 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: 26716
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nmq = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, m, q) = (nmq[0], nmq[1], nmq[2]);
        var quadraples = new (int a, int b, int c, int d)[q];
        for (int i = 0; i < quadraples.Length; ++i)
        {
            var abcd = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            quadraples[i] = (abcd[0], abcd[1], abcd[2], abcd[3]);
        }

        var seqA = new int[n + 1];
        (seqA[0], seqA[^1]) = (1, m);
        var max = Dfs(quadraples, seqA, 1);

        Console.WriteLine(max);
    }

    static long Dfs((int a, int b, int c, int d)[] qs, int[] seqA, int index)
    {
        if (index + 1 >= seqA.Length)
        {
            return qs.Where(x => seqA[x.b] - seqA[x.a] == x.c).Sum(x => x.d);
        }

        seqA[index] = seqA[index - 1];

        var r = 0L;
        while (seqA[index] <= seqA.Last())
        {
            r = Math.Max(r, Dfs(qs, seqA, index + 1));
            ++seqA[index];
        }

        return r;
    }
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<std::vector<char> > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n; cin >> n;
    
    v_ll a_l(n+1), a_r(n+1), b_l(n), b_r(n);
    
    irep(i, n+1) { cin >> a_l[i]; a_r[i] = a_l[i]; }
    irep(i, n)   { cin >> b_l[i]; b_r[i] = b_l[i]; }

    ll ans_l = 0;
    irep(i, n) {
        ll l = a_l[i], r = a_l[i+1];    
        ans_l += min(l, b_l[i]);
        b_l[i] -= min(l, b_l[i]);

        ans_l += min(r, b_l[i]);
        a_l[i+1] -= min(r, b_l[i]); 
        b_l[i] -= min(r, b_l[i]);
    }

    ll ans_r = 0;
    irep(i, n) {
        int j = n-i-1;
        ll l = a_r[j], r = a_r[j+1];    

        ans_r += min(r, b_r[j]);
        b_r[j] -= min(r, b_r[j]);

        ans_r += min(l, b_r[j]);
        a_r[j] -= min(l, b_r[j]); 
        b_r[j] -= min(l, b_r[j]);
    }

    cout << max(ans_l, ans_r) << endl;
    return 0;
}
/** atcoder **/


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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    ll x;
    cin >> x;
    vector<ll> a(n);
    for (ll& v: a) {
        cin >> v;
    }

    sort(a.begin(), a.end());
    ll ans = 0, s = 0;
    for (ll& v: a) {
        s += v;
        ans += s <= x;
    }

    ans -= s < x;
    cout << ans << "\n";
}

        

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
using lint = long long int;
template<typename T> void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }

const lint MOD = 998244353;

int N, S, A[3003];
lint dp[3003][3003];

int main() {
    cin >> N >> S;
    for_(i,0,N) cin >> A[i];

    for_(i,0,N+1) for_(j,0,S+1) dp[i][j] = 0;
    for_(i,0,N) dp[i][0] = 1;

    for_(i,0,N) for_(j,0,S+1) {
        modAdd(dp[i+1][j], dp[i][j], MOD);
        int jj = j + A[i];
        if (jj <= S) modAdd(dp[i+1][jj], dp[i][j], MOD);
    }

    lint ans = 0;
    for_(i,0,N+1) modAdd(ans, dp[i][S], MOD);
    cout << ans << endl;
}

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

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    
    int i = 0;
    while (i < s.size() && i < t.size()) {
        if (s[i] < t[i]) {
            cout << "Yes" << endl;
            return 0;
        } else if (s[i] > t[i]) {
            cout << "No" << endl;
            return 0;
        }
        i++;
    }
    if (s.size() < t.size()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		int n,m;
		bool used[510];
		memset(used,0,sizeof(used));
		used[1]=true;
		cin >> n;
		cin >> m;
		if(n==0&&m==0)break;
		vector<int> f[n+1];
		int ans=0;
		for(int i=0;i<m;i++)
		{
			int a,b;
			cin >> a >> b;
			if(a==1)
			{
				ans++;
				used[b]=true;
			}
			f[a].pb(b);
f[b].pb(a);
		}
		for(int i=0;i<f[1].size();i++)
		{
			for(int j=0;j<f[f[1][i]].size();j++)
			{
				if(!used[f[f[1][i]][j]])
				{
					ans++;
					used[f[f[1][i]][j]]=true;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1364
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define pb push_back
#define s(a) (int)(a).size()
#define all(x) (x).begin(),(x).end()
#define endl ("\n")

using ll = long long;
using ld = long double;
const ll M = 1000000007;
const ld pi = 3.14159265358979323846;

long long mod(long long x)
{
    return ((x%M + M)%M);
}

long long add(long long a, long long b)
{
    return mod(mod(a)+mod(b));
}

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

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

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

	int tt = 1;
	//cin >> tt;
	for(int test_case = 1; test_case <= tt; test_case++)
	{
		//cout << "Case #" << test_case << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3572
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val X = sc.nextLong()
  def makeDat(count:Int,d:List[Long],add:Long):List[Long]={
    count match {
      case 0 => d
      case _ => makeDat(count-1,d.head*2+add::d,add)
    }
  }
  val layer = makeDat(50,1::Nil,3)
  val patty = makeDat(50,1::Nil,1)
  def l(level:Int)= layer(50-level)
  def p(level:Int)= patty(50-level)
  def ans(n:Int,x:Long):Long={
    if(n==0) 1
    else if(x == 1) 0
    else if(x <  1 + l(n-1)) ans(n-1,x-1)
    else if(x == 1 + l(n-1)) p(n-1)
    else if(x == 2 + l(n-1)) p(n-1) + 1
    else if(x <  2 + l(n-1)*2) p(n-1) + 1 + ans(n-1,x-2-l(n-1))
    else p(n)
  }
  println(ans(N,X))
}

Measured memory_bytes: 27448
import math
N,D=map(int,input().split())
S=[]
C=0
for i in range(N):
	S.append(list(map(int,input().split())))
for i in range(0,N-1):
	for j in range(i+1,N):
		tmp=0
		for k in range(D):
			tmp+=(S[i][k]-S[j][k])**2
		tmp=math.sqrt(tmp)
		if tmp==int(tmp):
			C+=1
print(C)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

main = putStrLn . concat . intersperse " " . f =<< replicateM 3 readInt
  where f ns = show <$> sort ns


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

const int INF = 1e9;

int N, D, p[55][55], dp[55][55][55];

signed main(){  
  
  cin>>N>>D;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<D;j++) cin>>p[i][D-j-1];
  
  for(int i=0;i<=D;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<=D;k++) dp[i][j][k] = INF;
  
  for(int i=0;i<N;i++) dp[1][i][0] = p[i][0];

  
  for(int i=1;i<D;i++){
    
    for(int j=0;j<N;j++){

      for(int k=0;k<=D;k++){
	
	if( dp[i][j][k] == INF ) continue;
	
	for(int l=0;l<N;l++){
	  
	  int nk = k;
	  
	  if( j != l ) nk++;
	  
	  dp[i+1][l][nk] = min( dp[i+1][l][nk], dp[i][j][k] + p[l][i] );
	  
	}
	
      }
      
    }
    
  }
  
  int P = INF;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<=D;j++) P = min( P, dp[D][i][j] );
  
  int M = INF;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<=D;j++)
      if( P == dp[D][i][j] ) M = min( M, j );


  cout<<P<<' '<<M<<endl;

  int h = INF;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=D;j++)
      
      if( P == dp[D][i][j] && M == j ){
	h = i;
	break;
      }
    
    if( h != INF ) break;
    
  }
  
  vector<int> ans;
  
  int I = D, x = M;

  ans.push_back( h + 1 );
  
  while( --I ){
    
    for(int i=0;i<N;i++){
      
      if( h == i && dp[I+1][h][x] - p[h][I] == dp[I][i][x] ) break;
      
      if( h != i && x != 0 && dp[I+1][h][x] - p[h][I] == dp[I][i][x-1] ){
	h = i;
	x--;
	break;
      }
      
    }
    
    ans.push_back( h + 1 );
  }
  
  for(auto idx : ans ) cout<<idx<<endl;
  
  return 0;
}



Measured memory_bytes: 3756
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class MyScanner{
    InputStream stream;
    public MyScanner(){
        stream = System.in;
    }
    
    public int nextInt(){
        int ret = 0;
        try{
            while(true){
                char readed = (char)stream.read();
                if(readed < '0' || readed > '9'){
                    break;
                }
                ret = ret * 10 + (readed - '0');
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally{
            return ret;
        }
    }
}

class Main {
    public static void main(String args[]) {
        MyScanner sc = new MyScanner();
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; ++i){
            a[i] = sc.nextInt() - 1;
        }
        
        int ret = 0;
        for(int i = 0; i < n; ++i){
            if(a[a[i]] == i){
                ++ret;
            }
        }
        System.out.println(ret / 2);
    }
}


Measured memory_bytes: 21844
def integerornot(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

n = int(input())
for i in range(1,10):
    if integerornot(n/i) and 1<=n/i<=9:
        print("Yes")
        break
else:
    print("No")

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

int main(){
	int N;
	int L;
	cin >> N >> L;
	
	vector<int> apple(N);
	for(int i = 0; i < N; i++){
		apple.at(i) = L + i;
	}

	int sum = 0;
	for(int i = 0; i < N; i++){
		sum += apple.at(i);
	}
	
	if(apple.at(0) >= 0){
		sum -= apple.at(0);
	}
	else if(apple.at(N - 1) <= 0){
		sum -= apple.at(N - 1);
	}
	cout << sum << endl;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	for(int i = 1; i < s.size(); i++) {
		if(s[i-1] == s[i]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int X=0,M=0,U=0,T=0;
string N;
cin>>N;
int len=N.length();
for(int i=0;i<len;i++){
	if(N[i]=='A'){
	X=i;
	T=1;
}
if(T==1)
break;
}
for(int y=len-1;y>0;y--){
	
	if(N[y]=='Z'){
		
		M=y;
		U=1;
	}
	if(U==1)
	break;
}
cout<<M-X+1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,m){
		rep(j,n-1){
			if(v[j]%(i+1)>v[j+1]%(i+1))swap(v[j],v[j+1]);
		}
	}
	rep(i,n)cout<<v[i]<<endl;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
	int a,b;
	cin>>a>>b;

	if(b>=a)
	cout<<a;
	else
	cout<<a-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,y,z;
int main(){
	cin>>x>>y>>z;
	int a=x/y;
	if(x%y)a++;
	cout<<a*z<<endl;
	return 0;
}


Measured memory_bytes: 3560
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long double ans = 0;
	long double d, n, m;
	cin >> n >> m >> d;
	if (d >= n) {
		cout << "0" << endl;
		return 0;
	}
	ans = (long double) (m-(long double) 1) * (n - d) / (n * n);
	if (d != 0) {
		ans *= (long double)2;
	}
	cout << fixed << setprecision(10);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <functional>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void Main();

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  Main();
#ifdef LOCAL
  cout << "\nTime: " << (int)ceil((double)1000 * clock() / CLOCKS_PER_SEC) << " ms";
#endif
}

const int MOD = (int)1e9 + 7;
int n;
vector<int> p2(60), cnt_one(60, 0), cnt_zero(60, 0);
int ans = 0;

inline int mult(int a, int b) {
  return 1ll * a * b % MOD;
}

inline int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}

void Main() {
  p2[0] = 1;
  for (int i = 1; i < 60; i++) {
    p2[i] = mult(p2[i - 1], 2);
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    for (ll bit = 0; bit < 60; bit++) {
      if (a & (1ll << bit)) {
        ans = add(ans, mult(cnt_zero[bit], p2[bit]));
        cnt_one[bit]++;
      } else {
        ans = add(ans, mult(cnt_one[bit], p2[bit]));
        cnt_zero[bit]++;
      }
    }
  }
  cout << ans << '\n';
}

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

using namespace std;

#define lli long long int
#define scin(x) scanf("%lld",&x)

int main()
{
    lli n;
    scin(n);
    lli a[n+5][5],dp[n+5][5];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[n-1][0]=a[n-1][0];
    dp[n-1][1]=a[n-1][1];
    dp[n-1][2]=a[n-1][2];
    for(int i=n-2;i>=0;i--)
    {
        dp[i][0]=max(dp[i+1][1],dp[i+1][2])+a[i][0];
        dp[i][1]=max(dp[i+1][0],dp[i+1][2])+a[i][1];
        dp[i][2]=max(dp[i+1][0],dp[i+1][1])+a[i][2];
    }
    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	int ans = 0,i=0;
	while (ans < x) {
		i++;
		ans += i;

	}
	cout << i <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, k, i;
  long long ans;
  cin >> n >> k;
  if(k%2==1)
    ans=pow(n/k, 3);
  else
    ans=pow(((n+k/2)/k), 3)+pow((n/k), 3);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include "iostream"
using namespace std;
#define dir(a,b) (a>>b)
const int Max=500010;
int root[Max],tot,val[Max];
using namespace std;
struct node
{
    int lef,rig,sum;
}msegtr[Max*40];
map<int,int> mp;
void Init()
{
    tot=0;
    msegtr[0].lef=msegtr[0].rig=msegtr[0].sum=0;
    root[0]=0;
    mp.clear();
    return;
}
void Create(int sta,int enn,int &x,int y,int pos,int aad)
{
    msegtr[++tot]=msegtr[y];
    msegtr[tot].sum+=aad;
    x=tot;
    if(sta==enn)
        return;
    int mid=dir(sta+enn,1);
    if(mid>=pos)
        Create(sta,mid,msegtr[x].lef,msegtr[y].lef,pos,aad);
    else
        Create(mid+1,enn,msegtr[x].rig,msegtr[y].rig,pos,aad);
    return;
}
int Query(int sta,int enn,int x,int y)//只有左边有界限
{
    if(sta>=y)
        return msegtr[x].sum;
    int mid=dir(sta+enn,1);
    if(mid>=y)
        return Query(sta,mid,msegtr[x].lef,y)+msegtr[msegtr[x].rig].sum;
    else
        return Query(mid+1,enn,msegtr[x].rig,y);
}
int main()
{
    int n,m,temp;
    int lef,rig;
    cin>>n>>m;
        Init();
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&val[i]);
            if(!mp.count(val[i]))//直接加
            {
                Create(1,n,root[i],root[i-1],i,1);//注意是在i这个位置加1，不是权值线段树的val[i]位置加1
            }
            else
            {
                Create(1,n,temp,root[i-1],mp[val[i]],-1);//先在原位置减去1
                Create(1,n,root[i],temp,i,1);
            }
            mp[val[i]]=i;
        }

        for(int i=0;i<m;++i)
        {
            scanf("%d %d",&lef,&rig);
            printf("%d\n",Query(1,n,root[rig],lef));//在rig的历史版本上找(lef,rig)的值
        }

    return 0;
}

Measured memory_bytes: 241204
#include<bits/stdc++.h>
#include"unistd.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
int N,A[100005];
int perm[100005];
void calc(){
	perm[1]=1;
	REP(i,N+1)(perm[1]*=i)%=mod;
	for(int i=2;i<=N;i++)perm[i]=perm[1]*mod_pow(i,mod-2)%mod;
	REP(i,N+1)(perm[i+1]+=perm[i])%=mod;
}
signed main(){
	cin>>N;
	calc();
	int ans=0;
	rep(i,N){
		int a;cin>>a;
		int memo=(perm[i+1]-perm[1]+mod)%mod;
		int memo2=(perm[N-i]-perm[1]+mod)%mod;
		ans+=a*(memo+memo2+perm[1])%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};
 
    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }
 
    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = max(a+b, a*b);
    ans = max(ans, a-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}

ll n;
vector<int> c;
vector<vector<int>> g;
vector<ll> ans;
vector<ll> siz;

ll sdfs(int pre,int now){
    ll ret=1;
    for(auto to:g[now])if(pre!=to) ret+=sdfs(now,to);
    return siz[now]=ret;
}


map<ll,ll> dfs(int pre,int now){
    map<ll,ll> ret;
    for(auto &to:g[now])if(pre!=to){
        auto mp=dfs(now,to);
        ll k=siz[to]-mp[c[now]];
        ans[c[now]]+=k*(k+1)/2;
        if(ret.size()<mp.size()) swap(ret,mp);
        for(auto &p:mp) ret[p.first]+=p.second;
    }
    ret[c[now]]=siz[now];
    return ret;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    cin>>n;
    c.resize(n);g.resize(n);ans.resize(n,0);siz.resize(n);
    rep(i,n){
        cin>>c[i];c[i]--;
    }
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    sdfs(-1,0);
    auto res=dfs(-1,0);
    rep(i,n){
        ll k=n-res[i];
        cout<<n*(n+1)/2-k*(k+1)/2-ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 74224
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[110];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    scanf("%s",ss+1);int len=strlen(ss+1);
    int n=read();
    if(n==1)pr2(ss[1]-'0'+(len-1)*9);
    else if(n==2)
    {
    	int ans=0;
    	for(int i=1;i<=len;i++)
    	{
    		for(int j=i+1;j<=len;j++)
    		{
    			for(int k1=1;k1<=9;k1++)
    			{
    				for(int k2=1;k2<=9;k2++)
    				{
    					bool bk=true;
    					for(int k=1;k<=len;k++)
    					{
    						int uf=0;
    						if(k==i)uf=k1;
							if(k==j)uf=k2;
							if(ss[k]-'0'>uf){break;}
    						if(ss[k]-'0'<uf){bk=false;break;}
    					}
    					if(bk==true)ans++;
    				}
    			}
    		}
    	}
    	pr2(ans);
    }
    else
    {
    	int ans=0;
    	for(int i=2;i<=len;i++)
    	{
    		for(int j=i+1;j<=len;j++)
    		{
    			if(j<len)ans+=9*9*9*(i-1);
    			else ans+=(ss[1]-'0'-1)*9*9*(i-1);
    		}
    	}
    	for(int i=2;i<=len;i++)
    	{
    		for(int j=i+1;j<=len;j++)
    		{
    			for(int k1=1;k1<=9;k1++)
    			{
    				for(int k2=1;k2<=9;k2++)
    				{
    					bool bk=true;
    					for(int k=2;k<=len;k++)
    					{
    						int uf=0;
    						if(k==i)uf=k1;
							if(k==j)uf=k2;
							if(ss[k]-'0'>uf){break;}
    						if(ss[k]-'0'<uf){bk=false;break;}
    					}
    					if(bk==true)ans++;
    				}
    			}
    		}
    	}
 		pr2(ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ar1[b];
    int ar2[a];
    for(int i=0;i<b;i++)
    {
        ar1[i]=a;
    }
    for(int i=0;i<a;i++)
    {
        ar2[i]=b;
    }
    if(ar1[0]>ar2[0]){
        for(int i=0;i<a;i++)
        {
            cout<<ar2[i];
        }
    }
    else{
        for(int i=0;i<b;i++)
        {
            cout<<ar1[i];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n;cin>>n;
    vector<plli> a(n);
    flli(i,0,n-1)
    {
    	cin>>a[i].first>>a[i].second;
    }
    flli(i,1,n-2)
    {
    	if(a[i-1].first==a[i-1].second && a[i].first==a[i].second && a[i+1].first==a[i+1].second)
    	{
    		cout<<"Yes";
    		return 0;
    	}
    }
    cout<<"No";
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3840
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = (1e5 + 10) * 3, P = 998244353;
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
inline int mul(int a,int b){return ll(a)*b%P;}
int fac[N] = {1} , ifac[N] , pw[N] = {1} , ipw[N] = {1};
int inv(int x){return x == 1 ? 1 : P-ll(P/x)*inv(P%x)%P;}
inline int comb(int a,int b){return mul(fac[a],mul(ifac[b],ifac[a-b]));}
int n , m , lsum[N];
string A , B , C , D;

int solve(){
    int left = 0;
    for(auto ch : A) left += ch == '1';
    int base = 0 , up = 0 , down = 0;
    rep(i,0,m) {
        lsum[i] = i ? lsum[i-1] : 0;
        if(C[i] == '1' || D[i] == '1') {
            if(left == 0) pp(lsum[i] , mul(ipw[base] , up == 0 && down == 0));
            else pp(lsum[i] , mul(ipw[base] , comb(left + up + down - 1 , left - 1)));
        }
        up += C[i] == '1';
        down += D[i] == '1';
        if(C[i] == '1' && D[i] == '1') base++;
    }
    int right = 0;
    for(auto ch : B) right += ch == '1';
    base = 0 , up = 0 , down = 0;
    int res = 0;
    per(i,0,m) {
        int tmp = 0;
        if(right == 0) tmp = mul(ipw[base] , up == 0 && down == 0);
        else tmp = mul(ipw[base] , comb(right + up + down - 1 , right - 1));
        up += C[i] == '1';
        down += D[i] == '1';
        if(C[i] == '1' || D[i] == '1') pp(res , mul(lsum[i] , tmp));
        if(C[i] == '1' && D[i] == '1') base++;
    }
    return mul(res , pw[base]);
}

int main(){
    rep(i,1,N) fac[i] = mul(fac[i-1] , i);
    ifac[N-1] = inv(fac[N-1]);
    per(i,1,N) ifac[i-1] = mul(ifac[i] , i);
    int inv2 = inv(2);
    rep(i,1,N) pw[i] = mul(pw[i-1] , 2);
    rep(i,1,N) ipw[i] = mul(ipw[i-1] , inv2);
    cin >> n >> m;
    cin >> A >> B >> C >> D;
    int ans = solve();
    swap(n , m);
    swap(A , C);
    swap(B , D);
    pp(ans , solve());
    bool has = false;
    for(auto ch : A) has |= ch == '1';
    for(auto ch : B) has |= ch == '1';
    for(auto ch : C) has |= ch == '1';
    for(auto ch : D) has |= ch == '1';
    if(has == false) ans ++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5888
#include<algorithm>
#include<vector>
#include<iostream>
int main(){
    int N,K;
    std::cin>>N>>K;
    std::vector<int> p(N);
    int sum;
    for(auto& price:p){
        std::cin>>price;
    }
    std::sort(p.begin(),p.end());
    sum=0;
    for(int i=0;i<K;++i){
        sum+=p[i];
    }
    std::cout<<sum;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
ll n;
Vi a;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(3*n);
    rep(i,3*n){
        cin>>a[i];
    }
    priority_queue< ll ,vector<ll>,greater<ll>> fr;
    ll fs = 0;
    priority_queue<ll> bk;
    ll bs = 0;
    Vi frs(n+1,0);
    Vi bks(n+1,0);
    rep(i,n){
        fs += a[i];
        fr.push(a[i]);
    }
    frs[0]=fs;
    rep(i,n){
        bs += a[3*n-1-i];
        bk.push(a[3*n-1-i]);
    }
    bks[0]=bs;
    rep(i,n){
        ll tp = fr.top();
        if(tp<a[n+i]){
            fr.pop();
            fr.push(a[n+i]);
            fs += a[n+i]-tp;
        }
        frs[i+1]=fs;
    }
    rep(i,n){
        ll tp = bk.top();
        if(tp>a[2*n-i-1]){
            bk.pop();
            bk.push(a[2*n-i-1]);
            bs += a[2*n-i-1] - tp;
        }
        bks[i+1]=bs;
    }
    ll ans = -INF;
    rep(i,n+1){
        chmax(ans,frs[i]-bks[n-i]);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 6516
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		for (int i = a; i <= b * a; i += a) {
			if (i % b == c) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int mapp[200010];
int dp[200010];

int main(){
	int n;
	int k;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&mapp[i]);
	}
	memset(dp,inf,sizeof dp);
	dp[1]=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=k && i+j<=n;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(mapp[i]-mapp[i+j]));
		}
	}
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  int d[10][10],a[n][m];
  rep(i,10)rep(j,10) R d[i][j];
  rep(i,n)rep(j,m) R a[i][j];
  rep(k,10)rep(i,10)rep(j,10) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  ll ans=0;
  rep(i,n) {
    rep(j,m) {
      if(a[i][j]!=-1) ans+=d[a[i][j]][1];
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#include<iostream>
#include<queue>

struct P{
	int x, y;
};

const int MAX_H = 1000, MAX_W = 1000, MAX_CN = 10, INF = 1<<24;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int h, w, cn;
int map[MAX_H][MAX_W], d[MAX_H][MAX_W];
P ps[MAX_CN];
//ps x y の順
//map 通れる1 通れない0
//used 通ってない0 通った1
//d d[y][x] spから(x,y)までの最短距離

int main(){
	std::cin >> h >> w >> cn;
	for(int i=0;i<h;i++){
		std::fill(map[i], map[i]+w, 0);
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			std::cin >> c;
			if(c == 'S'){
				ps[0].x = j;
				ps[0].y = i;
				map[i][j] = 1;
			}else if('1' <= c && c <= '9'){
				ps[c-'0'].x = j;
				ps[c-'0'].y = i;
				map[i][j] = 1;
			}else if(c == '.'){
				map[i][j] = 1;
			}
		}
	}

	int res = 0;
	for(int i=0;i<cn;i++){//ps[i] -> ps[i+1]への最短路を調べる．それを足せばいい
		P sp = ps[i], gp = ps[i+1];
		for(int i=0;i<h;i++){
			std::fill(d[i], d[i]+w, INF);
		}
		d[sp.y][sp.x] = 0;
		std::queue<P> pq;
		pq.push(sp);

		while(!pq.empty()){
			P p = pq.front();pq.pop();
			if(p.x == gp.x && p.y == gp.y){
				break;
			}
			for(int i=0;i<4;i++){
				int nx = p.x+dx[i], ny = p.y+dy[i];
				if(nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] && d[ny][nx] == INF){
					pq.push({nx, ny});
					d[ny][nx] = d[p.y][p.x] + 1;
				}
			}
		}

		res += d[gp.y][gp.x];
	}
	
	std::cout << res << std::endl;
}

Measured memory_bytes: 9028
#include <iostream>
#include <vector>

long f(long n){
      long ans = 0;
      while(n % 2 == 0){
            ans++;
            n /= 2;
      }
      return ans;
}
using namespace std;
int main(void){
    int n;
    cin >> n;
    long ans = 0;
    vector<long> a(n);
    for(int i = 0;i < n;i++){
          cin >> a[i];
          ans += f(a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3700