akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    long startTime = System.currentTimeMillis();
    Scanner stdIn = new Scanner(System.in);
    try {
      String weather = new String();
      weather = stdIn.nextLine();
      char[] weatherList = weather.toCharArray();

      int rainDays = 0;
      for (int dayCnt = 0; dayCnt < 3; dayCnt++) {
        int tempRainDays = 0;
        for (int rainCnt = dayCnt; rainCnt < 3; rainCnt++) {
          if (weatherList[rainCnt] == 'R') {
            tempRainDays++;
          } else {
            break;
          }
        }
        if (rainDays < tempRainDays) {
          rainDays = tempRainDays;
        }
      }
      System.out.println(rainDays);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      stdIn.close();
    }
    long endTime = System.currentTimeMillis();
    double resultTime = (double)(endTime - startTime) / 1000;
    //System.out.println("処理時間：" + resultTime + "ミリ秒");
  }
}

Measured memory_bytes: 35596
# https://atcoder.jp/contests/abc153/tasks/abc153_f
# 座標圧縮、貪欲法、imos法


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


# まず、何回攻撃すればいいのかを計算する。これがとにかく必要だ(なくてもいいけど)。
#
# 素直な戦略として、左から倒せるギリギリの爆弾を投下して倒すのが最適
# だけどナイーブに実装すると、O(N^2)。だから体力を管理するのが重要。
# どこにどれだけダメージが蓄積したのかはimos法(デルタ関数をおいてから累積和)で管理できる。

from bisect import bisect_left
N, D, A = read_ints()
XH = read_tuple(N)
XH.sort()  # 座標でソート

n_atk = []  # 何回攻撃するのが必要か
X = []  # 座標アクセス用配列
for x, h in XH:
    n_atk.append((h - 1) // A + 1)
    X.append(x)

damege = [0] * (N + 10)  # ダメージ管理用、配列外アクセスがめんどくさいので長めに取る
ans = 0
# j = 0  # 次のxが、今のx+2d以下でもっとも大きなidx
for i, (x, n) in enumerate(zip(X, n_atk)):
    damege[i] += damege[i - 1]  # 積分して、現時点の蓄積回数を表示
    atk = max(0, n - damege[i])  # iには何回攻撃したか
    ans += atk
    # 攻撃下回数を記録
    damege[i] += atk
    # 効果が切れる点を予約 # 尺取ならO(1)で次に行けるけど二分探索でも間に合うか
    damege[bisect_left(X, x + 2 * D + 1, lo=i)] -= atk  # 効果切れを予約

print(ans)


Measured memory_bytes: 48624
#include<iostream>

using namespace std;

int main(){

    int a,b,m;
    cin >>a >> b >> m;

    int s[a];
    int t[b];

    for(int i=0;i<a;i++)cin >> s[i];
    for(int i=0;i<b;i++)cin >> t[i];

    int x[m];
    int y[m];
    int c[m];

    for(int i=0;i<m;i++)cin >> x[i] >> y[i] >> c[i];

    int ma=s[0];

    for(int i=0;i<a;i++){
        ma =min(ma,s[i]);
    }

    int mb=t[0];

    for(int i=0;i<b;i++){
        mb =min(mb,t[i]);
    }

    int l = ma +mb;

    for(int i=0;i<m;i++){
        l = min(l,s[x[i]-1]+t[y[i]-1]-c[i]);
    }

    cout << l << endl;



}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
signed main()
{
	int x=read();
	double ans=0;
	For(i,1,40)
	{
		rep(j,2,20)
		{
			if(pow(i,j)<=x)ans=max(ans,pow(i,j));
		}
	}
	cout<<(int)ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<int, int> > A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A.begin(), A.end(), greater<pair<int, int> >());
	for (int i = 0; i < N; ++i) {
		if (A[0].second != i) {
			cout << A[0].first << '\n';
		}
		else {
			cout << A[1].first << '\n';
		}
	}
	return 0;
}

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

namespace atcoderれんしゅー
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            var color = Console.ReadLine();
            if (num >= 3200)
            {
                Console.WriteLine(color);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}

