akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int odd = 0;
    int eve = 0;
    rep(i,n){
        if(v[i]%2)odd++;
        else eve++;
    }
    int ans = pow(3,odd+eve);
    ans-=pow(2,eve)*pow(1,odd);
    cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    LLI N;
    cin >> N;
    vector<LLI> v(N);
    vector<LLI> l(N + 1);
    vector<LLI> r(N + 1, 0);
    REP(i, N) { cin >> v[i]; }
    LLI d = 0, d2 = 0;
    REP(i, N) { d += v[i] * (i % 2 == 0 ? 1 : -1); }
    REP(i, N) {
        cout << (d - d2 * 2) * (i % 2 == 0 ? 1 : -1) << " ";
        d2 = d2 + v[i] * (i % 2 == 0 ? 1 : -1);
    }

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main(){
    
    int b1,b2,b3;
    cin>>b1>>b2>>b3;
    if(b1==1&&b2==0&&b3==0){
        cout<<"Close"<<endl;
    }
    if(b1==0&&b2==1&&b3==0){
        cout<<"Close"<<endl;
    }
    if(b1==1&&b2==1&&b3==0){
        cout<<"Open"<<endl;
    }
    if(b1==0&&b2==0&&b3==1){
        cout<<"Open"<<endl;
    }
    if(b1==0&&b2==0&&b3==0){
        cout<<"Close"<<endl;
    }
}



