akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define mod  1000000007
#define ps(x, y) fixed<<setprecision(y)<<x
#define w(t) int t; cin>>t;while(t--)
int power (int b , int a) {
	int ans = 1;
	a = a % mod;
	while (b != 0) {
		if (b & 1)
		{ans = (ans * a) % mod;}
		b >>= 1; //b/2
		a = a * a;
		a %= mod;

	}
	return ans;
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt" , "w", stdout);
#endif
	int n , m;
	cin >> n >> m;
	int arr[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	map<int, set<int> > mp;
	int count = 0;
	while (m--) {
		int a , b;
		cin >> a >> b;
		mp[a].insert(b);
		mp[b].insert(a);



	}
	// for (auto x : mp) {
	// 	cout << x.first << " ";
	// 	set<int>v = x.second;
	// 	for (auto x : v) {
	// 		cout << x << " ";
	// 	}
	// 	cout << "\n";

	// }
	//int flag = 0;
	for (auto x : mp) {
		int flag = 0;
		set<int>v = x.second;
		for (auto y : v) {

			if (arr[x.first ] <= arr[y ]) {
				//count++;
				flag = 1;
				break;
			}


		}
		if (flag == 0)count++;
	}
	for (int i = 1; i <= n; i++) {
		if (mp.find(i) == mp.end()) {
			count++;
		}
	}
	cout << count << "\n";
	return 0;



}





Measured memory_bytes: 22740
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
        
      if((A == B  && A != C ) || (A == C && A != B) || (B == C && A != B)){
      
      System.out.print("Yes");

      }else{
 
      System.out.print("No");
 
     }

   }
 }

Measured memory_bytes: 35752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int best = 1;
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        while (t != string(t.size(), c)) {
            string u;
            for (int i=1; i<(int)t.size(); i++)
                u.pb(t[i]==c||t[i-1]==c? c:'?');
            swap(t, u);
        }
        best = max<int>(best, t.size());
    }
    cout << (s.size() - best) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int A, P;
    cin >> A >> P;
    cout << ((A * 3 + P) / 2) << endl;
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,P[202020];
ll a[10][10];
ll i, j,ans;
int main(){
    scanf("%lld",&N);
    fornum(i,1,N+1){
        ll b = i % 10;
        ll c = i;
        while(c/10){
            c /= 10;
        }
        ++a[b][c];
    }
    fornum(i,0,10){
        fornum(j,0,10){
            ans += a[i][j] * a[j][i];
        }
    }
    printf("%lld", ans);
    return 0;
}

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

using namespace std;

int main()
{

int a,b,c,k,x=0;
cin>>a>>b>>c;
cin>>k;
while(a>=b)
{
    b=b*2;
    x++;
}
while(b>=c)
{
    c=c*2;
    x++;
}

if(x<=k){cout<<"Yes";}
else{cout<<"No";}

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    string s;
    int ans=0;
    cin >> n >> s;
    for (int i=1; i<n; i++){
        int cnt=0;
        for (char c='a'; c<='z'; c++){
            bool left=false, right=false;
            for(int j=0; j<i; j++){
                if (s[j] == c) left = true;
            }
            for (int j=i; j<n; j++){
                if (s[j] == c) right = true;
            }
            if(right && left) cnt++;
        }
        ans = max(cnt, ans);
    }
    out(ans);

}

Measured memory_bytes: 256
while 
    x = gets()
    x = x.split
    if x[0].to_i == 0 && x[1].to_i == 0; break
    end
    a = x[0].to_i - 2
    puts "#" * x[1].to_i
    a.times do
    puts "#" + "." * (x[1].to_i - 2) + "#"
    end
    puts "#" * x[1].to_i
    puts ""
end



Measured memory_bytes: 6960
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    string weather[] = {"Sunny", "Cloudy", "Rainy"};

    int w = 0;
    for(w = 0; w < 3 ; w++){
        if(s.compare(weather[w]) != 0){
            continue;
        }
        if( w == 2 ){
            w = 0;
        } else {
            w++;
        }
        break;
    }

    cout << weather[w] << endl;

    return 0;
}



Measured memory_bytes: 256
arr = input().split(" ")
num = list(map(lambda x: int(x), input().split(" ")))
lost = input()

if arr[0] == lost:
    num[0] = num[0] - 1
elif arr[1] == lost:
    num[1] = num[1] - 1
