akhauriyash/Code-Regression huggingface dataset:
def bubbleSort( cards ):
    n = len( cards )
    for i in range( 0, n ):
        for j in range( n-1 , i, -1 ):
            if int( cards[j][1] ) < int( cards[ j-1 ][1] ):
                cards[j], cards[ j-1 ] = cards[ j-1 ], cards[j]
 
    print( " ".join( map( str, cards ) ) )
 
def selectionSort( cards ):
	n = len( cards )
	for i in range( 0, n ):
		mini = i
		for j in range( i , n ):
			if int( cards[j][1] ) < int( cards[ mini ][1] ):
				mini = j
		if mini != i:
			cards[i], cards[ mini ] = cards[ mini ], cards[i]

	print( " ".join( map( str, cards ) ) )


n = int( raw_input( ) )
cards = raw_input( ).split( " " )
cards2 = list( cards )
bubbleSort( cards )
print( "Stable" )
selectionSort( cards2 )
if " ".join( map( str, cards2 ) ) == " ".join( map( str, cards ) ):
	print( "Stable" )
else:
	print( "Not stable" )

Measured memory_bytes: 4276
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.function.Function;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());

      Function<String,double[]> lineSpliteThenArray =
        s -> Stream.of(s.split(" "))
          .mapToDouble(Double::parseDouble)
          .toArray();

      double[][] vecter =
        br.lines()
          .limit(2)
          .map( lineSpliteThenArray )
          .toArray(double[][]::new);

      double p1 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]) )
          .sum();

      double p2 = Math.sqrt(
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.pow( vecter[0][i] - vecter[1][i], 2))
          .sum() );

      double p3 = Math.pow(
        IntStream.range(0, n)
        .parallel()
        .mapToDouble(i -> Math.pow( Math.abs(vecter[0][i] - vecter[1][i]), 3d))
        .sum() , 1d/3d );

      double p00 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]))
          .max()
          .getAsDouble();

      System.out.printf("%.8f\n%.8f\n%.8f\n%.8f\n", p1,p2,p3,p00);
    }
  }

}


Measured memory_bytes: 33344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define INF (1 << 30)
#define rep(i,n) for(int i=0; i<n; ++i)


