akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;

namespace Solution
{
    class Solution
    {
        static void Main(string[] args)
        {
            List<int> mountains = new List<int>();
            for(int i = 0; i <= 9; i++)
            {
                int height = Int32.Parse(Console.ReadLine());
                for(int j = 0; j <= mountains.Count; j++)
                {
                    if (j == mountains.Count)
                    {
                        mountains.Add(height);
                        break;
                    }

                    if (height >= mountains[j])
                    {
                        mountains.Insert(j, height);
                        break;
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(mountains[0].ToString());
            sb.AppendLine(mountains[1].ToString());
            sb.Append(mountains[2].ToString());
            Console.WriteLine(sb.ToString());
        }

    }
}


Measured memory_bytes: 9128
import sys


def main():
    input = sys.stdin.readline
    N = int(input())
    S = input().strip()
    A = S.count('R')*S.count('G')*S.count('B')
    assert 1 <= N <= 4000
    total = 0
    for j in range(1, N-1):
        for i in range(j):
            k = 2*j-i
            if k < len(S):
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    total += 1
    print(A - total)


if __name__ == "__main__":
    main()


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


constexpr int P = 1'000'000'007;

void solve(std::istream &in, std::ostream &out) {
  int n, k;
  in >> n >> k;
  vector<int> pos, neg;
  bool zero = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    in >> x;
    zero |= x == 0;
    if (x > 0) pos.push_back(x);
    if (x < 0) neg.push_back(-x);
  }
  int ps = pos.size();
  int ns = neg.size();
  if (ps + ns < k) {
    out << 0 << '\n';
    return;
  } else if (ps + ns == k) {
    int ans = 1;
    for (int i = 0; i < ps; ++i) {
      ans = (int64_t) ans * pos[i] % P;
    }
    for (int i = 0; i < ns; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
    return;
  }
  sort(pos.rbegin(), pos.rend());
  sort(neg.rbegin(), neg.rend());
  vector<long double> lpos(1, 0), lneg(1, 0);
  for (int i = 0; i < ps; ++i) {
    lpos.push_back(lpos.back() + log((long double)pos[i]) + log2((long double)pos[i]));
  }
  for (int i = 0; i < ns; ++i) {
    lneg.push_back(lneg.back() + log((long double)neg[i]) + log2((long double)neg[i]));
  }
  vector<pair<double, int>> pp;
  if (ps > 0) {
    int ans = 1;
    int itt = (k - min(ps, k)) % 2 == 0 ? min(ps, k) : min(ps, k) - 1;   
    int  l = itt - 1, r = k - itt;
    while (l > 0 && r + 1 < ns && (int64_t) pos[l] * pos[l - 1] <= (int64_t) neg[r] * neg[r + 1]) {
      l -= 2;
      r += 2;
    }
    for (int i = 0; i <= l; ++i) {
      ans = (int64_t) ans * pos[i] % P;
    }
    for (int i = 0; i < r; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
  } else {
    if (k % 2 == 1) {
      if (zero) {
        cout << 0 << '\n';
        return;
      }
      reverse(neg.begin(), neg.end());
    }
    int ans = 1;
    for (int i = 0; i < k; ++i) {
      ans = (int64_t) ans * (P - neg[i]) % P;
    }
    out << ans << '\n';
    return;
  }
}


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

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int x = 0; x <= 50000; x++)
            {
                if (Math.Floor(x * 1.08) == n)
                {
                    Console.WriteLine(x);
                    return;
                }
            }
            Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 13140
#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(){
	ll a;
	double b;
	cin >> a >> b;
	ll c = b*100+0.5;
	ll ans = a*c/100;
	cout << ans << endl;
}

Measured memory_bytes: 3712
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b,x = map(int,input().split())
ab = a+b
if x>=a and x<=ab:
    print("YES")
else:
    print("NO")

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

long long h, n;
vector<long long> a, b;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> h >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i] >> b[i];