print(str(num[0]) + " " + str(num[1]))

Measured memory_bytes: 3060
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll N, K;
  cin >> N >> K;

  vector< double > v(N + 1), sum(N + 1);
  FOR(i, 1, N)
  {
    double pi;
    cin >> pi;

    v[i] = double(pi + 1.0) / 2.0;
    sum[i] = v[i] + sum[i - 1];
  }

  double ans = 0;
  FOR(i, 0, N - K)
  {
    double res = sum[i + K] - sum[i];
    ans = max(ans, res);
  }
  cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 3456
n = int(input())
xx = [[] for _ in range(200001)]
yy = [[] for _ in range(200001)]
xy = [[] for _ in range(400001)]
yx = [[] for _ in range(200001)]
for _ in range(n):
    x, y, u = input().split()
    if u=='U' or u=='D':
        xx[int(x)].append((int(y), u))
    else:
        yy[int(y)].append((int(x), u))
    xy[int(x)+int(y)].append((int(x), u))
    yx[int(y)-int(x)].append((int(x), u))
ans = 10**10
for i in xx:
    if len(i)<=1:
        continue
    i.sort()
    d = -10**10
    for j, k in i:
        if k=='U':
            d = j
        elif ans > (j-d)*5:
            ans = (j-d)*5
for i in yy:
    if len(i)<=1:
        continue
    i.sort()
    d = -10**10
    for j, k in i:
        if k=='R':
            d = j
        elif ans > (j-d)*5:
            ans = (j-d)*5
for i in xy:
    if len(i)<=1:
        continue
    i.sort()
    d = -10**10
    for j, k in i:
        if k=='R':
            d = j
        elif k=='U' and ans > (j-d)*10:
            ans = (j-d)*10
    d = -10**10
    for j, k in i:
        if k=='D':
            d = j
        elif k=='L' and ans > (j-d)*10:
            ans = (j-d)*10
for i in yx:
    if len(i)<=1:
        continue
    i.sort()
    d = -10**10
    for j, k in i:
        if k=='U':
            d = j
        elif k=='L' and ans > (j-d)*10:
            ans = (j-d)*10
    d = -10**10
    for j, k in i:
        if k=='R':
            d = j
        elif k=='D' and ans > (j-d)*10:
            ans = (j-d)*10
if ans == 10**10:
    print('SAFE')
else:
    print(ans)

Measured memory_bytes: 191640
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
n=int(input())
A=list(map(int,input().split()))
YN(len(A)==len(set(A)))

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

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vvi A(N, vi(M));
	vi B(M);
	cin >> B >> A;

	int ans = 0;

	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++)
			sum += A[i][j] * B[j];

		if (sum + C > 0)
			ans++;
	}

	say(ans);


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
#include <set>
using namespace std;
using ll = long long;

const int borne = 2e5 + 5;
vector<int> adj[borne];
int val[borne];
int res[borne];
int nbNod;

set<pair<int, int>> cur;
void dfs(int nod, int par) {
	auto it = cur.lower_bound({val[nod], -1});
	auto itPrev = it; --itPrev;
	pair<int, int> und = {-1, -1};
	pair<int, int> toAdd = und, toDel = und;
	if (it == cur.end() || (itPrev->second+1 >= it->second)) { 
		if (it != cur.end()) {
			toAdd = *it;
			cur.erase(it);
		}
		toDel = {val[nod], itPrev->second+1};
		cur.insert(toDel);
	}
	res[nod] = cur.rbegin()->second;
	for (int child : adj[nod]) if (child != par) {
		dfs(child, nod);
	}
	if (toDel != und) cur.erase(toDel);
	if (toAdd != und) cur.insert(toAdd);
}

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

	cin >> nbNod;
	for (int iNod = 0; iNod < nbNod; ++iNod) {
		cin >> val[iNod];
	}
	for(int iEdge = 0; iEdge < nbNod-1; ++iEdge) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cur.insert({0, 0});
	dfs(0, -1);
	for (int iNod = 0; iNod < nbNod; ++iNod) {
		cout << res[iNod] << "\n";
	}

	return 0;
}


