akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int left=0, right=0;
    int sum=0;
    int ans = INF;
    while(left < n){
        while(sum<k){
            right++;
            if(right > n) break;
            sum += a[right-1];
        }
        if(left==0 && right==n+1 && sum < k) {
            ans = 0;
            break;
        }
        chmin(ans, right-left);
        while(left <= right){
            left++;
            sum -= a[left-1];
            if(sum < k) break;
            chmin(ans, right-left);
        }
    }
    pr(ans);
    return 0;}


Measured memory_bytes: 3132
#include <iostream>
#include<cstdio>
#include<queue>
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
int a[3005];
int b[3005];
int c[3005];

int vis[3005];
long long lf[19];

int main()
{

 long long s;


//scanf("%lld",&s);
 cin>>s;
 lf[0]=1;
 for(int i=1;i<19;i++)
 {
     lf[i]=lf[i-1]*10;
 }
 int k=18;
long long x=s/lf[9];
long long c=(x+1)*lf[9]-s;
if(s==lf[18])
    printf("%d %d %d %lld %lld %d",0,0,0,lf[9],lf[9],0);
else
printf("%d %d %lld %d %lld %lld\n",0,0,x+1,1,c,lf[9]);

    return 0;
}


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

int main(){
        char s[1001], t[1001], kiri[1001];
        int n, m;
        scanf("%s%s", s, t);
        n=strlen(s); m=strlen(t);

        int i, j, min, diff;
        min=m;
        for(i=0; i<=n-m; i++){
                diff=0;
                for(j=0; j<m; j++){
                        if(t[j]!=s[i+j]){
                                diff++;
                        }
                }
                if(min>diff){
                        min=diff;
                }
        }
        printf("%d", min);


        return 0;
}


Measured memory_bytes: 1732
import math
from decimal import Decimal
N = int(input())
T = [0 for i in range(N)]
A = [0 for i in range(N)]
for i in range(N):
	T[i], A[i] = map(int, input().split())

minT = T[0]
minA = A[0]

for i in range(1, N):
	tmpT = T[i]
	tmpA = A[i]
	# rate = 1
	rate = Decimal(max(math.ceil(minT/tmpT), math.ceil(minA/tmpA)))
	# if tmpT<minT or tmpA<minA:
		# rate = max(int((minT-1)/tmpT)+1, int((minA-1)/tmpA)+1)
		# rate = max(math.ceil(minT/tmpT), math.ceil(minA/tmpA))
	minT = tmpT*rate
	minA = tmpA*rate
print(minT+minA)


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k,x; cin>>k>>x;
	cout<<x-k+1;
	for(int i=x-k+2;i<x+k;++i){
		cout<<" "s<<i;
	}
	cout<<"\n"s;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>

// template {{{
using namespace std;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))

using int64 = long long;

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

bool in_field(int W, int H, int x, int y) {
  return (0 <= x && x < W) && (0 <= y && y < H);
}

// pair
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << "\t";
  }
  return s;
}

// }}}

// url: https://atcoder.jp/contests/abc124/tasks/abc124_d

int N, K;
string S;

int main() {
  cin >> N >> K >> S;

  int l = 0, r = 0, k = 0, sum = 0;
  int ans = 0;
  while (r < N) {
    while (r < N && k < K) {
      if (S[r] == '0' && S[r + 1] == '1') {
        k++;
      }
      r++;
      sum++;
    }

    while (S[r] == '1') {
      r++;
      sum++;
    }
    ans = max(sum, ans);
    while (k >= K) {
      if (S[l] == '0' && S[l + 1] == '1') {
        k--;
      }
      l++;
      sum--;
    }
  }
  cout << ans << endl;

  return 0;
}

// vim: foldmethod=marker


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    string a[3];
    cin >> a[0] >> a[1] >> a[2];
    int g[3] = {-1, -1, -1}, cur=0;
    while( 69 ) {
        g[cur]++;
        if( g[cur] >= a[cur].size() ) {
            char x = cur+'A';
            cout << x;
            return 0;
        }
        cur = a[cur][g[cur]] - 'a';
    }
    return 0;
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 1e5 + 41;
int const MOD = 1e9 + 7;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int n, m;

int x[MAX];
int y[MAX];

