akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(8);
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  Vi ans(0);
  rep(i,0,n){
    repreq(j,a.size()-1,0){
      if(j+1==a[j]) {
        ans.pb(j+1);
        a.erase(a.begin()+j);
        break;
      }
      if(j==0){cout<<-1<<endl;return 0;}
    }
  }
  reverse(ALL(ans));
  rep(i,0,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a+b==c+d)
cout<<"Balanced";
else if(a+b>c+d)
cout<<"Left";
else cout<<"Right";
return 0;
}
 


Measured memory_bytes: 256
N = int(input())
T, A = (int(i) for i in input().split())
H = (int(i) for i in input().split())

def t(h):
    return T - h * 0.006

l = [abs(A - t(h)) for h in H]

a = min(l)

cnt = 1
for x in l:
    if a == x:
        print(cnt)
    else:
        cnt += 1


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))

sunuke = [0] * (N)
guma = [0] * (N)

for i in range(N-1):
  if i == 0:
    sunuke[i] += A[i]
    continue  
  sunuke[i] += sunuke[i-1] + A[i]

for j in range(N-1,0,-1):
  if j == N - 1:
    guma[j] += A[j]
    continue
  guma[j] += guma[j+1] + A[j]
  
ans = float("inf")
for k in range(N-1):
  ans = min(ans, abs(sunuke[k] - guma[k+1]))

print(ans)

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