Measured memory_bytes: 36284
dice = list(map(str, input().split()))
direction = input()
for i in range(len(direction)):
    if direction[i] == "N":
        dice[0], dice[1], dice[4], dice[5] = dice[1], dice[5], dice[0], dice[4]
    elif direction[i] == "S":
        dice[0], dice[1], dice[4], dice[5] = dice[4], dice[0], dice[5], dice[1]
    elif direction[i] == "W":
        dice[0], dice[2], dice[3], dice[5] = dice[2], dice[5], dice[0], dice[3]
    else:
        dice[0], dice[2], dice[3], dice[5] = dice[3], dice[0], dice[5], dice[2]
print(dice[0])

Measured memory_bytes: 7480
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int c=0;
    int n,t,flag;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%15==0)
            continue;
        else if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else
            c=c+i;
    }
    cout<<c;

}


Measured memory_bytes: 3632
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto s = readln.chomp.to!(char[]);
  int q;
  rd(q);
  auto ks = readln.split.to!(int[]);
  foreach (k; ks) {
    long d = 0, dm = 0, dmc = 0;
    long m = 0;
    foreach (i; 0 .. k) {
      if (s[i] == 'D') {
        d++;
      } else if (s[i] == 'M') {
        dm += d;
        m++;
      } else if (s[i] == 'C') {
        dmc += dm;
      }
    }
    foreach (i; k .. n) {
      if (s[i - k] == 'D') {
        d--;
        dm -= m;
      } else if (s[i - k] == 'M') {
        m--;
      }
      if (s[i] == 'D') {
        d++;
      } else if (s[i] == 'M') {
        dm += d;
        m++;
      } else if (s[i] == 'C') {
        dmc += dm;
      }
    }
    writeln(dmc);
  }

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[26];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        if(i==0)
        {
            a=a1=m;
        }
        else
        {
            a=max(a,m);
            a1=min(a1,m);
        }
    }
    cout<<a-a1;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,sum = 0;
  cin  >>N;
  vector<int> array (N);
  for (int i = 0; i < N ;i++)
    cin >> array.at(i);
  sort(array.begin(),array.end());
  reverse(array.begin(),array.end());
  for (int i = 0;i < N;i++){
    if(i%2==0)sum+=array.at(i);
    else sum-=array.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char c = sc.next().toCharArray()[0];
		char[] vowel = { 'a', 'i', 'u', 'e', 'o' };
		for (int i = 0; i < 5; i++) {
			if (c == vowel[i]) {
				System.out.println("vowel");
				return;
			}
		}
		System.out.println("consonant");
	}

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


Measured memory_bytes: 8916
#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() {
    ll n,k;
    cin>>n>>k;

    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }

    ll ans=0;
    for(int i=k+1;i<=n;i++){
        int y=i-k;
        ans+=y*((n+1)/i);
        int r=(n+1)%i;
        ans+=max(r-k,0LL);
        //cout<<i<<" "<<ans<<endl;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll x, y, z, n, a, b, p;
int main(void){
    // Your code here!
    cin >> n >> a >> b;
    for (ll i = 0; i < n; i++){
        cin >> p;
        if (p <= a){
            x++;
        } else if (p > b){
            z++;
        } else {
            y++;
        }
    }
    cout << min(x, min(y, z)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <iterator>
#include<algorithm>
#include<fstream>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
const int maxn = 2e5 + 5;
#define ll long long
int main()
{
    string s, t;
    cin >> s >>t;
    int i;
    for (i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])break;
    }
    if (i == s.length())
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int N;
  int tmp,c = 0;
  
  cin >> N;
  vector<int> a;
  
  for(int i = 0;i < N;i++){
    int z;
    cin >> z;
    z--;
    a.push_back(z);
  }
  
  tmp = 0;
  int i = 0;
  while(true){
    if(tmp == 1){
      cout << i << endl;
      break;
    }
    if(i >= N){
      cout << -1 << endl;
      break;
    }
    tmp = a.at(tmp);
    i++;
  }
  
  return 0;
}

Measured memory_bytes: 892
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)

Measured memory_bytes: 23044
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#define int long long
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

