akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>


#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector<vector<int>> A(N, vector <int>(N-1));
	for (int ii = 0; ii < N; ++ii){
		for (int jj = 0; jj < N-1; ++jj){
			int idx = N-2-jj;
			cin >> A[ii][idx];
			A[ii][idx]--;
		}
	}

	int ans = 0;
	while (true) {
		//処理
		vector <int> skip(N, 0);
		bool OK = false;
		bool allZero = true;
		for (int ii = 0; ii < N; ++ii){
			if (A[ii].size() == 0){
				skip[ii] = 1;
			} else {
				allZero = false;
			}
			if (skip[ii] == 1){
				continue;
			}

			int teki = A[ii].back();
			if ( (A[teki].back() == ii) && (skip[teki] == 0) ){
				OK = true;
				A[ii].pop_back();
				A[teki].pop_back();
				skip[ii] = 1;
				skip[teki] = 1;
			}
		}

		if (allZero){
			break;
		}
		ans++;
		if (OK == false){
			ans = -1;
			break;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c-a-b < 0){
        cout<<"No";
        return 0;
    }
    YN(4*a*b < (c-a-b)*(c-a-b));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  rep(i,10000) {
    if (floor(i * 0.08) == a and floor(i*0.10) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import math as m

def main(**kwargs):
    r = -1

    if n > 1:
        for i in range(10 ** n - 1, 10 ** (n - 1) - 1, -1):
            stri = str(i)
            flg = True

            for s, c in zip(S, C):
                if stri[s-1] != str(c):
                    flg = False
        
            if flg:
                r = i

    else:
        for i in range(9, -1, -1):
            stri = str(i)
            flg = True

            for s, c in zip(S, C):
                if stri[s-1] != str(c):
                    flg = False
        
            if flg:
                r = i
    
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, m, *_ = cin

    S = np.zeros(m, dtype="int")
    C = np.zeros(m, dtype="int")

    for i in range(m):
        cin = np.array(input().split(" ")).astype("int")
        S[i], C[i] = np.array(cin)
    
    cout = main(n=n, m=m, S=S, C=C)
    print(cout)

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

Measured memory_bytes: 1024
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

int main(int argc, const char * argv[]) {
    ll N ;
    cin >> N;
    
    vector<ll> A(N);
    A[0] = 0;
    for(ll i=1;i<N;i++){
        cin >> A[i];
        A[i]--;
    }
    
    vector<ll> buka(N,0);
    
    for(ll i=1 ; i<N;i++){
        buka[A[i]]++;
    }
    for(ll i=0;i<N;i++){
        cout << buka[i] << endl;
    }

    return 0;
    
}




Measured memory_bytes: 6340
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [n, x, t] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ ((n - 1) `div` x + 1) * t

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

int main() {
  int a, b, c, swap;
  cin >> a >> b >> c;
  if (a > b) { swap = a; a = b; b = swap; }
  if (b > c) { swap = b; b = c; c = swap; }
  if (a > b) { swap = a; a = b; b = swap; }
  cout << a << " " << b << " " << c << endl;
}



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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t quotient = N / (A + B);
  int64_t remainder = N % (A + B);
  
  int64_t ans = 0;
  ans += A * quotient;
  if (remainder <= A) {
    ans += remainder;
  }
  else {
    ans += A;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	long double sx, sy, gx, gy;
	long double x[2000] = {};
	long double y[2000] = {};
	long double r[2000] = {};
	long double dis[2000] = {};
	cin >> sx >> sy >> gx >> gy;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[0] = sx;
	y[0] = sy;
	r[0] = 0;
	x[N+1] = gx;
	y[N+1] = gy;
	r[N+1] = 0;
	for (int i = 1; i <= N+1; i++) {
		dis[i] = 10000000000;
	}
	priority_queue<pair<long double, int>, vector<pair<long double, int>>, greater<pair<long double, int>>>PQ;
	PQ.push({ 0,0 });
	while (!PQ.empty()) {
		long double c = PQ.top().first;
		int cn = PQ.top().second;
		PQ.pop();
		if (dis[cn] < c)continue;
		for (int i = 1; i <= N + 1; i++) {
			if (dis[i] > dis[cn] + max((long double)0, sqrt((x[i] - x[cn])*(x[i] - x[cn]) + (y[i] - y[cn])*(y[i] - y[cn])) - r[i] - r[cn])) {
				dis[i] = dis[cn] + max((long double)0, sqrt((x[i] - x[cn])*(x[i] - x[cn]) + (y[i] - y[cn])*(y[i] - y[cn])) - r[i] - r[cn]);
				PQ.push({ dis[i], i });
			}
		}
	}
	cout << setprecision(15) << dis[N + 1] << endl;
	return 0;
}


Measured memory_bytes: 9964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin>>N;cin.ignore();
    string S;
    getline(cin,S);
    int K;
    cin>>K;
    char not_rep_char;
    not_rep_char=S[K-1];
    for(int i=0;i<N;i++){
        if(S[i]==not_rep_char){
            cout<<not_rep_char;
        }else{
            cout<<"*";
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
# N = int(input())


N, K = [int(i) for i in input().split()]
h = [0] + [int(i) for i in input().split()]
INF = 10 ** 9
dp = [INF for i in range(N+1)]
dp[1] = 0
for j in range(1, N+1):
    for i in range(1, K+1):
        if j > i:
            dp[j] = min(dp[j], dp[j-i] + abs(h[j] - h[j-i]))

print(dp[N])




Measured memory_bytes: 57312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int K = Integer.parseInt(lines[0]);
		int X = Integer.parseInt(lines[1]);

		int min = X - K + 1;
		int max = X + K - 1;
		for(int i = min; i <= max ;i++) {
			if(i == max) {
				System.out.println(i);
			}else {
				System.out.print(i + " ");
			}
		}
	}

}


Measured memory_bytes: 38264
S, N = map(int, input().split())
A = list(map(int, input().split()))
O = [a for a in A if a % 2 == 1]
E = [a for a in A if a % 2 == 0]

if len(O) > 2:
    print("Impossible")
else:
    A = O[:min(len(O), 1)] + E + O[min(1, len(O)):]
    B = A[:] + ([0] if len(A) == 1 else [])
    B[0] -= 1
    B[-1] += 1
    if B[0] == 0:
        B = B[1:]
    print(" ".join(str(a) for a in A))
    print(len(B))
    print(" ".join(str(b) for b in B))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    int x,y,z;
    while(n--){
        cin>>x>>y>>z;
        x = max(b,c)+x;
        y = max(a,c)+y;
        z = max(a,b)+z;
        a = x;
        b = y;
        c = z;
    }
    cout<<max(max(a,b),c)<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};

//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!
int wwa[2000000], bwa[2000000];

signed main() {
	int A, B, T;
	cin >> A >> B >> T;
	cout << T / A * B << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

int main() 
{
    string s,t; cin >> s >> t;
    
    rep(i, s.size()) {
        s = s.substr(s.size()-1,1) + s.substr(0, s.size()-1);
        if(s == t) { cout << "Yes" << endl; return 0; }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# lang: Ruby(2.3.3)
# submission # - User: herp_sy
# https://atcoder.jp/contests/
# ------------------------------------------------------------

s = gets.split('')
t = gets.split('')

cnt = 0
for i in 0..2 do
	if s[i] == t[i]
		cnt += 1
	end
end

p cnt


Measured memory_bytes: 1788
import copy
n=int(input())
k=[0]*n
for i in range(n):
    k[i]=list(map(int,input().split()))
dp=[[0]*3]*n
dp[0]=copy.deepcopy(k[0])
for i in range(n-1):
    dp[i+1]=[copy.deepcopy(max(dp[i][1],dp[i][2]))+copy.deepcopy(k[i+1][0]),copy.deepcopy(max(dp[i][2],dp[i][0]))+copy.deepcopy(k[i+1][1]),copy.deepcopy(max(dp[i][1],dp[i][0]))+copy.deepcopy(k[i+1][2])]
print(max(dp[n-1]))


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

int main(){
	int a,b,c;
	cin >> a >>b;
	if(a> b){
		c=b;
		b=a;
		a=c;
	}

	for(int i = 0;i<b;i++){
		cout << a;
	}
  
}

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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();

            Console.WriteLine((n*(n+1))/2);
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
  
#define MAX 100
#define INF 100000000
#define white 0
#define gray 1
#define black 2
  
typedef struct{
  int data[MAX];
  int head;
  int tail;
}queue;
  
queue Q;
  
int n,d[MAX] = {INF};
int g[MAX][MAX] = {0};
int color[MAX] = {white};
  
void bfs(int);
void enqueue(int);
int dequeue(void);
  
int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u-1][v-1] = 1;
    }
  }
  for(i=0;i<n;i++)
    d[i] = INF;
  
  bfs(0);
  
  for(i=0;i<n;i++){
    if(d[i] == INF)printf("%d %d\n",i+1,-1);
    else printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}
  
void bfs(s){
  int v,u;
  
  d[s] = 0;
  color[s] = gray;
  Q.head = Q.tail = 0;
  enqueue(s);
  
  while(Q.tail < n){
    u = dequeue();
    if(u == INF)break;
    for(v=0;v<n;v++){
      if(g[u][v] == 0)continue;
      if(color[v] == white){
    d[v] = d[u] + 1;
    color[v] = gray;
    enqueue(v);
      }
    }
    color[u] = black;
  }
}
  
void enqueue(int s){
  
  if(Q.tail >= n)return;
    
  Q.data[Q.tail] = s;
  Q.tail++;
}
  
int dequeue(){
  int s;
  
  if(Q.head == Q.tail)return INF;
  
  s = Q.data[Q.head];
  Q.head++;
  
  return s;
}

Measured memory_bytes: 636
<?php
$a = explode(' ', trim(fgets(STDIN)));
$b = explode(' ', trim(fgets(STDIN)));
fscanf(STDIN, "%d", $t);

$dis = abs($b[0] - $a[0]);
$dis_a = bcmul($a[1], $t);
$dis_b = bcadd($dis, bcmul($b[1], $t));

if ($dis_a >= $dis_b) {
  echo 'YES';
} else {
  echo 'NO';
}


Measured memory_bytes: 16080
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

#ifdef DEBUG
#define NDEBUG
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 11
char _buf[INTSPACE*1000000 + 3];  // ここ要確認

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

int solve(int N, vector<int>& a) {
    rep(i, N) --a[i];
    int sw = 0;

    int i=0;
    while (i < N-3) {
        if (a[i] != i) { ++i; continue; }
        if (a[i] == i) { ++sw; i+=2; }
    }
    assert(i==N-2 || i==N-3);
    if (i == N-2) {
        if (a[N-2] == N-2 || a[N-1] == N-1) ++sw;
    } else if (i == N-3) {
        if (a[i] == N-3) {
            ++sw;
            if (a[N-1] == N-1) ++sw;
        } else {
            if (a[N-2] == N-2 || a[N-1] == N-1) ++sw;
        }

    }
    return sw;
}

int main() {
    int N = loadint();
    vector<int> a;
    loadvec(a, N);
    int ans = solve(N, a);
    cout << ans << endl;
    return 0;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  for(int A = 1; A <= 9; ++A) {
    int B = N / A;
    if(N % A == 0 and B <= 9) {
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,a[200001],b[200001],i,j,s,t,i_,j_,c,d;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=n;i>=1;i--)
        cin>>b[i];
    for(i=1;i<=n;i++)
        if(a[i]==b[i])
            break;
    for(j=n;j>=1;j--)
        if(a[j]==b[j])
            break;
    s=j-i+1;
    t=a[i];
    for(i_=1;i_<i;i_++)
    {
        if(a[i_]!=t)
            c++;
    }
    for(j_=j+1;j_<=n;j_++)
    {
        if(b[j_]!=t)
            c++;
    }
    if(c<s)
        cout<<"No"<<endl;
    else
    {
        d=i;
        if(d!=n+1)
        for(i=1;i<=n;i++)
        {
            if(s==0)
                break;
            if(a[i]!=t&&b[i]!=t)
            {
                swap(b[i],b[d]);
                d++;
                s--;
            }
        }
        cout<<"Yes"<<endl;
        for(i=1;i<=n;i++)
            cout<<b[i]<<" ";
        cout<<endl;
    }
    //system("pause");
    return 0;
}


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

int main()
{
	int n; cin >> n;
	set<string> st;

	string s;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		st.insert(s);
	}
	
	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  ll n,t;
  cin>>n>>t;

  vector<ll> p(n);
  rep(i,n) cin>>p[i];

  ll mi=INF;
  ll ri=0;
  rep(i,n){
    chmax(ri,p[i]-mi);
    chmin(mi,p[i]);
  }

  mi=INF;
  ll ans=0;
  rep(i,n){
    if(p[i]-mi==ri) ans++;;
    chmin(mi,p[i]);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3972
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();

    let mut ds = String::new();
    stdin().read_line(&mut ds).unwrap();
    let mut ds: Vec<usize> = ds.trim().split_whitespace().flat_map(str::parse).collect();

    ds.sort();
    println!("{}", ds[n/2] - ds[n/2 - 1]);
}


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

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

    bool front = true;
    deque<char> dq;
    for (auto c : s) {
        dq.push_back(c);
    }

    int q;
    cin >> q;

    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            front = !front;
        } else {
            int f;
            char c;
            cin >> f;
            cin >> c;
            if (f == 1) {
                if (front) dq.push_front(c);
                else dq.push_back(c);
            } else {
                if (front) dq.push_back(c);
                else dq.push_front(c);
            }
        }
    }

    if (front) {
        while (!dq.empty()) {
            cout << dq.front();
            dq.pop_front();
        }
    } else {
        while (!dq.empty()) {
            cout << dq.back();
            dq.pop_back();
        }
    }
    cout << endl;
}

