akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void coin() {
	int n; cin >> n;
	vector<double>prob(n);
	for (int i = 0; i < n; i++)
		cin >> prob[i];

	double dp[n + 1][n + 1];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
		dp[i][0] = (1 - prob[i - 1]) * dp[i - 1][0];
	for (int i = 1; i <= n; i++)
		dp[0][i] = 0;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			dp[i][j] = prob[i - 1] * dp[i - 1][j - 1] + (1 - prob[i - 1]) * dp[i - 1][j];

	int min = (n + 1) / 2;
	double ans = 0;
	for (int i = min; i <= n; i++)
		ans += dp[n][i];
	cout << setprecision(10) << ans << endl;
	return ;
}

int main()
{
	coin();
	return 0;
}

// for (int i = 0; i <= n; i++) {
// 		for (int j = 0; j <= n; j++)
// 			cout << dp[i][j] << " ";
// 		cout << endl;
// 	}


Measured memory_bytes: 70528
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

signed main()
{
	string inp = in<string>();
	string result;
	REPC(i, inp) {
		switch (i) {
		case '0':
			result.push_back('0');
			break;
		case '1':
			result.push_back('1');
			break;
		case 'B':
			if (result.size() != 0)result.pop_back();
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 256
s = input()

s_first = s[0]
s_last = s[-1]

# 偶数の場合
if (len(s) % 2 == 0):
    # a...a のような型 => 最終形は奇数
    if (s_first == s_last):
        print('First')
    # a...b のような型 => 最終形は偶数
    else:
        print('Second')
else:
    if (s_first == s_last):
        print('Second')
        # a...b のような型 => 最終形は偶数
    else:
        print('First')

Measured memory_bytes: 39024
n,k,q=map(int, input().split())
if q==1:
    print(0)
    exit()
*a,=map(int, input().split())
a+=[-1]
ans=10**10
for i in range(n):
    ai=a[i]
    tmp=[10**11]##15行目でtmp[:0]になるから
    tmp2=[ai]
    for j in range(n+1):
        if i==j:
            continue
        if a[j]<ai:
            tmp.sort()
            if len(tmp)>=k+1:
                tmp2+=tmp[:-k]
            tmp=[10**11]###
        else:
            tmp.append(a[j])
            #print("test",tmp)
    tmp2.sort()
#    print(tmp,tmp2)
    if len(tmp2)>=q:    
#        print("test2")
        ans=min(ans,tmp2[q-1]-ai)
print(ans)

Measured memory_bytes: 44804
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String str = sc.next();

		if(str.length()==2){

			System.out.println(str);
		}else{
			StringBuffer sb = new StringBuffer(str);
System.out.println(sb.reverse());
			
		}




	}

}

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}
bool cmp(ll x ,ll y){
    return abs(x)<abs(y);
}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

vll adj[100001];

ll vis[100001];






void solve(){
ll n,d;
cin>>n>>d;
ll cnt=0;
pll vec;
fo(i,0,n){
    ll a,b;
    cin>>a>>b;
    if(a*a+b*b<=d*d)cnt++;
}
cout<<cnt;


}






















int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //  cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 5968
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let a: HashSet<usize> = (0..m).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut dp: Vec<usize> = vec![0; n + 2];
    dp[n] = 1;
    for i in (0..n).rev() {
        if a.contains(&i) {
            continue;
        }
        dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
    }

    return format!("{}", dp[0]);
}

const MOD: usize = 1_000_000_007;


Measured memory_bytes: 8444
# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))

def gcd(a,b):
    if b>a:
        a,b = b,a
    while b!=0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def f(m):
    s = 0
    for i in range(n):
        s += m%al[i]
    return s

res = al[0]
for i in range(1,n):
    res = lcm(res,al[i])


print(f(res-1))


Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2612
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)2e5 + 5;
const int mod = (int)1e9 + 7;

int H, W, h, w;
int a[505][505];
ll sum[505][505];

ll get(int x, int y, int x2, int y2) {
    return sum[x2][y2] - sum[x - 1][y2] - sum[x2][y - 1] + sum[x - 1][y - 1];
}

