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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	map<int, int> K;
	cin >> N;
	for (int x = 1; x <= 100;x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int k = x * x + y * y + z * z + x * y + y * z + z * x;
				K[k]++;
			}
		}
	}

	fx(N) {
		ce(K[x+1])
	}
    return 0;
}



Measured memory_bytes: 5384
def watering(h)
  min = h.map { |v| v.zero? ? 101 : v }.min
  min_i = h.index min
  l = 0
  r = h.size - 1
  # ((min_i - 1)..0).each do |i|
  (min_i - 1).step 0, -1 do |i|
    if h[i].zero?
      l = i + 1
      break
    end
  end
  ((min_i + 1)..r).each do |i|
    if h[i].zero?
      r = i - 1
      break
    end
  end
  (l..r).each { |i| h[i] -= min }
  [h, min]
end

n = gets.to_i
h = gets.split.map(&:to_i)
ans = 0
while h.any? { |i| i != 0 }
  h, num = watering h
  ans += num
end
puts ans


Measured memory_bytes: 1916
require 'prime'
class Prime
  def each_divisor(n, &block)
    pf = prime_division(n)
    num = pf.inject(1) { |prod, (_, e)| prod * e.succ }
    Enumerator.new(num) { |y| __each_divisor__(1, pf, &y.method(:<<)) }.tap { |enum| enum.each(&block) }
  end
  
  private def __each_divisor__(d, ary, &block)
    return yield(d) if ary.empty?

    ary = ary.dup
    prime, exp = ary.pop
    (0..exp).each { __each_divisor__(d, ary, &block); d *= prime }
  end
end

n = gets.to_i

# substraction only or `n` itself
m = Prime.each_divisor(n-1).size

m += Prime.each_divisor(n).count do |z|
  next false if z <= 1 || z * z > n

  s, t = n, 0
  s, t = s.divmod(z) while t == 0
  t == 1
end

p m

load __FILE__ unless $stdin.eof?


Measured memory_bytes: 2300
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int p[100010];
vector<int> v;
string s;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> p[i];
	}
	v.push_back(1); s.push_back('(');
	int cnt = 2;
	for(i=0;i<n;i++){
		if(i!=0 && p[i] - p[i-1]==-1){
			v.pop_back();
			s.push_back(')');
		}else{
			while(1){
				int x = v.back();
				if(x<p[i]){
					v.push_back(cnt); cnt++;
					s.push_back('(');
				}else if(x==p[i]){
					v.pop_back(); s.push_back(')');
					break;
				}else{
					cout << ":(" << endl;
					return 0;
				}
			}
		}
	}
	cout << s << endl;
}


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

int main()
{
  map<string, int> m;
  string str, most, w_ct;


  while (cin >> str){
    m[str]++;
    if (m[most] < m[str]){
      most = str;
    }
    else if(w_ct.size() < str.size()){
      w_ct = str;
    }
  }
  cout << most << ' ' << w_ct << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

  cout << fixed << setprecision(10) << ceil(N / 2)/ N << endl;

  return 0;
}

Measured memory_bytes: 256
from decimal import Decimal


def main_v1():
    A, B = input().split()
    A = int(A)
    B = Decimal(B)
    print(int(A * B))


def main_v2():
    A, B = input().split()
    A = int(A)
    B = int(B.replace(".", ""))
    print(int(A * B / 100))


if __name__ == "__main__":
    main_v1()