signed main() {

    int a,b,c,x;
    int n;
    int count = -1;
    int m[140000];
    int ans = 0;

    cin >> a >> b >> c >> x;
    n = (a+1)*(b+1)*(c+1);

    for(int i = 0; i < n; i ++){
        m[i] = 10000000;
    }

    for(int i = 0; i < a+1; i ++){
        for(int j = 0; j < b+1; j ++){
            for(int k = 0; k < c+1; k ++){
                count ++;
                m[count] = i*500 + j*100 + k*50;
            }
        }
    }

    for(int i = 0; i < n; i ++){
        if(m[i] == x) ans ++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4632
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var m = o.m(n);
  var t = 0, x = 0, y = 0;
  for(var i = 0; i < n; i++){
    var dxy = Math.abs(x - m[i][1]);
    dxy += Math.abs(y - m[i][2]);
    var dt = m[i][0] - t;
    if(dxy > dt || dxy % 2 !== dt % 2)return "No";
    x = m[i][1]; y = m[i][2]; t = m[i][0];
  }
  return "Yes";
}

Measured memory_bytes: 63976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;

const int MAX_V = 100;
const int INF = INT_MAX;

int v;
int g[MAX_V][MAX_V];
int d[MAX_V][MAX_V];

bool warshallfloyd()
{
  copy(&g[0][0], &g[MAX_V][0], &d[0][0]);
  for(int i = 0; i < v; i++)
    d[i][i] = 0;
  
  for(int k = 0; k < v; k++)
    for(int i = 0; i < v; i++)
      for(int j = 0; j < v; j++)
        if(d[i][k] != INF && d[k][j] != INF)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  
  for(int i = 0; i < v; i++)
    if(d[i][i] < 0) return false;
  
  return true;
}

int main()
{
  int gv, ge;
  cin >> gv >> ge;
  v = gv;
  fill(&g[0][0], &g[MAX_V][0], INF);
  for(int i = 0; i < ge; i++){
    int gs, gt, gd;
    cin >> gs >> gt >> gd;
    g[gs][gt] = gd;
  }
  
  if(warshallfloyd())
    for(int i = 0; i < v; i++)
      for(int j = 0; j < v; j++){
        if(d[i][j] != INF)
          cout << d[i][j];
        else
          cout << "INF";
        if(j != v - 1)
          cout << " ";
        else 
          cout << endl;
      }
  else
    cout << "NEGATIVE CYCLE" << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {


  int K;
  int out;
  cin >> K;
  if (K % 2 == 0) {
    out = (K / 2) * (K / 2);
  } else {
    out = (K * K - 1) / 4;
  }
  cout << out << endl;

  return 0;
}


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

using namespace std;

const long long MOD = 1000000007;
int main() {
    int N;
    cin>>N;
    vector<vector<int> >a(N);
    for(int i=0;i<N-1;i++){
        int l,m;
        cin>>l>>m;
        l--;
        m--;
        a[l].push_back(m);
        a[m].push_back(l);

    }
    int c[N];
    for(int i=0;i<N;i++){
        cin>>c[i];
    }
    sort(c,c+N);
    reverse(c,c+N);
    int ne=-1;
    int kazu=-1;
    for(int i=0;i<N;i++){
        if((int)a[i].size()>kazu){
            kazu=a[i].size();
            ne=i;
        }

    }
    queue<int>bfs;
    int used[N];
    for(int i=0;i<N;i++){
        used[i]=-1;

    }
    int ans[N];
    int now=0;
    bfs.push(ne);
    used[ne]=1;
    while(!bfs.empty()){
        int m=bfs.front();
        bfs.pop();
        used[m]=1;
        ans[m]=c[now];
        now++;
        for(int i=0;i<a[m].size();i++){
            if(used[a[m][i]]!=1){
                bfs.push(a[m][i]);
            }
        }
    }
    int sum=0;
    for(int i=1;i<N;i++){
        sum+=c[i];
    }
    cout<<sum<<endl;
    for(int i=0;i<N;i++){
        cout<<ans[i];
        if(i==N-1){
            cout<<""<<endl;
        }else{
            cout<<" ";
        }
    }



}













Measured memory_bytes: 1024
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		
		int a1=sc.nextInt();
		int a2=sc.nextInt();
		int a3=sc.nextInt();
		int a4=sc.nextInt();
		
		int a5=(Math.abs(a3-a1))*(Math.abs(a4-a2));
		System.out.println(a5);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define MOD 1000000007
#define INF (1LL)<<50;
 
signed main(){
 
	lli n;
	cin>>n;
	lli k;
	cin>>k;
	vector<lli> v(n);
	REP(i,0,n)cin>>v[i];
 
	lli ans=-INF;
	for(lli i=0;i<n;i++){
 
		vector<lli> p;
		lli left=i;
		lli sum=0;
		for(lli ii=0;ii<left;ii++){
			sum += v[ii];
			if(v[ii]<0)p.push_back(v[ii]);
		}
 
		
		for(lli j=0;j<=n;j++){
 
			if(i+j>k)continue;
 
		
			lli right=n-j;
			if(left>right)continue;
 
			vector<lli> pp;
			lli nextSum=sum;
			REP(g,0,p.size())pp.push_back(p[g]);
 
			for(lli jj=n-1;jj>=right;jj--){
				nextSum+= v[jj];
				if(v[jj]<0)pp.push_back(v[jj]);
			}
 
			sort(pp.begin(),pp.end());
 
			lli allowCnt = k-(i+j);
 
			for(lli g=0;(g<allowCnt && g<pp.size());g++){
				nextSum -= pp[g];
			}
			ans = max(ans,nextSum);
		}
	}
 
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> ok(n,false);
    rep(i,k) {
        int d;
        cin >> d;
        rep(j,d) {
            int a;
            cin >> a;
            ok[a-1] = true;
        }
    }
    int ans = 0;
    rep(i,n) if (!ok[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  for(int i=0;i<W+2;i++)
    cout << "#";
  
  cout << endl;
  
  
  for(int i=0;i<H;i++){
    vector<int> a(W);
    
    cout << "#";
    
    for(int j=0;j<W;j++){
      char a;
      cin >> a;
      cout << a;
    }
    
    cout << "#" << endl;
  }
  
  
  for(int i=0;i<W+2;i++)
    cout << "#";
  
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;

//動き方K通りで貰うDPだと base case 作りづらい→配るDP
//j-1まででのminとjでのを比べてより小さい方をansに入れてたけど再帰になって面倒
//ans結局cost[i]に入れるなら最初からcostに入れて上書きしてけばいい 全部のi,jでfor文
int main() {
  int N,K;
  cin >> N >> K;
  int h[N-1];
  for(int i=0; i<N; i++) //0スタートにした
    cin >> h[i]; //宣言分けないようにした
  //dp[],制約見てN-1+K入れても大丈夫なくらい大きく確保 or N-1+K確保
  long long dp[110000]; //INFで初期化するからintだと桁足りないの注意
  for(int i=0; i<N; i++)
    dp[i] = INF; //最小化問題だからINFで初期化　比べて小さい方採用ってしたいから-1入れたらだめ
  dp[0] = 0; //配るDPにするから base case i=0だけ
  for(int i=0; i<N; i++) {
    for(int j=1; j<K+1; j++)
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j])); //配るDPで全部のi,j試す 2+4と3+3比べるみたいな
  }
  cout << dp[N-1] << endl; //Nじゃないの注意
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

	return NIL;

}

Node treeMaximum(Node x){

	return NIL;
}

Node treeSearch(Node u, int k){
	while (u)
	{
		if (u->key == k) return u;
		else if (k < u->key) u = u->left;
		else u = u->right;
	}

	return NIL;
}

Node treeSuccessor(Node x){


	return NIL;
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y



}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z;

	z = (Node)malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	if (root == NIL)
	{
		root = z;
		return;
	}
	while (x != NIL) {
		y = x;
		if (k < x->key)
			x = x->left;
		else
			x = x->right;
	}

	if (k < y->key)
		y->left = z;
	else
		y->right = z;
}

void inorder(Node u){
	if (u == NULL) return;

	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node u){
	if (u == NULL) return;

	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}
	return 0;
}

