akhauriyash/Code-Regression huggingface dataset:
n,u,v=map(int,input().split())
u-=1;v-=1
ki=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  ki[a-1].append(b-1)
  ki[b-1].append(a-1)
ha=[]
for i in range(n):
  if len(ki[i])==1:
    ha.append(i)
ta=[0]*n
ao=[0]*n
from collections import deque
d=deque()
d.append(u)
visited=[False]*n
visited[u]=True
while d:
  g=d.popleft()
  for i in ki[g]:
    if visited[i]:
      continue
    d.append(i)
    visited[i]=True
    ta[i]=ta[g]+1
d=deque()
d.append(v)
visited=[False]*n
visited[v]=True
while d:
  g=d.popleft()
  for i in ki[g]:
    if visited[i]:
      continue
    d.append(i)
    visited[i]=True
    ao[i]=ao[g]+1
if u in ha and ki[u][0]==v:
  print(0)
  exit()
m=0
for i in ha:
  if ta[i]<ao[i]:
    m=max(m,ao[i])
print(m-1)

Measured memory_bytes: 30496
s = input()[::-1]
i = 0
while i != len(s):
  if s[i] == 'm':
    if s[i:i+5] == 'maerd':
      i += 5
    else:
      print('NO')
      break
  elif s[i] == 'e':
    if s[i:i+5] == 'esare':
      i += 5
    else:
      print('NO')
      break
  elif s[i] == 'r': 
    if s[i:i+6] == 'resare':
      i += 6
    elif s[i:i+7] == 'remaerd':
      i += 7
    else:
      print('NO')
      break
  else:
    print('NO')
    break
else:
  print('YES')

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

#define pb push_back

vector<int>g[100003];
vector<int>v(100003);
queue<int>q;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    for(char i='a';i<='z';i++)
    {
        if(s1+i==s2)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 5980
#include <stdio.h>
#include <math.h>


int main(void) {
	int n, i;
	int s[1001] = {0};
	double mean, dev, tmp, sum;

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		sum = 0;
		dev = 0;
		for (i = 0; i < n; ++i) {
			scanf("%d", &s[i]);
			sum += s[i];
		}
		mean = sum / n;
		for (i = 0; i < n; ++i) {
			dev += pow(mean - s[i], 2);
		}
		printf("%lf\n", sqrt(dev/n));
	}
	return 0;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    string a = s.substr(0,2);
    string b = s.substr(2,2);
    int m = stoi(a);
    int n = stoi(b);
    bool y = false, z = false;
    if(m<=12&&m>0) z = true;
    if(n<=12&&n>0) y = true;
    string ans;
    if(z){
        if(y) ans = "AMBIGUOUS";
        else ans = "MMYY";
    } else {
        if(y) ans = "YYMM";
        else ans = "NA";
    }
    print(ans);
    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;
const int M = 1000 * 1000 + 13;
const int AL = 26;

int n;
string a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	static char buf[M];
	forn(i, n){
		scanf("%s", buf);
		a[i] = buf;
	}
	return true;
}

struct node{
	int nxt[AL];
	int cnt[AL];
	node(){
		memset(nxt, -1, sizeof(nxt));
		memset(cnt, 0, sizeof(cnt));
	}
	int& operator [](int x){
		return nxt[x];
	}
};

int siz;
node trie[M];
int lst[AL];

void add(string s){
	memset(lst, -1, sizeof(lst));
	reverse(all(s));
	forn(i, sz(s)) lst[s[i] - 'a'] = i;
	int cur = 0;
	forn(i, sz(s)){
		int c = s[i] - 'a';
		forn(j, AL) if (lst[j] >= i)
			++trie[cur].cnt[j];
		if (trie[cur][c] == -1){
			trie[cur][c] = siz;
			trie[siz++] = node();
		}
		cur = trie[cur][c];
	}
}

int ask(string s){
	reverse(all(s));
	int cur = 0;
	forn(i, sz(s) - 1){
		int c = s[i] - 'a';
		if (trie[cur][c] == -1)
			return 0;
		cur = trie[cur][c];
	}
	return trie[cur].cnt[s.back() - 'a'];
}