Measured memory_bytes: 9936
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int a[10010], sum;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d", &a[i]), sum += a[i];
	if (n < sum) {
		puts("-1");
	} else {
		cout << n - sum;
	}
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++){
    	if(s[i] == '?'){
    		s[i] = 'D';
    	}
    }
    cout << s;
    return 0;
}
 

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
bool solve(){
	if(a==b&&a^c)return 1;
	if(a==c&&a^b)return 1;
	if(c==b&&a^c)return 1;
	return 0;
}
int main(){
	scanf("%d%d%d",&a,&b,&c);
	puts(solve()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {

  val lines = Iterator.continually(readLine())
  val xs = {
    val xs = for {
      line       <- lines
      Array(h, w) = line.split(" ").map { _.toInt }
    } yield (h, w)

    xs.takeWhile { _ != (0, 0) }
  }

  for {
    rows <- xs.map(solve)
  } {
    rows.foreach(println)
    println()
  }

  def solve(pair: (Int, Int)): Seq[String] = pair match {
    case (h, w) =>
      val s = {
        val sb = StringBuilder.newBuilder
        for {
          i <- 1 to w + 1
          c  = if (i % 2 == 0) '.' else '#'
        } {
          sb += c
        }
        sb.toString
      }

      val oddRow  = s.init
      val evenRow = s.tail

      val rows = for {
        i  <- 1 to h
        row = if (i % 2 == 0) evenRow else oddRow
      } yield row

      rows
  }
}



Measured memory_bytes: 44512
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    string S;
    cin >> S;

    for (int i = 0; i <= 2; i++){
        if (S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  vector<int> D(N);
  
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  for(int i=0;i<N;i++){
    D.at(i) = V.at(i) - C.at(i);
  }
  
  int answer = 0;
  
  for(int i=0;i<N;i++){
    if(D.at(i) > 0){
      answer = answer + D.at(i);
    }
  }
  cout << answer << endl;
}

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

int main() {
	//cout<<"GfG!";
	long long int n, t[100], m, pi[100], x[100], i, j, k, tot = 0;
	cin>>n;
	for (i = 0; i < n; i++)
	    cin>>t[i];
	cin>>m;
	for (i = 0; i < m; i++)
	    cin>>pi[i]>>x[i];
	tot = accumulate(t, t + n, 0); 
	for (i = 0; i < m; i++)
	{
	    cout<<(tot - t[pi[i]-1] + x[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, i, j, mj, ans=0;
  cin >> N;
  vector<pair<int,int>> R(N), B(N);
  for(i=0; i<N; i++) cin >> R[i].second >> R[i].first;
  for(i=0; i<N; i++) cin >> B[i].first >> B[i].second;
  sort(R.begin(), R.end());
  sort(B.begin(), B.end());
  vector<int> A(N);
  for(i=0; i<N; i++){
    bool f=false;
    for(j=0; j<N; j++){
      if(R[j].second<B[i].first && R[j].first<B[i].second){
        if(A[j] == 0){
          f=true;
          mj=j;
        }
      }
    }
    if(f){
      ans++;
      A[mj]=1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[]
b=[]
c=[[0]*l for i in range(n)]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(m):
    b.append(list(map(int,input().split())))

for i in range(n):
    for j in range(l):
        c[i][j]=str(sum(a[i][k]*b[k][j] for k in range(m)))
for i in c:
    print(*i)


Measured memory_bytes: 7284
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

class Dice{
private:
  int right,wrong;
  int N,E,W,S;
  int tmp1,tmp2;
public:
  Dice(int ri,int wr,int n,int e,int w,int s):right(ri),wrong(wr),N(n),E(e),W(w),S(s){};
  int ShowRight(){return right;}
  int ShowWrong(){return wrong;}
  int ShowN(){return N;}
  int ShowE(){return E;}
  int ShowW(){return W;}
  int ShowS(){return S;}
  void goN();
  void goE();
  void goW();
  void goS();
};

void Dice::goN(){
  tmp1=N; tmp2=S;
  N=wrong; S=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goE(){
  tmp1=E; tmp2=W;
  E=wrong; W=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goW(){
  tmp1=W; tmp2=E;
  W=wrong; E=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goS(){
  tmp1=S; tmp2=N;
  S=wrong; N=right;
  right=tmp1; wrong=tmp2;
}

int main()
{
 
  int label[6];
  int q;
  int a,b,c;
  int ans[24];

  for(int i=0;i<6;i++)
    cin >> label[i];
  cin >> q;

  Dice dice(label[0],label[5],label[1],label[3],label[2],label[4]);

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

      if(a==dice.ShowWrong()){ dice.goN();dice.goN();}
      else if(a==dice.ShowN()) dice.goN();
      else if(a==dice.ShowE()) dice.goE();
      else if(a==dice.ShowW()) dice.goW();
      else if(a==dice.ShowS()) dice.goS(); 

      if(b==dice.ShowWrong()) c=-1;
      else if(b==dice.ShowN()) c=dice.ShowW();
      else if(b==dice.ShowW()) c=dice.ShowS();
      else if(b==dice.ShowS()) c=dice.ShowE();
      else if(b==dice.ShowE()) c=dice.ShowN();

      ans[i]=c;

    }

  for(int i=0;i<q;i++)
    cout << ans[i] << endl;


  return 0;
}

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
	for(double a;cin>>a,a>=0;){
		int n=(int)(a*16);
		if(n>(1<<12) || n!=a*16)	cout<<"NA"<<endl;
		else{
			for(int i=11;i>=0;i--){
				if(i==3)	cout<<'.';
				cout<<(bool)(n&(1<<i));
			}
			cout<<endl;
		}
	}
	return 0;
}

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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair < int , int > ii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

int r , c;
string s[ 105 ];
bool bad[ 105 ][ 105 ];

void go( int x , int y ) {
        bool f = true;
        for( int i = 0; i < c; i++ ) {
                if( s[x][i] == '#' ) {
                        f = false;
                        break;
                }
        }
        if( f ) {
              for( int i = 0; i < c; i++ ) {
                bad[x][i] = true;
            }
        }
        f = true;
        for( int i = 0; i < r; i++ ) {
                if( s[i][y] == '#' ) {
                        f = false;
                        break;
                }
        }
        if( f ) {
                for( int i = 0; i < r; i++ ) {
                    bad[i][y] = true;
            }
        }
}
int main( int argc , char const *argv[] ) {
        ios_base :: sync_with_stdio(false); cin.tie(NULL);
        cin >> r >> c;
        for( int i = 0; i < r; i++ ) cin >> s[i];
        for( int i = 0; i < r; i++ ) {
                for( int j = 0; j < c; j++ ) {
                        if( s[i][j] == '.' ) go( i , j );
                }
        }
        for( int i = 0; i < r; i++ ) {
                for( int j = 0; j < c; j++ ) {
                        if( !bad[i][j] ) cout << s[i][j];
                }
                cout << endl;
        }
        return 0;
}








Measured memory_bytes: 256
def abc126d():
    n = int(input())
    e = [list() for _ in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        e[u - 1].append([v - 1, w])
        e[v - 1].append([u - 1, w])
    ans = [-1] * n
    ans[0] = 0
    q = e[0].copy()
    while len(q) > 0:
        v, w = q.pop()
        #print(v, w)
        if ans[v] != -1: continue
        elif w % 2 == 0: ans[v] = 0
        else: ans[v] = 1
        for v1, w1 in e[v]:
            if ans[v1] != -1: continue
            q.append([v1, w+w1])
    for i in ans:
        print(i)
abc126d()

Measured memory_bytes: 104148
# -*- coding: utf-8 -*-
"""
A - Two Integers
https://atcoder.jp/contests/apc001/tasks/apc001_a

"""
import sys


def solve(X, Y):
    t = X / Y
    if t.is_integer():
        return -1
    return X


def main(args):
    X, Y = map(int, input().split())
    ans = solve(X, Y)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
double ans1,n; 
int main()
{
	//fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	   if (i%2!=0)
	      ans1++;
	printf("%.10lf",ans1/n); 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
typedef mp::cpp_int ll;

// ====================================================================

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

  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  sort(v.begin(), v.end());

  ll ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= v[i];
    if (ans > 1000000000000000000ll) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a.at(i);
    }
    int count = 0;
    for(int i = 1; i <= n; i++){
        if(i == a.at(a.at(i))){
            count++;
        }
    }
    cout << count/2;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main()
{
    long long n,i,max=0,k=1,j;
    string s,c[200005];
    map<string,long long>m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s;
        m[s]++;
        if(m[s]>max)
        {
            k=1;
            c[k]=s;    
            k++;   
            max=m[s];   
        }
        else if(m[s]==max)
        {
            c[k]=s;
            k++;
        }
    }
    sort(c+1,c+k);
    for(j=1;j<k;j++)
    {
        cout<<c[j]<<endl;
    }
    return 0;
}

Measured memory_bytes: 25436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 3e5 + 10;

int r[N], c[N];
vi row[N];
bool pos[N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int h, w, m;
	cin >> h >> w >> m;
	vector<pii> v(m);
	int mx = 0;
	for(int i = 0; i < m; i++) {
		cin >> v[i].fi >> v[i].se;
		row[v[i].fi].pb(i);
		r[v[i].fi]++;
		c[v[i].se]++;
		mx = max(mx, c[v[i].se]);
	}
	int cnt = 0;
	for(int i = 1; i <= w; i++) {
		if(c[i] == mx) {
			pos[i] = 1;
			cnt++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= h; i++) {
		int tmp = cnt;
		for(auto it : row[i]) {
			if(pos[v[it].se]) {
				tmp--;
			}
		}
		if(tmp) {
			ans = max(ans, r[i] + mx);
		}
		else {
			ans = max(ans, r[i] + mx - 1);
		}
	}
	cout << ans;

	return 0;
}

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

int main() {
  
  int N; cin >> N; int V[N]; int C[N]; int ans = 0;
  
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  
  for (int i = 0; i < N; i++) {
    if (C[i] < V[i]) ans += V[i] - C[i];
  }
  
  cout << ans << endl;
  
}

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

int main() {
  int A, B, sumsub, mul;
  cin >> A >> B;
  sumsub = (B>0)?(A+B):(A-B);
  mul = A*B;
  cout << ((mul>sumsub)?mul:sumsub) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
/*#include<contactdeviceservice.h>
#include<stdio.h>
#include<functiondiscoverycategories.h>
#include<highlevelmonitorconfigurationapi.h>
#include<xxrefwrap>
#include<msfeedsid.h>
#include<TOM.h>
#include<vpccominterfaces.h>
#include<wsman.h>
#include<_dbdao.h>
*/
using namespace std;
int main(){
	 int n,a[1000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n-1;i++)
        cout<<a[n-i-1]<<" ";
    cout<<a[0]<<endl;
	return 0;
}



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

int a[200010], b[200010];

int main() {
	int N;
	cin >> N;
	for(int i=1; i<=N; i <<= 1){
		if(i==N){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for(int i=0; i<2; ++i){
		a[i*2]=i+1, b[i*2]=i+2;
		a[i*2+1]=i+1+N, b[i*2+1]=i+2+N;
	}
	a[4]=3, b[4]=N+1;
	int fn=5;
	for(int i=4; i<N; i += 2){
		a[fn]=1, b[fn]=i;
		a[fn+1]=1, b[fn+1]=i+1;
		a[fn+2]=i, b[fn+2]=i+1+N;
		a[fn+3]=i+1, b[fn+3]=i+N;
		fn += 4;
	}
	if(N%2==0){
		int d=1;
		while((N&d)==0) d <<= 1;
		a[fn]=N, b[fn]=d;
		a[fn+1]=N*2, b[fn+1]=N-d+1;
		fn += 2;
	}
	for(int i=0; i<fn; ++i) cout << a[i] << ' ' << b[i] << endl;
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  vector<int>m(N,300000);
  int ans=1;
  m[0]=p[0];
  for(int i=1;i<N;i++){
    if(m[i-1]>=p[i])ans++;
    m[i]=min(m[i-1],p[i]);
  }
  cout<<ans<<endl;
}






Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int n;
long long sum;
int main()
{
	//cout << "ok" << endl;
	cin >> n;
	if(n == 1 || n == 2 || n == 4)
	{
		cout << n << endl;
		exit(0);
	}
	sum = 7;
	for(int i = 6; i <= n;i++)
	{
		if(i % 3 == 0 || i % 5 == 0)
		{
			continue;
		}
		else
		{
			sum += i;
			//cout << i << " ";
		}
	}
	//cout << endl;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    String s1 = s.substring(0,1);
    String s2 = s.substring(s.length() - 1);
    
    int n = (s.length()-2);
    
    System.out.println(s1+n+s2);
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }

signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    vector<vector<int>>dp(2,vector<int>(n,0LL));
    rep(i,n){
        if(i == 0){
            dp[0][0] = dp[1][0] = v[i];
        } else {
            // use nomal
            dp[0][i] = max(dp[0][i-1], dp[1][i-1]) + v[i];
            if(i - 2 >= 0){
                dp[1][i] = max(dp[1][i-1] +v[i-1] + -1 *v[i] + v[i-1],dp[0][i-1] - v[i-1] + -1*(v[i] + v[i-1]));
            } else {
                dp[1][i] = -1 * (v[i] + v[i-1]);
            }
        }
    }
    cout << max(dp[0][n-1], dp[1][n-1]) << endl;
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = INF;

  if (x <= y) ans = min(ans, y - x);
  if (-x <= y) ans = min(ans, y + x + 1);
  if (x <= -y) ans = min(ans, -y - x + 1);
  if (-x <= -y) ans = min(ans, -y + x + 2);

  print(ans);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            //W???H???x???y???r
            var nums = GetNumbers();
            var W = nums[0];
            var H = nums[1];
            var x = nums[2];
            var y = nums[3];
            var r = nums[4];
            var minX = r;
            var minY = r;
            var maxX = W - r;
            var maxY = H - r;

            if (minX <= x && x <= maxX && minY <= y && y <= maxY)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbers()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 10068
<?php
//ワーシャルフロイド（全点対最短路問題）
//スタート地点１つに対してゴールが２つ。流れるものは水
//故に、単純に $cost[$s][$g1] + $cost[$s][$g2] とするとWA
//スタート〜ある点までは合流道。ある点〜それぞれのゴールまでは二股に分かれて進むイメージ
//また、有向グラフ（一方通行）なので注意。
//と言ってもむしろ$cost[$b][$a] = $cost[$a][$b]というコピーが不要になるので楽。


$file_handle = fopen('php://stdin', "r");

function warshall_floyd($cost) {
	global $n;

	for ($i = 1; $i <= $n; ++$i) {
	    for ($j = 1; $j <= $n; ++$j) {
	        for ($k = 1; $k <= $n; ++$k) {
	        	//INFだったらスルー。これで劇的に早くなる。
	        	if ($cost[$j][$i]===INF || $cost[$i][$k]===INF) continue;
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $cost[$j][$i] + $cost[$i][$k];
	            if ($via < $cost[$j][$k]) {
	                $cost[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $cost;
}


while(1){
	//ファイル読み込み
	$info = trim(fgets($file_handle));
	$explode = explode(' ', $info);
	$n = $explode[0]; $m = $explode[1]; $s = $explode[2]; $g1 = $explode[3]; $g2 = $explode[4];
	//終了条件
	if ($n==0) break;
	
	//初期化

	//ワーシャルフロイド準備。
	for ($i=1; $i<=$n; ++$i){
		for ($j=1; $j<=$n; ++$j){
			if ($i === $j){
				$cost[$i][$i] = 0;
			} else {
				$cost[$i][$j] = INF;
			}
		}
	}

	//辺の情報を格納
	for ($i=1; $i<=$m; ++$i){
		$info2 = trim(fgets($file_handle));
		$explode = explode(' ', $info2);
		$a = $explode[0]; $b = $explode[1]; $c = $explode[2];
		$cost[$a][$b] = $c;
	}

	//探索。先に全点対最短路を求めておく必要がある
	$cost = warshall_floyd($cost);
	
	//最小値計算
	$min = INF;
	for($i=1; $i<=$n; ++$i){
		//どこで分岐するのが最も総コストが低いか比較
		$via = $cost[$s][$i] + $cost[$i][$g1] + $cost[$i][$g2];
		$min = min($min, $via);
	}
	
	//出力
	echo $min.PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 9900
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    int N;
    cin>>N;
    int d[110];
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    set<int>values;
    for(int i=0;i<N;i++){
        values.insert(d[i]);
    }

    cout<<values.size()<<endl;


}


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

int main()
{
  int n;
  cin >> n;
  int a[n];
  
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  int dp[n];
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for(int i = 2; i < n; i++)
    dp[i] = min(abs(a[i] - a[i-1]) + dp[i-1], abs(a[i] - a[i-2]) + dp[i-2]);
  
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

typedef long long value; // 格納するデータの型
const value INIT = 0ll; // 初期値．目的に応じて，適切な値に変更すること．

class segment_tree {
private:
	int n;
	vector<value> dat;

	value func(value a, value b) const { // ノードの値を決める為の関数
		return max(a, b);
	}

	value query(int a, int b, int k, int l, int r) const {
		if(r <= a || b <= l) // 求める区間が，ノードの区間と重なっていない．
			return INIT;

		if(a <= l && r <= b) { // 求める区間が，ノードの区間を完全に含む．
			return dat[k];
		}
		else {
			const int mid = (l + r) / 2;
			const value vl = query(a, b, k * 2 + 1, l, mid);
			const value vr = query(a, b, k * 2 + 2, mid, r);
			return func(vl, vr);
		}
	}

public:
	segment_tree(int n_) {
		n = 1;
		while(n < n_)
			n *= 2;

		dat.assign(2 * n, INIT);
	}

	void update(int k, value a) { // k番目の要素をaに更新する．
		k += n - 1;
		dat[k] = a;
		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	value query(int a, int b) { // [a, b)に対するクエリ
		return query(a, b, 0, 0, n);
	}
};

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

	int m;
	cin >> m;

	segment_tree segt(m);

	long long mx = 0;
	for(int i = 0; i < m; ++i) {
		int w;
		cin >> w;

		long long tmp = segt.query(1, w) + w;
		segt.update(w, tmp);
		chmax(mx, tmp);
	}

	cout << ((m + 1ll) * m / 2ll - mx) << endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 3120
a, b, c, d, e, f = map(int, input().split())
tmp = {}

for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w = (100*a)*i + (100*b)*j
                s = c*k + d*l
                if w == 0:
                    break
                if w+s > f:
                    break
                else:
                    if w/100 * e >= s:
                        density = 100*s/(w+s)
                        tmp[w, s] = density

mxv = max(tmp, key=tmp.get)
print(mxv[0]+mxv[1], mxv[1])

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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;
int a[N];

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

    int n, cnt = 0;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> a[i];
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0) cnt = 1;
        }
    }
    if(cnt == 0){
        cout << "APPROVED";
        return 0;
    }
    cout << "DENIED";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	ll i;
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	
	ll dp[3][n];
	memset(dp,0,sizeof(dp));
	dp[0][0]=a[0];
	dp[1][0]=b[0];
	dp[2][0]=c[0];
	if(n==1)
	{
		cout<<max(a[0],max(b[0],c[0]));
		return 0;
	}
	dp[0][1]=a[1]+max(a[0],max(b[0],c[0]));
	dp[1][1]=b[1]+max(a[0],max(b[0],c[0]));
	dp[2][1]=c[1]+max(a[0],max(b[0],c[0]));
	if(n==2)
	{
		cout<<max(dp[0][1],max(dp[1][1],dp[2][1]));
		return 0;
	}
	for(i=2;i<n;i++)
	{
		dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k, pos = 1;
double res = 0, ans = 0;
vector< double > p( 2e5 + 5 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k;
	for( int i = 1; i <= n; ++i )
	{
		cin >> p[ i ];		
	}
	for( int i = 1; i <= k; ++i )
	{
		res += ( p[ i ] + 1 ) / 2;
	}
	ans = max( ans, res );
	for( int i = k + 1; i <= n; ++i )
	{
		res -= ( p[ pos ] + 1 ) / 2;
		++pos;
		res += ( p[ i ] + 1 ) / 2;
		ans = max( ans, res );
	}
	cout << setprecision( 15 ) << fixed << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int countFreq(string txt, string pat){
    int N = txt.size(), M = pat.size();
    int i,j,res;

    for(i =0; i <= N-M; i++){
        for(j = 0; j < M; j++){
            if(txt[i+j] != pat[j]) break;
        }
        if(j == M){
            res++;
            j = 0;
        }
    }
    return res;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    
    #ifndef ONLINE_JUDGE
        fread();
    #endif
    */
    
    
    int n;
    string s; 
    while(scanf("%d",&n)==1){
        //init();
        getchar();
        string s; cin>>s;
        printf("%d\n", countFreq(s, "ABC"));
    }
    return 0;
}

Measured memory_bytes: 256
# D Gathering_Children

def Ranlength_RL(arr):
    r,l = 0,0
    res = []
    for i in arr:
        if (i == "R"):
            r+=1
            if (l!=0) : 
                res.append(l)
                l = 0
        if (i == "L"):
            l+=1
            if (r!=0) :
                res.append(r)
                r = 0
    if (l!=0) : res.append(l)
    return res

def main():
    s = input()
    si = 0
    ans = [0]*len(s)
    r = Ranlength_RL(s)
    for i in range(0,len(r)-1,2):
        n = r[i] + r[i+1]
        if (n % 2 == 0):
            e,o = n//2,n//2
        else:
            e,o = n//2+1,n//2
            if (r[i] % 2 == 0):
                e,o = o,e
        ans[r[i]+si-1] = e
        ans[r[i]+si] = o
        si += n

    for i in ans:
        print(i,end=" ")
        


if __name__ == "__main__" :
    main()



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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> res(n,1);
    vector<int> ht(n,0);

    for(int i=0;i<n;i++)
        cin>>ht[i];

    int ans = 0;
    for(int i=0;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        if( ht[a-1] == ht[b-1])
        {
            res[a-1] = 0;
            res[b-1] = 0;
        }
        else if(ht[a-1] > ht[b-1])
            res[b-1] = 0;
        else
            res[a-1] = 0;
    }

    for(int i = 0; i< n;i++)
        if(res[i] > 0)
            ans++;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}
ll n,k;
ll a[maxn],f[maxn];
bool check(ll mid)
{	
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(a[i]*f[i]<=mid)
		continue;
		else
		{	
		
			ans+=(a[i]-(mid)/f[i]);
		}
		
	}
	return (ans<=k);
}
int32_t main()
{
    
   

  
    IOS
	
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	cin>>a[i];
	for(ll j=0;j<n;j++)
	cin>>f[j];
	sort(f,f+n);
	sort(a,a+n,greater<ll>());
	ll l=0,r=1e13;
	while(r-l>1)
	{
		ll mid=(l+r)>>1;
		if(check(mid))
			r=mid;
		else
		{
			l=mid;
		}
		
	}
	if(check(l))
	cout<<l;
	else
	{
		cout<<r;
	}
	
	
	
}
  
           
         
       


Measured memory_bytes: 6016
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

map<string, set<int> > memo;

bool kakko(const string &str) {
  int n = str.size();
  int open = 0;
  REP(i, n - 1) {
    if (str[i] == '(') { open++; }
    if (str[i] == ')') { open--; }
    if (open == 0) { return false; }
  }
  return true;
}

set<int> calc(const string str) {
  if (memo.count(str)) { return memo[str]; }
  set<int> ret;
  int n = str.size();
  int open = 0;
  bool onlyDigit = true;
  REP(i, n) { if (!isdigit(str[i])) { onlyDigit = false; } }
  if (onlyDigit) {
    ret.insert(atoi(str.c_str()));
  } else if (kakko(str)) {
    ret = calc(str.substr(1, n - 2));
  } else {
    REP(i, n) {
      if (str[i] == '(') { open++; }
      else if (str[i] == ')') { open--; }
      else if (isdigit(str[i])) {
      } else if (open == 0) {
        set<int> left = calc(str.substr(0, i));
        set<int> right = calc(str.substr(i + 1, n - (i + 1)));
        FORIT(it1, left) {
          FORIT(it2, right) {
            if (str[i] == '+') {
              ret.insert(*it1 + *it2);
            } else if (str[i] == '-') {
              ret.insert(*it1 - *it2);
            } else if (str[i] == '*') {
              ret.insert(*it1 * *it2);
            } else if (str[i] == '/') {
              if (*it2 == 0) { continue; }
              ret.insert(*it1 / *it2);
            }
          }
        }
      }
    }
  }
  //cout << str << " " << endl;
  //FORIT(it, ret) { cout << *it << " "; }
  //puts("");
  return memo[str] = ret;
}

int main() {
  string str;
  while (getline(cin, str), str[0] != '#') {
    memo.clear();
    printf("%d\n", (int)calc(str).size());
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    /*
    int t,n;
    cin>>t;
    loop(t1,1,t+1)
    {
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    string s,t;
    cin>>s>>t;
    int n = s.length(), f = 1;
    loop(i,0,n) if(s[i] != t[i]) {f = 0; break;}

    //int ans;

    if(f) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';

    return 0;
}


Measured memory_bytes: 3596
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = []
a,b,c = 0,0,0
for i in range(n):
    if i>=k:
        if t[i]==ans[i-k]:
            ans.append('X')
            continue
    if t[i] =='r':
        ans.append('r')
        c += 1
    elif t[i]=='s':
        ans.append('s')
        a += 1
    else:
        ans.append('p')
        b += 1
print(a*r+b*s+c*p)

Measured memory_bytes: 77012
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
	long int n,ds;
	cin>>n>>ds;
	vector<pair<long int, long int> > a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	long int count=0;
	vector<double> d(n);
	for(int i=0;i<n;i++){
		d[i] = sqrt(pow(a[i].first,2) + pow(a[i].second,2));
		if(d[i]<=ds)
		count++;
	}
	cout<<count;

	return 0;
}

Measured memory_bytes: 8044
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            ArrayList<Integer> a = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                a.add(sc.nextInt());
            }

            for (int i = 0; i < n - k; i++) {
                if (a.get(i) < a.get(i + k)) {
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
            }
            return null;
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 56088
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

#define MAX_N (2*100000)
vector<vector<ll>>G;
vector<ll> Ans;
vector<bool> visited;
int main() {
    cout.precision(15);
    cout << fixed;
    ll N,M;
    cin>>N>>M;
    Ans.resize(N,-1);
    G.resize(N);
    REP(i,M) {
        ll A,B;
        cin >> A>>B;
        --A;--B;
        G[A].pb(B);
        G[B].pb(A);
    }
    queue<int> cpos;
    cpos.push(0);
    Ans[0]=-1;
    while(!cpos.empty()) {
        int n=cpos.front();
        cpos.pop();
        for(auto e:G[n]) {
            if (Ans[e]==-1) {
                Ans[e]=n;
                cpos.push(e);
            }
        }
    }

    cout<<"Yes"<<endl;
    REP(i,N-1)
        cout<<Ans[i+1]+1<<endl;

}


Measured memory_bytes: 12692
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n,m,c;
	cin>>n>>m>>c;
	vector<int> A,B;
	int a,b;
	rep(i,m){
		cin>>b;
		B.push_back(b);
	}
	int ans = 0;
	rep(i,n){
		A.clear();
		rep(i,m){
			cin>>a;
			A.push_back(a);
		}
		ll memo = 0;
		rep(i,m){
			memo += A[i]*B[i];
		}
		memo += c;
		if(memo>0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
XY = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

# マンハッタン距離の偶奇は全部同じじゃないとだめ
x, y = XY[0]
odd = (abs(x) + abs(y)) % 2
ok = True
for x, y in XY:
    ok &= (abs(x) + abs(y)) % 2 == odd

if not ok:
    print(-1)
    exit()


def solve(x):
    # a + b = 2^39 - 1
    # a - b = x
    # とおいて a を求める
    # 2a = 2^39 - 1 + x
    n = int((2 ** 39 - 1 + x) // 2)
    ret = []
    for _ in range(39):
        if n & 1:
            ret.append(1)
        else:
            ret.append(-1)
        n >>= 1
    ret = np.array(ret, dtype=int)
    return ret


P = [complex(x, y) for x, y in XY]
P = np.array(P)
# マンハッタン距離を奇数にする
# 原点を (-1, 0) だけずらす
if not odd:
    P -= 1
# 45度回転してみる
# アームの長さが決まってるとき、xとyについて独立にプラスマイナスを決められるようになる
P *= 1 + 1j

D = (2 ** np.arange(39, dtype=int)).tolist()
ans = []
for p in P:
    xd = solve(p.real)
    yd = solve(p.imag)
    W = np.empty_like(D, dtype='U1')
    W[(xd > 0) & (yd > 0)] = 'R'
    W[(xd > 0) & (yd < 0)] = 'D'
    W[(xd < 0) & (yd > 0)] = 'U'
    W[(xd < 0) & (yd < 0)] = 'L'
    ans.append(''.join(W))

if not odd:
    D.append(1)
    for i in range(len(ans)):
        ans[i] += 'R'
print(len(D))
print(*D)
print(*ans, sep='\n')


Measured memory_bytes: 12652