  cout << solve() << endl;
  return 0;
}
long long solve() {
  dp.assign(n + 1, vector<long long>(h + 1, 1e17));
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j <= h; ++j) {
      dp[i + 1][j] = dp[i][j];
      if(j >= a[i])
        dp[i + 1][j] =
            min(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
      else
        dp[i + 1][j] =
            min(dp[i + 1][j], dp[i + 1][0] + b[i]);
    }
  }
  return dp[n][h];
}

Measured memory_bytes: 78592
import java.util.Scanner;
import java.util.stream.Stream;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		int[] list = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int max = list[0];
		int result=1;
		
        for(int i=1;i<list.length;i++) {
        	if(max <= list[i]) {
        		result++;
        		max = list[i];
        	}
		}
    	System.out.println(result);
	}
}

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

using namespace std;

typedef long long ll;

const int N=1e6+5,M=1e3+7,mod=1e9+7;

int dx[]={0,1,-1,0},
    dy[]={1,0,0,-1};
              
char s[N];

int a[N],n,m,k,tc,ans,d;

map<pair<int,int>,int > e;
vector<pair<int,int> > edge;

vector<int> g[N];

void dfs(int u,int p){
    vector<int> colored;
    for(auto v:g[u]){
        int mn=min(u,v);
        int mx=max(u,v);
        int c=e[{mn,mx}];
        if (c!=0)
            colored.push_back(c);
    }
    sort(colored.begin(),colored.end());
    colored.push_back(0);
    int curr=1,l=0;
    for(auto v:g[u]){
        int mn=min(u,v);
        int mx=max(u,v);
        int c=e[{mn,mx}];
        if (c==0){
            while (curr == colored[l]){
                l++;
                curr++;
            }
            e[{mn,mx}]=curr++;
        }
    }
    ans=max(ans,curr-1);
    for(auto v:g[u])
        if (v!=p)
            dfs(v,u);

}

int main() {
    
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
        e[{min(u,v),max(u,v)}]=0;
        edge.push_back({u,v});
    }
    dfs(1,1);
    printf("%d\n",ans);
    for(auto p:edge){
        int mn=min(p.first,p.second);
        int mx=max(p.first,p.second);
        printf("%d\n",e[{mn,mx}]);
    }
}