Measured memory_bytes: 13140
from collections import Counter
n=int(input())
a=sorted(list(map(int,input().split())))
a_count=Counter(a)
if n%2==1:
    ans=1
    for i in a_count:
        if i%2!=0:
            print(0)
            break
        else:
            if i==0:
                if a_count[i]!=1:
                    print(0)
                    break
            
            else:
                if a_count[i]==2:
                     ans=(ans*2)%(10**9+7)
                else:
                    print(0)
                    break
    else:
      print(ans)
else:
    ans=1
    for j in a_count:
        if j%2!=1:
            print(0)
            break
        else:
            if a_count[j]==2:
                ans=(ans*2)%(10**9+7)
           
            else:
                print(0)
                break
    else:
      print(ans)

Measured memory_bytes: 20624
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
     int a;
     cin>>a;
     int first,second;
     cin>>first>>second;
     int diff = second-first;
     int minn = min(first,second);
     for(int i=2;i<a;i++)
     {    
         int input;
         cin>>input;
         diff = max(input-minn,diff);
         minn = min(minn,input);
         
     }
     cout<<diff<<endl;
 }

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N,100100),B(N);
    rep(i,N-1)cin >> B[i];
    B[N-1] = 100100;
    rep(i,N-1){
            if(A[i]>B[i]){
                A[i] = B[i];
            }
            A[i+1] = B[i];
    }
        
    int res = 0;
    for(auto e : A){
        res += e;
    }
    cout << res << endl;
    return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int N, K;
    cin >> N >> K;
    vector<vector<int>> g(N);
    vector<pii> edges;
    REP(i, N - 1) {
        edges.pb(pii(i, N - 1));
    }
    int L = (N - 1) * (N - 2) / 2;
    if (L < K) {
        cout << (-1) << endl;
    } else {
        REP(i, N - 1) {
            if (L == K) {
                break;
            }
            FOR(j, i + 1, N - 1) {
                if (L == K) {
                    break;
                }
                edges.pb(pii(i, j));
                L--;
                if (L == K) {
                    break;
                }
            }
        }
        cout << edges.size() << '\n';
        for (auto e: edges) {
            cout << e.first + 1 << " " << e.second + 1 << '\n';
        }
        cout << flush;
    }

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int d,n;
  cin>>d>>n;
  vi t(d),a(n),b(n),c(n);
  rep(i,d)cin>>t[i];
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  vector<vi> dp(d+1,vi(n,-INF));
  rep(i,n)
    if(a[i]<=t[0]&& t[0]<=b[i])dp[0][i]=0;

  loop(i,1,d)rep(j,n)if(a[j]<=t[i] && t[i]<=b[j])
    rep(k,n)if(a[k]<=t[i-1] && t[i-1]<=b[k])
      dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(c[k]-c[j]));
  int ans=0;
  rep(i,n)ans=max(ans,dp[d-1][i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 3180
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + 11)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        if dp[Y][i] <= 0.0:
            continue
        s += i * dp[Y][i]
    print(int(s))

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = list(map(int, input().split()))
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

Measured memory_bytes: 10960
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readContents 2 >>= main'
    where
        main' [[n, m, c], bs] = readContents n >>= print . solve c bs

solve :: Int -> [Int] -> [[Int]] -> Int
solve c bs = length . filter (> 0) . map mf
    where
        mf = (+ c) . sum . zipWith (*) bs

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
#include <iostream>

using namespace std;

int main() {

	int a, b;
	double xi;
	int x;

	cin >> a >> b;
	xi = (a + b) / 2;

	if ((a + b) % 2 == 0)x = xi;
	else {
		x = ++xi;
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    string s;
    cin>>s;
    int ok = 0;
  	int n = s.length();
    for (int i=0; i<n; i++){
        if (s[i]=='7'){
            ok = 1;
            break;
        }
    }
    puts(ok?"Yes":"No");
 
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n+1);
    vector<int> dp(n+1);
    for (int i = 1; i < n+1; i++) {
        cin >> h.at(i);
    }
    dp.at(1) = 0;
    dp.at(2) = abs(h.at(2) - h.at(1)); 
    for (int i = 3; i < n+1; i++) {
        dp.at(i) = min(dp.at(i-1) + abs(h.at(i) - h.at(i-1)), dp.at(i-2) + abs(h.at(i) - h.at(i-2)));       
    }
    int ans = dp.at(n);
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

//		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		String T = sc.next();

		int count = 0;
		for(int i=0;i<3;i++) {
			if(S.substring(i,i+1).equals(T.substring(i,i+1)))count++;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 22612
s = input()
t = input()
ans = 10000
if t in s:
    print(0)
    exit()

for i in range(len(s)-len(t)+1):
    cut = s[i:i+len(t)]
    cnt = 0
    for k, j in zip(cut, t):
        if k != j:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        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 COM(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(){
  COMinit();
  long long n,k;
  cin >> n >> k;
  long long r=n-k;
  rep(i,k){
    long long y=i+1;
    cout << (COM(k-1,y-1)*COM(r+1,y))%MOD << endl;
  }
}


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

using namespace std;

template <typename M>
struct SegTree {
    using Op = function<M(const M&, const M&)>;
    M ID; // monoid identity
    Op op; // associative operation
    int N; // 2^lg space, for non-commutative
    vector<M> a;
    
    SegTree(int n, M leaf_default, M _ID, Op _op) : ID(_ID), op(_op) {
        init_space(n);
        fill(a.begin() + N, a.begin() + N + n, leaf_default);
        build();
    }
    SegTree(const vector<M> leaves, M _ID, Op _op) : ID(_ID), op(_op) {
        int n = leaves.size();
        init_space(n);
        copy(leaves.begin(), leaves.end(), a.begin() + N);
        build();
    }
    void init_space(int n) {
        N = 1; while (N < n) N<<=1;
        a.assign(N<<1, ID);
    }
    inline void pull(int i) { a[i] = op(a[i<<1], a[i<<1|1]); }
    void build() { for (int i = N-1; i >= 1; i--) pull(i); }

    void assign(int p, M val) {
        assert(0 <= p && p < N);
        for (a[p += N] = val; p >>= 1;) pull(p);
    }
    M query(int l, int r) const {
        assert(0 <= l && r <= N);
        M resl(ID), resr(ID);
        for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
            if (l & 1) resl = op(resl, a[l++]);
            if (r & 1) resr = op(a[--r], resr);
        }
        return op(resl, resr);
    }
    M query_point(int p) const { 
        assert(0 <= p && p < N);
        return a[p + N];
    }
    M query_all() const { return a[1]; }
};

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = 1<<(s[i]-'a');
    }
    SegTree<int> occur(a, 0, [](int u, int v){ return u|v; });

    int q; cin >> q;
    while (q--) {
        int op; cin >> op;
        if (op==1) {
            int i; char x;
            cin >> i >> x;
            i--;
            occur.assign(i, 1<<(x-'a'));
        } else {
            int l,r;
            cin >> l >> r;
            l--;
            cout << __builtin_popcount(occur.query(l,r))<<'\n';
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 8912
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
const ll MOD = 1e9+7;
const ll SIZE = 2010;
const ll inf = 1e18;
//LLONG_MIN

//AC
//

int main(void){
	ll d,g,p[100],c[100],ans=inf;
	cin>>d>>g;
	reg(i,1,d)cin>>p[i]>>c[i];
	for(ll i=0;i<(1<<d);i++){//bit総当たり
		ll sum=0,cnt=0;
		rep(j,d){
			if(i>>j & 1){//全部取る
				sum+=p[j+1]*(j+1)*100+c[j+1];
				cnt+=p[j+1];
			}
		}
		irep(j,d){
			if(!(i>>j & 1)){//最上位を取る
				ll a = (g-sum)/(100*(j+1));
				if(g-sum>0 && a<=p[j+1]){
					sum+=a*(j+1)*100;
					cnt+=a;
					if(sum<g && (a+1)<=p[j+1]){
						sum+=(j+1)*100;
						cnt+=1;
					}
					// printf("%lld,%lld,%lld\n",i,j,a);
				}
				break;
			}
		}
		if(sum>=g)ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using pint = pair<long long int,long long int>;

int n;
vector<pint> a;

int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a.at(i).first >> a.at(i).second;
	}

	for (int i = 1; i < n; ++i)
	{	
		if (a.at(i-1).first <= a.at(i).first && a.at(i-1).second <= a.at(i).second) continue;
		
		long long int r = max(a.at(i-1).first/a.at(i).first + (a.at(i-1).first%a.at(i).first!=0) , a.at(i-1).second/a.at(i).second + (a.at(i-1).second%a.at(i).second!=0));
		a.at(i).first *= r; a.at(i).second *= r;
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << a.at(i).first << a.at(i).second << endl;
	// }

	cout << a.at(n-1).first + a.at(n-1).second << endl;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll s,w; cin>>s>>w;
    if(w>=s)cout<<"unsafe\n";
    else cout<<"safe\n";
    return 0;
}
/*
5 10 10
22 23
17 19
13 17
8 12
2 6
*/


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, char *argv[])
{
  int n; ll a[200010], sum[200010];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    sum[i + 1] = sum[i] + a[i];
  }

  ll ans = LLONG_MAX;
  for (int i = 1; i <= n - 3; i++) {
    int l = 0, r = i + 1, med;
    ll lmin = LLONG_MAX, lmax = LLONG_MIN;
    ll rmin = LLONG_MAX, rmax = LLONG_MIN;
    
    while (r - l > 1) {
      med = (l + r) / 2;
      if (sum[med] < sum[i + 1] - sum[med]) l = med;
      else r = med;
    }
    if (sum[r] == sum[i + 1] - sum[r]) lmin = lmax = sum[r];
    else {
      if (2 * sum[r] - sum[i + 1] < -(2 * sum[l] - sum[i + 1])) {
	lmin = sum[i + 1] - sum[r];
	lmax = sum[r];
      } else {
	lmin = sum[l];
	lmax = sum[i + 1] - sum[l];
      }
    }

    l = i + 1; r = n;
    while (r - l > 1) {
      med = (l + r) / 2;
      if (sum[med] - sum[i + 1] < sum[n] - sum[med]) l = med;
      else r = med;
    }
    if (sum[r] - sum[i + 1] == sum[n] - sum[r])
      rmin = rmax = sum[r] - sum[r];
    else {
      ll x = -(2 * sum[l] - sum[i + 1] - sum[n]);
      ll y = 2 * sum[r] - sum[i + 1] - sum[n];
      if (x < y) {
	rmax = sum[n] - sum[l];
	rmin = sum[l] - sum[i + 1];
      } else {
	rmax = sum[r] - sum[i + 1];
	rmin = sum[n] - sum[r];
      }
    }
    //printf("l : %lld %lld\n", lmin, lmax);
    //printf("r : %lld %lld\n", rmin, rmax);
    //endl;
    ans = Min(ans, Max(rmax, lmax) - Min(rmin, lmin));
  }

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

  return 0;
}
    
    
    
    
  
	      


Measured memory_bytes: 3328
N = int(input(""))
A = [int(i) for i in input("").split(" ")]

ans = 0
if N != 1:
    for i in range(N - 1):
        if A[i] > A[i + 1]:
            step = A[i] - A[i + 1]
            ans += step
            A[i + 1] = A[i]

print(ans)


Measured memory_bytes: 32148
#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll; 
const ll MOD = 1000000007;

int main()  
{ 
    FAST_INP;
    int k;
    cin >> k;
	int val=7%k;
	for(int i=1;i<1e7;i++){
		if(val==0){
			cout << i << endl;
			return 0;
		}
		val=(val*10+7)%k;
	}
	cout << "-1" << endl;
    return 0;
} 

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


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

#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

void solve()
{
    int n; cin >> n;
    long long int count = 0;
    long long int prev = 0;
    REP(i, 0, n)
    {
        int x; cin >> x;
        if (x < prev)
            count += (prev - x);
        else
            prev = x;
    }
    
    cout << count << "\n";
}

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

    int t = 1; // cin >> t;

    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    K = int(input())
    ans = INF
    for a in range(N + 1):
        b = N - a
        ans = min(ans, 2 ** a + b * K)
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{ 
 	long int N;
    char *name;
    char c;
  cin>>N;
    N-=1;
    
    for(int i=1;i<2000;i++)
    {
      long int tmp=1;
      	for(int j=0;j<i;j++)
          tmp=tmp*26;
        if(N<tmp)
        {
            name=new char[i];
            for(int j=0;j<i;j++)
            {
                name[j]=N%26+97;
                N=N/26;
            }
            for(int j=i-1;j>=0;j--)
                cout<<name[j];

            delete[] name;   
            break;
        }
        else
            N-=tmp;
        
        
    }

}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Map<String, Integer> cache = new HashMap<String, Integer>();

        final Integer MAX = 1000000;
        boolean[] natural = new boolean[MAX];
        int[] counts = new int[MAX];

        for (int i = 2; i <= 500000; i++) {
            for (int j = 2; j <= Math.ceil(999999 / i); j++) {
                natural[i * j] = true;
            }
        }

        String line;
        while ((line = br.readLine()) != null && !line.isEmpty()) {
            if (cache.containsKey(line)) {
                System.out.println(cache.get(line));
                continue;
            }

            int cnt = 0;
            for (int i = 2; i <= Integer.parseInt(line); i++) {
                if (!natural[i]) cnt++;
            }
            cache.put(line, cnt);
            System.out.println(cnt);
        }
    }
}

Measured memory_bytes: 31052
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s;
	int ans = 0,tmp = 0;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			tmp++;
		}
		else {
			ans = max(tmp, ans);
			tmp = 0;
		}
	}
	ans = max(ans, tmp);
	cout << ans << endl;
}

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