void solve(int H, int W, int h, int w) {
    if (H % h == 0 && W % w == 0) {
        cout << "No\n";
        return;
    }
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            if (i % h == 0 && j % w == 0)
                a[i][j] = 1000 * (h * w - 1) - 1;
            else
                a[i][j] = -1000;
        }
    for (int i = 1; i <= H; i++)
        for (int j = 1; j <= W; j++) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i - 1][j - 1];
        }
    for (int i = 1; i + h - 1 <= H; i++)
        for (int j = 1; j + w - 1 <= W; j++) {
            assert(get(i, j, i + h - 1, j + w - 1) < 0);
        }
    assert(sum[H][W] > 0);
    cout << "Yes\n";
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++)
            cout << a[i][j] << ' ';
        cout << endl;
    }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif  
    cin >> H >> W >> h >> w;
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 4736
n = int(input())
a = list(map(int,input().split()))

if sorted(a)[0]==0:
    print(0)
else:
    import math
    b = [math.log10(i) for i in a if i!=0]    
    if sum(b)>18:
        print(-1)
    else:
        z = 1
        for i in a:
            z*=i
        if z>10**18:
            print(-1)
        else:
            print(z)

Measured memory_bytes: 21648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<P> even(100005), odd(100005);
    for(int i = 0; i <= 1e+5; ++i){
        even[i] = P(0, i);
        odd[i] = P(0, i);
    }
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(i % 2 == 0)  ++even[a].first;
        else    ++odd[a].first;
    }
    sort(even.begin(), even.end(), greater<P>());
    sort(odd.begin(), odd.end(), greater<P>());
    if(even[0].second != odd[0].second){
        cout << n - even[0].first - odd[0].first << "\n";
        return 0;
    }
    int res = INF;
    chmin(res, n - even[0].first - odd[1].first);
    chmin(res, n - even[1].first - odd[0].first);
    cout << res << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    cin >> N;
    
    int B[N+10];
    rep(i,N-1) cin >> B[i];
    B[N-1] = 1000000;

    ll ans = B[0];
    rep(i,N-1)
    {
        ans += min(B[i], B[i+1]);
    }
    cout << ans << endl;
}

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

int main(){
  long long int n, d, j;
  cin >> n;
  for(long long int i=1; i*i<=n; i++){
    if(n%i == 0){
      d = n/i;
      j = i;
    }
  }
  cout << d+j-2 << endl;
  return 0;
}

Measured memory_bytes: 888
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var S = input[0];
        var W = input[1];

        if (S > W)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("unsafe");
        }
    }
}


Measured memory_bytes: 28288
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using ll = long long;

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

	atcoder::fenwick_tree<ll> tw(n);

	for(int i = 0;i<n;i++)
	{
		int a;
		cin >> a;
		tw.add(i,a);
	}
	while(q--)
	{
		int t,a,b;
		cin >> t >> a >> b;
		if(t)
		{
			cout<<tw.sum(a,b)<<endl;
		}
		else
		{
			tw.add(a,b);
		}
	}
}


Measured memory_bytes: 8208
D = int(input())
C = list(map(int, input().split()))
s = list()
for i in range(D):
  s1 = list(map(int, input().split()))
  s.append(s1)
t = list()
for i in range(D):
  t.append(D%26)

def point(t, C, s):
  done = [0] * 26
  ans = 0
  for d in range(1, D+1):
    td = t[d-1]
    done[td] = d
    ans += s[d-1][td]
    for i in range(26):
      ans -= C[i]*(d-done[i])
  return ans

ans = 0
bettert = 0
for i in range(26):
  t[0] = i
  #print(point(t, C, s))
  if(point(t, C, s) > ans):
    ans = point(t, C, s)
    bettert = i
    
print(bettert+1)
for i in range(1,D):
  print(t[i])

Measured memory_bytes: 74108
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

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

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

template<typename T>
vector<T> DIVISOR(T n) {
    vector<T> v;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            v.push_back(i);
            if (i != n / i) {
                v.push_back(n / i);
            }
        }
    }
    sort(v.begin(), v.end());
    return v;
}