Measured memory_bytes: 21348
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
 
using namespace std;
  
int main() {	
	int n, C, tmp;
	cin >> n>>C;
	vector<vector<int>> d(C, vector<int>(C));
	vector<vector<int>> col(3, vector<int>(C, 0));

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C;j++) {
			cin >> d[j][i];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> tmp;
			col[(i + j) % 3][tmp - 1]++;
		}
	}

	vector<vector<int>> in_pr(3,vector<int>(C));
	for (int i = 0; i < 3; i++) {
		transform(d.begin(), d.end(),
			in_pr[i].begin(),
			[col,i](vector<int> di)->int {return inner_product(di.begin(), di.end(), col[i].begin(), 0); });
	}


	int ans{ INT32_MAX };
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			if (i == j) continue;
			for (int k = 0; k < C; k++) {
				if (i == k || j == k)continue;
				ans = min(ans, in_pr[0][i] + in_pr[1][j] + in_pr[2][k]);
			}
		}
	}

	std::cout << ans << endl;

	return 0;
}

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

using namespace std;

long long x;
int Ans=0;
inline int calc(long long x,int t)
{
	int ret=0,ss=0;
	while(x)
		ss++,ret+=(ss>t)*(x%10),x/=10;
	return ret-(t!=0);
}
int main()
{
	cin >> x;
	int len=0; long long tx=x;
	while(tx) len++,tx/=10;
	for(int i=0;i<len;i++)
	{
		Ans=max(Ans,calc(x,i)+9*i);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static long p = 0;
        static int[] ng;

        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int n = int.Parse(inputs[0]) + 1;
            int m = int.Parse(inputs[1]);
            ng = new int[n];
            for (int i = 0; i < n; i++)
                ng[i] = 0;
            for (int i = 0; i < m; i++)
                ng[int.Parse(Console.ReadLine())] = 1;
            long[] nums = new long[n];
            nums[0] = 1;
            for (int i = 0; i < n; i++)
            {
                if (ng[i] == 0)
                {
                    if (i + 1 < n)
                    {
                        nums[i + 1] += nums[i];
                        nums[i + 1] %= 1000000007;
                    }
                    if (i + 2 < n)
                    {
                        nums[i + 2] += nums[i];
                        nums[i + 2] %= 1000000007;
                    }
                }
            }
            Console.WriteLine(nums[nums.Length - 1]);
        }
    }
}

