akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
       Scanner sc = new Scanner(System.in);
       long a = sc.nextInt();
       long b = sc.nextInt();
       long d,r;
       double f,x,y;
       x=a;
       y=b;
       d=a/b;
       f=x/y;
       r=a%b;
       System.out.print(d + " ");
       System.out.print(r + " ");
       System.out.printf("%f\n",f);
	}

}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e5+5;
char s[N],t[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	scanf("%s%s",s,t);
	int d=__gcd(n,m);
	int _n=n/d,_m=m/d;
	for(int i=0,j=0;i<n;i+=_n,j+=_m)
	if(s[i]!=t[j]){puts("-1");exit(0);}
	cout<<s64(n)*m/d;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(void) {
    double xa, ya, ra, xb, yb, rb, dist;
    int num, i;
    
    scanf("%d", &num);
    
    for(i = 0; i < num; i++) {
        scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
    
        dist = sqrt(pow(xa - xb, 2) + pow(ya - yb, 2));
    
        if(ra > rb && dist < ra - rb)
            puts("2");
        else if(rb > ra && dist < rb - ra)
            puts("-2");
        else if(dist <= ra + rb && dist >= ra - rb)
            puts("1");
        else
            puts("0");
    }
    
    return(0);
}

Measured memory_bytes: 620
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll N, K;cin >> N >> K;
	vector<ll> A(N);rep(i,N) cin >> A[i];

	sort(ALL(A));

	ll ans = 0;
	for(int i = 0; i < K;i++){
		ans += A[i];
	}

	cout << ans << endl;
}

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

using ll = long long int;
const int mod = 1e9+7;
const int INF = 1e9+5;


