akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;

const int N=1e5+1 ; 
long long Dp[N],n,k;
int height[N];
long long calc(int idx){
       
       if(idx==n-1)return 0 ; 
       if (idx>=n)return 1e9 ;
        long long &ret = Dp[idx] ; 
        if(ret!=-1)return  ret ; 
        ret = 1e9 ;
        ret=min(ret , abs(height[idx+1]-height[idx])+calc(idx+1));
        ret = min (ret , abs(height[idx+2]-height[idx])+calc(idx+2));
      
        return ret ; 
}
int main()
{ 
        cin>>n;
        for(int i=0;i<n;i++)cin>>height[i];
        memset(Dp,-1,sizeof Dp);
        cout<<calc(0);
    
}


Measured memory_bytes: 9452
import sys
input = sys.stdin.readline

MOD=10**9+7
 
n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n-1):
  p,q = [int(i)-1 for i in input().split()]
  edge[p].append(q)
  edge[q].append(p)

flag=[0]*n
flag[0]=1
if n==1:
  ans=2
else:
  dp=[[0] * 2 for i in range(n)]
  for i in range(n):
    if len(edge[i])==1:
      dp[i]=[1,1]
      flag[i]=1
    else:
      dp[i]=[0,0]
  dp[0]=[0,0]
  stack = [0]
  while len(stack)!=0:
    term=0
    white=1
    black=1
    length=len(stack)-1
    for i in range(len(edge[stack[length]])):
      if flag[edge[stack[length]][i]]==0:
        flag[edge[stack[length]][i]]=1
        stack.append(edge[stack[length]][i])
        term=1
      else:
        sub1=max(1,(dp[edge[stack[length]][i]][0]+dp[edge[stack[length]][i]][1])%MOD)
        sub2=max(1,dp[edge[stack[length]][i]][0])
        white=(white*sub1)%MOD
        black=(black*sub2)%MOD
    if term == 0:
      dp[stack[length]]=[white,black]
      stack.pop()
  
  ans = (dp[0][0]+dp[0][1])%MOD