Measured memory_bytes: 14176
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  long t=sc.nextLong();
  long total=0;
 for(long i=0;i<=t;i++){
  	if(i%3==0 || i%5==0){
    continue;
    }
    else{
    total+=i;
    }
  }
  System.out.println(total);
}
}


Measured memory_bytes: 35816
import sys
from bisect import bisect_left, bisect_right
from collections import deque
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    idx1 = bisect_left(A, 0)
    idx2 = bisect_right(A, 0)
    A_minus = A[:idx1]
    A_zero = idx2 - idx1
    A_plus = A[idx2:]

    if N == K:
        ans = 1
        for a in A:
            ans *= a
            ans %= mod
        print(ans)
        return
    if N - A_zero < K:
        print(0)
        return
    if N - idx2 == 0 and K % 2 == 0:
        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= mod
        print(ans)
        return
    if N - idx2 == 0 and K % 2 != 0:
        if A_zero != 0:
            print(0)
            return
        ans = 1
        for i in range(K):
            ans *= A[N - i - 1]
            ans %= mod
        print(ans)
        return

    if (N - idx2) < K and (K - (N - idx2)) % 2 == 0:
        pos_idx = 0
        neg_idx = K - (N - idx2)
    elif (N - idx2) < K and (K - (N - idx2)) % 2 != 0:
        pos_idx = 1
        neg_idx = K - (N - idx2) + 1
    else:
        pos_idx = (N - idx2) - K
        neg_idx = 0

    while pos_idx < N - idx2 - 1 and neg_idx < idx1 - 1:
        x = A_plus[pos_idx] * A_plus[pos_idx + 1]
        y = A_minus[neg_idx] * A_minus[neg_idx + 1]
        if x < y:
            pos_idx += 2
            neg_idx += 2
        else:
            break

    ans = 1
    for i in range(pos_idx, N - idx2):
        ans *= A_plus[i]
        ans %= mod
    for i in range(neg_idx):
        ans *= A_minus[i]
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 95748
import math
mod=10**9+7
factorial=[1 for _ in range(10**5+10)]
for i in range(1, 10**5+10):
    factorial[i]=i*factorial[i-1] % mod
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*factorial[n]*factorial[m]%mod)
else:
    print(factorial[n]*factorial[m]%mod)


Measured memory_bytes: 7064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, r=0, b=0;
    string s;
    cin >> n >> s;
    for(size_t i = 0; i < n; i++)
    {
        if(s[i] == 'R') r++;
        else b++;
    }
    if(r > b) cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 1e5 + 100;