int main()
{
	int a[3],i,j;
	for(i=0;i<3;i++)
		cin>>a[i];
	int k;
	cin>>k;
	for(i=0;i<3;i++)
		for(j=i+1;j<3;j++)
		{
			if(a[j]>a[i])
			{
				int temp;
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	for(i=0;i<k;i++)
	{
		a[0]*=2;
	}
	cout<<a[0]+a[1]+a[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
/* ex4_1
   YSK722 */

#include <math.h>
#include <stdio.h>

int main(void){
    double short_hand, long_hand, hour, minute, ans, angle_diff;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
    // 短針と長針のか鵜戸の差を求める
    angle_diff = 2 * M_PI * ((hour + minute/60.0) / 12 - minute / 60);
    /* 余弦定理を用いる
       cos(-x) = cos(x)より、回転角の大小は考えない */
    ans = sqrt(
              pow(short_hand, 2) + pow(long_hand, 2) \
              - 2 * short_hand * long_hand * cos(angle_diff)
          );
    printf("%.9lf\n", ans);
    return 0;
}

Measured memory_bytes: 2472
float a,b,c,d,p=57.2957795;
float A,B,C,D,E,F;
main(){
	for(;scanf("%f%f%f%f",&a,&b,&c,&d),a+1;){
		a/=p;
		b/=p;
		c/=p;
		d/=p;
		A=cos(a)*cos(b);
		B=cos(a)*sin(b);
		C=sin(a);
		D=cos(c)*cos(d);
		E=cos(c)*sin(d);
		F=sin(c);
		printf("%.0f\n",6378.1*acos(A*D+B*E+C*F));
	}
	exit(0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {


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

		int N = sc.nextInt();

		String stringN = Integer.toString(N);
		if(stringN.contains("7")) {
			System.out.println("Yes");
			}
		else if(!stringN.contains("7")) {
			System.out.println("No");
		}

}
}


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

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int ans=0;
    rep(i,n){
        int a;
        cin>>a;
        ans+=(d-1)/a;
    }
    cout<<ans+x+n<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int n,m,sum,s[1111111];
bool cmp(int cl,int cr) {return cl>cr;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	sort(s+1,s+1+n,cmp);
	for(int i=1;i<=m;i++) sum+=s[i];
	printf("%d\n",sum); 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 8223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct edge { int to, cost; };
int N;
vector<vector<edge> > G;
VI d;

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, N)d[i] = LLINF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		
		if (d[v] < p.first)continue;
		

		REP(i, G[v].size()) {
			edge e = G[v][i];
			//cout << v << " " << e.to << " " << d[e.to] << endl;
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

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

	int M, S, T; cin >> N >> M >> S >> T;
	int n = N;
	VI ans(N);
	S--; T--;
	N *= 2;
	G.resize(N);
	d.resize(N);
	REP(i, M) {
		int v, u, a, b; cin >> u >> v >> a >> b;
		u--; v--;
		G[2 * u].push_back((edge) { 2 * v, a });
		G[2 * v].push_back((edge) { 2 * u, a });
		G[2 * u + 1].push_back((edge) { 2 * v + 1, b });
		G[2 * v + 1].push_back((edge) { 2 * u + 1, b });
		
	}
	//G[2 * (n - 1)].push_back((edge) { 2 * (n - 1) + 1, 0 });
	//G[2 * (n - 1) +	1].push_back((edge) { 2 * (n - 1), 0 });
	dikstra(2 * T + 1);
	VI dd = d;
	dikstra(2 * S);
	int mi = LLINF;
	for (int i = n - 1; i >= 0; i--) {

		chmin(mi, d[2 * i] + dd[2 * i + 1]);
		ans[i] = mi;


	}
	

	fore(i, ans)cout << 1000000000000000LL - i << endl;
	return 0;
}



Measured memory_bytes: 20604
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

ll a;
//double b;
char b[5];

int main(){
  scanf("%lld%s",&a,b);

  ll tmp=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
  //printf("%lld\n",tmp);
  ll ans=a*tmp/100;
  printf("%lld\n",ans);
  
  return 0;
}


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

const int mod = 1e9 + 7;

inline int add(int x, int y)
{
	return (0LL + x + y)%mod;
}

class Solution
{
public:
	int n;
	vector<vector<int>> memo;
	vector<vector<bool>> compatible;
public:
	int recurse(int i, int mask);
};

int Solution :: recurse(int i, int mask)
{
	if(i < 0)
		return (mask == 0);
	
	if(memo[i][mask] != -1)
		return memo[i][mask];

	int res = 0;
	for(int j = 0; j < n; j++)
		if(compatible[i][j] and (mask & (1 << j)) )
			res = add(res, recurse(i-1, mask xor (1 << j)));

	memo[i][mask] = res;
	return res;
}

void Matching(vector<vector<bool>> &compatible)
{
	int n = compatible.size();

	// Biggest mask happens when all the women are available
	int biggest_mask = ( 1 << n) - 1;

	Solution sol;
	sol.n = n;
	sol.compatible = compatible;
	sol.memo.resize(n, vector<int>(biggest_mask + 1, -1));

	cout << sol.recurse(n-1, biggest_mask) << endl;
	return;
}

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

	vector<vector<bool>> compatible(n, vector<bool>(n, false));

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			int val;
			cin >> val;

			compatible[i][j] = ( val == 1);
		}
	}

	Matching(compatible);
	return 0;
}



Measured memory_bytes: 180608
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=999999999999999999;
int n,id;
ll a[101010],f[101010],T,E;
int main()
{
	scanf("%d%lld%lld",&n,&E,&T);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for (int i=1;i<=n;++i) f[i]=inf;
	ll minn=inf;
	for (int i=1;i<=n;++i)
	{
		while (T<=2*(a[i]-a[id+1]))
			minn=min(minn,f[id]-2*a[id+1]),++id;
		f[i]=min(f[id]+T,2*a[i]+minn);
	}
	printf("%lld\n",E+f[n]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    vector<char>c={'A','B','C','D','E','F'};
    char x,y;cin>>x>>y;
    int X,Y;
    rep(i,6){
        if(x==c.at(i)){
            X=i;
        }
        if(y==c.at(i)){
            Y=i;
        }
    }
    if(X<Y){
        cout<<"<"<<endl;
    }else if (X==Y){
        cout<<"="<<endl;
    }else{
        cout<<">"<<endl;
    }
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int (i) = (a); (i) <= (n); (i)++)
using namespace std;
typedef pair<long, int> PAIR;

const int SIZE = 100001;
int N;
PAIR A[SIZE];

int main(void) {
  cin >> N;
  REP(i, 1, N) {
    cin >> A[i].first;
    A[i].second = i;
  }

  sort(A + 1, A + N + 1);
  reverse(A + 1, A + N + 1);

  long ans[SIZE];
  REP(i, 1, N) ans[i] = 0;

  int m = SIZE;
  REP(i, 1, N) {
    long diff = i != N ? A[i].first - A[i + 1].first : A[i].first;
    m = min(m, A[i].second);
    ans[m] += i * diff;
  }

  REP(i, 1, N) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 3456
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")
 
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on
 
int main() {
    fastio();

    int D = nxt(), T = nxt(), S = nxt();

    if (D % S == 0) {
        bool res = T >= (D / S);
        cout << (res ? "Yes" : "No") << endl;
    } else {
        bool res = T >= (D / S) + 1;
        cout << (res ? "Yes" : "No") << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
    if(n!=1) ord[n]++;
   return ord ;
 }
  
  int main() {
   ll a,b ;cin>>a>>b ;
   cout<<lcm(a,b)<<endl ;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a_lis = list(map(int, input().split()))
asum_mods = [0]
tmp_sum = 0
for i in range(n):
    tmp_sum += a_lis[i]
    asum_mods.append(tmp_sum % m)
import collections
c = collections.Counter(asum_mods).values()
ans = 0
for b in c:
    ans += b * (b - 1) // 2
print(ans)

Measured memory_bytes: 16556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int n;
	cin >> n;
	vector<ll> a(3*n);
	for(int i=0;i<3*n;++i){cin >> a[i];}
	sort(a.begin(),a.end(),std::greater<ll>());
	ll res = 0;
	for(int i=0;i<n;++i){
		res += a[2*i+1];
	}
	cout << res << endl;
}

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

int gcd(int x,int y){
    int r = 0;
    if(x < y){
        swap(x,y);
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    
    return x;
}

int main(){
    int x,y = 0;
    cin >> x >> y;
    
    cout << gcd(x,y) << endl;
    
    return 0;
}

Measured memory_bytes: 3116
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 2e5;
std::vector<std::vector<int>> g;
int n;
ll a[N];
void dfs(int i, int p = -1) {
  for(auto j : g[i]) if(j != p) {
    a[j] += a[i];
    dfs(j, i);
  }
}
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int q;
  cin >> n;
  cin >> q;
  g.resize(n);
  for(int i = 0; i < n - 1; i++) {
    int a, b; std::cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  for(int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    a[p]+=x;
  }
  dfs(0, -1);
  for(int i = 0; i < n; i++) cout << a[i] << " \n"[i == n - 1];
  return 0;
}


Measured memory_bytes: 24320
def main():
    ans = 2019
    l, r = map(int, input().split())

    for i in range(l, r+1):
        for j in range(i+1, r+1):
            mod = i * j % 2019
            if mod == 0:
                return 0
            elif mod < ans:
                ans = mod

    return ans


print(main())


Measured memory_bytes: 2940
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
L = []
M = []
for i in range(len(A)):
  if (i % 2 == 0):
    L.append(A[i])
  else:
    M.append(A[i])
print(sum(L)-sum(M))

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author houghstc
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;

class ARainySeason {
public:
    void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        int best = 0, curr = 0;
        for(int i = 0; i < s.size(); ++i)
        {
            if(s[i] == 'R')
                curr++;
            else
            {
                best = max(best, curr);
                curr = 0;
            }
        }

        best = max(best, curr);
        out << best << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ARainySeason solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  a <- readInt
  b <- readInt 
  c <- readInt 
  x <- readInt 
  print $ selection' a b c x

selection
  :: Int -> Int -> Int -> Int -> Int
selection a b c x
  = length [(s,t,u) | s<-[0..a], t<-[0..b], u<-[0..c]
                    , 500*s + 100*t + 50*u == x]

selection' a b c x = sum [ g b c (x-500*s) | s <- [0 .. a]]
g b c x = sum [h c (x-100*t) | t <- [0 .. b]]
h c x 
  | x >= 0 && 50* c >= x = 1
  | otherwise            = 0

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

int main(){
  int n, k, sum=0;
  cin >> n >> k;
  
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    if(k-x < x){
      sum += (k-x)*2;
    }else{
      sum += x*2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    vector<int> a(s.size(),1);
    for(int i = 0;i < s.size()-1;i++){
        if(s[i] == 'R' && s[i+1] == 'R'){
            a[i+2] += a[i];
            a[i] = 0;
        }
    }

    for (int i = s.size(); i > 0; --i) {
        if(s[i] == 'L' && s[i-1] == 'L'){
            a[i-2] += a[i];
            a[i] = 0;
        }
    }
    for (int i = 0; i < s.size(); ++i) {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int mt[20][20];
int pr[20];
int n, m, x;
const int inf = 1e18;
int solve(){
	int ans = inf;
	for(int w=0; w<(1LL<<n); ++w){
		bool can = true;
		for(int j=0; j<m; ++j){
			ll skill = 0;
			for(int i=0; i<n; ++i){
				if(w&(1LL<<i))
					skill+=mt[i][j];
			}
			if(skill<x) can=false; 
		}
		if(can){
			int res = 0;
			for(int i=0; i<n; ++i)
				if(w&(1LL<<i))
					res+=pr[i];
			ans = min(ans, res);
		}
	}
	if(ans==inf) ans = -1;
	return ans;
}
int32_t main(){
	ios::sync_with_stdio(0);
	cin >> n >> m >> x;
	for(int i=0; i<n; ++i){
		cin >> pr[i];
		for(int j=0; j<m; ++j)
			cin >> mt[i][j];
	}
	cout << solve() << endl;

}


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

int main() {
  int a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    switch (op) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
      case '?':
        return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#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 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
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 x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    
    ll n,m;
    cin >> n >> m;
    cout << ((n*m %2 == 0)?"Even":"Odd") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std; 

const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n = nxt(), m = nxt();
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for (int i = 1; i < N; ++i) {
        A[i] = A[i] % A[0];
    }
    sort(A.begin(), A.end());
    for (int i = 1; i < N; ++i) {
        A[i] = __gcd(A[i - 1], A[i]);
    }
    cout << A[N - 1] << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll n,count=0;
	cin >> n;
	vector<ll>p(n);
	for (ll i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (ll i = 0; i < n; i++) {
		if (p[i] != i + 1) {
			count++;
		}
	}
	if (count == 0 || count == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int MAX_N = 100 + 2;
const int MAX_K = 100000 + 2;
int dp[MAX_K];
int a[MAX_N];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

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

  memset(dp, 0, sizeof(dp));
  dp[0] = -1;

  for (int k = 1; k <= K; k++) {

    int ans = 1;
    for (int i = 0; i < N; i++) {
      if (k - a[i] >= 0) {
	if (dp[k - a[i]] == -1) {
	  ans = -1;
	  break;
	}
      }
    }

    if (ans == -1) dp[k] = 1;
    else dp[k] = -1;
  }

  if (dp[K] == 1) cout << "First" << endl;
  else cout << "Second" << endl;
  
  return 0;
}


Measured memory_bytes: 3524
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <ll> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        a[i] += ans;
        int mem = b[i] - a[i] % b[i];
        mem %= b[i];
        ans += mem;
    }
    cout << ans << '\n';
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

int N;

ll f(ll x) {
    return x * (x+1) / 2;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    int cur = -1;
    FOR(i,1,N+1) {
        if (f(i-1) < N && N <= f(i) ) {
            cur = i;
            break;
        }
    }
    ll skip = f(cur) - N;
    REP(i,cur) {
        if(i+1==skip) continue;
        cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int n;
    cin >> n;
    for(ll i = 1; i <= 3500; i++){
        for(ll j = 1; j <= 3500; j++){
            if((4*i*j-(i+j)*n)>0 and (n*i*j)%(4*i*j-(i+j)*n)==0){
                cout << i << " " << j << " " <<(n*i*j)/(4*i*j-(i+j)*n) << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var r = int.Parse(line[0]);
            var c = int.Parse(line[1]);
            if (r == 0 && c == 0) break;
            Console.WriteLine(r % 2 == 0 || c % 2 == 0 ? "yes" : "no");
        }
    }
}



Measured memory_bytes: 15912
#include <iostream>
using namespace std;
bool prime[100000];
void init(){
  prime[0] = true;
  prime[1] = true;
  for(int i = 2; 100000 > i; i++){
    if(!prime[i]){
      for(int j = i+i; 100000 > j; j+=i)prime[j] = true;
    }
  }
}
bool lk[100000];
int rui[100000];
int main(){
  init();
  int q;cin>>q;
  for(int i = 1; 100000 > i; i+=2){
    if((!prime[i]) && (!prime[(i+1)/2]))lk[i] = true;
  }
  for(int i = 1; 100000 > i; i++){
    rui[i] = rui[i-1] + lk[i];
  }
  for(int i = 0; q > i; i++){
    int l,r;cin>>l>>r;
    cout << rui[r]-rui[l-1] << endl;
  }

}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> m;
    rep(i, n) {
        ll a;
        cin >> a;
        m[i] = a;
    }
    rep(i, n) {
        if(i == 0) {
            ans += (m[i]/2);
            m[i] %= 2;
        }
        else {
            // 前が残っている
            if(m[i-1] > 0 && m[i] > 0) {
                m[i]--;
                ans++;
            }
            ans += (m[i]/2);
            m[i] %= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a * b;

            if (c % 2 == 0)
                Console.WriteLine("Even");

            else
                Console.WriteLine("Odd");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <algorithm>
void Unused(...) {}
#ifndef DEBUG
  #define echo(...) Unused(__VA_ARGS__)
#else
  #define echo(...) fprintf(stderr, __VA_ARGS__)
#endif

typedef long long laolin;

int n;

int main()
{
    scanf("%d", &n);
    laolin ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i / 10 == 0 || (i / 100 != 0 && i / 1000 == 0) || (i / 10000 != 0 && i / 100000 == 0))
            ++ans;
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        static void Solve()
        {
            var n = ReadAndParseInt();
            var h = ReadAndParseIntArr();
            int[] dp = new int[n + 1];

            for(int i=1;i<n;++i)
            {
                int dpi_1 = int.MaxValue;
                if( i - 1 >= 0)
                {
                    dpi_1 = dp[i - 1] + Math.Abs(h[i] - h[i - 1]);
                }
                int dpi_2 = int.MaxValue;
                if( i - 2>= 0)
                {
                    dpi_2 = dp[i - 2] + Math.Abs(h[i] - h[i - 2]);
                }
                dp[i] = Math.Min(dpi_1, dpi_2);
            }
            int ans = dp[n - 1];
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 16864
#include <iostream>

using namespace std;

int main() {
    
    
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    
    long long n=min(a,k);
    if((k-a-b)>0)
    {
        n=n-min(c,k-a-b);
    }
    cout<<n<<endl;
    
    return 0;
}

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

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

    int a = 0, b = 0;
    rep(i, S.size()) {
        if (S[i] == 'A')
            a++;
        else
            b++;
    }

    if (a >= 1 && b >= 1)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,x,a[100],cnt=0;
  cin >> n >> x;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  sort(a,a+n);
  cout << n+(x-cnt)/a[0] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int signed long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
vector<int> vec;
int n;
void dfs(int s,int next,int sum) {
  if (s == n) {
    vec.push_back(sum);
    return;
  }
  for (int i = 0; i <= 9; i++) {
    if (s == n - 1 && i == 0) continue;
    if (abs(next - i) <= 1 || next == -1) {
      int k = sum + i * (int) pow(10, s);
      dfs(s + 1, i, k);
    }
  }
}
signed main() {
  IO;
  for(n = 1 ; n <= 10 ;n++) dfs(0,-1,0);
  sort(vec.begin(),vec.end());
  int sz = unique(vec.begin(),vec.end()) - vec.begin();
  int k;
  cin >> k;
  cout << vec[k-1] << endl;
  return 0;
}

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

int p[7];

int main(){
	int num;
	float height;
	for(int i=0; i < 8; i++) p[i] = 0;

	cin >> num;
	for(int i=0; i < num; i++){
		cin >> height;

		if(height < 165.0) p[1]++;
		else if(height < 170.0) p[2]++;
		else if(height < 175.0) p[3]++;
		else if(height < 180.0) p[4]++;
		else if(height < 185.0) p[5]++;
		else p[6]++;
	}
	for(int i=1; i <= 6; i++){
		cout << i << ":";
		for(int j=0; j < p[i]; j++){
			cout << "*";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

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

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    if (n & 1) { std::cout << 0 << '\n'; return; }

    n /= 2;

    ll ans = 0;
    for (ll i = 5; i <= n; i *= 5)
        ans += n / i;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=5e5+1 ;
ll n,m ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;

    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
ll fac[N] , ifac[N] ;
ll c(ll i,ll j)
{
    ll x=(fac[i]*ifac[j])%maa ;
    x=(x*ifac[i-j])%maa ;

    //cout<<i<<" "<<j<<" "<<x<<endl ;


    return x ;
}
int main()
{
    fast ;
    fac[0]=ifac[0]=1 ;

    cin>>n>>m ;

    for(ll i=1;i<N;i++)
    {
        fac[i]=(fac[i-1]*i)%maa ;
        ifac[i]=power(fac[i],maa-2) ;

    }
    ll ans=0 ;
    for(ll i=0;i<=n;i++)
    {
        ll x=(c(n,i)*c(m,i))%maa ;
        x=(x*fac[i])%maa ;

        ll y=(c(m-i,n-i)*fac[n-i])%maa ;
        y=(y*y)%maa ;

        x=(x*y)%maa ;

        if(i%2==0)
        {
            ans+=x ;
            ans%=maa ;
        }
        else
        {
            ans-=x ;
            ans%=maa ;
            ans+=maa ;
            ans%=maa ;
        }

       // cout<<i<<" "<<x<<endl ;


    }

    cout<<ans ;


}




Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % 13;
        x = x*x % 13;
        n = n >> 1; 
    }
    return res;
}

ll solve(string &s,int k = 0,ll status = 0){
    // status : equal to limit? 1 : 0
    static ll dp[100001][13];
    if(!k) memset(dp,-1,sizeof(dp));

    if(k==s.size()){
        if(status==5) return 1;
        else          return 0;
    }

    ll &res = dp[k][status];
    if(res!=-1) return res;
    else res = 0;

    if(s[k]!='?') res = (res+solve(s,k+1,(status+(ll)(s[k]-'0')*mpow(10,s.size()-1-k))%13))%mod;
    else for(int i = 0;i <= 9;i ++){
        ll cnt;
        cnt = solve(s,k+1,(status+i*mpow(10,s.size()-1-k))%13)%mod;
        res = (res+cnt)%mod;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 18432
import queue
INF=10**8
r,c=map(int,input().split())
#sy,sx=map(int,input().split())
#gy,gx=map(int,input().split())
maze=[input() for _ in range(r)]
d=[[INF for i in range(r)] for _ in range(c)]
sx,sy=1,1
gx,gy=r,c
cnt=0
for i in range(r):
  for j in range(c):
    if maze[i][j]=='.':
      cnt+=1

sx-=1
sy-=1
gx-=1
gy-=1
q=queue.Queue()
dx=[-1,0,1,0]
dy=[0,-1,0,1]
q.put((sx,sy))
d[sy][sx]=0

while not q.empty():
  x,y=q.get()
  if (x,y)==(gx,gy):break
  for i in range(4):
    nx=x+dx[i]
    ny=y+dy[i]
    if 0<=nx<c and 0<=ny<r:
      if maze[ny][nx]=='.' and d[nx][ny]==INF:
        q.put((nx,ny))
        d[nx][ny]=d[x][y]+1
if d[gy][gx]==INF:
  print(-1)
else:print(cnt-d[gy][gx]-1)

Measured memory_bytes: 43240
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {break;}
            for (int i = 0; i < H;i++) {
                if (i == 0) {
                    for (int j = 0; j < W; j++){
                        System.out.print("#");
                    }
                    System.out.println();
                } else if (i > 0 && H - 1 > i) {
                System.out.print("#");
                    for (int j = 0; j < W-2; j++) {
                    System.out.print(".");
                    }
                System.out.print("#");
                System.out.println();
                } else if (i == H - 1) {
                    for (int j = 0; j < W; j++){
                        System.out.print("#");
                    }
                    System.out.println();
                }
            }
            System.out.println();

        }
    }
}


Measured memory_bytes: 32844
#include <cstdio>
#include <vector>   
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <random>
#include <ctime>
#include <iomanip>
#include <deque>
#include <queue> 
#include <cmath>
#include <cstring>
#include <cassert>
#include <bitset>
#include <unordered_set>
typedef long long ll;
typedef long double ld;
 
using namespace std;

const int N = 101;

vector<int> g[N];
vector<pair<int, int>> e;
vector<int> mp;

int dfs(int v, int p, int h) {
    int ans = h;
    mp[h] = max(mp[h], (int) g[v].size() - 1);
    for (int u : g[v]) {
        if (u == p)
            continue;
        ans = max(ans, dfs(u, v, h + 1));
    }
    return ans;
}


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
#endif
    int n, u, v;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
        e.push_back({u, v});
    }
    int ans = 1000, ca;
    ll inf = ((1ll << 62) - 1) * 2, lp = inf, p = 1;
    for (int i = 1; i <= n; i++) {
        mp.assign(n + 1, 0);
        ca = dfs(i, 0, 1);
        if (ca < ans) {
            ans = ca;
            lp = inf;
        }
        if (ans == ca) {
            p = mp[1] + 1;
            for (int j = 2; j <= n && mp[j]; j++)
                p *= mp[j];
            lp = min(lp, p);
        }
    }
    for (int i = 0; i < n - 1; i++) {
        mp.assign(n + 1, 0);
        ca = max(dfs(e[i].first, e[i].second, 1), dfs(e[i].second, e[i].first, 1));
        if (ca < ans) {
            ans = ca;
            lp = inf;
        }
        if (ans == ca) {
            p = 2;
            for (int j = 1; j <= n && mp[j]; j++) {
                p *= mp[j];
            }
            lp = min(lp, p);
        }
    }
    printf("%d %lld", ans, lp);
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
ans = 0
now = x[0]
for i in range(n):
    if (x[i] - now)*a >= b:
        ans += b
        now = x[i]
    else:
        ans += (x[i] - now)*a
        now = x[i]
print(ans)

Measured memory_bytes: 14252
n = int(input())
v = list(map(int, input().split()))

v = sorted(v)

while True:
    if len(v) == 1:
        break
    val = (v[0] + v[1]) / 2
    v.pop(0)
    v.pop(0)
    v.insert(0, val)

print(v[0])

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define fs first
#define sc second
using namespace std;
using lint = unsigned long long;

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> vp(N);
    rep(i, N) cin >> vp[i].fs >> vp[i].sc;
    sort(vp.begin(), vp.end(), greater<pair<int, int>>());
    priority_queue<int, vector<int>, greater<int>> que;
    int day = vp[0].fs;
    for(int i = 0; i < N; i++){
        if(vp[i].fs > M) continue;
        if(vp[i].fs != day){
            while(que.size() > M-day+1){
                que.pop();
            }
            day = vp[i].fs;
        }
        que.push(vp[i].sc);
    }
    while(que.size() > M-day+1){
        que.pop();
    }
    int ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>

int main()
{
    int N = 0;

    scanf("%d", &N);
    if (N % 2 == 0) {
        if (N > 2) {
            printf("%d\n", N);
        }
        else {
            printf("%d\n", 2);
        }
    } else {
        if (N > 2) {
            printf("%d\n", N*2);
        } else {
            printf("%d\n", 2);
        }
    }

    return 0;
}


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

int main(void)
{
    int x,a,n,b,i,h,j,m=0;
    scanf("%d %d %d %d",&n,&a,&b,&x);
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=a;j++)
        {
            for(h=0;h<=b;h++)
            {
                if(i*500+j*100+h*50==x)
                    m++;
            }
        }
    }
    printf("%d\n",m);
    return 0;
}


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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int a=0;
  int count=0;
  while(count<C){
    count+=A;
    a++;
    if(a%7==0) count+=B;
    
  }
  cout<<a<<endl;;
  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	cin >> n;
	vector<ll> p(n);
	vector<ll> q(n);
	rep(i, n) {
		cin >> p[i];
		q[i] = p[i];
	}
	ll cnt = 0;
	sort(q.begin(), q.end());
	rep(i, n) {
		if (p[i] != q[i]) {
			cnt++;
		}
	}
	if (cnt == 0 || cnt == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cub(x) (1ll * (x) * (x) * (x))
#define ll long long
using namespace std;

const int N = 100005, K = 2500;
int n, num, ans; ll o[N], a[N];
bool isp[K]; int cnt, p[K];
map <ll, int> app;
map <ll, bool> vis;
void sieve () {
	memset(isp,1,sizeof isp), isp[1] = 0;
	for (int i = 2; i < K; ++i) {
		if (isp[i]) p[++cnt] = i;
		for (int j = 1; j <= cnt && i * p[j] < K; ++j) {
            isp[i * p[j]] = 0;
            if (i % p[j] == 0) break;
        }
    }
}

int main () {
	sieve();
	cin >> n, num = 0;
	for (int i = 1; i <= n; ++i) {
		ll x, y; scanf("%lld", &x);
		o[i] = a[i] = 1;
		for (int j = 1; j <= cnt; ++j) {
			y = cub(p[j]);
			if (y > x) break;
			for ( ; x % y == 0; x /= y);
			y = p[j] * p[j];
			if (x % y == 0) o[i] *= y, a[i] *= p[j];
			else if (x % p[j] == 0) o[i] *= p[j], a[i] *= y;
			for ( ; x % p[j] == 0; x /= p[j]);
		}
		if (x > 1) {
			y = sqrt(x);
			if (y * y == x) o[i] *= x, a[i] *= y;
			else o[i] *= x, a[i] *= x * x;
		}
		++app[o[i]];
	}
	for (int i = 1; i <= n; ++i) if (!vis[o[i]]) {
		vis[o[i]] = vis[a[i]] = 1;
		if (o[i] == 1) {
			ans += min(max(app[o[i]], app[a[i]]), 1);
		} else ans += max(app[o[i]], app[a[i]]);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	while (true) {
		string str;
		string leftstr = "qwertasdfgzxcvb";
		cin >> str;

		if (str == "#") {
			break;
		}

		int count = 0;
		bool left;

		for (unsigned int i = 0; i < str.size(); i++) {
			bool flag = false;
			for (unsigned int j = 0; j < leftstr.size(); j++) {
				if (str[i] == leftstr[j]) {
					flag = true;
					break;
				}
			}

			if (i == 0) {
				left = flag;
			}
			else {
				if (left != flag) {
					count++;
					left = flag;
				}
			}
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 3148