Measured memory_bytes: 44536
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int a, b;
    cin >> a >> b;
    int num;
    if (abs(a - b) == 0)
    {
        if ((a * b * a) % 2 == 1)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else if (abs(a - b) == 1)
    {
        if ((a * b * b) % 2 == 1 || (a * b * a) % 2 == 1)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else if (abs(a - b) == 2)
    {
        if ((a * b * a) % 2 == 1 || (a * b * 2) % 2 == 1 || (a * b * 3) % 2 == 1)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    return 0;
}

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

using namespace std;

int main() 
{
    set <string> a;
    long n;
    cin >> n;
    for (long i = 0; i < n; i++)
    {
        string x;
        cin >> x;
        a.insert(x);
    }
    cout << a.size() << endl;
}


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

int main(){
    ll n, temp;
    vector<ll> an;
    cin >> n;
    for(auto i=0;i<n;i++){
        cin >> temp;
        an.push_back(temp);
    }
    ll xors = an.at(0);
    for(auto i=1;i<n;i++){
        xors = xors^an.at(i);
    }
    for(auto i=0;i<n;i++){
        ll ans = xors^an.at(i);
        cout << ans <<" ";
    }
    cout << endl;
}

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

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

int nbombs(int H, int W, string S[50], int x, int y) {
int bombcount=0, p, q;
  for(int i=0; i<8; ++i) {
    p = x+dx[i], q = y+dy[i];
    if(p>=0 && p<H && q>=0 && q<W && S[p][q] == '#')
      bombcount++;
  }
  return bombcount;
}

int main(){
  int H, W;
  string S[50];
  int p, q;
  bool cellflag;
  
  cin >> H >> W;
  for(int i=0; i<H; ++i) cin >> S[i];

  for(int x=0; x<H; ++x)
    for(int y=0; y<W; ++y)
      if(S[x][y] == '#') {
        cellflag = false;
      	for(int i=0; i<4; ++i) {
        	p=x+dx[i], q=y+dy[i];
        	if(p>=0 && p<H && q>=0 && q<W && S[p][q] == '#')
              cellflag = true;
        }
        if(!cellflag) {
          cout << "No" << endl;
          return 0;
        }
      }
  cout << "Yes" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll gcd(ll x,ll y){
  if(y==0)return x;
  return gcd(y,x%y);
}


int main(){
  int N,M;cin>>N>>M;
  string S,T;cin>>S>>T;
  int g = gcd(N,M);
  ll n=N/g,m=M/g;
  bool isok=true;
  repeat(i,g){
    isok &= S[i*n]==T[i*m];
  }
  cout << (isok? (ll)n*m*g:-1) << endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func NewScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func NewWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func ScanString(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan string failed")
	}
	return s.Text()
}

func ScanInt(s *bufio.Scanner) int {
	return int(ScanInt64(s))
}

func ScanInt64(s *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(ScanString(s), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	s := NewScanner()
	w := NewWriter()
	defer w.Flush()

	if ScanInt(s) < 1200 {
		fmt.Fprintln(w, "ABC")
	} else {
		fmt.Fprintln(w, "ARC")
	}
}



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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    ll tmp;
    rep (i, n) {
        cin >> tmp;
        a[i] = tmp - i;
    }

    ll b;
    vector<ll> aa = a;
    sort(all(aa));
    b = aa[n / 2];

    ll kanashimi = 0;
    rep (i, n)
        kanashimi += abs(a[i] - b);

    print(kanashimi);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 3328
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << '\n'; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...);}
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 1e16;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 61;
const int DIGITSIZE = 19;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
bool take_test_cases = 0;
bool print_case_no = 0;
int n,m;
ll k;
vector < ll > cost;
vector < ll > adj[13];
ll ans=inf;
void solve(int i , ll c, vector < int> curr){
    if(i==n){
        int count1=0;
        for(int l=0;l<m;l++){
           // cout<<curr[l]<<' ';
            if(curr[l]>=k){
                count1++;
            }

        }
         //cout<<'\n';
        if(count1==m){
            //cout<<c<<'\n';
            ans=min(ans,c);
        }
        return ;
    }
    solve(i+1,c,curr);
    for(int l=0;l<m;l++)
    {
        curr[l]+=adj[i][l];
    }
    solve(i+1,c+cost[i],curr);
    return ;
}
void getac(int T) {
    cin>>n>>m;
    cin>>k;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        cost.push_back(x);
        for(int j=0;j<m;j++){
            ll y;
            cin>>y;
            adj[i].push_back(y);
        }
    }
    vector < int > mp(m,0);
    solve(0,0,mp);
    if(ans==inf){
        cout<<-1<<'\n';
    }
    else{
        cout<<ans<<'\n';
    }
}
int  main()
{

    fastio;
    int t = 1;
    if (take_test_cases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (print_case_no)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

int op(int a, int b){return max(a, b);}
int e(){ return 0;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> dp(n+10, vector<int>(2));
  segtree<int, op, e> seg(300000+10);
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    // seg.set(a[i], 1);
  }
  dp[1][1] = 1;
  for (int i = 1; i < n+1; ++i) {
    dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
    dp[i][1] = seg.prod(max(0, a[i-1]-k), min(300000+10, a[i-1]+k+1)) + 1;
    seg.set(a[i-1], dp[i][1]);
  }

  // print(dp);
  cout << max(dp[n][0], dp[n][1]) << endl;
}


Measured memory_bytes: 24968
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
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;}


void solve() {
    int N;
    ll t;
    cin >> N;
    cin >> t;
    REP(_,N-1) {
        cerr << "t: " << t << endl;
        ll t2;
        cin >> t2;
        t = lcm(t,t2);
    }
    cout << t << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
n,m,c=map(int, input().split())
b=list(map(int, input().split()))
count=0
for _ in range(n):
    a=list(map(int, input().split()))
    all_sum=c
    for i in range(m):
        all_sum+=a[i]*b[i]
    if all_sum>0:
        count+=1
print(count)

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

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  int X;
  cin >> X;

  if( X < 1200) {
    cout << "ABC\n";
  } else if ( X >= 1200 ) {
    cout << "ARC\n";
  }

  return 0;
}


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

namespace AtCoder_Tutorial
{
    class Program
    {
        static double GetRadian(double angle)
        {
            return angle * Math.PI / 180.0;
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] sp = str.Split(' ');
            double A = double.Parse(sp[0]);
            double B = double.Parse(sp[1]);
            double hour = double.Parse(sp[2]);
            double min = double.Parse(sp[3]);

            // 長針
            double lx = B*Math.Cos(GetRadian(min*360/60 - 90.0));
            double ly = B*Math.Sin(GetRadian(min * 360 / 60 - 90.0));

            // 短針
            double sx = A * Math.Cos(GetRadian(hour * 360 / 12 + min * 0.5 - 90.0));
            double sy = A * Math.Sin(GetRadian(hour * 360 / 12 + min * 0.5 - 90.0));

            Console.WriteLine(Math.Sqrt((lx - sx) * (lx - sx) + (ly - sy) * (ly - sy)));
        }
    }
}


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