int main() {
    long long A, B; cin >> A >> B;

    // まずはAの約数から
    vector<ll> d_a;
    for(ll i=1; i*i<=A; i++){
        if(A%i){
            continue;
        }

        if(i==A/i){
            d_a.push_back(i);
        }else{
            d_a.push_back(i);
            d_a.push_back(A/i);
        }
    }


    // 次に公約数
    vector<ll> d;
    for(auto a: d_a){
        if(B%a==0){
            d.push_back(a);
        }
    }
    sort(d.begin(), d.end());

    ll ans=0ll;
    for(auto a: d){
        auto v=DIVISOR(a);
        if(v.size()<=2){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int k,n,a[N];
int main()
{
    scanf("%d%d",&k,&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int ans=k;
    for(int i=1;i<n;i++) ans=min(ans,k-(a[i+1]-a[i]));
    ans=min(ans,k-a[1]-(k-a[n]));
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    vector<ll> A(N,inf);
    ll ans=0;
    FORI(i,1,N)
    {
        READV(x);
        A[i-1]=min(A[i-1],x);
        A[i]=min(A[i],x);
    }
    FORI(i,0,N)
    {
        ans+=A[i];
    }
    cout<<ans<<endl;

    return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k, n;
    cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int d = a[0] + k - a[n - 1];
    for (int i = 0; i < n - 1; i++) {
        d = max(d, a[i + 1] - a[i]);
    }
    cout << k - d << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	map<ll,ll>p;
	ll ch=false;
	for(ll i=0;i<3;i++){
		ll n;
		cin>>n;
		p[n]++;
		if(p[n]==2){
			ch=true;
		}
		if(p[n]==3){
			ch=false;
		}
	}
	if(ch){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main() {
    cin >> n >> m;
    cout << (n + m + 1) / 2 << endl;
}

Measured memory_bytes: 256
n = int(input())
MOD = 1e9 + 7

memo = [{} for _ in range(n + 1)]

def ok(s):
    for i in range(4):
        ls = list(s)
        if i >= 1:
            ls[i], ls[i - 1] = ls[i - 1], ls[i]
        if ''.join(ls).count('AGC') >= 1:
            return False
    return True

def sol(cur, s):
    if s in memo[cur]:
        return memo[cur][s]
    if cur == n:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(s + c):
            ret = int(ret + sol(cur + 1, s[1:] + c)) % MOD
    memo[cur][s] = int(ret)
    return int(ret)

print(sol(0, 'TTT'))


Measured memory_bytes: 3864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    char a,b,c;
    cin>>a>>b>>c;
    map<char,int> x;
    x[a] ++;
    x[b] ++;
    x[c] ++;
    if(x['A'] && x['B']) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,k;
    cin >> n >> k;
    ll x = n/k;
    ll ka = n - x*k;

    cout << min(ka , abs(ka-k));
    return 0;
}


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

using namespace std;


void solve() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        if (x >= k) cnt++;
    }
    cout << cnt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  string S;
  cin>>N>>S;
  
  for(ll i=1; i<N; ++i){
    ll cnt=0;
    for(ll j=0; j<N-i; ++j){
      if(S[i+j]==S[j]) cnt++;
      if(S[i+j]!=S[j] || i+j==N-1){
        chmin(cnt,i);
        chmax(ans,cnt);
        cnt=0;
      }
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF (1<<29)

#define DEBUG(x) cout << #x << ": " << x << endl;

int N, M, R; // 町数、道数、訪れる町数
int d[201][201]; // 町と町の距離
int r[9];//なにこれ
int A, B, C; // A町、B町、AB間の距離
int res;//なにこれ
bool used[9];

void dfs(int c, int las, int dist);

int main() {
    cin >> N >> M >> R; // 1段目の読み込み
    // 町の間の距離の初期化作業 -----------------------------------------------------------
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            //if (i != j) { // A町からA町のように、無意味なものは初期化しない
            d[i][j] = INF; // 町の間の距離をできるだけ大きな数値で初期化
            //}
        }
    }
    // END -------------------------------------------------------------------------

    // どの町を訪れるか入力 --------------------------------------------------------------
    vector<int> road;
    for (int i = 1; i <= R; i++) {
        //cin >> r[i]; // 2段目の読み込み
        int x;
        cin >> x;
        road.push_back(x);
    }
    sort(road.begin(), road.end()); // 後に辞書順に並べることが役に立つため、ソートしておく 
    // END ---------------------------------------------------------------------------

    for (int i = 1; i <= M; i++) {
        cin >> A >> B >> C; // 3段目以降の読み込み
        if (d[A][B] > C) { // CはA,B間の距離
            d[A][B] = d[B][A] = C; // より小さい距離を格納
                                   // d[A][B]とd[B][A]は同じ
        }
    }

    // ワーシャルフロイド法
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); // より小さいものを格納していくスタイル
            }
        }
    }

    int ans = INF;  // より小さい値が欲しいため、あらかじめ大きい値を入れておく
    do {
        int dist = 0; // 一時的に使う距離
        for (int i = 0; i < (R - 1); i++) {
            dist += d[road[i]][road[i+1]];
        }
        ans = min(ans, dist); // 本命の答え
    } while (next_permutation(road.begin(), road.end())); // next_permutation使えなければDFS使うっぽい
    
    cout << ans << endl;

}

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


