akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 100005
#define ins insert
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    string s[n];
    rep(i,0,n) cin>>s[i];
    int dp[n][m];
    rep(i,0,n) rep(j,0,m) dp[i][j]=0;
    dp[0][0]=1;
    rep(i,0,n){
        rep(j,0,m){
            if(i+j!=0){
                if(s[i][j]!='#'){
                    if(i>0) dp[i][j]+=dp[i-1][j];
                    dp[i][j]%=U;
                    if(j>0) dp[i][j]+=dp[i][j-1];
                    dp[i][j]%=U;
                }

            }
        }
    }
    cout<<dp[n-1][m-1];



}

Measured memory_bytes: 9088
#include <stdio.h>
 
int main()
{
  int s;
  scanf("%d",&s);
  int a,b,c,d;
  a=s/1000;
  b=(s-a*1000)/100;
  c=(s-a*1000-b*100)/10;
  d=s%10;
  if(a==0 && 1<=b && b<=9){
      if(c==0 && 1<=d && d<=9)puts("AMBIGUOUS");
      else if(c==1 && 0<=d && d<=2)puts("AMBIGUOUS");
      else puts("MMYY");
    }
  else if(a==1 && 0<=b && b<=2){
      if(c==0 && 1<=d && d<=9)puts("AMBIGUOUS");
      else if(c==1 && 0<=d && d<=2)puts("AMBIGUOUS");
      else puts("MMYY");
  }
  else if(c==0 && 1<=d && d<=9)puts("YYMM");
  else if(c==1 && 0<=d && d<=2)puts("YYMM");
  else puts("NA");
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout  << ":(" << endl;
  return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A+B;
  R = C+D;
  if( L > R ) {
    cout << "Left" << endl;
  } else if ( L < R ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;

int main()
{
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll sum=0;
    while(n)
    {
        n/=k;
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  for(auto c:s){
    c += n;
    c -= 'A';
    c %= 26;
    c += 'A';
    cout << c;
  }
  cout << endl;
  
  return 0;
}




Measured memory_bytes: 3732
tmp = input()

char_list = list()
acgt_list = list()
max_acgt = list()
acgt = ["A", "C", "G", "T"]
for char in tmp:
  if char in acgt:
    acgt_list.append(char)
    if len(max_acgt) < len(acgt_list):
      max_acgt = acgt_list
  else:
    if len(max_acgt) < len(acgt_list):
      max_acgt = acgt_list
    acgt_list = list()
print(len(max_acgt))

Measured memory_bytes: 3064
n,m,v,p=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
a=a[p-1:]
le=len(a)
l,r=0,le-1
#print(a)
def adopt(x):
    global a,n,m,v,p
    b=a[x]+m
    if b<a[0]:
        return False
    al=v*m
    al-=(n-x)*m
    if al<=0:
        return True
    s=x*b-sum(a[:x])
    #print(al)
    #print(s)
    if al>s:
        return False
    else:
        return True

while l+1<r:
    #print()
    #print(str(l)+" "+str(r))
    k=(l+r)//2
    if adopt(k):
        l=k
    else:
        r=k

if adopt(r):
    print(p+r)
else:
    print(p+l)


Measured memory_bytes: 14484
#include <cstdio>
#include <cassert>

int main(void) {
  char s[27];
  scanf("%s", s);
  for (int i=0; s[i]!='\0'; ++i) {
    for (int j=i+1; j>26||s[j]!='\0'; ++j) {
      assert(i<j);
      if (s[i] == s[j]) {
        printf("no\n");
        return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var x int64

	var countFive, countSeven int64
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d", &x)

		if x == 5 {
			countFive++
		} else if x == 7 {
			countSeven++
		}
	}

	if countFive == 2 && countSeven == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

int main()
{
    long long  a[5];
   long long  n;
    while(cin>>n)
    {

        for(int i=0;i<5;i++)
        {

            cin>>a[i];
        }
        sort(a,a+5);
        if(n<=a[0])
        {

            cout<<5<<endl;
        }
        else
        {   if(n%a[0]==0)
            cout<<n/a[0]+4<<endl;
            else

            cout<<n/a[0]+5<<endl;

        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

vector<int> nv;

int main()
{
  int n;
  int x,y,z;
  int f;

  cin >> n;
  nv.resize(n);

  for (x=1; x*x<=n-5; x++) {
    for (y=1; y*y<=n-5; y++) {
      for (z=1; z*z<=n-5; z++) {
        f = x*x+y*y+z*z+x*y+y*z+z*x;
        if (f>n) break;
        nv[f-1]++;
      }
    }
  }

  for (int i=1; i<=n; i++) {
    cout << nv[i-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int coin_num = sc.nextInt();
      	int target = sc.nextInt();
      	final int fivehund = 500;
      	if(coin_num * fivehund >= target)
        	System.out.println("Yes");
      	else
          	System.out.println("No");
    }
}

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


int main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  int ans = 0;
  for (int i=0; i<n; i++){
    cin >> h[i];
    if(h[i]>=k){ans++;}
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define DEV_VAL 1000000007

template <typename T>
void inputList(vector<T>* list, int n, int sortType = 0)
{
  repl(i, n)
  {
    T tmp;
    cin >> tmp;
    list->push_back(tmp);
  }
  if(sortType == 0)
  {
    sort(list->begin(), list->end());
  }
  else if(sortType == 1)
  {
    sort(list->begin(), list->end(), greater<T>());
  }
}

int main()
{
  int n;
  cin >> n;
  vector<int> ilist;
  inputList(&ilist, n, 2);
  int ans = 0;

  for(int x = 0; x < ilist.size(); x += 2)
  {
    if(ilist[x] % 2 == 1) ans++;
  }

  cout << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ll2;
typedef pair<ll, ll2> ll3;
#define mp make_pair
#define mt(x, y, z) mp(x, mp(y, z))
#define endl "\n"
#define pb push_back
#define all(x) x.begin(), x.end()
#define fori(x) for (ll i = 0; i < x; i++)
#define forj(x) for (ll j = 0; j < x; j++)
#define fork(x) for (ll k = 0; k < x; k++)
#define fst first
#define snd second
#define testcases(t) while (t--)
#define newline << endl << 
#define space << " " << 
#define printvector(x) for(auto ele : x){cout << ele space;} cout << newline;

void solve(){

	ll n;
	cin >> n;
	ll ans = 0;
	while(n >= 500){
		n-=500;
		ans+=1000;
	}
	while(n>=5){
		n-=5;
		ans+=5;
	}
	cout << ans << endl;

	return ;
}



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

	ll TC;
	// cin >> TC;
	TC=1;
	while(TC--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 256
// abc171_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const string str_table = "abcdefghijklmnopqrstuvwxyz";

int main() {
  ll N;
  cin >> N;
  vector<char> ans;
  while (N > 0) {
    N--;
    char tmp = str_table[N%26];
    ans.push_back(tmp);
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) {
    cout << x;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> A(n, vector<int> (m));
    
    REP(i, n) {
        cin >> c[i];
        REP(j, m) {
            cin >> A[i][j];
        }
    }

    int cost = 1e9;

    for (int bit = 0; bit < (1 << n); bit++) {

        vector<int> sum(m, 0);
        int cost_tmp = 0;

        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                cost_tmp += c[i];
                REP(j, m) {
                    sum[j] += A[i][j];
                }
            }
        }

        bool can = 1;
        for(int i = 0; i < m; i++) {
            if(sum[i] < x) can = 0;
        }
        
        if (can) cost = min(cost, cost_tmp);
    }

    if (cost == 1e9) {
        cout << -1 << endl;
    } else {
        cout << cost << endl;
    }



    return 0;
}

Measured memory_bytes: 3604
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

xs, ys, xt, yt = map(int, input().split())
n = int(input())

p = [(xs,ys,0),(xt,yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
edge = [[-1]*(n+2)for i in range(n+2)]
 
for i in range(n+2):
    for j in range(i+1,n+2):
        edge[i][j] = edge[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0.0)

G = csgraph_from_dense(edge,null_value=-1)
print(dijkstra(G,indices=0)[1])

Measured memory_bytes: 63152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

vector<int32_t> dp;
vector<vector<int32_t>> graph;

int32_t dfs(int32_t node) {
	if (graph[node].size() == 0) return 0;
	if (dp[node]) return dp[node];

	int32_t max_path = 0;
	for (int32_t child : graph[node]) {
		max_path = max(max_path, dfs(child) + 1);
	}

	dp[node] = max_path;
	return max_path;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n, m;
	cin >> n >> m;
  dp.reserve(n);
  graph.reserve(n);
  rep(i, n) {
    dp.push_back(0);
    graph.emplace_back();
  }

  rep(i, m) {
    int32_t from, to;
    cin >> from >> to;
    graph[from - 1].push_back(to - 1);
  }

	int result = 0;
	rep(i, n) {
		if (dp[i] == 0) {
			dp[i] = dfs(i);
			result = max(result, dp[i]);
		}
		//cerr << dp[i] << ' ';
	}
	cout << result;
}

Measured memory_bytes: 8192
from collections import deque

N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, c))
    edges[to].append((fr, c))

depth = [-1] * N
st = deque([(0, -1, 0)])  # now, parent, dep

while st:
    now, parent, d = st.pop()

    depth[now] = d

    for to, c in edges[now]:
        if to == parent:
            continue
        st.append((to, now, d + c))

ans = [d % 2 for d in depth]
print(*ans, sep='\n')

Measured memory_bytes: 45436
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

typedef pair<int, int> Pi;

#define F first
#define S second

int crossProduct(Pi p1, Pi p2) {
  return p1.F * p2.S - p2.F * p1.S;
}

int main(void) {
  int n, k = 1;

  while(cin >> n, n) {
    stack<Pi> st;
    int x, y;
    int sx, sy;
    cin >> sx >> sy;
    st.push(make_pair(sx, sy));
    for(int i = 1;i < n; i++) {
      cin >> x >> y;
      st.push(make_pair(x, y));
    }
    st.push(make_pair(sx, sy));
    Pi prev = st.top(); st.pop();
    int S = 0;
    while(st.size()) {
      Pi p = st.top(); st.pop();
      S += crossProduct(prev, p);
      prev = p;
    }
    cout << k++ << ' ' << fixed << setprecision(1) << S / 2.0 << endl;
  }
}


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

using namespace std;

#define ll long long

bool x[100001];
int c[100002];

void prime(int n) {
	fill(x, x+n+1, true);
	for (int i = 2; i <= sqrt(n); i++) {
		if (x[i] == true) {
			for (int j = i*i; j <= n; j+=i) {
				x[j] = false;
			}
		}
	}
}

void xd() {
	for (int i = 3; i <= 100000; i+=2) {
		if (x[i] && x[(i+1)/2]) {
			c[i]++;
		}
	}
	for (int i = 3; i <= 100000; i++) {
		c[i] += c[i-1];
	}
}

void solve() {
	int a, b;
	cin >> a >> b;
	cout << c[b] - c[a-1] << "\n";
}


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

	int t = 1, i = 1;
	cin >> t;
	prime(100001);
	xd();
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define  fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
int main()
{
	fuckit();
	int h,w,i,j;
	cin>>h>>w;
	char c[h+1][w+1],C[h*2+1][w];
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			cin>>c[i][j];
		}
	}
	for(i=1;i<=2*h;i++){
		for(j=1;j<=w;j++){
			C[i][j]=c[(i+1)/2][j];
		}
	}
	for(i=1;i<=2*h;i++){
		for(j=1;j<=w;j++){
			cout<<C[i][j];
		}
		cout<<"\n";
	}
	return 0;	
}


Measured memory_bytes: 256
import sys
N = int(input())
pre_a = int(input())
if pre_a != 0:
    print(-1)
    sys.exit()
ans = 0
for i in range(N-1):
    ai = int(input())
    if ai - pre_a < 1:
        ans += ai
    elif ai - pre_a == 1:
        ans += 1
    else:
        ans = -1
        break
    pre_a = ai

print(ans)

Measured memory_bytes: 75980
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n,m,p;cin>>n>>m>>p,n;){
    double nr[100][100]={};
    int d[100][100];
    const int INF=1<<29;
    fill(d[0],d[100],INF);
    for(int i=0;i<n;i++){
      d[i][i]=0;
    }
    while(m--){
      int s,t,u;
      cin>>s>>t>>u;
      d[s][t]=d[t][s]=u;
      nr[s][t]=nr[t][s]=1;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  int nd=d[j][i]+d[i][k];
	  if(nd<=d[j][k]){
	    if(nd<d[j][k]){
	      nr[j][k]=0;
	    }
	    d[j][k]=nd;
	    nr[j][k]+=nr[j][i]*nr[i][k];
	  }
	}
      }
    }
    while(p--){
      int c;
      cin>>c;
      cout.precision(9);
      cout<<fixed<<((c==0||c==n-1)?1:(d[0][c]+d[c][n-1]!=d[0][n-1])?0:nr[0][c]*nr[c][n-1]/nr[0][n-1])<<endl;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1356
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int temp=n;
int fx=0;
while(temp>0){
fx+=temp%10;
temp/=10;
}
String ans="";
if(n%fx==0){ans="Yes";}else{ans="No";}
System.out.println(ans);
}}

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

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

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

int N,M;
int ans = 0;
vector<vector<int>> G;

void dfs(int now, unsigned int bits){
  bits |= (1<<now);

  if(__builtin_popcount(bits) == N) {
    ans += 1;
    return;
  }

  for(auto e:G[now]){
    if(!(bits & (1<<e))){
      dfs(e,bits);
    }
  }

}

int main(){

  cin >> N >> M;
  G.resize(N);

  rep(i,M){
    int from,to;
    cin >> from >> to;
    from--;to--;

    G[from].push_back(to);
    G[to].push_back(from);
  }

  dfs(0,0b00000000);
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
 int N,X,x;
 scanf("%d",&N);
 int A[N];
 for(int i=0;i<N;i++){
   scanf("%d",&A[i]);
   X += A[i];
   if(i%2==1 && i<N )X-=2*A[i];  
}
  printf("%d",X);
  for(int i=0;i<N-1;i++){
  X = 2*A[i%N] - X;
  printf(" %d",X);
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main() {
	int N;
	int ans = 0;
	cin >> N;
	int h[100] = {};
	int ruiseki[100] = {};
	for (int i = 1; i < N + 1; i++)cin >> h[i];
	for (int i = 1; i < N + 1; i++) {
		ruiseki[i] = h[i] - h[i - 1];
	}
	for (int i = 1; i < N + 1; i++) {
		if (ruiseki[i] > 0)ans += ruiseki[i];
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

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

int main(void){
  long long n, a[200010], sum=0, x=0, min=10000000000000000, y=0;
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> a[i];
  	sum += a[i];
  }
  for(int i=0;i<n-1;++i){
    x += a[i];
    y = sum - x;
    long long tmp = abs(x-y);
    if(min > tmp) min = tmp;
  }
  cout << min << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
bool checkValue(long long v){
    while(v>0){
        if((v%7!=0)||(v%10==0))return false;
        v/=10;
    }
    return true;
}
int main(){
    long long x;
    cin >> x;
    unsigned long long value = 7;
    vector <long long> result;
    long long cnt = 0;
    while(value>0){
        cnt++;
        //cout << value%x << endl;
        value = value%x;
        if(value==0){
            cout << cnt << endl;
            return 0;
        }
        //if(result.size()%10000!=0){
            //for(long long i = 0; i < result.size(); i++){
                //if(result[i]==value){
                    //cout << -1 << endl;
                    //return 0;
                //}
            //}
        //}
        if(result.size()>=10000000){
            cout << -1 << endl;
            return 0;
        }
        result.push_back(value);
        value = value*10+7;
    }
    return 0;
}

Measured memory_bytes: 134400
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define MAXN   200005 

ll n;
map<int,int> dp[100005][2];
vector<int> v[100005];

ll rec(int ver,int col,int par)
{
	if(dp[ver][col][par]!=0)
		return dp[ver][col][par];
	int sol=1;
	for(int i=0;i<v[ver].size();i++)
	{
		if(v[ver][i]!=par)
		
			if(col==0)
			{
				sol=	(sol%mod*rec(v[ver][i],1,ver)%mod)%mod;
			}
			else
			{
				sol=(sol%mod*(rec(v[ver][i],1,ver)%mod+rec(v[ver][i],0,ver)%mod)%mod)%mod;
			}

		
		



	}
	dp[ver][col][par]=sol;
	return sol;
}




int main()
{
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	v[a].push_back(b);
    	v[b].push_back(a);
    }
    
    cout<<(rec(1,0,-1)%mod+rec(1,1,-1)%mod)%mod;


   return 0;
}
	

	
	
	
	
 


Measured memory_bytes: 36992
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int dp[100005];
	int i;
	for (i = 0; i <= n; i++)
		dp[i] = i;
	int k;
	for (k = 1; k <= n; k *= 6)
		for (i = 0; i <= n - k; i++)
			if (dp[i + k] > dp[i] + 1)
				dp[i + k] = dp[i] + 1;
	for (k = 1; k <= n; k *= 9)
		for (i = 0; i <= n - k; i++)
			if (dp[i + k] > dp[i] + 1)
				dp[i + k] = dp[i] + 1;
	printf("%d\n", dp[n]);
	return 0;
}

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

int main()
{
    int n;
    float sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int j;
        scanf("%d", &j);
        sum += 1.0 / j;
    }
    printf("%f\n", 1 / sum);
    return 0;
}

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

Turn="Alice"
while True:
    if Turn=="Alice":
        if A==1 and B==2:
            print("Borys")
            break
        if A+1==B:
            A-=1
        else:
            A+=1
        Turn="Borys"
    else:
        if A==N-1 and B==N:
            print("Alice")
            break
        if A==B-1:
            B+=1
        else:
            B-=1
        Turn="Alice"


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

int gcd(int a, int b){
	return (b>0)? gcd(b, a%b) : a;
}
int lcm(int a, int b){
	return a / gcd(a, b) * b;
}

int main(){
	int a,b,n,m;
	
	while( cin >> a >> b ){
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let k: i64 = read();

    for i in a..std::cmp::min(b, a + k - 1)+1 {
        println!("{}",i);
    }
    for i in std::cmp::max(b - k + 1, a + k)..b+1{
        println!("{}",i);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，DP
// 存在判定：構成方法，入力の特徴
// 例外を十分に含む一般化．想像力の限界
// 場合分けを書き出す．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N; cin >> N;
VS s(N); rep(i, 0, N) cin >> s[i];
int cnt = 0, cntAB = 0, cntA = 0, cntB = 0;
rep(i, 0, N){
    if (s[i][0] == 'B') 
        if (s[i].back() == 'A') ++cntAB;
        else ++cntB;
    else if (s[i].back() == 'A') ++cntA;

    rep(j, 0, s[i].size()-1){
        if (s[i].substr(j, 2) == "AB") ++cnt;
    }
}

if (cntA + cntB)
    cout << cnt + cntAB + min(cntA, cntB) << "\n";
else
    cout << cnt + max(0, cntAB - 1) << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 768
#include <iostream>
#include <sstream>
int INF=1000000000;
int cnt=0;
void merge(int A[],int left,int mid,int right){
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1];
  int R[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      cnt++;
    }else{
      A[k]=R[j];
      j++;
      cnt++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  int left=0;
  int right=n;
  mergeSort(A,left,right);
  for(int i=0;i<n-1;i++){
    std::cout<<A[i]<<" ";
  }
  std::cout<<A[n-1]<<"\n";
  std::cout<<cnt<<"\n";
  return 0;
}


Measured memory_bytes: 6988
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];

            if (A == B)
            {
                Console.WriteLine(C);
            }
            else if (A == C)
            {
                Console.WriteLine(B);
            }
            else
            {
                Console.WriteLine(A);
            }
        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(n);
    cin >> a[0];
    int ans = 1;
    bool up = false, down = false, next = true;
    for(int i = 1; i < n; i++){
        cin >> a[i];
        if(a[i] == a[i-1]) continue;
        if(next){
            if(a[i] > a[i-1]) up = true;
            else down = true;
            next = false;
        }
        else{
            if(up){
                if(a[i] < a[i-1]){
                    up = false;
                    ans++;
                    next = true;
                }
            }
            else if(down){
                if(a[i] > a[i-1]){
                    down = false;
                    ans++;
                    next = true;
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            string[] s2 = Console.ReadLine().Split(' ');
            string[] s3 = Console.ReadLine().Split(' ');
            int[,] c = new int[3,3];
            int[] a = new int[3];
            int[] b = new int[3];

            for (int i = 0; i < 3; i++)
            {
                c[i, 0] = int.Parse(s1[i]);
                a[i] = int.Parse(s1[i]);
            }
            for (int i = 0; i < 3; i++)
            {
                c[i, 1] = int.Parse(s2[i]);
            }
            for (int i = 0; i < 3; i++)
            {
                c[i, 2] = int.Parse(s3[i]);
            }
            b[0] = c[0, 0] - a[0];
            b[1] = c[0, 1] - a[0];
            b[2] = c[0, 2] - a[0];


            Boolean f = true;
            for (int i = 0; i < 3; i++)
            {
                for(int j = 0;j < 3; j++)
                {
                    if(c[i,j] != a[i] + b[j])
                    {
                        f = false;
                    }
                }
            }
            if (f)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut sum = 0;
	for i in 0..n {
		let v:Vec<i32> = procon_read();
		let li = v[0];
		let ri = v[1];
		sum += (ri - li) + 1;
	}
	println!("{}", sum);
}

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

ll inf=1e10;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> dp(n,inf);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  reverse(a.begin(),a.end());
  for(ll i=0;i<n;i++) {
    *upper_bound(dp.begin(),dp.end(),a[i])=a[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(dp[i]!=inf) {
      ans=i+1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main() {
	int n;
	std::cin>>n;
	std::cout<<(1000000-n)%1000<<std::endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
	int d; cin >> d;
	int c[26];
	for (int i = 0; i < 26; i++) cin >> c[i];
	int s[d][26];
	for (int i = 0; i < d; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			cin >> s[i][j];
		}
	}
	int t[d];
	for (int i = 0; i < d; i++) {
		cin >> t[i];
		t[i]--;
	}

	int last[26] = {};
	int v = 0;

	for (int i = 0; i < d; i++)
	{
		v += s[i][t[i]];
		last[t[i]] = i+1;
		for (int j = 0; j < 26; j++)
		{
			v -= c[j] * (i + 1 - last[j]);
		}
		cout << v << endl;
	}

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n;
string a[200];
unordered_set <string> s;
int32_t main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	s.insert(a[0]);
	for(int i = 1; i < n; ++i) {
		int b = s.size();
		if (a[i][0] != a[i-1][a[i-1].length()-1]) {
			cout << "No";
			return 0;
		}
		s.insert(a[i]);
		if (b == s.size()) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<complex>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

bool dfs(ll pos, ll iro, vector<ll>& col, vector<vector<ll>>& adj) {
	col[pos]=iro;
	ll niro=0;
	if(iro%2) niro=iro-1;
	else niro=iro+1;
	bool ret=true;
	REP(i,(ll)adj[pos].size()) {
		if(col[adj[pos][i]]==-1) ret=ret&dfs(adj[pos][i],niro,col,adj);
		else if(col[adj[pos][i]]==iro) return false;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<vector<bool>> mat(n,vector<bool>(n,false));
	vector<vector<ll>> adj(n);
	REP(i,m) {
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
		mat[a][b]=true;
		mat[b][a]=true;
	}
	vector<vector<ll>> r_adj(n);
	REP(i,n) REP(j,n) {
		if(i==j) continue;
		if(!mat[i][j]) r_adj[i].pb(j);
	}
	vector<ll> col(n,-1);
	ll cnt=0;
	REP(i,n) {
		if(col[i]==-1) {
			//cout<<i<<endl;
			if(!dfs(i,cnt,col,r_adj)) {
				cout<<-1<<endl;
				return 0;
			}
			cnt+=2;
		}
	}
	vector<ll> c(cnt,0);
	REP(i,n) c[col[i]]++;
	vector<vector<bool>> dp(cnt/2,vector<bool>(n+1,false));
	dp[0][c[0]]=true;
	dp[0][c[1]]=true;
	for(ll i=2; i<cnt; i+=2) {
		for(ll j=0; j<n+1; j++) {
			if(j-c[i]>=0&&dp[i/2-1][j-c[i]]) dp[i/2][j]=true;
			if(j-c[i+1]>=0&&dp[i/2-1][j-c[i+1]]) dp[i/2][j]=true;
		}
	}
	ll ans=INF*INF;
	REP(i,n+1) {
		if(!dp[cnt/2-1][i]) continue;
		ll piy1=i;
		ll piy2=n-i;
		ans=min(ans,piy1*(piy1-1)/2+piy2*(piy2-1)/2);
	}
	cout<<ans<<endl;
}


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

int main()

{
    long long a, b;
    cin >> a>> b;
    long long mid  = (a+b)/2;
    if(mid-a == b-mid)
    {
        cout << mid << endl;
    }
    else
        cout << "IMPOSSIBLE\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <complex>
#include <cstdio>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = (1e-10);    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;
}

bool isecLL(P a1, P a2, P b1, P b2) {
  return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}


int main() {
  D xa, ya, xb, yb, xc, yc, xd, yd;
  while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
    P a1 = P(xa, ya);
    P a2 = P(xb, yb);
    P b1 = P(xc, yc);
    P b2 = P(xd, yd);
    
    if (isecLL(a1, a2, b1, b2) && EQ(dot(a1-a2, b1-b2), 0)) {
      std::cout << "YES" << std::endl;
    }else {
      std::cout << "NO" << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1240
#!/usr/bin/env python3
n, m = map(int, input().split())
dp = [float('inf')] * 2**n
dp[0] = 0
for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(i)-1) for i in input().split()])
    for s in range(2**n):
            t = s|c
            if dp[t] > dp[s] + a:
                dp[t] = dp[s] + a
ans = dp[-1]
if ans == float('inf'):
    ans = -1
print(ans)


Measured memory_bytes: 3188
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	RREP(i, n) {
		if (s.substr(n - 1 - i, i + 1) == t.substr(0, i + 1)) {
			cout << 2 * n - i -1<< endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	

}


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

typedef long long ll;

/* 
 * g++ -std=c++17 main.cpp -o main
 */
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n = s.size();
  ll total = 0;
  for(ll cuts = 0; cuts < (1ll << (n-1)); cuts++) {
    ll sum = s[0] - '0';
    for(int i = 0; i < n - 1; i++) {
      if((cuts >> i) & 1) {
        total += sum;
        sum = 0;
      }
      sum = sum * 10;
      sum += s[i+1] - '0';
    }
    total += sum;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: i64, b: i64, c: i64, k: i64);
    let mut tot = 0i64;
    let mut k = k;
    let r = min(k, a);
    tot += r;
    k -= r;
    let r = min(k, b);
    k -= r;
    let r = min(k, c);
    tot -= r;
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2240
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){

    int A = 0;
    int B = 0;
    double H = 0;
    double M = 0;
    double angle = 0;
    double answer = 0.0;
    scanf("%d %d %lf %lf", &A, &B, &H, &M);

    angle = H * 30.0 + 30.0 * (M / 60.0) - M * 6.0;
    angle = fabs(angle);
    if (angle > 180){
        angle = 360 - angle;
    }
    if (angle == 90){
        answer = sqrt(A * A + B * B);
    } else {
        answer = A * A + B * B - 2 * A * B * cos(angle * 3.1415926535897932 / 180.0);
        answer = sqrt(answer);
    }
    printf("%0.10lf\n", answer);

    return 0;
}

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;

  vector<int> ans(n, 0);
  rep(i, n) rep(j, n) {
    if (i >= j) continue;
    int d = min(j - i, abs(x - i) + abs(y - j) + 1);
    ans.at(d)++;
  }

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

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

using namespace std;
const int N = 1e6+100;
const long long INF = 999999999999;
long long dis[N][3];
vector<int> G[N];
bool vis[N][3];
struct node{
    int id;
    int  dis;
};
int n,m,S,T;
queue<node> q;
void dijkstra(int S){
    for(int i=1;i<=n+100;i++){
        for(int j=0;j<3;j++) dis[i][j]=INF,vis[i][j]=0;
    }
    dis[S][0]=0;
    q.push({S,0});
    while(!q.empty()){
        node rt=q.front();q.pop();
        int u=rt.id;
        int L=rt.dis;
        if(vis[u][L]) continue;
        vis[u][L]=1;
        for(auto v:G[u]){
            int nowL=(L+1)%3;
            if(dis[v][nowL]>dis[u][L]+1){
                dis[v][nowL]=dis[u][L]+1;
                q.push({v,nowL});
            }
        }
    }
}
int main(){
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        G[u].push_back(v);
    }
    cin>>S>>T;
    dijkstra(S);
    //cout<<dis[T][0]<<endl;
    if(dis[T][0]==INF) puts("-1");
    else cout<<dis[T][0]/3<<endl;
    return 0;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int x=1;
  for(int i=0;i<N;i++){
    if(K+x>=x*2){
      x*=2;
    }
    else{
      x+=K;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 998244353;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
const int biggg = 2000000000;
const long long biggest = 1000000000000000000LL;
const double eps = .0000000001; 


int main ()
{
  prep();
  int s, w;
  cin >> s >> w;
  cout << (s <= w? "unsafe":"safe");
  return 0;
}


Measured memory_bytes: 3612