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

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

vector<int> A;
vector<vector<int>> g;

bool dfs(int p, int x, int& r)
{
  vector<int> l;
  int t;
  r = A[x];
  int sum = 0;
  for (auto a : g[x]) {
    if (a == p) continue;
    if (!dfs(x, a, t)) return false;
    l.push_back(t);
    sum += t;
  }
  if (l.size() == 0) return true;
  cerr << x << " ";
  for (auto a : l) cerr << a << " ";
  sort(l.begin(), l.end());
  int mi = sum - min(sum / 2, (sum - l.back()));
  r = 2 * A[x] - sum;
  cerr << r << endl;
  return mi <= A[x] && A[x] <= sum && r <= A[x];
}

signed main()
{
  int N;
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];
  g.resize(N, vector<int>());
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int res;
  if (dfs(-1, 0, res) && dfs(-1, N-1, res)) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}


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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll p[n],q[n],x[n];
    for (ll i=0;i<n;i++){
        cin >> p[i];
    }
    for (ll i=0;i<n;i++){
        cin >> q[i];
    }
    for (ll i=0;i<n;i++){
        x[i]=p[i];
    }
    sort(x,x+n);
    vector<ll> x1;
    vector<ll> x2;
    for (ll i=0;i<n;i++){
        x1.push_back(x[i]);
        x2.push_back(x[i]);
    }
    ll a=1,b=1,c=junnretu(n-1),z=n-1;
    for (ll i=0;i<n-1;i++){
        for (ll j=0;j<n;j++){
            if (p[i]==x1[j]){
                x1.erase(x1.begin()+j);
                if (j==0)break;
                a+=c*j;
                break;
            }
        }
        c=c/z;
        z--;
    }
    c=junnretu(n-1);
    z=n-1;
    for (ll i=0;i<n-1;i++){
        for (ll j=0;j<n;j++){
            if (q[i]==x2[j]){
                x2.erase(x2.begin()+j);
                if (j==0)break;
                b+=c*j;
                break;
            }
        }
        c=c/z;
        z--;
    }
    cout << abs(a-b) << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<int> a(n, 0);
  vector<int> cnt(n, 0);
  REPP(i, n - 1){
    cin>>a[i];
    a[i]--;
    cnt[a[i]]++;
    cnt[i]++;
  }
  REP(i, n){
    if(i == 0){
      cout<<cnt[i]<<endl;
    }else{
      cout<<cnt[i] - 1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N; cin >> N;
  vector<ll> A(N), B(N);
  rep(i, 0, N) cin >> A[i];
  ll sum = 0;
  rep(i, 0, N) sum += A[i];
  for (ll i = 0; i < N - 1; i += 2) {
  	sum -= A[i] * 2;
  }
  B[N - 1] = sum;
  for (ll i = N - 2; i >= 0; i--) {
  	B[i] = A[i] * 2 - B[i + 1];
  }
  rep(i, 0, N) cout << B[i] << " ";
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int H,W;cin >> H >> W;
    vector<vector<int> > a(H,vector<int>(W));
    rep(i,H)rep(j,W){
        cin >> a[i][j];
        a[i][j]%=2;
    }
    vector<pii> res;
    res.reserve(H*W*2);
    int carry = 0;
    rep(i,H){
        if(i%2==0){
            rep(j,W){
                if(a[i][j]==1||carry==1){
                    res.push_back(make_pair(i,j));
                    if(carry&&!a[i][j])res.push_back(make_pair(i,j));
                    if(a[i][j]==1)carry = 1-carry;
                }
            }
        }
        else if(i%2==1){
            rep(j,W){
                if(a[i][W-j-1]==1||carry==1){
                    res.push_back(make_pair(i,W-j-1));
                    if(carry&&!a[i][W-j-1])res.push_back(make_pair(i,W-j-1));
                    if(a[i][W-j-1]==1)carry = 1-carry;
                }
            }
        } 
    }
    int N = res.size()/2;
    cout << N << endl;
    for(int i=0;i<=N*2-1;i+=2){
        cout << res[i].first+1 << " " << res[i].second+1 << " ";
        cout << res[i+1].first+1 << " " << res[i+1].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

void argCout(int A[],int N){
  cout<<A[0];
  for(int i=1;i<N;i++){
    printf(" %d",A[i]);
  }
  cout<<endl;
}

void insertionSort(int A[],int N){
  for(int i=1;i<N;i++){
    int v=A[i];
    int k=i-1;
    while(k>=0 && A[k]>v){
      A[k+1]=A[k];
      k--;
    }
    A[k+1]=v;
    argCout(A,N);
  }
  
}

int  main(){
  int n;
  int A[1000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  argCout(A,n);
  insertionSort(A,n);

  
  return 0;
}



Measured memory_bytes: 3300
#include<iostream>
using namespace std;
int main(){
  int a[31];
  int d;
  //while(cin>>d){
    for(int i = 0 ; i <= 30 ; i++ ) a[i] = 0;
    for(int i = 0 ; i < 28 ; i++ ){
      cin>>d;
      a[d] = 1;
      //if(i!=27)cin>>d;
    }
    for(int i = 1 ; i <= 30 ; i++ ){
      if(a[i]==0)cout<<i<<endl;
    }
    //for(int i = 1 ; i <= 30 ; i++) cout<<a[d]<<endl;
  }

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7, MAXN = 1e5 + 5;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
int N;
vector<int> adj[MAXN];
ll dp[MAXN][2]; //0 = black, 1 = white
void dfs (int u, int p){
	dp[u][0]=dp[u][1]=1;
	for (int v: adj[u]){
		if (v==p) continue;
		dfs(v, u);
		dp[u][0]*=dp[v][1];
		dp[u][1]*=(dp[v][0]+dp[v][1])%MOD;
		dp[u][0]%=MOD;
		dp[u][1]%=MOD;
	}
}
int main(){
	//ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	scanf("%d", &N);
	for (int i = 1, u, v; i<N; i++){
		scanf("%d%d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1, -1);
	printf("%lld\n", (dp[1][0]+dp[1][1])%MOD);
}	

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

void InsertionSort(int n, int* ar){
    for(int i=1;i<n;i++){

        //---
        // 途中経過表示
        for(int q=0;q<n;q++){    
            cout << ar[q];
            if(q != n-1) cout << " ";
        }
        cout << endl;
        //---

        int v = ar[i];
        int j = i - 1;
        while(j >= 0 && ar[j] > v){
            ar[j+1] = ar[j];
            j--;
        }
        ar[j+1] = v;      
    }
}

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

    int *ar = new int[n];

    for(int i=0;i<n;i++){
        cin >> ar[i];
    }

    InsertionSort(n, ar);

    for(int q=0;q<n;q++){    
        cout << ar[q];
        if(q != n-1) cout << " ";
    }
    cout << endl;

    delete[] ar;

    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> height(n);
    vector<int> dp(n);
    for(int i=0; i<n; i++) dp[i] = INT_MAX;
    for(int i=0; i<n; i++) cin >> height[i];
    dp[0] = 0;
    for(int i=1; i<n; i++) {
        for(int j=i-1; j>=i-k && j>=0; j--) {
            dp[i] = min(dp[i], dp[j]+abs(height[j]-height[i]));
        }
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,z,w;
  cin>>n>>z>>w;
  int a[n];
  int mx=0;
  rep(i,n){
    cin>>a[i];
    mx=max(mx,a[i]);
  }
  if(n==1){
    cout<<abs(a[0]-w)<<endl;
  }else{
    cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
  }


  return 0;
}


Measured memory_bytes: 3660
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int64_t N, t;
  string name = "";
  cin >> N;
  while (N > 0) {
    N--;
    t = 'a' + (N % 26);
    name += t;
    N = N / 26;
  }
  reverse(name.begin(), name.end());
  cout << name << endl;
}


Measured memory_bytes: 3128
object Main {

  import scala.collection.mutable.ArrayBuffer

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, Q = sc.nextInt()
    val G = Array.fill(N+1)(ArrayBuffer[Int]())
    (0 until N - 1) foreach { _ =>
      val a, b = sc.nextInt()
      G(a).append(b)
      G(b).append(a)
    }
    val PtoX = new Array[Long](N+1)
    (0 until Q). foreach { _ =>
      val p, x = sc.nextInt()
      PtoX(p) += x
    }

    val Counter = new Array[Long](N+1)
    val visited = new Array[Boolean](N+1)

    val stack = new scala.collection.mutable.Stack[Int]
    stack.push(1)
    while (stack.nonEmpty) {
      val u = stack.pop()
      visited(u) = true
      val thisCount = PtoX(u)
      Counter(u) += thisCount
      G(u).foreach { v =>
        if (!visited(v)) {
          stack.push(v)
          Counter(v) += Counter(u)
        }
      }
    }

    println(Counter.tail.mkString(" "))
  }

}


Measured memory_bytes: 153576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll sum = 0;
  rep(i, n) {
    sum += s[i] - '0';
    sum %= 9;
  }
  cout << (sum == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n,m;cin>>n>>m;
  vector<int> A(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>A[i];
    sum += A[i];
  }
  long double p = ((long double)sum) / 4.0 / m;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(A[i]>=p)cnt++;
  }
  if(cnt>=m){
    puts("Yes");
  }else{
    puts("No");

  }
  
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    ll sum =0, prev = 0, x, y, ans = 10000000000;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n-1){
        x = sum - a[i];
        y = prev + a[i];
        ans = min(abs(x-y), ans);
        sum -= a[i];
        prev+=a[i];
    }
    cout << ans;
    return 0;
}

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

int main()
{
    


    long long N;
    cin >> N;
    long long ans = 10000000000000;
    long long i = 1;
    while (i*i <= N) {
        if (N % i == 0) {

            long long j = N / i;

            long long tmp = i + j - 2;
            if (tmp < ans)ans = tmp;
        }

        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.3
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#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 dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int digisum(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}  //  桁和

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  cin >> s;
  if(s.size()==1) {cout << s[0]-'0' << endl;return 0;}
  rep(i,1,s.size()){
    if(s[i]!='9') break;
    if(i==s.size()-1) {cout<<digisum(stoll(s))<<endl;return 0;}
  }
  cout << (s[0]-'1') + 9*(s.size()-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int c1, c5, c10, c50, c100, c500, total = 0;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  total = c1*1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
  if(total >= 1000) cout << 1 << endl;
  else cout << 0 << endl;
}




Measured memory_bytes: 3104
"C Vacation"
N = int(input())
summer = []
for i in range(N):
    active = list(map(int, input().split()))
    summer.append(active)

dp = [[0]*3 for i in range(N+1)]
# dp = [[0, 0, 0]] * (N+1)

# print(dp)
for i in range(N):
    dp[i+1][0] = max((max(dp[i][1], dp[i][2])+summer[i][0]), dp[i+1][0])
    dp[i+1][1] = max((max(dp[i][0], dp[i][2])+summer[i][1]), dp[i+1][1])
    dp[i+1][2] = max((max(dp[i][0], dp[i][1])+summer[i][2]), dp[i+1][2])

print(max(dp[-1]))


Measured memory_bytes: 47344
/*A問題*/
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


int main() {
	int H,W,N;
	cin >> H >> W >> N;

	if (H > W) {
		ans =  N / H ;
		if (N%H != 0) {
			cout << ans + 1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	else {
		ans = N / W;
		if (N%W != 0) {
			cout << ans + 1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}

	return 0;
}


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

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

    switch(x%7){
    case 0:
        cout << "thu" << endl;
        break;
    
    case 1:
        cout << "fri" << endl;
        break;

    case 2:
        cout << "sat" << endl;
        break;

    case 3:
        cout << "sun" << endl;
        break;

    case 4:
        cout << "mon" << endl;
        break;
    
    case 5:
        cout << "tue" << endl;
        break;
    
    case 6:
        cout << "wed" << endl;
        break;
    
    default:
        break;
    }

    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

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

Measured memory_bytes: 128
K, A, B = map(int, input().split())

if B - A >= 2:
    n_0 = A - 1
    n_1 = (K - n_0) // 2
    ans = 1 + n_1 * (B - A) + (K - 2 * n_1) * 1
else:
    ans = 1 + K

print(ans)

Measured memory_bytes: 2940
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

for _ in range(II()):
    n=II()
    ff=[]
    bb=[]
    ans=0
    for _ in range(n):
        k,l,r=MI()
        if l>r:ff.append((k,l,r))
        elif l<r:bb.append((n-k,l,r))
        else:ans+=r

    ff.sort()
    hp=[]
    for i,(k,l,r) in enumerate(ff):
        heappush(hp,l-r)
        ans+=l
        if i+1<len(ff) and ff[i+1][0]==k:continue
        while len(hp)>k:
            d=heappop(hp)
            ans-=d

    bb.sort()
    hp = []
    for i, (k, l, r) in enumerate(bb):
        heappush(hp, r-l)
        ans += r
        if i + 1 < len(bb) and bb[i + 1][0] == k: continue
        while len(hp) > k:
            d = heappop(hp)
            ans -= d

    print(ans)

Measured memory_bytes: 42440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

vector<string> S(100010);  // mod kごとにわける

int main() {
    ll n;
    string s1,s2;
    cin >> n;
    cin >> s1 >> s2;
    ll ans;
    if(s1[0] == s2[0]){  // 最初縦が同じ
        ans = 3;
        for (int i = 1; i < n; ++i) {
            if(s1[i-1] == s2[i-1] && s1[i] == s2[i]) ans *= 2,ans %= mod;  // 縦縦
            else if(s1[i-1] == s2[i-1] && s1[i] != s2[i]){     // 縦横
                ans *= 2,ans %= mod;
                i++;
            }else if(s1[i-1] != s2[i-1] && s1[i] == s2[i]){  // 横縦
                ans *= 1;
            }else if(s1[i-1] != s2[i-1] && s1[i] != s2[i]){  // 横横
                ans *= 3,ans %= mod;
                i++;
            }
        }
    }
    else{    // 最初横同じ
        ans = 6;
        for (int i = 2; i < n; ++i) {
            if(s1[i-1] == s2[i-1] && s1[i] == s2[i]) ans *= 2,ans %= mod;  // 縦縦
            else if(s1[i-1] == s2[i-1] && s1[i] != s2[i]){     // 縦横
                ans *= 2,ans %= mod;
                i++;
            }else if(s1[i-1] != s2[i-1] && s1[i] == s2[i]){  // 横縦
                ans *= 1;
            }else if(s1[i-1] != s2[i-1] && s1[i] != s2[i]){  // 横横
                ans *= 3,ans %= mod;
                i++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e3 + 10;
const int inf = 0x3f3f3f3f;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
  int n; cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  vector<int> l(n + 1);
  vector<int> r(n + 1);
  l[1] = a[1]; r[n] = a[n];
  for (int i = 2; i <= n; ++i){
    l[i] = __gcd(l[i-1], a[i]);
  }
  for (int i = n - 1 ; i > 0; --i){
    r[i] = __gcd(r[i+1], a[i]);
  }

  int ma = max(r[2], l[n-1]);
  for (int i = 2; i <= n - 1; ++i)
    ma = max(ma, __gcd(l[i-1], r[i+1]) );
  cout << ma;
return 0;
}



Measured memory_bytes: 1408
def main():
    N = int(input())
    inp = [list(map(int, input().split())) for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmax = 10 ** 10
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        ha = 0
                        break
                    if ha:
                        if ht != ha:
                            ha = 0
                            break
                    else:
                        ha = ht
            
            if 0 < ha <= hmax:
                print(cx, cy, ha)
                exit()


if __name__ == "__main__":
    main()

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int a,b;
  cin>>a>>b;
  char A=(char)('0'+a);
  char B=(char)('0'+b);
  string BB="";
  for(int i=0;i<a;i++){
    BB+=B;
  }
  string AA="";
  for(int i=0;i<b;i++){
    AA+=A;
  }
  cout<<min(AA,BB)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node_ {int parent,left,right; };
typedef struct Node_ Node;

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

void setDepth(int u, int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0;
  int h2=0;
  if(T[u].left != NIL){
    h1=setHeight(T[u].left)+1;
  }
  if(T[u].right != NIL){
    h2=setHeight(T[u].right)+1;
  }
  return H[u]=(h1 > h2 ? h1:h2);
}

int getSibling(int u){
  if(T[u].parent == NIL){
    return NIL;
  }
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
    return T[T[u].parent].right;
  }
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg=0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left==NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l != NIL){
      T[l].parent=v;
    }
    if(r != NIL){
      T[r].parent=v;
    }
  }

  for(i=0;i<n;i++){
    if(T[i].parent == NIL){
      root=i;
    }
  }

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



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

#define INF 1e9
using namespace std;

int main() {

    int H, W; cin >> H >> W;

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

    vector<string> temp;
    for (int i = 0; i < H; ++i) {
        bool line = true;
        for (int j = 0; j < W; ++j) {
            if (S[i][j] != '.') {
                line = false;
            }
        }

        if (!line) {
            temp.push_back(S[i]);
        }
    }

    vector<string> ans(temp.size());
    for (int j = 0; j < W; ++j) {
        bool line = true;
        for (int i = 0; i < temp.size(); ++i) {
            if (temp[i][j] != '.') {
                line = false;
            }
        }

        if (!line) {
            for (int i = 0; i < temp.size(); ++i) {
                ans[i].push_back(temp[i][j]);
            }
        }
    }

    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
import fractions
def count(n, m, l):
    c_m = n // m
    c_l = n // l
    c_ml = n // (m * l // fractions.gcd(m, l))
    return n - (c_m + c_l - c_ml)

a, b, c, d = map(int, input().split())
b_tar = count(b, c, d)
a_tar = count(a, c, d)
is_plus_a = not(bool(a % c == 0 or a % d == 0))
ans = b_tar - a_tar
if is_plus_a: ans += 1
print(ans)

Measured memory_bytes: 5048
n=int(input())
a=list(map(int, input().split()))
ans=0
d={}
for ai in a:
    if ai in d:
        d[ai]+=1
    else:
        d[ai]=1
for k, v in d.items():
    if k>v:
        ans+=v
    elif k<v:
        ans+=v-k
print(ans)

Measured memory_bytes: 17780
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void)
{
    int n;

    cin >> n;

    int count = 0;
    int ans = 0;
    int before = 0;
    for (int i = 3; i <= n; i+=2) {
        count = 0;
        for (int j = 1; j <= i/2; j+=2) {
            if (j == before) {
                break;
            }
            if (i % j == 0) {
                if (i/j == j) {
                    count++;
                }
                else {
                    count += 2;
                }
                before = i/j;
            }
        }
        if (count == 8) {

            ans++;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Field{
	StringBuilder map;
	int width;
	int height;
	
	Field(int w,int h, String[] buf) throws IOException{
		width = w;
		height= h;
		map= new StringBuilder();
		StringBuilder edge= new StringBuilder();
		for(int i=0;i<w+2;i++){
			edge.append("#");
		}
		map.append(edge);
		for(int i=0;i<h;i++){
			map.append("#");
			map.append(buf[i]);
			map.append("#");
		}
		map.append(edge);
	}
	
	int point2int(int x, int y){
		return (width+2)*y + x;
	}
	int int2x(int n){
		return n%(width+2);
	}
	int int2y(int n){
		return n/(width+2);
	}
	
	int[] neighbor(int x, int y){
		int[] neib= {point2int(x,y-1),point2int(x-1,y),point2int(x+1,y),point2int(x,y+1)};
		return neib;
	}
	int[] neighbor(int n){
		int x= int2x(n); int y= int2y(n);
		int[] neib= {point2int(x,y-1),point2int(x-1,y),point2int(x+1,y),point2int(x,y+1)};
		return neib;
	}

	char charAt(int x, int y){
		return map.charAt(point2int(x,y));
	}
	char charAt(int n){
		int x= int2x(n); int y= int2y(n);
		return map.charAt(point2int(x,y));
	}
	
	int countRange(){
		int cnt=0;
		for(int i=0;i<map.length();i++){
			if( map.charAt(i)=='@' ){ cnt++; }
		}
		return cnt;
	}
	
	void traverse(){
		Deque<Integer> dfs= new LinkedList<Integer>();
		dfs.push(map.indexOf("@"));
		while( !dfs.isEmpty() ){
			int tmp  = dfs.peek();
			boolean reached= true;
			for(int i=0;i<4;i++){
				int next= neighbor(tmp)[i];
				if( charAt(next)=='.' ){
					map.setCharAt(next, '@');
					dfs.push(next);
					reached= false;
				}
			}
			if(reached){ dfs.pop(); }
		}

		System.out.println(countRange());
	}
}

public class Main{
    public static void main(String args[]) throws Exception{
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	int width,height;
    	while(true){
    		String[] buf= br.readLine().split(" ");
    		width = Integer.parseInt(buf[0]);
    		height= Integer.parseInt(buf[1]);
    		if( width!=0 || height!=0 ){
    			String[] buf_map= new String[height];
    			for(int i=0;i<height;i++){
    				buf_map[i]= br.readLine();
    			}
    			Field f= new Field(width,height,buf_map); 
    			f.traverse();
    		} else{ break; }
    	}
    }
}

Measured memory_bytes: 27196
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        int tapi,tapu;
        cin >> tapi >> tapu;
        double ans = 1.0 * tapi / tapu;
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
n,m=map(int,input().split())
li=[]
city_counter = [1] * (10**5+2)
ans=[]

for i in range(m):
    p,y=map(int,input().split())
    li.append((p,y,i))

li.sort(key=lambda x:x[1])

for i in range(m):
    tmp = str(li[i][0]).zfill(6) + str(city_counter[li[i][0]]).zfill(6)
    ans.append((tmp,li[i][2]))
    city_counter[li[i][0]] += 1

ans.sort(key=lambda x:x[1])

for i in range(m):
    print(ans[i][0])


Measured memory_bytes: 36244
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 200005;
int n, fa[maxn], sg[maxn], pos = 1, tot, maxi = -1, mini = 0x3f3f3f3f;
bool vis[maxn], bucket[maxn];
vector<int> e[maxn];
void dfs(int u) {
	for(auto v : e[u]) 
		if(!vis[v]) dfs(v);
	for(auto v : e[u])
		if(!vis[v]) bucket[sg[v]] = true;
	while(bucket[sg[u]]) ++sg[u];
	for(auto v : e[u])
		if(!vis[v]) bucket[sg[v]] = false;
}
int main() {
	ios :: sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> fa[i], e[fa[i]].push_back(i);
	while(!vis[pos]) vis[pos] = true, pos = fa[pos];
	memset(vis, 0, sizeof vis);
	while(!vis[pos]) vis[pos] = true, pos = fa[pos], ++tot;
	if(tot & 1) for(int i = 1; i <= n; ++i)
		if(vis[i]) dfs(i), maxi = max(maxi, sg[i]), mini = min(mini, sg[i]);
	puts(tot & 1 and maxi == mini ? "IMPOSSIBLE" : "POSSIBLE");
}

Measured memory_bytes: 12160
import sys
N,K,Q = (int(x) for x in input().split(" "))
result = [0]*N

for i in range(0, Q):
    result[int(input())-1] += 1
# #A = [int(x) for x in input().split()]
for i in range(0, len(result)):
    if ((K-Q+result[i])<=0):
        print("No")
    else:
        print("Yes")

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

int main() {
	int a[3];
	int i;
	int sum_task= 0;

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	sum_task = abs(a[1] - a[0]) + abs(a[2] - a[1]);

	cout << sum_task << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,u,v,ver[N*2],nxt[N*2],head[N],tot,du[N],dv[N],ans=0;
int read(){
    int x=0,c;
    while(!isdigit(c=getchar()));
    while(isdigit(c))x=x*10+c-48,c=getchar();
    return x;
}
void add(int x,int y){ver[++tot]=y;nxt[tot]=head[x];head[x]=tot;}
void dfs(int x,int ff,int *d){
    d[x]=d[ff]+1;
    for(int i=head[x],y;i;i=nxt[i])
        if((y=ver[i])!=ff)dfs(y,x,d);
}
void dfs2(int x,int ff){
    ans=max(ans,dv[x]-1);
    for(int i=head[x],y;i;i=nxt[i]){
        if((y=ver[i])==ff||du[y]>=dv[y])continue;
        dfs2(y,x);
    }
}
int main(){
    // freopen("test.in","r",stdin);
    n=read();u=read();v=read();
    for(int i=1,x,y;i<n;i++){
        x=read();y=read();
        add(x,y);add(y,x);
    }
    du[0]=dv[0]=-1;
    dfs(u,0,du);dfs(v,0,dv);
    dfs2(u,0);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 6784
import java.util.Scanner;

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

  while (in.hasNext()) {
	int n = in.nextInt();
	int[] pre = new int[n];
	int[] now = new int[n];
	int max = 0;
	for (int line = 0; line < n; line++) {
	  String str = in.next();
	  for (int posi = 0; posi < str.length(); posi++) {
		final int pp;
		if (str.charAt(posi) == '*') {
		  pp = 0;
		} else {
		  final int uppr = pre[posi];// Upper
		  final int lfet;// Left
		  final int uplf;// upper-left
		  if (posi != 0) {
			lfet = now[posi - 1];
			uplf = pre[posi - 1];
		  } else {
			lfet = uplf = 0;
		  }
		  pp = Math.min(Math.min(uppr, lfet), uplf) + 1;
		}
		now[posi] = pp;
		max = Math.max(max, pp);
	  }
	  if (line < n - 1) {
		int[] buf = pre;
		pre = now;
		now = buf;
	  } else {
		System.out.println(max);
	  }
	}
  }
}
}

Measured memory_bytes: 12000
#include<iostream>
#include<cstring>
using namespace std;
#define ll long long int 
const ll M= 1e9 + 7;
ll dp[2005];
ll solve(int n){
	if(n==0)return 1ll;
	else if(n==1 || n==2)return 0ll;
	else if(n>=3 && n<=5)return 1ll; 
	else if(dp[n]!=-1)return dp[n];
	else{ 
		ll total=0;
		for(int i=3;i<=n;i++){
		if(n-i>=0){
			total = (total%M + solve(n-i)%M)%M; 
		}
	}
	return dp[n]=total;
	}
}
int main(){
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	dp[0]=1;
	cout<<solve(n);
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<utility>
#include<map>
#define h first
#define w second
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 202;
const int origin_h = MAX_N, origin_w = MAX_N;

bool is_exist[2 * MAX_N][2 * MAX_N];

void solve(int N) {
    for (int i = 0; i < 2 * MAX_N; i++) {
        for (int j = 0; j < 2 * MAX_N; j++) {
            is_exist[i][j] = false;
        }
    }
    is_exist[origin_h][origin_w] = true;
    map<int, P> pos;
    pos[0] = P(origin_h, origin_w);
    int n, d;
    for (int i = 0; i < N - 1; i++) {
        cin >> n >> d;
        int adj_h = pos[n].h, adj_w = pos[n].w;
        if (d == 0) adj_w--;
        else if (d == 1) adj_h++;
        else if (d == 2) adj_w++;
        else adj_h--;
        is_exist[adj_h][adj_w] = true;
        pos[i + 1] = P(adj_h, adj_w);
    }
    int min_h = 3 * MAX_N, max_h = -1, min_w = 3 * MAX_N, max_w = -1;
    for (int i = 0; i < 2 * MAX_N; i++) {
        for (int j = 0; j < 2 * MAX_N; j++) {
            if (is_exist[i][j]) {
                min_h = min(min_h, i);
                max_h = max(max_h, i);
                min_w = min(min_w, j);
                max_w = max(max_w, j);
            }
        }
    }
    cout << max_w - min_w + 1 << ' ' << max_h - min_h + 1 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> part(N);
    for (int i = 0; i < Q; ++i)
    {
        int temp;
        cin >> temp;
        part[temp - 1] += 1;
    }

    for (int i = 0; i < N; ++i)
    {
        if (part[i] + K - Q > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

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

	int32_t count{ 3 };
	if (a == b) --count;
	if (a == c) --count;
	if (count != 1 && b == c) --count;

	cout << count << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int age[7], n, i, a;
	while (~fscanf(stdin, "%d", &n), n != 0) {
		memset(age, 0, sizeof(age));
		for (i = 0; i < n; i++) {
			fscanf(stdin, "%d", &a);
			if (a >= 60) a = 60;
			age[a / 10]++;
		}
		for (i = 0; i < 7; i++) fprintf(stdout, "%d\n", age[i]);
	}
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main() {
  int ans = 0;
  char buf[10];
  
  scanf("%s", buf);
  
  if (buf[0] == '2') ans++;
  if (buf[1] == '2') ans++;
  if (buf[2] == '2') ans++;
  if (buf[3] == '2') ans++;
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  bool CAN=false;
  
  for(ll i=0; i<N; ++i){
    if(A+(N-1-i)*C-i*D<=B && B<=A-i*C+(N-1-i)*D) CAN=true;
  }
  
  if(CAN) COYE;
  else CONO;
  return 0;
}

Measured memory_bytes: 256
l = [int(input()) for i in range(5)]
min = 9
min_index = 0
sum = 0
for i in range(len(l)):
    if l[i] % 10 != 0 and l[i] % 10 < min:
        min = l[i] % 10
        min_index = i
for i in range(len(l)):
    if i != min_index:
        sum += (l[i] + 9) // 10 * 10
sum += l[min_index]
print(sum)

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

int N;
set<pair<int,int> > st;
vector<pair<int,int> > ans;

int main()
{
    scanf("%d",&N);

    for(int i = 1; i < N; i += 3)
    {
        for(int j = 1 - (i % 2); j < N; j += 2)
        {
            st.insert(mk(j,i));
            ans.push_back(mk(j,i));
        }
    }

    for(int i = 0; i < N; i++)
    {
        if(i % 2 == 0)continue;
        if(st.count(mk(0,i)))continue;
        ans.push_back(mk(0,i));
        st.insert(mk(0,i));
    }
    for(int i = 0; i < N; i++)
    {
        if((i + N - 1) % 2 == 0)continue;
        if(st.count(mk(i,N - 1)))continue;
        ans.push_back(mk(i,N - 1));
        st.insert(mk(i,N - 1));
    }

    printf("%d\n",ans.size());
    for(int i = 0; i < ans.size(); i++)
    {
        printf("%d %d\n",ans[i].fi,ans[i].se);
    }
    return 0;
}


Measured memory_bytes: 10608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S1,S2;
    cin >> S1 >> S2;
    // ■     ■■
    // ■　or □□　のどちらか
    vector<int> ptn;
    for(int i=0;i<N;i++){
        if(S1[i]==S2[i]){
            ptn.push_back(1);
        }else{
            ptn.push_back(2);
            i++;
        }
    }
    ll ans = 1;
    for(int i=0;i<ptn.size();i++){
        if(i==0){
            if(ptn[0]==1){
                ans*=3;
                ans%=MOD;
            }else{
                ans*=6;
                ans%=MOD;
            }
        }else{
            if(ptn[i]==1){
                if(ptn[i-1]==1){
                    ans*=2;
                    ans%=MOD;
                }else{
                    ans*=1;
                }
            }else{
                if(ptn[i-1]==1){
                    ans*=2;
                    ans%=MOD;
                }else{
                    ans*=3;
                    ans%=MOD;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
   int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
       {
       cin>>arr[i];

       }
   int ans=INT_MAX;
   for(int i=0;i<=n-k;i++)
   {
       int l=arr[i];
       int r=arr[i+k-1];
       ans=min(ans,min(abs(l)+abs(r-l),abs(r)+abs(r-l)));


   }
   cout<<ans;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    int N, K; cin >> N >> K;
    vector<int> su(N + 1);
    for (int i = 0; i < K; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int a; cin >> a;
            su[a]++;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (su[i] == 0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
char a[1010][1010];
int ans[1010][1010];
int main(){
	vector<pair<int,int> > v;
	memset(ans,0,sizeof(ans));
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
			if(a[i][j]=='#')v.push_back(make_pair(i,j));
		}
	}
	for(int i=0;i<v.size();i++){
		int x=v[i].first;
		int y=v[i].second;
		for(int i=0;i<4;i++){
			int ax=x+dx[i];
			int ay=y+dy[i];
			if(ax>=0&&ax<n&&ay>=0&&ay<m&&a[ax][ay]=='.'){
				a[ax][ay]='#';
				v.push_back(make_pair(ax,ay));
				ans[ax][ay]=ans[x][y]+1;
			}
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cnt=max(cnt,ans[i][j]);
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 14956
#include <iostream>
using namespace std;
 
int main() {
	int a, b;
	int ans;
	cin >> a >> b;

	if (a > b) {
		ans = 2 * a - 1;
	}
	else if (b > a) {
		ans = 2 * b - 1;
	}
	else {
		ans = a + b;
	};

	cout << ans << endl;

}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int a, b, c;

int main(){
  cin >> a >> b >> c;
  if(a + b + c >= 22){
    cout << "bust" <<endl;
  }else{
    cout <<"win" <<endl;
  }
}



Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
a = []
for i in range(n-1):
    if h[i] >= h[i+1]:
        a.append(1)
    else:
        a.append(0)

c = ''.join(map(str,a))
d = c.split('0')
m = [x for x in d if x]
if m == []:
    print(0)
    exit()
e = max(map(int,m))
f = len(str(e))
print(f)



Measured memory_bytes: 15020
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<vector<bool>> food(N, vector<bool>(M, false));
  for (auto i = 0; i < N; i++) {
    ll k;
    cin >> k;
    for (auto j = 0; j < k; j++) {
      ll x;
      cin >> x;
      food[i][x-1] = true;
    }
  }
  ll res = 0;
  for (auto j = 0; j < M; j++) {
    bool valid = true;
    for (auto i = 0; i < N; i++) valid &= food[i][j];
    if (valid) res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    int S, h, m, s;
    cin >> S;
    
    h=S/3600;
    m=(S-3600*h)/60;
    s=S%60;
    
    cout << h; //余り
    cout << ":"; //コロン
    cout << m;
    cout << ":";
    cout << s;
    
    cout << endl; 
}


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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  vi s;
  int n, m;
  int a, b;
 
  cin>> n;
  for(int i=0;i<n;i++){
    cin>> a>> b;
    s.pb(60*a+b);
  }

  cin>> m;
  for(int i=0;i<m;i++){
    cin>> a>> b;
    s.pb(60*a+b);
  }

  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  for(int i=0;i<s.size();i++){
    if( i ) cout<< " ";
    printf("%d:%02d",s[i]/60,s[i]%60);
  }
  cout<< endl;
}

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

int main() {
	int n, a[100], i, j, flag, hoge, counta = 0;
	cin >> n;
	for (i = 0; i < n; i++)cin >> a[i];
	flag = 1;
	while (flag) {
		flag = 0;
		i = 0;
		for (j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				hoge = a[j];
				a[j] = a[j - 1];
				a[j - 1] = hoge;
				flag = 1;
				counta++;
			}
		}
		i++;
	}
	for (i = 0; i < n; i++) {
		if (i > 0)cout << " ";
		cout << a[i];
	}
	cout << endl << counta << endl;
}


Measured memory_bytes: 3100