Measured memory_bytes: 896
n,k = map(int, input().split())
p = list(map(int, input().split()))

p_sum = [0] * (n + 1)

for i in range(n):
    p_sum[i+1] = p_sum[i] + p[i]

ans = 0
for i in range(n - k  + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)

Measured memory_bytes: 24556
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, U, V;
vector<int> g[112345];
int d[2][112345];

void dfs(int u, int par, int idx) {
	for (int v : g[u]) {
		if (v == par) continue;
		d[idx][v] = d[idx][u] + 1;
		dfs(v, u, idx);
	}
}

int main() {
	cin >> N >> U >> V;
	U--; V--;
	
	REP(i, N - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	dfs(U, -1, 0);
	dfs(V, -1, 1);
	
	int ans = 0;
	REP(i, N) if (g[i].size() == 1) {
		int d1 = d[0][i];
		int d2 = d[1][i];
		if (d1 >= d2) continue;
		chmax(ans, d2 - 1);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 13184
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
double solve(vector<double>r){
	//53124
	int i,j,n=r.size();
	vector<double>s(n);
	for(i=1;i+1<n;i++){s[i]=r[i-1]*r[i+1];}
	s[0]=r[0]*r[1];s[n-1]=r[n-2]*r[n-1];
	if(n==4){return s[0]+s[1]+s[2]+s[3];}
	double bmin=0,bmax=s[0]*s[1]*1.01;
	//角度合計を2pai にする ただし、n=3のみpaiにする。
	double moku=pai*2;
	if(n==3){moku=pai;}
	for(int h=0;h<40;h++){
		double bgen=(bmin+bmax)/2;
		double kak=0;
		for(i=0;i<n;i++){
			double sor=bgen/s[i];
			if(sor<1){kak+=acos(sor);}
		}
		if(kak>moku){bmin=bgen;}
		else{bmax=bgen;}
	}
	//bmaxを採用
	double ans=0;
	for(i=0;i<n;i++){
		double sor=bmax/s[i];
		//cerr<<sor<<endl;
		if(sor<1){ans+=sqrt(1-sor*sor)*s[i];}
	}
	//cerr<<"n="<<n<<"ans="<<ans<<endl;
	return ans;
}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,n;cin>>n;
	double ans=0;
	vector<double>r(n);
	for(i=0;i<n;i++){cin>>r[i];}
	SO(r);REV(r);
	while(r.size()>=3){
		maxeq(ans,solve(r));
		r.pob();
	}
	cout<<ans/2<<endl;
	return 0;
}



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

#ifdef DEBUG
#define ifd if(true)
#else
#define ifd if(false)
#endif

#define dout ifd cerr

#define uint unsigned long long
#define int int64_t

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int mini = min(a, min(b, c));
  int maxi = max(a, max(b, c));
  int midi = a + b + c - mini - maxi;
  cout << (midi - mini) + (maxi - midi);
}


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

vector<int> G[100005];
int dist[2][100005];

int ans = 0;

void dfs(int parent, int cur, int idx) {
  for(auto nx : G[cur]){
    if(nx == parent) continue;
    dist[idx][nx] = dist[idx][cur] + 1;
    dfs(cur, nx, idx);
  }
}

void dfs2(int parent, int cur) {
  if (dist[0][cur]==dist[1][cur]){
    ans = max(ans, dist[1][cur]);
  }
  if (dist[0][cur]<dist[1][cur]){
    ans = max(ans, dist[1][cur]-1);
  }
  for(auto nx : G[cur]){
    if(nx == parent) continue;
    if (dist[0][nx]==dist[1][nx]){
      ans = max(ans, dist[1][nx]);
    }
    if (dist[0][nx]<dist[1][nx]){
      dfs2(cur, nx);
    }
  }
}

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

  int n;cin>>n;
  int u,v;cin>>u>>v;u--,v--;
  for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;a--,b--;
    G[a].push_back(b);G[b].push_back(a);
  }

  dfs(u, u, 0);
  dfs(v, v, 1);
  // for(int i=0;i<n;i++){
  //   cout<<i<<':'<<dist[0][i]<<endl;
  // }
  // for(int i=0;i<n;i++){
  //   cout<<i<<':'<<dist[1][i]<<endl;
  // }
  dfs2(u, u);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12928
