akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> ls;
    ls.push_back(2);
    ls.push_back(1);
    for(int i = 2; i <= n; i++){
        ls.push_back(ls[i - 1] + ls[i - 2]);
        // prints(ls.back());
    }
    cout << ls.back() << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sumation=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sumation+=a[i];
    }
    ll sum1=a[0], sum2=sumation-sum1;
    ll ans=llabs(sum1-sum2);
    for(int i=1; i<N-1; i++){
        sum1+=a[i];
        sum2-=a[i];
        ll tmp=llabs(sum1-sum2);
        ans=min(ans, tmp);
    }
    cout << ans << endl;
    
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  string s, t;
  cin >> s >> t;
  ll n = s.size();
  ll buf = 0;
  bool judge = true;
  for(i = 'a'; i <= 'z' && judge; i++){
    for(j = 0, buf = 0; j < n; j++){
      if(s[j] == i && buf == 0){
        buf = t[j];
      }
      else if(s[j] == i && t[j] != buf){
        judge = false;
      }
        
    }
  }
  
  for(i = 'a'; i <= 'z' && judge; i++){
    for(j = 0, buf = 0; j < n; j++){
      if(t[j] == i && buf == 0){
        buf = s[j];
      }
      else if(t[j] == i && s[j] != buf){
        judge = false;
      }
        
    }
  }

  if(judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      s[i] = '9';
    } else {
      s[i] = '1';
    }
  }
  cout << s << endl;
}


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

int a[100005];

