akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define drep(i, n, k) for(int i=n; i>k; --i)
using namespace std;

int main(){
  string enter;
  cin >> enter;
  int r = 1, l = 1;
  vector<int> ans(enter.size());
  rep(i, enter.size()) ans.at(i) = 0;

  rep(i, enter.size()-1){
    if(enter.at(i) == 'R' && enter.at(i+1) == 'R'){
      r++;
    }
    else if(enter.at(i) == 'R' && enter.at(i+1) == 'L'){
      ans.at(i+1) += r / 2;
      ans.at(i) += r - r / 2;
      r = 1;
    }
  }
  drep(i, enter.size() - 1, 0){
    if(enter.at(i) == 'L' && enter.at(i-1) == 'L'){
      l++;
    }
    else if(enter.at(i) == 'L' && enter.at(i-1) == 'R'){
      ans.at(i-1) += l / 2;
      ans.at(i) += l - l / 2;
      l = 1;
    }
  }
  
  rep(i, enter.size()) cout << ans.at(i) << " ";
  cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  vi f(n+1,0);
  for(int x=1; x<=1000; x++){
    for(int y=1; y<=1000; y++){
      for(int z=1; z<=1000; z++){
        if(x*x + y*y + z*z + x*y + y*z + z*x > n) continue;
        f[x*x + y*y + z*z + x*y + y*z + z*x]++;
      }
    }
  }
  for(int i=1; i<=n; i++) cout << f[i] << endl;
}


Measured memory_bytes: 3664
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = Integer.parseInt(scan.next());
		int w = Integer.parseInt(scan.next());		
		int i=0;
		int j=0;
		while(h!=0 && w!=0){
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					System.out.print("#");
				}
				System.out.println("");
			}	
			h = Integer.parseInt(scan.next());
			w = Integer.parseInt(scan.next());
                        System.out.println("");	
		}
	}
}

Measured memory_bytes: 25772
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = (ll)1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;
[[maybe_unused]] static constexpr double e = 2.71828182846;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int i = 0;
    for (; i < C; ++i) {
        if (B - A >= 0) {
            B -= A;
        } else {
            break;
        }
    }
    cout << i << endl;
}


Measured memory_bytes: 888
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#ifdef ONLINE_JUDGE
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define dbg(v)
#else
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
#endif

// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int k;
    cin >> k;
    rep(i, k) cout << "ACL";
    cout << endl;
    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


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

#define N 45
int A[N];

int fibonacci(int i) {
    if (A[i] != -1) {
        return A[i];
    }

    if (i == 0 || i == 1) {
        return 1;
    }

    A[i] = fibonacci(i - 1) + fibonacci(i - 2);
    return A[i];
}

int main() {
    int n;
    cin >> n;

    for (int i = 0; i <= n; i++) {
        A[i] = -1;
    }

    cout << fibonacci(n) << endl;
}



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

