akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b >> c;
	cout << a * b / 2 << "\n";
	
	std::cin >> e;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
     
using namespace std;
     
int main(void){
     
  int a, b, c, cnt = 0;

  cin >> a >> b >> c;

  if(a != b) cnt++;
  if(a != c) cnt++;
  if(b != c) cnt++;
  if(cnt == 0) cnt++;

  cout << cnt << endl;
     
  return 0;
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,p,x,o,e;
int c[666][666];

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> p;
    for(int i = 1;i <= n;i++)
    {
        cin >> x;
        if(x & 1) o++;
        else e++;
    }
    int ans = 0;
    c[0][0] = 1;
    for(int i = 1;i <= 51;i++)
        for(int j = 0;j <= i;j++)
        {
            c[i][j] = c[i - 1][j] + (j ? c[i - 1][j - 1] : 0);
        }
    for(int i = 0;i <= o;i++)
    {
        for(int j = 0;j <= e;j++)
        {
            if(p == 0)
            {
                if(i % 2 == 0) ans += c[o][i] * c[e][j];
            }
            else
            {
                if(i & 1) ans += c[o][i] * c[e][j];
            }
        }
    }
    rc(ans);
}


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

long long r, c, k;
vector<vector<long long>> memo;
vector<vector<vector<long long>>> dp;

long long solve();

int main() {
  cin >> r >> c >> k;
  memo.resize(r, vector<long long>(c, 0));
  for (int i = 0; i < k; ++i) {
    int x, y, v;
    cin >> x >> y >> v;
    memo[--x][--y] = v;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dp.assign(r + 1, vector(c + 1, vector<long long>(4, 0)));
  for (int i = 0; i < r; ++i)
    for (int j = 0; j < c; ++j)
      for (int k = 0; k <= 3; ++k) {
        // use
        dp[i + 1][j + 1][1] =
            max(dp[i + 1][j + 1][1], dp[i][j + 1][k] + memo[i][j]);
        if (k)
          dp[i + 1][j + 1][k] =
              max(dp[i + 1][j + 1][k], dp[i + 1][j][k - 1] + memo[i][j]);
        // not use
        dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j + 1][k]);
        dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k], dp[i + 1][j][k]);
      }
  long long res = 0;
  for (int i = 0; i <= r; ++i)
    for (int j = 0; j <= c; ++j)
      for (int k = 0; k <= 3; ++k) res = max(res, dp[i][j][k]);
  return res;
}