int main()
{
	int n,i,c,k,cnt=0,C=0,s=0;
	scanf("%d %d %d", &n, &c, &k);
	for(i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	std::sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		if(s<a[i]||C>=c)s=a[i]+k,cnt++,C=0;
		C++;
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using prior = priority_queue<T>;

const ll MOD = 1e9+7;
const ll SPMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define Unique(v) v.rs(unique(ALL(v))-v.begin())
#define EB emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

// template
ll POW();
int gcd(int a, int b);
// end of template

#define N 110

void solve(){
    int n, m;
    double sum = 0;
    
    cin >> n >> m;
    vec<double> v(n);
    for(auto &i:v){
        cin >> i;
        sum += i;
    }
    
    double k = sum / 4 / m;
    int cnt = 0;
    
    for(auto i:v){
        if(i >= k) cnt++;
    }
    
    cout << (cnt >= m ? "Yes" : "No" )<< '\n';
    
}

int main(){
    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


// templates

ll POW(ll a, ll b, ll m = MOD){
    ll res = 1;
    while(b){
        if(b&1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}


Measured memory_bytes: 256
use std::io;
use std::cmp::min;
fn main (){
    let input_one = read_ints();
    let a = input_one[1]; let b = input_one[2];
    let xs = read_ints();
    println!("{}", solve(&a,&b,&xs));
}

fn distances(xs:&[u64]) -> Vec<u64>{
    // Find the distance between adjacent cities
    xs.iter().zip(xs.iter().skip(1)).map(|(a,b)| b-a).collect()
}

fn solve(a:&u64, b:&u64, xs:&[u64]) -> u64 {
    let dists = distances(xs);
    dists.iter().fold(0, |acc,dist| {
        acc + min(a*dist, *b)
    })
}
fn read_ints() -> Vec<u64> {
    get_line().trim().split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

Measured memory_bytes: 6396
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

tot=sum(p[:X])+sum(q[:Y])

a=0
b=0
f=False
for i in r:
    if f==True:
        break
    elif a==X and b==Y:
        break
    elif a==X:
        if i>q[Y-b-1]:
            tot+=i-q[Y-b-1]
            b+=1
        else:
            f=True
    elif b==Y:
        if i>p[X-a-1]:
            tot+=i-p[X-a-1]
            a+=1
        else:
            f=True
    else:
        if i>p[X-a-1] and i>q[Y-b-1]:
            if p[X-a-1]<q[Y-b-1]:
                tot+=i-p[X-a-1]
                a+=1
            else:
                tot+=i-q[Y-b-1]
                b+=1
        elif i>p[X-a-1]:
            tot+=i-p[X-a-1]
            a+=1
        elif i>q[Y-b-1]:
            tot+=i-q[Y-b-1]
            b+=1
        else:
            f=True

print(tot)




Measured memory_bytes: 23328
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int a[6]={1,5,10,50,100,500},b[6],c[670000];
  fill(c,c+670000,-1);
  int n;
  while(cin>>n){
    int m=0;
    for(i=0;i<6;++i){
      cin>>b[i];
      m+=a[i]*b[i];
    }
    if(n==0)
      break;
    int mn=1<<30;
    for(i=n;i<=m;++i){
      int ct=0,sm=0;
      for(j=5;j>=0;--j){
	if(a[j]*b[j]>i-sm){
	  ct+=(i-sm)/a[j];
	  sm+=(i-sm)/a[j]*a[j];
	}else{
	  ct+=b[j];
	  sm+=a[j]*b[j];
	}
      }
      if(i>sm)
	continue;
      if(c[i-n]<0){
	int p=i-n;
	int ct=0;
	for(j=5;j>=0;--j){
	  ct+=p/a[j];
	  p-=p/a[j]*a[j];
	}
	c[i-n]=ct;
      }
      ct+=c[i-n];
      mn=min(mn,ct);
    }
    cout<<mn<<endl;
  }
  return 0;
}

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

using namespace std;

// Union-Find Tree
class DisjointSet {
private:
    struct Node {
        int parent;
        int rank;
    };

public:
    DisjointSet(size_t n) : _nodes(n) {
        int i = 0;
        for (auto& node : _nodes) {
            node.parent = i++;
            node.rank = 0;
        }
    }

    bool same(int a, int b) {
        return find(a) == find(b);
    }

    void unite(int a, int b) {
        link(find(a), find(b));
    }

    int find(int x) {
        if (x != _nodes[x].parent) {
            // path compression
            _nodes[x].parent = find(_nodes[x].parent);
        }
        return _nodes[x].parent;
    }

    void link(int a, int b) {
        if (_nodes[a].rank > _nodes[b].rank) {
            _nodes[b].parent = a;
        } else {
            _nodes[a].parent = b;
            if (_nodes[a].rank == _nodes[b].rank) {
                _nodes[b].rank += 1;
            }
        }
    }

private:
    std::vector<Node> _nodes;
};


struct edge {
    int src, dst;
    int weight;

    edge(int src, int dst, int w) : src(src), dst(dst), weight(w) {}
};

int main() {
    int V, E;
    cin >> V >> E;

    vector<edge> edges;
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        edges.emplace_back(s, t, w);
    }

    // Kruskal's algorithm
    int total = 0;
    sort(edges.begin(), edges.end(), [](const edge& a, const edge& b) { return a.weight < b.weight; });
    auto S = DisjointSet(V);
    for (auto& e : edges) {
        if (!S.same(e.src, e.dst)) {
            total += e.weight;
            S.unite(e.src, e.dst);
        }
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 4524
#include <iostream>
#include <cstdio>
#include <cmath>

#define PI 3.1415926535

using namespace std;

int main() {
	int a, b, C;

	cin >> a >> b >> C;


	double S = a*b*sin(C / 180.0 * PI) / 2;
	double L = sqrt(a*a + b*b - 2 * a*b*cos(C / 180.0 * PI)) + a + b;
	double h = 2 * S / a;

	printf("%.4f\n", S);
	printf("%.4f\n", L);
	printf("%.4f\n", h);

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
typedef pair<ll,ll> P;
int main(){
ll n,mi=10000000,ma=-10000000,mii,maa;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(mi>=a[i]){
      mi=a[i];
      mii=i;
    }
    if(ma<a[i]){
      ma=a[i];
      maa=i;
    }
  }
  vector<P> p;
  bool f=true;
  if(mi<0&&ma>0){
    if(abs(mi)>ma){
      f=false;
      while(mi<a[n-1]){
        a[n-1]+=mi;
        p.push_back(P(mii+1,n));
      }
    }else{
      while(ma>a[0]){
        a[0]+=ma;
        p.push_back(P(maa+1,1));
      }
    }
  }else if(mi<0){
    f=false;
    while(mi<a[n-1]){
      a[n-1]+=mi;
      p.push_back(P(mii+1,n));
    }
  }else if(ma>0){
    while(ma>a[0]){
      a[0]+=ma;
      p.push_back(P(maa+1,1));
    }
  }
  if(f){
    for(int i=1;i<n;i++){
      if(a[i-1]>a[i]){
        while(a[i-1]>a[i]){
          a[i]+=a[i-1];
          p.push_back(P(i,i+1));
        }
      }
    }
  }else{
    for(int i=n-1;i>0;i--){
      if(a[i-1]>a[i]){
        while(a[i-1]>a[i]){
          a[i-1]+=a[i];
          p.push_back(P(i+1,i));
        }
      }
    }
  }
  cout<<p.size()<<endl;
  for(int i=0;i<p.size();i++){
    cout<<p[i].first<<" "<<p[i].second<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;

/* 2017/01/21 問題 -----  ABC046 D /Link http://abc046.contest.atcoder.jp/tasks/arc062_b */
/* -----解説等-----
問題: シカのAtCoDeerくんは友達のTopCoDeerくんとあるゲームをして対戦しています。
このゲームは N ターンからなります。各ターンではそれぞれのプレイヤーはじゃんけんのグーかパーを出します。
ただし、各プレイヤーは次の条件を満たす必要があります。

(※) 各ターンの後で、(今までにパーを出した回数)≦(今までにグーを出した回数)　を満たす

このゲームでの各プレイヤーの得点は、(勝ったターンの数) − (負けたターンの数) です。 
AtCoDeerくんは特殊能力を持っているので、ゲームが始まる前にTopCoDeerくんの出す N ターンの手を全て知ることが出来ました。 
AtCoDeerくんの各ターンでの手を決めて、AtCoDeerくんの得点を最大化してください。
TopCoDeerくんの出す手の情報は文字列 s で与えられます。 
s の i(1≦i≦N) 文字目が gのときは i ターン目でTopCoDeerくんがグーを出すことを、 pのときはパーを出すことを表します。

制約
1≦N≦10^5
N=|s|
s の各文字はgかp
s で表される手は、条件(※)を満たしている

AtCoDeerくんの得点の最大値を出力せよ。


部分問題。

*/

string S;
stack<int> sta;
int ans = 0;

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

    cin >> S;
    FOR(i, 0, S.size()) {
        if (!sta.empty()) {
            if (S[i] == 'g') {
                sta.pop();
                ans++;
            }
            else {
                sta.pop();
            }
        }
        else {
            if (S[i] == 'g') {
                sta.push(1);
            }
            else {
                sta.push(1);
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
    string w, t;
    cin >> w;
    for(int i= 0; i < w.size(); i++) w[i] = tolower(w[i]);

    int count = 0;
    while(true){
        cin >> t;
        if(t == "END_OF_TEXT") break;
        for(int i= 0; i < t.size(); i++) t[i] = tolower(t[i]);
        if(t == w) count++;
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3152
#include<iostream>
using namespace std;
int N, S;
int main(){
	while(cin>>N && N>0) {
		int sum=0, large=0, small=1000;
		for(int i=0;i<N;++i){
			cin>>S;
			sum+=S;
			if(large<S) large=S;
			if(small>S) small=S;
		}
		sum=sum-large-small;
		cout<<sum/(N-2)<<endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
int n;
int x,b[100011]; 
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>x;
    	b[x]=i;
	}
	for(int i=1;i<n;i++)
	{
		cout<<b[i]<<" ";
	}
	cout<<b[n]<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>

int main(void) {
	int n;
	while (scanf("%d", &n) == 1 && n != 0) {
		double s[1024];
		int i;
		double average = 0, sd = 0;
		for (i = 0; i < n; i++) {
			if (scanf("%lf", &s[i]) != 1) return 1;
			average += s[i];
		}
		average /= n;
		for (i = 0; i < n; i++) {
			sd += (s[i] - average) * (s[i] - average);
		}
		printf("%.15f\n", sqrt(sd / n));
	}
	return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

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

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

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    char a, b;
    cin >> a >> b;

    if(a == 'H' && b == 'H') cout << "H" << endl;
    else if(a == 'H' && b == 'D') cout << "D" << endl;
    else if(a == 'D' && b == 'H') cout << "D" << endl;
    else if(a == 'D' && b == 'D') cout << "H" << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
d={}
for i in range(n):
  s=input()
  if s in d:
    d[s]+=1
  else:
    d[s]=0
m=max(d.values())
ans=[]
for x in d.keys():
  if d[x]==m:
    ans.append(x)
ans.sort()
for x in ans:
  print(x)

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  string s[n];
  REP(i, n) cin >> s[i];
  int a[n][26];
  REP(i, n) REP(j, 26) a[i][j] = 0;
  REP(i, n) REP(j, s[i].size()) { a[i][s[i][j] - 'a']++; }
  int ans[26];
  REP(i, 26) ans[i] = 100;
  REP(i, 26) REP(j, n) { ans[i] = min(ans[i], a[j][i]); }
  REP(i, 26) REP(j, ans[i]) cout << (char)(i + 'a');
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

ll n,a,b,ans,k;

int main()
{

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

    cin >> n >> a >> b;
    k = n/(a+b);
    ans = a*k;
    n-=(a+b)*k;
    ans+=min( a , n );
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    double a, b, h;
    cin >> a >> b >> h;
    cout << ((a + b) * h) / 2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << (m1 != m2) << endl;
  return 0;
}


Measured memory_bytes: 888
# https://atcoder.jp/contests/agc009/tasks/agc009_a
# 普通にBの倍数かつAより大きいものの中で最小の数を高速に求めれば良い
# いや[0,i)を+1増やすらしい。めちゃくちゃめんどくさいやつだ

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


from math import floor, ceil

N = a_int()
A, B = read_col(N)
# 後ろから決定していく
n_pushed = 0  # すでに何回押されたか(a+n_pushedがその時点での数字の大きさに成る)
for a, b in zip(reversed(A), reversed(B)):
    a += n_pushed
    x = (ceil(a / b)) * b
    # print(x)
    n_pushed += x - a

print(n_pushed)


Measured memory_bytes: 92716
//09-25
#include <bits/stdc++.h>

using namespace std;

const int N = 200100;

int pos_a, pos_b;

int c, d;


char s[N];

bool try_a() {
	if(pos_a == c) return false;
	if(pos_a + 1 != pos_b && s[pos_a + 1] == '.') {
		pos_a++;
		return true;
	}
	if(pos_a + 2 != pos_b && s[pos_a + 2] == '.') {
		pos_a+=2;
		return true;
	}	
	return false;
}


bool try_b() {
	if(pos_b == d) return false;
	if(pos_b + 1 != pos_a && s[pos_b + 1] == '.') {
		pos_b++;
		return true;
	}
	if(pos_b + 2 != pos_a && s[pos_b + 2] == '.') {
		pos_b+=2;
		return true;
	}	
	return false;
}


int main() {
	int n, a, b;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	pos_a = a, pos_b = b;
	for (int i = 0; i < n; ++i) {
		scanf(" %c", &s[i]);
	}
	int qtd = 2*N;
	while(qtd) {
		if(d < c) {
			if(try_a()) {
			} else {
				try_b();
			}
		} else {
			if(try_b()) {
			} else {
				try_a();
			}
		}
		if(pos_a == c && pos_b == d)break;
		qtd--;
	}
	if(qtd) {
		puts("Yes");
	} else {
		puts("No");
	}

}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){

  int n,i,j,a;

  while(1){

  int data[100000]={0};

  scanf("%d",&n);

  if(n==0)break;

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

  for(i=0;i<10;i++){
    if(data[i]==0){
      printf("-");
    }
    else {
      for(j=0;j<data[i];j++){
	printf("*");
      }
    }
    printf("\n");
  }

  }
  return 0;
}

Measured memory_bytes: 1556
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  string ans="No";
  if(n%4==0||n%7==0)ans="Yes";
  reps(i,25){
      int now=n-i*4;
      if(now<0)break;
      if(now%7==0)ans="Yes";
  }
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
import sys
n = int(input())
w = []
for i in range(n):
    w.append(input())
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n-1):
    if w[i][len(w[i]) - 1] != w[i+1][0]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
#define INF 2147483647

int w,h;
char a[102][102];
int dir[4][2] = {-1,0,1,0,0,-1,0,1};
int ans = 0;

void dfs(int x,int y,char s){
	if(x < 0 || x >= h || y < 0 || y >= w || a[x][y] != s) return;
	char t = a[x][y];
	a[x][y] = 'o';
	for(int i = 0;i < 4; i++){
		dfs(x+dir[i][0], y+dir[i][1], t);
	}
}

int main(){
	while(cin >> h >> w){
		if(w == 0 && h == 0) break;
		ans = 0;
		int sx,sy;
		for(int i = 0;i < h; i++){
			for(int j = 0;j < w; j++){
				cin >> a[i][j];
			}
		}
		for(int i = 0;i < h; i++){
			for(int j = 0;j < w; j++){
				if(a[i][j] != 'o'){
					ans++;
					dfs(i,j,a[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
} 

Measured memory_bytes: 3544
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = INF ;
	for(int i=-110;i<=110;i++){
		ll sub = 0 ;
		for(int j=0;j<n;j++){
			sub += (a.at(j)-i)*(a.at(j)-i) ;
		}
		ans = min(ans,sub) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 384
N, M = map(int, input().strip().split())

vs = [[] for _ in range(N + 1)]
for _ in range(M):
	v, u = map(int, input().strip().split())
	vs[v].append(u)
#	vs[u].append(v)
S, T = map(int, input().strip().split())

def search(vs, S, T):
	queue = [(S, 0)]
	dists = [[-1] * (N + 1) for _ in range(3)]
	while queue:
		n, d = queue.pop(0)
		d += 1
		dr = d % 3
		dists_tmp = dists[dr]
		for n2 in vs[n]:
			if dr == 0 and n2 == T:

#				for dd in dists:
#					print(dd)
#				print(n, d, queue)

				return d // 3
			if dists_tmp[n2] < 0:
				dists_tmp[n2] = d
				queue.append((n2, d))
	return -1

print(search(vs, S, T))



Measured memory_bytes: 29852
import java.io.*;
import java.util.*;
 
class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] array = new int[26];
        Arrays.fill(array,0);
        char[] c_array;
        String str;
        do{
            if((str=br.readLine())==null) break;
            c_array=str.toCharArray();
            for(char c:c_array){
                if('a'<=c&&c<='z') array[c-'a']++;
                else if('A'<=c&&c<='Z') array[c-'A']++;
            }
        }while(true);
        for(int i=0;i<26;i++){
            System.out.println((char)('a'+i)+" : "+array[i]);
        }
    }
}

Measured memory_bytes: 24304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<int> d1(n),d2(n);
    vector<int> v(n,0);
    rep(i,n){
        cin>>d1[i]>>d2[i];
        if(d1[i]==d2[i]) v[i]=1;
    }
    rep(i,n-2){
        if(v[i]==1 && v[i+1]==1 && v[i+2]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  bool ok = false;
  if(abs(a-c) <= d) ok = true;
  else if(abs(a-b) <= d && abs(b-c) <= d) ok = true;
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a[3][3];
  rep(i,3) rep(j,3) cin>>a[i][j];
  int n;cin>>n;
  rep(_,n){
    int b;cin>>b;
    rep(i,3){
      rep(j,3){
        if(a[i][j]==b){
          a[i][j]=0;
        }
      }
    }
  }
  string ans="No";
  rep(i,3){
    if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0) ans="Yes";
  }
  rep(i,3){
    if(a[0][i]==0 && a[1][i]==0 && a[2][i]==0) ans="Yes";
  }
  if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0) ans="Yes";
  if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0) ans="Yes";
  cout<<ans<<endl;
}

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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  a.at(0)-=32;
  b.at(0)-=32;
  c.at(0)-=32;
  cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ');
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);

        var s = Console.ReadLine().Split(' ');
        var d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(s[i]);
        }

        var min = int.MaxValue;
        for (int i = 0; i + k - 1 < n; i++)
        {
            min = Math.Min(Math.Min(min,
                d[i + k - 1] - d[i] + Math.Abs(d[i])),
                d[i + k - 1] - d[i] + Math.Abs(d[i + k - 1]));
        }

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 20192
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  ll n;
  scanf("%lld",&n);
  PRL(n*(n-1)/2);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

rList = []
gList = []
bList = []

for indx in range(N):
    if S[indx] == 'R':
        rList.append(indx)
    elif S[indx] == 'G':
        gList.append(indx)
    elif S[indx] == 'B':
        bList.append(indx)

NoSum = 0
fList = rList
sList = gList
remain = 'B'

for fItem in fList:
    for sItem in sList:
        prsMax = max(fItem, sItem)
        prsMin = min(fItem, sItem)
        if ((2 * prsMax - prsMin) <= N-1):
            if (S[(2 * prsMax - prsMin)] == remain):
                NoSum += 1
        
        if ((prsMax - prsMin) % 2 == 0):
            if (S[int((prsMax + prsMin)/2)] == remain):
                NoSum += 1
        
        if ((2 * prsMin - prsMax) >= 0):
            if  (S[(2 * prsMin - prsMax)] == remain):
                NoSum += 1

print(len(rList) * len(gList) * len(bList) - NoSum)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int iti;
  rep(i,n){
    cin >> a.at(i);
    if(a.at(i)==1){
      iti=i+1;
    }
  }
  int ans=0,sum=0;
  while(sum+1<iti){
    sum+=k-1;
    ans++;
  }
  int sum1=0;
  while(max(sum+1,iti)+sum1<n){
    sum1+=k-1;
    ans++;
  }
  cout << ans;
}
      

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define DEBUG_MODE
//#define FILE_INPUT

void DebugPrint(vector<int> a)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < (int)a.size(); i++) {
		cout << a[i];
	}
	cout << endl;
#endif
	return;
}

int Search(int n, int k, vector<int> &a)
{
	DebugPrint(a);
	vector<int> block_lens(n + 2, 0);
	vector<int> total_lens(n + 2, 0);
	int index = 0;
	int value = 1;
	int block_len = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] != value) {
			block_lens[index++] = block_len;
			block_len = 0;
			value = a[i];
		}
		block_len++;
	}
	block_lens[index++] = block_len;
	DebugPrint(block_lens);
	int total_len = 0;
	for (int i = 0; i < 2 * k + 1; ++i) {
		if (i < (int)block_lens.size()) {
			total_len += block_lens[i];
		}
	}
	total_lens[0] = total_len;
	for (int i = 2; i < n; i += 2) {
		for (int j = -2; j < 0; ++j) {
			int add_position = i + 2 * k + 1 + j;
			if (add_position < (int)block_lens.size()) {
				total_len += block_lens[add_position];
			}
			int sub_position = i + j;
			total_len -= block_lens[sub_position];
		}
		total_lens[i] = total_len;
	}
	DebugPrint(total_lens);
	sort(total_lens.begin(), total_lens.end());
	int max_len = total_lens.back();
	return max_len;
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */

	int n, k;
	cin >> n >> k;
	vector<int> a(n, 0);
	char c;
	for (int i = 0; i < n; ++i) {
		cin >> c;
		if (c == '1') {
			a[i] = 1;
		}
	}
	int max = Search(n, k, a);
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1796
N = int(input())
L = list(map(int,input().split()))
L.sort()
c = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        zum = L[i]+L[j]
        start = j+1
        goal = N-1
        now = (start + goal)//2

        if zum > L[goal]:
            c += goal - j
        elif zum <= L[start]:
            c += 0
        else:
            while not L[now] < zum <= L[now+1]:
                now = (start + goal)//2
                if zum > L[now]:
                    start = now
                else:
                    goal = now
            c += now - j

print(c)

Measured memory_bytes: 44268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, K ,a;
  cin >> N >> K;
  
  a = 0;
  
  for (int i = 0; i < N; i++) {
    
    int x;
    cin >>x;
    
    if (K - x >= x) {
      a += x * 2;
    }
    else if (K <= x) {
      a += (x - K) * 2;
    }
    else {
      a += (K - x) * 2;
    }
  }
  
  cout << a << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

vector <pii> from[60];
int vis[60];

void dfs(int x, int p){
	vis[x] = 1;
	for (int i = 0; i < from[x].size(); i++){
		int v = from[x][i].fi, id = from[x][i].se;
		if (id == p || vis[v]) continue;
		dfs(v, p);
	}
}

int main(){
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++){
		int u, v; scanf("%d%d", &u, &v);
		from[u].push_back(mp(v, i)), from[v].push_back(mp(u, i));
	}
	int ans = 0;
	for (int i = 0; i < m; i++){
		memset(vis, 0, sizeof(vis));
		dfs(1, i);
		int flag = 1;
		for (int j = 1; j <= n; j++){
			flag &= vis[j];
		}
		ans += flag ^ 1;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int maxn=1e5+5;
int f[maxn],n,m,k,ans[maxn],cnt[maxn];
vector<int>e[maxn];

int find(int x){
	if(x==f[x]) return x;
	else return f[x]=find(f[x]); 
}

void merge(int x,int y){
	int f1=find(x),f2=find(y);
	if(f1==f2) return;
	else f[f1]=f2;
}

int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1,u,v;i<=m;i++){
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
		merge(u,v);
	}
	
	for(int i=1;i<=n;i++){
		cnt[find(i)]++;
	}
	for(int i=1;i<=n;i++){
		ans[i]=cnt[find(i)]-e[i].size()-1;
	}
	for(int i=1,u,v;i<=k;i++){
		cin>>u>>v;
		if(find(u)==find(v)) ans[u]=max(0,ans[u]-1),ans[v]=max(0,ans[v]-1);
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" "; 
	}
}


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

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

    string s1,s2;
    int k=0;
    while(s.size()>8){
        
    if(s.substr(0,6)=="eraser"){
        s.erase(0,6);
    }
    else if(s.substr(0,5)=="erase"){
        s.erase(0,5);
    }
    else if(s.substr(0,8)=="dreamerd" or s.substr(0,8)=="dreamere"){
        s.erase(0,7);
    }
    else if(s.substr(0,5)=="dream"){
        s.erase(0,5);
    }
    else{
        k=1;
        break;
    }
}

int k2=1;
    if(s=="dream" or s=="dreamer" or s=="erase" or s=="eraser"){
        k2=0;
    }
    
    if(k2==1 or k==1){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n) {
        if ( ans * 2 < ans + k ) {
            ans *= 2;
        }
        else {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}


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

signed main()
 {
   string s,t;
   cin>>s>>t;
   rep(i,s.size()){
     if(s[i]!=t[i]){cout<<"No";exit(0);}
   }
   cout<<"Yes";
}


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

const int N = 2e+5 + 5;
int dp[N], accept[N];
vector<int> dpval[N];
int main()
{
    int n, k, c, maxi = 0;
    string s;
    cin >> n >> k >> c >> s;
    for (int i = n; i >= 1; i--)
    {
        if (s[i - 1] == 'o')
            dp[i] = 1 + dp[min(n + 1, i + c + 1)];
        else
            dp[i] = dp[i + 1];
        maxi = max(maxi, dp[i]);
        // cout<<dp[i]<<" ";
    }
    if (maxi == k)
    {
        // cout<<"j";
        for (int i = 1; i <= n; i++)
        {
            if (s[i - 1] == 'o')
                dpval[dp[i]].push_back(i);
            accept[i] = n;
        }
        vector<int> ans;
        accept[k] = dpval[k][0];
        int g = 0;
        if (accept[k] == dpval[k].back())
            ans.push_back(accept[k]);
        for (int i = k - 1; i > 0; i--)
        {
            // cout<<accept[i]<<" ";
            if (upper_bound(dpval[i].begin(), dpval[i].end(), accept[i + 1] + c) != dpval[i].end())
                accept[i] = *upper_bound(dpval[i].begin(), dpval[i].end(), accept[i + 1] + c);
            if (accept[i] == dpval[i].back())
                ans.push_back(accept[i]);
        }
        for (auto it : ans)
            cout << it << "\n";
    }
}

Measured memory_bytes: 15100
a[5],i;main(f){for(;~scanf("%d",a+i);){if(i)f|=1<<(a[i]=(a[i]+3-*a)%3);if(++i==5){for(*a=i=0;i<5;i++)printf("%d\n",f-1&&f-7?f-3?2-a[i]/2:a[i]+1:3);i=0;f=1;}}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=3005,mod=998244353;
typedef long long ll;
int dp[N][N][2];
//0上一步删行
//1上一步删列
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(c>a) dp[c][d][0]=1;
    if(d>b) dp[c][d][1]=1;
    ll ans=0;
    for(int i=c;i>=a;i--)
        for(int j=d;j>=b;j--)
    {
        dp[i][j-1][0]=(dp[i][j-1][0]+(ll)dp[i][j][1]*i)%mod;
        dp[i][j-1][1]=(dp[i][j-1][1]+(ll)dp[i][j][1]*i)%mod;
        dp[i-1][j][0]=(dp[i-1][j][0]+(ll)dp[i][j][0]*j)%mod;
        dp[i-1][j][1]=(dp[i-1][j][1]+(ll)dp[i][j][0])%mod;
        if(i==a&&j-1==b)
            ans=(ans+(ll)dp[i][j][1]*i)%mod;
        if(i-1==a&&j==b)
            ans=(ans+(ll)dp[i][j][0]*j)%mod;
    }
    if(a==c&&b==d) ans=1;
    printf("%lld\n",ans);
}


Measured memory_bytes: 74052
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] array = new int[6];
		for(int i =0; i < array.length; i++)
			array[i] = sc.nextInt();
		
		for(int i = 0; i < 5; i++) {
			for(int j = i+1; j < 5; j++) {
				if(array[j] - array[i] > array[array.length-1]) {
					System.out.println(":(");
					return;
				}
			}
		}
		System.out.println("Yay!");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

struct Edge {
	int to, weight;
	Edge() {}
	Edge(int t, int w) : to(t), weight(w) {}
};
const int MAX = 100005;
const int INF = 1 << 30;
int dist[MAX], n;
vector<Edge> G[MAX];
void bfs(int s)
{
	for (int i = 0; i < n; ++i)
		dist[i] = INF;
	queue<int> Q;
	Q.push(s);
	dist[s] = 0;
	int t;
	Edge e;
	while (!Q.empty())
	{
		t = Q.front();
		Q.pop();
		for (unsigned i = 0; i < G[t].size(); ++i)
		{
			e = G[t][i];
			if (dist[e.to] == INF)
			{
				dist[e.to] = dist[t] + e.weight;
				Q.push(e.to);
			}
		}
	}
}

int Diameter()
{
	bfs(0);
	int ans = 0;
	int start = 0;
	for (int i = 0; i < n; ++i)
	{
		if (dist[i] == INF)
			continue;
		if (ans < dist[i])
		{
			ans = dist[i];
			start = i;
		}
	}
	bfs(start);
	ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (dist[i] == INF)
			continue;
		ans = max(ans, dist[i]);
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s, t, w;
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		cin >> s >> t >> w;
		G[s].push_back(Edge(t, w));
		G[t].push_back(Edge(s, w));
	}
	cout << Diameter() << endl;
	return 0;
}

Measured memory_bytes: 9884
def calc(N, M, A):
    S = sum(A)
    n = len([x for x in A if x < S / 4 / M])
    if M <= N - n:
        return 'Yes'
    else:
        return 'No'



(N, M) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
print(calc(N, M, A))

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException{

	BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
	String[] yomikomi=new String[2];
	Set<String> jisyo=new HashSet<String>();
	String yomi="";

	int limit=Integer.parseInt(bfr.readLine());

	for(int i=0; i<limit; i++){
			yomikomi=bfr.readLine().split(" ");

			if(yomikomi[0].equals("insert")){
				jisyo.add(yomikomi[1]);
			}

			else if(yomikomi[0].equals("find")){
				if(jisyo.contains(yomikomi[1])==false){
					System.out.println("no");
				}
				else{
					System.out.println("yes");
				}
			}
		}
	}
}


//List だと　TLE
// Set Hashset だと・・・・?



Measured memory_bytes: 190500
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
constexpr double PI  = 3.1415926535;
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double dx = abs(cos(PI * (h * 30 + m * 0.5) / 180) * a - cos(PI * m * 6 / 180) * b);
    double dy = abs(sin(PI * (h * 30 + m * 0.5) / 180) * a - sin(PI * m * 6 / 180) * b);
    //dump(cos(PI * h * 30 / 180));
    //dump(sin(PI * h * 30 / 180));
    //dump(dx);
    //dump(dy);
    printf("%.09lf\n", sqrt(sqr(dx) + sqr(dy)));
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<b;++i)
char c[60][60];
int a[60][60];
int flag, w, h;

void dfs(int y,int x){
  if(c[y][x] == 'B'){
    if(flag == 0 || flag == 1) flag = 1;
    else flag = 3;    
    a[y][x] = 9;
  }else if(c[y][x] == 'W'){
    if(flag == 0 || flag == 2) flag = 2;
    else flag = 3;
    a[y][x] = 9;
  }else if(a[y][x]==0){
    a[y][x] = 4;
    FOR(i,y-1,y+2) if(i>=0 && i<h) dfs(i,x);
    FOR(j,x-1,x+2) if(j>=0 && j<w) dfs(y,j);
  }
}
int main(){
  int bl, wh;
  while(cin>>w>>h, w){
    bl = 0; wh = 0;
    REP(i, h) REP(j, w){
      cin>>c[i][j];
      a[i][j]=0;
    }
    
    REP(i, h) REP(j, w){
      if(c[i][j] == 'B' || c[i][j] == 'W' || a[i][j]) continue;
      flag = 0;
      dfs(i,j);
      
      if(flag) REP(k,h) REP(l,w){
          if(a[k][l] == 4) a[k][l] = flag;
        }
    }
    REP(i,h) REP(j,w){
      if(a[i][j] == 1) bl++;
      if(a[i][j] == 2) wh++;
    }
    cout<<bl<<" "<<wh<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
import java.io.*;
import java.util.*;
//import java.util.stream.*;;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long cost = 0;
        double sum = 0;
        int array[] = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            sum += array[i];
        }
        int avg = (int) Math.round(sum / n);
        for (int i = 0; i < n; i++) {
            cost += ((array[i] - avg) * (array[i] - avg));
        }
        System.out.println(cost);
        bw.flush();
    }
}


Measured memory_bytes: 23124