akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main(){
    int d,N;
    cin>>d;
    for(int i=0;i<d;i++){
        int N;
        cin>>N;
        char fie[200][200];
        for(int i=0;i<200;i++){
            for(int j=0;j<200;j++)fie[i][j]=' ';
        }
        for(int j=0;j<N;j++)fie[j][0]='#';
        int x=0,y=0;
        for(int j=0;;j++){
            int p=(N-1)-(j/2*2);
            if(p<=0||(p==1&&j%2==1&&N%2==0))break;
            for(int k=0;k<p;k++){
                y+=dy[j%4],x+=dx[j%4];
                fie[y][x]='#';
            }
        }
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                cout<<fie[j][k];
            }
            puts("");
        }
        if(i!=d-1)puts("");
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, ans = 0; cin >> N;
  vector<ll> data(100010, 0);
  rep(i, N){
    ll a; cin >> a;
    data[a]++;
    ans += a;
  }
  ll Q; cin >> Q;
  rep(i, Q){
    ll b, c; cin >> b >> c;
    ans -= data[b] * b;
    ans += data[b] * c;
    data[c] += data[b];
    data[b] = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;
int inf=1e9;
ll p=1e9+7;
ll ans[13];
ll ans1[13];
int cua[13];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);

    string s;
    cin>>s;
    int n=s.size();
    ans[0]=1;
    ll d=1LL;
    int sum=0;
    for(int i=n-1;i>-1;i--){
        if(s[i]=='?'){
            for(int j=0;j<13;j++) ans1[j]=0;
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    ans1[(j+k*d)%13]+=ans[j];
                }
            }
            for(int j=0;j<13;j++) ans[j]=ans1[j]%p;
        }
        else{
            int k=s[i]-'0';
            k*=d;
            k%=13;
            sum+=k;
            sum%=13;
        }
        d*=10;
        d%=13;
    }
    int k=5-sum;
    ((k%=13)+=13)%=13;
    cout<<ans[k];
    return 0;
}


Measured memory_bytes: 512
//
//  main.cpp
//  DPi
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    vector<double>p(n+1);
    vector<vector<double>>dp(n+1,vector<double>(n+1));
    for (int i=1; i<=n; i++) {
        cin >> p.at(i);
    }
    dp.at(1).at(0)=1-p.at(1);
    dp.at(1).at(1)=p.at(1);
    for (int j=2; j<=n; j++) {
        dp.at(j).at(0)=dp.at(j-1).at(0)*(1.0-p.at(j));
        for (int k=1; k<j; k++) {
            dp.at(j).at(k)=dp.at(j-1).at(k-1)*p.at(j)+dp.at(j-1).at(k)*(1.0-p.at(j));
        }
        dp.at(j).at(j)=dp.at(j-1).at(j-1)*p.at(j);
    }
    double ans=0.0;
    for (int i=n/2+1; i<=n; i++) {
        ans+=dp[n][i];
    }
    printf("%10.10lf\n",ans); // 書式付の出力
    return 0;
}


Measured memory_bytes: 70656
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	auto start=a.begin();
	ll fnum=0;
	FOR(i,1,n+1){
		auto it=find(start,a.end(),i);
		if(it==a.end())break;
		else{
			fnum++;
			start=it;
		}
	}
	if(fnum==0)cout<<-1<<endl;
	else cout<<n-fnum<<endl;
	return 0;
}


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

int main(void){
    int t;
    int minus{0};
    int sum{0};

    for(int i=0; i<5; ++i){
        cin >> t;
        sum += t;
        if(sum%10!=0){
            sum += 10-sum%10;
            if(10-t%10>minus)
                minus = 10-t%10;
        }
    }

    cout << sum-minus << endl;
}

Measured memory_bytes: 256
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "20" => "15800",
    "60" => "47200",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    (1..n + 1).fold(0, |mut acc, x| {
        acc += 800;

        if x % 15 == 0 {
            acc -= 200;
        }

        acc
    }).to_string()
}

Measured memory_bytes: 4352
#include <iostream>