//双対BIT（区間加算、1点取得）
template <class Abel> struct BIT {
	vector<Abel> dat[2];
	Abel UNITY_SUM = 0;                     // to be set

	/* [1, n] */
	BIT(int n) { init(n); }
	void init(int n) { for (int i = 0; i < 2; ++i) dat[i].assign(n + 1, UNITY_SUM); }

	//区間加算
	/* a, b are 1-indexed, [a, b) */
	inline void sub_add(int p, int a, Abel x) {
		for (int i = a; i < (int)dat[p].size(); i += i & -i)
			dat[p][i] = dat[p][i] + x;
	}
	inline void add(int a, int b, Abel x) {
		sub_add(0, a, x * -(a - 1));
		sub_add(1, a, x);
		sub_add(0, b, x * (b - 1));
		sub_add(1, b, x * (-1));
	}

	/* a is 1-indexed, [a, b) */
	inline Abel sub_sum(int p, int a) {
		Abel res = UNITY_SUM;
		for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
		return res;
	}
	inline Abel sum(int a, int b) {
		return sub_sum(0, b - 1)
			+ sub_sum(1, b - 1) * (b - 1)
			- sub_sum(0, a - 1)
			- sub_sum(1, a - 1) * (a - 1);
	}

	/* debug */
	void print() {
		for (int i = 1; i < (int)dat[0].size(); ++i)
			cout << sum(i, i + 1) << ",";
		cout << endl;
	}
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) cin >> a[i];

	vector<int> lefts(Q), rights(Q), ids(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> lefts[i] >> rights[i];
		--lefts[i];
		ids[i] = i;
	}
	sort(ids.begin(), ids.end(), [&](int i, int j) {
		return rights[i] < rights[j];}
	);

	BIT<int> bit(N + 5);
	vector<int> prev(1100000, -1);	//前回その種類が出た位置
	vector<int> res(Q, 0);
	int r = 0;
	for (auto i : ids) {
		for (; r < rights[i]; ++r) {
			bit.add(prev[a[r]] + 2, r + 2, 1);	//[前回その種類が出た位置, 今回の位置)へ+1する
			prev[a[r]] = r;
			//bit.print();
		}
		int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
		res[i] = max(res[i], tmp);
	}
	for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 21760
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b, k);
  k--;

  for (int i = a; i <= b; ++i) {
    if (i <= a + k || b - k <= i) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    int i,n,k,t1;
    double sum=0,t;
    ll ans=0;
    cin>>n;
    int x[n+1];
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        sum=sum+x[i];
    }
    t=sum/n;
    //cout<<t<<endl;
    k=(int)(t*10.0);
    //cout<<k<<endl;
   // cout<<k%10<<endl;
   // cout<<ceil(t)<<endl;
    if(k%10>5)
        t1=(k/10)+1;
    else
        t1=(k/10);
   // cout<<t1<<endl;
    for(i=0;i<n;i++)
    {
        ans=ans+((t1-x[i])*(t1-x[i]));
    }
    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static List<int>[] li;
	static long[] h;
	static string ans="YES";
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		h=sc.La2;
		li=new List<int>[n+1];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i=1;i<n;i++){
			int[] e=sc.Ia;
			li[e[0]].Add(e[1]);
			li[e[1]].Add(e[0]);
		}
		if(Fu(1,0)!=0){ans="NO";}
		Console.WriteLine("{0}",ans);
	}
	static long Fu(int a,int g){
		long q=0;
		for(int i=0;i<li[a].Count;i++){
			if(li[a][i]!=g){
				long p=Fu(li[a][i],a);
				if(h[a]<p){ans="NO";}
				q+=p;
			}
		}
		if(a==1&&li[a].Count==1){q-=h[a];}
		else if(a==1){q-=h[a]*2;}
		else if(li[a].Count>1){q=h[a]*2-q;}
		else{q+=h[a];}
		if(h[a]<q||q<0){ans="NO";}
		return q;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

const int N = 200005;

vector<int> pos[2][N];
int n;
priority_queue<ii> pq[2];
int ans[N];


int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int u;
        cin >> u;
        pos[0][u].pb(i);
    }
    for (int i = 1; i <= n; i++) {
        int u;
        cin >> u;
        pos[1][u].pb(u);
    }

    for (int i = 0; i < 2; i++) {
        for (int j = 1; j <= n; j++) {
            if (pos[i][j].size() != 0) pq[i].push({pos[i][j].size(), j});
        }
    }

    bool ok = 1;
    for (int i = 1; i <= n; i++) if (pos[0][i].size() + pos[1][i].size() > n) ok = 0;
    if (ok == 0) {
        cout << "No";
        return 0;
    }

    while (!pq[0].empty()) {


        auto u = pq[0].top();

        int sz = u.x;
        int val = u.y;
        pq[0].pop();
        int id = pos[0][val].back();
        if (!pq[0].empty() && pq[0].top().x == sz) {
            int vall = pq[0].top().y;
            if (pos[0][vall].size() + pos[1][vall].size() > pos[0][val].size() + pos[1][val].size()) {
                ii tmp = u;
                u = pq[0].top();
                pq[0].pop();
                sz = u.x;
                val = u.y;
                id = pos[0][val].back();
                pq[0].push(tmp);
            }
        }
        pos[0][val].pop_back();


        auto v = pq[1].top();
        pq[1].pop();
        int sz1 = v.x;
        int val1 = v.y;
        if (val == val1) {
            ii tmp = v;
            v = pq[1].top();
            pq[1].pop();
            sz1 = v.x;
            val1 = v.y;
            pq[1].push(tmp);
        }
        pos[1][val1].pop_back();
        ans[id] = val1;
        u.x--;
        v.x--;


        if (u.x) pq[0].push(u);
        if (v.x) pq[1].push(v);

    }

    cout << "Yes\n";
    for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
    return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int r, g, b;
	cin >> r >> g >> b;

	r *= 100; g *= 10;
	r += g + b;

	if(r % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

using namespace std;

int main(void) {

  string S, T;
  cin >> S >> T;

  int min = T.size(); // 書き換える文字列の最小値
  for (int i = 0; i <= S.size() - T.size(); i++) {
    int count = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j)) {
        count++;
      }
    }
    if (min > count) {
      min = count;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

//ABC055B
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long ans = 1;
        long x = 1000000007;
        int N = s.nextInt();
        for(int i = 1; i <= N; i++){
            ans *= i;
            ans %= x;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll n,i,j;
    cin>>n;
    map<ll,ll> mp;
    ll ans = 1;
    for(i=n;i>=2;i--)
    {
        ll tmp = i;
        while(tmp%2==0)
        {
            tmp/=2;
            mp[2]++;
        }
        for(j=3;j*j<=i;j+=2)
        {
            while(tmp%j==0)
            {
                tmp/=j;
                mp[j]++;
            }
        }
        if(tmp>1) mp[tmp]++;
    }
    for(auto p: mp)
    {
        // cout<<p.first<<" "<<p.second<<"\n";
        ans = (ans*(p.second+1))%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 256
import sys, math
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
x, = [int(num) for num in lines.pop(0).split(" ")]
max_base = int(math.sqrt(x))
max = 1
for base in range(2, max_base + 1):
    i = 2
    while True:
        tmp_max = base ** i
        if tmp_max <= x:
            if tmp_max > max:
                max = tmp_max
            i += 1
        else:
            break
print(max)


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


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
     
    char c;
    cin >> c;
    int a = c - '0';
    a++;
    c = a + '0';
    cout << c << endl;
} 

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n, a[25][25],d[25][1 << 21];

int f(int i,int x)
{
	if(i == n)
		return 1;

	int & ans = d[i][x];
	if(ans != -1) return ans;
	ans = 0;
	for(int j = 0;j < n;j++)
    {
		if(a[i][j] && !(x & (1 << j))) ans = (ans+f(i + 1,x | (1 << j))) % 1000000007;
    }
	return ans;
}

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

    }   }
	memset(d,-1,sizeof(d));
	cout << f(0,0);
	return 0;
}