n, m = map(int, input().split())

edges = [set() for _ in range(n)]
for _ in range(m):
    _from, to = map(int, input().split())
    edges[_from-1].add(to-1)

first = list(edges[0])

possible = False
while first:
    island = first.pop()
    if n-1 in edges[island]:
        possible = True
        break

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE ")


Measured memory_bytes: 65908
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,m,ans=1,i,j;cin>>n>>m;
	for(i=2;i*i<=m;i++){
		int kou=0;
		while(m%i==0){kou++;m/=i;}
		for(j=n;j<n+kou;j++){ans*=j;ans%=mod;}
		for(j=1;j<=kou;j++){
			llint bgen=j;
			for(int h=0;h<30;h++){
				if((mod-2)&(1<<h)){ans*=bgen;ans%=mod;}
				bgen*=bgen;bgen%=mod;
			}
		}
	}
	if(m!=1){ans*=n;ans%=mod;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<int> a(n+1),b(n+1),c(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n;i++)cin>>c[i];
    int ans=accumulate(b.begin(),b.end(),0);
    for(int i=1;i<n;i++){
        if(a[i]+1==a[i+1])ans+=c[a[i]];
    }
    
    cout<<ans;
}

Measured memory_bytes: 256
using System;

namespace C_
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string station = Console.ReadLine();
                
                if(station.IndexOf("AAA") == 0 || station.IndexOf("BBB") == 0)
                {
                    Console.WriteLine("No");    
                }
                else
                {
                    Console.WriteLine("Yes");
                }
                

            }
            catch(Exception e)
            {
                throw;
            }

            

        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
// #define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
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;}
// head
const int mxN = 1e3;
int h, w;
int mp[mxN][mxN], dp[mxN][mxN];
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
	cin >> h >> w;
	string str;
	rep(i, 0, h){
		cin >> str;
		rep(j, 0, w){
			mp[i][j] = (str[j] != '#');
		}
	}
	rep(i, 0, h){
		if(mp[i][0]) dp[i][0] = 1;
		else break;
	}
	rep(i, 0, w){
		if(mp[0][i]) dp[0][i] = 1;
		else break;
	}
	rep(i, 1, h){
		rep(j, 1, w){
			if(mp[i][j]) {
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
			}			
		}
	}
	cout << dp[h-1][w-1] << endl;
}




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