int a[MAXN];

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        sum += a[i];
    }
    cout << n + (m - sum) / a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s,t;
  cin >> s >> t;
  int c[26];
  memset(c,-1,sizeof(c));
  rep(i,s.size()) {
    int x=s[i]-'a',y=t[i]-'a';
    if(c[x]!=-1&&c[x]!=y) {
      pr("No");
      return;
    }
    c[x]=y;
  }
  swap(s,t);
  memset(c,-1,sizeof(c));
  rep(i,s.size()) {
    int x=s[i]-'a',y=t[i]-'a';
    if(c[x]!=-1&&c[x]!=y) {
      pr("No");
      return;
    }
    c[x]=y;
  }
  pr("Yes");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 916
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

std::string convert(ll b) {
  if (b == 0) return "+";
  else return "-";
}

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

  std::string S;
  std::cin >> S;
  ll N = 4;

  std::vector<ll> va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    va[i] = S[i] - '0';
  }

  for (ll S = 0; S < std::pow(2, 3); S++) {
    ll state = S;
    ll sum = va[0];
    std::vector<ll> vb;
    for (ll i = 0; i < 3; i++) {
      if (state % 2 == 0) {
	vb.push_back(0);
	sum += va[i+1];
      } else {
	vb.push_back(1);
	sum -= va[i+1];
      }
      state /= 2;
    }
    if (sum == 7) {
      std::cout << va[0];
      for (ll i = 0; i < 3; i++) {
	std::cout << convert(vb[i]) << va[i+1];
      }
      print("=7");
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

std::string s, t;

int dp[3001][3001];

int main(){
  std::cin >> s >> t;
  int n = s.length();
  int m = t.length();

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = std::max(dp[i-1][j], dp[i][j-1]);
    }
  }
  std::string ans;

  while(n && m){
    if(s[n-1] == t[m-1]) ans.push_back(s[n-1]), n--, m--;
    else if(dp[n-1][m] > dp[n][m-1]) n--;
    else m--;
  }
  std::reverse(ans.begin(), ans.end());

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=2e5;
const int inf=1e9;
int main(){
	int A,B,C,D; cin>>A>>B>>C>>D;
	long dp[C+1][D+1] = {};
	rep(i,A,C+1)rep(j,B,D+1){
		(dp[i][j] += i * dp[i][j-1] + j * dp[i-1][j]) %= mod;
        (dp[i][j] += mod - (i-1) * (j-1) * dp[i-1][j-1] % mod) %= mod;
        if(i == A && j == B) dp[i][j] = 1;
	}cout<<dp[C][D]<<endl;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n,k;
    cin >> n >> k;

    cout << (n-1) / (k-1) + ((n-1)%(k-1)?1:0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
using namespace std;
#define MOD 1000000007

long long N, K;
long long a[111];
long long dp[2][100001];

int main(){
    cin >> N >> K;
    for(long long i=0; i<N; i++)
        cin >> a[i];

    dp[0][0] = 1;

    for(long long i=0; i<N; i++){
        long long b[100002];
        fill_n(b, K+2, 0);

        for(int j=0; j<=K+1; j++)
            b[j] = (b[j-1] + dp[i%2][j-1])%MOD;

        for(long long j=0; j<=K; j++){
            dp[(i+1)%2][j] = (b[j+1] - b[max(j-a[i], 0LL)] + MOD)%MOD;
        }
    }
    cout << dp[N%2][K] << endl;

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double ans = 0;
        for(int n=0; n<N; n++) ans += 1/sc.nextDouble();
        System.out.println(1/ans);


    }
}

Measured memory_bytes: 24660
#include<stdio.h>

int main(void){
  int a[3],cnt5=0,cnt7=0,i;
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    if(a[i]==5) cnt5++;
    else if(a[i]==7) cnt7++;
  }
  if((cnt5==2) && (cnt7==1)) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <boost/version.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    string s;
    cin >> s;

    auto t = s;

    sort(all(t));

    int cnt = 0;

    rep(i,n){
        cnt += (t[i] != s[i]);
    }

    cout << cnt / 2 << '\n';

    return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if(c>=a && c<=b) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	int n,a;cin>>n;
	int ans=0;
	for (int i = 1; i <= n; i++)
	{
		cin>>a;
		if(a&1&&i&1)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(){
  string data;
  cin>>data;
  map<char,int> s;
  for(int i=0;i<data.size();i++){
    s[data[i]]=1;
  }
  if(data.size()==s.size()){
    cout<<"yes"<<endl;
  }
  else if(data.size()!=s.size()){
    cout<<"no"<<endl;
  }
}

Measured memory_bytes: 256