akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const ll mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


int a[10005];
int main()
{
	IO;
	int n{},ans{};
	cin>>n;
		For(j,1,101)
		{
			For(k,1,101)
			{
				For(jj,1,101)
				{
					if((j*j)+(k*k)+(jj*jj)+j*k+j*jj+k*jj<=10000)
						a[(j*j)+(k*k)+(jj*jj)+j*k+j*jj+k*jj]++;
				}
				
			}
		}
	For(i,1,n+1)
		cout<<a[i]<<'\n';

//	system("pause");
	return 0;
}

Measured memory_bytes: 3592
a=int(input())
lis=list(reversed(list(map(int,input().split()))))
cou2=0
for i in range(a-1):
  if lis[i+1]-lis[i]==1:
    lis[i+1]-=1
  elif lis[i+1]-lis[i]>1:
    cou2=1
if cou2==1:
  print("No")
else:
  print("Yes")

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

int main() {
  int N, K, m = 0, S = 0;
  cin >> N >> K;
  vector<int> v(N);
  REP(i, N) {
    cin >> v[i];
  }
  REP(i, K) {
    S += v[i];
  }
  m = S;
  REP(i, N - K) {
    S -= v[i];
    S += v[K + i];
    if (S > m) m = S;
  }
  cout << fixed << setprecision(8) << (double)(m + K) / 2 << endl;
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N	 = scan.nextInt();
		String S = scan.next();
		String front	= S.substring(0, S.length()/2);
		String behind	= S.substring(S.length()/2, S.length());

		if (N % 2 == 0 && front.equals(behind)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}
const int mod = 1000000007; 

long long inv[2001],fact[2001],ifact[2001];
long long comb(ll n, ll k)
{
	return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}



int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i=2;i<2001;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}
	
	ll N,K;
	cin>>N>>K;
	ll B=K;
	ll A=N-K;
	for(int i=1;i<=K;i++){
	    ll ans=0;
	    if(A+1>=i&&B-1>=i-1){
		ans=comb(A+1,i)*comb(B-1,i-1);
	    }
	    else ans=0;
		ans%=mod;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 105;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int a[4][4], n;
bool tag[4][4];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	for(int i=1; i<=3; i++)	
		for(int j=1; j<=3; j++)
			cin >> a[i][j];
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		for(int i=1; i<=3; i++)	
			for(int j=1; j<=3; j++)
				if(a[i][j]==x) tag[i][j] = 1;
	}
	bool ok = 0;
	for(int i=1; i<=3; i++) if(tag[i][1]&&tag[i][2]&&tag[i][3]) ok = 1;
	for(int i=1; i<=3; i++) if(tag[1][i]&&tag[2][i]&&tag[3][i]) ok = 1;
	if(tag[1][1]&&tag[2][2]&&tag[3][3]) ok = 1;
	if(tag[1][3]&&tag[2][2]&&tag[3][1]) ok = 1;
	if(ok) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]
btn=[0]*n
ans=1
i=0
while True:
  if btn[i]==1:
    print(-1)
    exit()
  if a[i]==2:
    print(ans)
    exit()
  btn[i]=1
  i=a[i]-1
  ans+=1


Measured memory_bytes: 7852
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    c = list(geta(int))
    c.sort(reverse=True)
    mod = 10**9 + 7
    dp = [0] * (N + 1)

    base = 1
    for n in range(1, N + 1):
        dp[n] = (4 * dp[n - 1] + (n + 1) * base * c[n - 1]) % mod
        base = (4 * base) % mod
    print(dp[N])


if __name__ == "__main__":
    main()