int F[MAX];

void upd(int x, int v) {
	while (x < MAX) {
		F[x] = add(F[x], v);
		x |= (x + 1);
	}
}

int get(int x) {
	int res = 0;
	while (x >= 0) {
		res = add(res, F[x]);
		x = (x & (x + 1)) - 1;
	}
	return res;
}

bool cmp(pii a, pii b) {
	if (a.first != b.first) return a.first < b.first;
	return a > b;
}

void solve() {
	vi b;
	fi(1, n) {
		int p = (int) (upper_bound(y + 1, y + m + 1, x[i]) - y);
		if (p == 1 || p == m + 1) continue;
		b.pb(y[p] - x[i]);
	}	
	b.pb(0);
	sort(b.begin(), b.end());
	b.resize(unique(b.begin(), b.end()) - b.begin());

	vpii a;
	fi(1, n) {
		int p = (int) (upper_bound(y + 1, y + m + 1, x[i]) - y);
		if (p == 1 || p == m + 1) continue;
		int posb = (int) (lower_bound(b.begin(), b.end(), y[p] - x[i]) - b.begin());
		a.pb(mp(x[i] - y[p - 1], posb));
	}	
	sort(a.begin(), a.end(), cmp);
	a.resize(unique(a.begin(), a.end()) - a.begin());

	//
	err("b:\n");
	for (int x : b) {
		err("%d ", x);
	}
	err("\n");

	err("a:\n");
	for (auto z : a) {
		err("%d %d\n", z.first, z.second);
	}
	err("\n");
	//

	upd(0, 1);
	fi(0, sz(a) - 1) {
		int s = get(a[i].second - 1);
		upd(a[i].second, s);
	}

	printf("%d\n", get(MAX - 1));
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d %d", &n, &m);  
  fi(1, n) {
  	scanf("%d", &x[i]);
  }
  fi(1, m) {
  	scanf("%d", &y[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    
    long long int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
        
        
    }
    long long int dp[n+1][4];
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2;i<=n;i++){
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
        
      
    }
   long long  int ans=max(dp[n][1],max(dp[n][2],dp[n][3]));
    cout<<ans;
}

Measured memory_bytes: 5760
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;

    for(int i=0; i<ty-sy; ++i){
        cout <<"U";
    }

    for(int i=0; i<tx-sx; ++i){
        cout <<"R";
    }

    for(int i=0; i<ty-sy; ++i){
        cout <<"D";
    }

    for(int i=0; i<tx-sx; ++i){
        cout <<"L";
    }

    cout << "L";

    for(int i=0; i<ty-sy; ++i){
        cout <<"U";
    }

    cout << "U";

    for(int i=0; i<tx-sx+1; ++i){
        cout <<"R";
    }

    cout << "DR";

    for(int i=0; i<ty-sy+1; ++i){
        cout <<"D";
    }

    for(int i=0; i<tx-sx+1; ++i){
        cout <<"L";
    }

    cout << "U" << endl;

    return 0;
}


Measured memory_bytes: 256
import random 

def dice (a, b, c, d, e, f, l) :  #def = 関数定義 

  if(l == "N") : 

    return [b, f, c, d, a, e] 

  elif (l == "S") : 

    return [e, a, c, d, f, b] 

  elif (l == "W") : 

    return [d, b, a, f, e, c] 

  else : 

    return [c, b, f, a, e, d] 

  

d1 = list (map(int, input().split())) 

a, b, c, d, e, f = map(int, input().split()) 

L = ["N", "S", "W", "E"] 

  

cnt = 0 

  

while (cnt <= 10000) : 

  x = random.randrange(4)  #0～3の中からランダムに1つ整数を選択 

  d1 = dice(d1[0], d1[1], d1[2], d1[3], d1[4], d1[5], L[x]) 

  

  if (d1[0] == a and d1[1] == b and d1[2] == c and d1[3] == d 

     and d1[4] == e and d1[5] == f) : 

    print("Yes") 

    break 

  elif (cnt == 10000) : 

    print ("No") 

    break 

  else : 

    cnt += 1 

 


Measured memory_bytes: 8176
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""


input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1