#endif // 1++


Measured memory_bytes: 205056
S = input()
Q = int(input())
s = 0
s1 = []
s2 = []
for i in range(Q):
    q = list(input().split())
    s += int(q[0])
    if q[0]=='2':
        s_i = s + int(q[1]) 
        if s_i%2 == 0:
            s1.append(q[2])
        else:
            s2.append(q[2])
s1 = ''.join(s1)
s2 = ''.join(s2)
s2 = s2[::-1]
S = s2 + S + s1
if s%2 == 0:
    print(S)
else:
    print(S[::-1])

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> k;
    vl A;
    rep(i, n) {
        cin >> x;
        A.push_back(x);
    }

    ans = INF;
    ll sum = 0;

    for (ll l = 0, r = 0;; l++) {
        for (; r < n && sum < k; sum += A[r], r++)
            ;
        if (sum < k) break;
        //[l,r)は条件を満たす。
        ans=min(ans,r-l);
        sum-=A[l];
    }

    if (ans == INF) cout << 0 << endl;
    else
        cout << ans << endl;
}



Measured memory_bytes: 3920
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    R = [0] * K
    for i in range(1, N + 1):
        R[i % K] += 1

    ans = 0
    for a in range(K):
        if 2 * (K - a) % K == 0:
            ans += R[a] * R[(K - a) % K] ** 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 65284
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 0; i < n; i++) {
			int a = scanner.nextInt();
			for (int j = -1; j <= 1; j++) {
				int tar = a + j;
				if (map.containsKey(tar)) {
					map.put(tar, map.get(tar) + 1);
				} else {
					map.put(tar, 1);
				}
			}
		}

		int max = 0;
		for (int value : map.values()) {
			max = Math.max(max, value);
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 65212
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ll N;
    cin >> N;
    auto check = [&](ll h, ll n, ll w) {
        return n*(4*h*w - N* w - N * h) == N * h * w;
    };
    REP(h, 1, 3501) REP(w, 1, 3501) {
        if((4LL*h * w - N * w - N * h) == 0) continue;
        ll n = N * h * w / (4LL*h * w - N * w - N * h);
        if(n <= 0) continue;
        if(n != 0 && check(h, n, w)) {
            cout << h << " " << n << " " << w << endl;
            return 0;
        } 
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

static long
solve(int N, vector<int> const &A)
{
  vector<int> C(N);
  for (int n = 0; n < N; n++)
  {
    C[A[n] - 1]++;
  }
  long total = 0;
  for (int n = 0; n < N; n++)
  {
    long c = C[n];
    if (1 < c)
    {
      total += (c * (c - 1)) / 2;
    }
  }
  for (int n = 0; n < N; n++)
  {
    long diff = 0;
    long c = C[A[n] - 1];
    if (1 < c)
    {
      diff = (((c - 1) * (c - 2)) / 2) - ((c * (c - 1)) / 2);
    }
    cout << total + diff << endl;
  }
  return 0;
}

int
main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int n = 0; n < N; n++)
  {
    cin >> A[n];
  }
  solve(N, A);
  return 0;
}


