akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    std::cout << std::fixed << std::setprecision(10);
    int N, T, A;
    cin >> N >> T >> A;

    vector<int> H(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    int location = 1;
    double degree = 0.006;
    double minimum = abs(A - (T - (H[0] * degree)));
    double temp;
    // cout << mnimum << endl;

    for (int i = 1; i < N; i++)
    {
        temp = abs(A - (T - (H[i] * degree)));

        if (minimum > temp)
        {
            minimum = temp;
            location = i + 1;
        }
    }
    cout << location << endl;
    return (0);
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, A;

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

  std::cin >> H >> A;

  int res = (H + A - 1) / A;
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> M(H+1, vector<int>(W+1));
  REP(i, H) {
    string S;
    cin >> S;
    REP(j, W) {
      M[i+1][j+1] = S[j] - '0';
    }
  }
  REP(i, H) {
    REP(j, W) {
      M[i+1][j+1] += M[i+1][j];
    }
  }
  REP(i, H) {
    REP(j, W) {
      M[i+1][j+1] += M[i][j+1];
    }
  }
  
  int dHmax = 1 << (H-1);
  int ret = 999999;
  for(int dH=0; dH<dHmax; ++dH) {
    vector<pair<int, int>> segs;
    {
      int seg_l = 0;
      int tdH = dH;
      for(int i = 1; i < H; ++i) {
        if(tdH&1) {
          segs.push_back(make_pair(seg_l, i));
          seg_l = i;
        }
        tdH >>= 1;
      }
      segs.push_back(make_pair(seg_l, H));
    }
    for(const auto& seg : segs){
        int sT = seg.first, sB = seg.second;
        cerr << "(" << sT << "," << sB << ")" << " ";
    }
    int left = 0, vcut = 0;
    for(int i=1; i<=W; ++i) {
      int flag = false;
      for(const auto& seg : segs){
        int sT = seg.first, sB = seg.second;
        int tw = M[sB][i] - M[sT][i] - M[sB][left] + M[sT][left];
        if(tw > K) {
          flag = true;
          break;
        }
      }
      if(flag) {
        if(left == i - 1) {
          vcut = 999999;
          break;
        }
        left = i - 1;
        vcut++;
      }
    }
    cerr << __builtin_popcount(dH) << "+" << vcut << endl;
    int tret = __builtin_popcount(dH) + vcut;
    ret = min(ret, tret);
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
c = []
for i in range(3):
  r = list(map(int, input().split()))
  c.append(r)
  
d1 = set([])
d2 = set([])
d3 = set([])
d4 = set([])
for i in range(3):
  d1.add(c[i][1] - c[i][0])
  d2.add(c[i][2] - c[i][1])
  d3.add(c[1][i] - c[0][i])
  d4.add(c[2][i] - c[1][i])
if len(d1) == 1 and len(d2) == 1 and len(d3) == 1 and len(d4) == 1:
  print('Yes')
else:
  print('No')
  


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
typedef long long ll;
#define MAX 100005
#define SENTINEL 2000000000
#define NIL -1

struct Node { int p,l,r;};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout <<"node " << u <<": ";
  cout <<"parent = " << T[u].p<<", ";
  cout <<"depth = " << D[u] << ", ";
  
  if(T[u].p == NIL) cout << "root, ";
  else if(T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";
  
  cout <<"[";
  for(i=0,c = T[u].l;c != NIL;i++,c = T[c].r){
    if(i) cout <<", ";
    cout << c;
  }
  
  cout << "]" << endl;
}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r !=NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main(){
  int v,d,c,r,l;
  cin >> n;
  rep(i,n) T[i].p = T[i].l = T[i].r = NIL;
  
  rep(i,n){
    cin >> v >> d;
    rep(j,d){
      cin >> c;
      T[c].p = v;
      if(j==0) T[v].l = c;
      else T[l].r = c;
      l = c;
    }
  }
  
  rep(i,n){
    if(T[i].p==NIL) r=i;
  }
  
  rec(r,0);
  
  rep(i,n) print(i);
  
  return 0;
}
                                        
  
  
  
     






Measured memory_bytes: 7652
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;

    bool result = (a < b) && (b < c);

    if (result) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }


    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	string S;
	cin >> S;
	ll a=0;
	ll sum = 0;
	for (int i = 0; i < S.size(); i++) {

		if (S[i] == 'W') {

			sum += i - a;
			a++;
		}

	}
	cout << sum;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
int X, Y;

void input() {
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
}
void solve() {
  int ans = 0;
  rep(i, 1, N) {
    if (i <= K) {
      ans += X;
    } else {
      ans += Y;
    }
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int W,a,b;
  cin >> W >> a >> b;
  if (a > b) {
    int temp = a;
    a = b;
    b = temp;
  }
  int ans = b - W - a;
  if (ans > 0) cout << ans << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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;
}

int main()
{
  INT(N);
  vector<P> A(N);
  REP(i,N) cin >> A[i].first >> A[i].second;
  ll x = A[0].fi;
  ll y = A[0].se;
  FOR(i,1,N){
    ll k=1;
    if(x<=A[i].fi&&y<=A[i].se){
    }else if(x>A[i].fi&&y<=A[i].se){
      k=(x+(A[i].fi-1))/A[i].fi;
    }else if(x<=A[i].fi&&y>A[i].se){
      k=(y+(A[i].se-1))/A[i].se;
    }else{
      k=max((x+(A[i].fi-1))/A[i].fi,(y+(A[i].se-1))/A[i].se);
    }
    x=A[i].fi*k;
    y=A[i].se*k;
  }
  cout << x+y << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int n,x;
    int c = 0,s = 0;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        for(int i = 1;i<n-1;i++){
            for(int j = i+1;j<n;j++){
                for(int k = j+1;k<=n;k++){
                    s = i + j +k;
                    if(s == x){
                        c++;
                    }
                }
            }
        }
        cout << c << endl;
        c = 0;
    }
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI i;cin>>i;
      cout<<i+(i*i)+(i*i*i);
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string str;
  cin>>str;
  if(str.at(0)==str.at(1) && str.at(1)==str.at(2)){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

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

using namespace std;
const int Max_N(2050);

int N, Ans, Lst[Max_N], Nxt[Max_N];
char A[Max_N], B[Max_N];

bool all_0(char S[Max_N])
{
	for (int i = 1;i <= N;++i)
		if (S[i] != '0')
			return false;
	return true;
}

struct node
{
	int x, y;
	void give(int _x, int _y)
	{
		x = _x, y = _y;
	}
	inline bool operator<(const node &b) const
	{
		return x < b.x;
	}
};
int M, Suf[Max_N];
node V[Max_N];

int work()
{
	if (M == 0)
		return 0;
	sort(V + 1, V + 1 + M);
	Suf[M + 1] = 0;
	for (int i = M;i >= 1;--i)
		Suf[i] = max(Suf[i + 1], V[i].y);
	int Ans(min(V[M].x, Suf[1]));
	for (int i = 1;i <= M - 1;++i)
		Ans = min(Ans, V[i].x + Suf[i + 1]);
	return Ans;
}

int main()
{
	scanf("%s", A + 1), N = strlen(A + 1);
	scanf("%s", B + 1);
	if (all_0(B))
	{
		printf("%d", all_0(A) ? 0 : -1);
		return 0;
	}
	for (int s = 1;s <= N;++s)
		if (B[s] == '1')
		{
			for (int i = s;i <= N;++i)
				Lst[i] = (B[i] == '1' ? 0 : Lst[i - 1] + 1);
			Lst[0] = Lst[N];
			for (int i = 1;i <= s - 1;++i)
				Lst[i] = (B[i] == '1' ? 0 : Lst[i - 1] + 1);
			for (int i = s;i >= 1;--i)
				Nxt[i] = (B[i] == '1' ? 0 : Nxt[i + 1] + 1);
			Nxt[N + 1] = Nxt[1];
			for (int i = N;i >= s + 1;--i)
				Nxt[i] = (B[i] == '1' ? 0 : Nxt[i + 1] + 1);
			break;
		}
	Ans = 0X3F3F3F3F;
	for (int l = 0;l <= N - 1;++l)
	{
		M = 0;
		for (int i = 1, j;i <= N;++i)
		{
			j = i - l;
			if (j <= 0)
				j += N;
			if (A[i] != B[j])
				V[++M].give(max(Lst[i] - l, 0), Nxt[i]);
		}
		Ans = min(Ans, l + work() * 2 + M);
	}
	for (int r = 1;r <= N - 1;++r)
	{
		M = 0;
		for (int i = 1, j;i <= N;++i)
		{
			j = i + r;
			if (j > N)
				j -= N;
			if (A[i] != B[j])
				V[++M].give(max(Nxt[i] - r, 0), Lst[i]);
		}
		Ans = min(Ans, r + work() * 2 + M);
	}
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
  long long A, V;
  cin >> A >> V;
  long long B, W;
  cin >> B >> W;
  long long T;
  cin >> T;
  if(V <= W) cout << "NO" << endl;
  else{
    if(abs(B - A) <= abs(V -W) * T)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 3508
#include<stdio.h>
int main(void)
{
	int h,m,s,x,S;
	scanf("%d",&S);
	h=S/3600;
	x=S%3600;
	m=x/60;
	s=x%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

	


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

using namespace std;

int freq[26];

int main() {
	string s;
	while (cin >> s) {
		for (auto c: s) {
			if (c >= 'a' && c <= 'z') {
				freq[c - 'a']++;
			} else if (c >= 'A' && c <= 'Z') {
				freq[c - 'A']++;
			}
		}
	}
	for (int i = 0; i < 26; ++i) {
		cout << static_cast<char>(i + 'a') << " : " << freq[i] << '\n';
	}
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  long long ans, x, y, a, b, c, d;
  cin >> a >> b;
  x = max(a, b);
  cin >> c >> d;
  ans = max(a * c, max(a * d, max(b * c, b * d)));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int n,val,sum,ans;
it Calc(int p){return n*p*p-2*sum*p;}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i){
		read(val),sum+=val;
		ans+=val*val;
	}
	print(ans+min(min(Calc(sum/n),Calc(sum/n+1)),Calc(sum/n-1)));
	return 0;
}

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

int main(void) {
  
  int n;
  int alice, bob;
  cin >> n;
  vector<int> vec(n);

  for (int i = 0; i < vec.size(); i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int i = 0; i < vec.size(); i++) {
    alice += vec.at(i);
    i++;
  }

  for (int i = 1; i < vec.size(); i++) {
    bob += vec.at(i);
    i++;
  }

  cout << alice - bob << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main()
{
	vector<vector<int>> node(4, vector<int>(2));
	rep(i,2){
		rep(j,2){
			cin >>node.at(i).at(j);
		}
	}

	int vec1 = node.at(1).at(0)-node.at(0).at(0);
	int vec2 = node.at(1).at(1)-node.at(0).at(1);

	for(int i=2; i<4; i++){
		swap(vec1,vec2);
		vec1 *= -1;
		node.at(i).at(0) = node.at(i-1).at(0)+vec1;
		node.at(i).at(1) = node.at(i-1).at(1)+vec2;
	}

	for(int i=2; i<4; i++){
		cout <<node.at(i).at(0) <<" " <<node.at(i).at(1) <<" ";
	}
	cout <<endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	long long l[87] = {2, 1};
	for(int i = 2; i < 87; i++) l[i] = l[i - 1] + l[i - 2];
	int n; scanf("%d", &n);
	printf("%lld\n", l[n]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{  
  vector<int > v;
    int n,l,sum=0,min=32000;
     int i,ans;
    scanf("%d%d",&n,&l);
    for(i=1;i<=n;++i)
    {
       v.push_back(l+i-1);
    }
   
  sort(v.begin(),v.end());
    for(i=0;i<v.size();++i)
         sum+=v[i];
  
   for(i=0;i<v.size();++i)
   {
     if(min>abs(sum-(sum-v[i])))
     {
        min=abs(sum-(sum-v[i]));
        ans=sum-v[i];
     }
     
   }
  
  printf("%d",ans);
   
}

Measured memory_bytes: 256
N = gets.to_i
S = []
gets.each_char {|ch| S << ch }
ans = 0

for former in 0..N-2
	anstemp = 0

	S1 = S[0..former].uniq
	S2 = S[former+1..N-1].uniq

	for check in 0..former
		if S2.include?(S1[check])
		    anstemp += 1
		end
	end

	ans = [ans,anstemp].max 
end

print ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int mxn = 1e5;
int cnt[mxn+10] , ar[mxn+10];
int n;
int main()
{
    cin>>n;
    int tot_cnt = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>ar[i];
        if(ar[i] > mxn) tot_cnt++;
        else cnt[ar[i]]++;
    }
    for(int i = 1; i <= mxn; i++)
    {
        if(i==cnt[i]) continue;
        if(cnt[i] >= i)
        tot_cnt += (cnt[i]-i);
        else tot_cnt += cnt[i];
    }
    cout<<tot_cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
m = int(input())
s = input().rstrip()
def zalgo(s):
  n = len(s)
  lcp = [0]*n
  lcp[0] = n
  i = 1
  j = 0
  while i < n:
    while i+j < n and s[j] == s[i+j]:
      j += 1
    lcp[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i+k < n and k+lcp[k] < j:
      lcp[i+k] = lcp[k]
      k += 1
    i += k
    j -= k
  return lcp
ans = 0
for i in range(m):
  ss = s[i:]
  lcp = zalgo(ss)
  ans = max([ans]+[min(lcp[j],j) for j in range(m-i)])
print(ans)

Measured memory_bytes: 55516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,x,t;
  cin >> n >> x >> t;
  cout << ((n-1) / x + 1) * t << endl;
}

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

using namespace std;
using llint = long long;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

int n;
vector<int> l;


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

    l.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> l.at(i);
    }

    // Solve
    sort(l.begin(), l.end(), greater<int>());

    int lm = l.at(0);
    int sum = 0;

    for (int i = 1; i < n; ++i) {
        sum += l.at(i);
    }

    // Output
    if (sum > lm)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (H, W) = Slice2<long>();
            var ban = new string[H];
            var ryH = new bool[H];
            var ryW = new bool[W];
            for (var i = 0; i < H; ++i)
                ban[i] = ReadLine();
            for (var h = 0; h < H; ++h)
            {
                for (var w = 0; w < W; ++w)
                    if (ban[h][w] != '.')
                        ryH[h] = true;
            }
            for (var w = 0; w < W; ++w)
                for (var h = 0; h < H; ++h)
                    if (ban[h][w] != '.')
                        ryW[w] = true;
            var str = new StringBuilder();
            for (var i = 0; i < H; ++i)
            {
                for (var j = 0; j < W; ++j)
                    if (ryH[i] && ryW[j])
                        str.Append(ban[i][j]);
                str.Append("\n");
            }
            str.Replace("\n\n", "\n");
            if (str[0] == '\n') str.Remove(0, 1);
            WriteLine(str);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int r; cin >> r;
    cout << 3 * r * r;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

struct UnionFind{
private:
    std::vector<int> par;
    std::vector<int> siz;
public:
    UnionFind(int size){
        par=std::vector<int>(size);
        siz=std::vector<int>(size);
        for(int i=0;i<size;++i){
            par[i]=i;
            siz[i]=1;
        }
    }

    int root(int x){
        if(par[x]==x)return x;
        else {
            par[x]=root(par[x]);
            return par[x];
        }
    }

    bool same(int x,int y){//0-indexed
        return root(x)==root(y);
    }

    void unite(int x,int y){//0-indexed
        x=root(x);
        y=root(y);
        if(x==y)return;

        if(siz[x]<siz[y]){
            par[x]=y;
            siz[y]+=siz[x];
        }
        else{
            par[y]=x;
            siz[x]+=siz[y];
        }
    }

    int component_size(int x){
        return siz[root(x)];
    }
};

int main(){
    int n,m;
    std::cin>>n>>m;
    std::vector<std::vector<int>> l(m);
    for(int i = 0; i < n; ++i){
        int k;
        std::cin>>k;
        for(int j = 0; j < k; ++j){
            int t;
            std::cin>>t;
            --t;
            l[t].push_back(i);
        }
    }
    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        if(l[i].size()==0)continue;
        int x=l[i][0];
        for(int j = 1; j < l[i].size(); ++j){
            uf.unite(x,l[i][j]);
        }
    }
    if(uf.component_size(0)==n)std::cout<<"YES"<<std::endl;
    else std::cout<<"NO"<<std::endl;
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define ll long long
#define lld long double

#define rep(i, a, b) for (int i = a; i < b; i++)
#define For(i, a, b) for (int i = a; i <= b; i++)

using namespace std;

const int mod = 1000000000 + 7;
const int MAXN = 100000 + 5;

int n;
double sum;
int temp;

int main(){
    scanf("%d", &n);
    while (n--){
        scanf("%d", &temp);
        sum += 1.0 / (double) temp;
    }
    printf("%f", 1.0 / sum);
}

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

int main()
{
    char s[4];
    scanf("%s", s);
    if ((s[0] == s[1] && s[0] != s[2] && s[2] == s[3]) ||
        (s[1] == s[2] && s[1] != s[3] && s[3] == s[0]) ||
        (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");

        if (n[0].equals(n[2])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  for(int n; cin >> n && n; ) {
    int size = 0;
    vector<string> s(n);
    for(int i = 0; i < n; ++i) {
      cin >> s[i];
      size = max(size, (int)s[i].size());
    }
    for(int i = 0; i < n; ++i) {
      s[i].resize(size, ' ');
    }

    for(int i = 0; i < n; ++i) {
      for(int j = 0; j+1 < s[i].size(); ++j) {
        if(s[i][j] == '.' && s[i][j+1] != '.') {
          s[i][j] = '+';
          break;
        }
      }
    }
    for(int j = 0; j < size; ++j) {
      for(int i = 0, k = n; i < n; ++i) {
        if(s[i][j] == '+') {
          for(int l = i-1; l > k; --l) {
            s[l][j] = '|';
          }
          k = i;
        } else if(s[i][j] != '.') {
          k = n;
        }
      }
    }
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < size; ++j) {
        if(s[i][j] == ' ') break;
        if(s[i][j] == '.') cout << " ";
        else cout << s[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

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


int main(){
string s,t;
cin >> s >> t;
int len = (int) t.length();
int n = (int) s.length();
bool f=0;
int maxcnt = 0,max_so_far = 0;
 for(int i = 0;i < n;  i++){
    maxcnt = 0; 
    int k = 0;
    for(int j = i;j <i+len ;j++){
       if(i+len-1>=n){
        f = 1;
        break;
       }
       if(s[j] == t[k]) maxcnt++;
       if(maxcnt > max_so_far) max_so_far = maxcnt;
       //max_so_far = max(maxcnt,max_so_far);
       k++;
    }
   if(f) break;
}
cout << abs(max_so_far-len);
return 0;
}


Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vp = vector<Pii>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

  int x, a;
  cin >> x >> a;
  cout << (x < a ? 0 : 10) << endl;

}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  int n;
  cin >> n;
  int k = -1;
  for (int j = 1; j*j <= 1 + 8 *n; j++) {
    if (j * j == 1 + 8 * n) {
      k = (1 + j) / 2;
      break;
    }
  }
  if (k == -1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << k << endl;
  vi num(n);
  rep (i, k) {
    cout << k - 1 << " ";
    int cnt = 0;
    int pre = -1;
    vi a;
    rep (j, n) {
      if (a.size() == k - 1) {
        break;
      }
      if (num[j] == 0) {
        num[j] = i + 1;
        a.push_back(j + 1);
      }
      else if (num[j] > 0) {
        if (num[j] != pre) {
          pre = num[j];
          num[j] = -1;
          a.push_back(j + 1);
        }
      }
    }
    rep (i, k - 1) {
      cout << a[i];
      if (i == k - 2) {
        cout << endl;
      }
      else {
        cout << " ";
      }
    }
  }
}
  


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S;
    cin >> S;
    int n = S.size();
    for (int i = n / 2 - 1; i > 0; i--) {
        bool f = true;
        rep(j, i) {
            if (S[j] != S[i + j]) f = false;
        }
        if (f) {
            cout << i * 2 << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }

  double total_vote = accumulate(A.begin(), A.end(), 0);
  double threshold = total_vote/(4*M);

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  if (A[M-1] >= threshold) printf("Yes\n");
  else printf("No\n");

}


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


public class B
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());		
		string[] args = Console.ReadLine().Split(' ');
		int flag = 0;
		for(int i = 0; i < N; i++)
		{
			switch(args[i][0])
			{
				case 'P':
					flag |= 1;
					break;
				
				case 'W':
					flag |= (1 << 1);
					break;

				case 'G':
					flag |= (1 << 2);
					break;

				case 'Y':
					flag |= (1 << 3);
					break;

				default:
					throw new Exception();
			}
		}

		Console.WriteLine((flag == 15) ? "Four" : "Three");
	}
}





Measured memory_bytes: 11092
def resolve():
  s = input()
  for i in range(1<<3):
    e = s[0]
    e += '+' if ((i>>0) & 1) else '-'
    e += s[1]
    e += '+' if ((i>>1) & 1) else '-'
    e += s[2]
    e += '+' if ((i>>2) & 1) else '-'
    e += s[3]
    if eval(e) == 7:
      e += '=7'
      print(e)
      return
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s.size()==3)REV(s);
	cout << s << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll cnt = K;

    // A
    ll ans = min(A, cnt);
    cnt -= min(A, cnt);

    // B
    if (cnt > 0) {
        cnt = max(0LL, cnt - B);
    }

    // C
    ans -= cnt;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){

int N;
cin>>N;

for(int i=1;i<=9;i++){
    for(int k=1;k<=9;k++){
    if(i*k==N){
        cout<<"Yes";
        return 0;
    }
    }
}
cout<<"No";
 return 0;
}
/*
10

Yes

50

No

81

Yes
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100009
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;
ll dp[409][409];
ll s[409][409];
int a[409];
ll fun(int i,int j){
    // tr2(i,j);
    if(i==j){return 0;}
    if(abs(i-j)==1){return a[i]+a[j];}
    if(dp[i][j]){return dp[i][j];}
    ll x=1000000000000000;
    for(int k=i; k<j; k++){
        // tr3(i,k,j);
        x=min(x,fun(i,k)+fun(k+1,j)+s[i][j]);
    }
    dp[i][j]=x;
    return x;
}
int main(){
    int i,j,n,m,t,k,x,y;
    sd(n);
    for(i=0; i<n; i++){sd(a[i]);}
    for(i=0; i<n; i++){
        s[i][i]=a[i];
        for(j=i+1; j<n; j++){
            s[i][j]=s[i][j-1]+a[j];
        }
    }
    ll ans = fun(0,n-1);
    tr(ans);
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int main(){

    long long N, P; cin >> N >> P;

    vector <long long> cnt;
    long long num = P;
    for (long long i = 2; i * i <= P; i++){
        while(num % i == 0){
            cnt.push_back(i);
            num = num / i;
        }
    }
    if (num != 1) cnt.push_back(num);
    cnt.push_back(0);

    long long count = 1, ans = 1;
    for (int i = 1; i < cnt.size(); i++){
        if (cnt[i] == cnt[i - 1]){
            count ++;
        }else{
            if (count >= N){
                long long T = count / N;
                for (long long j = 0; j < T; j++){
                    ans = ans * cnt[i - 1];
                }
            }
            count = 1;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Multiple of 2019
 */

#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>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int M = 2019;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int rs[M];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  rs[0]++;
  for (int i = n - 1, r = 0, t = 1; i >= 0; i--) {
    r = ((s[i] - '0') * t + r) % M;
    t = t * 10 % M;
    rs[r]++;
  }

  ll sum = 0;
  for (int i = 0; i < M; i++) {
    sum += (ll)rs[i] * (rs[i] - 1) / 2;
    //if (rs[i] > 0) printf("%d %d\n", i, rs[i]);
  }

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


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

int z(int n) {
    return (1LL << (n + 1)) - 3;
}
int p(int n) {
    return (1LL << n) - 1;
}

int ans(int n, int x) {
    if(x <= 0) return 0;
    if(n == 1) return 1;
    if((x - 1) < z(n - 1)) return ans(n - 1, x - 1);
    return p(n - 1) + 1 * ((x - 1 - z(n - 1)) > 0) + ans(n - 1, x - 2 - z(n - 1));
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x;
    cin >> n >> x;
    ++n;
    cout << ans(n, x) << endl;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    int fst = B[0], sec = B[1];
    for (int i = 0; i < N; ++i) {
        if (A[i] == fst)
            cout << sec << endl;
        else
            cout << fst << endl;
    }
    return 0;
}

Measured memory_bytes: 4464
#include <iostream>
#include <cmath>
#include <valarray>
#include <vector>
#include <utility>

using namespace std;


int N, M, Z;
int h;


struct Matrix
{
	valarray<int> a;
	Matrix() : a(h*h){ a=0;}
};

Matrix mult(const Matrix A, const Matrix B){
	Matrix C;
	for (int i = 0; i < h ; ++i)
	{
		for(int j = 0; j < h; ++j)
		{
			C.a[i*h+j] =( A.a[slice(i*h,h,1)]  * B.a[slice(j,h,h)] ).sum();
		}
	}
	return C;
};

Matrix expt(Matrix A, long long p)
{
	if (p == 1) return A;
	else if ( p % 2 != 0){  
		Matrix T = expt(A, p-1); 
		return mult(A,T);
	}else{
		Matrix T = expt(A, p/2);
		return mult(T, T);
	}
};

int main()
{
	while(cin>>N>>M>>Z, N)
	{
		int s, d;
		vector< pair<int,int> > v;
		v.push_back(make_pair(1,1));
		for(int i = 0; i < M; ++i)
		{
			cin>>s>>d;
			v.push_back(make_pair(s,d));
			v.push_back(make_pair(d,s));
		}
		h = 2 * M + 1; 
		Matrix A;
		for( int i = 0; i < h; ++i)
		{
			for(int j = 1; j < h; ++j)
			{
				if(v[i].first != v[j].second && v[i].second==v[j].first && i != j)
				{ 
					 A.a[i*h+j] = 1;
				}

			}

		}
		A = expt(A,Z);
		bool fg=false;
		for(int i = 0; i < h; i++)
		{
			if(v[i].second == N && A.a[i])
			{
				fg = true;
			}
		}
		cout << (fg?"yes":"no") << endl;
	}
	return 0;
}
 

 

Measured memory_bytes: 5432
#include<bits/stdc++.h>
using namespace std;
const int N=200010,M=8000,MOD=1000000007,inv=500000004;
int fac[M+10],ifac[M+10],f[M/2+10][M/2+10],base=M/4+2,A[N],B[N];
inline int Power(int a,int b)
{
    register int ans=1;
    for(;b;b>>=1,a=1ll*a*a%MOD)
        if(b&1)
			ans=1ll*ans*a%MOD;
    return ans;
}
inline int C(int n,int m)
{
	return 1ll*fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;
}
int main()
{
    fac[0]=1;
    for(register int i=1;i<=M;++i)
        fac[i]=1ll*fac[i-1]*i%MOD;
    ifac[M]=Power(fac[M],MOD-2);
    for(register int i=M-1;i>=0;--i)
        ifac[i]=1ll*ifac[i+1]*(i+1)%MOD;
	register int n;
	scanf("%d",&n);
    for(register int i=1;i<=n;++i)
        scanf("%d%d",&A[i],&B[i]),++f[base-A[i]][base-B[i]];
    for(register int i=1;i<=M/2+2;++i)
        for(register int j=1;j<=M/2+2;++j)
            f[i][j]=(f[i][j]+(f[i-1][j]+f[i][j-1])%MOD)%MOD;
    register int ans=0;
    for(register int i=1;i<=n;++i)
        ans=(ans+f[A[i]+base][B[i]+base])%MOD,ans=(ans-C(2*A[i]+2*B[i],2*A[i])+MOD)%MOD;
    ans=1ll*inv*ans%MOD;
    return cout<<ans<<endl,0;
}

Measured memory_bytes: 64512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,ans=0;
    cin >> n;
    ll b[n];
    for (ll i=0;i<n-1;i++)cin >> b[i];
    b[n-1]=b[n-2];
    ans+=b[0];
    for (ll i=0;i<n-1;i++){
        ans+=min(b[i],b[i+1]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  cout<<fixed<<setprecision(12);
  int N,K;cin>>N>>K;
  vector<double> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  //vector<double> ans(N-K+1);
  priority_queue<double> ans;
  double X=0;
  for(int i=0;i<K;i++) X+=(A.at(i)+1.0)/2;
  ans.push(X);
  for(int i=1;i<N-K+1;i++){
    X-=(A.at(i-1)+1.0)/2;
    X+=(A.at(i+K-1)+1.0)/2;
    ans.push(X);
  }
  cout<<ans.top()<<endl;
}
  
  
  


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

int main(){

    int n;
    cin>>n;
    string s;
    cin>>s;
    deque<int> r,w;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r.push_front(i);
        }else{
            w.push_front(i);
        }
    }
    int cnt=0;
    while(!w.empty() && !r.empty()){
        //cout<<w.back()<<" "<<r.front()<<endl;
        if((w.back()>r.front()))break;
        w.pop_back();
        r.pop_front();
        cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 4404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char S[3][1024];

int main() {
  int N = in();
  for (int i = 0; i < 3; ++i) {
    scanf("%s", S[i]);
  }

  int res = 0;
  for (int i = 0; i < N; ++i) {
    int sm = 0;
    for (int a = 0; a < 3; ++a) {
      for (int b = a + 1; b < 3; ++b) {
        if (S[a][i] == S[b][i]) {
          ++sm;
        }
      }
    }
    if (sm == 0) {
      res += 2;
    } else if (sm == 1) {
      res += 1;
    }
  }

  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.next();
      for(char s='a'; s<='z'; s++){
        if(!(str.contains(s+""))){
          System.out.println(s);
          return;
        }
      }
      System.out.println("None");
    }
}

Measured memory_bytes: 25064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rrep(i, n) for(int i = (int)(n) - 1; i >= 0; i --)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define mod2 998244353
#define inf 1000000000000000000
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rsort(a) sort(a.rbegin(), a.rend())
#define print(x) for(auto i : (x)) cout << i << " "; cout << endl
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans_1 = a * x + b * y;
    ll ans_2 = inf;
    if (a + b > 2*c) {
        ll p = min(x, y), res = 0;
        x -= p;
        y -= p;
        res += 2 * c * p;
        res += min(a, 2 * c) * x + min(b, 2 * c) * y;
        chmin(ans_2, res);
    }
    cout << min(ans_1, ans_2) << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[200][200], rui[200][200];
signed main(){
  int n;
  scanf("%lld", &n);
  rrep(i,n)rrep(j,n)scanf("%lld", &a[i][j]);
  rrep(i,n)rrep(j,n)rui[i][j] = rui[i-1][j]+a[i][j];
  int ans = -INF;
  rrep(i,n)rrep(j,n){
    if(i > j)continue;
    int t = 0;
    rrep(k,n){
      if(t < 0)t = rui[j][k]-rui[i-1][k];
      else t += rui[j][k]-rui[i-1][k];
      chmax(ans, t);
    }
  }
  cout << ans << endl;
	return 0;
}











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

const int MAXN = 112345;
const int INF = 1e9;

int h[MAXN], dp[MAXN];

int solve (int n) {

    if(n == 0) return 0;
    if(dp[n] != INF) return dp[n];

    for(int i = 1; i <= 2; i++) {
        if(n-i >= 0)
            dp[n] = min(dp[n], solve(n-i) + abs(h[n] - h[n-i]));
    }

    return dp[n];
}

void imprime(int n) {

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

int main() {

    for(int i = 0; i < MAXN; i++)
        dp[i] = INF;
    dp[0] = 0;

    int n;
    scanf("%d", &n);

    //imprime(n);

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

    cout << solve(n-1) << endl;

    //imprime(n);

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1e+9;
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,k;
    cin>>n>>k;
    vector<int> vec(n);
    for(int& i: vec){
        cin>>i;
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j = i+1; j<=i+k;j++){
            if(j<n){
                dp[j] = min(dp[j] , dp[i] + abs(vec[i] - vec[j]));
            }
        }
    }

    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 3988