int main() {
    int n,m;
    cin >> n >> m;
    vector<string> grid(n);
    rep(i,n) cin >> grid[i];

    //s -> even grid -> odd grid -> t
    mf_graph<int> g(n*m+2);
    int s = n*m, t = n*m+1;

    //s -> even  +  odd -> t
    rep(i,n) {
        rep(j,m) {
            if(grid[i][j] == '#') continue;
            int v = i*m + j;
            if((i+j) % 2 == 0) {
                g.add_edge(s,v,1);
            } else {
                g.add_edge(v,t,1);
            }
        }
    }

    //evem -> odd
    rep(i,n) {
        rep(j,m) {
            if((i+j) % 2 == 1 || grid[i][j] == '#') continue;
            int ve = i*m + j;
            if(i > 0 && grid[i-1][j] == '.') {
                int vo = (i-1)*m + j;
                g.add_edge(ve,vo,1);
            }
            if(j > 0 && grid[i][j-1] == '.') {
                int vo = i*m + j-1;
                g.add_edge(ve,vo,1);
            }
            if(i+1 < n && grid[i+1][j] == '.') {
                int vo = (i+1)*m + j;
                g.add_edge(ve,vo,1);
            }
            if(j+1 < m && grid[i][j+1] == '.') {
                int vo = i*m + j+1;
                g.add_edge(ve,vo,1);
            }
        }
    }

    cout << g.flow(s,t) << endl;

    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        int i0 = e.from / m, j0 = e.from % m;
        int i1 = e.to / m, j1 = e.to % m;

        if (i0 == i1 + 1) {
            grid[i1][j1] = 'v';
            grid[i0][j0] = '^';
        } else if (j0 == j1 + 1) {
            grid[i1][j1] = '>'; grid[i0][j0] = '<';
        } else if (i0 == i1 - 1) {
            grid[i0][j0] = 'v';
            grid[i1][j1] = '^';
        } else {
            grid[i0][j0] = '>'; grid[i1][j1] = '<';
        }
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }

}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int N;
main(){
  cin>>N;
  int result=N;
  for(int i=0;i<=N;++i){
    int n_count=0;
    int money6=i;
    int money9=N-i;
    while(money6){
      n_count+=money6%6;
      money6/=6;
    }
    while(money9){
      n_count+=money9%9;
      money9/=9;
    }
    result=min(result,n_count);
  }
  cout<<result<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<int>> cnt(n, vector<int>(26));
	rep(i,n){
		string s;cin >> s;
		rep(j,s.size()){
			cnt[i][s.at(j) - 'a']++;
		}
	}
	rep(i,26){
		int mi = 10000;
		rep(j,n){
			mi = min(mi,cnt[j][i]);
		}
		char c = 'a' + i;
		rep(j,mi) cout << c;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const long long INF=1LL<<60;
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; }
using namespace std;
 long long a [100010][3];
  long long dp[100010][3];
int main(){
int n; cin>>n;
 
for(int i=0;i<n;i++){
   for(int j=0;j<3;j++){
     cin>>a[i][j];
   }
 }
   
  for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
long long res=0;
  for (int j = 0; j < 3; ++j) chmax(res, dp[n][j]);
    cout << res << endl;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define eb emplace_back

typedef unsigned long long ll;
typedef long double ld;

const int IN_PROCESS = -2;
const int NOT_DONE = -1;
const int INF = 1e9;

template <class T>
struct segtree_t {
	vector<T> t;
	int n;
	
	segtree_t(const vector<T> &elems) {
		n = elems.size();
		t = vector<T>(2*n);
		for (int i=0; i<n; i++) {
			t[n+i] = elems[i];
		}
		build();
	}
 
	void build() {  // build the tree
		for (int i = n - 1; i > 0; --i) t[i] = min(t[i<<1], t[i<<1|1]);
	}
 
	void modify(int p, T value) {  // set value at position p
		for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = min(t[p], t[p^1]);
	}
 
	T query(int l, int r) {  // sum on interval [l, r)
		int res = INF;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l&1) res = min(res, t[l++]);
			if (r&1) res = min(res, t[--r]);
		}
		return res;
	}
};