int main(){
    int a,b;
    cin >>a>>b;
    int x,y;
    y = 2*a +2*b;
    x = a*b;
    cout <<x<<" "<<y<<endl;
}



Measured memory_bytes: 3084
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for C - Same Integers
	A := make([]int, 3)
	fmt.Scanf("%d %d %d", &A[0], &A[1], &A[2])

	sort.Sort(sort.IntSlice(A))
	if ((A[2]-A[0])+(A[2]-A[1]))%2 == 0 {
		fmt.Println((3*A[2] - A[2] - A[1] - A[0]) / 2)
	} else {
		fmt.Println((3*(A[2]+1) - A[2] - A[1] - A[0]) / 2)
	}

}


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





int main(void){
	int n;
	int k;
	int q;
	int a[100000];
	int b[100000];
	int i;
	int c;

	scanf("%d %d %d",&n,&k,&q);

	for(i=0;i<n;i++){
		b[i] = 0;
	}

	for(i=0;i<q;i++){
		scanf("%d",&a[i]);
	}	

	for(i=0;i<q;i++){
		b[a[i]-1]++;
	}
	c = 0;
	for(i=0;i<n;i++){
		if(k - (q - b[i]) <= 0){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	}

	return 0;
}




Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    if (a+b>c+d)
    cout<<"Left";
    else if (a+b==c+d)
    cout<<"Balanced";
    else
    cout<<"Right";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[225816],b;
vector<ll> v;

int main(void){
	int n,i,k;
	ll ans=0ll,p,t;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		cin >> b;
		v.push_back(b);
	}
	for(k=40; k>0; --k){
		p = (1ll<<(k-1));
		for(i=0; i<n; ++i){
			v[i] %= (p*2);
		}
		sort(v.begin(),v.end());
		t = 0ll; 
		for(i=0; i<n; ++i){
			a[i] %= (p*2);
			t += (ll)(lower_bound(v.begin(),v.end(),p*2-a[i])-lower_bound(v.begin(),v.end(),p-a[i]));
			t += (ll)(lower_bound(v.begin(),v.end(),p*4-a[i])-lower_bound(v.begin(),v.end(),p*3-a[i]));
		}
		ans += p*(t%2);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
 int x; cin>>x;
 cout<< ((x>=30)?"Yes":"No") <<endl;
 return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
	double x1 = 0, y1 = 0, x2 = 0, y2 = 0;

	cin >> x1 >> y1 >> x2 >> y2;

	cout << setprecision(10) << sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2)) << endl;

    return 0;
}

Measured memory_bytes: 3264
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def decrease(d):
    tmp = 0
    for i in range(26):
        tmp += c[i]*(d-last[i])
    return tmp 

D = INT()
c = LIST()
s = [LIST() for _ in range(D)]
t = [INT() for _ in range(D)]

ans = [0]*D

last = [0]*26
now = 0
for i in range(D):  # i+1日目
    now += s[i][t[i]-1]
    last[t[i]-1] = i+1

    now -= decrease(i+1)
    ans[i] = now