int main(int argc, const char * argv[]) {
    int h, w;
    for ( ; std::cin >> h >> w && !(h == 0 && w ==0); ) {
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                std::cout << "#";
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}

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

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

    if(n==0)
      break;

    char c[100];
    for(int i=0; i<n; i++){
      cin >> c[i];
    }

    int cnt[26] = {0};

    for(int i=0; i<n; i++){
      cnt[(int)(c[i])-'A']++;

      int max1 = -1;
      int max2 = -1;

      for(int j=0; j<26; j++){
        if(cnt[j]>max1){
          max2 = max1;
          max1 = cnt[j];
        }
        else if(cnt[j]>max2){
          max2 = cnt[j];
        }
      }
      if(max1-max2>n-(i+1)){
        for(int j=0; j<26; j++){
          if(cnt[j]==max1){
            cout << (char)(j+'A') << ' ';
            break;
          }
        }
        cout << (i+1) << endl;
        break;
      }
      if(i==n-1){
        cout << "TIE" << endl;
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3088
input_str = input().split()
amount_to_make = int(input_str[0])
lot_size = int(input_str[1])
time_to_make_one_lot = int(input_str[2])

proceeded_time = 0
made_amount = 0
while made_amount < amount_to_make:
    made_amount += lot_size
    proceeded_time += time_to_make_one_lot

print(proceeded_time)


Measured memory_bytes: 9144
import sys
N =int(input())
D = []
for i in range(N):
  d_1,d_2 = map(int,input().split())
  D.append([d_1,d_2])
for x in range(N-2):
  if D[x][0]==D[x][1] and D[x+1][1]==D[x+1][0] and D[x+2][1]==D[x+2][0]:
    print("Yes")
    sys.exit()
print("No")


Measured memory_bytes: 9180
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<char>>v1(n,vector<char>(n,0));
    vector<vector<char>>v2(m,vector<char>(m,0));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>v1[i][j];
        }
    }
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>v2[i][j];
        }
    }
    bool yes=0;
    for(int i=0;i<=n-m;i++)
    {
        for(int j=0;j<=n-m;j++)
        {
            bool no=0;
            for(int k=0;k<m;k++)
            {
                for(int p=0;p<m;p++)
                {
                    if(v1[i+k][j+p]!=v2[k][p]){
                        no=1;
                        break;
                    }
                }
                if(no){
                    break;
                }
            }
            if(!no){
                yes=1;
                break;
            }
        }
        if(yes){
            break;
        }
    }
    if(yes){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint Q;
bool prime[100005];
llint sum[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	for(int i = 2; i < 100005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 100005; j+=i) prime[j] = true;
	}
	
	for(int i = 2; i < 100005; i++){
		sum[i] = sum[i-1];
		if(i % 2 && !prime[i] && !prime[(i+1)/2]) sum[i]++;
	}
	
	cin >> Q;
	llint l, r;
	for(int q = 0; q < Q; q++){
		cin >> l >> r;
		cout << sum[r] - sum[l-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int M = 100000;

int n;
int da[100010];
int f[100010];
long long p[200010];

inline int lowbit(int x){return x&(-x);}

void up(int pos, int val){
	for(int i = pos; i <= 2*n+1; i += lowbit(i)){
		p[i] += val;
	}
}

long long que(int pos){
	long long ans = 0;
	for(int i = pos; i; i -= lowbit(i)){
		ans += p[i];
	}
	return ans;
}

long long calc(int x){
	memset(f, 0, sizeof(f));
	memset(p, 0, sizeof(p));
	for(int i = 1; i <= n; i ++){
		if(da[i] >= x) f[i] = 1;
		else f[i] = -1; 
		f[i] += f[i-1];
	}
	long long res = 0;
	up(n+1, 1);
	for(int i = 1; i <= n; i ++){
		up(f[i]+n+1, 1);
		res += que(2*n+1) - que(f[i]+n+1);
	}
	return res;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &da[i]);
	}
	if(n == 1) {printf("%d\n", da[1]); return 0;}
	int l = 1, r = 1e9+1, ans = 0;
	while(l <= r){
		int mid = (l+r) >> 1;
		if(calc(mid) <= ((long long)(1+n)*n/2)/2 + 1){
			l = mid + 1, ans = mid;
		}else r = mid - 1;
	} 
	printf("%d\n", ans);
	return 0;	
}

Measured memory_bytes: 2560
// template version 1.10
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
//}}}

// dump macro {{{
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
// }}}

template<typename T=int>/*{{{*/
struct BIT {
  public:
    vector<T> data;  // 1-index

    // constructor
    BIT(vector<T> v){  // v: 0-index vector
      data = vector<T>(sz(v)+1);
      rep(i, 1, sz(v)) add(i+1, v[i]);
    }
    BIT(int n){
      data = vector<T>(n+1);
    }
    //------------

    T cum(int idx){
      T res = 0;
      for (int i = idx; i > 0; i -= i&-i) res += data[i];
      return res;
    }

    void add(int idx, T x){
      for (int i = idx; i <= (int)data.size(); i += i&-i){
        data[i] += x;
      }
    }

  private:
};/*}}}*/

int solve(){
  int n;cin>>n;
  vector<int> a(n+1);
  rep(i, n) {
    cin>>a[i+1];
  }
  dump(a);

  int L = (n+1)*n/2;
  dump(L);

  int left = 0;
  int right = 1e9+1;
  auto isright = [&](int x) {  // is k(x) <= L/2 -> false
    vi b(n+1, 0);
    BIT<int> bit(2e5+5);
    bit.add(0+1e5+2, 1);
    int k = 0;
    rep(i, 1, n+1){
      b[i] = b[i-1];
      if(a[i]<=x) b[i]+=1;
      else b[i]-=1;

      k += bit.cum(b[i]+1e5+2-1);
      bit.add(b[i]+1e5+2, 1);
      // dump(k);
    }

    if (k<=L/2){
      // dump(x, k, "left");
      return false;
    }
    else if (k>=L/2+1){
      // dump(x, k, "right");
      return true;
    }
  };

  while (right-left>1){
    int mid = (right+left)/2;
    if (isright(mid)) { right = mid;}
    else{ left = mid; }
  }
  dump(right);
  cout << right << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int N,Q;
vector<int> edges[200000];
long long num[200000];

void dfs(int i, int p){
  for(int j : edges[i]) {
    if (j != p) {
      num[j] += num[i];
      dfs(j, i);
    }
  }
}
       
int main() {
  cin >> N >> Q;
  
  for (int i = 0; i < N -1; ++i) {
    int a,b;
    cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }
  for (int i=0; i<Q; ++i) {
    int p,x;
    cin >> p >> x;
    num[p-1] += x;
  }
  dfs(0, -1);
  for(int i=0; i<N; i++) cout << num[i] << " \n"[i==N-1];
  return 0;
}

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

int main() {
	long long A, B, C, D, max;
	scanf("%lld%lld%lld", &A, &B, &C);
	if ((A>=B && B>=C) || (A>=C && C>=B)) D = B*C*(A%2);
	else if ((A>=B && C>=A) || (A<=B && B<=C)) D = A*B*(C%2);
	else if ((B>=A && A>=C) || (B>=C && C>=A)) D = C*A*(B%2);

	printf("%lld\n", D);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <list> //???????????????????????????
#include <vector>//????????¢??????????????????
#include <climits>
using namespace std;


bool solve(int i, int m , const vector <int> &A){
	if (m == 0){
		return true;
	}
	
	int n= A.size();
	
	if (i >= n){
		return false;
	}
	
	bool res = solve(i + 1, m, A) || solve(i + 1, m - A[i], A);
	return res;

}

int main(void){
	std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> A(n);
	for(int i=0 ; i < n; i++){
		cin >> A[i];
	}
	int q;
	cin >> q;
	vector <int> mi(q);
	for(int i=0 ; i < q; i++){
		cin >> mi[i];
	}
	for(int j =0 ; j < q ; j++){
		
		if(solve(0,mi[j],A)){
			cout << "yes" << endl;
		}else cout << "no" << endl;
	}
		
	

}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    long long k = 0, n = s.length();
    for (long long i = 0; i < n; i++)
        if (s[i] == 'p') k++;
    cout << n / 2 - k;
}

Measured memory_bytes: 3732
import sys
input = sys.stdin.readline
read = sys.stdin.read

n, t = map(int, input().split())
m = map(int, read().split())
AB = sorted(zip(m, m))
A, B = zip(*AB)
dp = [[0]*t for _ in range(n+1)]
for i, a in enumerate(A[:-1]):
  for j in range(t):
    if j < a:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j-a]+B[i], dp[i][j])