Measured memory_bytes: 3100
#include<cstdio>
#define chkmax(a,b) ((a)>(b)?(a):(b))
long long ans;
long long n,k;
int main()
{
	scanf("%lld%lld",&n,&k);
	if(k==0)return printf("%lld",n*n),0;
	for(register long long i=k+1;i<=n;++i)
	{
		if(n%i>=k)ans+=(n%i)-k+1;
		ans+=(i-k)*(n/i);
		//printf("%lld %lld %lld\n",(i-k),n%i,(n/i));
		//printf("%lld %lld %lld\n",i-k,((n-(i-1))/i)+1,(n-(n/i)*i-k));
		//ans+=chkmax((n-(n/i)*i-k),0);
		//ans+=(i-k)*(((n-(i-1))/i)+1);
		//if(n%i==0)
		//if(k==0)ans+=(i-k)*
		//ans+=n-(n+k)/i*i;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
nn = '0' + input()
ans = 0
dp = [[0 for i in range(2)] for j in range(len(nn))]
dp[0][1] = 1

for i,c in enumerate(nn[1:]):
    cc = int(c)
    zero = dp[i][0] + cc
    one = dp[i][1] + 10 - cc
    dp[i+1][0] = min(zero, one)
    dp[i+1][1] = min(zero + 1, one - (1 if i < len(nn) - 2 else 0))
print(min(dp[len(nn)-1]))
# print(dp)
 

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

int main(){
  int s, h, m;
  cin >> s;
  
  if(s < 60){
    cout << "0:0:" << s << endl;
  }else if(s < 3600){
    m = s / 60;
    s %= 60;
    cout << "0:" << m << ":" << s << endl;
  }else {
    h = s / 3600;
    s %= 3600;
    m = s / 60;
    s %= 60;
    cout << h << ":" << m << ":" << s << endl;
  }

  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#define debug(x) cerr << #x << ": " << x << endl;
using namespace std;
int N, M;

int main(){
	cin >> N >> M;

	int b;
	b = N/2 + 1;
	for(int i=0;i<N;i++){
		if(i) cout << " ";
		if(i < b){
			cout << 0;
		}
		else{
			cout << M;
		}
	}
	cout << endl;
}



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

using namespace std;

constexpr int N = 5;
int cooktime[N];

int round10(int x) {
  const int r = x % 10;
  return r ? x - r + 10 : x;
}

int dfs(vector<int> used, int rem) {
  if (rem == 0) {
    return 0;
  }

  int ans = 100000;
  for (int j = 0; j < N; j++) {
    if (used[j]) {
      continue;
    }
    auto newused = used;
    newused[j] = 1;

    int cost = round10(cooktime[j]);
    if (rem == 1) {
      cost = cooktime[j];
    }
    ans = min(ans, dfs(newused, rem - 1) + cost);
  }
  return ans;
}

int main() {
  for (int i = 0; i < N; i++) {
    cin >> cooktime[i];
  }
  int ans = dfs({0, 0, 0, 0, 0}, N);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i] == k){
            puts("POSSIBLE");
            return 0;
        }
    }
    int ma = *max_element(a.begin(), a.end());
    if(ma < k){
        puts("IMPOSSIBLE");
        return 0;
    }
    int temp = a[0];
    rep(i,n){
        temp = __gcd(temp,a[i]);
    }
    rep(i,n){
        if(abs(k-a[i])%temp==0){
            puts("POSSIBLE");
            return 0;
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
ll dp[100000][2];
ll b[100000];
ll e[100000];

int main(){
    ll n;
    cin >> n;
    VLL a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    ll gcdNum = a[0];

    rep(i,n){
         gcdNum = gcd(a[i],gcdNum);
         b[i] = gcdNum;
    }
    gcdNum = a[n-1];
    for(int i = n-1; i >= 0; i--){
        gcdNum = gcd(a[i],gcdNum);
        e[i] = gcdNum;
    }
    ll maxGcd = gcdNum;
    rep(i,n){
        if(i == 0) maxGcd = max(maxGcd,e[i+1]);
        else if(i == n-1) maxGcd = max(maxGcd,b[n-2]);
        else  maxGcd = max(maxGcd,gcd(b[i-1],e[i+1]));
    }
    cout << maxGcd << endl;


    return 0;
}


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

using namespace std;

typedef long long ll;

void solve(ll test_num) {
  (void) test_num;
  const ll MAX = 111000;
  static vector<ll> by_mod[MAX];
  ll N, M;
  cin >> N >> M;
  for (ll i = 0, x; i < N; ++i) {
    cin >> x;
    by_mod[x % M].push_back(x);
  }
  ll res = 0;
  for (ll r = 0; r < M; ++r) {
    if (2 * r == M || r == 0) {
      res += by_mod[r].size() / 2;
    } else {
      const ll am = min(by_mod[r].size(), by_mod[M - r].size());
      if (r < M - r)
        res += am;
      sort(by_mod[r].begin(), by_mod[r].end());
      for (ll i = 1, cnt = 0; i < (ll) by_mod[r].size() && cnt + am + 2 <= by_mod[r].size(); ) {
        if (by_mod[r][i] == by_mod[r][i - 1]) {
          ++res;
          cnt += 2;
          i += 2;
        } else {
          ++i;
        }
      }
    }
  }
  cout << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
  return 0;
}

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

int collatz(int n, int i){
  if(n == 4 || n == 2 || n == 1)
    return i + 3;                     //124の出現が基準124から3回の操作を経た値も124
  else if(n % 2 == 0)
    return collatz(n/2, i+1);
  else if(n % 2 == 1)
    return collatz(3*n+1, i+1);
}

int main(){
  int s;
  cin >> s;

  cout << collatz(s, 1) << endl;
  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;


int main()
{
    fast;
   
  ll t1,t2,a1,a2,b1,b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;

  if(a1*t1+a2*t2-b1*t1-b2*t2==0)
  	cout<<"infinity"<<endl;

  else if((a1>b1 and a2>b2) or (a1<b1 and a2<b2) )
  	cout<<0<<endl;
  
  else
  {
  	if(a1<b1)
  		{swap(a1,b1);
  			swap(a2,b2);}

  ll diff=a1*t1+a2*t2-b1*t1-b2*t2;
  		if(diff>0)
  		cout<<0<<endl;
  		else
  		{
  			ll gap1=a1*t1-b1*t1,gap2=b2*t2-a2*t2;
  			ll ans=gap1/(gap2-gap1);
  			ans*=2;
  			diff*=-1;
  			if(gap1%diff!=0)
  				ans++;
  			cout<<ans<<endl;
  		}
  }
   }

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

double A, B;
int H, M;

int main() {
    cin >> A >> B >> H >> M;
    double radA = (60*H + M) * (2*M_PI / 720);
    double radB = M * (2*M_PI / 60);
    double C = sqrt(A * A + B * B - 2 * A * B * cos(radA - radB));
    cout << fixed << setprecision(10) << C << endl;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 998244353;
const int MAXN = 10000010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll F[MAXN], I[MAXN], tav[MAXN];

ll powmod(ll a, ll b){
	if (!b) return 1;
	if (b&1) return a*powmod(a*a%mod, b>>1)%mod;
	return powmod(a*a%mod, b>>1);
}

ll C(ll n, ll r){
	if (r<0 || r>n) return 0;
	return F[n]*I[r]%mod*I[n-r]%mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	F[0]=tav[0]=1;
	for (int i=1; i<MAXN; i++) F[i]=F[i-1]*i%mod, tav[i]=tav[i-1]*2%mod;
	I[MAXN-1]=powmod(F[MAXN-1], mod-2);
	for (int i=MAXN-1; i; i--) I[i-1]=I[i]*i%mod;
	
	cin>>n;
	ans=powmod(3, n);
	for (int i=n/2+1; i<=n; i++) ans=(ans-tav[n+1-i]*C(n, i))%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 234624
import math

a,b,x= map(int,input().split())

deg = 0
enp = a*a*b - x

if(x == a*a*b/2): #半分
    ans = 45
elif(x > a*a*b/2): #多い
    ans = math.degrees(math.atan2(2*enp,a*a*a))
else: #少ない
    ans = math.degrees(math.atan2(a*b*b,2*x))
    
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

in sum_vec(vector<int> &p,int sup){
  in sum=0;
  rep(i,sup)
    sum+=p.at(i);
  return sum;
}

int main(){
  int n;
  in W;
  cin>>n>>W;
  vector<in> w(n),v(n);
  vector<vector<int>> p(4);
  rep(i,n){
    cin>>w.at(i)>>v.at(i);
    if(i==0) {p.at(0).push_back(v.at(0));continue;}
    rep(j,4){
      if(w.at(i)==w.at(0)+j)
        p.at(j).push_back(v.at(i));
      
    }
  }
  vector<int> size(4);
  rep(j,4){
    size.at(j)=p.at(j).size();
    sort(all(p.at(j)));
    reverse(all(p.at(j)));
  }
  //ここから
  in max_v=0;
  rep(i,size.at(0)+1){
    rep(j,size.at(1)+1){
      rep(k,size.at(2)+1){
        rep(l,size.at(3)+1){
          in sum_w=i*w.at(0)+j*(w.at(0)+1)+k*(w.at(0)+2)+l*(w.at(0)+3);
          if(sum_w>W) continue;
          in sum_v = sum_vec(p.at(0),i)+sum_vec(p.at(1),j)+sum_vec(p.at(2),k)+sum_vec(p.at(3),l);
          max_v = max(max_v,sum_v);
        }
      }
    }
  }
  cout<<max_v<<endl;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using ll = long long;
using namespace std;

signed main(){

    int AB,BC;
    cin >> AB >> BC;
    cout << (AB*BC)/2 << endl;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) { Console.WriteLine("YES"); }
        else { Console.WriteLine("NO"); }
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        for (long i = 2; i < n; i++) { if (n % i == 0) return false; }
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
from collections import Counter
n = int(input())
counter1 = Counter(input())
counter2 = Counter(input())
values1 = [0] * (26 - len(counter1)) + sorted(counter1.values())
values2 = [0] * (26 - len(counter2)) + sorted(counter2.values())
print(sum([abs(i - j) for i, j in zip(values1, values2)]) // 2)


Measured memory_bytes: 6208
#include<bits/stdc++.h>
using namespace std;
int N,C,d[32][32],c[502][502],cnt[3][30]={0},ans=2147483647;
int main(){
	cin>>N>>C;
	for(int i=1;i<=C;i++) for(int j=1;j<=C;j++) cin>>d[i][j];
	for(int i=1;i<=N;i++) for(int j=1;j<=N;j++){
		cin>>c[i][j];
		cnt[(i+j)%3][c[i][j]]++;
	}
	for(int i=1;i<=C;i++){
		for(int j=1;j<=C;j++){
			for(int k=1;k<=C;k++){
				if(i==j||j==k||i==k) continue;
				int colour[3]={i,j,k},tmp=0;
				for(int m=0;m<3;m++){
					for(int co=1;co<=30;co++){
						tmp=tmp+d[co][colour[m]]*cnt[m][co];
					}
				}
				ans=min(ans,tmp);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    for(int i=1; i<10; i++){
      for(int j=1; j<10; j++){
        if(n == i*j){
          System.out.println("Yes");
          return;
        }
      }
    }
    
    System.out.println("No");
  }
}


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

using i64 = long long;
using P   = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

void solve(long long N, std::vector<long long> A) {
    i64 g       = A[0];
    rep(i, N) g = gcd(g, A[i]);
    if(g != 1) {
        cout << "not coprime" << endl;
        return;
    }
    bool flag = false;
    sort(all(A));
    rep(i, N - 1) if(A[i] == A[i + 1] && A[i] != 1) flag = true;
    vector<bool> table(1000010, true), exist(1000010);
    rep(i, N) exist[A[i]] = true;
    table[0] = table[1] = false;
    rep(i, 1000000) {
        if(!table[i]) continue;
        i64 cnt = 0;
        if(exist[i]) ++cnt;
        for(int j = 2; i * j <= 1000000; ++j) {
            table[i * j] = false;
            if(exist[i * j]) ++cnt;
        }
        if(cnt >= 2) flag = true;
    }
    if(flag)
        cout << "setwise coprime" << endl;
    else
        cout << "pairwise coprime" << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11424
def submit():
    n = int(input())
    a = [int(e) for e in input().split()]
    thr = 10 ** 18

    if 0 in a:
        print(0)
        return

    ans = 1
    for e in a:
        ans *= e
        if ans > thr:
            ans = -1
            break
    
    print(ans)


submit()
        

Measured memory_bytes: 21480
#include <stdio.h>

int main(){
	int in;
	int i, n;
	int min, max;
	long sum;
	
	sum = 0;

	scanf("%d", &n);

	for(i=0; i<n; i++) {
		scanf("%d", &in);
		if(i == 0) {
			min = in;
			max = in;
		}
		if(in > max) max = in;
		if(in < min) min = in;
		sum += in;
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 600
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 100010;

int a[MAXN];
int op[MAXN];
ll suf[MAXN];
ll pre[MAXN];

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri - 1;
	pre[0] = a[0] = ri;
	for(int i = 1; i <= n; i++) {
		char opt = ge;
		while(opt != '-' && opt != '+') opt = ge;
		op[i] = opt == '-' ? -1 : 1;
		a[i] = ri, pre[i] = pre[i - 1] + (opt == '-' ? -a[i] : a[i]);
	}

	for(int i = n; i >= 1; i--) suf[i] = suf[i + 1] + a[i];

	ll res = pre[n];
	int las = n + 1;
	for(int i = n; i >= 1; i--)
		if(op[i] == -1) {
			chkmax(res, pre[i - 1] + suf[las] * 2 - suf[i]);
			las = i;
		}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2816
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()


def minimum_spanning_tree(n, info):
    """
    頂点の数:nと辺の情報i:infoから最小全域木([[辺の始点の頂点,辺の終点の頂点, 重み], ...])を返す。
    info:[[辺の始点の頂点,辺の終点の頂点, 重み], ...](bellman_ford()の入力形式)
    """
    ans = []
    info.sort(key=itemgetter(2))

    class UnionFind:
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    uf = UnionFind(n)
    for i in info:
        if not uf.same(i[0], i[1]):
            ans.append(i)
            uf.union(i[0], i[1])
    return ans


def digit_print(num, digit):  # digitは小数何桁まで表示するか。 >= 0
    if digit == 0:
        if type(num) is int:
            return num
        else:
            num = str(num)
            return num[:num.index(".")]
    else:
        if type(num) is int:
            return str(num) + "." + "0" * digit
        else:
            num = str(num) + "0" * digit
            return num[:num.index(".") + digit + 1]


while True:
    n = int(input())
    if n == 0:
        break
    x_y_z_r_num = [list(map(float, input().split())) + [i] for i in range(n)]
    info = []
    for i in itertools.combinations(x_y_z_r_num, 2):
        dis = math.sqrt(sum((px - qx) ** 2.0 for px, qx in zip(i[0][:3], i[1][:3])))
        if i[0][3] + i[1][3] >= dis:
            info.append([i[0][4], i[1][4], 0.00])
        else:
            info.append([i[0][4], i[1][4], dis - i[0][3] - i[1][3]])
    print(digit_print(round(sum(i[2] for i in minimum_spanning_tree(n, info)), 3), 3))



Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {      
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i,h) {
        cin >> s[i];
    }
    vi dx = {-1, -1, -1, 0, 0, 1, 1, 1};
    vi dy = {-1, 0, 1, -1, 1, -1, 0, 1};
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '#' ) continue;

            int count = 0;
            for(int d = 0; d < 8; d++) {
                int ni = dx[d] + i;
                int nj = dy[d] + j;
                if( ni < 0 || h <= ni) continue;
                if( nj < 0 || w <= nj) continue;
                if(s[ni][nj] == '#') count++;
            }
            s[i][j] = char(count + '0');
        }
    }
    rep(i, h) {
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt(),q=sc.nextInt(),r=sc.nextInt();
		int ans;
		ans = Math.min(p+q, q+r);
		ans = Math.min(ans, r+p);
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
int main(void){
     
    int a[3];
 
    for (int i = 0; i < 3; i++)
        cin >> a[i];
 
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (a[j] > a[j + 1])
                swap(a[j], a[j + 1]);
        }
    }
 
    for (int i = 0; i < 3; i++) {
        if (i != 0)
            cout << ' ' << a[i];
        else
            cout << a[i];
    }
 
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    int x,a;
    int ans = 0;

    cin >> x >> a;

   
    x<a ? cout << 0 << endl : cout << 10 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  int N;
  cin >> N;

  int maxi = 0,point;
  for(int i = 0;i < N;i++) {
    int a,b;
    cin >> a >> b;
    if(maxi < a) {
      maxi = a;
      point = b;
    }
  }

  cout << maxi + point << endl;
}



Measured memory_bytes: 256
fun main() {
    val (k, a, b) = next3Int()
    for (i in a..b) {
        if (i % k == 0) {
            return println("OK")
        }
    }
    println("NG")
}

val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun next2Int() = Pair(scanner.nextInt(), scanner.nextInt())
fun next3Int() = Triple(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
fun nextLong() = scanner.nextLong()
fun nextLine(): String = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

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

int main() {
  int N;
  cin >> N;
  bool yellow_found = false;
  rep(i, N) {
    string S;
    cin >> S;
    if (S == "Y") {
      yellow_found = true;
      break;
    }
  }
  if (yellow_found) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b,c;
bool panduan(){
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
		return true;
	return false;
}
int main()
{
	cin >> a >> b >> c;
	if(panduan())cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

void solve(){
  int n;
  cin >> n;
  double ans=0.;
  double rate = 380000.00;
  rep(i,n){
    double a;
    string b;
    cin >> a >> b;
    if(b=="JPY") ans += a;
    else ans += a*rate;
  }
  cout << ans << endl;

}

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


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[N-1])

Measured memory_bytes: 20628
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		int[] a = {1, 0, 0};
		for (;sc.hasNext();) {
			String s = sc.next();
			char c1 = s.charAt(0);
			char c2 = s.charAt(2);
			swap(a, c1 - 'A', c2 - 'A');
		}
		for (int i = 0; i < a.length; i++) {
			if (a[i] == 1) {
				System.out.println((char)('A' + i));
			}
		}
	}
	void swap(int[] a, int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
long long a,b,c;
	cin>>a>>b;
	if(a==1 || b==1)
	cout<<1;
	else if(a%2!=0 && b%2!=0)
	{
		cout<<(a*b)/2+1;
		
	}
	else
	cout<<(a*b)/2;
	
}

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

int shimo(int n){
	return n%10;
}

int main(){
	int v[5];
	int shimo = 10;
	int id = 0;
	rep(i,5){
		cin >> v[i];
		if(v[i]%10 != 0){
			if(shimo > v[i]%10){
				shimo = v[i]%10;
				id = i;
			}
		}
	}
	
	int ans = 0;
	rep(i,5){
		if(i!=id){
			ans += v[i];
			if(ans % 10 != 0){
				ans += 10-ans%10;
			}
		}
	}
	
	ans += v[id];
	
	cout << ans << endl;
	
}



Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int ans = min(A,B)+min(C,D);
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define NUM             100005

const int INF = 1e9+5;

typedef long long ll;


int main()
{
    ll n,k;

    cin>>n>>k;

    vector<int>a(n);

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

    vector<int>dp(n,INF);

    dp[0] = 0;

    for(ll i=0; i<n; ++i)
    {
        for(ll j=i+1; j<=i+k; ++j)
        {
            if(j<n)
            {
                dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
            }
        }
    }

    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) {
		cout << "delicious" << endl;
	}
	else {
		if (x >= b - a) {
			cout << "safe" << endl;
		}
		else {
			cout << "dangerous" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#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 a,b;
  cin >> a >> b ;
  int c = a + b;
  if( c == 3) cout << 3 << endl;
  else if( c == 4) cout << 2 << endl;
  else if( c == 5) cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

string s;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> s;
	for(int a = 0;a < 2;a++)
	{
		for(int b = 0;b < 2;b++)
		{
			for(int c = 0;c < 2;c++)
			{
				int x = s[0] - '0';
				int y = s[1] - '0';
				int z = s[2] - '0';
				int w = s[3] - '0';
				if(x + y * (a == 0 ? 1 : -1) + z * (b == 0 ? 1 : -1) + w * (c == 0 ? 1 : -1) == 7) rc(s[0] << (a == 0 ? '+' : '-') << s[1] << (b == 0 ? '+' : '-') << s[2] << (c == 0 ? '+' : '-') << s[3] << "=7");
			}
		}
	}
}



Measured memory_bytes: 256
n=int(input())
happines=[list(map(int,input().split())) for _ in range(n)]

solution=[[0,0,0] for _ in range(n)]

solution[0][0]=happines[0][0]
solution[0][1]=happines[0][1]
solution[0][2]=happines[0][2]

for i in range(1,n):
    for j in range(3):
        solution[i][j]=happines[i][j]+max(solution[i-1][(j+1)%3],solution[i-1][(j+2)%3])

print(max(solution[-1]))

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

 using namespace std;

  int main(){
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
   if(a==b&&a==c)printf("1");
   else if(a==b||b==c||a==c)printf("2");
   else printf("3");
  }


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

hourDegree = H * 30 + 0.5 * M
hourDegree = hourDegree % 360
minDegree = (H * 60 + M) * 6
minDegree = minDegree % 360

if abs(minDegree - hourDegree) > 180:
    degree = 360 - abs(minDegree - hourDegree)
else:
    degree = abs(minDegree - hourDegree)

c = math.sqrt((A ** 2) + (B ** 2) - 2 * A * B * (math.cos(math.radians(degree))))
print(c)


Measured memory_bytes: 9516
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] o = sc.next().toCharArray();
		char[] e = sc.next().toCharArray();
		int i;
		char[] pass = new char[o.length + e.length];
		for(i = 0; i < pass.length / 2; i++) {
			pass[i * 2] = o[i];
			pass[i * 2 + 1] = e[i];
		}
		if(o.length - e.length == 1) pass[i * 2] = o[i];
		System.out.println(pass);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

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

		Scanner cin = new Scanner(System.in);

		int A = cin.nextInt();
		int B = cin.nextInt();
		int C = cin.nextInt();
		cin.close();

		String result = "No";

		if(A<=C&&C<=B){
			result = "Yes";
		}


		System.out.println(result);
	}
}


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

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;

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

    ll a, b;
    cin >> a >> b;

    ll ans = abs(abs(a)-abs(b));
    if((a >= 0 && b > 0) || (a < 0 && b <= 0)) {
        if(a <= b) {
            cout << ans << endl;
        }else{
            cout << ans + 2 << endl;
        }
    }else{
        cout << ans + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#create date: 2020-08-10 07:34

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a = na()
    a.sort()
    zero = False
    for ai in a:
        if ai % 2== 0:
            zero =True
    print(0 if zero else a[0]*a[1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
fun main(args: Array<String>) {
    val s = readInputLine().replace("BC", "D").toCharArray()
    
    var Acnt = 0L
    var ans = 0L

    for (i in 0 until s.size) {
        when (s[i]) {
            'A' -> Acnt++
            'D' -> ans += Acnt
            else -> Acnt = 0L
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 43748
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

using namespace std;

const ll INF = 1e9 + 10;
const ll INF2 = 3e18 + 10;
const int MOD = 1e9 + 7;
const ld EPS = 1e-4;

const int LOGN = 19;
const int MAXN = 305;


inline void add_self(int &a, int b) {
	a = (a + b) % MOD;
}

int dp[3000][3000];

int main() {
	FAST;

	int n;
	cin >> n;
	string s;
	cin >> s;
	dp[0][0] = 1;

	vector<ll> a(n + 1);
	for (int i = 1; i < n; i++) {
		a[0] = 0;
		for (int j = 0; j <= i; j++) {
			a[j + 1] = a[j] + dp[i - 1][j];
		}
		if (s[i - 1] == '<')
			for (int j = 1; j <= i; j++) {
				add_self(dp[i][j], a[j] % MOD);
			}
		else {
			for (int j = 0; j < i; j++) {
				add_self(dp[i][j], (a[i + 1] - a[j]) % MOD);
			}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) add_self(ans, dp[n - 1][i]);
	cout << ans;
}

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

int main() {
    ios::sync_with_stdio(false);
    long long int n, d, ans = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        long long int x, y;
        cin >> x >> y;
        if ((x*x + y*y) <= d*d)
            ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
N=int(input())
ba=bx=xa=0
ans=0
for i in range(N):
    s=input()
    ans+=s.count('AB')
    if s.startswith('B') and s.endswith('A'):
        ba+=1
    elif s.startswith('B'):
        bx+=1
    elif s.endswith('A'):
        xa+=1

if ba==0:
    ans+=min(bx,xa)
elif ba>0:
    if bx+xa>0:
        ans+=ba+min(bx,xa)
    elif bx+xa==0:
        ans+=ba-1

print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c > a - b) cout << c - a + b << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
n, x= map(int, input().split())
ls = list(map(int, input().split()))

zahyo = 0
cnt = 0
for i in range(n):
    cnt += 1
    zahyo += ls[i]

    if zahyo > x:
        break

if zahyo <= x:
    cnt += 1

print(cnt)


Measured memory_bytes: 3060
import sys
 
 
def solve():
    n = int(input())
    h = list(map(int, input().split()))
    up_h = [0]
    for i in range(len(h)-1):
        if h[i] < h[i+1]:
            up_h.append(i)
    up_h.append(len(h)-1)
    if len(up_h) == len(h) + 1:
        print(0)
        sys.exit(0)
    elif len(up_h) == 2:
        print(n-1)
        sys.exit(0)
    h_max = 0
    for i in range(len(up_h)-1):
        if h_max < up_h[i+1]-up_h[i]:
            h_max = up_h[i+1]-up_h[i]-1

    print(h_max)
 
 
solve()

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    ll n, a, b, c; cin >> n >> a >> b >> c;
    ll ans = 1e9;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    REP(i, 0, (1<<2*n)){
        ll mid = 0;
        ll aa = 0, bb = 0, cc = 0;
        ll at = 0, bt = 0, ct = 0;
        ll ch = i;
        int count = 0;
        while(ch != 0){
            int h = ch % 4;
            if(h == 0){
                //pass
            }else if(h == 1){
                aa += lis[count];
                at++;
            }else if(h == 2){
                bb += lis[count];
                bt++;
            }else if(h == 3){
                cc += lis[count];
                ct++;
            }
            ch = ch >> 2;
            count++;
        }
        if(aa == 0 || bb == 0 || cc == 0){
            continue;
        }
        //cout << aa << " " << bb << " " << cc << endl;
        mid = (at+bt+ct-3) * 10 + abs(a-aa) + abs(b-bb) + abs(c-cc);
        ans = min(mid, ans);
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define dbg(x)                cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	ll n; scn(n);
	ll k; scn(k);
	vec stone;
	ara_read(stone, n);
	vec dp(n,INF);
	dp[0]=0;
	for(int i=0; i< n ; i++){
		for(int j =i+1; j<= i+k ; j++){
			if(j< n){
				dp[j]=min(dp[j] ,dp[i]+abs(stone[j]-stone[i]));
				
			}
		}
	}
	printf("%lld\n",dp[n-1]);
   return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 1000;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int maxs(int &a, int b) { return a = max(a, b);}
int mins(int &a, int b) { return a = min(a, b);}
int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int H, W, res[maxn][maxn];
string S[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> H >> W;
    for (int i = 0; i < H; ++i)
        cin >> S[i];

    res[0][0] = 1;
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            if (S[i][j] == '#') continue;
            if (i > 0 && S[i - 1][j] == '.')
                res[i][j] = add(res[i][j], res[i - 1][j]);

            if (j > 0 && S[i][j - 1] == '.')
                res[i][j] = add(res[i][j], res[i][j - 1]);
        }
    }
    
    cout << res[H - 1][W - 1];
}


Measured memory_bytes: 5248
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

double dp[3000][3000];

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

    vector<double> p(n);

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

    dp[0][0] = 1.0;

    for(int i = 0;i < n;i++) {
        for(int j = 0;j <= i;j++) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double sum = 0.0;
    for(int i = (n+1)/2;i <= n;i++) {
        sum += dp[n][i];
    }

    cout<<fixed<<setprecision(10)<<sum<<endl;

    return 0;
}

            


Measured memory_bytes: 68864