print(*ans, sep="\n")


Measured memory_bytes: 10112
a,b,c,d=map(int, input().split())

if b<=c or d<=a:
    ans = 0
elif a<=c:
    if b<=d:
        ans = b-c
    elif d<=b:
        ans = d-c
elif c<=a:
    if d<=b:
        ans = d-a
    elif b<=d:
        ans = b-a
elif a==c and b==d:
    ans = b-a

print(ans)

Measured memory_bytes: 3060
a=raw_input()
b=raw_input()
c=raw_input()
f=0
while 1:
#    print a,b,c
    if f==0:
        if len(a)==0:
            print 'A'
            break
        elif a[0]=='b':
            f=1
        elif a[0]=='c':
            f=2
        a=a[1:]
    elif f==1:
        if len(b)==0:
            print 'B'
            break
        elif b[0]=='a':
            f=0
        elif b[0]=='c':
            f=2
        b=b[1:]
    else:
        if len(c)==0:
            print 'C'
            break
        elif c[0]=='a':
            f=0
        elif c[0]=='b':
            f=1
        c=c[1:]


Measured memory_bytes: 2692
# coding: utf-8
# Your code here!

n = int(input())
a = [int(i) for i in input().split()]


pmin = 10**9
pind = -1
qmax =  -10**9
qind = -1

for j,i in enumerate(a):
    if 0 <= i < pmin:
        pmin = i
        pind = j
    if qmax < i < 0:
        qmax = i 
        qind = j

#print(a)
#print(pmin,qmax, "pmin", "pmax")

pmax = pmin

if pind == -1: # 非負が0個
    ans = -sum(a) + 2*a[qind]
    print(ans)
    for i, ai in enumerate(a):
        if i != qind:
            print(qmax,ai)
            qmax -= ai
#            print(qind, i)
    exit()
    
elif qind == -1: # 負が0個
    ans = sum(a) - 2*a[pind]
    print(ans)
    if pind == 0:
        for i in range(2,n):
            print(pmax, a[i])
            pmax -= a[i]
        print(a[1], pmax)
    else:
        for i in range(1,n):
            if i==pind: continue
            print(pmax, a[i])
            pmax -= a[i]
        print(a[0], pmax)
    exit()

else:
#    print("pq")
    ans = 0
    for ai in a:
        ans += abs(ai)
    print(ans)
    for i, ai in enumerate(a):
        if i == pind or i == qind: continue
        if ai <= 0:
            print(pmax, ai)
            pmax -= ai
        if ai > 0:
            print(qmax,ai)
            qmax -= ai
    print(pmax,qmax)
        
    







Measured memory_bytes: 14260
#include <iostream>

using namespace std;

int main() {
    string s;
    string t;
    int tempCollect = 0;
    int collect = 2000;

    cin >> s;
    cin >> t;

    for (int i = 0; i <= s.length() - t.length(); i++) {
        for (int j = 0; j < t.length(); j++) {
            if (s[j + i] != t[j]) {
                tempCollect++;
            }
        }
        if (tempCollect < collect) {
            collect = tempCollect;
        }
        tempCollect = 0;
    }

    cout << collect << endl;
}

Measured memory_bytes: 3532
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W = map(int, input().split())
c = []
for _ in range(H):
  c.append(list(input()))
Q = dq([])
Q.append((0, 0))
dist = [[float("inf")] * W for _ in range(H)]
d = [-1, 0, 1, 0]
dist[0][0] = 1
while len(Q):
  p = Q.popleft()
  for i in range(4):
    y = p[0] + d[i]
    x = p[1] + d[-1 - i]
    if (0 <= y < H) and (0 <= x < W):
      if c[y][x] == "." and (dist[y][x] > dist[p[0]][p[1]] + 1):
        Q.append((y, x))
        dist[y][x] = dist[p[0]][p[1]] + 1
if dist[H - 1][W - 1] == float("inf"):
  print(-1)
  exit(0)
black = 0
for i in range(H):
  black += c[i].count("#")
print(H * W - dist[H - 1][W - 1] - black)

