akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize, m: u64, q: usize,
        qs: [(Usize1, Usize1, u64, u64); q]
    }
    let mut sq = Vec::new();
    enum Call {
        In(u64),
        Out,
    }
    use Call::*;
    let mut st = vec![In(1), Out];
    let mut an = 0;
    while let Some(ins) = st.pop() {
        match ins {
            In(x) => {
                st.push(Out);
                sq.push(x);
                if sq.len() < n {
                    for x in x..=m {
                        st.push(In(x));
                    }
                } else {
                    let ev = |&(a, b, c, d)| if sq[b] - sq[a] == c { d } else { 0 };
                    an = an.max(qs.iter().map(ev).sum());
                }
            }
            Out => {
                sq.pop();
            }
        }
    }
    println!("{}", an)
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define lld  long double 
int main(){
	int n;
	cin >> n;
	cout << fixed << setprecision(12);
	vector<vector<lld>>dp(n+1,vector<lld>(n+1,0.00000000));
	lld arr[n];
	for(int i=0;i<n;i++)cin >> arr[i];
	dp[1][0]=1-arr[0];
	for(int i=1;i<=n;i++){
	
    if(i>1)dp[i][0]=(1-arr[i-1])*dp[i-1][0];
	}
	
	dp[1][1]=arr[0];
	for(int i=2;i<=n;i++){
    for(int j=1;j<=n;j++){
    dp[i][j]=(1-arr[i-1])*dp[i-1][j]+arr[i-1]*dp[i-1][j-1];
    }
	}
	lld ans=0;
	for(int i=n/2 +1;i<=n;i++){
    ans+=dp[n][i];
	}
	cout << ans;

}

Measured memory_bytes: 141056
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];

		for(int i=0; i<n; i++){
			arr[i] = sc.nextInt();
		}
		
		int min = 0;
		int max = 0;

		int[] color = new int[9];

		for(int i=0; i<n; i++){
			if((arr[i]/400) >= 8){
				color[8]++;
			}else{
				color[arr[i]/400] = 1;
			}
		}

		for(int i=0; i<8; i++){
			if(color[i] == 1){
				min++;
				max++;
			}
		}
		
		if(min == 0 && color[8] > 0)
			min++;
		if(color[8] > 0){
			max = max + color[8];
			/*if((max + color[8]) < 8)
				max = max + color[8];
			else
				max = 8;*/
		}

		System.out.println(min + " " + max);
	}
}


Measured memory_bytes: 21716
n = gets.to_i
deck = []
(2*n).times do |i|
	deck << i+1
end

m = gets.to_i

tmp = []
m.times do
	k = gets.to_i
	if(k == 0) then
 		n.times do |i|
 			tmp << deck[i]
 			tmp << deck[n+i]
 		end
 	else
		for i in k..deck.length-1
			tmp << deck[i]
		end
		
		for i in 0..k-1
			tmp << deck[i]
		end
	end
	
 	deck = Marshal.load(Marshal.dump(tmp))
	tmp.clear
	
end

puts deck

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define MAXN 128*4
using namespace std;
int n,m;
vector<int>g[MAXN];
int a[MAXN][MAXN],b[MAXN][MAXN],us[MAXN][MAXN],used[MAXN],mt[MAXN];
void read()
{
    int i,j;
    cin>>n>>m;
    for(i=0; i<n; i++)
        for(j=0; j<m; j++)
            cin>>a[i][j];
}

bool try_kuhn (int v)
{
    if(used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i)
    {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to]))
        {
            mt[to] = v;
            mt[v]=to;
            return true;
        }
    }
    return false;
}