print(ans)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    set<ll> tmp;
    REP(i, n) cin >> l[i];
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = i+1; j < n; j++){
            for(ll k = j+1; k < n; k++){
                if(l[i] == l[j]) continue;
                if(l[j] == l[k]) continue;
                if(l[k] == l[i]) continue;
                if(l[i]+l[j]+l[k] > 2 * max(l[i], max(l[j], l[k]))) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll rem=n*(n+1)/2;
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  if(sum%rem){
    cout << "NO" << endl;
  }
  else{
    ll use=sum/rem;
    ll pl[n],mi[n];
    bool check=true;
    for(int i=0;i<n;i++){
      ll dis;
      if(i<n-1){
        dis=a[i+1]-a[i];
      }
      else{
        dis=a[0]-a[i];
      }
      ll s=use-dis;
      if(s%n||s/n>use||s/n<0){
        check=false;
      }
      else{
        pl[i]=use-s/n;
        mi[i]=s/n;
      }
    }
    if(!check){
      cout << "NO" << endl;
    }
    else{
      ll x=0,y=0;
      for(int i=0;i<n;i++){
        x+=pl[i];
        y+=mi[i];
      }
      if(x==use*(n-1)&&y==use){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
  }
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int M = nextInt();
		Pair[] p = new Pair[M];
		ArrayList<Pair> list = new ArrayList<>();
		for(int i =0;i<M;i++){

			p[i]=new Pair(nextInt(),nextInt(),i);
			list.add(p[i]);
		}
		Collections.sort(list,Pair.getComparator());

		int cnt=0;
		int bef=-1;
		for(Pair x:list){
			if(bef!=x.N){
				cnt=0;
				bef=x.N;
			}
			cnt++;
			x.cnt=cnt;
		}
		PrintWriter pw = new PrintWriter(System.out);
		for(Pair x:p){
			pw.printf("%06d%06d\n",x.N,x.cnt);
		}
		pw.flush();
	}

	public static class Pair {
		int N;
		int V;
		int idx;
		int cnt;

		Pair(int N, int V,int idx) {
			this.N = N;
			this.V = V;
			this.idx=idx;
		}

		public int getN() {
			return N;
		}

		public int getV() {
			return V;
		}


		public int getIdx() {
			return idx;
		}

		public void setIdx(int idx) {
			this.idx = idx;
		}

		public static Comparator<Pair> getComparator() {
			return Comparator.comparing(Pair::getN).thenComparing(Pair::getV);
		}
		public static Comparator<Pair> getComparator2() {
			return Comparator.comparing(Pair::getIdx);
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 115184
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
 
using ll = long long;
using ld = long double;
using namespace std;

typedef long double T;
typedef complex <T> pt;
#define x real()
#define y imag()

int sign(ld a) {
	return (0 < a) - (a < 0);
}

T dot(pt a, pt b) {
	return (conj(a) * b).x;
}

T cross(pt a, pt b) {
	return (conj(a) * b).y;
}

struct line {
	// a*x + b*y - c = 0
	pt v; T c; // (b, -a), c
	line (pt v, T c) : v(v), c(c) {} // direction and offset
	line (T a, T b, T c) : v({b, -a}), c(c) {} // (a, b, c)
	line (pt p, pt q) : v(q - p), c(cross(v, p)) {}
};

pt intersection(line a, line b) {
	return (a.c * b.v - b.c * a.v) / cross(a.v, b.v);
}

line moveleft(line a, T dis) {// shift line
	return {a.v, a.c + dis * abs(a.v)};
}

int main() {
	vector <pt> f;
	rep(i, 1, 3) {
		int ax, ay;
		scanf ("%d%d", &ax, &ay);
		f.pb({(ld)ax, (ld)ay});
	}
	if (cross(f[1] - f[0], f[2] - f[0]) < 0)
		reverse(all(f));
	ld l = 0, r = abs(cross(f[1] - f[0], f[2] - f[0])) / abs(f[1] - f[0]);
	rep(i, 1, 200) {
		ld m = (l + r) / 2;
		line A = moveleft(line(f[0], f[1]), m);
		line B = moveleft(line(f[1], f[2]), m);
		line C = moveleft(line(f[2], f[0]), m);
		pt a = intersection(C, A);
		pt b = intersection(A, B);
		pt c = intersection(B, C);
		if (sign(cross(b - a, c - a)) * sign(cross(b - a, f[2] - a)) == -1) {
			r = m;
			continue;
		}
		T distance = max({abs(a - b), abs(b - c), abs(c - a)});
		if (distance >= 2 * m) 
			l = m;
		else
			r = m;
	}
	printf ("%.15Lf\n", l);
	return 0;
}


Measured memory_bytes: 3840
#include<cstdio>

using ll = long long;
using ull = unsigned long long;
const static int MOD = 1000000007;
const static int MAX_N = 100000;
ll RepeatSquaring(ll N, ull P){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ll t = RepeatSquaring(N, P >> 1);
		return t*t %MOD;
	}
	//Pが偶数のときN^(P/2)を求めてからそれの2乗を返す
	return N*RepeatSquaring(N, P - 1) % MOD;
	//Pが奇数のときN^((P - 1)/2)を求めてからそれの2乗を返す
}
int main(){
    unsigned N;
    scanf("%u", &N);
    ull square = 0, tmp, sum = 0;
    for(unsigned i = 0; i < N;i++){
        scanf("%llu", &tmp);
        square = (tmp*tmp %MOD + square) %MOD;
        sum = (sum + tmp) %MOD;
    }
    printf("%llu\n", (sum*sum %MOD + MOD - square)%MOD *RepeatSquaring(2, MOD-2) %MOD);
	return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                 

using namespace std;
#define ll long long

int main(){
  ll A, B;
  char op;
  cin >> A >> op >> B;
  if(op == '+')
    cout << A + B << endl;
  else
    cout << A - B << endl;
  return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    set<int> d;
    rep(i,N){
        int n; cin>>n;
        d.insert(n);
    }
    cout<<d.size()<<endl;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=1000000007;
const int MOD=998244353;
const int mod=998244353;
const int MAX=3001000;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
vi fac,finv,inv;
void init(ll n) {
    fac=vi(n+5);finv=vi(n+5);inv=vi(n+5);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,n+5){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
} 

int main(){
  ll x,y,n,a,b,k;cin>>n>>a>>b>>k;
  ll ans=0;
  init(n);
  ll i=0;
  while(i<=n){
		if((k-i*a)%b!=0){
          i++;
          continue;
        }
		ll j=(k-i*a)/b;
		ans+=modcom(n,i)*modcom(n,j)%mod;
    	ans%=mod;
    	i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7296
// Problem : A - +-x
// Contest : AtCoder - AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int A, B;
	cin >> A >> B;
	int resPrim = max(A+B, A-B);
	cout << max(resPrim, A*B);
}




Measured memory_bytes: 3648
#include<cstdio>
int main(){
	int n;
	int i,j,k;
	while(scanf("%d",&n) != EOF){
		int counter = 0;
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				for(k=0;k<=9;k++){
					if(n-(i+j+k) >= 0 && n-(i+j+k) <= 9){
						counter++;
					}
				}
			}
		}
		printf("%d\n",counter);
	}
	return 0;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 503;
int n, d[N][N], a[N][N];
pii p[] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

queue <pii> q;

void bfs(pii s) {
	a[s.F][s.S] = 0;
	q.push(s);
	pii v;
	while (!q.empty()) {
		v = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int x = v.F + p[i].F, y = v.S + p[i].S;
			if (x < 1 || y < 1 || x > n || y > n) {
				continue;
			}
			if (d[x][y] > d[v.F][v.S] + a[v.F][v.S]) {
				d[x][y] = d[v.F][v.S] + a[v.F][v.S];
				q.push({x, y});
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			d[i][j] = min({i - 1, j - 1, n - i, n - j});
			a[i][j] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n * n; i++) {
		int x;
		cin >> x;
		int r = (x - 1) / n + 1;
		int c = x - (r - 1) * n;
		ans += d[r][c];
		bfs({r, c});
	}
	cout << ans;
}


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

int main() {
  int s, w;
  cin >> s >> w;
  string ans = s > w ? "safe" : "unsafe";
  cout << ans << endl;
}


Measured memory_bytes: 3568
h,n = list(map(int, input().split()))
ab = []
a = []
b = []
for _ in range(n):
    t_ab = list(map(int, input().split()))
    ab.append(t_ab)
    a.append(t_ab[0])
    b.append(t_ab[1])

maxa = max(a)
hmaxa = h+maxa
dp = [0 for _ in range(hmaxa)]

for i in range(1, hmaxa):
    ab_child = [dp[i-a]+b for a,b in ab]
    dp[i] = min(ab_child)

print(min(dp[h:]))

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

using namespace std;

typedef long long ll;

const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;

#define rep(i, s, t) for (auto i = s; i < (t); ++i)
#define per(i, s, t) for (auto i = s; i >= (t); --i)
#define sz(x) ((int) (x).size())
#define mp make_pair
#define pb push_back

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return 1;
    }
    return 0;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return 1;
    }
    return 0;
}

void run();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
    return 0;
}

void run() {
    ll x, y;
    cin >> x >> y;
    if (x % y == 0) {
        cout << "-1\n";
        return;
    }
    cout << x << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
long long Max(long long a, long long b) {
	if (a <= b)return b;
	else return a;
}
using namespace std;
int main(){
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b)cout << 0 << endl;
	else if (a != b && n == 1)cout << 0 << endl;
	else cout << Max(n - 2,0)*(b - a) + 1 << endl;
    return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    int sum = 0;
    for(int i=0; i<N-1; i++) sum += L[i];
    if(sum > L[N-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

vector<mint> ten,one;

struct S {
    mint val;
    int len;
};

S op(S sl,S sr){
    return {sl.val * ten[sr.len] + sr.val , sl.len + sr.len};
}

S e(){
    return {0,0};
}

struct F {
    int a;
};

S mapping(F f,S s){
    if(f.a == -1)return s;// 恒等写像
    return {f.a * one[s.len] , s.len};
}

F composition(F f,F g){
    if(f.a == -1)return g;
    return f;
}

F id(){
    return {-1};
}


int main() {
    int N,Q;cin >> N >> Q;
    ten.resize(N+1,0);
    one.resize(N+1,0);
    ten[0] = 1;
    rep(i,N)ten[i+1] = ten[i] * 10;
    rep(i,N)one[i+1] = one[i] + ten[i];

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N,{1,1}));

    rep(_,Q){
        int l,r,d;cin >> l >> r >> d;
        l--;
        seg.apply(l,r,{d});
        cout << seg.all_prod().val.val() << endl;
    }
}

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



int inline calc(int x, int y){
    return pow((x-y), 2);
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    
    rep(i,n) cin >> a[i];
    
    
    int ans = INF;
    rep2(y, -100, 101){
        int cost = 0;
        rep(i,n){
            cost += calc(a[i], y);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    
    
    
    
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  string O;
  cin >> O;
  int l = O.length();
  vector<char> P(10);
  for(int i = 0; i < 10; ++i) P[i] = '0' + i;
  long long int m = 0, k = 1;
  for(int i = 0; i < l; ++i) k *= 10;
  string ans;
  do{
    string t;
    for(int i = 0; i < l; ++i) t += P[i];
    if(min(abs(stoll(O)-stoll(t)), k - abs(stoll(O)-stoll(t))) > m){
      m = min(abs(stoll(O)-stoll(t)), k - abs(stoll(O)-stoll(t)));
      ans = t;
    }
  }while(next_permutation(P.begin(),P.end()));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int N;
	cin >> N;
    string S;
    cin >> S;
    int l = 0, r = 0, lp = 0, rp = 0;
    rep(i,N) {
        if (S[i] == '(') l++;
        else             r++;
        lp = max(lp, r-l);
    }
    rp = lp + l - r;
    string ans = string(lp, '(') + S + string(rp, ')');
	cout << ans << endl;
	return 0;
}


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

int main()
{
  vector<int> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  sort(A.begin(), A.end());
  cout << A.at(0) << " " << A.at(1) << " " << A.at(2) << endl;
}


Measured memory_bytes: 3152
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int a, b, n;
    cin >> a >> b >> n;

    cout << a * min(b-1, n) / b - a * (min(b-1, n) / b) << '\n';

    return 0;
}

Measured memory_bytes: 3660
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;


    
    public class Main{
        
        

   public static void main (String[] args)  throws IOException{

      Scanner sc=new Scanner(System.in);
      int N=0;
      if(sc.hasNextInt())
      {
          N=sc.nextInt();
      }
      int count=0;
      for(int i=0;i<=N;i++)
      {
          if(i%2!=0)
          {
              count++;
          }
      }
      
     
     double X=(double)count/N;
      System.out.println(X);
        
       
   }
   
}
   

Measured memory_bytes: 22996
#include <bits/stdc++.h>  // ver2.2.5
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
#define PI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  double a,b,x;
  cin >> a >> b >> x;  
  double giri = a*a*b/2.0;
  double qw;
  if(x <= giri){
    
    qw = 2.0*x/(a*b);
    cout << atan(b/qw)*(180.0/PI) << endl;
    
  }
  else {
    qw = 2.0*b - ((2*x)/(a*a));
    cout << 90.0-(atan(a/qw)*(180.0/PI)) << endl;
  }
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    ll ans = 0;
    REP(i, S.length()){
        if(S[i] == '+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true){
            int x = sc.nextInt();
            if(x == 0) break; 
            System.out.println("Case " + i + ": " + x);
            i++;
        }

        sc.close();
	}
}


Measured memory_bytes: 41384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct P{
	double x;
	double y;
};

namespace std {
  bool operator < (const P& a, const P& b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  }
}

int ccw(P p0, P p1, P p2)
{
	double dx1 = p1.x-p0.x;
	double dy1 = p1.y-p0.y;
	double dx2 = p2.x-p0.x;
	double dy2 = p2.y-p0.y;
	
	if(dx1*dy2 > dy1*dx2){
		return 1;
	} 
	if(dx1*dy2 < dy1*dx2){
		return -1;
	}
	if((dx1*dx2 < 0) || (dy1*dy2 < 0)){
		return -1;
	}
	if((dx1*dx1+dy1*dy1)<(dx2*dx2+dy2*dy2)){
		return 1;
	}
	
	return 0;
}

int convh(vector<P> vec)
{
	int n = vec.size(), k = 0;
	sort(vec.begin(), vec.end());
	vector<P> ch(2*n);
	
	for(int i = 0; i < n; ch[k++] = vec[i++]){
		while(k >= 2 && ccw(ch[k-2], ch[k-1], vec[i]) <= 0){
			k--;
		}
	}
	
	for(int i = n-2, t = k+1; i >= 0; ch[k++] = vec[i--]){
		while(k >= t && ccw(ch[k-2], ch[k-1], vec[i]) <= 0){
			k--;
		}
	}
	
	ch.resize(k-1);
	
	return ch.size();
}

int main()
{
	int n;
	P t;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		vector<P> vec;
		for(int i = 0; i < n; i++){
			scanf("%lf,%lf", &t.x, &t.y);
			vec.push_back(t);
		}
		
		cout << (n-convh(vec)) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

const int MAX_A = 5000, MAX_B = 5000;

int A, B;
int as[MAX_A], bs[MAX_B];

int main()
{
	scanf( "%d%d", &A, &B );
	rep( i, A )
		scanf( "%d", as+i );
	rep( i, B )
		scanf( "%d", bs+i );

	int ans = 0;
	rep( i, B )
	{
		int k = 0;
		repi( j, i, B )
		{
			while( k < A && as[k] != bs[j] )
				++k;
			
			if( k == A || j == B-1 )
				ans = std::max( ans, j-i );
			
			if( k == A )
				break;

			++k;
		}
	}

	printf( "%d\n", ans );

	return 0;
}

Measured memory_bytes: 1064
N, x = map(int,input().split())
a = sorted(map(int,input().split()))

A = sum(a)
if x > A:
    print(N-1)
elif x == A:
    print(N)
else:
    t = 0
    for n in range(N):
        t += a[n]
        if t > x:
            print(n)
            break

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int negaCount = 0;
            long minAbs = Long.MAX_VALUE;
            long sum = 0;
            for (int i = 0; i < N; i++) {
                long ai = sc.nextInt();
                if (ai < 0L) {
                    negaCount += 1;
                }
                long abs = Math.abs(ai);
                minAbs = Math.min(minAbs, abs);
                sum += abs;
            }
            if (negaCount % 2 != 0) {
                sum -= minAbs * 2L;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 48788
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

# A
"""
a, b = map(int, input().split())
sum = a-1
if b >= a:
    sum += 1
print(sum)
"""
# B
"""
a,b,c = map(int, input().split())
k = int(input())
sum = a+b+c+max(a,b,c)*(2**k-1)
print(sum)
"""
# C
"""
def check(y,x):
    if y-1 < 0:
        if x-1 < 0:
            move_x = [1,0]
            move_y = [0,1]
        if x+1 >= w:
            move_x = [-1,0]
            move_y = [0,1]
        else:
            move_x = [1,-1,0]
            move_y = [0,0,1]
    if y+1 >= h:
        if x-1 < 0:
            move_x = [1,0]
            move_y = [0,-1]
        if x+1 >= w:
            move_x = [-1,0]
            move_y = [0,-1]
        else:
            move_x = [1,-1,0]
            move_y = [0,0,-1]
    else:
        if x-1 < 0:
            move_x = [1,0,0]
            move_y = [0,1,-1]
        if x+1 >= w:
            move_x = [-1,0,0]
            move_y = [0,1,-1]
        else:
            move_x = [1,-1,0,0]
            move_y = [0,0,1,-1]
    for i in range(len(move_x)):
        if stage[y+move_y[i]][x+move_x[i]] == "#":
            return True
    return False
h,w = map(int, input().split())
stage = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if stage[i][j] == "#":
            if not check(i,j):
                print("No")
                quit()
print("Yes")
"""
# D
def dfs(n,k,b):
    if n == 4:
        a.append(k)
    else:
        for i in range(len(b)):
            dfs(n+1,k+b[i],b[i+1:])
n = I()
f = [i for i in range(55555)]
f[1] = 0
z = 2
while 1:
    for i in range(2,55555//z+1):
        if z*i < 55555:
            f[z*i] = 0
    for j in range(z+1,55555):
        if f[j]:
            z = j
            break
    if j == 55554:break
l = []
ans = []
for i in range(55555):
    if f[i] and i%5==1:ans.append(i)
print(*ans[:n])


Measured memory_bytes: 42608
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (
    acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
    sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))

# For getting input from input.txt file
#sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
#sys.stdout = open('output.txt', 'w')


def main():
    x, k, d = invr()
    x = abs(x)
    d_move = min(k, x // d)
    curr = x - d_move*d
    baki = k - d_move
    if baki % 2 != 0:
        print(d - curr)
    else:
        print(curr)


# ab
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")

# endregion


if __name__ == "__main__":
    main()


Measured memory_bytes: 10700
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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

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; }

ll dp[101][100001]; //dpテーブル
int v[100],w[100];
int N,W;


ll rec(int i,int j){
   
  if(dp[i][j]>-1){
    return dp[i][j];
  }
  ll res;
  if(i==N){
    res= 0;
  }
  else if(j<w[i]){
    res = rec(i+1,j);//入らない時
  }
  else{
    res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);//入れると入れないで比較
    }
  return dp[i][j]=res;
  }

int main() {
  
  cin >>N>>W; 
  rep(i,N)
    cin >> w[i] >> v[i];

  for(int i=0;i<101;i++){
    for(int j=0;j<100001;j++){
      dp[i][j]= -1;
    }
  }
  
  
  cout << rec(0,W)<< endl; // 標準出力
}




Measured memory_bytes: 82076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int gcd(int a,int b){
	return a%b==0? b:gcd(b,a%b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	int ans=0;
	bool flg=true;
	while(n>9){
		if(n%10!=9) flg=false;
		ans+=9;
		n/=10;
	}
	if(flg) ans+=n;
	else ans+=n-1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
char s[MAXN];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    scanf("%s", s);

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) ans++;
    }

    printf("%d\n", min(n - 1, ans + 2 * k));
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        XXOR solver = new XXOR();
        solver.solve(1, in, out);
        out.close();
    }

    static class XXOR {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long k = in.nextLong();
            long[] a = new long[n];
            long max = k;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
                max = Math.max(max, a[i]);
            }

            // 桁数 | 未満フラグ
            long[][] dp = new long[100][2];

            int dnum = 0;
            for (int i = 0; i <= 50; i++) {
                dp[i][0] = -1;
                dp[i][1] = -1;
                if ((max >> i) > 0) {
                    dnum++;
                }
            }
            if (dnum == 0) {
                long result = 0;
                for (long l : a) {
                    result ^= l;
                }
                out.println(result);
                return;
            }
            dp[0][0] = 0;
            for (int i = 0; i < dnum; i++) {
                int shift = dnum - i - 1;
                long mask = 1L << shift;
                long one = 0;
                for (long l : a) {
                    if ((l & mask) > 0L) {
                        one++;
                    }
                }
                long cost0 = mask * one;
                long cost1 = mask * (n - one);

                if (dp[i][1] != -1) {
                    // 未満フラグ立っている
                    dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][1] + Math.max(cost1, cost0));
                }
                // 未満フラグ立ってない
                if (dp[i][0] != -1) {
                    // ぴったり->未満
                    if ((k & mask) > 0L) {
                        // kのbitが立っていたときに未満にできる
                        dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][0] + cost0);
                    }

                    // ぴったり->ぴったり
                    if ((k & mask) > 0L) {
                        dp[i + 1][0] = Math.max(dp[i + 1][0], dp[i][0] + cost1);
                    } else {
                        dp[i + 1][0] = Math.max(dp[i + 1][0], dp[i][0] + cost0);
                    }

                }
            }
            out.print(Math.max(dp[dnum][0], dp[dnum][1]));
        }

    }
}