int calc(vector<int> &cyclic, int idx, const vector<char> &T, const int step, const char expected) {
	//cout << "IDX " << idx << endl;
	if (T[idx] != expected) {
		return 0;
	}
	
	if (cyclic[idx] > 0) {
		return cyclic[idx];
	}
	
	if (cyclic[idx] == IN_PROCESS) {
		cyclic[idx] = INF;
		return INF;
	}
	
	cyclic[idx] = IN_PROCESS;
	int val = calc(cyclic, (idx+step)%T.size(), T, step, expected);
	if (val != INF) {
		val++;
	}
	cyclic[idx] = val;
	return val;
}

vector<int> prefix_function(vector<char> &s) {
    int n = (int)s.size();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	vector<char> S, T;
	
	string a, b; cin >> a >> b;
	
	S.reserve(b.length());
	for (char e : b) {
		S.pb(e);
	}
	
	unsigned int sz = 3 * max(a.length(), S.size());
	T.reserve(sz + a.length());
	while (T.size() < sz) {
		for (char e : a) {
			T.pb(e);
		}
	}
	
	vector<int> cyclic(T.size(), NOT_DONE);
	int n = S.size();
	for (int i=0; i<(int)cyclic.size(); i++) {
		if (cyclic[i] == NOT_DONE) {
			calc(cyclic, i, T, n, T[i]);
		}
		//cout << cyclic[i] << "\t";
	}
	
	segtree_t<int> seg(cyclic);
	
	vector<int> pref_size = prefix_function(S);
	
	int res = 0;
	
	int le = 0;
	for (int i=0; i<(int)T.size(); i++) {
		if (S[le] == T[i]) {
			le++;
			if (le == n) {
				//cout << "MATCH" << endl;
				res = max(res, seg.query(i-(n-1), i+1));
				le = pref_size[n-1];
			}
		} else {
			while (le > 0 && S[le] != T[i]) {
				le = pref_size[le-1];
			}
			if (S[le] == T[i]) {
				le++;
			}
		}
	}
	if (res == INF) {
		res = -1;
	}
	cout << res << endl;
	
	
}


Measured memory_bytes: 69660
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int c[4][4];
    int max=0;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            cin>>c[i][j];
            if(max<c[i][j])max=c[i][j];
        }
    }

    int a[4],b[4];
    int flag;

    
    
    for(a[1]=0;a[1]<=max;a[1]++){
        b[1]=c[1][1]-a[1];
        b[2]=c[1][2]-a[1];
        b[3]=c[1][3]-a[1];
        a[2]=c[2][2]-b[2];
        a[3]=c[3][3]-b[3];

        flag=1;
        for(int i=1;i<=3;i++){
            for(int j=1;j<=3;j++){
                if(a[i]+b[j]!=c[i][j])flag=0;
            }
        }
        if(flag){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    vector<int> p(m);
    rep(i, m){
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j, k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i, m) cin >> p[i];
    vector<int> count(m);
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        int on_count = 0;
        rep(i, m) count[i] = 0;
        rep(i, n){
            if(bit & (1 << i)){
                rep(j, m){
                    for(auto it : s[j]) if(i == it) count[j]++;
                }
            }
        }
        rep(i, m) if(count[i] % 2 == p[i]) on_count++;
        if(on_count == m) ans++;
    }
    cout << ans << endl;
}

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

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

	string s,t;
	cin>>s>>t;
	int cnt=0,sl=s.size(),tl=t.size();

	for(int i=0;i<sl-tl+1;i++)
	{
		int maxi=0;
		for(int j =0;j<tl;j++)
			if(s[i+j]==t[j])
				maxi++;
		cnt = max(cnt,maxi);
	}
	cout<<t.size()-cnt<<'\n';




    return 0;
		
}