/*
 * @Author: Kaizyn
 * @Date: 2020-03-07 22:56:55
 * @LastEditors: Kaizyn
 * @LastEditTime: 2020-03-12 10:22:20
 * @FilePath: \Code\atcoder\abc158E_3.cpp
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 2e5+7;
const int P = 1e5+7;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

int n, m, p;
long long pw10[N], inv[N];
char s[N];

void exgcd(long long a, long long b, long long &d, long long &x, long long &y)
{
    if (!b) d = a, x = 1, y = 0;
    else exgcd(b, a%b, d, y, x), y -= x*(a/b);
}

inline long long mul_inv(const int &a)
{
    long long d, x, y;
    exgcd(a, p, d, x, y);
    return (x%p+p)%p;
}

long long f(const int &l, const int &r)
{
    if (l == r) return (s[l]-'0')%p == 0;
    int mid = (l+r)>>1;
    long long res = 0, now;
    map<long long, int> mp;
    res += f(l, mid)+f(mid+1, r);
    // i <= mid, j > mid
    // s[i, j] = s[i, mid]*pw10[j-mid]+s[mid+1, j]
    // s[i, j]%p == 0 ==> mul inv by two side
    // s[i, mid]+s[mid+1, j]*inv === 0 %p
    now = 0;
    for (int i = mid+1; i <= r; ++i) {
        now = (now*10+s[i]-'0')%p;
        ++mp[now*inv[i-mid]%p];
    }
    now = 0;
    for (int i = mid; i >= l; --i) {
        now = (pw10[mid-i]*(s[i]-'0')+now)%p;
        res += mp[(p-now)%p];
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> p >> (s+1);
    if (p == 2 || p == 5) {
        long long res = 0;
        for (int i = n; i; --i) {
            if ((s[i]-'0')%p == 0) res += i;
        }
        cout << res << endl;
        return 0;
    }
    pw10[0] = inv[0] = 1; inv[1] = mul_inv(10);
    for (int i = 1; i <= n; ++i) pw10[i] = pw10[i-1]*10%p;
    for (int i = 2; i <= n; ++i) inv[i] = inv[i-1]*inv[1]%p;
    cout << f(1, n) << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main (){
while (1){
long n,dset[5000],temp=0,max;
cin>>n;
if (n==0)break;
for (int i=0;i<n;i++){
        cin>>dset[i];
}
max=dset[0];
for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
                temp=temp+dset[j];
                if (max<temp){
                        max=temp;
                }
        }
temp=0;
}
cout<<max<<endl;
}
return 0;
}

Measured memory_bytes: 3100
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  $s=intval($s);

  $ans=[0,0,0];
  for($i=3;$i<=$s;$i++){
    $ans[$i]=1;
    for($j=1;$j<=$i-3;$j++){
      $ans[$i]+=$ans[$j];
      $ans[$i]%=1000000007;
    }
  }

  echo $ans[$s];

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

int A[MAX];

vector<PII> B[MAX];
int DP[MAX][2];

int getLen(int x)
{
	int a = 1;
	int res = 0;
	while(a < x)
	{
		a *= 2;
		res++;
	}

	return res;
}

void add(int ind, int x)
{
	int len = getLen(x);
	if (x == (1<<len))
	{
		B[ind].PB(MP(len, len));
		return;
	}

//	cout<<x<<": "<<len<<endl;

	B[ind].PB(MP(len - 1, len));
	B[ind].PB(MP(len, len - 1));
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);

		add(i, x);
	}

	FOR (i, 0, n)
	{
		DP[i][0] = DP[i][1] = INF;
	}

	DP[0][0] = max(B[0][0].first, B[0][0].second);
	if (SZ(B[0]) > 1)
	{
		DP[0][1] = DP[0][0];
	}

	FOR (i, 0, n)
	{
		FOR (j, 0, SZ(B[i]))
		{
			FOR (k, 0, SZ(B[i+1]))
			{
				DP[i+1][k] = min(DP[i+1][k], DP[i][j] + max(B[i+1][k].first, B[i+1][k].second) - min(B[i][j].second, B[i+1][k].first));
			}
		}
	}

/*	FOR (i, 0, n)
	{
		FOR (j, 0, SZ(B[i]))
		{
			cout<<DP[i][j]<<' ';
		}
		cout<<endl;
	}
	cout<<endl;*/

	int res = INF;
	FOR (i, 0, SZ(B[n-1]))
	{
		res = min(res, DP[n-1][i]);
	}

	cout<<res<<endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll c(max(a / 2 * 25 + (a % 2 ? 13 : 0), b * 10));
    cout << (floor(c * 0.08) == a && floor(c * 0.1) == b ? c : -1) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define ll long long