ans = 0
maxB = [B[-1]]*n
for i in range(n-2, 0, -1):
  maxB[i] = max(B[i], maxB[i+1])
for i in range(n-1):
  ans = max(ans, dp[i+1][-1] + maxB[i+1])
print(ans)

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int d[100000];

int main()
{
    canhazfast();

    int n, h;

    cin >> n;
    h = n/2;
    for (int i = 0; i < n; ++i) cin >> d[i];
    sort(d, d+n);
    cout << d[h]-d[h-1] << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int a[5],k;
  rep(i,0,5) cin>>a[i];
  cin>>k;
  rep(i,1,5){
    if(a[i]-a[0]>k){
      cout<<":(\n";
      return;
    }
  }
  cout<<"Yay!\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 
ll dp[110][100010] = {};
int main(){
  ll N, W, w, v;
  vector<ll> item[101];
  cin >> N >> W;
  rep(i, 0, N){
    cin >> w >> v;
    item[i].push_back(w);
    item[i].push_back(v);
  }

  rep(i, 0, N){
    rep(weight, 0, W){
      if (weight + 1 - item[i][0] >= 0){
      dp[i+1][weight+1] = max(dp[i][weight+1], dp[i][weight+1 - item[i][0]] + item[i][1]);
      }else{
        dp[i+1][weight+1] = dp[i][weight+1];
      }
    }
  }
  print(dp[N][W]);
  

  return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define ub upper_bound 
#define lb lower_bound 
#define pb push_back
#define s second 
#define f first 
#define ma 1000000007	
#define fr(n) for(i=0;i<n;i++)
struct well {
	ll aa,bb,cc,dd;
};
ll ans [1000][1000];
int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	ll i,j,k=0,x=0,y=0,z=0,c=0,mini=0,anss=LLONG_MIN,last,sum=0;
	ll n,a,m=0,b,f,c0,d0;
	cin>>n>>a;
	
	char A[n+5][a+5];
	memset(A,'.',sizeof(A));
	for(i=1;i<=n;i++)
	for(j=1;j<=a;j++)
	cin>>A[i][j];
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=a;j++)
		{
		if(A[i][j]=='#')
		continue;
		if(A[i-1][j]=='#')
		ans[i][j]+=1;
		if(A[i-1][j+1]=='#')
		ans[i][j]+=1;
		if(A[i-1][j-1]=='#')
		ans[i][j]+=1;
		if(A[i][j+1]=='#')
		ans[i][j]+=1;
		if(A[i][j-1]=='#')
		ans[i][j]+=1;
		if(A[i+1][j]=='#')
		ans[i][j]+=1;
		if(A[i+1][j+1]=='#')
		ans[i][j]+=1;
		if(A[i+1][j-1]=='#')
		ans[i][j]+=1;
		
	}
	}
		for(i=1;i<=n;i++,cout<<endl)
	for(j=1;j<=a;j++)
	if(A[i][j]=='#')
	cout<<"#";
	else cout<<ans[i][j];
	
	
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main() {
  char x[100];
  scanf ("%s",x);
  int n;
  for (n=0;n<100;n++) {
    if (x[n] == ',') x[n] = ' ';
  }
  printf ("%s\n",x);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 107;
int n, mx;
int a[N], cnt[N];
int main() {
#ifdef fwat
#endif
	n = gi();
	rep(i, 1, n) a[i] = gi();
	sort(a + 1, a + 1 + n);
	mx = a[n];
	rep(i, 1, n) ++cnt[a[i]];
	int gg = mx / 2 + (mx & 1);
	rep(i, 1, gg - 1) if(cnt[i]) return puts("Impossible"), 0;
	rep(i, gg + 1, mx) if(cnt[i] < 2)
		return puts("Impossible"), 0;
	if(mx % 2 == 0) {
		if(cnt[gg] != 1) return puts("Impossible"), 0;
	}else {
		if(cnt[gg] != 2) return puts("Impossible"), 0;
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ma[55][55];
int used[55][55];
int used2[55][55];
int w,h;
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};

int dfs(int x,int y){
  if(x<0||y<0||x==h||y==w)return 2;
  if(ma[x][y]=='B')return 1;
  if(ma[x][y]=='W')return 0;
  if(used[x][y])return 2;
  used[x][y]=1;
  int sum[4]={};
  for(int i=0;i<4;i++)
    sum[dfs(x+dx[i],y+dy[i])]++;
  if(sum[3])return 3;
  if(sum[0]&&sum[1])return 3;
  if(sum[0])return 0;
  if(sum[1])return 1;
  return 2;
}

int dfs2(int x,int y){
  if(x<0||y<0||x==h||y==w)return 0;
  if(used2[x][y])return 0;
  if(ma[x][y]!='.')return 0;
  used2[x][y]=1;
  int sum=1;
  for(int i=0;i<4;i++)sum+=dfs2(x+dx[i],y+dy[i]);
  return sum;
}

int main(){
  while(cin>>w>>h,w+h){
    memset(used,0,sizeof(used));
    memset(used2,0,sizeof(used2));
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>ma[i][j];
    int ans[2]={};
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(used[i][j]==0&&ma[i][j]=='.'){
	  int t=dfs(i,j);
	  if(t==0||t==1)ans[t]+=dfs2(i,j);
	}
    cout<<ans[1]<<" "<<ans[0]<<endl;
  }
  return 0;
}


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

int main(){

	int t = 1;
	//cin >> t;
	while(t--){
		ll a;
		long double b;
		cin >> a >> b;
		cout << (ll)(a*b);
	}
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

    int n;
    cin >> n;

    int tmp = n;
    while(true){
        int i;
        for(i = 2; i < tmp; i++){
            if (tmp % i == 0){
                tmp++;
                break;
            }
        }
        if (i == tmp){
            cout << tmp << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    vector<lli> divider_n;
    for(lli i = 1; i * i <= n; ++i){
        if(i * i == n){
            divider_n.push_back(i);
        }else if(n % i == 0){
            divider_n.push_back(i);
            divider_n.push_back(n / i);
        }
    }

    lli ans = 0;
    for(lli i = 1; i < divider_n.size(); ++i){
        lli m = divider_n[i] - 1;
        if(n / m == n % m){
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long H = cin.nextLong();
            long W = cin.nextLong();

            long N = H * W;
            if (H == 1 || W == 1)
            {
                Console.WriteLine(1);
            }
            else if (N % 2 == 0)
            {
                Console.WriteLine(N / 2);
            }
            else
            {
                Console.WriteLine(N / 2 + 1);
            }
        }

    }
}


Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

using namespace std;

const int N = (int) 1e5 + 100;
int a[N];
int f[N];
int n;

int build(int x){
	if(x == n + 1)
		return 0;
		
	return f[x] = build(x + 1) + abs(a[x] - a[x + 1]);
}

int main (){
	
	cin >> n;

	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	
	build(0);
	
	for(int i = 1 ; i <= n ; i++){
		if(i == 1){
			cout << f[i + 1] + abs(a[i + 1]) << '\n';
		}else if(i == n){
			cout << f[0] - f[n - 1] + abs(a[n - 1]) << '\n';
		}else{
			cout << f[0] - f[i - 1] + abs(a[i - 1] - a[i + 1]) + f[i + 1] << '\n' ;
		}
	}
	
	return 0;
}

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

int main() {
	int h, w;

	cin >> h >> w ;

	vector<vector<char>> a(h, vector<char>(w));
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	vector<bool> x(h,false);
	vector<bool> y(w, false);

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j]=='#') {
				x[i] = true;
				y[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (x[i]) {
			for (int j = 0; j < w; j++) {
				if (y[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
// AtCoder Regular Contest 075
// F - Mirrored

#include <cstdio>
#include <cmath>
using namespace std;
typedef long long int ll;


const int MAX_K = 9;

ll D;
ll pow_dec[2 * MAX_K + 1];
ll ans;

ll count_n(int l, int r, ll d) {
    if (l - r < 0) {
        return (d == 0) ? 1 : 0;
    }

    ll cnt = 0;
    int k;
    int d_ini = (d / pow_dec[r] % 10 + 10) % 10;
    d_ini = (r == 0 && d_ini > 0) ? d_ini - 10 : d_ini;
    for (int i = d_ini; i > -10; i -= 10) {
        k = 10 - abs(i);
        if (r == 0 && -i >= 0) {
            k--;
        }
        cnt += k * count_n(l - 1, r + 1, d + i * pow_dec[l] - i * pow_dec[r]);
    }

    return cnt;
}

int main() {

    pow_dec[0] = 1;
    for (int i = 1; i <= 2 * MAX_K; i++) {
        pow_dec[i] = pow_dec[i - 1] * 10;
    }

    scanf("%lld", &D);

    ans = 0;
    for (int i = 0; i <= 2 * MAX_K; i++) {
        ans += count_n(i, 0, D);
    }

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

    return 0;

}


Measured memory_bytes: 128
#include<bits//stdc++.h>
using namespace std;
int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(a>x)
        cout<<"NO"<<endl;
    else if(a==x ||a+b>=x)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <unordered_map>
using namespace std;
int main(void) {
  int H, W, N;
  cin >> H >> W >> N;
  unordered_map <unsigned long long, int> ptlist;

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

    for (int h_pos = a-1; h_pos <= a+1; h_pos++) {
      if (h_pos <= 1) continue;
      if (h_pos >= H) continue;

      for (int w_pos = b-1; w_pos <= b+1; w_pos++) {
        if (w_pos <= 1) continue;
        if (w_pos >= W) continue;

        ptlist[((unsigned long long)h_pos<<32)+w_pos] += 1;

      }
    }
  }

  // output
  long long ans[10] = {0};
  ans[0] = ((unsigned long long)H-2)*(W-2) - ptlist.size();

	unordered_map <unsigned long long, int>::iterator it;
	for (it = ptlist.begin(); it != ptlist.end(); it++) {
    int depth = it->second;
		ans[depth]++;
	}

  for (int i = 0; i <= 9; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 38544
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	char s[64];
	while (scanf("%s", s), *s != '#')
	{
		int res = 0;
		char* left = "qwertasdfgzxcvb";
		for (int i = 1; s[i]; ++i)
		{
			bool a = strchr(left, s[i - 1]);
			bool b = strchr(left, s[i]);
			if (a ^ b)
				++res;
		}
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int C[3][3];
  for(int i=0; i<3; i++)
    for(int j=0; j<3; j++)
      cin >> C[i][j];
  bool ret = true;
  if(C[0][0] - C[0][1] == C[1][0] - C[1][1] &&
     C[0][0] - C[0][1] == C[2][0] - C[2][1] &&
     C[0][1] - C[0][2] == C[1][1] - C[1][2] &&
     C[0][1] - C[0][2] == C[2][1] - C[2][2] &&
     C[0][0] - C[1][0] == C[0][1] - C[1][1] &&
     C[0][0] - C[1][0] == C[0][2] - C[1][2] &&
     C[1][0] - C[2][0] == C[1][1] - C[2][1] &&
     C[1][0] - C[2][0] == C[1][2] - C[2][2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  else if(d == 24) cout << "Christmas Eve" << endl;
  else if(d == 23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a%3 && b%3 && (a+b)%3)
    cout << "Impossible" << endl;
  else
    cout << "Possible" << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val grid = (1..h).map { readLine()!! }

    val d = listOf(0 to 1, 1 to 0, 0 to -1, -1 to 0)

    for (y in (0 until h)) {
        for (x in (0 until w)) {
            if (grid[y][x] == '.') {
                continue
            }
            var found = false
            for ((dy, dx) in d) {
                val nextY = y + dy
                val nextX = x + dx
                if (nextY in 0 until h && nextX in 0 until w) {
                    if (grid[nextY][nextX] == '#') {
                        found = true
                        break
                    }
                }
            }
            if (!found) {
                println("No")
                return
            }
        }
    }
    println("Yes")
}

Measured memory_bytes: 37904
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1) {
        int H,W;
        cin >> H >> W;
        if (H+W==0){
            break;
        }
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                cout <<'#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
A,B,C,D,E,F = map(int,input().split())
solve = E/(100+E)
ans = [0,0,0]
for i in range(int(F//100//A)+1):
    for j in range(int((F-A*100*i)//100//B)+1):
        for k in range(int((F-A*100*i-B*100*j)//C)+1):
            for l in range(int((F-A*100*i-B*100*j-C*k)//D)+1):
                if  i!=0 or j!=0:
                    can = (C*k+D*l)/(A*100*i+B*100*j+C*k+D*l)
                    if solve>=can>=ans[0]:
                        
                        ans[0],ans[1],ans[2] = can,A*100*i+B*100*j+C*k+D*l,C*k+D*l

print(ans[1],ans[2])

Measured memory_bytes: 42732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=105;
int N,X;
int main(){
	//freopen("in","r",stdin);
	N=read(),X=read();
	int sum=0,ans=N+1;
	for(int i=1;i<=N;i++){
		sum+=read();
		if(sum>X){
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

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

bool dp[8010][16010];

int main() {
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    for (int i = 0; i < H; ++i) {
        char w[2]={'1','0'};
        if(i<B){
            w[0]='0';
            w[1]='1';
        }
        string s;
        for (int j = 0; j < W; ++j) {
            if(j<A) s+=w[0];
            else s+=w[1];
        }
        cout<<s<<endl;
    }
    return 0;
}


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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;

string s;
int ans[100100];


int main() {
  rep(i, 100099) {
  ans[i] = 0;
}

  cin >> s;
  int n = s.length();
  for(int i = 1; i < n-1; i++) {
    if(s[i] == 'R' && s[i+1] == 'L') {
      ans[i] = 1;
      for (int j = 1; i+j < n; j++) {
        if (s[i+j] == 'R') {
          break;
        }
        if (s[i+j] == 'L' && j%2 == 0) {
          ans[i]++;
        }
      }
      for (int j = 1; i-j >= 0; j++) {
        if (s[i-j] == 'L') {
          break;
        }
        if (s[i-j] == 'R' && j%2 == 0) {
          ans[i]++;
        }
      }
    }
    if(s[i] == 'L' && s[i-1] == 'R') {
      ans[i] = 1;
      for (int j = 1; i-j >= 0; j++) {
        if (s[i-j] == 'L') {
          break;
        }
        if (s[i-j] == 'R' && j%2 == 0) {
          ans[i]++;
        }
      }
      for (int j = 1; i+j < n; j++) {
        if (s[i+j] == 'R') {
          break;
        }
        if (s[i+j] == 'L' && j%2 == 0) {
          ans[i]++;
        }
      }
    }
  }

  if (s[1] == 'L') {
    ans[0] = 1;
    for (int j = 1; j < n; j++) {
      if (s[j] == 'R') {
        break;
      }
      if(s[j] == 'L' && j%2 == 0) {
        ans[0]++;
      }
    }
  }

  if (s[n-2] == 'R') {
    ans[n-1] = 1;
    for (int j = 1; n-1-j >= 0; j++) {
      if (s[n-1-j] == 'L') {
        break;
      }
      if (s[n-1-j] == 'R' && j%2 == 0) {
        ans[n-1]++;
      }
    }
  }

  rep(i, n) {
    if (i != 0) {
      cout << " ";
    }
    cout << ans[i];
    if (i == n-1) {
      cout << endl;
    }
  }

}


Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  string s;
  int a,b;
  cin >> a>>b;
  s = to_string(a)+to_string(b);
  auto ans = (int)sqrt(stoi(s));
  if(ans*ans ==stoi(s)){
  	cout<<"Yes";
  }else{
  	cout<<"No";
  }
  
}

Measured memory_bytes: 256
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:h=[];s+=sum(heappush(h,l-r)or l-(k<len(h)and heappop(h))for k,l,r in sorted(x))
 print(s)

Measured memory_bytes: 51392
#include <stdio.h>
#include <math.h>
int main(){
  int x;
  int i;
  int flag=0;
  scanf("%d",&x);
  
  while(1){
    for(i=2;i<x;i++){
      	if(x%i==0){
          flag=1;
          break;
        }
    }
    if(flag==1){
      x++;
      flag=0;
    } else {
      break;
    }
  }
  printf("%d",x);
}


Measured memory_bytes: 128
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


const int maxn=2e5+10;

ll d[maxn]={-1};
int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int k;
	cin>>k;
	
	string s;
	cin>>s;

	string f;


	if(s.size()<=k) cout<<s;

	else
	{
		for(int i=0;i<k;i++)
		{
			f+=s[i];
		}

		f+=".";
		f+='.';
		f+='.';
		cout<<f;

	}

	
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main() {
  map<char,int> m;
  rep(i,3) {
    char s;
    cin >> s;
    m[s]++; 
  }
  if(m.size() == 3) cout << "Yes" << endl;
  else cout << "No" << endl;  
}


Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[],int N){
  int i;
  for( i = 0 ; i < N; i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
    
void insertionSort(int A[], int N){
  int i,j,v; 
  for (i=1; i < N; i++) {
    v = A[i];
    j = i - 1; 
    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A,N); 
  }
}

int main(){
  int N,i,j;
  int A[100];
  
  scanf("%d",&N);
  for( i = 0 ; i < N; i++) scanf("%d",&A[i]);
  
  trace(A,N);
  insertionSort(A,N);

  return 0;
}
  



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int n,m,sum;
int r[50];
vector<int> v[50];
bool used[50];

void cnt(int idx) {
	used[idx]=true;
	sum++;
	int nxt,ccnt=0;
	REP(i,v[idx].size()) {
		if(used[v[idx][i]]) continue;
		ccnt++;
		nxt=v[idx][i];
	}
	if(ccnt==1) {
		cnt(nxt);
	}
	else sum--,used[idx]=false;
	return;
}

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

	REP(i,50) used[i]=false;

	cin>>n>>m;
	REP(i,m) {
		int a,b; cin>>a>>b; a--;b--;
		r[a]++; r[b]++;
		v[a].push_back(b); v[b].push_back(a);
	}
	REP(i,n) {
		if(r[i]==1) {
			cnt(i);
		}
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp);
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


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

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;

        vi x(n), y(n), r(n), c(n);
        REP(i, n) cin >> x[i] >> y[i] >> r[i] >> c[i];

        vi dp(1<<n);
        dp[0] = 1;
        REP(s, 1<<n) {
            if (dp[s] == 0) continue;

            map<int, vi> remove;
            REP(i, n) {
                if (s >> i & 1) continue;
                bool valid = true;
                REP(j, i) {
                    if (s >> j & 1) continue;
                    int dx = x[i] - x[j], dy = y[i] - y[j];
                    double d = sqrt(dx * dx + dy * dy);
                    if (r[i] + r[j] > d + eps) valid = false;
                }
                if (valid) remove[c[i]].push_back(i);
            }
            for (auto &tp : remove) {
                REP(i, tp.second.size()) {
                    FOR(j, i+1, tp.second.size()) {
                        int t = s;
                        t |= 1<<tp.second[i];
                        t |= 1<<tp.second[j];
                        dp[t] = 1;
                    }
                }
            }
        }

        int ans = 0;
        REP(s, 1<<n) if (dp[s]) chmax(ans, __builtin_popcount(s));
        cout << ans << endl;
    }

    return 0;
}



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

using namespace std;

int main()
{
    int ar[5],point,diff,max=-2590,i,s=0;
    cin>>ar[0]>>ar[1]>>ar[2]>>ar[3]>>ar[4];
    for (i=0;i<5;++i){

        if (ar[i]%10!=0){

            diff = (((ar[i]/10)+1)*10)-ar[i];
            if (diff>max){

                max=diff;
                point = i;

            }

        }

    }

    for (i=0;i<5;++i){

        if (point!=i){

            if (ar[i]%10!=0){

                diff = (((ar[i]/10)+1)*10);
                s+=diff;

            }
            else s+=ar[i];


        }

    }

    cout<<(s+ar[point])<<endl;
    return 0;

}


Measured memory_bytes: 256