Measured memory_bytes: 3656
/*
  AOJ 2619
  Title:Thread tree
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int N;
struct node_st 
{
  char message[51];
  int  link_ch;         
  int  link_br;
} node[1001];

void write_thread(int node_no,int depth)
{
  int i;
  for(i=0;i<depth;i++)
    printf(".");
  printf("%s\n",node[node_no].message);
  if(node[node_no].link_ch>0)
    write_thread(node[node_no].link_ch,depth+1);
  if(node[node_no].link_br>0)
    write_thread(node[node_no].link_br,depth);
}

void set_link(int x,int y)
{
  if(node[x].link_ch==0)
    {
      node[x].link_ch=y;
    }
  else
    {
      x=node[x].link_ch;
      while(node[x].link_br>0)
	{
	  x = node[x].link_br;
	}
      node[x].link_br=y;
    }
}

main()
{
  int i,re;
  
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    {
      scanf("%d",&re);
      if(i>0)
	set_link(re,i);
      scanf("%s",&(node[i].message[0]));
    }
  write_thread(1,0);
  
  return(0);
}

Measured memory_bytes: 696
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n , m;
  cin >> n >> m;
  vector<int> s[m];
  int p[m];

  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp - 1);
    }
  }

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

  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int on_cnt = 0;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (bit & (1 << s[i][j])) cnt++;
      }
      if (cnt % 2 == p[i]) on_cnt++;
    }
    if (on_cnt == m) ans++;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())

mod = []
if R+1-L<=2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod.append((i*j)%2019)

else:
    for i in range(L, L+2019):
        for j in range(i, L+2019+1):
            mod.append((i*j)%2019)


if len(mod)==0:
    print((L*R)%2019)
else:
    print(min(mod))


Measured memory_bytes: 75588
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long A, B, H, M;
    scan(A, B, H, M);
    real h = 2 * PI * ((H * 60 + M) / (12.0 * 60));
    real m = 2 * PI * (M / 60.0);
    real hx = A * cos(h);
    real hy = A * sin(h);
    real mx = B * cos(m);
    real my = B * sin(m);
    writefln("%.10f", sqrt((hx - mx) ^^ 2 + (hy - my) ^^ 2));
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define MAXSIZE 1e6+3

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

template<class T>
void show_1d_vector(const vector<T> &v){
    for(auto v1: v) {
        cout << v1 << " ";
    }
    cout << endl;
}
vector<ll> eratosthenes(ll n){
    vector<ll> arr(n,1);
	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(int j = 2; i * j < n; j++){
				arr[i*j] = 0;
			}
		}
	}
    return arr;
}

vector<ll> make_prime_list(ll n){
    vector<ll> prime = eratosthenes(n);
    vector<ll> prime_list;
    for(int i = 2; i < n; i++){
		if(prime[i]){
			prime_list.push_back(i);
		}
	}
    return prime_list;
}

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

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<ll> prime = make_prime_list(MAXSIZE);
    vector<ll> cnt(MAXSIZE,0);
    for(int i = 0; i < n; i++){
        ll t = a[i];
        map<ll,ll> mp;
        for(int j = 0; j < prime.size(); j++){
            if(sqrt(a[i]+1) < prime[j]){
                if(t != 1){
                    mp[t]++;
                }
                break;
            }
            while(t%prime[j] == 0){
                t /= prime[j];
                mp[prime[j]]++;
            }
        }
        for(auto itr = mp.begin(); itr != mp.end(); ++itr){
            cnt[itr->first] = max(cnt[itr->first], itr->second);
        }
    }
    map<ll,ll> c;
    for(int i = 0; i < MAXSIZE; i++){
        if(cnt[i] > 0){
            c[i] = cnt[i];
        }
    }

    mint lcm = 1;
    for(auto itr = c.begin(); itr != c.end(); ++itr){
        for(int i = 0; i < itr->second; i++){
            lcm *= itr->first;
        }
    }

    mint ans = 0;
    for(int i = 0; i < n; i++){
        mint b = lcm/a[i];
        ans += b;
    }


    cout << ans.x << endl;
    return 0;

}


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

int main()
{
	string s;
	cin >> s;
	bool ans = false;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '9')
			ans = true;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define US unordered_set
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
struct Node {ll v,d,p,l,r;};
typedef vector<Node> Tree;

int main(){
  ll N,T; cin>>N>>T;
  vi t(N); REP(i,N) cin>>t[i];
  ll ans=0;
  REP(i,N) if(i==N-1) ans+=T; else ans+=min(T,t[i+1]-t[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int x=0;
	double p,ans=0;
	for(int i=1;i<=n;i++)
	{
		int t=i;
		x=0;
		while(t<k)
		{
			t=t*2;
			x++;
		}
		
		ans+=pow(0.5,x);
		//cout<<x<<" "<<pow(0.5,x)<<" "<<ans<<endl;
	}
	ans/=n;
	printf("%0.10lf",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        String string = scanner.next();
        char[] chars = string.toCharArray();
        chars[k-1] = Character.toLowerCase(chars[k-1]);

        System.out.println(String.valueOf(chars));
    }
}

Measured memory_bytes: 21076
#!/usr/bin/env ruby

n = STDIN.gets.chomp.to_i
values = STDIN.gets.chomp.split(' ').map &:to_i
costs  = STDIN.gets.chomp.split(' ').map &:to_i

ans = 0
(0..(n-1)).each do |i|
  income = values[i] - costs[i]
  if income > 0
    ans += income
  end
end

puts ans


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

string s,r;

int main() {
	cin>>s;
	r=s;
	long long len=s.length();
	//cout<<len<<endl;
	for(long long i=0;i<len;i++) {
		r[i+1]=s[len-i-1];
	}
	for(long long i=len;i>=1;i--) {
		s[i]=s[i-1];
	}
	
	/*
	for(int i=1;i<=len;i++) {
		cout<<r[i]<<" ";
	} 
	cout<<endl;
	for(int i=1;i<=len;i++) {
		cout<<s[i]<<" ";
	}
	cout<<endl;
	*/
	for(long long i=1;i<=len;i++) {
		if(r[i]=='b') r[i]='d';
		else if(r[i]=='d') r[i]='b';
		else if(r[i]=='p') r[i]='q';
		else r[i]='p';
	}
	for(long long i=1;i<=len;i++) {
		//cout<<r[i]<<" "<<s[i]<<endl;
		if(r[i]!=s[i]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

ans = 0
idx = 0
cnt = 1
for a in range(N-1):
    ans += A[idx]
    cnt += 1
    if cnt == 2:
        idx += 1
        cnt = 0

print(ans)

Measured memory_bytes: 31604
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] data = new int[5];
		for(int i = 0;i < 5;i++) {
			data[i] = sc.nextInt();
		}
		int k = sc.nextInt();
		for(int i = 0;i < 5;i++) {
			for(int j = 0;j < 5;j ++) {
				if(Math.abs(data[i] - data[j]) > k) {
					System.out.println(":(");
					return;
				}
			}
		}
		System.out.println("Yay!");
	}
}

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