int main(void){
	char s[100];
	int len;
	int k;

	scanf("%s", s);

	len = strlen(s);

	for (k = 0; k < len; k++) {
		s[k] = 'x';
	}

	printf("%s\n", s);

	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string ret = "";
    for (int i = 0; i < n; ++i) {
        ret += s.substr(i, 1) + t.substr(i, 1);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
open Scanf
let rec for_all_iter a b f = if a >= b then true else f a && for_all_iter (a+1) b f
let for_some_iter a b f = not @@ for_all_iter a b (fun a -> not (f a))
let () =
  let n, m = scanf "%d %d" (fun n m -> n, m) in
  let a = Array.init n (fun _ -> scanf " %s" (fun s -> s)) in
  let b = Array.init m (fun _ -> scanf " %s" (fun s -> s)) in
  let res = for_some_iter 0 (n-m+1) (fun i ->
    for_some_iter 0 (n-m+1) (fun j ->
      for_all_iter 0 m (fun k ->
        for_all_iter 0 m (fun l -> a.(i+k).[j+l] = b.(k).[l])))) in
  print_endline @@ if res then "Yes" else "No"


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>cnt(n);
    ll sum=0;
    bool f=0;
    ll ans=0;
    while(!f){
        bool ff=1;
        sum=0;
        rep(i,n)cnt[i]=0;
        rep(i,n){
            if(a[i]>=n){
                ff=0;
                ll s=a[i]-n+1;
                cnt[i]=(s-1)/n+1;
                sum+=cnt[i];
                a[i]-=cnt[i]*n;
            }
        }
        f|=ff;
        ans+=sum;
        rep(i,n){
            a[i]+=sum-cnt[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	vector<int>a(n);

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

	sort(a.rbegin(), a.rend());

	int ans = 0;

	vector<int>nxt(n);

	nxt[1] = 0;

	int delta = 2;

	for (int i = 1; i < n; i++) {

		if (i + delta < n) {
			nxt[i + delta] = i;
			nxt[i + delta - 1] = i;
		}
		else if (i + delta - 1 < n) {
			nxt[i + delta - 1] = i;
		}

		delta++;

	}


	//debug() << imie(nxt);


	for (int i = 1; i < n; i++) {

		if (i == 0 && i > 1) {
			continue;
		}
		ans += a[nxt[i]];
		//debug() << imie(ans) << imie(a[nxt[i]]);

	}



	cout << ans << endl;





}

Measured memory_bytes: 6352
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

long long int lower_fact(long long int n, int k) {
	return (k == 0) ? 1 : n * lower_fact(n - 1, k - 1);
}
long long int comb(int n, int r) {
	if (n < r) return 0;
	else return lower_fact(n, r) / lower_fact(r, r);
}
long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base;
	default: return power(base, exp & 1) * power(base * base, exp >> 1);
	}
}
long long int count_below(const std::string& str, int k, int digit) {
	if (k == 0) return 1;
	if (digit == str.size()) return 0;
	long long int result = 0;
	for (auto i = 1; i < 10; ++i) {
		if (str[digit] > '0' + i) {
			result += comb(str.size() - digit - 1, k - 1) * power(9, k - 1);
		}
		else if (str[digit] == '0' + i) {
			result += count_below(str, k - 1, digit + 1);
		}
	}
	if (str[digit] == '0') {
		result += count_below(str, k, digit + 1);
	}
	else {
		result += comb(str.size() - digit - 1, k) * power(9, k);
	}
	return result;
}

int main(){
	std::string str; std::cin >> str;
	int k; std::cin >> k;
	std::cout << count_below(str, k, 0) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/

vector<vector<ll>> G;
vector<bool> seen;
struct UnionFind{
  vector<ll> par,siz;
  
  UnionFind(ll N):par(N+1), siz(N+1, 1){
    for(int i = 0; i <= N; i++)
      par[i] = i;
  }
  
  void mkpar(ll n, ll set){//親はset=根
    for(auto next_n: G[n]){
      if(seen[next_n]) continue;
      seen[next_n] = true;
      par[next_n] = set;
      mkpar(next_n, set);
    }
  }

  void mkpar2(ll n){//親は1個上、引数1個
    for(auto next_n: G[n]){
      if(seen[next_n]) continue;
      seen[next_n] = true;
      par[next_n] = n;
      mkpar2(next_n);
    }
  }

  ll root(ll x){
    if(par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  
  void unite(ll x, ll y){
    ll rx = root(x), ry = root(y);
    if(rx == ry)
      return;
    par[ry] = rx;
    siz[rx] += siz[ry];    
  }
  
  bool issame(ll x, ll y){
    return root(x) == root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll N, M;
  cin >> N >> M;
  G.assign(N+1, vector<ll>());
  seen.assign(N+1, false);
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  UnionFind tree(N);
  seen[1] = true;
  for(int i = 1; i <= N; i++) tree.mkpar(i, i);
  ll ans = 0, tmp = 0;
  vector used(N+1, 0);
  for(int i = 1; i <= N; i++){
    used[tree.par[i]]++;
  }
  for(int i = 1; i <= N; i++){
    if (used[i])
      tmp++;
  }
  tmp--;
  cout << tmp << endl;
}


Measured memory_bytes: 12712
// AOJ 2399: Save Your Privacy!
// 2017.10.4 bal4u@uu

#include <stdio.h>
#include <string.h>

int rel[101][101], sz[101];
int mk[101];

int main()
{
	int n, i, j, x, m, p, ans;

	while (scanf("%d", &n) && n > 0) {
		memset(sz, 0, sizeof(sz));
		memset(mk, 0, sizeof(mk));
		for (i = 1; i <= n; i++) {
			scanf("%d", &m);
			for (j = 0; j < m; j++) {
				scanf("%d", &p);
				rel[p][sz[p]++] = i;
			}
		}

		scanf("%d", &m);
		for (i = 0; i < m; i++) {
			scanf("%d", &p);
			for (j = 0; j < sz[p]; j++) {
				x = rel[p][j];
				mk[x]++;
			}
		}

		for (ans = -1, x = 1; x <= n; x++) {
			if (mk[x] == m) {
				if (ans < 0) ans = x;
				else { ans = -1; goto Done; }
			}
		}
Done:
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1888
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
int A[100];
int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	cout << A[N - 1] - A[0] << endl;
	return 0;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    ll ans = LLONG_MAX;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll x = n / i;
            ans = min(ans, x - 1 + i - 1);
        }
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
import math

while True:
    n=int(input())
    if n==0:
        break
    G=[]
    for index in range(n):
        x,y,z,r=map(float,input().split())
        G.append((x,y,z,r))

    def distance(X,Y):
        d=(X[0]-Y[0])**2+(X[1]-Y[1])**2+(X[2]-Y[2])**2
        Max=X[3]+Y[3]
        if Max**2<d:
            return math.sqrt(d)-Max    
        else:
            return 0
    
    D=[[0]*n for _ in range(n)]
    #隣接行列
    for index1 in range(n):
        for index2 in range(index1+1,n):
            dist=distance(G[index1],G[index2])
            D[index1][index2]=dist
            D[index2][index1]=dist

    def prim(n,cost):
        mincost = [float("inf")]*n
        used = [False] * n
        mincost[0] = 0
        res = 0

        while True:
            v = -1
            for i in range(n):
                if (not used[i]) and (v == -1 or mincost[i] < mincost[v]):
                    v = i
            if v == -1:
                break
            used[v] = True
            res += mincost[v]
            for i in range(n):
                mincost[i] = min(mincost[i],cost[v][i])
        return res
    

    ans=prim(n,D)
    print('{:.3f}'.format(ans))


Measured memory_bytes: 5980
#include<iostream>
#include<cmath>

using namespace std;

struct Point {
    double x, y;
    Point(double x_ = 0, double y_ = 0):x(x_), y(y_) {}
    Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
};
istream &operator>>(istream &is, Point &p) {
    return is >> p.x >> p.y;
}
ostream &operator<<(ostream &os, Point &p) {
    return os << '(' << p.x << ", " << p.y << ')';
}

double herons_formula(double a, double b, double c) {
    double s = (a+b+c) / 2.0;
    double S = sqrt((a+b+c)*(b+c-a)*(a+c-b)*(a+b-c)) / 4.0;
    double r = S / s;
    return r;
}

double dist(const Point &a, const Point &b) {
    return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}

double angle(double a, double b, double c) {
    double cosA =  (b*b + c*c - a*a) / (2*b*c);
    return acos(cosA);
}

double f(double r, double A, double B, double C) {
    double nume = r * (1.0 + tan(B/4.0)) * (1.0 + tan(C/4.0));
    double deno = 2.0 * (1.0 + tan(A/4.0));
    return nume / deno;
}

int main() {
    cout.setf(ios::fixed);
    cout.precision(10);
    
    while (true) {
        Point p1, p2, p3;
        cin >> p1 >> p2 >> p3;
        if (p1.x == 0 && p1.y == 0 &&
            p2.x == 0 && p2.y == 0 &&
            p3.x == 0 && p3.y == 0) break;

        double a = dist(p1, p2);
        double b = dist(p2, p3);
        double c = dist(p3, p1);
        double r = herons_formula(a, b, c);

        double A = angle(a, b, c);
        double B = angle(b, a, c);
        double C = angle(c, a, b);

        double r1 = f(r, B, C, A);
        double r2 = f(r, C, A, B);
        double r3 = f(r, A, B, C);

        cout << r1 << " " << r2 << " " << r3 << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin >> S;

  ll ans = 1LL*sz(S)*(sz(S)+1)/2;
  vector<int> sa = suffix_array(S);
  vector<int> x = lcp_array(S, sa);
  rep(i,sz(S)-1)  ans -= x.at(i);
  cout << ans << endl;

  return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

typedef pair<int64_t, int64_t> P;
const int64_t INF = 1e18;

pair<vector<int64_t>, vector<int64_t>> dijkstra(int N, int s, vector<P> edges[]){
    vector<int64_t> dist(N, INF), num(N, 0);
    dist[s] = 0;
    num[s] = 1;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, s});
    while(que.size()){
        auto p = que.top(); que.pop();
        int i = p.second;
        int64_t d = p.first;
        if(d > dist[i]) continue;
        for(auto& e : edges[i]){
            int j = e.first;
            int64_t d2 = d + e.second;
            if(d2 == dist[j]){
                add(num[j], num[i]);
            }else if(d2 < dist[j]){
                num[j] = num[i];
                dist[j] = d2;
                que.push({d2, j});
            }
        }
    }
    return {dist, num};
}



int main(){
    int N, M, S[2];
    cin >> N >> M >> S[0] >> S[1];
    S[0]--; S[1]--;
    vector<P> edges[100000];
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }

    vector<int64_t> dist[2], num[2];
    for(int k=0; k<2; k++){
        auto res = dijkstra(N, S[k], edges);
        dist[k] = res.first;
        num[k] = res.second;
    }

    int64_t ans = num[0][S[1]] * num[0][S[1]] % MOD;
    int64_t D = dist[0][S[1]];
    for(int i=0; i<N; i++) if(dist[0][i] + dist[1][i] == D && 2*dist[0][i] == D){
        int64_t res = num[0][i] * num[1][i] % MOD;
        res = res*res % MOD;
        add(ans, MOD - res);
    }
    for(int i=0; i<N; i++) for(auto& e : edges[i]){
        int j = e.first, c = e.second;
        if(dist[0][i] + c + dist[1][j] == D && 2*dist[0][i] < D && 2*dist[1][j] < D){
            int64_t res = num[0][i] * num[1][j] % MOD;
            res = res*res % MOD;
            add(ans, MOD - res);
        }
    }
    cout << ans << endl;
}

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

int main(void) {
    int an, bn, m;
    cin >> an >> bn >> m;
    vector<int> a(an + 1);
    int am = 1e9;
    for (int i = 1; i <= an; i++) {
        cin >> a.at(i);
        am = min(am, a.at(i));
    }
    vector<int> b(bn + 1);
    int bm = 1e9;
    for (int i = 1; i <= bn; i++) {
        cin >> b.at(i);
        bm = min(bm, b.at(i));
    }
    vector<int> x(m);
    vector<int> y(m);
    vector<int> c(m);
    for (int i = 0; i < m; i++) {
        cin >> x.at(i) >> y.at(i) >> c.at(i);
    }
    int cm = 1e9;
    for (int i = 0; i < m; i++) {
        cm = min(cm, a.at(x.at(i)) + b.at(y.at(i)) - c.at(i));
    }
    cout << min(cm, am + bm) << endl;
    return 0;
}

Measured memory_bytes: 5032
#include <iostream>
#include <cstring>

#define max(x,y) (x)>(y) ? (x) : (y)

using namespace std;

int main()
{
	int cj,co,ci,level=0;
	char input[1000001];
	cin>>input;
	for (int i=0; i<strlen(input); i++) {
		if (input[i]=='J') {
			cj=1,i++;
			while (input[i]=='J') cj++,i++;
			if (input[i]!='O') {
				continue;
			} else {
				co=1,i++;
				while (input[i]=='O') co++,i++;
			}
			if (input[i]!='I') {
				i--;
				continue;
			} else {
				ci=1,i++;
				while (input[i]=='I') ci++,i++;
			}
			if (cj>=co&&co<=ci) level=max(level,co);
			i--;
		}
	}
	cout<<level<<endl;
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=1005,M=2005,mod=1e9+7,inf=2e9;
struct node{
	int x,y,w;
	inline bool operator <(const node &rhs)const{
		return w<rhs.w;
	}
}e[M],v[M];
int fa[N];
inline int find(ri x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int tot,head[N],nxt[N<<1],adj[N<<1],w[N<<1],power[M];
inline void addedge(ri x,ri y,ri z){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
	w[tot]=z;
}
inline int dfs(ri x,ri t,ri lst){
	if(x==t) return 0;
	for(ri res,y,i=head[x];i;i=nxt[i])
		if((y=adj[i])!=lst&&(res=dfs(y,t,x))!=-1)
			return max(res,w[i]);
	return -1;
}
int main(){
	ri n,m,i,cnt,x,y,ans,tmp;
	rll lim,cost;
	gi(n);gi(m);gi(lim);
	power[0]=1;
	for(i=1;i<=m;++i)
		gi(e[i].x),gi(e[i].y),gi(e[i].w),
		power[i]=power[i-1]*2%mod;
	sort(e+1,e+1+m);
	for(i=1;i<=n;++i) fa[i]=i;
	cost=0;cnt=0;tmp=0;
	for(i=1;i<=m;++i){
		x=find(e[i].x);
		y=find(e[i].y);
		if(x==y)
			v[++tmp]=e[i],
			v[tmp].w=e[i].w-dfs(e[i].x,e[i].y,0);
		else{
			fa[x]=y;
			addedge(x,y,e[i].w);
			addedge(y,x,e[i].w);
			cost+=e[i].w;
			++cnt;
		}
	}
	if(cnt<n-1) return puts("0"),0;
	if(cost==lim)
		ans=(ll)(power[n-1]-2+mod)*power[m-(n-1)]%mod;
	else
		ans=0;
	sort(v+1,v+1+tmp);
	for(i=1;i<=tmp;++i)
		if(cost+v[i].w==lim)
			ans=(ans+2ll*power[m-(n-1)-i])%mod; 
		else if(cost+v[i].w>lim)
			break;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2432