int main()
{
    int n;
    cin>>n;
    int arr[n],l = 100,r = 0,ans = 100000000;
    ref(i,n,0)
    {
        cin>>arr[i];
        l = min(arr[i],l);
        r = max(arr[i],r);
    }
    for(int i = l;i<=r;i++)
    {
        int temp = 0;
        ref(j,n,0)
        {
            temp += (arr[j]-i)*(arr[j]-i);
        }
        ans = min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int N;
string s;

int main()
{
  cin >> N;
  cin >> s; s = ' ' + s + ' ';
  int res = 0;
  int key = 1;
  while (key <= N) 
  {
    while (s[key] == s[key + 1]) key++;
    key++;
    res++;
  }
  cout << res;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int x[110],y[110],h[110];

int main(void){
	int n,i,cx,cy,ph,b;
	bool flag;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i]){
			b = i;
		}
	}
	for(cx=0; cx<=100; ++cx){
		for(cy=0; cy<=100; ++cy){
			ph = h[b] + abs(x[b]-cx) + abs(y[b]-cy);
			flag = true;
			for(i=0; i<n; ++i){
				if(max(ph-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << cx << " " << cy << " " << ph << endl;
			}
		}
		if(flag){
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def mergesort array_A,left,right
  if left+1 < right
  mid = (left+right)/2
  mergesort(array_A,left,mid)
  mergesort(array_A,mid,right)  
  merge(array_A,left,mid,right) 
  end
end

def merge array_A,left,mid,right
n1 = mid - left
n2 = right - mid
array_L,array_R = Array.new(),Array.new()
n1.times {|i|
array_L[i] = array_A[left+i]
}
n2.times {|i|
  array_R[i] = array_A[mid+i]
}
array_L[n1],array_R[n2]=(10**9).next,(10**9).next
j,i=0,0
p = right - left
p.times {|k|
  if array_L[i] <= array_R[j]
  array_A[left+k]=array_L[i]
  i+=1
  else
  array_A[left+k]=array_R[j]
  j+=1
  end
}
$count +=  p
end
n = gets.chomp.to_i
$count = 0
array_A = gets.split(" ").map{|x|x.to_i}
mergesort(array_A,0,n)
q = array_A.count {|item| !item.nil? }
(q-1).times {|i|
  printf("%d ",array_A[i])
}
printf("%d\n%d\n",array_A[q-1],$count)

Measured memory_bytes: 193020
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int alice=0;
    int bob=0;

    sort(a.begin(),a.end(),greater<int>());

    for(int i=0;i<n;i++){
        if(i%2==0)alice+=a[i];
        else bob+=a[i];
    }

    cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

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

	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for(auto &x : a) cin >> x;
	int res = n - accumulate(all(a), 0);
	if(res < 0) res = -1;
	cout << res;

	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;	cin >> n;
	int a[n];
	int ans = 0;
	REP(i, n){
		cin >> a[i];
		ans += a[i] - 1;
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
const long long inf = LLONG_MAX;

int main() {
    int N;
    cin >> N;
    set<long long> a;
    for (int i = 0; i < N; i++) {
        int key;
        cin >> key;
        a.insert(key);
    }
    vector<long long> A;
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        A.push_back(*itr);
    }
    while (A.size() > 1) {
        long long min = A[0];
        for (int i = 1; i < A.size(); i++) {
            A[i] %= min;
            if (A[i] == 0) {
                A.erase(A.begin() + i);
                i--;
            }
        }
        sort(A.begin(), A.end());
    }
    cout << A[0] << endl;
    return 0;
}

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

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

	int X, Y, Z;
	cin >> X >> Y >> Z;
	int buf = X;
	X = Y;
	Y = buf;
	buf = X;
	X = Z;
	Z = buf;
	cout << X << " " << Y << " " << Z << endl;
}






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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	cout << v[n - 1] - v[0] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            if (s.charAt(0) == s.charAt(1)) {
                if (s.charAt(2)!=s.charAt(0) && s.charAt(2) == s.charAt(3)) {
                    System.out.println("Yes");
                    return;
                }
            } else if (s.charAt(0) == s.charAt(2)) {
                if (s.charAt(1)!=s.charAt(0) && s.charAt(1) == s.charAt(3)) {
                    System.out.println("Yes");
                    return;
                }
            } else if (s.charAt(0) == s.charAt(3)) {
                if (s.charAt(1)!=s.charAt(0) && s.charAt(1) == s.charAt(2)) {
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");
        }
    }
}


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


int main(){
  char **t,**h;
  int n,taro=0,hanako=0,i;
  scanf("%d",&n);
  t=malloc(n*sizeof(char *));
  h=malloc(n*sizeof(char *));
  for(i=0;i<n;i++){
    t[i]=malloc(100*sizeof(char));
    h[i]=malloc(100*sizeof(char));
    scanf("%s",t[i]);
    scanf("%s",h[i]);
    if(strcmp(t[i],h[i])<0) hanako+=3;
    if(strcmp(t[i],h[i])>0) taro+=3;
    if(strcmp(t[i],h[i])==0){
      taro+=1;
      hanako+=1;
    }
    free(t[i]);
    free(h[i]);
  }
  printf("%d %d\n",taro,hanako);
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define MAX 200000
using namespace std;

long long n, c[MAX];
long long cnt[MAX];
vector<int> adj[MAX];
int last[MAX];
long long res[MAX];
long long val[MAX];
long long tillFirst[MAX];


int dfs( int cur, int par){
    long long sum = 1;
    int tmp = last[c[cur]];
    last[c[cur]] = cur;
    for( int u : adj[cur] ){
        if(par == u)
            continue;
        val[cur] = 0;
        int su = dfs(u, cur);
        sum += su;
        val[cur] += su;
        //cout << cur << ' ' << val[cur] << endl;
        res[c[cur]] -= val[cur] * ( val[cur] + 1 ) / 2;
    }
    if(tmp != -1)
        val[tmp] -= sum;
    else
        tillFirst[c[cur]] -= sum;
    last[c[cur]] = tmp;
    return sum;
}

int main()
{
    cin >> n;
    for( int i = 0; i < n; i++ ){
        cin >> c[i];
        c[i]--;
        cnt[c[i]]++;
    }
    for( int i = 0; i < n - 1; i++ ){
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(last, -1, sizeof last);
    for( int i = 0; i < n; i++ )
        if(cnt[i])
            res[i] = n * (n + 1) / 2, tillFirst[i] = n;
    /*for( int i = 0; i < n; i++ )
        cout << res[i] << ' ';
    cout << endl;
    */
    dfs(0, -1);
    for( int i = 0; i < n; i++ )
        cout << ( res[i] - tillFirst[i] * ( tillFirst[i] + 1 ) / 2)  << endl;

    return 0;
}

Measured memory_bytes: 41704
#include <iostream>
#include <cstring>

using namespace std;

const int INF = 1 << 30;
const int SIZE = 300;
const int N = 1000002;
int p[SIZE+1];
int dp1[N], dp2[N];

void make_pollock (void )
{
	for (int i = 0; i <= SIZE; i++ )
		p[i] = i*(i+1LL)*(i+2LL)/6LL;
}

void make_dp (void )
{
	dp1[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		int m = p[i];
		for (int j = m; j <= N; j++ )
			dp1[j] = min (dp1[j], dp1[j-m]+1 );
	} // end for

	dp2[0] = 0;
	for (int i = 1; i <= SIZE; i++ ){
		if (p[i] % 2 == 0 ) continue;
		int m = p[i];
		for (int j = m; j <= N; j++ )
			dp2[j] = min (dp2[j], dp2[j-m]+1 );
	} // end for	
}
	
int main()
{
	memset (p, 0, sizeof (p ) );
	fill (dp1, dp1+N, INF );
	fill (dp2, dp2+N, INF );

	make_pollock();
	make_dp ();

	int n;
	while (cin >> n, n )
		cout << dp1[n] << ' ' << dp2[n] << endl;
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    int flag = 1;
    int count = 0;
    while(flag){
        flag = 0;
        for(int i = 0;i < n - 1;i++){
            if(a[i] > a[i + 1]){
                int x;
                x = a[i];
                a[i] = a[i + 1];
                a[i + 1] = x;
                flag = 1;
                count++;
            }
        }
    }
    for(int i = 0;i < n;i++){
        cout << a[i];
        if(i != n - 1){
            cout << " ";
        }
    }
    cout << endl << count << endl;
}


Measured memory_bytes: 3096
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
k=sum(a)
a.sort(reverse=True)
cont=0
ans=''
for i in a:
    if i>=k*(1/(4*m)):
        cont+=1
if cont>=m: print("Yes")
else: print("No")


Measured memory_bytes: 9192
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		long double a,b,c;
		cin >> a >> b >> c;
		long double d = c-a-b;
		if(d>0 && 4*a*b<d*d) cout << "Yes" << endl;
		else cout << "No" << endl; 
		return 0;  
}  


Measured memory_bytes: 3692
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a < b && b < c)
        printf("%d %d %d\n", a, b, c);
    else if(b < c && c < a)
        printf("%d %d %d\n", b, c, a);
    else if(c < a && a < b)
        printf("%d %d %d\n", c, a, b);
    else if(c < b && b < a)
        printf("%d %d %d\n", c, b, a);
    else if(a < c && c < b)
        printf("%d %d %d\n", a, c, b);
    else if(b < a && a < c)
        printf("%d %d %d\n", b, a, c);
    else if(a < b && b == c)
        printf("%d %d %d\n", a, b, c);
    else if(b < c && c == a)
        printf("%d %d %d\n", b, c, a);
    else if(c < a && a == b)
        printf("%d %d %d\n", c, a, b);
    else if(b < a && a == c)
        printf("%d %d %d\n", b, a, c);
    else if(c < b && b == a)
        printf("%d %d %d\n", c, b, a);
    else if(a < c && c == b)
        printf("%d %d %d\n", a, c, b);
    else if(a == b && b == c)
        printf("%d %d %d\n", a, b, c);
    else if(a < b && a == c)
        printf("%d %d %d\n", a, c, b);
    else if(b < c && b == a)
        printf("%d %d %d\n", b, a, c);
    else if(c < a && c == b)
        printf("%d %d %d\n", c, b, a);
    else if(b < a && b == c)
        printf("%d %d %d\n", b, c, a);
    else if(c < b && c == a)
        printf("%d %d %d\n", c, a, b);
    else if(a < c && a == b)
        printf("%d %d %d\n", a, b, c);
    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 2e5 + 10;

char str[N];

int n, k;

int pos(int x, int l)
{
	int p = x + l % n;
	if (p > n) p -= n;
	return p;
}

int main()
{
	gii(n, k);
	scanf("%s", str + 1);
	for (int i = 1; i <= n; ++i) str[i] -= 'A';
	if (k <= 2 * n + 10)
	{
		int l = 0, t = 0;
		for (int i = 1; i <= k; ++i)
		{
			if (!(str[pos(1, l)] ^ t))
			{
				str[pos(1, l)] ^= 1;
			}
			else
			{
				++l, t ^= 1; str[pos(n, l)] = t;
			}
		}
		for (int i = 1; i <= n; ++i) putchar((str[pos(i, l)] ^ t) + 'A');
		puts("");
		return 0;
	}
	else
	{
		int l = 0, t = 0;
		for (int i = 1; i <= 2 * n + 10; ++i)
		{
			if (!(str[pos(1, l)] ^ t))
			{
				str[pos(1, l)] ^= 1;
			}
			else
			{
				++l, t ^= 1; str[pos(n, l)] = t;
			}
		}
		k -= 2 * n + 10;
		if (n & 1)
		{
			str[pos(1, l)] ^= (k & 1);
			for (int i = 1; i <= n; ++i) putchar((str[pos(i, l)] ^ t) + 'A');
			puts("");
			return 0;
		}
		else
		{
			for (int i = 1; i <= n; ++i) putchar((str[pos(i, l)] ^ t) + 'A');
			puts("");
			return 0;
		}
	} 
}

Measured memory_bytes: 640
#include<stdio.h>
void call(int n){
    int i = 1,x;
    do{
        x = i;
        if(x % 3 == 0 ){
            printf(" %d",i);
        }
        else{
            do{
                if(x % 10 == 3){
                    printf(" %d",i);
                    x = 0;
                }
                else x /= 10;
            }while(x);
        }
    }while(++i <= n);
    printf("\n");
}
int main(void){
    int n;
    scanf("%d",&n);
    call(n);
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
#define maxn 3005
int n;
vi a(maxn);
int dp[maxn][maxn];
int removal_game(int i,int j)
{if(i>j)
return 0;
if(dp[i][j]!=-1)
return dp[i][j];
if(i==j)
return dp[i][j]=a[i];
if(i==j-1)
return dp[i][j]=max(a[i],a[j]);
return dp[i][j]=max(a[i]+min(removal_game(i+2,j),removal_game(i+1,j-1)),a[j]+min(removal_game(i,j-2),removal_game(i+1,j-1)));
}
int32_t main() {
    int s=0;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i],s+=a[i];
    cout<<2*max(a[0]+min(removal_game(2,n-1),removal_game(1,n-2)),a[n-1]+min(removal_game(0,n-3),removal_game(1,n-2)))-s;
    return 0;
}


Measured memory_bytes: 74316
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,sum=0;
    cin>>n>>k;
    int s[n];
    for(i=0;i<n;i++){
 
    cin>>s[i];
 
}
sort(s,s+n);
for(i=0;i<k;i++){
sum+=s[i];
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 3648
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] t = nextIntArray(sc, N);

		sc.close();

		long ct = 0;
		long pt = t[0];
		long ans = 0;
		for (int i = 1; i < N; i++) {
			ct = t[i];

			ans += Math.min(T, ct - pt);
			pt = ct;
		}
		ans += T;

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 63952
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]

ps = list(map(int, input().split()))

ans = 0

"""
s0, s1, s2, ... , sn
d0, d1, d2, ... , dm
"""

for i in range(2**N):
    light = 0
    for j in range(M):
        cnt = 0
        for k in range(1, ks[j][0]+1):
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                cnt += 1
        if cnt % 2 == ps[j]:
            light += 1

    if light == M:
        ans += 1

print(ans)


Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

def main():
    ans = 0
    s = input().rstrip('\n')
    ls = len(s)
    for i in range(1,ls):
        if (ls - i)%2 != 0:
            continue
        temps = s[:-i]
        if temps[:(ls-i)//2] == temps[(ls-i)//2:]:
            ans = ls - i 
            break

    print(ans)

if __name__ == '__main__':
    main()

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a * n, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    string s, t;
    cin >> s >> t;

    map<char, VI> isHere;
    FOR(i, 0, s.length())isHere[s[i]].push_back(i);
    for (char i : t)if (isHere[i].empty()) {
        cout << "-1\n";
        return 0;
    }

    ll ans = 0;
    int now = isHere[t[0]][0];
    FOR(i, 1, t.length()) {
        int size = isHere[t[i]].size();
        int a = lower_bound(isHere[t[i]].begin(), isHere[t[i]].end(), now) - isHere[t[i]].begin();
        if (a < size && now == isHere[t[i]][a])a++;
        
        if (a < size)now = isHere[t[i]][a];
        else {
            ans += s.length();
            now = isHere[t[i]][0];
        }
    }

    cout << ans + now + 1 << "\n";
}


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

int main(){
	int a,b,c,m;
	cin>>a>>b>>c;
	m=max(max(a,b),c);
	if(m==a+b+c-m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int a[6];
int main(){
	for(int i=1;i<=5;i++)cin>>a[i];
	for(int i=1;i<=5;i++){
		if(!a[i]){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //cout << fixed;
  //cout.precision(40);
  ll x,y,ans = 0;
  cin >> x >> y;
  if(x <= 3) ans += (4-x)*100000;
  if(y <= 3) ans += (4-y)*100000;
  if(x == 1 and y == 1) ans += 400000;
  cout << ans;
  return 0;
}

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

int main() 
{
  int n,m,l;
  cin >> n >> m >> l;
  int a[n][m];
  int b[m][l];
  long long c[n][l];
  int i,j,k;
  for(i = 0;i < n;++i){
    for(j = 0;j < l;++j){
      c[i][j] = 0;
    }
  }
  for(i = 0;i < n;++i){
    for(j = 0;j < m;++j){
      cin >> a[i][j];
    }
  }
  for(i = 0;i < m;++i){
    for(j = 0;j < l;++j){
      cin >> b[i][j];
    }
  }
  for(i = 0;i < n;++i){
    for(j = 0;j < l;++j){
      for(k = 0;k < m;++k){
        c[i][j] += a[i][k]*b[k][j];
      }
    }
  }
  for(i = 0;i < n;++i){
    for(j = 0;j < l;++j){
      if(j != l-1){
        cout << c[i][j] << " ";
      }else{
        cout << c[i][j] << endl;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[100005];
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive)); for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
// ll a[11*LIM]={0},b[11*LIM]={0};
// vp64 v[LIM];
typedef struct 
{
	ll one,two,three;
}data;



v64 factorize (ll temp)
{
	v64 fac;
	while (temp%2==0)
	{
		fac.pb(2);
		temp/=2;
	}
	for (ll i=3;i*i<=temp;i+=2)
	{
		while (temp%i==0)
		{
			fac.pb(i);
			temp/=i;
		}
	}
	if (temp!=1)
	{
		fac.pb(temp);
	}

	reverse(all(fac));

	return fac;
}



int main()
{
	fast;
	ll h,w,n;
	cin>>h>>w>>n;
	cout<<(n+max(h,w)-1)/max(h,w);

} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int main() {
    string s;
    int ans = 0;
 
    cin >> s;
 
    if (s[0] == s[1]) {
        if (s[0] != s[2] && s[2] == s [3]) ans = 1;
    } else if (s[0] == s[2]) {
        if (s[0] != s[1] && s[1] == s [3]) ans = 1;
    } else if (s[0] == s[3]) {
        if (s[0] != s[1] && s[1] == s [2]) ans = 1;
    }
    
    ans == 1 ? cout << "Yes" << endl : cout << "No" << endl;
}

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

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

  int cnt = 0;
  for(int i=1; i<=n; i++){
    if(a[a[i]] == i) cnt++;
  }

  cout << cnt / 2 << endl;

  return 0;
}


Measured memory_bytes: 640
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n,ans;
    string s;
    cin>>n>>s;
    ans =n;
    rep(i,n-1){
        if(s[i+1]==s[i]) ans -=1;
    }
    cout<<ans<<endl;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int m; cin >> m;

    int diff = 24-m;
    int sum = diff+24;
    cout << sum << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  ll a,b,Q;
  const ll inf = (1ll << 60);
  cin >> a >> b >> Q;
  vector<ll> s(a+1),t(b+1);
  s[0] = -inf;
  t[0] = -inf;
  for(int i = 1;i <= a;i++)cin >> s[i];
  for(int i = 1;i <= b;i++)cin >> t[i];
  s.push_back(inf);
  t.push_back(inf);

  auto bssl = [&](ll x)-> ll{
    ll left = 0,right = (ll)s.size()-1;
    while(right-left > 1){
      ll mid = (right+left)/2;
      if(s[mid] >= x)right = mid;
      else left = mid;
    }
    return right;
  };
  auto bstl = [&](ll x)-> ll{
    ll left = 0,right = (ll)t.size()-1;
    while(right-left > 1){
      ll mid = (right+left)/2;
      if(t[mid] >= x)right = mid;
      else left = mid;
    }
    return right;
  };
  REP(i,Q){
    ll x;cin >> x;
    ll sl = bssl(x),sm = sl-1,tl = bstl(x),tm = tl-1;
    ll l = max(s[sl],t[tl])-x,m = x-min(s[sm],t[tm]),st = min(abs(t[tl]-x),abs(x-s[sm]))*2+max(abs(t[tl]-x),abs(x-s[sm])),ts = min(abs(s[sl]-x),abs(x-t[tm]))*2+max(abs(s[sl]-x),abs(x-t[tm]));
    cout << min({l,m,st,ts}) << endl;
  }


  return 0;
}

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
int A[100000],B[100000],dist[100000];
pair<int,int> who[100000];

int main(){
    int a,b,m;
    scanf(" %d %d %d",&a,&b,&m);
    int mi1 = 1000000000,mi2 = 1000000000;
    for(int i = 0; i < a;++i){scanf(" %d",&A[i]);mi1 = min(mi1,A[i]);}
    for(int i = 0; i < b;++i){scanf(" %d",&B[i]);mi2 = min(mi2,B[i]);}
    int ans = mi1+mi2;
    for(int i = 0; i < m;++i) {
        int ai,bi,ci;
        scanf(" %d %d %d",&ai,&bi,&ci);
        --ai,--bi;
        ans = min(ans,A[ai]+B[bi]-ci);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N;
  long long ans = 1;
  char S[100001];
  map<char, int> M;
  cin >> N;
  scanf("%s", S);
  for(int i = 0; i < N; i++){
    if(M.count(S[i])){
      M.at(S[i])++;
    }else{
      M[S[i]] = 1;
    }
  }
  for(auto p : M){
    ans *= (p.second+1);
    if(ans > 1000000007) ans %= 1000000007;
  }
  ans--;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Control.Arrow
import qualified Data.IntMap.Strict as IM
import qualified Data.Sequence as Sq


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


toTup [a,b] = (a,b)
flipTup (a,b) = (b,a)

main = do
    [n,m] <- r'

    ways <- V.map toTup <$> V.replicateM m r'

    let im = V.accumulate (Sq.|>) (V.replicate (n+1) Sq.empty) (ways V.++ V.map flipTup ways)

    answer  <- U.thaw $ U.replicate (n+2) ((-1) :: Int)
    UM.write answer 1 0

    bfs (Sq.singleton 1) im answer
    ans <- U.freeze answer

    putStrLn "Yes"
    U.mapM_ print $ U.take (n-1) $ U.drop 2 ans

bfs :: Sq.Seq Int -> V.Vector (Sq.Seq Int) -> UM.IOVector Int -> IO ()
bfs Sq.Empty _ _ = return ()
bfs (h Sq.:<| sq) imap answer = do
    let children = imap V.! h
    xs <- traverse (\a -> do
        b <- UM.read answer a
        return (b<0,a)) children
    let nextBFS = fmap snd $ Sq.filter fst xs
    mapM_ (\c -> UM.write answer c h) nextBFS
    bfs (sq Sq.>< nextBFS) imap answer


Measured memory_bytes: 81124
import java.util.Scanner;

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

		String[] s = {sc.next(), sc.next(), sc.next()};
		int p = 0;
		while (s[p].length() != 0) {
			int np = s[p].charAt(0) - 'a';
			s[p] = s[p].substring(1);
			p = np;
		}
		System.out.println((char)('A' + p));
	}
}



Measured memory_bytes: 23764
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String a = scanner.next();
            String b = scanner.next();
            Set<String> l = new TreeSet<>();
            l.add(IntStream.range(0, Integer.parseInt(b)).mapToObj(i -> a).collect(Collectors.joining()));
            l.add(IntStream.range(0, Integer.parseInt(a)).mapToObj(i -> b).collect(Collectors.joining()));
            System.out.println(l.toArray()[0]);
        }
    }

}


Measured memory_bytes: 26704
N=parse(Int,readline())
A=[map(x->parse(Int,x),split(s)) for s=readlines()]
for cx=0:100,cy=0:100
	H=114514
	for i=1:N
		if A[i][3]>0
			H=A[i][3]+abs(A[i][1]-cx)+abs(A[i][2]-cy)
			break
		end
	end
	flag=true
	for i=1:N
		if A[i][3]!=max(0,H-abs(A[i][1]-cx)-abs(A[i][2]-cy))
			flag=false
			break
		end
	end
	if flag
		println("$cx $cy $H")
		exit()
	end
end


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

int main() {
	int n;
	while (cin >> n, n) {
		int mp[25][25] = {};

		for (int i = 0;i < n;i++) {
			int a, b;
			cin >> a >> b;
			mp[a][b] = 1;
		}
		int m;
		cin >> m;

		int nx = 10;
		int ny = 10;
		int jw = 0;
		for (int i = 0;i < m;i++) {
			int a;
			char b;
			cin >> b >> a;

			if (b == 'N') {
				for (int i = 0;i < a;i++) {
					ny++;
					if (mp[nx][ny] == 1)jw++;
					mp[nx][ny] = 0;
				}
			}
			else if (b == 'E') {
				for (int i = 0;i < a;i++) {
					nx++;
					if (mp[nx][ny] == 1)jw++;
					mp[nx][ny] = 0;
				}
			}
			else if (b == 'W') {
				for (int i = 0;i < a;i++) {
					nx--;
					if (mp[nx][ny] == 1)jw++;
					mp[nx][ny] = 0;
				}
			}
			else {
				for (int i = 0;i < a;i++) {
					ny--;
					if (mp[nx][ny] == 1)jw++;
					mp[nx][ny] = 0;
				}
			}
		}
		if (n == jw)cout << "Yes" << endl;
		else cout << "No" << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3076
n,k=map(int,input().split())

if k==0:
    print(n**2)
else:
    #bの値かな
    co=0
    for i in range(k+1,n+1):
        co+=(n//i)*(i-k)
        co+=max(n%i-k+1,0)
    print(co)


Measured memory_bytes: 2940
function Main(input) {
input = input.split("\n");//行ごとに分解して配列にする。一行の時は"\n"を" "にして三行目を消そう

count = 0;
flg = false;
for(i=1; i<input.length; i++){
    num = input[i].split(" ")
	if(num[0] == num[1]){
    	count++;
      
      	if(count == 3)
        {
        	console.log("Yes");
          	flg = true;
            break;
        }
    }else{
     	count = 0; 
    }
}

if (flg == false){
  console.log("No");
}

//省略。
//var a = input[1];
  
  
//console.log(a[0]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));//おまじない

Measured memory_bytes: 29684
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int leap_years_list[1000], int year_begin, int year_end);

int main()
{
  int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない                                                                                                     

  bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので                                                                                                      

  while (true) {
    int year_begin, year_end;

    //読み込み                                                                                                                                                                       
    scanf("%d %d", &year_begin, &year_end);

    //終了判定                                                                                                                                                                       
    if (year_begin == 0 && year_end == 0) {
      break;
    }

    //閏年を計算する                                                                                                                                                                 
    int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

    //セットとセットの間には空行を入れる                                                                                                                                             
    if (first_set) {
      first_set = false;
    } else {
      putchar('\n'); //putcharは一文字だけ出力する関数です                                                                                                                           
    }

    //閏年を出力                                                                                                                                                                     
    if (leap_years_count == 0) {
      puts("NA"); //putsは与えられた文字列を出力した後改行する関数です                                                                                                               
    } else {
      for (int i = 0; i < leap_years_count; i++) {
        printf("%d\n", leap_years_list[i]);
      }
    }

  }
}

bool is_leap_year(int y)
{
  if (y % 400 == 0) {
    return true;
  } else if (y % 100 == 0) {
    return false;
  } else {
    return y % 4 == 0;
  }
}

int get_leap_years(int leap_years_count[1000], int year_begin, int year_end)
{
    int k = 0;
    for (int n = year_begin; n <= year_end ; n++) {
      if ( is_leap_year(n) == false ) {
        //false の時何も処理しない                                                                                                                                                   
      } else {
        leap_years_count[k] = n;  //k番目のメモリに閏年の年を入力する                                                                                                                
        k++;
      }
    }
    return k;  //使ったメモリの数を返す                                                                                                                                              
}

Measured memory_bytes: 1044
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int m = n*a;

        if (m > b) {
            System.out.print(b);
        } else {
            System.out.print(m);
        }
    }
}

Measured memory_bytes: 22740
while True:
    n=int(input())
    if n==0:
        break
    s=list(map(int,input().split()))
    m=sum(s)/len(s)
    sig=0
    for i in range(n):
        sig=sig+(s[i]-m)**2
    print('{:.5f}'.format((sig/n)**(1/2)))


Measured memory_bytes: 5672
from collections import Counter

n,*v = map(int,open(0).read().split())
v0,v1 = Counter(v[::2]),Counter(v[1::2])
len0,len1 = len(v0),len(v1)
if len0==1 and len1==1:
    if v0.keys() != v1.keys():
        print(0)
    else:
        sv = sorted(v1.values())[0]
        print(sv)
elif len0 == 1:
    print(sum(v1.values()) - max(v1.values()))
elif len1 == 1:
    print(sum(v0.values()) - max(v0.values()))
else:
    v0_1,v0_2 = v0.most_common(2)
    v1_1,v1_2 = v1.most_common(2)
    if v0_1[0] != v1_1[0]:
        sum0 = sum(v0.values()) - v0_1[1]
        sum1 = sum(v1.values()) - v1_1[1]
        print(sum0 + sum1)
    else:
        sum0 = sum(v0.values())
        sum1 = sum(v1.values())
        sum0_1 = sum0 - v0_1[1]
        sum0_2 = sum0 - v0_2[1]
        sum1_1 = sum1 - v1_1[1]
        sum1_2 = sum1 - v1_2[1]
        print(min(sum0_1 + sum1_2 , sum0_2 + sum1_1))

Measured memory_bytes: 18528
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const int sz = 20;
int c[sz][sz];
int h, w;
ll ret = 0;
void solve()
{
    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    rep(i, h)
    {
        rep(j, w)
        {
            int x;
            cin >> x;
            if (~x)
                ret += c[x][1];
        }
    }
}
main()
{
    cin.tie();
    ios::sync_with_stdio(0);
    cin >> h >> w;
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    solve();
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256