int main()
{
	int n;
	cin>>n;
	std::vector<ll> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}
	ll t=1;
	for (int i = 0; i < n; ++i)
	{
	     t=lcm(v[i],t);
	}
	cout<<t;
	return 0;
}


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

struct Node{
  int key;
  Node *next;
  Node *prev; 
};

class DoubleLinkedList{
    private:
        Node *nil;
    
    public: DoubleLinkedList(){
        nil = (Node *)malloc(sizeof(Node));
        nil -> next = nil;
        nil -> prev = nil;
    }
    
    public: Node insert(int key){
        Node *x;
        x = (Node *)malloc(sizeof(Node));
        x -> key = key;
        x -> next = nil -> next;
        x -> prev = nil;
        nil -> next -> prev  = x;
        nil -> next = x;
        return *x;
        
    }

        
    public: void deleteN(Node *n){
        if(n == nil) return ;
        n -> prev -> next = n -> next;
        n -> next -> prev = n -> prev;
        free(n);
    }
    
    public: void deleteFirst(){ deleteN(nil -> next); }
    public: void deleteLast(){ deleteN(nil -> prev); }
    
    public: Node* listsearch(int key){
        Node *cur = nil -> next;
        while(cur != nil){
            if(cur -> key == key) return cur;
            cur = cur -> next;
        }
        
        return nil;
    }
    