Measured memory_bytes: 40176
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
  cin>>s;
  int i,c1,c2;
  char c,t;
  c= s[0];
  c1=c2=0;
  for(i=0;i<4;i++)
  {
    if(c==s[i])
      c1++;}
 for(i=0;i<4;i++)
 {
   if(c!=s[i])
   { t=s[i];
    break;
   }
 }
  for(i=0;i<4;i++)
  {
    if(t==s[i])
      c2++;}
  if(c1==2&&c2==2)
    cout<<"Yes";
  else
    cout<<"No"; 
  return 0;
}

    


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

int n;
ll a[20][20];
ll cost[1<<16];

vector < int > moves , not_taken;
void sos(int i , int mask)
{
    if(i == (int) not_taken.size())
    {
        moves.push_back(mask);
        return;
    }
    sos(i+1,mask) , sos(i+1,mask^(1<<not_taken[i]));
}
ll dp[1<<16];
ll get(int mask = (1<<n)-1)
{
    if(mask == 0)return 0;
    if(~dp[mask]) return dp[mask];
    dp[mask] = 0;

    not_taken.clear();
    moves.clear();
    for(int i = 0 ; i < n ; i++)
        if(mask>>i&1)
            not_taken.push_back(i);
    sos(0,mask);

    for(auto mask2 : moves)
        dp[mask] = max(dp[mask] , get(mask^mask2) + cost[mask2]);

    return dp[mask];
}
int main()
{
    scanf("%d",&n);
    for(int i = 0 ; i < n; i++)
        for(int j = 0 ; j < n; j++)
            scanf("%lld",&a[i][j]);

    for(int mask = 0 ; mask < (1<<n) ; mask++)
        for(int i = 0 ; i < n; i++)
            if(mask>>i&1)
            for(int j = i+1 ; j < n ; j++)
                if(mask>>j&1)
                    cost[mask] += a[i][j];
    memset(dp,-1,sizeof dp);
    printf("%lld\n",get());
    return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            String[] tokens = line.split(" ");
            int a = Integer.parseInt(tokens[0]);
            int b = Integer.parseInt(tokens[1]);
            System.out.println(a+b);
        }
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(BufferedReader br) throws IOException {
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip(BufferedReader s) throws IOException {
        return Integer.parseInt(s.readLine());
    }
}

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

int main() {
  int a, b, k; cin >> a >> b >> k;
  
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      k--;
      if (k == 0) {
        cout <<  i << endl;
        return 0;
      }
    }
  }
  
  assert(false);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w,'0'));
  vector<int> dh(h);
  vector<int> dw(w);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cin>>a.at(i).at(j);
  }
  for(int i=0;i<h;i++){
    int cnt=0;
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='.') cnt++;
    }
    if(cnt==w) dh.at(i)=1;
  }
  for(int i=0;i<w;i++){
    int cnt=0;
    for(int j=0;j<h;j++){
      if(a.at(j).at(i)=='.') cnt++;
    }
    if(cnt==h) dw.at(i)=1;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(dh.at(i)==0 && dw.at(j)==0) cout<<a.at(i).at(j);
    }
    if(dh.at(i)==0) cout<<endl;
  }
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
T = 0
for i in range(n-2):
    if p[i+1] < p[i+2] and p[i+1] >= p[i]:
        T += 1
    elif p[i+1] < p[i] and p[i+1] >= p[i+2]:
        T += 1
print(T)

Measured memory_bytes: 3060
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){
	int n,m,min,tmp;
	scanf("%d",&n);
	int minimum[n+1];
	scanf("%d",&m);
	int coin[m];
	for(int i=0;i < m; i++)scanf("%d",&coin[i]);

	minimum[0] = 0;
	minimum[1] = 1;
	for(int i=2;i<=n;i++){
		min = n+1;
		for(int k=0;k<m;k++){
			if(coin[k] <= i){	//?????????????????¢???????????\?????§????????´???????????????
				tmp = 1 + minimum[i-coin[k]];
				min = (min <= tmp)?min:tmp;
			}
		}
		minimum[i] = min;
	}

	printf("%d\n",minimum[n]);

    return 0;
}