Measured memory_bytes: 61208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>      // std::swap
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;
struct edge {int to,cost;};
typedef std::pair<int,int> P;
    ll W,H,N,M;
    ll sum=0;
    //ll A[300000],B[300000];
    ll d[300000];
    ll back=0;
    bool f=false;
    ll ans=INF;
    vector<edge> G[300001];

    void dijkstra(int s){
        std::priority_queue<P,vector<P>,std::greater<P>> que;
        std::fill(d,d+N,INF);
        d[s]=0;
        que.push(P(0,s));
        while(!que.empty()){

            P p =que.top();que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            for(int i=0;i<(signed)G[v].size();i++){
                edge e =G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }
    }

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,M){
        int a,b;
        cin>>a>>b;
        edge es;
        es.to=b-1,es.cost=1;
        G[a-1].push_back(es);
        es.to=a-1;
        G[b-1].push_back(es);
    }
    dijkstra(0);
    if(d[N-1]==2)
        cout<<"POSSIBLE"<<endl;
    else
     cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 18280
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int r = in.nextInt();
        System.out.println(2.0 * Math.PI * r);
    }
}


Measured memory_bytes: 35856
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 100005



// Driver code to tes above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int n;
    cin >> n;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";

    return 0;
    
} 

Measured memory_bytes: 256
import math
from fractions import gcd
import fractions
 
 
N = int(input())
A=list(map(int, input().split()))
 