    public: void print(){
        Node *cur = nil -> next;
        while(cur != nil -> prev){
            printf("%d ",cur -> key);
            cur = cur -> next;
        }
        printf("%d\n",cur -> key);
    }
    
};

int main(){
    DoubleLinkedList list;
    int n,key;
    std::string cmd;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        std::cin >> cmd;
        if(cmd == "insert"){
            std::cin >> key;
            list.insert(key);
        } else if(cmd == "delete"){
            std::cin >> key;
            list.deleteN(list.listsearch(key));
        } else if(cmd == "deleteFirst"){
            list.deleteFirst();
        } else if(cmd == "deleteLast"){
            list.deleteLast();
        }
    }
    list.print();
    
}





Measured memory_bytes: 34520
#include <cstdio>
using namespace std;

class Dice{
    public:
    int face[6];
    Dice(){}
    int roll(int a, int b, int c, int d){
        int temp = face[a]; face[a] = face[b]; face[b] = face[c]; face[c] = face[d]; face[d] = temp;
        return 0;
    }
    int move(char c){
        if (c == 'W') roll(0, 2, 5, 3);
        if (c == 'E') roll(0, 3, 5, 2);
        if (c == 'S') roll(0, 4, 5, 1);
        if (c == 'N') roll(0, 1, 5, 4);
        return 0;
    }
};