Measured memory_bytes: 2916
#include <iostream>
#include <cstdio>

using namespace std;

char c;
string s;
int cnt = 0;

int main()
{
    cin>>s;
    c = s[0];
    for(int i = 1; s[i]; i++)
    {
        if(c != s[i])
        {
            c = s[i];
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}


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

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

	int* A = new int[N];

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;

		A[a - 1] = i + 1;
	}
	
	for (int i = 0; i < N; i++) {
		cout << A[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1152
import copy
INF = 10000000000
def Partition(A,p,r):
    x = A[r][1]
    i = p-1
    for j in range(p,r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
            flag = 1
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def Qsort(A,p,r):
    if p < r:
        q = Partition(A,p,r)
        Qsort(A,p,q-1)
        Qsort(A,q+1,r)

def merge(A, left, mid, right):
    count = 0
    L = A[left:mid] + [(INF,INF)]
    R = A[mid:right] + [(INF,INF)]

    i, j = 0, 0
    for k in range(left, right):
        count = count + 1
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return count

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        countL = mergeSort(A, left, mid)
        countR = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + countL + countR
    return 0

N = int(input())
C = []
for i in range(N):
    C.append(input().split())
    C[i][1] = int(C[i][1])

D = copy.deepcopy(C)
Qsort(C,0,N-1)
mergeSort(D,0,N)

if C==D:
    print("Stable")
else:
    print("Not stable")
for i in range(N):
    print(C[i][0]+" "+str(C[i][1]))



Measured memory_bytes: 47388
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple {
    private int n;
    private int[] a;
    void Solve() {
        //input
        n = io.Int;
        a = new int[n];
        for(int i = 0; i < n; ++i)
            a[i] = io.Int;
        //cal
        var b = new int[n];
        var hIndex = 0;
        var tIndex = n - 1;
        Array.Reverse(a);
        for(int i = 0; i < n; ++i) {
            if(i % 2 == 0)
                b[hIndex++] = a[i];
            else
                b[tIndex--] = a[i];
        }
        //ret
        foreach(var v in b)
            Write(v + " ");
        WriteLine("");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 34444
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		string str;
		cin >> str;
		while(n--){
			stringstream ss;
			const char *p = str.c_str();
			char n = *(p++);
			int c = 1;
			while(*p != '\0'){
				if(*p != n){ ss << c << n; n = *p; c = 0; }
				c++;
				p++;
			}
			ss << c << n;
			str = ss.str();
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int right = 0, left = 0;
    vector<int> vi;
    string s;

    while (cin >> s) {
        if(s == "+") {
            right = vi.back();
            vi.pop_back();
            left = vi.back();
            vi.pop_back();
            
            vi.push_back(left + right);
        } else if(s == "-") {
            right = vi.back();
            vi.pop_back();
            left = vi.back();
            vi.pop_back();
        
            vi.push_back(left - right);    
        } else if(s == "*") {
            right = vi.back();
            vi.pop_back();
            left = vi.back();
            vi.pop_back();

            vi.push_back(left * right);            
        } else {
            vi.push_back(stoi(s));
        }
    }
    
    for(auto i: vi) {
        cout << i << endl;
    }
}



Measured memory_bytes: 3176
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
using namespace std;

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(a*x, a*y); }
    Point operator / (double a) { return Point(x/a, y/a); }

    double abs() {return sqrt(norm()); }
    double norm() {return x*x + y*y; }
};

typedef Point Vector;


double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

Point projection(Point p1, Point p2, Point p) {
    Vector v = p2 - p1;
    Vector u = p - p1;
    Point t = p1 + v*dot(u,v)/v.norm();
    return t;
}

double dist(Point p0, Point p1, Point p);

int main(){
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        Point p0, p1, p2, p3;
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        
        double d2 = dist(p0,p1,p2);
        double d3 = dist(p0,p1,p3);
        double r2 = d3/(d2+d3);
        double r3 = d2/(d2+d3);

        Point crossp = projection(p0, p1, p2)*r2 + projection(p0, p1, p3)*r3;

        cout << setprecision(14) << crossp.x << " " << crossp.y <<"\n";
    }
    
    return 0;
}

double dist(Point p0, Point p1, Point p){
    Vector v = p1 - p0;
    Vector u = p - p0;

    return fabs(cross(v,u))/v.abs();
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int tab[200010];
bool bisa[1000010];
int ada[1000010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1 ; i <= n ; i++)
    {
        int ta;
        cin >> ta;
        ada[ta] += 1;
        tab[i] = ta;
    }
    memset(bisa,1,sizeof(bisa));
    for (int i = 1 ; i <= 1000000 ; i++) if (ada[i])
    {
        // cout << i << ": ";
        for (int j = i + i ; j <= 1000000 ; j += i)
        {
            // cout << j << " ";
            bisa[j] = 0;
        }
        
        bisa[i] &= (ada[i] == 1);
        // cout << bisa[i];
        // cout << endl;
    }
    // cout << bisa[24] << endl; 
    int ans = 0;
    for (int i = 1 ; i <= n ; i++)
        ans += bisa[tab[i]];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9280
class CountingSort:
    def countingSort(self, a, b, k):
        n = len(a)
        c = [0] * (k + 1)
        for j in a:
            c[j] += 1
        
        for i in range(1, k + 1):
            c[i] = c[i] + c[i-1]
            
        for j in a[::-1]:
            b[c[j]] = j
            c[j] -= 1
        return b[1:]

if __name__ == '__main__':
    n = int(input().rstrip())
    a = [int(i) for i in input().rstrip().split(" ")]
    b = [0] * (n + 1)
    k = max(a)
    x = CountingSort()
    print(" ".join([str(i) for i in x.countingSort(a, b, k)]))

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

int main() {
  int N;
  int A[110];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = N - 1; j > i; j--) {
      if (A[j - 1] > A[j]) {
        int v = A[j - 1];
        A[j - 1] = A[j];
        A[j] = v;
        cnt++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << "\n" << cnt << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#define MAX 1000000000
using namespace std;
int w,h;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
int func(int y,int x,int now,int tab[][20]){
	if(now>10)
	return MAX;
	int ans=MAX,nx,ny;
	for(int i=0;i<4;i++){
		nx=dx[i]+x;
		ny=dy[i]+y;
		if(nx>=0&&nx<w&&ny>=0&&ny<h&&tab[ny][nx]==1)
		continue;
		while(nx>=0&&nx<w&&ny>=0&&ny<h){
			if(tab[ny][nx]==1||tab[ny][nx]==3)
				break;
			nx+=dx[i];
			ny+=dy[i];
		}
		if(!(nx>=0&&nx<w&&ny>=0&&ny<h)){
			continue;
		}else if(tab[ny][nx]==1){
			tab[ny][nx]=0;
			ans=min(ans,func(ny-dy[i],nx-dx[i],now+1,tab));
			tab[ny][nx]=1;
		}else if(tab[ny][nx]==3){
			ans=min(ans,now);
		}
	}
	return ans;
}
int main(){
	int sy,sx;
	while(cin>>w>>h,w||h){
		int tab[20][20];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			cin>>tab[i][j];
			if(tab[i][j]==2){
				sy=i;
				sx=j;
			}
		}
		
		int ans=func(sy,sx,1,tab);
		if(ans!=MAX&&ans<11)
			cout<<ans<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
n, m = list(map(int, input().split()))
 
a = []
b = []
c = {}
for i in range(m):
    _a, _b = list(map(int, input().split()))
    a.append(_a)
    b.append(_b)
    c[i] = list(map(int, input().split()))
    
inf = int(10e+6)
 
dp = [inf]*(2**n)
dp[0] = 0
 
def rec(dp_i, cost):
    if dp[dp_i] > cost:
        dp[dp_i] = cost
        
    return
 
for _ci, _cv in c.items():
    now = 0
    for _v in _cv:
        now |= 1 << _v-1
    
    for bits in range(1 << n):
        rec(bits|now, dp[bits] + a[_ci])
 
        
if dp[(1 << n) - 1] == inf:
    print(-1)
else:
    print(dp[(1 << n) - 1])

Measured memory_bytes: 3424