"""

import sys


class UnionFind(object):
    __slots__ = ('size', 'tree_height_rank_list', 'ancestor_list')

    def __init__(self, size):
        self.size = int(size)
        self.tree_height_rank_list = [0] * self.size
        self.ancestor_list = [i for i in range(self.size)]

    def __find(self, x):
        if x != self.ancestor_list[x]:
            self.ancestor_list[x] = self.__find(self.ancestor_list[x])
        return self.ancestor_list[x]

    def same(self, x, y):
        return self.__find(x) == self.__find(y)

    def __link(self, x, y):
        if self.tree_height_rank_list[x] > self.tree_height_rank_list[y]:
            self.ancestor_list[y] = x
        else:
            self.ancestor_list[x] = y
            if self.tree_height_rank_list[x] == self.tree_height_rank_list[y]:
                self.tree_height_rank_list[y] += 1

    def union(self, x, y):
        self.__link(self.__find(x), self.__find(y))


def action(cmd_list):
    for each in cmd_list:
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            if case.same(ele_1, ele_2):
                print('1')
            else:
                print('0')
    return case


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    e_num, c_num = map(int, _input[0].split())
    c_list = map(lambda x: x.split(), _input[1:])

    case = UnionFind(size=e_num)

    ans = action(c_list)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int x[100];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(int i=0;i<n-1-i;i++)swap(x[i],x[n-1-i]);
    
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<x[i];
    }
    
    cout<<endl;
    
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
struct P {
  int x;
  int y;
  int t;
};

bool isValid(P from, P to) {
  int d = ABS(from.x, to.x) + ABS(from.y, to.y);
  int t = to.t - from.t;

  return t >= d && (t-d)%2 == 0;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  vector<P> points;
  for (int i=0; i<N; i++) {
    P to;
    cin >> to.t >> to.x >> to.y;
    points.push_back(to);
  }

  P p{0, 0, 0};
  for (P to : points) {
    if (!isValid(p, to)) {
      cout << "No" << endl;
      return 0;
    }
    p = to;
  }

  cout << "Yes" << endl;

  return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

vector<bool> isPrime;

void eratosthenes(int N){
    isPrime.resize(N+1);
    rep(i, 2){
        isPrime[i] = false;
    }
    isPrime[2] = true;
    REP(i, 3, N+1){
        if(i % 2 == 0){
            isPrime[i] = false;
        }else{
            isPrime[i] = true;
        }
    }
    for(int i = 3 ; i * i <= N ; i += 2){
        if(isPrime[i]){
            for(int j = i ; i * j <= N ; j++){
                isPrime[i*j] = false;
            }
        }
    }
    return;
}

int main(){
    eratosthenes(1e6+10);
    int a, d, n;
    while(cin >> a >> d >> n, a){
        int cnt = 0;
        while(true){
            if(isPrime[a]){
                cnt++;
                if(cnt == n){
                    break;
                }
            }
            a += d;
        }
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#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>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

double K, L, R, P, E, T;

double f(double l, double r, int k) {
    // output(l, r, k);
    if (k == 0) {
        double h = (l + r) / 2.;
        if (T - E <= h && h <= T + E) return 1.;
        else return 0.;
    }
    if (r < T - E || T + E < l) return 0.;
    if (T - E < l && r < T + E) return 1.;
    double h = (l + r) / 2.;
    double pl = (T <= h ? 1. - P : P);
    double pr = 1. - pl;
    return pl * f(l, h, k - 1) + pr * f(h, r, k - 1);
}

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

    cin >> K >> L >> R >> P >> E >> T;
    cout << fixed << setprecision(10) << f(L, R, K) << endl;
}

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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}

vector<ll> adj[100010];
ll dp1[100010],dp2[100010];

void dfs1(ll i,ll par)
{
	ll j;
	for(j=0;j<sz(adj[i]);j++)
	{
		ll x = adj[i][j];
		if(x==par)
			continue;
		dp1[x] = dp1[i]+1;
		dfs1(x,i);
	}
	return ;
}

void dfs2(ll i,ll par)
{
	ll j;
	for(j=0;j<sz(adj[i]);j++)
	{
		ll x = adj[i][j];
		if(x==par)
			continue;
		dp2[x] = dp2[i]+1;
		dfs2(x,i);
	}
	return ;
}

int main()
{
	fastio;
	ll i,j,n,a,b;
	cin>>n>>a>>b;
	for(i=0;i<n-1;i++)
	{
		ll u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dp1[a]=0;
	dfs1(a,0);
	dp2[b]=0;
	dfs2(b,0);
	ll ma=-1e9,mi=1e9;
	for(i=1;i<=n;i++)
	{
		if(dp1[i]==dp2[i])
			mi=min(mi,dp1[i]);
		if((dp2[i]>dp1[i])&&(dp2[i]>2))
		{
			// if((dp1[i]+dp2[i])%2)
			// 	ma=max(dp2[i]-1,ma);
			// else
			ma=max(ma,dp2[i]-1);
		}
		// cout<<dp1[i]<<" "<<dp2[i]<<endl;
		// cout<<ma<<endl;
	}
	if(mi!=1e9)
		ma=max(ma,mi);
	if(ma==-1e9)
		ma=0;
	cout<<ma<<endl;
    return 0;
}





Measured memory_bytes: 14568
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N), Y(N), H(N);
    int x, y, h;
    REP(i, N) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > 0) {
            x = X[i], y = Y[i], h = H[i];
        }
    }
    REP(cx, 101) {
        REP(cy, 101) {
            bool f = true;
            int A = h + abs(x - cx) + abs(y - cy);
            REP(i, N) {
                if (H[i] > 0) {
                    if (H[i] + abs(X[i] - cx) + abs(Y[i] - cy) != A) {
                        f = false;
                    }
                } else {
                    if (A - abs(X[i] - cx) - abs(Y[i] - cy) > 0) {
                        f = false;
                    }
                }
            }
            if (f) {
                cout << cx << " " << cy << " " << A << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

#define int long long

int get(int i,int x)
{
    if(x==1)
        return i;
    return i*get(i,x-1);
}

void solve(int tt)
{
    int x;
    cin>>x;
    int val[1005]={0};
    for(int i=0;i<=1000;i++)
        val[i]=get(i,5);
    for(int i=0;i<=1000;i++)
    {
        if(binary_search(val,val+1001,x+val[i]))
        {
            cout<<(lower_bound(val,val+1001,x+val[i])-val)<<" "<<i;
            return;
        }
        
        if(binary_search(val,val+1001,x-val[i]))
        {
            cout<<(lower_bound(val,val+1001,x-val[i])-val)<<" "<<(-1)*i;
            return;
        }
    }
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (long long) (n); i++)
using ll=int64_t;
using vi = vector<int>;
using vll = vector<ll>;
/*
    vi v(N);
    for(int i=0;i<N;i++){
        cin>>v.at(i);
    }
*/
/*
    int x;
    cin >> x;
    return x;
*/


int main(){

string s,t;
cin>>s>>t;
int n =s.size();
bool aho = true;
for(int i=0;i<n;i++){
    if(s.at(i)!=t.at(i)) {aho = false;break;}
}
if(aho) cout<<"Yes";
else cout<<"No";

}


Measured memory_bytes: 3560
/**
 * Created by 卢嘉昊 on 2017/7/23.
 */
import java.util.Scanner;
public class Main {
    public static void main(String args[]){
        //read in
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int k = scan.nextInt();
        int A[] = new int[N];
        int max = 0;
        for(int i=0;i<N;i++){
            A[i] = scan.nextInt();
            max = max>A[i]?max:A[i];
        }
        //solution
        if(k>max){
            System.out.println("IMPOSSIBLE");
            return;
        }
        int g,a,b;
        if(N==1){
            if(A[0] == k){
                System.out.println("POSSIBLE");
                return;
            }else{
                System.out.println("IMPOSSIBLE");
                return;
            }
        }
        a = A[0];
        b = A[1];
        g = gcd(a,b);
        for(int i=2;i<N;i++){
            b = A[i];
            g = gcd(g,b);
        }
        if(k%g != 0){
            System.out.println("IMPOSSIBLE");
            return;
        }else{
            System.out.println("POSSIBLE");
            return;
        }
    }
    public static int gcd(int a,int b){
        if(a==b) return a;
        int big = a>b?a:b;
        int small = a<b?a:b;
        if(big%small==0){
            return small;
        }else{
            return gcd(big%small,small);
        }
    }
}


Measured memory_bytes: 50792
def main():
    c = [[int(x) for x in input().split()] for _ in range(3)]
    all_sum = 0
    answer = True
    for i in range(3):
        all_sum += sum(c[i])
    if all_sum % 3 == 0:
        all_sum //= 3
    else:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][i]
    if now_sum != all_sum:
        answer = False
    now_sum = 0
    for i in range(3):
        now_sum += c[i][2 - i]
    if now_sum != all_sum:
        answer = False
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
M = int(input())
d = [0] * M
c = [0] * M
for i in range(M):
	d[i], c[i] = map(int, input().split())
D = 0
S = 0
for i in range(M):
	D += c[i]
	S += d[i] * c[i]
print((D - 1) + (S - 1) // 9)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, K;

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

    int ans = 1;
    while(N/K) ans++, N/=K;

    cout << ans << endl;

    return 0;
}

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int a, b;
  while (cin >> s >> a >> b) {
    cout << s << " " << a + b << " " << a * 200 + b * 300 << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
n,q = map(int,input().split())
s = list(input())
l = len(s)
for i in range(l-1):
  if s[i] == "A" and s[i+1] == "C":
    s[i]= "a"


lis = [0]*(l+1)
for i in range(1,l+1):
  lis[i] = lis[i-1]+(1 if s[i-1]=="a" else 0)


for i in range(q):
  l,r = map(int,input().split())
  print(lis[r-1]-lis[l-1])
  
  



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

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

int n;
cin >> n;
vector<int> a(n);
vector<int> ans(n);
int i=0;
for(i=0;i<n;i++){
    cin >> a[i];
    ans[a[i]-1] = i+1;
}

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


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  ll k;
  cin>>k;
  set<string> h;
  string kk;
  int si=s.size();
  int p=0;
  rep(i,si){
    for(int j=1;j<=k;j++){
      kk=s.substr(i,j);
      h.insert(kk);
    }
  }
  auto g=h.begin();
  for(int i=0;i<k-1;i++){
    g++;
  }
  COUT(*g);
}
    
  


Measured memory_bytes: 1664
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
#def MXI(): return [LI() for i in range(n)]　
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
height=LI()
dp=[inf for i in range(n)]
dp[0]=0
for i in range(1,n):
    for j in range(1,min(i,k)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]))
print(dp[-1])
    








            
    
    

Measured memory_bytes: 92208
main = getContents >>= print . rhombic_path . map (map read . splitOn ',') . lines

splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)

rhombic_path = maximum . rhombic_path []
 where
  rhombic_path acc [] = acc
  rhombic_path acc (ns:nss) 
   | null acc = rhombic_path ns nss
   | length ns > length acc = rhombic_path acc' nss
   | otherwise = rhombic_path acc'' nss
   where
    acc' = zipWith max (zipWith (+) acc ns ++ [0]) ([0] ++ zipWith (+) acc (tail ns))
    acc'' = zipWith (+) ns (zipWith max acc (tail acc))

Measured memory_bytes: 4952
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,n;cin>>k>>n;
  int count=0;
  for(int x=0;x<=k;x++)
    for(int y=0;y<=k;y++){
      int z = n - (x+y);
  	if(z<=k && z>=0)count++;}
  cout<<count;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,sum=0,tmp=0;
  int a[LIMIT2]={0};
  ll b[LIMIT1]={0},c[LIMIT1]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n+1) scanf("%d",&a[i]);
  tmp=1;
  sum=0;
  rep(i,n+1) sum+=(ll)a[i];
  rep(i,n+1){
    if(tmp<(ll)a[i]){
      result = -1;
      break;
    }
    c[i]=tmp;
    tmp -= (ll)a[i];
    tmp *= 2;
    sum -= (ll)a[i];
    tmp = min(tmp,sum);
  }
  if(a[n]>c[n]) result=-1;
  if(result!=-1){
    b[n]=a[n];
    per(i,n){
      b[i]=b[i+1]+(ll)a[i];
    }
    result = 0;
    rep(i,n+1){
      result += min(b[i],c[i]);
    }
    if(result<=0) result=-1;
  }
  printf("%lld",result);
  return 0;
}

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

int main()
{
	int h, w;
	cin >> h >> w;

	int i, j;

	vector<vector<char>>a(h, vector<char>(w));

	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			cin >> a.at(i).at(j);
		}
	}
	vector<bool>r(h, false);
	vector<bool>c(w, false);

	for (i = 0; i < h ; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (a.at(i).at(j) == '#')
			{
				r.at(i) = true;
				c.at(j) = true;
			}
		}
	}
	for (i = 0; i < h; i++)
	{
		if (r.at(i))
		{
			for (j = 0; j < w; j++)
			{
				if (c.at(j))
				{
					cout << a.at(i).at(j);
				}
			}
			cout << endl;
		}
	}

}



/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>


using namespace std;


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

	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    INT(R);

    cout << SYOU(5) << 2*R*M_PI << endl;
   
}

Measured memory_bytes: 3836
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll x, y;
const ll M = pow(10, 9) + 7;

vector<ll> fac(10000001);  //n!(mod M)
vector<ll> ifac(10000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
//conbination
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 1000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
    cin >> x>>y;
    if((x+y)%3!=0||(y*2<x||x*2<y)){
        cout<<0<<"\n";
        return 0;
    }
    ll n=(x+y)/3;
    ll ansn;
    for(int i=1;i<=n;i++){
        if(i+(n-i)*2==x&&(n-i)+2*i==y){
            ansn=i;
            break;
        }
    }
    ll ans=comb(n,ansn);
    ans%=M;
    cout <<ans<< "\n";
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var h = inputLongArray[2];
            var m = inputLongArray[3];

            double rad = 2 * Math.PI * Math.Abs((h + m / 60.0) / 12.0 - m / 60.0);
            double result = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(rad));
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int dp[20][2];

int main() {
    string s; cin >> s;
    int n = s.size();
    dp[0][0] = 0; dp[0][1] = -1;
    rep(i,n)rep(j,2) {
        if (i == 0 && j == 1) continue;
        int x = s[i] - '0';
        for (int k = 0; k < 10; k++) {
            int n_j = j;
            if (n_j == 0) {
                if (k > x) continue;
                if (k < x) n_j = 1;
            }
            chmax(dp[i+1][n_j],dp[i][j]+k);
        }
    }
    int ans = max(dp[n][1],dp[n][0]);
    cout << ans << endl;
}

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

#define ran 202202

int n, k;
int p[ran];

int main() {
	scanf("%d%d", &n, &k);
	
	int s = 0, ans = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &p[i]);
		if(i<k) s+=p[i];
	}
	ans = s;
	for(int i=k;i<n;i++) {
		s += p[i] - p[i-k];
		ans = max(ans, s);
	}
	ans += k;
	printf("%.10lf\n", 1.*ans/2);
	
	return 0;
}

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

public class ABC157_B {
	private static void Main(string[] args) {
		var a = ReadIntsLinesAsList(3);
		var n = ReadInt();
		var b = ReadIntLinesAsList(n);

		var card = new BingoCard(a);
		b.ForEach((number) => card.Mark(number));

		var answer = (card.HasBingo()) ? "Yes" : "No";
		Console.WriteLine(answer);
	}

	private static int ReadInt() => int.Parse(Console.ReadLine().Trim());

	private static List<int> ReadIntLinesAsList(int numOfLines) {
		var list = new List<int>();
		for (int i = 0; i < numOfLines; i++)
			list.Add(int.Parse(Console.ReadLine().Trim()));
		return list;
	}
	  
	private static List<int> ReadIntsLinesAsList(int numOfLines) {
		var list = new List<int>();
		for (var i = 0; i < numOfLines; i++) {
			var tempArray = Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
			for (var j = 0; j < tempArray.Length; j++)
				list.Add(tempArray[j]);
		}
		return list;
	}
}

public class Cell {
	private int number;
	private bool isMarked;

	public bool IsMarked {
		get { return this.isMarked; }
	}

	public Cell(int number) {
		this.number = number;
		this.isMarked = false;
	}

	public void Mark(int number) {
		if (number == this.number)
			isMarked = true;
	}
}

public class BingoCard {
	private List<Cell> cells = new List<Cell>();
	private int size;

	public BingoCard(List<int> numbers) {
		numbers.ForEach((n) => this.cells.Add(new Cell(n)));
		this.size = (int)Math.Sqrt(cells.Count());
	}

	public void Mark(int number) {
		cells.ForEach((x) => x.Mark(number));
	}

	public bool HasBingo() {
		if (HasVerticalBingo() || HasHorizontalBingo() || HasDiagonalBingo())
			return true;
		else
			return false;
	}

	private bool HasVerticalBingo() {
		for (int column = 0; column < size; column++) {
			bool isBingo = true;

			for (int row = 0; row < size; row++) {
				if (!cells[CalcIndex(row, column)].IsMarked)
					isBingo = false;
			}

			if (isBingo)
				return true;
		}
		return false;
	}

	private bool HasHorizontalBingo() {
		for (int row = 0; row < size; row++) {
			bool isBingo = true;

			for (int column = 0; column < size; column++) {
				if (!cells[CalcIndex(row, column)].IsMarked)
					isBingo = false;
			}

			if (isBingo)
				return true;
		}
		return false;
	}

	private bool HasDiagonalBingo() {
		if (HasSlashBingo() || HasBackslashBingo())
			return true;
		else
			return false;
	}

	private bool HasSlashBingo() {
		for (int row = 0; row < size; row++) {
			for (int column = 0; column < size; column++) {
				if ((row + column) == (size - 1)) {
					if (!cells[CalcIndex(row, column)].IsMarked) {
						return false;
					}
				}
			}
		}
		return true;
	}

	private bool HasBackslashBingo() {
		for (int row = 0; row < size; row++) {
			for (int column = 0; column < size; column++) {
				if (row == column) {
					if (!cells[CalcIndex(row, column)].IsMarked) {
						return false;
					}
				}
			}
		}
		return true;
	}

	public int CalcIndex(int row, int column) {
		return row * size + column;
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;
vvi g;

bool dfs(int v){
	vi c;
	int s=0,S=0;
	bool B=1;
	for(auto u:g[v]){
		B&=dfs(u);
		S+=max(a[u],b[u]);
		s+=min(a[u],b[u]);
		c.push_back(abs(a[u]-b[u]));
	}
	int N=a[v]-s+1;
	if(N<=0||!B) return 0;
	vi dp(N);
	dp[0]=1;
	for(int i=0;i<c.size();i++) for(int j=N-c[i]-1;j>=0;j--) dp[j+c[i]]|=dp[j];
	for(int i=0;i<N;i++) if(dp[i]) b[v]=S-i;
	return 1;
}

int main(){
	cin>>n;
	g=vvi(n);
	a=b=vi(n);
	for(int i=1;i<n;i++){
		int v;
		cin>>v;
		g[v-1].push_back(i);
	}
	for(int i=0;i<n;i++) cin>>a[i];
	if(dfs(0)) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    long long power = 1;
    const int div = 1000000000 + 7;
    for(int i=0;i<n;i++){
        power *= i+1;
        power %= div;
    }
    cout << power << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    sort(x.begin(), x.end());
    int l = 1;
    int r = 100;
    ll s = 1e+15;
    for(int i = 1; i < 101; i++){
        ll si = 0;
        rep(j, n) si += (x[j] - i) * (x[j] - i);
        if (si <= s) s = si;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

int main(){
	int year, month, day, ansYear;
	string gengou;
	while (cin >> year >> month >> day){
		ansYear = 0;
		if (year > 1989 || (year == 1989 && (month > 1 || month == 1 && day >= 8))){
			gengou = "heisei";
			ansYear = year - 1989;
		}
		else if (year > 1926 || (year == 1926 && (month >= 12 && day >= 25))){
			gengou = "showa";
			ansYear = year - 1926;
		}
		else if (year > 1912 || (year == 1912 && (month > 7 || month == 7 && day >= 30))){
			gengou = "taisho";
			ansYear = year - 1912;
		}
		else if (year > 1868 || (year == 1868 && (month > 9 || month == 9 && day >= 8))){
			gengou = "meiji";
			ansYear = year - 1868;
		}
		else
			gengou = "pre-meiji";

		ansYear++;
		if (gengou == "pre-meiji")
			cout << gengou << endl;
		else
			cout << gengou << " " << ansYear << " " << month << " " << day << endl;
	}
	return 0;
}

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

signed main(void)
{
	string s, t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256