int right(Dice dice, int top, int front){
    for (int i = 0; i <= 6; i++){
        if (dice.face[1] == front){
            for (int j = 0; j < 4; j++){
                if (dice.face[0] == top){
                    printf("%d\n", dice.face[2]);
                    return 0;
                }
                else dice.move('W');
            }
        }
        else{
            if (i == 3) dice.move('W');
            dice.move('N');
        }
    }
    return 0;
}

int main(void){
    int num_of_question, top, front;
    
    Dice dice;
    scanf("%d%d%d%d%d%d", &dice.face[0], &dice.face[1], &dice.face[2], &dice.face[3], &dice.face[4], &dice.face[5]);
    scanf("%d", &num_of_question);
    for (int i = 0; i < num_of_question; i++){
        scanf("%d%d", &top, &front);
        right(dice, top, front);
    }
    return 0;
}

Measured memory_bytes: 2672
#include<iostream>
#include<algorithm>
#include<cmath>
#include <limits>
#include <cstdint>
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[100005];
vector<int>a;
int getmin(int s,int e)
{  
    int mine=INT_MAX;
            
           for(int j=s;j<e;j++)
           {
               if(dp[j]+abs(a[e]-a[j])<mine)
               {
                   mine = dp[j]+abs(a[e]-a[j]);
               }
           }
    
    return mine;
}
int mincost(vector<int>&a)
{
 
    
   //dp[0]=a[0];
   dp[0]=a[0];
   dp[1]=abs(a[1]-a[0]);
  
   for(int i=2;i<n;i++)
    {   
        int val;
        if(i<=k)
        {  
           dp[i] = min(getmin(1,i),abs(a[i]-a[0]));
        }
        else
        {  
           dp[i] = getmin(i-k,i);
        }
    }
//   for(int i=0;i<n;i++)
//   {
//       cout<<dp[i]<<" ";
//   }
  return dp[n-1];
}
  