num = A[0]
for i in range(1, N):
    num = num * A[i] // fractions.gcd(num, A[i])
 
ans = 0
 
for i in range(N):
    ans += (num // A[i])
 
print(ans%(10**9+7))

Measured memory_bytes: 7736
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;cin>>s;
    int output;output=0;
    if(s[0]=='1'){
        output++;
    }
    if(s[1]=='1'){
        output++;
    }
    if(s[2]=='1'){
        output++;
    }
    cout<<output<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> d(N);
    Rep (i, N) {
        cin >> d[i];
    }

    ll ans = 0;
    Rep (i, N) {
        Rep (j, N) {
            if (i >= j) continue;
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
task = [0] * N
for i in range(N):
    task[i] = list(map(int, input().split()))

task_sorted = sorted(task, key=lambda x: x[1])

time = 0
prev_dd = 0
ans = 'Yes'
for t in task_sorted:
    time += t[1] - prev_dd
    prev_dd = t[1]
    time -= t[0]
    if time < 0:
        ans = 'No'
        break
print(ans)


Measured memory_bytes: 83064
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
ll n, A, B, h[N];

bool check(ll Bcnt){
  
  ll cnt=0;
  
  for(int i=0;i<n;i++){
    
    ll hp=h[i]-Bcnt*B;
    
    if(hp>0){

      if(!(hp%A)) cnt+=hp/A;
      else cnt+=hp/A+1;
      
    }
      
  }
  
  return cnt<=Bcnt;
}

ll bynary_search(){

  ll l=0,r=(1e9)+1;
  
  while(l<r){

    ll m=(l+r)/2;
    
    if(!check(m)) l=m+1;
    else r=m;
    
  }

  return l;
}

int main(){

  cin>>n>>A>>B;

  A-=B;
  
  for(int i=0;i<n;i++) cin>>h[i];
  
  sort(h,h+n,greater<int>());

  cout<<bynary_search()<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ZHOU 2002
#define MAXN 200010
#define MOD 1000000007
typedef long long LL;
int n;
LL a[MAXN], b[MAXN];
LL dp[ZHOU * 2 + 10][ZHOU * 2 + 10];
LL ans;
LL fac[ZHOU * 5 + 10], inv[ZHOU * 5 + 10];
inline LL ksm(LL x, LL y)
{
    LL ret = 1;
    while(y)
    {
        if(y & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ret;
}

inline LL C(LL x, LL y){return (fac[x] * inv[y]) % MOD * inv[x - y] % MOD;}
int main()
{
    scanf("%d", &n);
    fac[0] = 1;
    for (register int i = 1;i <= ZHOU * 5;i ++) fac[i] = (1ll * fac[i - 1] * i) % MOD;
    inv[ZHOU * 5] = ksm(fac[ZHOU * 5] , MOD - 2);
    for (register int i = ZHOU * 5 - 1;i >= 0;i --) inv[i] = (1ll * inv[i + 1] * (i + 1)) % MOD;
    for (register int i = 1;i <= n;i ++)
    {
        scanf("%lld%lld", &a[i], &b[i]);
        ans = ans - C((a[i] + b[i]) << 1, a[i] << 1);
        ans = (ans + MOD) % MOD;
        dp[ZHOU - a[i]][ZHOU - b[i]] ++;
    }
    for (register int i = 1;i <= ZHOU * 2 + 2;i ++)
    {
        for (register int j = 1;j <= ZHOU * 2 + 2;j ++)
        {
            dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % MOD;
        }
    }
    for (register int i = 1;i <= n;i ++){ans = (ans + dp[ZHOU + a[i]][ZHOU + b[i]]) % MOD;}
    printf("%lld\n", ans * ksm(2, MOD - 2) % MOD);
}


Measured memory_bytes: 132752
N = int(input())
S = input()
ans = 0

for L in range(1,N): #比較する文字列同士の距離
    dp = [0] * (N+5)
    for x in range(N-L): #文字列の始点を全探索
        if S[x] == S[x+L]:
            if x == 0:
                dp[x] += 1
            else:
                dp[x] = min(dp[x-1]+1,L)
            ans = max(ans,dp[x])
        else:
            dp[x] = 0
            
print(ans)

Measured memory_bytes: 44636
def a_simple_calculator(X, Y):
    # 途中でBボタンを押す必要はないので、最初か最後にBボタンを押すことになる
    # 最初に押すことを-Xで、最後に押すことを-Yで表現している
    # 数値はBボタンを押した回数
    operation = [[X, Y, 0], [-X, Y, 1], [X, -Y, 1], [-X, -Y, 2]]
    ans = float('inf')

    for x, y, push_B in operation:
        if x <= y:
            ans = min(ans, push_B + (y - x))
    return ans

X, Y = [int(i) for i in input().split()]
print(a_simple_calculator(X, Y))

Measured memory_bytes: 3064