Measured memory_bytes: 4096
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc145_a.cpp
 * time   : Sat May  2 13:55:53 2020
 * quest  : A - Circle
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r;
  cin >> r;
  cout << r * r << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100100,M=440;
int i,j,k,n,m,h,a,b,c,d,ch,ff;
int degree[M],f[M],fg[M],z[M];
struct cc { int x,y;} A[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int getf(int x) {
	if (f[x]==x) return x;
	return f[x]=getf(f[x]);
}
int main() {
	R(n);R(h);
	m=h+h;
	for (i=1;i<=n;i++) {
		R(a);R(b);R(c);R(d);
		int x,y;
		if (c) x=h+c;
		else x=a;
		if (d) y=d;
		else y=h+b;
		A[i].x=x;A[i].y=y;
		degree[x]++;
		degree[y]--;
		z[x]=z[y]=1;
	}
	for (i=1;i<=h;i++) if (degree[i]<0 || degree[h+i]>0) return puts("NO"),0;
	for (i=1;i<=m;i++) {
		f[i]=i;
		if (degree[i]) fg[i]=1;
	}
	for (i=1;i<=n;i++) {
		int x=A[i].x,y=A[i].y;
		if (getf(x)!=getf(y)) {
			fg[f[y]]|=fg[f[x]];
			f[f[x]]=f[y];
		}
	}
	for (i=1;i<=m;i++) if (z[i] && !fg[getf(i)]) return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 896
import sys
from queue import Queue

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

dict = {}

for i in range(M):
    A,B = list(map(int, input().split()))

    if A in dict:
        l = dict[A]
        l.append(B)
        dict[A] = l
    else:
        l = [B]
        dict[A] = l

    if B in dict:
        l = dict[B]
        l.append(A)
        dict[B] = l
    else:
        l = [A]
        dict[B] = l

queue = Queue()
queue.put(1)
prev = 1

ans = [-1] * N
while not queue.empty():
    tmp = queue.get()

    if tmp in dict:
        next = dict[tmp]
        for i in next:
            if ans[i - 1] == -1:
                queue.put(i)
                ans[i - 1] = tmp
        
    prev = tmp

if -1 in ans:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(ans[i])



Measured memory_bytes: 110640
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	REP(i, n) {
		int a;
		cin >> a;
		pq.push(a);
	}
	REP(i, m) {
		int a = pq.top();
		pq.pop();
		pq.push(a / 2);
	}
	ll ans = 0;
	REP(i, n) {
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll max(ll a,ll b) {return a<b?b:a;}
ll cmp(const ll &x,const ll &y) {return x>y;}
ll a[4][110];
int main()
{
	int n;
	ll W,w1,w,x,ans=0;
	scanf("%d%lld",&n,&W);
	scanf("%lld%lld",&w1,&x);
	a[0][1]=x;a[0][0]=1;
	for(int i=1;i<n;i++)
	{
		scanf("%lld%lld",&w,&x);
		int p=w-w1;
		a[p][++a[p][0]]=x;
	}
	for(int i=0;i<4;i++) sort(a[i]+1,a[i]+a[i][0]+1,cmp);
	for(int i=0;i<=a[0][0];i++)
	for(int j=0;j<=a[1][0];j++)
	for(int k=0;k<=a[2][0];k++)
	{
		ll res=(i+j+k)*w1+j+2*k;
		res=W-res;if(res<0) continue;
		res/=(w1+3);if(res>a[3][0]) res=a[3][0];
		ll s=0;
		for(int ii=1;ii<=i;ii++) s+=a[0][ii];
		for(int ii=1;ii<=j;ii++) s+=a[1][ii];
		for(int ii=1;ii<=k;ii++) s+=a[2][ii];
		for(int ii=1;ii<=res;ii++) s+=a[3][ii];
		ans=max(ans,s);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  std::vector<int> hills;
  int temp;
  while(std::cin >> temp) {
    hills.push_back(temp);
  }
  std::sort(hills.begin(), hills.end());

  auto it = hills.rbegin();
  for(int i = 0; i < 3; ++i) {
    std::cout << *it << std::endl;
    it++;
  }
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
odd = 0
even = 0

for i in range(N):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1

if even == 0:
    ans = 3 ** N - 1
else:
    ans = 3 ** N - 2 ** even

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

int main() {
    ll n, ans = 0;
    cin >> n;
    for(auto x : prime_factor(n)){
        ll now = x.second, i = 1;
        while(now - i >= 0){
            now -= i;
            ans++; i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>

using namespace std;

int output(int *A, int N){
  for(int i = 0; i < N; i++){
    printf("%d", A[i]);
    if(i < N - 1){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

int insertion_sort(int *A, int N){
  for(int i = 1; i < N; i++){
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      A[j] = v;
      j--;
    }
    output(A, N);
  }
  return 0;
}

int main(void){
  int N;
  int A[101];
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  output(A, N);
  insertion_sort(A, N);
  return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  for (int p : {0, 1}) {
    int j = 0;
    for (int i = p; i < (int)s.size(); i += 2) {
      while (j < (int)t.size() and t[j] != s[i]) {
        ++j;
      }
      ++j;
    }
    if (j <= (int)t.size()) {
      cout << "Yes\n";
      exit(0);
    }
  }
  cout << "No\n";
}



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

int main() {
	string S,T;

	cin >> S >> T;

	for(int i = 0 ; i < (int)S.size(); i++){
		if(S[i] != T[i]){
			cout << "No" << endl;
			exit(0);
		}
	}

	if((S.size() + 1) != T.size()){
		cout << "No" << endl;
		exit(0);
	}

	cout << "Yes"<< endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
ll a[200005];
int main(void)
{
	scanf("%lld%lld",&n,&m);
	ll sum=0;
	for(ll i=0;i<m;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	if(sum>n)
	{
		printf("-1");
	}
	else
	{
		printf("%lld",n-sum);
	}
}

Measured memory_bytes: 3792
n,a,b = map(int,input().split())
s = input()
i,f = 0,0
for x in s:
    ok = False
    if x=='a':
        if i+f<a+b:
            ok = True
            i+=1
    elif x=='b':
        if f<b and i+f<a+b:
            ok = True
            f += 1
    print('Yes' if ok else 'No')

Measured memory_bytes: 53080
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int type = Integer.parseInt(sc.next());
        int powder = Integer.parseInt(sc.next());
        int min = powder;
        for(int x=1; x<=type; x++) {
            int pow = Integer.parseInt(sc.next());
            powder -= pow;
            min = min<pow?min:pow;
        }
        System.out.println(type+powder/min);
    }
}


Measured memory_bytes: 21844
import  java.util.*;

public class Main {
	public static void main(String[] args) {
		final int SLength = 4;
		int ans = 0;
		String s;

		Scanner scan = new Scanner(System.in);
		s = scan.next();

		for (int i = 0 ; i < SLength; i++) {
			if (s.charAt(i) == '+') {
				ans++;
			} else if (s.charAt(i) == '-') {
				ans--;
			}

		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  int cnt=1;
  for(;;ans++){
    if(cnt>=B){
      break;
    }
    cnt += (A-1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <map>
#include <vector>
#include <string>
#include <tuple>
#include <set>

using namespace std;

class Solver {
};

	int main() {
		while (true) {
			int r, n;
			cin >> r >> n;
			if (r == 0)break;

			vector<vector<int>> ranges(n, vector<int>(3, 0));
			vector<int> heights(50, 0);
			for (int i = 0; i < n; i++) {
				int l, r, h;
				cin >> l >> r >> h;
				for (int j = l; j < r; j++) {
					heights[25 + j] = max(heights[25 + j], h);
				}
			}

			vector<double> times(50, 0);
			double res = 500;
			for (int i = -r; i < r; i++) {
				int near = min(abs(i), abs(i + 1));
				double height = heights[25 + i] + r - sqrt(r * r - near * near);
				res = min(res,height);
			}

			cout << res << endl;
		}
	}



Measured memory_bytes: 3236
#include "iostream"
#include "vector"

using namespace std;

int main(){
    int N,A,B;

    cin >> N >> A >> B;
    if(A>B)cout << B << " ";
    else cout << A << " ";
    if(A+B-N<0)cout << 0;
    else cout << A+B-N;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
char a,b;
bool f;
int main()
{
	cin>>a>>b;
	if(a=='D')
	f=!f;
	if(b=='D')
	f=!f;
	if(!f)
	cout<<"H\n";
	else
	cout<<"D\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  string s; cin >> s;
  string S="";
  rep(i,SZ(s)){
    if(i+1<SZ(s) && s[i]=='B' && s[i+1]=='C'){
      S+='D';
      i++;
    }
    else S+=s[i];
  }
  int cnt=0;
  int ans=0;
  rep(i,SZ(S)){
    if(S[i]=='A') cnt++;
    else if(S[i]=='D') ans+=cnt;
    else{
      cnt=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 916
#include <iostream>
using namespace std;
#define MAXL 100

int main(){
    //char str[MAXL + 1] = "atcoder";
    int n, ans = 0;
    char str[MAXL + 1];
    cin >> n >> str;
    for(int slash = 1; slash < n - 1; slash++){
        int char_left[26] = {}, char_right[26] = {};
        for(int l = 0; l < slash; l++){
            for(int num = 0; num < 26; num++){
                if(str[l] == 'a' + num && char_left[num] == 0){
                    char_left[num] = 1;
                    break;
                }
            }
        }

        for(int r = slash; str[r] != '\0'; r++){
            for(int num = 0; num < 26; num++){
                if(str[r] == 'a' + num && char_right[num] == 0){
                    char_right[num] = 1;
                    break;
                }
            }
        }

        int sum = 0;
        for(int i = 0; i < 26; i++){
            sum += char_left[i] * char_right[i];
            if(sum > ans){
                ans = sum;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define int         ll
typedef vector<int> vi;
#define test        int t; cin >> t; while(t--)
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
const int mod = 1000000007;

int n;
vector<int> v;


int32_t main() {

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


    cin >> n;
    vector<int> dp(n + 1);
    v = vector<int>(n + 1);
    vector<int> pre(n + 1);
    // dp[0]=INT_MIN;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        if (i % 2) {
            pre[i] = v[i];
            if (i > 1)
                pre[i] += pre[i - 2];
        }

    }

    for (int i = 2; i <= n; ++i){
            if(i%2){
                dp[i]=max(dp[i-1],dp[i-2]+v[i]);
            }else{
                dp[i]=max(pre[i-1],dp[i-2]+v[i]);
            }
    }
    // for(auto it:dp) cout<<it<<" ";
    // cout<<endl;
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 7960
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	int n; cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		int a; cin >> a;
		if (i % 2 == 1 && a % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3720
<?php

$answer = array_fill_keys(range("a", "z"), 0);

$input = fgets(STDIN);
while ($input) {
  $data  = str_split(strtolower(trim($input)));
  foreach ($data as $c) {
    if (array_key_exists($c, $answer)) {
      $answer[$c]++;
    }
  }

  $input = fgets(STDIN);
}

foreach ($answer as $key=>$value) {
  echo "${key} : ${value}" . PHP_EOL;
}

Measured memory_bytes: 15484
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void Print(const vector<int> & A)
{
    cout << A[0];
    for (int i = 1; i < A.size(); ++i) {
        cout << ' ' << A[i];
    }
    cout << endl;
}

void InsertionSort(vector<int> & A)
{
    int n = A.size();
    int count = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j >= i+1; --j) {
            if (A[j-1] > A[j]) {
                swap(A[j], A[j-1]);
                count ++;
            }
        }
    }
    Print(A);
    cout << count << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    // Print(A);
    InsertionSort(A);
    return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=510;
struct Data{
	int id,val;
	friend bool operator < (Data x,Data y){return x.val<y.val;}
}a[N];
vector<int> L[N],R[N];
int ans[N*N];
int n,m;
bool solve(){
	for (int now=1;now<=n*n;++now){
		for (int i=1;i<=n&&!ans[now];++i){
			if (a[i].val==now) ans[now]=a[i].id;
		}
		for (int i=1;i<=n&&!ans[now];++i){
			if (L[a[i].id].size()<a[i].id-1&&now<a[i].val)
				ans[now]=a[i].id,L[a[i].id].push_back(now);
		}
		for (int i=1;i<=n&&!ans[now];++i){
			if (R[a[i].id].size()<n-a[i].id&&now>a[i].val)
				ans[now]=a[i].id,R[a[i].id].push_back(now);
		}
		if (!ans[now]) return false;
	}
	return true;
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i].val),a[i].id=i;
	sort(a+1,a+1+n);
	if (!solve()) printf("No\n");
	else{
		printf("Yes\n");
		for (int i=1;i<=n*n;++i) printf("%d ",ans[i]); printf("\n");
	}
}

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

int main() {
	string S;
	cin >> S;
	unsigned int num_win = 15 - S.size();
	for (size_t i = 0; i < S.size(); i++) {
		if (S[i] == 'o') num_win++;
	}
	if (num_win >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import queue

h, w = list(map(int, input().split()))
s = [input() for _ in range(h)]
white = 0
for i in range(h):
    white += s[i].count('.')
q = queue.Queue()
q.put(0)
kyori = [0] * (h*w)
kyori[0] = 1
while not q.empty():
    p = q.get()
    kyo = kyori[p]
    x = p%w
    y = p//w
    if x >= 1 and s[y][x-1] == '.' and kyori[p-1] == 0:
        q.put(p-1)
        kyori[p-1] = kyo+1
    if x < w-1 and s[y][x+1] == '.' and kyori[p+1] == 0:
        q.put(p+1)
        kyori[p+1] = kyo+1
    if y >= 1 and s[y-1][x] == '.' and kyori[p-w] == 0:
        q.put(p-w)
        kyori[p-w] = kyo+1
    if y < h-1 and s[y+1][x] == '.' and kyori[p+w] == 0:
        q.put(p+w)
        kyori[p+w] = kyo+1
if kyori[-1] == 0:
    print(-1)
else:
    print(white - kyori[-1])

Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	string t;
	cin >> t;
	ll ans = 0;
	for (int i = 0; i < t.size(); i++)
	{
		if(t[i]=='?')
            t[i]='D';
		
    }
    cout<<t<<endl;
	
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

int main(){
  
    vector <char> string;
    vector <char> output;

    char s[20];
    cin >> s;
    int n = strlen(s);

    for(int i=0;i<n;i++){
    	string.push_back(s[i]);
    }
    
    int end = string.size()-1;
	for(int i=0;i<string.size();i++){

		if(string[i] == '0'){
			output.push_back('0');
		}else if(string[i] == '1'){
			output.push_back('1');
		}else{
			if(output.empty() == 0)
			   output.pop_back();
		}
	}

	for(auto i=output.begin();i!=output.end();i++){
		cout << *i ;

	}


return 0;

}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=2500;
const int MAXM=5000;
const ll INF=1e18;

struct edge{
    int from,to;
    ll cost;
};

int n,m;
ll p;
vector<edge> es(MAXM);
vector<ll> d(MAXN,-INF);

int main(){
    cin>>n>>m>>p;
    for(int i=0;i<m;i++){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        es[i]=edge{a,b,c};
    }
    d[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m;j++){
            edge e=es[j];
            if(d[e.from]!=-INF&&d[e.to]<d[e.from]+e.cost-p){
                d[e.to]=d[e.from]+e.cost-p;
            }
        }
    }
    ll ans=max(0LL,d[n-1]);
    vector<bool> negative(n,false);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            edge e=es[j];
            if(d[e.from]!=-INF&&d[e.to]<d[e.from]+e.cost-p){
                d[e.to]=d[e.from]+e.cost-p;
                negative[e.to]=true;
            }
            if(negative[e.from]) negative[e.to]=true;
        }
    }
    cout<<(negative[n-1]?-1:ans)<<endl;
    return 0;
}

Measured memory_bytes: 3728
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
scores = inpl()
T = input()
ctoi = {'r':0, 's':1, 'p':2}
ans = 0
for i in range(K):
    points = [0,0,0]
    j = i
    while j < N:
        en = ctoi[T[j]]
        points = [max(points[k] for k in ((c+1)%3,(c+2)%3)) + (scores[c] if (en-c) % 3 == 1 else 0) for c in range(3)]
        j += K
    ans += max(points)
print(ans)

Measured memory_bytes: 50396
// 解き直し.
// AGC 008 Editorial
// https://img.atcoder.jp/agc008/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
const int MAX = 555;
int IX[MAX], OX[MAX * MAX + 1], ANS[MAX * MAX + 1];
deque<int> lDq, rDq;

int main(){
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        scanf("%d", &IX[i]);
        OX[IX[i]] = i;
        ANS[IX[i]] = i;
    }
    
    // 2. 解説通り.
    // 2-1. 左側から配置していく.
    for(int i = 0; i <= MAX * MAX; i++){
        int index = OX[i];
        // index - 1 個 を 配置.
        if(index > 0) for(int j = 1; j < index; j++) lDq.pb(index);
    }
    
    // 2-2. 右側から配置していく.
    for(int i = MAX * MAX; i >= 0; i--){
        int index = OX[i];
        // N - index 個 を 配置.
        if(index > 0) for(int j = 1; j <= N - index; j++) rDq.pf(index);
    }
    
    // 3. 数列作成.
    int index = 1;
    while(!lDq.empty()){
        int d = lDq.front();
        while(ANS[index] > 0) index++;
        lDq.pop_front();
        ANS[index] = d;
        index++;
    }
    while(!rDq.empty()){
        int d = rDq.front();
        while(ANS[index] > 0) index++;
        rDq.pop_front();
        ANS[index] = d;
        index++;
    }
    
    // 4. 整合性チェック.
    bool ok = true;
    for(int i = 1; i <= N; i++){
        int count = 0;
        for(int j = 1; j <= N * N; j++){
            if(ANS[j] == i) count++;
            if(count == i){
                if(j != IX[i]) ok = false;
                break;
            }
        }
        if(!ok) break;
    }
    
    // 5. 出力.
    if(!ok){
        printf("%s\n", "No");
        return 0;
    }
    printf("%s\n", "Yes");
    for(int i = 1; i <= MAX * MAX; i++) if(ANS[i] != 0) printf("%d ", ANS[i]);
    return 0;
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	// 水平条件
	bool horizontal = x - r < 0 || x + r > W;
	// 垂直条件
	bool vertical = y - r < 0 || y + r > H;
	if (horizontal || vertical) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if(0<A && A<10){
    if(0<B && B<10){
      cout << A*B;
      return 0;
    }
  }
  
  cout << "-1";
  return 0;
}

Measured memory_bytes: 256