void solve() {
	li ans = 0;
	forn(_, 2){
		siz = 0;
		trie[siz++] = node();
		forn(i, n){
			ans += ask(a[i]);
			add(a[i]);
		}
		reverse(a, a + n);
	}
	printf("%lld\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;

    uint64_t result = 1;

    const uint64_t divisor = std::pow(10, 9) + 7;

    for(int i=1; i<= n; ++i)
    {
        result *= i;
        result = result % divisor;
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main
{
	public static void main(String[] args) {
		BufferedReader in = null;
		try {
			in = new BufferedReader(
				new InputStreamReader(System.in)
				);
			while (true) {
				String[] inputs = in.readLine().split(" ");
				int a = Integer.parseInt(inputs[0]);
				int b = Integer.parseInt(inputs[1]);
				if ((a == 0) && (b == 0)) {
					break;
				}
				if (a < b) {
					System.out.printf("%d %d\n", a, b);
				} else {
					System.out.printf("%d %d\n", b, a);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				
			}
		}
		
	}
}

Measured memory_bytes: 30792
/*
power code taken from geeks for geeks
*/

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001

using namespace std;
typedef long long ll;
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0) return 1LL;
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
    if (p % 2 == 1) P = (P * k) % MODD;
    return P;
}


void solve(){
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    // cout<<"n "<<n<<" k "<<k<<endl;
    ll a[n+1];
    a[0]=0;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    ll cur=1;
    bool mark[MAX_N];
    memset(mark, 0, sizeof(mark));

    ll rem=k;

    while(mark[cur]==0){
        // cout<<"cur "<<a[cur]<<endl;
        mark[cur]=1;
        cur=a[cur];
        rem-=1LL;
        if(rem==0){
            // cout<<"here"<<endl;
            cout<<cur<<endl;
            return;
        }
    }
    rem++;
    
    ll st=cur;
    
    // cout<<st<<" cur "<<cur<<endl;

    vector<ll> vec;
    vec.push_back(st);
    cur=a[cur];
    while(st!=cur){
        vec.push_back(cur);
        cur=a[cur];
    }

    // cout<<"vec ";
    // for(ll i=0;i<vec.size();i++){
    //     cout<<vec[i]<<" ";
    // }cout<<endl;

    // cout<<"rem "<<rem<<endl;

    ll len=vec.size();
    ll idx=rem%len;
    idx--;
    if(idx<0){
        idx=len-1;
    }
    cout<<vec[idx]<<endl;
}


int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t=1;
    
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5944
#include <stdio.h>

int main()
{
        int n;
        int R[200000];

        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
                scanf("%d", &R[i]);
        }

        int min = R[0];
        int max_profit = -1000000000;

        for (int i = 1; i < n; i++) {
                int temp;
                temp = R[i] - min;

                if (max_profit < temp) {
                        max_profit = temp;
                }

                if (min > R[i]) {
                        min = R[i];
                }
        }

        printf("%d\n", max_profit);

        return 0;
}


Measured memory_bytes: 2584
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n;
int main(){
	cin>>n;
	ll sum=0;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			ll k=n/i;
			k-=1;
			if(k>0 && n%k==n/k) sum+=k;
			//if(i-1>0 && n/(i-1)==n%(i-1)) sum+=i-1;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int cnt = 0;
    rep(i, n){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3916
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var A = G();
		int m = A.Min(), M = A.Max(), mi = 0, Mi = 0;
		while (A[mi] != m) mi++;
		while (A[Mi] != M) Mi++;
		if (m >= 0)
		{
			Console.WriteLine(N - 1);
			for (var i = 1; i < N; i++) Console.WriteLine("{0} {1}", i, i + 1);
		}
		else if (M <= 0)
		{
			Console.WriteLine(N - 1);
			for (var i = N - 1; i > 0; i--) Console.WriteLine("{0} {1}", i + 1, i);
		}
		// m < 0 && M > 0
		else if (M >= -m)
		{
			Console.WriteLine(2 * N - 1);
			for (var i = 0; i < N; i++) Console.WriteLine("{0} {1}", Mi + 1, i + 1);
			for (var i = 1; i < N; i++) Console.WriteLine("{0} {1}", i, i + 1);
		}
		else
		{
			Console.WriteLine(2 * N - 1);
			for (var i = 0; i < N; i++) Console.WriteLine("{0} {1}", mi + 1, i + 1);
			for (var i = N - 1; i > 0; i--) Console.WriteLine("{0} {1}", i + 1, i);
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>

int main() {
  std::string str;
  std::string key;

  std::getline(std::cin, str);
  std::getline(std::cin, key);

  str += str;

  bool iskey = false;
  if(str.find(key) != std::string::npos) iskey = true;

  if(iskey) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3188
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n) // aをソートしたもの
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
		b[i] = a[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	for i := 0; i < n; i++ {
		if a[i] == b[0] {
			fmt.Println(b[1])
		} else {
			fmt.Println(b[0])
		}
	}
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,T;
    cin >> N >> M >> T;
    int a[N+1];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    a[N]=T;
    int ans=a[0]-M+max(T-(a[N-1]+M),0);
    for(int i=0;i<N-1;i++){
        ans+=max(0,a[i+1]-M-(a[i]+M));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<ll, ll> P;

void print_line(vector<vector<int>> &ans) {
    for (int i = 0; i < ans.size(); i++) {
        for (int y = 0; y < ans[i].size(); y++) {
            cout << ans[i][y];
        }
        cout << endl;
    }
}

int main() {
    ll n, m;
    cin >> n >> m;

    // どっちが足を引っ張ってるか
    if (n * 2 > m) {
        // cが足りない
        cout << m / 2 << endl;
        return 0;
    }

    ll z = (m - (2 * n)) / 4;
    cout << n + z << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  string ans="No";
  if(a<=c && c<=b){
    ans="Yes";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        boolean flag = s[0]=='A';
        int c = 0, a = 0;
        for (int i = 2; i < s.length-1; i++) {
            if(s[i]=='C') c++;
        }
        for (int i = 0; i < s.length; i++) {
            if(s[i]<='z'&&s[i]>='a') a++;
        }
        flag = flag&&(c==1)&&(a==s.length-2);
        out.println(flag?"AC":"WA");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/
void debug(queue<pair<int, ll>> q){
    while(!q.empty()){
        auto x = q.front();
        q.pop();
        cerr<<"{"<<x.first<<", "<<x.second<<"}, ";
    }
    cerr<<endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,D,A;
    cin>>N>>D>>A;

    vector<pair<ll,ll>> XH(N);
    vector<ll> X(N),H(N);
    rep(i,N){
        cin>>XH[i].first>>XH[i].second;
    }
    sort(all(XH));
    rep(i,N){
        X[i] = XH[i].first;
        H[i] = (XH[i].second + A - 1) / A;
    }
    //print(X);print(H);

    /*queueの中に必要なもの
    {index, そこでの爆発回数}
    */
    ll sumq = 0;
    queue<pair<int,ll>> q;
    ll ans = 0;
    rep(i,N){
        //左端の設定
        while(!q.empty()){
            auto l = q.front().first;
            auto h = q.front().second;
            if(X[l] < X[i] - 2 * D){
                sumq -= h;
                q.pop();
            }
            else break;
        }
        //debug(q);
        //cerr<<sumq<<endl;
        //すでに起こった爆発
        H[i] -= sumq;
        if(H[i] <= 0)continue;
        //今起こった爆発を記録
        ans += H[i];
        sumq += H[i];
        q.push({i, H[i]});
    }
    cout<<ans<<endl;
}

/*あるiを見たとき
すでにある爆発でいくら減ってるかを計算したい
左端がどこまで効いてくるのかを考えたい

qの中には,過去の履歴が残っている
*/


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,u,v;
	
	cin>>n;
	vector<int> adj[n+1];
	vector<pair<int, int> > edges;
	for(int i=0;i<n-1;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		edges.push_back({u,v});
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(ans<adj[i].size())ans=adj[i].size();
	
	queue<int> q;
	map<pair<int, int>, int> color;
	bool vis[n+1];
	memset(vis, 0, sizeof vis);
	q.push(1);
	vis[1]=1;
	int colp[n+1];
	memset(colp, 0, sizeof colp);
	while(!q.empty())
	{
		v=q.front();q.pop();
		int col=1;
		
		for(auto u: adj[v])
		{
			if(vis[u])continue;
			if(colp[v]==col)col++;
			colp[u]=color[{u,v}]=color[{v,u}]=col;
			col++;
			
			q.push(u);vis[u]=1;
		}
		
		
		
	}
	cout<<ans<<"\n";
	for(auto x : edges)
	{
		cout<<color[x]<<"\n";
	}
}

Measured memory_bytes: 19828
#入力値処理
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    one = 0
    for a in A:
        if (a >> i & 1) == 1:
            one += 1
    ans += one * (N - one) * 2 ** i
    ans %= mod
print(ans)


Measured memory_bytes: 122936
import Data.Bool

main = do
  [n,k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  putStrLn $ bool "IMPOSSIBLE" "POSSIBLE" (getDiff n k as)

getDiff n k as
  | mod k d == 0 && k <= maximum as = True
  | otherwise = False
  where
    d = foldr1 gcd as

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

int main(){
	int N,loop;
	cin >> N;
	long long A=1,ain;
	int Astr,ainstr;
	for(loop=0;loop<N;loop++){
		cin >> ain;
		Astr=(int)to_string(A).length()-1;
		ainstr=(int)to_string(ain).length()-1;
		if(ain==0){
			A=0;
			break;
		}else if(A==-1){
			continue;
		}
		if(Astr+ainstr>18){
			A=-1;
		}else if(Astr+ainstr==18){
			if(A/pow(10,Astr)*ain/pow(10,ainstr)>2){
				A=-1;
			}else{
				A *= ain;
				if(A>1000000000000000000) A=-1;
			}
		}else if(Astr+ainstr==17){
			A *= ain;
			if(A>1000000000000000000) A=-1;
		}else{
			A *= ain;
		}
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    long double ans = v[0];
    FOR(i, 1, N) {
        ans += v[i];
        ans /= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17356
// 2011/05/24 Tazoe

#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

double trian(double x0, double y0, double x1, double y1, double x2, double y2)
{
	double a = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
	double b = sqrt((x2-x0)*(x2-x0)+(y2-y0)*(y2-y0));
	double c = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

	double z = (a+b+c)/2.0;

	return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main()
{
	double S = 0.0;

	double x[20], y[20];
	int i = 0;
	while(true){
		if(i>=20)
			break;

		string str;
		cin >> str;
		if(cin.eof())
			break;

		for(int j=0; j<str.size(); j++)
			if(str[j]==',')
				str[j] = ' ';

		istringstream ist(str);
		ist >> x[i] >> y[i];

		if(i>=2)
			S += trian(x[0], y[0], x[i-1], y[i-1], x[i], y[i]);

		i++;
	}

	cout.precision(8);
	cout << fixed << S << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
	int n,x,y,w,h,m;
	cin>>n;
	while(n--){
		int count = 0;
		cin>>x>>y>>w>>h>>m;
		while(m--){
			int X,Y;
			cin>>X>>Y;
			if(x<=X&&X<=x+w&&y<=Y&&Y<=y+h)count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
H = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1]<H[b-1]:
        ans[a-1] = 0
    elif H[b-1]<H[a-1]:
        ans[b-1] = 0
    else:
        ans[a-1], ans[b-1] = 0, 0
print(sum(ans))


Measured memory_bytes: 20060
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	long long a,b,c;

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

	if (c <= a + b + 1)
	{
		printf("%lld\n", b + c);
	}

	else
	{
		printf("%lld\n", a + b + b + 1);
	}

	return 0;
}

Measured memory_bytes: 128
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N], B[N], C[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
	for (ll i = 0; i < N; ++i) cin >> B[i];
	for (ll i = 0; i < N; ++i) cin >> C[i];
 
	// 解法
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);
	// sort(C, C + N, greater<ll>());
	
	ll ans = 0;
	ll c = 0;
	ll a = 0;
	
	for (ll b = 0; b < N; ++b){
		while(C[c]<=B[b] & c<N){
			c++;
		}while(B[b]>A[a] & a<N){
			a++;
		}
		// printf("idx %lld %lld %lld\n", c,b,a);
		// printf("%lld %lld %lld\n", C[c],B[b],A[a]);
		ll plus = (a)*(N-c);
		// printf("+ %lld\n", plus);
		ans += plus;	
	}
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	while(1){
		llong n, m;
		scanf("%lld%lld", &n, &m);
		if(n==0) return 0;

		vector<llong> v(n);
		REP(i, n){
			scanf("%lld", &v[i]);
		}
		v.push_back(0);
		n++;

		vector<llong> a;
		REP(i, n){
			REP(j, n){
				a.push_back(v[i]+v[j]);
			}
		}
		VSORT(a);

		llong ans=0;
		REP(i, n){
			REP(j, n){
				llong tmp=v[i]+v[j];
				llong k=upper_bound(a.begin(), a.end(), m-tmp)-a.begin();
				if(k==a.size()) continue;
				k--;

				if(k>=0) ans=max(ans, tmp+a[k]);
			}
		}

		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 17160
import java.io.*;
import java.util.*;
import java.math.BigDecimal;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();
		System.out.println(a.multiply(b).toBigInteger());
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 37404
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main(void){
	long double a,b,c;
	cin >> a >> b >> c;

	long double eps = 1.0E-14;
 	if(sqrt(a) + sqrt(b) + eps < sqrt(c))
		cout << "Yes" << endl;
    else
 		cout << "No" << endl;
 	

 	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

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

  ll N, M;
  cin >> N >> M;
  vector<ll> vec_l;
  vector<ll> vec_r;
  for (ll i = 0; i < M; ++i) {
    ll l, r;
    cin >> l >> r;
    vec_l.push_back(l);
    vec_r.push_back(r);
  }

  sort(vec_l.begin(), vec_l.end(), std::greater<ll>());
  sort(vec_r.begin(), vec_r.end());

  ll l, r;
  l = vec_l[0];
  r = vec_r[0];
  ll ans = r - l + 1;
  if (ans < 0) {
    ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;

  int mn = 1e9 + 1, ans = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (mn > a) {
      ans = i + 1;
      mn = a;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3096
S = input()
V = [0] * len(S)

state = 'R'
cnt = 0
for i, c in enumerate(S):
    if state == 'R':
        if c == 'R':
            cnt += 1
        else:
            V[i - 1] += cnt // 2 + cnt % 2
            V[i] += cnt // 2
            state = 'L'
            L = i
            cnt = 1
    else:
        if c == 'L':
            cnt += 1
        else:
            V[L] += cnt // 2 + cnt % 2
            V[L - 1] += cnt // 2
            state = 'R'
            cnt = 1
else:
    V[L] += cnt // 2 + cnt % 2
    V[L - 1] += cnt // 2


for i in range(len(S) - 1):
    print(V[i], end=' ')
print(V[len(S) - 1])


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

int main(void) {

  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  rep (i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{  
  int n;
    cin>>n;int ans=0;vi adj(n+1),ar(n+1);
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x>y)swap(x,y);
        adj[y]+=x;
    }
    ar[1]=1;ans=1;
    for(int i=2;i<=n;i++)
    {
        ar[i]=1+ar[i-1]+i-1-adj[i];
        ans+=ar[i];
    }
    cout<<ans<<endl;
}

signed main()
{ 
    boost
    int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    ll ans = 1;
    ll tmp = 1;
    bool flag = false;

    rep(i, N)
    {
        ll a;
        cin >> a;

        if (!a) {
            cout << 0 << endl;
            return 0;
        }


        if (ans > 1000000000000000000 / a) {
            flag = true;
        }


        ans *= a;
        /*        if (ans / a != tmp) {
            flag = true;
        }
*/
        tmp = ans;
    }

    if (flag) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


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

#define scl(x) scanf("%lld",&x)
#define sc(x)  scanf("%d",&x)
#define ll long long
#define lop(i,n) for(int i=0;i<n;++i)
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

const int mod=998244353,mN=3e5+100;

inline int add(int a,int b){
   a+=b;
   if(a<0)a+=mod;
   if(a>=mod)a-=mod;
   return a;
}
inline int mul(int a,int b){
   ll ret=1LL*a*b;
   if(ret>=mod)ret%=mod;
   return ret;
}
inline int pwm(int a,ll p){
   int m=a,ret=1;
   while(p){
      if(p&1)ret=mul(ret,m);
      m=mul(m,m);
      p>>=1;
   }
   return ret;
}
int fact[mN];
inline int nCr(int n,int r){
	if(r>n||r<0)return 0;
	return mul( mul( fact[n] , pwm(fact[n-r],mod-2) ) , pwm(fact[r], mod-2 )) ;
}

int n,a,b;
ll k;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("i.txt", "r", stdin);
#endif
    fact[0]=1;
    for(int i=1;i<mN;i++)
    	fact[i]=mul(i,fact[i-1]);
    cin>>n>>a>>b>>k;
    int out = 0;
    for(int r=0;r<=n && 1LL*r*a<=k ;r++){
    	ll rem = k-1LL*r*a;
    	if(rem%b)continue;
    	ll B=rem/b;
    	if(B>n)continue;
    	out =add(out, mul(nCr(n,r),nCr(n,B)) );
    }
    cout<<out<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  int D;
  cin >>A>>B>>C>>D;
  int x=A*B;
  int y=C*D;
  int z=max(x,y);
  cout << z<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int r1,r2,c1,c2;
long long fac[2000100],finv[2000100],inv[2000100];
long long mod=1000000007;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>r1>>c1>>r2>>c2;
	inv[1]=1LL;
	for(int i=2;i<=2000010;i++){
		inv[i]=(mod-((mod/i)*inv[mod%i])%mod);
		if((i*inv[i])%mod!=1){
			cout<<"ERROR:"<<i<<endl;
			return 0;
		}
	}
	fac[0]=1LL;
	for(int i=1;i<=2000010;i++)
		fac[i]=(fac[i-1]*i)%mod;
	finv[0]=1LL;
	for(int i=1;i<=2000010;i++)
		finv[i]=(finv[i-1]*inv[i])%mod;
	long long ans=0LL;
	for(int i=c1;i<=c2;i++){
		ans+=((fac[r2+i+1]*finv[i+1])%mod*finv[r2])%mod;
		ans-=((fac[r1-1+i+1]*finv[i+1])%mod*finv[r1-1])%mod;
		ans%=mod;
		ans+=mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 47104
// 問題URL
// https://atcoder.jp/contests/abc131/tasks/abc131_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] ar = str.split("");
        int[] iar = Stream.of(ar).mapToInt(Integer::parseInt).toArray();

        boolean flag = false;
        for(int i =0; i < 4; i++) {
            for(int j =i; j < iar.length; j++) {
                if ( i == j) continue;
                if(iar[i] == iar[j]) {
                    flag = true;
                }
                break;
            }
        }
        if(flag) {
            System.out.println("Bad");
        }else {
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 26700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int n;
  cin >> n;
  vec1 p(n);
  for(int i = 0; i < n; i++) { cin >> p.at(i); }

  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());

  int ans = p.at(0) / 2;
  for(int i = 1; i < n; i++) {
    ans = ans + p.at(i);
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];

    long long mi = 1LL << 60;
    int mii = -1;
    for (int i = 0; i < n; ++i) {
        if (mi > abs(sum - a[i] * n)) mi = abs(sum - a[i] * n), mii = i;
    }

    cout << mii << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>
#include <bitset>
#include <numeric>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;

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

    multiset<int> v;
    v.insert(a[0]);
    for (int i = 1; i < n; i++)
    {
        auto it = v.lower_bound(a[i]);
        if (it != v.begin())
        {
            v.erase(--it);
        }
        v.insert(a[i]);
    }

    cout << v.size() << endl;
}

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

template <typename T>
void print(const T &v);

int main()
{
    string s;
    cin >> s;
    int start = 0, goal = 0;
    bool a_flag = false; // Aがすでに発見された -> true

    for (int i = 0; i < s.size(); i++)
    {
        if (a_flag == false)
        {
            if (s.at(i) == 'A')
            {
                start = i;
                a_flag = true;
            }
        }
        if (s.at(i) == 'Z')
        {
            goal = i;
        }
    }
    cout << goal - start + 1 << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 640
import java.io.*;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = new String(in.readLine());
        String[] field = s.split(" ", 0);
        
        Integer allTrain = Integer.valueOf(field[0]);
        Integer frontTrain = Integer.valueOf(field[1]);
        
        // 制約
        if (allTrain >= 1 && allTrain <= 100 && frontTrain >= 1 && frontTrain <= allTrain) {
        	Integer backTrain = allTrain - frontTrain + 1;
        	System.out.println(backTrain);
        }
    }
}

Measured memory_bytes: 22740
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define int ll 
using namespace std;             
 
const int N = 3005;
const int mod = 998244353; 
const ll INF = (ll)1e18 + 7;
int n, s, a[N];
pair <bool, ll> dp[N];
void solve () {
	dp[0].F = 1;
	dp[0].S = 0;
	cin >> n >> s;
	ll ans = 0;
	for (int i = 1; i <= n; i ++) cin >> a[i];
	for (int i = 1; i <= n; i ++) {
	
		if (s > a[i] && dp[s - a[i]].F == 1) ans += (n - i + 1) * dp[s - a[i]].S;
		if (s == a[i]) ans += ((n - i + 1) * i);
		ans %= mod;
		for (int j = s - 1; j >= 0; j --) {
			if (dp[j].F == 1 && j + a[i] <= s) {
				dp[j + a[i]].F = 1;
				dp[j + a[i]].S += dp[j].S;
				dp[j + a[i]].S %= mod;		
			}
		}
		if (a[i] < s) dp[a[i]].S += i;
		dp[a[i]].S %= mod;		
	}
	cout << ans;
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if((A == B && A == C && B ==C) || (A !=B && A !=C && B !=C))
      System.out.println("No");
    else System.out.println("Yes");
  }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(x...)
#endif
#define int long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define loop(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define F first
#define S second
const int mod =  1000000007;

void solving() {
	char ch;
	cin>>ch;
	if(ch>='A' and ch<='Z')	cout<<"A"<<endl;
	else	cout<<"a"<<endl;
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// int t{}; cin >> t; while (t--)
		solving();

	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int v,r;
  cin >> v >> r;
  vector<pair<ld,ld>> a(v);
  vector<vector<int>> c(v,vector<int>(0));
  rep(i,v) cin >> a[i].first >> a[i].second;
  int ff,gg;
  rep(i,r) {
    int f,g;
    cin >> f >> g;
    c[f-1].push_back(g-1);
    c[g-1].push_back(f-1);
  }
  ld ans=0;
  vector<int> b(v,0);
  rep(i,v){
    for (int j=i+1;j<v;j++){
      ld q=a[i].first,w=a[i].second,e=a[j].first,s=a[j].second;
      bool t=true;
      ld y=-3434343434;
      rep(k,v){
        if (k==i || k==j) continue;
        ld h=(s-w)*(a[k].first-q)+(e-q)*(w-a[k].second);
        if (y==-3434343434) y=h;
        if ((y<0 && h>0) || (y>0 && h<0)) t=false;
      }
      if (t) {
        ans+=sqrt(pow(e-q,2)+pow(s-w,2));
        b[i]=1;
        b[j]=1;
      }
    }
  }
  while(true){
    bool t=true;
    int q;
    ld w=inf;
    rep(i,v){
      if (b[i]==1) continue;
      t=false;
      ld y=inf;
      rep(j,c[i].size()){
        if (b[c[i][j]]==1){
          y=min(y,sqrt(pow(a[i].first-a[c[i][j]].first,2)+pow(a[i].second-a[c[i][j]].second,2)));
        }
      }
    if (y<w){
      q=i;
      w=y;
    }
    }
    if (t) break;
    ans+=w;
    b[q]=1;
  }
  cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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 (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    int a,b;
    cin >> a >> b;
    pf(a * b);
    return 0;
}


Measured memory_bytes: 3636