Measured memory_bytes: 706592
#include <iostream>
using namespace std;
int main(){
	int N,n,Sn=0;
	cin>>N;
	n=N;
	while(N>0){
		Sn+=N%10;
		N=N/10;
	}
	if(n%Sn==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll sx, sy, tx, ty;

signed main() {
    cin >> sx >> sy >> tx >> ty;
    ll dx = tx - sx, dy = ty - sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << "L" << string(dy + 1, 'U') << string(dx + 1, 'R') << "D";
    cout << "R" << string(dy + 1, 'D') << string(dx + 1, 'L') << "U"
         << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys

def manhattan(px, py, x, y):
    return abs(px-x) + abs(py-y)

N = int(input())
pt = 0
px = 0
py = 0
for i in range(N):
    t, x, y = map(int,input().split())
    dist = manhattan(px, py, x, y)
    time = t - pt
    if (time % 2 != dist % 2) or time < dist:
        print("No")
        sys.exit()
    else:
        pt = t
        px = x
        py = y
print("Yes")

Measured memory_bytes: 46440
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var v = cin.ReadIntArray(N);
            Array.Sort(v);

            double sum = v[0];
            for (int i = 1; i < N; i++)
            {
                sum += (double)v[i];
                sum /= 2.0;
            }

            Console.WriteLine(sum);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    x = int(input())

    i = 1
    pre = 0
    current = i

    while True:
        if pre < x <= current:
            print(i)
            exit()

        pre = current
        i += 1
        current += i


Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<tuple>
using namespace std;
typedef long long ll;
int main(){
    ll h; cin >> h;
    ll w;cin >> w;
    ll cost[10][10];

    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> cost[i][j];
            
        }
    }
    ll grid[10];
    for(int i=0;i<10;i++){
        grid[i] = 0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ll tmp;cin >> tmp;
            if(tmp >=0){
                grid[tmp]++;
            }
        }
    }
    ll d[10];
    bool fin[10];
    for(int i=0;i<10;i++){
        fin[i] = false;
    }
    d[1] = 0;
    fin[1] = true;
    priority_queue <tuple<ll,ll,ll>> q;
    for(int i=0;i<10;i++){
        if(i == 1)continue;
        q.push(make_tuple((-1)*cost[i][1],i,1));
    }
    while(!q.empty()){
        tuple<ll,ll,ll> now = q.top();
        #if TEST
            cout << get<0>(now) << " " << get<1>(now) << " " << get<2>(now)<<endl;
        #endif
        q.pop();
        if(!fin[get<1>(now)]){
            fin[get<1>(now)] = true;
            d[get<1>(now)] = -get<0>(now);

        #if TEST
            cout << get<1>(now) << " " << d[get<1>(now)]<<endl; 
        #endif
            for(int i=0;i<10;i++){
                if(get<1>(now) == i)continue;
                if(fin[i])continue;
                q.push(make_tuple((-1)*(cost[i][get<1>(now)]+d[get<1>(now)]),i,get<1>(now)));
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<10;i++){
        if(i == 1)continue;
        ans += d[i]*grid[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int mr=0;
  int r=0;
  for(auto c:S){
    if(c==')')r++;
    else r--;
    mr=max(mr,r);
  }
  reverse(ALL(S));
  int ml=0;
  int l=0;
  for(auto c:S){
    if(c=='(')l++;
    else l--;
    ml=max(ml,l);
  }
  reverse(ALL(S));
  REP(i,mr)cout<<'(';
  cout<<S;
  REP(i,ml)cout<<')';
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    string s,t;
    cin>>s>>t;

    ll ans=lmax; 

    ll n=s.size(),m=t.size();

    f(i,0,n-m+1){
        ll p=0;
        f(j,0,m){
            if(s[i+j]!=t[j]) p++;
        }
        ans=min(ans,p);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3612
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> fav;
    long long r = 1, m;
    while (1) {
        if (r * (r + 1) >= N) {
            break;
        }
        m = (N - r) / r;
        if ((N - r) % r == 0 && N % m != 0) {
            fav.push_back(m);
        }
        r += 1;
    }

    long long ans = 0;
    for (int i = 0; i < fav.size(); i++) {
        ans += fav[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;

using namespace std;

int R, C, N;
vector<ll> w;

struct E{
    int to, cost;
    E(int t, int c): to(t), cost(c) {};
};
vector<vector<E> > edge;
ll rmin, cmin;

bool dfs(int v) {
    if(v < R) rmin = min(rmin, w[v]);
    else cmin = min(cmin, w[v]);
    REP(i, edge[v].size()) {
        E e = edge[v][i];
        if(w[e.to] != -1) {
            if(w[v]+w[e.to]!=e.cost) return false;
        } else {
            w[e.to] = e.cost - w[v];
            if(!dfs(e.to)) return false;
        }
    }
    return true;
}

int main(void) {
    int tr, tc, ta;
    cin >> R >> C >> N;

    edge.resize(R+C);
    REP(i, N) {
        cin >> tr >> tc >> ta;
        tr--; tc--;
        edge[tr].push_back(E(R+tc, ta));
        edge[R+tc].push_back(E(tr, ta));
    }

    w.resize(R+C);
    w.assign(R+C, -1);

    REP(i, R+C) {
        if(w[i] != -1 || edge[i].size() == 0) continue;
        w[i] = 0;
        rmin = numeric_limits<ll>::max();
        cmin = numeric_limits<ll>::max();
        if(!dfs(i) || rmin+cmin < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int X[300000];
int Xs[300000];

int main(){
    int N = 0;
    memset(X,0,sizeof(X));
    memset(Xs,0,sizeof(Xs));
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> X[i];
        Xs[i] = X[i];
    }
    sort(Xs,Xs+N);
    int lnum = Xs[N/2-1];
    int rnum = Xs[N/2];

    for(int i=0;i<N;i++){
        if(X[i] <= lnum) cout << rnum << endl;
        else if(X[i] >= rnum) cout << lnum << endl;
    }
    return 0;
}

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

int main()
{
  ll n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n)
  {
    if (a[i] == 0)
    {
      ans = 0;
      break;
    }
    if (ans <= (ll)1e18 / a[i])
    {
      ans *= a[i];
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;
int N;
int v[100005];

void yes()
{
    printf("YES\n");
    exit(0);
}

void no()
{
    printf("NO\n");
    exit(0);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    LL sum = 0;
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]), sum += v[i];
    LL clr = 1LL * N * (N + 1) / 2;
    if(sum % clr != 0)  no();
    LL moves = sum / clr;
    v[N + 1] = v[1];
    for(int i = 1; i <= N; i++)
    {
        LL dif = v[i + 1] - v[i];
        LL kd = moves - dif;
        if(kd % N != 0 || kd < 0) no();
    }

    yes();
    return 0;
}


Measured memory_bytes: 640
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from math import gcd

def main():
		n = int(input())
		ans = 0
		for i in range(1, n+1):
			for j in range(1, n+1):
				for k in range(1, n+1):
					ans+=gcd(gcd(i, j), k)
		print(ans)
		
		


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n") + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode("ascii"))
		self.read = lambda: self.buffer.read().decode("ascii")
		self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
	main()

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

int main(){
  string S;
  cin>>S;
  int ans=0;
    if(S=="RRR"){
      cout<<3;
    }
    else if(S=="RRS" || S=="SRR"){
      cout<<2;
    }
    else if(S=="SSS"){
      cout<<0;
    }
    else{
      cout<<1;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll k = min(b-1, n);
    cout << a*k/b << endl;
    return 0;
}

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

int main() {
   set<int> s;
   int a, b, k;
   cin >> a >> b >> k;
   for (int i = a; i < a+k; i++) {
      s.insert(i);
      if (i == b) break;
   }
   for (int i = b; i > b-k; i--) {
      s.insert(i);
      if (i == a) break;
   }

   for (int x : s) {
      cout << x << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char s[11];
    scanf("%s", s);
    for(int i=0; s[i]!='\0'; i++){
        if(s[0]=='B') {
            for(int j=0;s[j]!='\0';j++) s[j]=s[j+1];
            i=0;
        }
        else if(s[i]=='B'){
            if (s[i]+1=='\0') s[i-1]='\0';
            else for(int j=i;s[j]!='\0';j++) s[j-1]=s[j+1];
            i=0;
        }
    }
    printf("%s", s);
    return 0;
}

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;

const int MAX { 1000010 };

bitset<MAX> found;

int solve(int K)
{
    ll r = 0;

    for (int i = 1; i < 2*MAX; ++i)
    {
        r *= 10;
        r += 7;
        r %= K;

        if (r == 0)
            return i;

        if (found[r])
            return -1;

        found[r] = true;
    }
        
    return -1;
}

int main()
{
    ios::sync_with_stdio(false);

    int K;
    cin >> K;

    auto ans = solve(K);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int n;
int wcnt,bcnt;
char c;
int main(){
	while(cin>>c){
		if(c=='0')
		   wcnt++;
		else if(c=='1')
		   bcnt++;
	}
	cout<<min(wcnt,bcnt)*2<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> A(H);
    rep(i, H) cin >> A[i];
    vector<int> exist(H, 0);
    rep(i, H) {
        int cnt = 0;
        rep(j, W) if(A[i][j] == '#') cnt++;
        exist[i] = cnt;
    }
    
    vector<vector<int>> ans(H, vector<int>(W, 0));
    int cur = 0;
    bool hfound = false;
    rep(i, H) {
        if(exist[i] > 0) {
            hfound = true;
            bool found = false;
            rep(j, W) {
                if(A[i][j] == '#') {
                    found = true;
                    cur++;
                    ans[i][j] = cur;
                }
                else {
                    if(found) ans[i][j] = cur;
                }
            }
            for(int j = W - 1; j >= 0; j--) {
                if(ans[i][j] == 0) {
                    ans[i][j] = ans[i][j + 1];
                }
            }
        }
        else {
            if(hfound) rep(j, W) ans[i][j] = ans[i - 1][j];
        }
    }
    for(int i = H - 1; i >= 0; i--) {
        rep(j, W) {
            if(ans[i][j] == 0) ans[i][j] = ans[i + 1][j];
        }
    }
    
    rep(i, H) voutput(ans[i]);
    
    return 0;
}


Measured memory_bytes: 1280
import math

A,B,H,M=map(int, input().split())

S=30*H+0.5*M
L=6*M

if S>L:
    rad=S-L
else:
    rad=L-S

if rad>=180:
    rad=360-rad

print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(rad))))


Measured memory_bytes: 9384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	char haiku[19];

	cin >> haiku;

	for(int i = 0; i < 19; i++)
	{
		if (i == 5 || i == 13)
		{
			cout << " ";
		}else
		{
			cout << haiku[i];
		}
	}

	cout << endl;

	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ii = pair<int, int>;

int dijkstra(vector<vector<int>> adjlist, int source, int end) {
	priority_queue<ii> pq;
	set<ii> visited;

	pq.push(ii(0, source));

	while (!pq.empty()) {
		ii val = pq.top();
		pq.pop();
		int d = val.first;
		int node = val.second;

		if (visited.find(ii(d % 3, node)) != visited.end()) {
			continue;
		}
		if (node == end && d % 3 == 0) {
			return -d/3;
		}
		for (int i : adjlist[node]) {
			pq.push(ii(d - 1, i));
		}
		visited.insert(make_pair(d % 3, node));
	}
	return -1;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> adjlist(N);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adjlist[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	cout << dijkstra(adjlist, S - 1, T - 1);
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    ll sum = 0;
    // flag = 1なら正にしたい
    int flag = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
       sum += a[i];
       if (sum == 0)
       {
           ans += (ll)1;
           if (flag)
               sum = 1;
           else
               sum = -1;
       }
       else if ((flag==1) ^ (sum > 0) == 1)
       {
           ans += (ll)(abs(sum)+1);
           if (flag)
               sum = 1;
           else
               sum = -1;
       }
       flag = (flag+1)%2;
    }
    sum = 0;
    flag = 0;
    ll temp = 0;
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
        if(sum == 0)
        {
            temp += (ll)1;
            if (flag)
                sum = 1;
            else
                sum = -1;
        }
        else if ((flag == 1) ^ (sum > 0) == 1)
        {
            temp += (ll)(abs(sum) + 1);
            if (flag)sum = 1;
            else sum = -1;
        }
        flag = (flag + 1) % 2;
    }
    cout << min(temp, ans) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    int main(){
        lint n;
        cin>>n;
        lint a[n];
        lint mx=0;
        lint mxidx=0;
        rep(i,n){
            cin>>a[i];
            if(abs(a[i])>mx){
                mxidx=i;
                mx=abs(a[i]);
            }
        }
        cout<<(n-1)*2<<endl;
        rep(i,n){
            if(i!=mxidx)cout<<mxidx+1<<" "<<i+1<<endl;
        }
        if(a[mxidx]<0){
            repm(i,n-1)cout<<i+2<<" "<<i+1<<endl;
        }else{
            rep(i,n-1)cout<<i+1<<" "<<i+2<<endl;
        }
    }
      

Measured memory_bytes: 3648
loop{
  n = gets.to_i
  break if n == 0

  matrix = Array.new(n)
  (0..n-1).each do |i|
    matrix[i] = gets.split.map(&:to_i)
  end

  matrix.each do |line|
    line_sum = line.inject(&:+)
    line.push(line_sum)

    line.each{|elm| print(sprintf("%5d", elm)) }
    puts
  end

  matrix.transpose.each do |col|
    col_sum = col.inject(&:+)
    print(sprintf("%5d", col_sum))
  end
  puts
}

Measured memory_bytes: 8748
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			var s = reader.ReadLine();
			s = s + s;
			var p = reader.ReadLine();
			
			
			writer.WriteLine(s.Contains(p) ? "Yes" : "No");
			
			
			
			
		}
	}
}

Measured memory_bytes: 12304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m,cnt=0;
    cin>>n>>m;
    int a[m];
    int b[m];
    rep(i,m)cin>>a[i]>>b[i];
    int c[n][n]={};
    rep(i,m){
        c[a[i]-1][b[i]-1]+=1;
        c[b[i]-1][a[i]-1]+=1;
    }
    rep(i,n){
        for(int j=0;j<n;j++){
            cnt+=c[i][j];
        }
        cout<<cnt<<endl;
        cnt=0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main(void){
    char head[10], tail[10];
    scanf("%s %s", head, tail);
    if (head[0] == tail[2] && head[1] == tail[1] && head[2] == tail[0])
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
}


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

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

	int th, ts, ah, as; cin >> th >> ts >> ah >> as;
	int c = 1000;
	while (c--)
	{
		ah = ah - ts;
		if (ah <= 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
		th = th - as;
		if (th <= 0)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdio.h>
#include<stdlib.h>


int main() {
	int h, w,m=0, a[505][505],b[505][505];
	scanf("%d%d", &h, &w);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf("%d", &a[i][j]);
			b[i][j] = a[i][j];
		}
	}
	for (int i = 1; i <= h-1; i++) {
		for (int j = 1; j <= w-1; j++) {
			if (a[i][j] % 2 == 1) {m++; a[i][j + 1]++; }
		}
		if (a[i][w] % 2 == 1) { m++; a[i + 1][w]++; }
	}
	for (int j = 1; j <= w - 1; j++) {
		if (a[h][j] % 2 == 1) { m++; a[h][j + 1]++; }
	}
	printf("%d\n", m);
	for (int i = 1; i <= h - 1; i++) {
		for (int j = 1; j <= w - 1; j++) {
			if (b[i][j] % 2 == 1) { printf("%d %d %d %d\n", i, j, i, j+1); b[i][j+1]++; }
		}
		if (b[i][w] % 2 == 1) { printf("%d %d %d %d\n", i, w, i+1,w); b[i+1][w]++; }
	}
	for (int j = 1; j <= w - 1; j++) {
		if (b[h][j] % 2 == 1) { printf("%d %d %d %d\n", h,j, h, j+1); b[h][j+1]++; }
	}
}

Measured memory_bytes: 3968
from itertools import zip_longest

def twoAnagrams(s, t):
    s_str = ''.join(sorted(s))
    t_str = ''.join(sorted(t, reverse=True))

    if t_str.startswith(s_str):
        if len(s_str) < len(t_str):
            return True
        # this implies s and t is the same string
        else:
            return False

    for s_chr,t_chr in zip_longest(s_str, t_str):
        if s_chr is None:
            return True
        elif t_chr is None or t_chr < s_chr:
            return False
        elif s_chr < t_chr:
            return True


s = list(input())
t = list(input())

print('Yes' if twoAnagrams(s,t) else 'No')


Measured memory_bytes: 3064
import sys

f_i = sys.stdin

n = int(f_i.readline())

adj = [[(int(cost), int(v_n)) for v_n, cost in zip(x.split()[2::2], x.split()[3::2])] for x in f_i]

import heapq

def dijkstra():
    PQ = [(0, 0)]
    distance = [999900001] * n

    distance[0] = 0
    
    while PQ:
        uc = heapq.heappop(PQ)
        u = uc[1]
        
        for vc in adj[u]:
            v = vc[1]
            t_cost = distance[u] + vc[0]
            if t_cost < distance[v]:
                distance[v] = t_cost
                heapq.heappush(PQ, (t_cost, v))

    for v, d in enumerate(distance):
        print(v, d)


dijkstra()

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    bool flag = false;
    rep(i, s.size()) {
        if (s[i] == 'A') {
            flag = true;
        }
        if (flag == true) {
            tmp += 1;
        }
        if (flag == true & s[i] =='Z') {
            ans += tmp;
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define f first
#define s second

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

template<class T> struct Seg { 
	const T ID = 0; // comb(ID,b) must equal b
	T combine(T a, T b) { return a+b; } 
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID);}

	void update(int p, T value) {	// set value at position p
		seg[p += n] += value;
		for (p /= 2; p; p /= 2) seg[p] = combine(seg[2*p], seg[2*p+1]);
	}
    
	T query(int l, int r) {	 // sum on interval [l, r]
		T ra = ID, rb = ID; 
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = combine(ra,seg[l++]);
			if (r&1) rb = combine(seg[--r],rb);
		}
		return combine(ra,rb);
	}
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	Seg<int> seg; seg.init(M+10);

	deque<pair<int, pii>> arr (N);
	F0R(i, N) {
		int a, b; cin >> a >> b;
		arr[i] = {b - a + 1, {a, b}};
	}

	sort(arr.begin(), arr.end());

	for (int d = 1; d <= M; ++d) {
		while (arr.size() && d > arr.front().f) {
			int l = arr.front().s.f;
			int r = arr.front().s.s;
			seg.update(l, 1);
			seg.update(r+1, -1);
			arr.pop_front();
		}
		int ans = arr.size();
		for (int x = 0; x <= M; x += d) {
			ans += seg.query(0, x);
		}
		print(ans);
	}	
}

Measured memory_bytes: 7656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126
{
    class A
    {
        static void Main(string[] args)
        {
            List<int> list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            string S = Console.ReadLine();
            int N = list[0], K = list[1];

            string SS = "";
            for (int i = 0; i < N; i++)
            {
                if (i == K - 1)
                {
                    SS += S.Substring(i, 1).ToLower();
                }
                else
                {
                    SS += S[i];
                }
            }
            Console.WriteLine(SS);

        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
map<string,int> dp;
int direction[] = {1,-1,4,-4};

void bfs()
{
	queue<string> que;
	que.push("01234567");
	dp["01234567"] = 0;
	while(!que.empty()){
		string now = que.front();
		que.pop();
		int p = 0;// p是'0'的位置  
		for(int j = 0; j < 8; j++){
			if(now[j] == '0'){
				p = j;
				break;
			}
		}
		for(int i = 0; i < 4; i++){
			int n = p + direction[i];
			if(0 <= n && n < 8 && !(p == 3 && i == 0) && !( p ==4 && i == 1)){// 右上角不能再往右了  左下角不能再左了 
				string next = now;
				swap(next[p], next[n]);
				if(dp.find(next) == dp.end()){
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}

int main()
{
	bfs();
	string line;
        while(getline(cin,line)){
		line.erase(remove(line.begin(),line.end(),' '), line.end());
		cout<<dp[line]<<endl;
	}
	return 0;
}


Measured memory_bytes: 5292
#include <cstdio>
#include <algorithm>

int n;
std::pair<int,int> bags[200020];
std::pair<int,int> balls[400040];

int main(void)
{
    long long answer;
    int i;
    int a,b,c;

    //freopen("x.in","r",stdin);

    scanf("%d",&n);
    if(n == 1)
        return puts("0"),0;

    a = 0,b = 0x7f7f7f7f;
    for(i = 0;i < n;++i)
    {
        scanf("%d %d",&bags[i].first,&bags[i].second);
        if(bags[i].first < bags[i].second)
            std::swap(bags[i].first,bags[i].second);
        b = std::min(b,bags[i].first);
        a = std::max(a,bags[i].second);
    }

    std::sort(bags,bags + n);
    for(i = 0;i < n;++i)
    {
        balls[i << 1].first = bags[i].first;
        balls[(i << 1) | 1].first = bags[i].second;
        balls[i << 1].second = balls[(i << 1) | 1].second = i;
    }
    std::sort(balls,balls + (n << 1));

    answer = 1ll * (balls[(n << 1) - 1].first - b) * (a - balls[0].first);
    if(balls[0].second != balls[(n << 1) - 1].second || balls[0].first == balls[1].first || balls[(n << 1) - 1].first == balls[(n << 1) - 2].first){
        c = 0x7f7f7f7f;
        for(i = (n << 1) - 1;i >= 0;--i)
        {
            c = std::min(c,balls[i].first - b);
            b = std::min(b,std::min(bags[balls[i].second].second,bags[balls[i].second].first));
            if(std::min(bags[balls[i].second].second,bags[balls[i].second].first) == balls[i].first)
                break;
        }
        answer = std::min(answer,1ll * c * (balls[(n << 1) - 1].first - balls[0].first));
    }
    printf("%lld\n",answer);

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  if(S == "abc")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

string s;
vector<char> v;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (v.empty())
            v.push_back(s[i]);
        else if (v.back() == 'S' && s[i] == 'T')
            v.pop_back();
        else
            v.push_back(s[i]);
    }

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

Measured memory_bytes: 788
#include<stdio.h>
long long T[101], b[101];
void init1();
void init2(int N);
int main()
{
	int N;

	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &T[i]);
	}
	if(N==1)
		printf("%lld\n",T[0]);
	else {
		init1();
		init2(N);
	}
	return 0;
}

void init1()
{
	long long m = T[0], n = T[1];
	long long c = 1;
	while (c != 0)
	{
		c = m%n;
		m = n;
		n = c;
	}
	b[1] = T[0] / m * T[1];

}
void init2(int N)
{
	long long c = 1, m, n, max = b[1];
	for (int i = 1; i < N - 1; i++)
	{c=1;
		m = b[i];
		n = T[i + 1];
		while (c != 0)
		{
			c = m % n;
			m = n;
			n = c;
		}b[i + 1] = b[i] / m * T[i + 1];
		if (max < b[i + 1])
		{
			max = b[i + 1];
		}
	}printf("%lld\n", max);
}


Measured memory_bytes: 128
//
// tested with : g++ (GCC) 8.3.0
//

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

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

    int result = 700;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            result += 100;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        System.out.println("A" + s2.charAt(0) + "C");
    }
}


Measured memory_bytes: 23252
/*
	Author: Dinesh Verra
	College: ABV-IIITM
	Date: 20/06/2020
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	char c;
	cin>>c;
	if((c-'a')>=0 && (c-'a')<26)
		prn('a');
	else
		prn('A');
}



Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<ctype.h>
#include<stack>
#include<queue>
#include <cmath>  
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define  inf 0x3fffffff 
int main()
{
	int i, n, x, a[110000];
	long long sum;
	while (cin>>n>>x)
	{
		sum = 0;
		for (i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		if (a[1] > x)
		{
			sum += a[1] - x;
			a[1] = x;
		}
		for (i = 2; i <= n; i++)
		{
			int flag = a[i] + a[i - 1] - x;
			if (flag > 0)
			{
				sum += flag;
				a[i] -= flag;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define isWorking()   cout<<"Wroking"<<endl
#define all(x)        (x).begin(),(x).end()
#define allr(x)       (x).rbegin(),(x).rend()
#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl
#define DoublePrint(x,a) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e8,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int F(ll a){
    int digit = 0;
    while(a>0){
        digit++;
        a/=10;
    }
    return digit;
}

int main() {
    Fast_Input

    while(testCase--) {
        ll n; cin >> n;

        ll lim = sqrt(n);

        int ans = INT_MAX;

        for(ll i=1; i<=lim; i++){
            if(n%i == 0){
                ll x = n/i;
                if(x == i) ans = min(ans,F(x));
                else ans = min(ans, max(F(i),F(x)) );
            }
        }

        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	double r;
	double men,syu;
	scanf("%lf", &r);
	men = r * r * 3.14159265358979;
	syu = 2 * r * 3.14159265358979;
	printf("%lf %lf\n", men, syu);
	return 0;
}

Measured memory_bytes: 648
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.util.Collections.sort;

/**
 */
class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		String s = in.nextLine();
		solve(s);
	}

	public static void solve(String s) {
		String ans = "";
		for(int i=0;i<s.length();i++) {
			char ch = s.charAt(i);

			// capitalize
			if((int)'a' <= (int)ch && (int)ch <= (int)'z') {
				ch = (char)((int)'A' + (int)(ch - 'a'));
			}
			ans += ch;
		}
		System.out.println(ans);
	}
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1 << 30;
//const ll INF = 1LL << 60;

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  vector<int> dp(n, INF);
  dp.at(0) = 0;
  for (int i = 1; i < n; i++) {
    if (i - 1 >= 0) {
      chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    }
    if (i - 2 >= 0) {
      chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
    }
  }
  cout << dp.at(n - 1) << endl;
  return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>

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

	int max = (n-1)*(n-2)/2;
	if (k > max) {
		puts("-1");
		return 0;
	}

	int rem = max-k;
	printf("%d\n", n-1 + rem);
	for (int i = 1; i < n; i++) {
		printf("%d %d\n", i, n);
	}

	int curn = 1, curt = 2;
	for (int i = 0; i < rem; i++) {
		printf("%d %d\n", curn, curt);
		curt++;
		if (curt == n) {
			curn++;
			curt = curn+1;
		}
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;

ll gcd(ll x, ll  y){
    if(x<y){
        ll z = x;
        x = y;
        y = z;
    }
    if(x % y == 0)return y;
    else return gcd( y, x % y);
}

int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        string s;
        cin >> s;
        if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])cout << "Bad\n";
        else cout << "Good\n";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256