void solve()
{
    int i,j,l;
    for(l=0; l<m; l++)
    {
        //cout<<"---------\n";
        for(i=0; i<n; i++)g[i].clear();
        for(i=0; i<n; i++)
        {
            for(j=0; j<m; j++)
            {
                if(!us[i][j])
                {
                    g[i].push_back(a[i][j]/m-(a[i][j]%m==0)+n);
                    g[a[i][j]/m-(a[i][j]%m==0)+n].push_back(i);
                    //cout<<i<<" "<<a[i][j]/m-(a[i][j]%m==0)+n<<endl;
                }
            }
        }
        //cout<<"---------\n";
        memset(mt,-1,sizeof(mt));
        for (int v=0; v<n; ++v)
        {

            memset(used,0,sizeof(used));
            try_kuhn (v);
        }

        for (int i=0; i<n; ++i)
        {
            //cout<<mt[i]<<endl;
            if (mt[i] != -1)
            {
                //printf ("%d %d\n", mt[i], i);
                for(j=0; j<m; j++)
                {
                    if(a[i][j]/m-(a[i][j]%m==0)+n==mt[i]&&!us[i][j])
                    {
                        us[i][j]=true;
                        ///cout<<" - > "<<i<<" "<<j<<endl;
                        b[i][l]=a[i][j];
                        break;
                    }
                }
            }
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cout<<b[i][j]<<" ";
        }
        cout<<endl;
    }
    vector<int>h;
    for(j=0; j<m; j++)
    {
        h.clear();
        for(i=0; i<n; i++)
        {
            h.push_back(b[i][j]);
        }
        sort(h.begin(),h.end());
        for(i=0; i<n; i++)
        {
            b[i][j]=h[i];
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cout<<b[i][j]<<" ";
        }
        cout<<endl;
    }
}

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


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

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    rep(i,N){
        if(!(i+4 <= N-1)){
            cout << "NO" << endl;
            return 0;
        }
        if(S[i] == 'd'){
            if(S[i] == 'd' && S[i+1] == 'r' && S[i+2] == 'e'&& S[i+3] == 'a' && S[i+4] =='m'){
                if(i+5 <= N-1 && S[i+5] == 'e'){
                    if(i+6 <= N-1 && S[i+6] == 'r'){
                        if(i+7 <= N-1 && S[i+7] == 'a'){
                            i += 4;
                        }else{
                            i += 6;
                        }
                    }else{
                        cout << "NO" << endl;
                        return 0;
                    }
                }else{
                    i += 4;
                }
            }else{
                cout <<"NO" << endl;
                return 0;
            }
        }else if(S[i] == 'e'){
            if(S[i] == 'e' && S[i+1] == 'r' && S[i+2] == 'a'&& S[i+3] == 's' && S[i+4] =='e'){
                if(i+5 <= N-1 && S[i+5] == 'r'){
                    i += 5;
                }else{
                    i += 4;
                }
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 7/2/2020

 22:24-

 */

const int MAX_N=1e6+1;
LL H[MAX_N],A,B;
int N;

bool ok(int cnt) {
  vector<LL> X(H,H+N);
  REP(i,N) X[i]-=B*cnt;
  LL d=A-B;
  LL x=0;
  REP(i,N) if(X[i]>0) {
    x+=(X[i]+d-1)/d;
  }
  return x<=cnt;
}
void solve() {
  int good=1e9+10,bad=0;
  while(abs(good-bad)>1) {
    int m=(good+bad)/2;
    bool res=ok(m);
    (res?good:bad)=m;
  }
  cout<<good<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>A>>B;
  REP(i,N) cin>>H[i];
  solve();

  return 0;
}


Measured memory_bytes: 5200
from sys import stdin


def main():
    readline = stdin.readline
    N, Q = map(int, readline().split())
    S = readline().strip()
    L = []
    R = []
    for i in range(Q):
        *LR, = map(int, readline().split())
        L.append(LR[0] - 1)
        R.append(LR[1] - 1)
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in zip(L, R):
        print(AC[r] - AC[l])
    return


main()


Measured memory_bytes: 14232
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
  LL p=0; LL f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}
LL a,b,c,x,y;
int main()
{
  a = read(); b = read(); c = read(); x = read(); y = read(); LL ans = 0;
  if(2*c <= a+b)
  {
    LL minf = min(x,y);
    x-=minf; y-=minf; ans += minf * 2 * c;
  }
  if(x)
  {
    if(2*c<=a) ans+=x*2*c;
	else ans+=x*a; 
  }
  if(y)
  {
    if(2*c<=b) ans+=y*2*c;
    else ans+=y*b;
  }
  return printf("%lld\n",ans),0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String S = scan.next();
        long K = scan.nextLong();
        char sChar[] = S.toCharArray();

        char prevChar = sChar[0];
        long count = 0;
        long tempCount = 1;
        long tempFirstGpCount = 0;
        boolean lastChanged = false;
        boolean isAllSame = true;
        for(int i = 1; i < sChar.length; i++) {
            if (prevChar == sChar[i]) {
                tempCount++;
                if (i == sChar.length - 1) {
                    if((tempCount) % 2 == 0)
                        lastChanged = true;
                    count += Math.floor((tempCount)/2.0);
                }
            }
            else {
                if(isAllSame) {//最初の集団
                    tempFirstGpCount = tempCount;
                }
                isAllSame = false;
                prevChar = sChar[i];
                count += Math.floor((tempCount)/2.0);
                tempCount = 1;
            }
        }
        if(sChar.length != 1) {
            if (!lastChanged && sChar[0] == sChar[sChar.length - 1]) {//最初と最後が一緒
                if(isAllSame) {
                    if(K % 2 == 0) {
                        count = (count+1) * 2 -1;
                        os.println(count * (K/2));
                    } else {
                        long originCount = count;
                        count = (count+1) * 2 -1;
                        os.println(count * Double.valueOf(Math.floor(K/2.0)).intValue() + originCount);
                    }
                } else {
                    if(tempFirstGpCount % 2 == 1) {
                        count++;
                        os.println(count * K - 1);
                    } else {
                        os.println(count * K);
                    }
                }
            }
            else
                os.println(count * K);
        }
        else
            os.println(Double.valueOf(Math.floor(K/2.0)).intValue());
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <deque>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,M,K;
vector<ll> A;

const ll INF=-1e18;

int main(){
  cin>>N>>M>>K;
  A.resize(N);
  for(int i=0;i<N;i++) cin>>A[i];

  vector<ll> dp(N);
  for(int i=0;i<N;i++) dp[i]=A[i];

  for(int i=2;i<=K;i++){
      vector<ll> next(N,INF);
      deque<ll> DQ;
      for(int j=0;j<N;j++){
          while(!DQ.empty()){
              if(DQ.front()<j-M) DQ.pop_front();
              else break;
          }

          if(!DQ.empty()){
              next[j]=dp[DQ.front()]+A[j]*i;
          }

          while(!DQ.empty()){
              if(dp[DQ.back()]<=dp[j]) DQ.pop_back();
              else break;
          }

          DQ.push_back(j);
      }
      dp=next;
  }

  ll ans=0;
  for(int i=0;i<N;i++) ans=max(ans,dp[i]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2672
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>


using namespace std;

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

    vector<int>d(N);
    for(int i=0;i<N;i++)cin>>d[i];
    int ans =0;

    for(int i=0;i<N;i++){
        for(int k=i+1;k<N;k++){
            ans+=d[i]*d[k];
        }
    }

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


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

visit = []
step = [-1] * (n + 1)
v = 1
while step[v] == -1:
    step[v] = len(visit)
    visit.append(v)
    v = a[v - 1]
cycle = len(visit) - step[v]
nonCycle = step[v]

if k < nonCycle:
    print(visit[k])
else:
    k -= nonCycle
    k %= cycle
    print(visit[nonCycle + k])

Measured memory_bytes: 32316
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	if a%k == 0 || b%k == 0 {
		fmt.Println("OK")
		return
	}

	if b-a >= b%k {
		fmt.Println("OK")
		return
	}

	fmt.Println("NG")
}

Measured memory_bytes: 1816
#include <stdio.h>

int main(void){
    int i,j,k,n,a,b,dice[7],
    side[5] = {2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
    
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
    
    scanf("%d", &n);
    
    //上面を合わせる
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        
        for(j=1;dice[j]!=a;j++);
        
        //回転
        
        for(k=0;order[j][k]!='\0';k++){
            
            dice[0] = dice[1];
            
            switch(order[j][k]){
                    
                case 'E':
                    dice[1] = dice[4];
                    dice[4] = dice[6];
                    dice[6] = dice[3];
                    dice[3] = dice[0];
                    break;
                    
                case 'N':
                    dice[1] = dice[2];
                    dice[2] = dice[6];
                    dice[6] = dice[5];
                    dice[5] = dice[0];
                    break;
                    
                case 'S':
                    dice[1] = dice[5];
                    dice[5] = dice[6];
                    dice[6] = dice[2];
                    dice[2] = dice[0];
                    break;
                    
                case 'W':
                    dice[1] = dice[3];
                    dice[3] = dice[6];
                    dice[6] = dice[4];
                    dice[4] = dice[0];
                    break;
                    
            }
        }
        
        for(j=0;b!=dice[side[j]];j++);
        
        printf("%d\n",dice[side[j+1]]);
        
    }
    
    return 0;
}


Measured memory_bytes: 2100
#define i(a,b) a=a<b?a:b
d,a[101][101],b[101][101],u,v,c,k,l;main(n){for(scanf("%d%*d",&n);u++<n;)for(v=0;v++<n;)b[u][v]=1e8;for(;~scanf("%d%d%d",&u,&v,&c);a[u][v]=a[v][u]=b[u][v]=b[v][u]=c);for(;k++<n;)for(u=0;u++<n;)for(v=0;v++<n;)i(b[u][v],b[u][k]+b[k][v]);for(;l++<n;)for(c=l;c++<n;)a[l][c]>b[l][c]?d++:0;printf("%d\n",d);}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define Mx 3000001
#define inf 1e15
const int MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


typedef long long  L;
//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim,turn;

//double rat;
L A[Mx+5],B[Mx+5];

char str1[Mx],str[Mx],ch;
//struct node{L nid,nv;node(L nid_,L nv_){nid=nid_;nv=nv_;}};
//vector<node>V;

void solve(){
	if(turn){
		if(x==1){
			str[++d2]=ch;
		}else{
			str[--d1]=ch;
		}
	}else{
		if(x==1){
			str[--d1]=ch;
		}else{
			str[++d2]=ch;
		}
	}
}
int main()
{
	___
	// scanf("%s",str1);
	cin>>str1;
	turn=0;
	d1=1e5*2+5;
	d2=d1-1;
	d3=strlen(str1);
	for(L i=0;i<d3;i++){
		str[++d2]=str1[i];
	}
	// scanf("%lld",&q);
	cin>>q;
	while(q--){
		// scanf("%lld",&n);
		cin>>n;
		if(n==1)turn=turn^1;
		else {
			// scanf("%lld",&x,&ch);
			cin>>x>>ch;
			solve();
		}
	}
	if(turn){
		for(L i=d2;i>=d1;i--)cout<<str[i];
	}else{
		for(L i=d1;i<=d2;i++){
			cout<<str[i];
		}
	}cout<<endl;
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 2944
s=input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len(s)-3)//2-i]):
    a=0
    break
if(a==1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  double x[100], y[100], d1{0}, d2{0}, d3{0}, di{0}, distance_max{0}, distance;
  cin >> n;
  for (int i{0}; i < n; ++i) {
    cin >> x[i];
  }
  for (int i{0}; i < n; ++i) {
    cin >> y[i];
    distance = x[i] > y[i] ? x[i] - y[i] : y[i] - x[i];
    d1 += distance;
    d2 += distance * distance;
    d3 += distance * distance * distance;
    if (di < distance) {
      di = distance;
    }
  }
  cout << fixed << setprecision(6);
  cout << d1 << '\n';
  cout << sqrt(d2) << '\n';
  cout << pow(d3, 1.0 / 3.0) << '\n';
  cout << di << '\n';
}



Measured memory_bytes: 3404
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int main() {
	int b;
	while (cin >> b && b) {
		int  x;
		vector<int>divisorList;
		stack<int>st;
		b *= 2;
		for(x=1;x*x<b;++x)
			if (b%x == 0) {
				divisorList.push_back(b / x);
				st.push(x);
			}
		if (x*x == b) divisorList.push_back(x);
		while (!st.empty()) {
			divisorList.push_back(st.top());
			st.pop();
		}
		for (int i = 0;; ++i) {
			int n = b / divisorList[i] - divisorList[i] + 1;
			if (n % 2 == 0 && n >= 1){
				cout << n/2 << " " << divisorList[i] << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
typedef long long ll;
#define chmax(x, y) x = max(x, y);
int V[3100][3100];
ll dp[3100][3100][5];

int main() {
    int R, C, K; cin >> R >> C >> K;
    for (int i = 0; i < K; i++) {
        int r, c, v; cin >> r >> c >> v;
        V[r-1][c-1] = v;
    }

    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 2; k >= 0; k--) {
                chmax(dp[i][j][k+1], dp[i][j][k] + V[i][j]);
            }
            for (int k = 0; k < 4; k++) {
                chmax(dp[i+1][j][0], dp[i][j][k]);
                chmax(dp[i][j+1][k], dp[i][j][k]);
            }
        }
    }
    
    ll ans = 0;
    for (int k = 0; k < 4; k++) chmax(ans, dp[R-1][C-1][k]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 403120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final long N = sc.nextLong();
		final long M = sc.nextLong();
		
		long scc = Math.min(N, M/2);
		long c = Math.max(M - (2 * N) , 0);
		
		scc += c/4;
		System.out.println(scc);
		sc.close();
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}com(200005);
mint choose(int n,int a){
  mint x = 1,y=1;
  rep(i,a){
    x*= n-i;
    y*= i+1;
  }
  return x/y;
}

int main(){
  ll n,k;cin>>n>>k;
  ll a[n];
  rep(i,n)cin>>a[i];
  vector<P>as(n);
  rep(i,n){
    int cn=0,cnt=0;
    rep2(j,i+1,n){
      if(a[i]>a[j])cn++;
    }
    rep(j,n){
      if(a[i]>a[j])cnt++;
    }
    as[i]={cn,cnt};
  }
  mint ans =0;
  rep(i,n){
    mint now =as[i].first+as[i].second*(k-1)+as[i].first;
    now*=k;
    now/=2;
    ans+=now;
    //ans%=mod;
  }
  cout<<ans.x<<endl;
}

Measured memory_bytes: 6192
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000000
#define MOD 1000000007
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    t = 1;
    while(t--){
        string s;
        string t;
        cin>>s>>t;
        lli n = s.length();
        if(s == t.substr(0,n))
            cout<<"Yes"<<endl;
        else{
            cout<<"No"<<endl;
        }     

    }

}

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

int main() {

	int n, k;
	cin >> n >> k;

	vector<int> l(n);
	for(int i=0; i<n; i++){
		cin >> l.at(i);
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());

    int ans=0;
	for(int i=0; i<k; i++){
		ans += l.at(i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll MAX = 1000000000000;

int main(void)
{
	ll l, n, m, q, d[300][300], ans[300][300];
	cin >> n >> m >> l;
	rep(i, n) {
		rep(j, n) {
			if (i == j) ans[i][j] = d[i][j] = 0;
			else ans[i][j] = d[i][j] = MAX; 
		}
	}
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		if (c <= l) {
			d[a][b] = c;
			d[b][a] = c;
		}
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				chmin(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (d[i][j] <= l && i != j) {
				chmin(ans[i][j], 1LL);
			}
		}
	}
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				chmin(ans[i][j], ans[i][k] + ans[k][j]);
			}
		}
	}
	cin >> q;
	rep(x, q) {
		ll s, t;
		cin >> s >> t;
		s--; t--;
		cout << (ans[s][t] < MAX ? ans[s][t] : 0) - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cstdint>

using namespace std;

struct node_t {
  int32_t parent;
  int32_t left;
  int32_t right;
};

#define TREE_SIZE 10000

node_t trees[TREE_SIZE];

void binary_tree_init()
{
  for (uint32_t i = 0; i < TREE_SIZE; i++) {
    trees[i].parent = -1;
    trees[i].left = -1;
    trees[i].right = -1;
  }
}

void binary_tree_add(int32_t index, int32_t left, int32_t right)
{
  trees[index].left = left;
  trees[index].right = right;
  trees[left].parent = index;
  trees[right].parent = index;
}

static size_t node_depth(int32_t index)
{
  int32_t parent = trees[index].parent;
  size_t depth = 0;
  while (parent != -1) {
    depth++;
    parent = trees[parent].parent;
  }

  return depth;
}

static size_t node_height(int32_t index)
{
  int32_t left = trees[index].left;
  int32_t right = trees[index].right;

  size_t lheight = 0, rheight = 0;
  if (left != -1) {
    lheight = node_height(left) + 1;
  }

  if (right != -1) {
    rheight = node_height(right) + 1;
  }

  return max(lheight, rheight);
}

void binary_tree_info(int32_t index, int32_t &parent, int32_t &sibling, size_t &degree, size_t &depth, size_t &height)
{
  parent = trees[index].parent;

  sibling = -1;
  if (parent != -1) {
    int32_t left = trees[parent].left;
    int32_t right = trees[parent].right;
    if (index == left) {
      sibling = right;
    } else {
      sibling = left;
    }
  }

  degree = 0;
  if (trees[index].left != -1) degree++;
  if (trees[index].right != -1) degree++;

  depth = node_depth(index);

  height = node_height(index);
}

#if !defined(TEST)
#include <iostream>
int32_t main()
{
  binary_tree_init();

  uint32_t num;
  cin >> num;

  for (uint32_t i = 0; i < num; i++) {
    int32_t index, left, right;
    cin >> index >> left >> right;
    binary_tree_add(index, left, right);
  }

  for (uint32_t i = 0; i < num; i++) {
    int32_t parent, sibling;
    size_t degree, depth, height;
    binary_tree_info(i, parent, sibling, degree, depth, height);

    cout << "node " << i << ": parent = " << parent << ", sibling = " << sibling << ", degree = " << degree << ", depth = " << depth
         << ", height = " << height;
    if (parent == -1) {
      cout << ", root";
    } else if (degree == 0) {
      cout << ", leaf";
    } else {
      cout << ", internal node";
    }

    cout << endl;
  }
  return 0;
}
#endif

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

int main(){
  int n;
  cin >> n;
  vector<int64_t> l(n+1);
  l.at(0)=2;
  l.at(1)=1;
  for(int i=2;i<n+1;i++){
    l.at(i) = l.at(i-2) + l.at(i-1);
  }
  cout << l.at(n) << endl;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("7");
            //3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1729");
            //294867501
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int S = int.Parse(InputList[0]);

        const int Hou = 1000000000 + 7;

        //場合の数[和]なDP表
        int UB = S;
        int[] DPArr = new int[UB + 1];
        DPArr[0] = 1;
        for (int I = 0; I <= UB; I++) {
            //if (DPArr[I] == 0) continue;
            for (int J = 3; J <= S; J++) {
                int NewInd = I + J;
                if (UB < NewInd) break;
                DPArr[NewInd] += DPArr[I];
                DPArr[NewInd] %= Hou;
            }
        }
        Console.WriteLine(DPArr[UB]);
    }
}


Measured memory_bytes: 27752
#include <stdio.h>
#include <stdlib.h>
#define VMAX 100001
#define MAX 2000001
int  C[VMAX],B[MAX];
void CountingSort(int A[],int n){
  int i,j;  
  for(i=1;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i] + C[i-1];
  }  
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n-1;i++){
  printf("%d ",B[i]);
  }
  printf("%d",B[n]);
  printf("\n");
}    
int main(){
  int A[MAX];
  int n, i, j;
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }  
  CountingSort(A,n);
  return 0;
}



Measured memory_bytes: 17704
n=int(input())
h=list(map(int,input().split()))
h.insert(0,0)
#print(h)
count=0
for i in range(n+1):
    if len(h[:i]):
        if h[i-1]<=h[i] and max(h[:i])<=h[i]:
            #print(h[i])
            count+=1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int h1,m1,h2,m2,k;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    printf("%d",60*(h2-h1)+m2-m1-k);
    return 0;
}

Measured memory_bytes: 1732
/*
 _____ ____ _____   ___   ___   ___   ___ 
|_   _/ __ \_   _| |__ \ / _ \ |__ \ / _ \
  | || |  | || |      ) | | | |   ) | | | |
  | || |  | || |     / /| | | |  / /| | | |
 _| || |__| || |_   / /_| |_| | / /_| |_| |
|_____\____/_____| |____|\___/ |____|\___/ 
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
// assert(x==y); gives run time when false
using namespace std;
int main(){
    int n;
    cin >> n;
    vi v;
    rep(i,0,n){
        v.pb(i+1);
    }
    vi v1(n),v2(n),klo;
    rep(i,0,n){
        cin >> v1[i];
    }
    rep(i,0,n){
        cin >> v2[i];
    }
    int i = 0;
    do{
        i++;
        if(v == v1){
            klo.pb(i);
        }
        if(v == v2){
            klo.pb(i);
        }
    }while(next_permutation(v.begin(),v.end()));
    cout << abs(klo[1]-klo[0]);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> w(N);
  for (int i = 0; i < N; i++) {
  	cin >> w.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
  	sum += w.at(i);
  }
  
  int s = 0;
  int count = 0;
  for (int i = 0; i < N; i++) {
  	s += w.at(i);
    count++;
  	if (s > sum - s) {
    	break;
    }
  }
  int sa = 0;
  int sb = 0;
  for (int i = 0; i < count; i++) {
  	sa += w.at(i);
  }
  for (int i = 0; i < count - 1; i++) {
  	sb += w.at(i);
  }
  
  if (abs(sum - 2 * sa) < abs(sum - 2 * sb)) {
  	cout << abs(sum - 2 * sa) << endl;
  }
  else {
  	cout << abs(sum - 2 * sb) << endl;
  }
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

w = x2 - x1
h = y2 - y1

x3 = x2 - h
y3 = y2 + w

x4 = x1 - h
y4 = y1 + w

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))



Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,a[201],k,g,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&g);
		a[i]=k*60+g;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&k,&g);
		a[i+n]=k*60+g;
	}
	a[n+m]=24*60+59;
	sort(a,a+n+m);
	for(i=0;i<n+m;i++){
		if(i>0){
			printf(" ");
		}
		if(a[i]%60<10){
			printf("%d:0%d",a[i]/60,a[i]%60);
		}
		else{
			printf("%d:%d",a[i]/60,a[i]%60);
		}
		if(a[i]==a[i+1]){
			i++;
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <cstdlib>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, n;
    cin, k, n;
    vector<ll> a(2 * n);
    REP(i, 0, n) {
        cin, a[i];
        a[i + n] = a[i] + k;
    }
    sort(a.begin(), a.end());

    ll mx = 0;
    REP(i, 0, 2 * n - 1) {
        chmax(mx, a[i + 1] - a[i]);
    }
    cout << k - mx << endl;
    return 0;
}


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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int a,b;
  cin >>a>>b;
  if(a<=8 && b<= 8){
    cout<<"Yay!\n";
  }
  else
    cout<<":(\n";
  return 0; 
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n[3], k;
long long deli[3][1009];
vector<long long> vec, ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n[0] >> n[1] >> n[2] >> k;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < n[i]; j++) {
			cin >> deli[i][j];
		}
	}
	for (int i = 0; i < n[0]; i++) {
		for (int j = 0; j < n[1]; j++) {
			vec.pb(deli[0][i] + deli[1][j]);
		}
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	vector<long long> vec2(vec.begin(), vec.begin() + min(k, (int)vec.size()));
	for (int i = 0; i < n[2]; i++) {
		for (int j = 0; j < (int)vec2.size(); j++) {
			ans.pb(deli[2][i] + vec2[j]);
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < k; i++) {
		cout << ans[i] << "\n";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 43236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
int n,m,k,x1,x2,h1,y2;
queue<pair<int,int> > q;
int main(){
	n=read(),m=read(),k=read();
	x1=read()-1,h1=read()-1;
	x2=read()-1,y2=read()-1;
	char a[n+5][m+5];
	int b[n+5][m+5];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin >> a[i][j];
	q.push(make_pair(x1,h1));
	memset(b,0x3f,sizeof(b));
	b[x1][h1]=0;
	while(!q.empty()){
		int nx=q.front().first,ny=q.front().second;
		if(nx==x2 and ny==y2){
			cout << b[nx][ny];
			return 0;
		}
		q.pop();
		for(int i=0;i<4;i++)
			for(int j=1;j<=k;j++){
				int tx=nx+dx[i]*j;
				int ty=ny+dy[i]*j;
				if(tx>=0 and tx<n and ty>=0 and ty<m){
					if(a[tx][ty]=='@')break;
					if(b[tx][ty]>1e7){
						b[tx][ty]=b[nx][ny]+1;
						q.push(make_pair(tx,ty));
					}
					if(b[tx][ty]<=b[nx][ny])
						break;
				}
				else break;
			}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 27960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double PI = acos(-1);
  double rad = PI * 2 *((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
  double ans = a * a + b * b - 2 * a * b * cos(rad);
  printf("%.10f", sqrt(ans));
  return 0;
}

Measured memory_bytes: 4024
# -*- coding: utf-8 -*-
import sys

nums = (int(i) for i in sys.stdin.readline().rstrip().split())
a, b, c = sorted(nums)

if (b - a) % 2 != 0:
  a += 1
  c += 1
  if a == b:
    print(c - b + 1)
  else:
    diff = b - a
    print(c - b + diff // 2 + 1)
else:
  diff = b - a
  print(c - b + diff // 2)

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

using namespace std;

int main() {
  long long N, A, B;
  cin >> N >> A >> B;

  long long q = N / (A + B);
  long long r = N % (A + B);

  long long result = q * A;
  if (r > A) {
    result += A;
  } else {
    result += r;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int cnt(int h[],int n,int t){
    vector<int>dp(n+1,INT_MAX);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        for(int k=1;k<=t;k++){
            if(k<=i)
            dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
        }
    }
    return dp[n-1];
}
int main(){
    int n,t;
    cin>>n>>t;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    cout<<cnt(h,n,t)<<endl;
    return 0;
}


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

using namespace std;

#define Int unsigned long long int
#define BIG 1000000007



int main() {
    int counter = 0,a=0,b=0;
    bool f = false;
    int l;
    cin >> l;
    string c[2];
    for(int i = 0;i<l;i++){
        cin >> a >> b;
        if(a == b){
            counter++;
            if(counter == 3){
                f = true;
            }
        }else{
            counter = 0;
        }
    }
    cout <<((f?"Yes":"No")) << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B;
    string S;
    cin >> A >> B >> S;
    bool ans = true;
    rep(i,A+B+1){
        if(i!=A) {
            int a = S[i]-'0';
            if(!(a>=0&&a<=9)) ans = false;
        } else {
            char s = S[i];
            if(s!='-') ans = false;
        } 
    }
    cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  while(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組み合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c){
        cout << "No";
    }
    else if(a!=b && b!=c && c!=a){
        cout << "No";
    }
    else cout << "Yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int mod=1000000007;
int n,top,num;
ll K,a[210],c[210],d[210];
pair<ll,ll> qj[12010];
struct node
{
    ll t[210],a1;
    int k;
}s[12010];
bool operator <(const node &a,const node &b)
{
    for(int i=1;i<n;i++)
        if(a.t[i]<b.t[i]) return 1;
        else if(a.t[i]>b.t[i]) return 0;
    return 0; 
}
bool check(node &a,node &b)
{
    for(int i=1;i<n;i++)
        if(a.t[i]!=b.t[i]) return 0;
    return 1;   
}

int maxpop(ll x,ll y)
{
    if(x==-1) return 0;
    int re=0;
    for(int i=60;i>=0;i--)
        if(((x>>i)&1)==((y>>i)&1)) re+=((x>>i)&1);
        else {re++;break;}
    return re;  
}
ll dp()
{
    sort(qj+1,qj+num+1);
    ll re=0,l=0,r=-1;
    for(int i=1;i<=num;i++)
    {
        if(qj[i].first>r) {re+=(r-l+1);l=qj[i].first;}
        r=qj[i].second;
    }
    re+=(r-l+1);
    return re;  
}
int main()
{
    scanf("%d%lld",&n,&K);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1);    
    for(int i=0;i<=60;i++)
    {
        for(int j=1;j<=n;j++)
            c[j]=(a[j]&((1ll<<i)-1));   
        sort(c+1,c+n+1);
        c[0]=-1;
        int sz=unique(c+1,c+n+1)-c-1;
        for(int j=1;j<=sz;j++)
            if(a[1]>=c[j])
            {
                int P=maxpop(c[j-1],c[j]);
                for(int l=1;l<=n;l++)
                    d[l]=((a[l]-c[j])>>i);  
                s[++top].a1=d[1];s[top].k=i+P;
                for(int l=1;l<n;l++)
                    s[top].t[l]=d[l+1]-d[l];        
            }
    }
    sort(s+1,s+top+1);
    num=0;
    ll ans=0;
    for(int i=1;i<=top;i++)
    {
        if(i!=1&&!check(s[i],s[i-1])) ans=(ans+dp())%mod,num=0; 
        if(s[i].k<=K)qj[++num]=make_pair(max(s[i].a1-K+s[i].k,0ll),s[i].a1);
    }
    ans=(ans+dp())%mod;
    printf("%lld",ans);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) a.size()
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  V a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  int res=0,sum=0,ans=0;
  rep(i,n){
    if(a[i]-b[i]>0)res+=a[i]-b[i];
  }

  out(res);

  
  
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void){

	float a, t;
	int b;
	
	cin >> a >> b >> t;
	t += 0.5;
	
	int ans = 0;
	for(float i = a; i < t; i += a){
		ans += b;
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
// ABC053B - A to Z String

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

int main() {
	string S;
	cin >> S;

	int A, Z;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A') {
			A = i;
			break;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'Z') {
			Z = i;
			break;
		}
	}

	cout << Z - A + 1 << endl;

	return 0;
}


Measured memory_bytes: 640