int main()
{
  cin>>n>>k;
  a.resize(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int ans = mincost(a);
  cout<<ans;
}

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

int main(){
  string s, ans;
  cin >> s;
  if(s == "Sunny") ans = "Cloudy";
  if(s == "Cloudy") ans = "Rainy";
  if(s == "Rainy") ans = "Sunny";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long long a,b,ans;
int main() 
{
int T;
scanf("%d", &T);
while(T--) 
{
scanf("%lld%lld",&a,&b);
if(a>b) 
swap(a,b);
if(a==b) 
ans=2*(a-1);
else if (a==b-1)
ans=2*(a-1);
else 
{
long long c=sqrt(a*b);
if(c*c==a*b)
c--;
if(c*(c + 1)>=a*b) 
ans=2*c-2;
else
ans=2*c-1;
}
printf("%lld\n",ans);
}
}

Measured memory_bytes: 128
import math
#切る回数を足してK以下ならOK
def ok(l):
    x =sum([math.ceil(a/l) -1 for a in A])
    if x <=K:
        return True
   # else:
    #    return False

# 初期入力
import bisect
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
A = list(map(int, input().split()))

#2分探索
bottom,top =0,max(A)
while top -bottom >1:
    mid =(top +bottom)//2
    if ok(mid):
        top =mid
    else:
        bottom =mid
print(top)

Measured memory_bytes: 30728
#include <cstdio>
#include <set>

using namespace std;

long long a[100000][3];
set <pair<long long, int> > s[3][3];

void remove(int x, int y) {
    int i;
    
    for (i = 0; i < 3; i++) {
        if (i == y) continue;
        
        s[y][i].erase(make_pair(a[x][y] - a[x][i], x));
    }
}

void insert(int x, int y) {
    int i;
    
    for (i = 0; i < 3; i++) {
        if (i == y) continue;
        
        s[y][i].insert(make_pair(a[x][y] - a[x][i], x));
    }
}

long long update(void) {
    int i, j;
    
    for (i = 0; i < 3; i++) {
        for (j = i + 1; j < 3; j++) {
            long long c = s[i][j].begin()->first + s[j][i].begin()->first;
            
            if (c < 0) {
                int x = s[i][j].begin()->second;
                int y = s[j][i].begin()->second;
                
                remove(x, i);
                remove(y, j);
                insert(x, j);
                insert(y, i);
                
                return c;
            }
        }
    }
    
    for (i = -1; i <= 1; i++) {
        long long c = 0;
        
        if (i == 0) continue;
        
        for (j = 0; j < 3; j++) c += s[j][(j + i + 3) % 3].begin()->first;
        
        if (c < 0) {
            for (j = 0; j < 3; j++) {
                int x = s[j][(j + i + 3) % 3].begin()->second;
                
                remove(x, j);
                insert(x, (j + i + 3) % 3);
            }
            
            return c;
        }
    }
    
    return 0;
}

int main() {
    int n, x, y, z, i;
    long long ans = 0;
    
    scanf("%d %d %d", &x, &y, &z);
    
    n = x + y + z;
    
    for (i = 0; i < n; i++) scanf("%lld %lld %lld", &a[i][0], &a[i][1], &a[i][2]);
    
    for (i = 0; i < x; i++) {
        ans += a[i][0];
        insert(i, 0);
    }
    
    for (; i < x + y; i++) {
        ans += a[i][1];
        insert(i, 1);
    }
    
    for (; i < n; i++) {
        ans += a[i][2];
        insert(i, 2);
    }
    
    while (1) {
        long long c = update();
        
        if (c == 0) break;
        
        ans -= c;
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  long long H;
  cin>>H;
  
  long long count=1;
  
  long long ans=0;
  
  
  while(H!=0){
    H/=2;
    ans+=count;
    count*=2;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
 // cin>>t;
  int tt=1;
  while(t--){
      ll n,x;
      cin>>n>>x;
      ll arr[n],cur=0,ans=0,i;
      fr(i,0,n)
      cin>>arr[i];
      fr(i,0,n)
      {
        if(cur<=x)
          ans++;
        cur+=arr[i];
      }
      if(cur<=x)
        ans++;
      cout<<ans;
      
    //cout<<"Case #"<<tt<<": ";
    //tt++;
    }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,x,count;
  while(scanf("%d",&n),n){
    count=0;
    for(;n>0;n--)for(x=n;x%5==0;){x=x/5;count++;}
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x, ans = 0;
    for(;;) {
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int k;
        ans = 0;
        for(int i = 1; i < n; i++) {
            for(int j = i+1; j <= n; j++) {
                k = x - i - j;
                if((k <= n && k > j) && (i != j && j != k && k != i)) ans++;
            }
        }
        cout << ans << endl;
    }
}


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

#define ll long long
#define fr first
#define se second
#define pb push_back

using namespace std;

const long long N = 1e5 + 7;

ll res, n, m, cnt, ans , a , b , sum , mx, mn, c , d;
string s;
map<int , int>mp;
vector<int>g[100007];
int main()
{
    cin >> n >>  m;
    ll arr[n + 1];
    for( int i = 1;i <= n;i += 1 )
        cin >> arr[i];
    for( int i = 0;i < m;i ++ ){
        ll x , y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    for( int i = 1;i <= n;i ++ ){
        mx = 0;
        for( auto it:g[i] )
            mx = max( mx , arr[it] );
        if( mx < arr[i] )
            cnt++;
    }
    cout << cnt;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    ll ans=0;
    rep(i,0,n){
        if(i != 0 && a[i-1]%2==1 && a[i]){ ans++; a[i]--;}
        ans += a[i]/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from itertools import accumulate
from bisect import bisect_right
n,m,k=MI()
A=LI()
B=LI()
a=[0]+list(accumulate(A))
b=[0]+list(accumulate(B))
ans=0
for i in range(n+1):
  if a[i]>k:
    break
  j=bisect_right(b,k-a[i])
  ans=max(ans,i+j-1)
print(ans)

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

using P = pair<ll, int>;
struct Edge{
    ll to,cost;
};

template<class T> void dijkstra(vector<vector<Edge>>& G, int s, vector<T>& dis){
    int N = G.size();
    priority_queue<P, vector<P>, greater<P>> q;
    dis[s] = 0;
    q.push({dis[s],s});

    while(!q.empty()){
        auto pos = q.top(); q.pop();

        int v = pos.second;
        if(dis[v] < pos.first) continue;
        for(auto next: G[v]){
            if(next.to == v)continue; //無限ループの回避
            if(dis[next.to] > dis[v]+next.cost){
                dis[next.to] = dis[v]+next.cost;
                q.push({dis[next.to], next.to});
            }
        }
    }
}

int main() {
    int N; cin >> N;
    vector<vector<Edge>> G(N);
    REP(i,N-1){
        ll a,b,c; cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    int Q,K; cin >> Q >> K;
    K--;
    vector<ll> dist(N,1e15);
    dijkstra(G,K,dist);

    REP(i,Q){
        int x,y; cin >> x >> y;
        x--;
        y--;
        cout << dist[x]+dist[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 14008
#include <stdio.h>
#define MAX 105

int G[MAX][MAX], f[MAX], d[MAX], dis=0, n;

void visit(int a){
    int i;
    d[a]=dis;
    
    for (i=0; i<n; i++){
        if(G[a][i] == 1 && d[i]==0){
            dis++;
            visit(i);
        }    
    }
    dis++;
    f[a] = dis;
}

int main(void) {
  int u,k,v,i,j;
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
      d[i]=0;
    for(j=0; j<1 ;j++)
      G[i][j] = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
          scanf("%d",&v);
          G[u-1][v-1] = 1;
    }
  }
    
  for(i=0;i<n;i++){
    if(d[i]==0){
        dis++;
        visit(i);
    }
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
  return 0;
}





Measured memory_bytes: 2056