using namespace std;

using ll = long long;

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

    int n, m;
    cin >> n >> m;

    vector<ll> a(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        a[i] += a[i - 1];

    map<int, int> cnt;
    for (int i = 0; i <= n; ++i)
        ++cnt[a[i] % m];

    ll num = 0;
    for (const auto &it : cnt) {
        ll m = it.second;
        if (1 < m)
            num += m * (m - 1) / 2;
    }

    cout << num << endl;

    return 0;
}


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

int main() {

    long int n,m;
    cin >> n >> m;

    vector<int> a(n);
    long int total = 0;
    rep(i,n) {
        cin >> a.at(i);
        total += a.at(i);
    }
    sort(a.begin(),a.end(),greater<long int>());
    double cVal = (double) total / (4*m);
    rep(i,m){
        if(a.at(i) < cVal){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}   


Measured memory_bytes: 256
nums=[int(i) for i in input()]
ops=[1,-1]
ans=-1
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      if nums[0]+op1*nums[1]+op2*nums[2]+op3*nums[3]==7:
        ans=''+str(nums[0])
        ans+='+' if op1==1 else '-'
        ans+=str(nums[1])
        ans+='+' if op2==1 else '-'
        ans+=str(nums[2])
        ans+='+' if op3==1 else '-'
        ans+=str(nums[3])
        ans+='=7'
print(ans)

Measured memory_bytes: 3064