int main(){
	int n, m;
	cin>>n>>m;
	vector<int>G[n];
	vector<int>indegree(n, 0);
	for(int i = 0; i < m; ++i){
		int u, v;
		cin>>u>>v;
		--u;
		--v;
		G[u].push_back(v);
		++indegree[v];
	}
	//for(int lst = 0; lst < n; ++lst){
		//cout<<lst;
		//for(int &v: G[lst]){
			//cout<< " -> "<< v<<", ";
		//}
		//cout<<endl;
	//}
	int src = 0;
	queue<int>q;
	for(int i = 0; i < n; ++i){
		if(indegree[i]==0){
			q.push(i);
		}
	}
	//cout<<src<<endl;
	vector<int>dist(n);
	vector<bool>visited(n);
	while(!q.empty()){
		int node = q.front();
		q.pop();
		//visited[node] = true;
		for(int& x: G[node]){
			if(!visited[x]){
				dist[x] = dist[node]+1;
				//q.push(x);
				--indegree[x];
				if(indegree[x]==0){
					q.push(x);
				}
			}
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans, dist[i]);
		//cout<<dist[i]<<' ';
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;

    swap(X, Y);
    swap(X,Z);

    cout << X << " " << Y << " " << Z;
}

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

int main(int argc, char const *argv[]) {
  int N;

  cin >> N;
  if (N <= 81) {
    for (int i = 1; i <= 9; i++) {
      if(N % i == 0 && N / i <= 9){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int s,m,h;
  cin >> s;
  h=s/3600;
  m=(s-h*3600)/60;
  s=s-h*3600-m*60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1168
is_not_first = 0
while True:
  a, b = map(int, input().split())
  if not a:
    break
   
  if is_not_first:
    print()
  is_not_first += 1
 
  print_flag = 0
  for year in range(a, b + 1):
    if (not year % 4) and ((not (not year % 100)) or (not year % 400)):
      print(year)
      print_flag = 1
 
  if not print_flag:
    print("NA")


Measured memory_bytes: 5724
import sys
input = sys.stdin.readline
H, W, A, B = map(int, input().split())
res = [[0] * W for _ in range(H)]
for i in range(B):
  for j in range(A): res[i][j] = 1
for i in range(B, H):
  for j in range(A, W): res[i][j] = 1
for r in res: print("".join(list(map(str, r))))

Measured memory_bytes: 17172
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

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

int main(){

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

  mx = H[0];

  for(int i=1; i<N; i++){
    if(H[i]>=mx){
      ans++;
      mx = H[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N = int(input())
A = []#value
for i in range(N):
    A.append(int(input()))
B = A[:]
B.sort()
one = B[-1]
two = B[-2]
for i in range(N):
    if A[i] == one:
        print(two)
    else:
        print(one)


Measured memory_bytes: 14132
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

int n,m,x[100010]={0},y[100010]={0};
int color[100010]={0},p[100010]={0},d[100010]={0},f[100010]={0},times;
vector<int>edge[100010],in_edge[100010];
stack<int>topo_order;
int dp[100010]={0};

void dfs_visit(int u){
    color[u]=1;
    times++;
    d[u]=times;
    rep(i,edge[u].size()){
        if(color[edge[u][i]]==0){
            p[edge[u][i]]=u;
            dfs_visit(edge[u][i]);
        }
    }
    color[u]++;
    times++;
    f[u]=times;
    topo_order.push(u);
}

void dfs(){
    times=0;
    rep(i,n){
        if(color[i+1]==0){
            dfs_visit(i+1);
        }
    }
}


signed main() {
	

    cin>>n>>m;
    rep(i,m){
        cin>>x[i]>>y[i];
        edge[x[i]].push_back(y[i]);
        in_edge[y[i]].push_back(x[i]);
    }

    dfs();
	
    int u;
    rep(i,n){
        u=topo_order.top();
        topo_order.pop();
        rep(j,in_edge[u].size()){
            dp[u]=max(dp[u],dp[in_edge[u][j]]+1);
        }
    }
	
    int res=0;
    rep(i,n){
        res=max(res,dp[i+1]);
    }
    cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 18816
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans=0;
    rep(i,L,R+1){
        if(i%d==0)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,m;
    cin>>a>>b>>n;
    ll ans=0;
    for(i=a;i<=b;i++) if(i%n==0) ans++;
    cout<<ans;
    
}

Measured memory_bytes: 3564
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)

diff = 0
for i in range(len(a)):
    if a[i] != b[i]:
        diff += 1
# print(a)
# print(b)
print("YES" if diff == 0 or diff == 2 else "NO")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l,m,x,y,cnt=1,flag=0;
	cin>>n>>m;
	int visit[n+1]={0};
	map<int,vi> node;
	rep(i,m){
		cin>>x>>y;
		node[x].pb(y);
		node[y].pb(x);
	}
	queue<int> q;
	q.push(1);
	visit[1]=1;
	while(!q.empty()){
		x=q.front();
		q.pop();
		//cout<<x<<"->";
		for(int it:node[x]){
			if(visit[it]==0){
				visit[it]=x;
				q.push(it);
			}
		}
	}
	loop(i,2,n+1){
		if(visit[i]==0) {
			flag=1;
			break;
		}
	}
	if(flag==1)
	{
		cout<<"No\n";
		return;
	}
	cout<<"Yes\n";
	loop(i,2,n+1){
		cout<<visit[i]<<endl;
	}
}
int  main() 
{
	fast_io;
    int t=1;
    ///cin>>t;
    while(t--)
    	solve();
	return 0; 
}

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  
  int n = 100*r + 10*g + b;
  
  if((n%4) == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}

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

Measured memory_bytes: 1024
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String L;for(int t,i;(t=s.nextInt())>0;System.out.println(L+"#")){List<String[]>l=new ArrayList<String[]>();for(;t-->0;){L=s.next();int[]x=new int[9];for(i=0;i<9;++i)x[i]=s.nextInt();l.add(new String[]{L,""+(double)(x[6]*x[8]*x[7]-x[0])/(x[1]+x[2]+x[3]+(x[4]+x[5])*x[8])});}Collections.sort(l,new Comparator<String[]>(){public int compare(String[]a,String[]b){int i=new Double(b[1]).compareTo(new Double(a[1]));return i==0?a[0].compareTo(b[0]):i;}});L="";for(String[]y:l)L+=y[0]+"\n";}}}

Measured memory_bytes: 13000
n=int(input())
line=input().split(" ")
f=0

for i in line:
  if int(i)==0:
    print("0")
    f=1

g=1
if f==0:
  for i in line:
    g=g*int(i)
    if g>10**18:
      print("-1")
      f=1
      break
  if f==0:
    print(g)

Measured memory_bytes: 19204
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }


int A, B;
int K;
void solve() {
	for (int i = 0; i < K; i++) {
		// EVEN A, ODD B
		// 奇数なら1枚食べて半分渡す、偶数ならそのまま渡す
		if (i % 2 == 0) {
			if (A % 2 == 0) {
				A /= 2;
				B += A;
			}
			else {
				A--;
				A /= 2;
				B += A;
			}
		}
		else {
			if (B % 2 == 0) {
				B /= 2;
				A += B;
			}
			else {
				B--;
				B /= 2;
				A += B;
			}
		}
	}
	cout << A << " " << B << endl;
}
int main() {
	cin >> A >> B >> K;
	solve();
	return 0;
}


Measured memory_bytes: 256
def actual(n, P):
    count = 0

    for i in range(1, n - 1):
        a, b, c = P[i - 1], P[i], P[i + 1]

        if (a < b < c) or (a > b > c):
            count += 1

    return count

n = int(input())
P = list(map(int, input().split()))

print(actual(n, P))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int h, a; cin >> h >> a;
    int ans = 0;
    while(h > 0){
        h -= a;
        ans++;
    }
    Out(ans);

    return 0;
}


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


class Main {
    static ArrayList<Integer>[]g;
    static boolean dfs(int v,List<Integer>l,boolean[]vis){
        if(vis[v])return false;
        l.add(v);
        vis[v]=true;
        for(int w:g[v]){
            boolean sub=dfs(w,l,vis);
            if(sub)break;
        }
        return true;
    }
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        g=new ArrayList[n];
        Arrays.setAll(g,x->new ArrayList<Integer>());
        for(int i=0;i<m;++i){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            g[a].add(b);
            g[b].add(a);
        }
        List<Integer>ans=new ArrayList<Integer>();
        boolean[]vis=new boolean[n];
        dfs(0,ans,vis);
        vis[0]=false;
        Collections.reverse(ans);
        ans.remove(ans.size()-1);
        dfs(0,ans,vis);
        out.println(ans.size());
        for(int i=0;i<ans.size();++i)
            out.print((ans.get(i)+1)+(i==ans.size()-1?"\n":" "));
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}


Measured memory_bytes: 81808
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        out.println(a * b % 2 != 0 ? "Yes" : "No");
        out.close();
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

template <typename T>
struct SegmentTree {
 private:
  ll n;            //最下段のサイズ
  T e;             //単位元
  vector<T> node;  //セグメント木を表現する配列
  typedef function<T(T, T)> Func;
  Func f;  //区間クエリで使う処理

 public:
  SegmentTree(vector<T> v, Func f_input, T e_input) {
    f = f_input;
    e = e_input;
    ll sz = SZ(v);
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, e);
    REP(i, sz) node[i + n - 1] = v[i];
    IREP(i, n - 1) node[i] = f(node[2 * i + 1], node[2 * i + 2]);
  }

  // x番目(0-indexed)の要素をvalに更新する
  void update(ll x, T val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = f(node[2 * x + 1], node[2 * x + 2]);
    }
  }

  // [a, b) に対する区間クエリに答える
  // k := 自分がいるノードのインデックス
  // [l, r) : ノードkの対象区間
  T query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
  }

  // 添字でアクセス
  T operator[](ll i) { return node[i + n - 1]; }
};

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<P> xh(n);
  REP(i, n) {
    scanf("%lld %lld", &xh[i].first, &xh[i].second);
    // cin >> xh[i].first >> xh[i].second;
    //何回で倒せるか
    xh[i].second = (xh[i].second + a - 1) / a;
  }
  sort(ALL(xh));
  vector<ll> x(n), h(n);
  REP(i, n) {
    x[i] = xh[i].first;
    h[i] = xh[i].second;
  }
  //区間のリスト
  // i -- kukan[i]までダメージ与えられる
  vector<ll> kukan(n, -1);
  REP(i, n) {
    ll r = x[i] + 2 * d;
    // x[j] <= rとなる最大のj
    auto it = --upper_bound(ALL(x), r);
    kukan[i] = it - x.begin();
    // DUMP(kukan[i]);
  }

  vector<ll> s(n + 1, 0);
  SegmentTree<ll> sg(s, [](ll x, ll y) { return x + y; }, 0LL);

  ll ans = 0;
  REP(i, n) {
    ll t = max(h[i] - sg.query(0LL, i + 1), 0LL);
    if (t == 0) continue;
    ans += t;
    // FOR(j, i, kukan[i] + 1) { h[j] = max(h[j] - t, 0LL); }
    sg.update(i, sg[i] + t);
    sg.update(kukan[i] + 1, sg[kukan[i] + 1] - t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 15232
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
o
e
 */
char o[51],e[51];
char s[101];

int main(){
  cin>>o>>e;
  int lo = strlen(o);
  int le = strlen(e);
  REP(i, lo+le){
    if(i%2==0)
      s[i] = o[i/2];
    else
      s[i] = e[i/2];
  }
  s[lo+le]='\0';
  cout << s<<endl;

  return 0;
}


Measured memory_bytes: 256
/*

宣告——
汝身听吾号令，托付吾之命运于汝之剑，
应圣杯之召，若汝遵从此意志此理，回应吧。
在此起誓，吾愿成就世间一切之善行，吾愿诛尽世间一切之恶行。
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<bitset>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;bitset<4000010>b;
int main(){
	n=read();b[0]=1;int i,sum=0,a;for(i=1;i<=n;i++) a=read(),b|=b<<a,sum+=a;
	for(i=(sum+1)/2;;i++) if(b[i]){cout<<i;return 0;}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    int cnt=0;
    vector<bool> kind(8,false);
    rep(i,n){
        if (a[i]>=3200){
            cnt++;
            continue;
        }
        kind[a[i]/400] = true;
    }
    int ans=0;
    rep(i,8)if(kind[i]) ans++;
    cout<<max(ans,1)<<" "<<ans+cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
a = LI()

if (0 in a):
    ret = 0
else:
    ret = a[0]
    for i in range(1,n):
        ret = ret * a[i]
        if(ret > 1000000000000000000):
            ret = -1
            break

print(ret)

Measured memory_bytes: 87668
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	/**
	 * ??\?????????????????? / ????????????????????????
	 */
	public static void main(String[] args) throws Exception {

		// ??\???????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		for (;;) {
			String[] readGame = br.readLine().split(" ");
			int sugorokuNum = Integer.parseInt(readGame[0]);
			int saikoroCnt = Integer.parseInt(readGame[1]);
			int[] sugorokuMasu = new int[sugorokuNum];

			if (sugorokuNum == 0) {
				break;
			}

			for (int i = 0; i < sugorokuNum; i++) {
				int factorCount = Integer.parseInt(br.readLine());
				sugorokuMasu[i] = factorCount;
			}

			int cnt = 0;
			int position = 0;

			for (int i = 0; i < saikoroCnt; i++) {
				int factorCount = Integer.parseInt(br.readLine());
				cnt++;
				if (position + factorCount >= sugorokuNum - 1
						|| position + factorCount + sugorokuMasu[position + factorCount] >= sugorokuNum - 1) {
					break;
				} else {
					position += factorCount + sugorokuMasu[position + factorCount];
				}
			}

			for (int i = 0; i < saikoroCnt - cnt; i++) {
				br.readLine();
			}

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

Measured memory_bytes: 25164
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}, dx[] = {-1, 0, 1, 0, 1, -1, 1, -1};
int h, w;
string s[10];

int main(){
	while(cin >> h >> w, h){;
		rep(i, h) cin >> s[i];
		map<string, int> cnt;
		rep(i, h) rep(j, w) rep(d, 8){
			
			int y = i, x = j;
			string t;
			do{
				t += s[y][x];
				if(t.size() > 1) cnt[t]++;
				y = (y + dy[d] + h) % h;
				x = (x + dx[d] + w) % w;
			}while(y != i || x != j);
		}
		string ans;
		each(i, cnt) if(i->second > 1){
			if(ans.size() < i->first.size()) ans = i->first;
		}
		cout << (ans == "" ? "0" : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 36024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
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; }

const ll mod = 1e9+7;
ll n;

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

    vector<ll> zero(65, 0);
    vector<ll> nzero(65, 0);

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 63; ++j) {
            if(A.at(i)&((ll)1<<j)) {
                nzero.at(j)++;
            }else {
                zero.at(j)++;
            }
        }
    }

    ll ans = 0;
    ll now = 1;
    for(int i = 0; i < 63; ++i) {
        ll next = nzero.at(i)*zero.at(i);
        next %= mod;
        next *= now;
        next %= mod;
        now *= 2;
        now %= mod;
        ans += next;
        ans %= mod;
        // cout << "i " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+5;
int a[maxn];
int n;
int book[maxn];
vector<pair<int ,int > > seg;
#define MP make_pair
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) book[i]=(a[i]==i);
    bool flag=false;
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        if(book[i]){
            if(!flag) l=i,flag=true;
            r=i;
        }else{
            if(flag) seg.push_back(MP(l,r));
            flag=false;
        }
    }
    if(flag) seg.push_back(MP(l,r));
    int Ans=0;
    for(int i=0;i<(int)seg.size();i++){
        int len=seg[i].second-seg[i].first+1;
        Ans+=(len+1)/2;
    }
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000009 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

struct Matrix {
  vector<vector<ll>> data;

  Matrix() {};
  Matrix(int n): data(n, vector<ll>(n, 0)) {};
  void init(int n) { data.assign(n, vector<ll>(n, 0)); }

};

Matrix base[100];

Matrix create(int n, bool *cur, bool *next) {
  Matrix res(n);

  for (int i=0; i<n; i++) {
    if (next[i]) continue;

    if (i > 0 && !cur[i-1]) res.data[i][i-1] = 1;
    if (!cur[i]) res.data[i][i] = 1;
    if (i + 1 < n && !cur[i+1]) res.data[i][i+1] = 1;
  }

  return res;
}

Matrix mul(Matrix &a, Matrix &b) {
  int n = a.data.size();
  Matrix res(n);

  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++)
      for (int k=0; k<n; k++)
        res.data[i][j] = (res.data[i][j] + a.data[i][k] * b.data[k][j]) % mod;

  return res;
}

ll solve() {
  int W, N; ll H;
  bool cur[75] = {}, next[75] = {};
  set<ll> line;
  set<pair<int,ll> > pos;

  scanf("%d%lld%d", &W, &H, &N);

  if (W == 0) return -1;

  base[0] = create(W, cur, next);

  for(int i=1; i<64; i++)
    base[i] = mul(base[i-1], base[i-1]);

  Matrix mat(W);

  for (int i=0; i<W; i++) mat.data[i][i] = 1;

  for (int i=0; i<N; i++) {
    int x; ll y;

    scanf("%d%lld", &x, &y);
    x--; y--;
    if (0 < y) line.insert(y);
    if (y+1 < H) line.insert(y+1);
    pos.insert({x, y});
  }
  line.insert(H-1);

  ll last = 0;

  for (auto y : line) {
    ll t = y - last - 1;

    for (int i=0; t; i++) {
      if (t & 1) mat = mul(base[i], mat);
      t /= 2;
    }

    for (int i=0; i<W; i++) {
      cur[i] = pos.find({i, y-1}) != pos.end();
      next[i] = pos.find({i, y}) != pos.end();
    }

    Matrix tmp = create(W, cur, next);
    mat = mul(tmp, mat);
    last = y;
  }



  return mat.data[W-1][0];
}

int main(){

  for (int i=1;; i++) {
    ll ans = solve();

    if (ans == -1) break;

    printf("Case %d: %lld\n", i, ans);
  }

  return 0;
}



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


void maxheapotf(int size,int array[], int i );
void buildMaxHeap(int size, int array[]);
int main()
{
    int size;
    scanf("%d",&size);
    int array[size+1];
    for(int i = 1; i<=size; i++)
    {
        scanf("%d", &array[i]);
    }  
    buildMaxHeap(size,array);
  
    for(int i=1;i<=size;i++)
    {
        printf(" %d", array[i]);
   
    }     printf("\n");
    
    return 0;
}


void maxheapotf(int size, int array[], int i)
{
    int temp, l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;
    if(l <= size)
    {
        if(array[l] > array[i])
            largest = l;
        if(array[l] < array[i])
            largest = i;
    }
    if(r <= size && array[r] > array[largest])
    {
        largest = r;
    }
    if(largest != i && largest > 0)
    {
        temp = array[i];
        array[i] = array[largest];
        array[largest]= temp; 
        maxheapotf(size, array, largest);
    }
   
}

void buildMaxHeap(int size,int array[])
{
    for(int i=size/2;i>0;i--)
        maxheapotf(size,array,i);
}



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

using namespace std;
using ll = long long;

#define FOR(i,m,n) for(ll i=(m); (i)<(ll)(n); ++(i))
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin,(a).end
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, n; cin >> a >> b >> n;
  ll res = (a*(b-1))/b - a*((b-1)/b);
  if(n < b-1) res = (a*n)/b - a*(n/b);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if( a+b > n+1){
		cout<<-1<<endl;
		return 0;
	}
	else if( a*b < n){
		cout<<-1<<endl;
		return 0;
	}
	else{
		vector<ll> ans;
		ll lef = n;
		for(int i=0;i<b;i++){
			ans.pb(1);
			lef--;
		}
		for(int i=0;i<b;i++){
			ll tmp = min( lef, a-1 );
			ans[i] += tmp;
			lef -= tmp;
		}
		ll cur = n;
		for(int i=0;i<b;i++){
			cur = cur-ans[i]+1;
			for(int j=0;j<ans[i];j++){
				cout<<cur+j<<" ";
			}
			cur--;
		}
		cout<<endl;
		return 0;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> p(N); rep(i, N) cin >> p[i];
  
  ll ans = 0;
  bool ok = false;
  for(int i = 1; i < N - 1; i++) {
    ok = false;
    if(p[i] > p[i-1] && p[i] <= p[i+1]) ok = true;
    if(p[i] > p[i+1] && p[i] <= p[i-1]) ok = true;
    if(ok) ans++;
  }
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

int main() {
    int A,B,X,Y,i;
    cin >> A >> B;
    X = 0;
    i = 0;
    Y = B; 
    if (B == 1) {
    cout << 0 << endl;
    return 0;
  }
  else{
    while(B>0){
        B = Y;
        i += 1;
        X += 1;
        B -= (A - 1)*(i - 1)+A;
        
    }
  }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

int T, X;

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

  printf( "%.12f\n", (double)T/X );

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
int main(){int n,k,a=0,x[100]={};
           std::cin>>n>>k;
           for(int i=0;i!=n;++i){
             std::cin>>x[i];
             a+=(x[i]<k-x[i]?2*x[i]:2*(k-x[i]));
           }
           std::cout<<a<<"\n";
          }
           

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

int main(){
    ll A,B,C; cin >> A >> B >> C;
    int wa=A+B+C;
    int ka=max({A,B,C})*3;
    if((wa%2)==(ka%2)){
        cout << (ka-wa)/2;
    }else{
        ka+=3;
        cout << (ka-wa)/2;
    }
}

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (n, d) = readIs()
  var ans = 0
  repeat(n) {
    val (x, y) = readLs()
    val r = sqrt((x * x + y * y).toDouble())
    if (r <= d) ans++
  }
  println(ans)
}


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

int main(){
  ll n;cin >> n;
  ll ans = 0;
  for(ll i=1;i<=n;++i){
    for(ll j=i+1;j<=n;++j){
      if( i*j >= n ) break;
      ++ans;
    }
  }
  ans *= 2;
  for(ll i=1;i<=n;++i){
    if( i*i >= n ) break;
    ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int main(){
	fast;
	ll n;
	cin >> n;
	ll mx = -INT_MAX, mxx = -INT_MAX, mn = 1e18, mnn = 1e18;
	for(int i = 0; i < n; ++i){
		ll u, v;
		cin >> u >> v;
		mx = max(mx, u + v);
		mn = min(mn, u + v);
		mxx = max(mxx, u - v);
		mnn = min(mnn, u - v);
	}
	cout << max(mx - mn, mxx - mnn);
	return 0;
}


Measured memory_bytes: 3624
while True:
    A, op, B = input().split()
    A = int(A)
    B = int(B)

    if op == "+":
        print(int(A + B))
    elif op == "-":
        print(int(A - B))
    elif op == "*":
        print(int(A * B))
    elif op == "/":
        print(int(A / B))
    elif op == "?":
        break


Measured memory_bytes: 5592
/*
*  Author: windystreet
*  Date  : 2019-03-03 11:46:33
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

bool vis[10];
bool cmp(int a,int b){
	return a%10 < b%10;
}

void solve(){
   	int s[10];
   	for(int i=1;i<=5;i++){
   		scanf("%d",s+i);
   	}
   	sort(s+1,s+6,cmp);
   	// for(int i=1;i<=5;i++){
   	// 	printf("%d%c",s[i]," \n"[i==5] );
   	// }
   	int ans = 0 ;
   	for(int i=1;i<=5;i++){
   		if(s[i]%10){
   			ans += (10 - s[i]%10 + s[i]);
   		}else{
   			ans += s[i];
   		}
   	}
   	int pos = 0;
   	for(int i=1;i<=5;i++){
   		if(s[i]%10 != 0){
   			pos = i;break;
   		}
   	}
   //	printf("pos = %d\n",pos );
   	printf("%d\n",ans - ( pos?(10 - s[pos]%10):0));
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int a[1010];
int b[11]={0};
int main(void){
    int m,n,a,b,x;
    string s;
    cin>>s;
    if(s[0]==s[1]){
        cout<<"Bad"<<endl;
        return 0;
    }
    if(s[1]==s[2]){
        cout<<"Bad"<<endl;
        return 0;
    }
    if(s[2]==s[3]){
        cout<<"Bad"<<endl;
        return 0;
    }
    cout<<"Good"<<endl;
    return 0;
}

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

int n, c, a[6];
long long f[1 << 5][1 << 5][305];

int main() {
  scanf("%d%d", &n, &c);
  c *= n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] *= n;
  }
  sort(a, a + n);
  f[0][0][a[n - 1]] = 1;
  long long ans = 0, all = 1;
  for (int x = 1; x < c; x++) if (x % n) {
    for (int l = x + 1; l <= c; l++) {
      for (int i = 0; i < 1 << n - 1; i++) if (!(i >> (x % n - 1) & 1)) {
        for (int j = 0; j < 1 << n - 1; j++) if (f[i][j][l]) {
          for (int y = 0; y < n - 1; y++) if (!(j >> y & 1)) {
            f[i | 1 << (x % n - 1)][j | 1 << y][min(c, max(x + a[y], l))] += f[i][j][l];
            if (i | 1 << (x % n - 1) == (1 << n - 1) - 1 && j | 1 << y == (1 << n - 1) - 1 && min(c, max(x + a[y], l)) == c) {
            }
          }
        }
      }
    }
  }
  ans = f[(1 << n - 1) - 1][(1 << n - 1) - 1][c];
  for (int i = 1; i < n; i++) {
    all *= i * c / n;
  }
  printf("%.13Lf\n", (long double) ans / all);
}



Measured memory_bytes: 1408
count = [0] * 101
maxCount = 0
while(True):
    try:
        s = input()
        count[s] += 1
        if(maxCount < count[s]):
            maxCount = count[s]
    except Exception:
        break   
for i in range(len(count)):
    if(maxCount == count[i]):
        print(i)

Measured memory_bytes: 4200
n, g = map(int, input().split())
cards = [[int(x) for x in input().split()] for _ in range(g)]

cards.sort(key=lambda x: x[0])
lmx = cards[g - 1][0]
cards.sort(key=lambda x: x[1])
rmn = min(cards[0][1], n)

print(max(0, rmn - lmx + 1))


Measured memory_bytes: 22784
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
int32_t main(){
	int a,b; cin>>a>>b;
	int ct=1;
	int og=a;
	a*=2LL;
	if(a<=b){
		++ct;
		while(a<=b){
			if((a*2LL)/2LL != a) break;
			a*=2LL;
			if(a<=b) ++ct;
			else break;
		}
	}
	cout<<ct;
}

Measured memory_bytes: 256
#include<cstdio>
#define ll long long
#define mod 1000000007ll
using namespace std;

ll ans=1;

int main(){
	int n;
	scanf("%d",&n);
	for(ll i=1;i<=n;i++) ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128