Measured memory_bytes: 78316
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, c;
    cin >> n >> c;
    using T = tuple<int, int, int>;
    vector<T> ps(n);
    int maxt = 0;
    repeat(i, n) {
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        maxt = max(t, maxt);
        ps[i] = T{s, t, c};
    }
    sort(ps.begin(), ps.end(), [] (const T &a, const T &b) {
        if (get<2>(a) != get<2>(b)) return get<2>(a) < get<2>(b);
        return get<0>(a) < get<0>(b);
    });
    
    vector<T> q;
    repeat(i, n) {
        T p = ps[i];
        if (q.size() == 0) {
            q.emplace_back(p);
        }
        else {
            T prevp = q.back();
            if (get<2>(prevp) == get<2>(p) && get<1>(prevp) == get<0>(p)) {
                q.pop_back();
                q.emplace_back( T{get<0>(prevp), get<1>(p), get<2>(p)} );
            }
            else {
                q.emplace_back(p);
            }
        }
    }
    
    vector<vector<bool>> on(c, vector<bool>(maxt + 1, false));
    repeat(i, q.size()) {
        int s = get<0>(q[i]);
        int t = get<1>(q[i]);
        repeat_from_to(j, s, t) {
            on[get<2>(q[i])][j] = true;
        }
    }
    
    int ans = 0;
    repeat(t, maxt + 1) {
        int num = 0;
        repeat(i, c) {
            if (on[i][t]) ++num;
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
            
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

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

    char* S = new char[15];

    scanf("%s", S);


    int lose = 0;
    while(*S)
    {
        if (*S == 'x')
        {
            ++lose;
        }
        ++S;
    }

    if (lose < 8)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::abs;

int
main()
{
  int N, A, B;
  cin >> N >> A >> B;
  cout << (abs(A - B) % 2 ? "Borys" : "Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
N = gets.chomp
=begin
N の 1 の位が 2,4,5,7,9のとき hon
Nの 1 の位が 0,1,6,8のとき pon
Nの 1 の位が 3 のとき bon
=end

if [2,4,5,7,9].include?(N[-1].to_i) then
  puts "hon"
elsif [0,1,6,8].include?(N[-1].to_i) then
  puts "pon"
else
  puts "bon"
end

Measured memory_bytes: 14360
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 n: u32 = read();
    let t: f32 = read();
    let a: f32 = read();
    let v: Vec<f32> = (0..n)
        .map(|_| read())
        .map(|x: f32| (a-(t-x*0.006)).abs())
        .collect();

    let mut cc: f32 = 1000000.0;
    let mut ans = 0;
    for (i, &d) in v.iter().enumerate() {
        if d < cc {
            cc = d;
            ans = i+1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
p = list(map(int, input().split(" ")))

s = list(range(1,len(p)+1))


is_ok = 1
m = 0
l = 0
for i, j in zip(p, s):
    if i == j:
        pass
    else:
        if m == 0:
            m = i
            l = j
        else:
            if i == l and j == m:
                pass
            else:
                is_ok = 0

if is_ok == 1:
    print('YES')
else:
    print('NO')


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

using namespace std;

int main(){
    int p[100010];
    int n;
    while(cin >> n, n){
        fill(p, p+100010, 0);
        int h1, m1, s1, h2, m2, s2;;
        for(int j=0; j < n; j++){
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            for(int i=h1*60*60+m1*60+s1; i < h2*60*60+m2*60+s2; i++) p[i]++;
        }
        int ret = 0;
        for(int i=0; i < 24*60*60+59*60+59; i++) ret = max(ret, p[i]);
        cout << ret << endl;
    }
}

Measured memory_bytes: 1628
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, t, x;
    cin >> n >> x >> t;
    cout << t * ((n+x-1)/x) << endl;
}


Measured memory_bytes: 3632
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import math
import sys
import heapq


# input
X,Y,Z,K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
B = list(map(int, sys.stdin.readline().rstrip().split()))
C = list(map(int, sys.stdin.readline().rstrip().split()))
A = sorted(A, key=lambda x:-x)
B = sorted(B, key=lambda x:-x)
C = sorted(C, key=lambda x:-x)

# solve
heap_q = []
heapq.heappush(heap_q, [-1*(A[0]+B[0]+C[0]), 0, 0, 0])
smt,at,bt,ct = [0, 0, 0, 0]

for _ in range(K):
  sm,a,b,c = heapq.heappop(heap_q)
  print(-sm)

  if len(heap_q) > 0:
    smt,at,bt,ct = heapq.heappop(heap_q)
  while len(heap_q) > 0 and sm==smt and a==at and b==bt and c==ct:
    smt,at,bt,ct = heapq.heappop(heap_q)
  heapq.heappush(heap_q, [smt,at,bt,ct])

  if a+1 < X:
    heapq.heappush(heap_q, [-A[a+1]-B[b]-C[c], a+1, b, c])
  if b+1 < Y:
    heapq.heappush(heap_q, [-A[a]-B[b+1]-C[c], a, b+1, c])
  if c+1 < Z:
    heapq.heappush(heap_q, [-A[a]-B[b]-C[c+1], a, b, c+1])



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

typedef long long LL;

#define INF 1000000000
#define INF_LL_YJ 1145141919810364364

using namespace std;

#define MAX_N 100005
int N;
int A[MAX_N];

void input()
{
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
}

bool solve()
{
  int a = 0, b = 0;
  for (int i = 0; i < N; i++) {
    if(A[i] % 2 == 0){
      a++;
    }
    else{
      b++;
    }
  }

  if(b % 2 == 1){
    return false;
  }
  else{
    return true;
  }

}

int main()
{
  input();

  if(solve()){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  int a=0,b=0,c=0;
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'a'){
      a++;
    }else if(S[i] == 'b'){
      b++;
    }else{
      c++;
    }
  }
  if(max({a,b,c}) - min({a,b,c}) <= 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b){if (a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b){if (a < b) a = b;}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

//勝ち局面かどうか
bool dp[100100];


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

	//負け局面で初期化
	for (int i = 0; i <= K; i++) {
		dp[i] = false;
	}

	//配るDP
	for (int i = 0; i <= K; i++) {
		//iが負け局面ならばiに遷移できるのは勝ち局面
		if (dp[i] == false) {
			rep(j, N) {
				if(i + a[j] <= K) dp[i + a[j]] = true;
			}
		}
	}
	//for (int i = 0; i <= K; i++) {cout << dp[i] << " ";}

	if (dp[K]) cout << "First" << endl;
	else cout << "Second" << endl;
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int ans=0;
    int length = s.size();
    rep(i,length){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
MOD = 10 ** 9 + 7

class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  MOD = 10 ** 9 + 7

  def initialize(n, mod: MOD)
    @mod = mod
    @finv = [1.mod_inverse, 1.mod_inverse]

    (2..n).each do |i|
      @finv[i] = finv[i - 1] * i.mod_inverse % mod
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fa = 1

    n.downto(n - k + 1) do |i|
      fa = (fa * i) % mod
    end

    (fa * finv[k]) % mod
  end
end

class Integer
  def mod_pow(n, mod = MOD)
    x = self
    res = 1

    while n > 0
      res = res * x % mod if n[0] == 1
      x = x * x % mod
      n >>= 1
    end

    res
  end

  def mod_inverse(mod = MOD)
    mod_pow(mod - 2, mod)
  end
end

N, A, B = gets.split.map(&:to_i)
mc = ModCombination.new([A, B].max)

puts (2.mod_pow(N) - mc.combination(N, A) - mc.combination(N, B) - 1) % MOD


Measured memory_bytes: 3528
program main
  implicit none
  integer :: n, i, k, res
  read(*, *) n
  read(*, *) k
  res = 1
  do i = 1, n
    if (res > k) then
      res = res + k
    else
      res = res * 2
    end if
  end do
  write(*, "(i0)") res
end program main


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
          int a,b,d,r;
          double f;
          scanf("%d %d",&a,&b);
          d=a/b;
          r=a%b;
          f=(double) a/(double) b;
          printf("%d %d %.5lf\n",d,r,f);

          return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
using namespace std;
#define mod 1000000007
const int maxn=1000000;
void solve() {
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<max({a*c,a*d,b*c,b*d});
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3644
h, w = gets.chomp.split(" ").map(&:to_i)
m = Array.new()
sharp = 0
h.times do
  row = gets.chomp.split("")
  sharp += row.count("#")
  m << row
end
cx = 0
cy = 0
(h + w - 2).times do |i|
# right
  if cx + 1 < w && m[cy][cx + 1] == "#" then
    cx += 1
    sharp -= 1
# down
  elsif cy + 1 < h && m[cy + 1][cx] == "#" then
    cy += 1
    sharp -= 1
  else
    puts "Impossible"
    exit
  end
end
 
if cx == w - 1 && cy == h - 1 && sharp == 1 then
  puts "Possible"
else
  puts "Impossible"
end
 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N, W;
  cin >> N >> W;
  ll dp[110][110000];
  for(int i=0; i<110; i++) for(int j=0; j<110000; j++) dp[i][j] = 0;

  ll w[N];
  ll v[N];
  for(int i=0; i<N; i++) cin >> w[i] >> v[i];

  dp[0][0] = 0; //でいいのか？
  for(int i=0; i<N; i++){
    for(int j=0; j<=W; j++){
      if(j >= w[i]){
        dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      }else dp[i+1][j] = dp[i][j];
    }
  }
/*  
  for(int i=0; i<=N; i++){
    for(int j=0; j<=W; j++){
      cout << dp[i][j] << ", ";
    }
    cout << endl;
  }
*/  
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 94720
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s; cin >> s;
  int ans = 0;

  if (s == "SUN") ans = 7;
  if (s == "MON") ans = 6;
  if (s == "TUE") ans = 5;
  if (s == "WED") ans = 4;
  if (s == "THU") ans = 3;
  if (s == "FRI") ans = 2;
  if (s == "SAT") ans = 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
a,b,x = map(int,input().split())

if x <= (a*a*b)/2:
  c = (2*x)/(a*b)
  tan = b/c
  print(np.rad2deg(math.atan(tan)))

elif x > (a*a*b)/2:
  c = ((2*x)/(a*a)) - b
  tan = (b-c)/a
  print(np.rad2deg(math.atan(tan)))
  

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

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = ((n)-1); i >= 0; --i)

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

const i32 MAX_W = 2000;
const i32 MAX_H = 2000;

i32 S[MAX_H][MAX_W];
i32 L[MAX_H][MAX_W];
i32 R[MAX_H][MAX_W];
i32 U[MAX_H][MAX_W];
i32 D[MAX_H][MAX_W];

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

	int H, W;
	cin >> H >> W;

	REP(i, H) {
		string s;
		cin >> s;
		REP(j, W) {
			S[i][j] = (s[j] == '#');
		}
	}

	REP(y, H) {
		REP(x, W) {
			if (S[y][x]) continue;
			U[y][x] = (y == 0) ? 1 : (U[y - 1][x] + 1);
			L[y][x] = (x == 0) ? 1 : (L[y][x - 1] + 1);
		}
	}
	REPR(x, W) {
		REPR(y, H) {
			if (S[y][x]) continue;
			D[y][x] = (y == H-1) ? 1 : (D[y + 1][x] + 1);
			R[y][x] = (x == W-1) ? 1 : (R[y][x + 1] + 1);
		}
	}

	i32 max_lighted = 0;
	REP(y, H) {
		REP(x, W) {
			const i32 num_lighted = L[y][x] + R[y][x] + U[y][x] + D[y][x] - 3;
			max_lighted = max(max_lighted, num_lighted);
		}
	}
	printf("%d\n", max_lighted);
	return 0;
}


Measured memory_bytes: 78464
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC143
{
    class D
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var L = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            var indexMax = 0;
            var count = 0;

            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    //indexMax = Array.BinarySearch(L, L[i] + L[j]);
                    //if (indexMax < 0) indexMax = ~indexMax;
                    //count += indexMax - (j + 1);

                    for (int k = N - 1; j < k; k--)
                    {
                        if (L[k] < L[i] + L[j])
                        {
                            count += k - j;
                            break;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11368
/*
 * src.cpp
 *
 *  Created on: 2016/08/15
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

const int MAX_N=4e2,MAX_C=4e2,MOD=1e9+7;

int N,C;
int A[MAX_N],B[MAX_N];

ll dp[MAX_N+1][MAX_C+1];
ll pw[MAX_C+1][MAX_C+1];

int main(){
    scanf("%d %d",&N,&C);
    REP(i,N){
        scanf("%d",&A[i]);
    }
    REP(i,N){
        scanf("%d",&B[i]);
    }
    FOR(i,1,MAX_C+1){
    	pw[i][0]=1;
    	FOR(j,1,MAX_C+1){
    		pw[i][j]=pw[i][j-1]*i%MOD;
    	}
    }
    FOR(i,1,MAX_C+1){
    	REP(j,MAX_C+1){
    		pw[i][j]+=pw[i-1][j];
    		pw[i][j]%=MOD;
    	}
    }
    dp[0][0]=1;
    FOR(i,1,N+1){
        REP(j,C+1){
            ll sum=0;
            REP(k,j+1){
            	ll t=(pw[B[i-1]][k]-pw[A[i-1]-1][k]+MOD)%MOD;
                sum+=dp[i-1][j-k]*t;
                sum%=MOD;
            }
            dp[i][j]=sum;
        }
    }
    printf("%lld\n",dp[N][C]);
    return 0;
}




Measured memory_bytes: 2816
N=int(input())
S=str(input())
ans=S.count('R')*S.count('G')*S.count('B')

for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i]==S[j]:
      continue
    if 2*j - i < N:
      if S[2*j - i] != S[i] and S[2*j - i] != S[j]:
        ans-=1
print(ans)


Measured memory_bytes: 67960
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long s=1;
int main() {
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		s*=i;
		s%=1000000007;
	}
	cout<<s<<endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll A,B,C,X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C>>X>>Y;
	ll mi=1LL<<60;
	for(int c=0;c<=200000;c+=2) {
		mi=min(mi,c*C+max(0LL,X-c/2)*A+max(0LL,Y-c/2)*B);
	}
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}



int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,k,x,q;
    int t=1;
    cin>>m>>x;
    int cnt = 0;
    for(int i=1;i<=m;i++){
        for(int j=2;j<=9;j++){
            for(int k=2;k<=9;k++){
                if((j*k) == i && (10*j+k)<=x)cnt++;
            }
        }
    }
    cout<<cnt<<"\n";


    
    return 0;
}


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

int main(){
  int a,b;
  char x;
  while(1){
    cin>>a>>x>>b;
    if(x=='?')break;
    if(x=='+')cout<<a+b<<endl;
    if(x=='-')cout<<a-b<<endl;
    if(x=='*')cout<<a*b<<endl;
    if(x=='/')cout<<a/b<<endl;
    
  }
}



Measured memory_bytes: 3100
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())
a = np.array(readline().split(), dtype=np.int64)
a = np.insert(a, n, 0)
C = 1000
I = 0
for i in range(n):
    if a[i] < a[i+1]:
        x = C // a[i]
        I += x
        C -= x * a[i]
    if a[i] > a[i+1]:
        C += I * a[i]
        I = 0
print(C)

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

using namespace std;

int main()
{
    int n; cin >> n;
    int a[3][109];
    int visited[3][109];

    for (int i = 0; i <= 2; i++) {
        for (int j = 0; j <= n; j++) {
            visited[i][j] = 0;
            a[i][j] = 0;
            // cout << i << ", " << j << endl;
        }
    }

    int maxCandies = 0;

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

    // search
    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == 1) {
                visited[i][j] = visited[i][j - 1] + a[i][j];
            } else {
                visited[i][j] = max(visited[i][j - 1] + a[i][j], visited[i - 1][j] + a[i][j]);
            }
        }
    }

    cout << visited[2][n] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<ctime>
#include<chrono>
#include<random>
using namespace std;
using ll = long long;

int d;
vector<vector<int>> s(365,vector<int>(26));
vector<int> c(26);

auto start=chrono::system_clock::now();
inline double get_time(){
    auto end=chrono::system_clock::now();
    auto dur=end-start;
    double msec=chrono::duration_cast<chrono::microseconds>(dur).count();
    return msec;
}

ll calc(vector<int> t){
    ll score=0;
    vector<int> last(26);
    for(int i=0;i<(int)t.size();i++){
        last[t[i]]=i;
        for(int j=0;j<26;j++) score-=c[j]*(i+1-last[j]);
        score+=s[i][t[i]];
    }
    return score;
}

void solve(){
    vector<int> v(d);
    srand(time(NULL));
    for(int i=0;i<d;i++) v[i]=rand()%26;
    ll score=calc(v);
    while(get_time()<190000){
        int i=rand()%d;
        int q=rand()%26;
        int old=v[i];
        v[i]=q;
        ll new_score=calc(v);
        if(score>new_score) v[i]=old;
        else score=new_score;
    }
    for(int k : v) cout<<k+1<<endl;
}

int main(){
    cin>>d;
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    solve();
}

Measured memory_bytes: 3656
// May be i don't deserve your attention...

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

#define F first
#define S second
#define pb push_back
#define elif else if
#define mp make_pair
#define int long long
#define ldd long double
#define vec_i vector<int>
#define pair_i pair<int,int>
#define sz(x) (int)(x.size())
#define vec_p vector<pair<int,int>>
#define vec_vec vector<vector<int>>
#define all(x) (x).begin(),(x).end()

#define forr(x,a,m) for(int x=a;x<m;x+=1)
#define debug(x) cout<<"~~"<<#x<<" => "<<x<<endl;

bool rev(int x, int y) {return x > y;}
void input_arr(int a[], int n) {forr(i, 0, n) cin >> a[i];}
bool sortbysec(const pair_i &a, const pair_i &b) {return a.S < b.S;}
bool sortinrev(const pair_i &a, const pair_i &b) {return (a.F > b.F);}
void print_vec(vec_i &v) {for (auto i : v) cout << i << " "; cout << endl;}
bool sortinrevbysec(const pair_i &a, const pair_i &b) {return (a.S > b.S);}
void print_arr(int a[], int n) {forr(i, 0, n)cout << a[i] << " "; cout << endl;}

template<typename...T>void input(T &...args) {((cin >> args), ...);}
template<typename...T>void print(T &&...args) {((cout << args << endl), ...);}
template<typename...T>void deb(T &&...args) {cout << "~~ "; ((cout << args << " "), ...); cout << endl;}

// ~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.

void stand8th() {
	int n; input(n);
	int a[n]; input_arr(a, n);
	int ans = 0;
	forr(i, 0, n) {
		forr(j, i + 1, n) {
			forr(k, j + 1, n) {
				if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) {
					ans++;
				}
			}
		}
	}
	print(ans);
}

// ~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.-.~.

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int tin = 1; //input(tin);
	while (tin--) {
		stand8th();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <cmath>

int shazou[8] = {0,9,9,909,909,90909,90909};

int main(){
  int n,f,g;
  int tmp,out;

  scanf("%d",&n);

  tmp = (int)std::log10((float)n);

  f = shazou[tmp];

  if(tmp%2==0){
    g = n + 1 - (int)std::pow(10,tmp);
    out = f + g;
  }else{
    out = f;
  }

  printf("%d\n", out);
  return 0;
}

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


int main(){
	int N;
	cin >> N;
	vector<vector<int>> A(2, vector<int>( N));
	int ans = 0;
	rep(i,N){
		cin >> A[0][i];
		ans += A[0][i];
	}
	rep(i,N) cin >> A[1][i];
	ans += A[1][N-1];
	int tmp = ans;
	for(int i = N -1; i >= 1; --i){
		tmp = tmp - A[0][i] + A[1][i-1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}














Measured memory_bytes: 3580
import java.util.ArrayList;
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		ArrayList<Integer> number = new ArrayList<>();
		ArrayList<Integer> count = new ArrayList<>();
		
		for(int add=0; scanner.hasNext();)
		{
			int input = scanner.nextInt();
			
			boolean is_add = false;
			for(int j=0; j<add; j++)
			{
				int no = number.get(j);
				if(input == no)
				{
					count.set(j, count.get(j)+1);
				}
			}
			if(!is_add)
			{
				add++;
				count.add(1);
				number.add(input);
			}
		}
		
		for(int i=0; i<number.size(); i++)
		{
			for(int j=i+1; j<number.size(); j++)
			{
				int n = number.get(i);
				int m = number.get(j);
				if(n > m)
				{
					number.set(i, m);
					number.set(j, n);
					
					int c0 = count.get(i);
					int c1 = count.get(j);
					count.set(i, c1);
					count.set(j, c0);
				}
			}
		}
		
		int max = 0;
		for(int i=0; i<number.size(); i++)
		{
			if(max < count.get(i))
			{
				max = count.get(i);
			}
		}
		
		for(int i=0; i<number.size(); i++)
		{
			if(max == count.get(i))
			{
				System.out.println(number.get(i));
			}
		}
	}
}

Measured memory_bytes: 26512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

int main(){
    int n; cin >> n;
    int Vlist[n];
    for (int i = 0; i < n; i++)
    {
        cin >> Vlist[i];
    }
    int Clist[n];
    for (int i = 0; i < n; i++)
    {
        cin >> Clist[i];
    }
    int diflist[n];
    for (int i = 0; i < n; i++)
    {
        diflist[i] = Vlist[i]-Clist[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (diflist[i]>0)
        {
            ans += diflist[i];
        }
        
    }
     
    cout << ans;
    return 0;
    
    
    
}

Measured memory_bytes: 256
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
for i in b1:
    for j in c1:
        if (i,j) not in d:
            print(bm+cm)
            exit()
print(bm+cm-1)

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

int main(){

	int a[5];
	int k,i;
	
	for(i=0;i<5;i++)
		cin >> a[i];
	
	cin >> k;

	
	if(a[4]-a[0]<=k)
		cout << "Yay!" << endl;
		
	else
		cout << ":(" << endl;
	
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	int n;
	cin >> n;

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			continue;
		}
		if (i % 5 == 0) {
			continue;
		}
		ans += i;
	}
	cout << ans << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


#define N 2000007
ll fac[N], inv[N], finv[N];

void cominit(int n) {
    int i;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (i = 2; i < n + 2; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
    return;
}

ll com(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    if (r == 0 || r == n) return 1;
    return (fac[n] * finv[r]) % mod * finv[n - r] % mod;
}

ll ml_pow(ll n, ll k, int p) {
    ll y, res;

    res = 1;
    y = n;
    while (k > 0) {
        if (k % 2 == 1) {
            res = res * y % p;
        }
        y = y * y % p;
        k /= 2;
    }

    return res;
}

int main(void) {
    int n, k, i, ans;
    string s;

    scanf("%d", &k);
    cin >> s;

    n = s.size();

    cominit(n + k);

    ans = 0;
    for (i = n; i <= n + k; i++) {
        ans = (ans + com(i - 1, n - 1) * ml_pow(25, i - n, mod) % mod * ml_pow(26, n + k - i, mod) % mod) % mod;
    }

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

    return 0;
}

Measured memory_bytes: 51192
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            //int cnt = int.Parse(Console.ReadLine());
            //double[] input=  Console.ReadLine().Split(' ').Select(double.Parse).ToArray();

            long ans = 0;
            long input = int.Parse(Console.ReadLine());
            ans = (input / 500) * 1000;

            if (input % 500 == 0)
            {
                //
            }
            else
            {
                ans = ans + (((input % 500) / 5 )* 5);

            }

            Console.WriteLine(ans);
                        
        }
    }
}




Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>
int main(void){
	double x1,y1,x2,y2,xq,yq,ax,ay,bx,by,b;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF){
		ax=x2-x1;ay=y2-y1;
		bx=ay;by=-ax;
		b=(ax*(yq-y1)-ay*(xq-x1))/(ay*bx-by*ax);
		printf("%lf %lf\n",xq+2*b*bx,yq+2*b*by);
	}
	return 0;
}

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

int main(){
    int n;
    scanf("%d",&n);
    vector<int>dp(3);
    for(int i=0;i<n;i++){
       vector<int>c(3,0);
       vector<int>ndp(3,0);
       for(int i=0;i<3;i++){
    	  scanf("%d",&c[i]);
       }
       for(int i=0;i<3;i++){
       	for(int j=0;j<3;j++){
       		if(i!=j){
       			ndp[j]=max(ndp[j],dp[i]+c[j]);
       		}
       	}
       }
       dp = ndp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));
	return 0;
}

Measured memory_bytes: 3788
import bisect
import collections

MOD = 1000000007
N, M = map(int, input().split(" "))
A = sorted(list(map(int, input().split(" "))))
B = sorted(list(map(int, input().split(" "))))
totalNum = N*M

if len(set(A)) != N or len(set(B)) != M:
    print(0)
    exit()
ans = 1
for i in range(totalNum):
    nowNum = totalNum - i
    aIndex = bisect.bisect_right(A, nowNum)
    bIndex = bisect.bisect_right(B, nowNum)

    flagA = False
    flagB = False

    if aIndex-1 >= 0:
        if A[aIndex-1] == nowNum:
            flagA = True
    if bIndex-1 >= 0:
        if B[bIndex-1] == nowNum:
            flagB = True
    canPutCount = 0
    if flagA and flagB:
        canPutCount = 1
    elif flagA:
        canPutCount = M - bIndex
    elif flagB:
        canPutCount = N - aIndex
    else:
        canPutCount = (N - aIndex) * (M - bIndex) - i

    if canPutCount <= 0:
        print(0)
        exit()
    else:
        ans = (ans * canPutCount) % MOD

print(ans)


Measured memory_bytes: 3564
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n, m, l = map(int, input().split())
INF = 1 << 60

# 距離のmatrixを作る
dist = [[INF] * n for _ in range(n)]

# 対角行列の成分は０
for i in range(n):
    dist[i][i] = 0

# 燃料の最大値より小さい場合に辺が張れる
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if c > l:
        continue
    dist[a][b] = c
    dist[b][a] = c

# 全点間の最短距離を求める
dist = floyd_warshall(csr_matrix(dist))

# 初期状態を１にする。燃料が足りない経路は迂回したいのでINFを置いておく
dist2 = np.full_like(dist, 1)
dist2[np.where(dist > l)] = INF

# 足し込むことで何回給油するべきかがわかる
dist2 = floyd_warshall(dist2, directed=False)
dist2 = dist2.astype(int)

# 無限大の経路は辿れない。-1を出力したいので０を置いていく
dist2[dist2 == INF] = 0

q = int(input())

# 初期状態を１としているので、１を引いて答えとする
ans = []
for _ in range(q):
    s, t = map(int, input().split())
    ans.append(dist2[s - 1, t - 1] - 1)

print(*ans, sep="\n")

Measured memory_bytes: 45548
#include<iostream>
using namespace std;
int main(){
  int n, k, i, ans;
  cin >> n;
  cin >> k;

  i = 0;
  ans = 1;

  while(i < n && ans < k){
    ans = ans * 2;
    i++;
//    cout << ans << endl;
  }

  while(i < n){
    ans = ans + k;
    i++;
//    cout << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	int a; int sum = 0;
	rep(i,0,N){ cin>>a; sum += a - 1; }
	cout<<sum<<endl;
}

Measured memory_bytes: 256
// -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"
const int mod = (1e9) + 7;
void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> arr(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    vector<vector<int>> dp(2, vector<int>(k + 1, 0));
    // dp[i][j] - ways of distributing j candies among i students
    // Memory Optimised
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dp[i%2][j] = 0;
            if (j == 0)
            {
                dp[i%2][j] = 1;
                continue;
            }
            if (arr[i - 1] >= j)
            {
                dp[i%2][j] += dp[(i + 1)%2][j];
            }
            else
            {
                dp[i%2][j] += dp[(i + 1)%2][j] - dp[(i + 1)%2][j - arr[i - 1] - 1];
            }
            dp[i%2][j] += dp[i%2][j - 1];
            dp[i%2][j] %= mod;
            dp[i%2][j] = (dp[i%2][j] + mod)%mod;
        }
    }
    cout << dp[n%2][k] % mod << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	
	int A,B;
	scanf("%d %d",&A,&B);
	
	int max = -10000000;
	if(max<A+B)max=A+B;
	if(max<A-B)max=A-B;
	if(max<A*B)max=A*B;
	
	printf("%d",max);
		
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int a; cin >> a; cout << a * a * a;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1, 2);
  a[0] = 0;
  a[1] = 1;
  rep2(i, 2, n+1){
    ll x = 2;
    while(i*x <= n){
      a[i*x]++;
      x++;
    }
  }
  ll ans = 0;
  rep2(i, 1, n+1){
    ans += i * a[i];
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<vector<long long>>> cur(5, vector<vector<long long>> (5, vector<long long> (5)));
        const int mod = 1e9 + 7;
        cur[4][4][4] = 1;
        rep(i, n) {
                vector<vector<vector<long long>>> next(5, vector<vector<long long>> (5, vector<long long> (5)));
                rep(z, 5) rep(y, 5) rep(x, 5) rep(w, 4) {
                        if (w == 2 && x == 1 && y == 0) continue;
                        if (w == 2 && x == 0 && y == 1) continue;
                        if (w == 1 && x == 2 && y == 0) continue;
                        if (w == 2 && x == 1 && z == 0) continue;
                        if (w == 2 && y == 1 && z == 0) continue;
                        (next[w][x][y] += cur[x][y][z]) %= mod;
                }
                cur.swap(next);
        }
        long long ans = 0;
        rep(x, 5) rep(y, 5) rep(z, 5) (ans += cur[x][y][z]) %= mod;
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;


int roma( char c )
{
  if ( c == 'I' )
    return 1;
  else if ( c == 'V' )
    return 5;
  else if ( c == 'X' )
    return 10;
  else if ( c == 'L' )
    return 50;
  else if ( c == 'C' )
    return 100;
  else if ( c == 'D' )
    return 500;
  else
    return 1000;
}

int main()
{
  string s;

  
  while ( cin >> s )
    {
      int n = 0;
      
      for ( auto i = 0; i < s.size(); ++i )
        {
          if ( i )
            {
              if ( roma( s[i] ) > roma( s[i-1] ) )
                n += roma( s[i] ) - 2 * roma( s[i-1] );
              else
                n += roma( s[i] );
            }
          else
            {
              n += roma( s[i] );
            }
        }
      cout << n << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1184
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func min(x, y float64) float64 {
	if x < y {
		return x
	}
	return y
}

func max(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

type Point struct {
	x float64
	y float64
}

func sub(l, r *Point) *Point {
	s := Point{
		x: l.x - r.x,
		y: l.y - r.y,
	}
	return &s
}

func crossProd(l, r *Point) float64 {
	return l.x*r.y - r.x*l.y
}

func direction(pi, pj, pk *Point) float64 {
	return crossProd(sub(pk, pi), sub(pj, pi))
}

func readPoint() *Point {
	x, _ := nextFloat64()
	y, _ := nextFloat64()
	point := Point{
		x: x,
		y: y,
	}
	return &point
}

func coef(p1, p2 *Point) (float64, float64, float64) {
	return p1.y - p2.y, -(p1.x - p2.x), p1.y*p2.x - p1.x*p2.y
}

func main() {
	scanner.Split(bufio.ScanWords)

	nQueries := nextInt()

	for iQuery := 0; iQuery < nQueries; iQuery++ {
		p0 := readPoint()
		p1 := readPoint()
		p2 := readPoint()
		p3 := readPoint()

		a, b, e := coef(p0, p1)
		c, d, f := coef(p2, p3)
		det := a*d - b*c
		x := (d*e - b*f) / det
		y := (a*f - c*e) / det
		fmt.Println(x, y)
	}
}



Measured memory_bytes: 1272
n = int(input())
p = list(map(int, input().split()))
tmp = p[:]
new_p = sorted(p)
ans = 'NO'
for i in range(n):
    for j in range(n):
        tmp = p[:]
        tmp[i], tmp[j] = tmp[j], tmp[i]
        if tmp == new_p:
            ans = 'YES'
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n;
   string s;
   cin>>n>>s;
   vector<char> t(s.size());
   rep(i,s.size()){
     t.at(i)=s.at(i);
     t.at(i)=((t.at(i)+n-'A')%26)+'A';
   }
   rep(i,s.size())
    cout<<t.at(i);
   
   cout<<endl;
   
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    if M == 0:
        if N == 1:
            print(0)
            exit()
        elif N == 2:
            print(10)
            exit()
        elif N == 3:
            print(100)
            exit()

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 10044