akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int D;
    cin >> D;
    vector<int> c(26);
    REP(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    REP(i, D) REP(j, 26) cin >> s[i][j];
    vector<int> t(D);
    REP(i, D) {
        cin >> t[i];
        --t[i];
    }


    int score = 0;
    vector<int> last(26, -1);
    REP(d, D) {
        score += s[d][t[d]];
        last[t[d]] = d;
        REP(i, 26) {
            score -= c[i] * (d - last[i]);
        }
        cout << score << endl;
    }


    return 0;
}


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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  e=a+b;
  f=c+d;
  if (e>f){
    cout << "Left" << endl;
  }
  else if (e<f){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a<c and c<b) or(a>c and c>b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d", $N, $A, $B, $C);
$arrayL = array();
for ($i = 0; $i < $N; $i ++) {
    $arrayL[$i] = fgets(STDIN);
}
$arrayA = array();
$arrayB = array();
$arrayC = array();
$minMP = 3000;

// 全探索
// N個の竹をどこで使用するか、A,B,C,未使用の4つに分類する
// 11(2):A, 10(2):B, 01(2):C, 00(2):未使用
for ($i = 0; $i < pow(4, $N); $i ++) {
    $arrayA = array();
    $arrayB = array();
    $arrayC = array();
    for ($j = 0; $j <= $N; $j ++) {
        // 11(2)=3(10), 10(2)=2(10), 01(2)=1(10), 00(2)=0(10)
        if (($i & (3 << $j * 2)) === (3 << $j * 2)) {
            $arrayA[] = $arrayL[$j];
        } elseif (($i & (3 << $j * 2)) === (2 << $j * 2)) {
            $arrayB[] = $arrayL[$j];
        } elseif (($i & (3 << $j * 2)) === (1 << $j * 2)) {
            $arrayC[] = $arrayL[$j];
        } elseif (($i & (3 << $j * 2)) === (0 << $j * 2)) {
            // 何もしない
        }
    }

    if (count($arrayA) * count($arrayB) * count($arrayC) === 0) {
        continue;
    }

    // A,B,C作成にかかるコスト
    // 延短魔法
    $value = abs(array_sum($arrayA) - $A) + abs(array_sum($arrayB) - $B) + abs(array_sum($arrayC) - $C);
    // 合成魔法
    $value += (count($arrayA) - 1) * 10 + (count($arrayB) - 1) * 10 + (count($arrayC) - 1) * 10;
    if ($minMP > $value) {
        $minMP = $value;
    }
}
echo $minMP;


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int days = 0;days < n;days++) {
        vector<int> new_dp(3);
        vector<int> c(3);
        for(int i = 0;i < 3;i++) scanf("%d",&c[i]);
        for(int i = 0;i < 3;i++) {
            for(int j = 0;j < 3;j++) {
                if(i != j){
                   //cout << dp[i] << endl;
                   new_dp[j] = max(new_dp[j],dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    cout << max ({dp[0],dp[1],dp[2]}) << 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;
typedef long long ll;

int main(){
  ll n,k;
  ll v[56];
  int i;
  ll sum = 0;
  int p = 0;
  int m = 0;

  scanf("%lld %lld", &n, &k);

  for(i = 0;i < n;i++){
    scanf("%lld", &v[i]);
  }

  ll limit = min(n,k);

  ll a,b;
  vector <ll> get;
  ll mx = 0;
  for(a = 0;a <= limit;a++){
    for(b = 0;b <= limit;b++){
      if(a + b > limit) break;

      if(!(get.empty())) get.clear();

      sum = 0;
      for(i = 0;i < a;i++){
        get.push_back(v[i]);
      }

      for(i = 0;i < b;i++){
        get.push_back(v[n - 1 - i]);
      }

      sort(get.begin(),get.end());

      ll t = get.size();
      ll limit2 = min(t,k - a - b);
      for(i = 0;i < limit2;i++){
        if(get[i] < 0) get[i] = 0;

        else break;
      }

      for(i = 0;i < get.size();i++){
        sum += get[i];
      }

      if(mx < sum) mx = sum;
    }
  }

  printf("%lld\n", mx);
  return 0;
}

Measured memory_bytes: 256
s=input() 
#maximize ans.count(p)-ans.count(g)
#at each point g>=p   
g=0 
p=0 
ans=''
for i in s: 
    if i=='g':
        if g==p: 
            ans+='g'
            g+=1 
        else: 
            ans+='p'
            p+=1  
    if i=='p':
        if g==p: 
            ans+='g'
            g+=1 
        else: 
            ans+='p'
            p+=1 
cnt=0 
#print(ans)
for i in range(len(s)):
    if s[i]=='g' and ans[i]=='p':
        cnt+=1 
    if s[i]=='p' and ans[i]=='g': 
        cnt-=1  
print(cnt)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,h,in[500],out[500];
vector<int> E[500];
bool vis[500],fl=0;
void dfs(int u) {
    vis[u]=1;
    if(in[u]!=out[u]) fl=1;
    for(int v:E[u])
        if(!vis[v]) dfs(v);
}
int main() {
    n=gi(),h=gi();
    for(int i=1;i<=n;i++) {
        int a=gi(),b=gi(),c=gi(),d=gi(),l,r;
        if(c==0) l=a; else l=-c;
        if(d==0) r=-b; else r=d;
        l+=h,r+=h;
        E[l].pb(r),E[r].pb(l),++out[l],++in[r];
    }
    for(int i=0;i<=2*h;i++) {
        if(i<h&&in[i]<out[i]) return puts("NO"),0;
        if(i>h&&in[i]>out[i]) return puts("NO"),0;
    }
    for(int i=0;i<=2*h;i++)
        if(i!=h&&!vis[i]&&in[i]+out[i]) {
            fl=0,dfs(i);
            if(!fl) return puts("NO"),0;
        }
    puts("YES");
    return 0;
}


Measured memory_bytes: 1664
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ans = 0
for a in range(k):
    mae = ''
    for i in range(a, n, k):
        if (mae != t[i]):
            mae = t[i]
            # win
            if(t[i] == 'r'):
                ans += p
            elif(t[i] == 's'):
                ans += r
            else:
                ans += s
        else:
            # can't win
            mae = ''
print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 準備
    int n = sc.nextInt();
    int[] a = new int[n];
    String ans = "YES";
    
    // 入力
    for(int i=0; i<n; ++i)
      a[i] = sc.nextInt();
    
    // 解く
    Arrays.sort(a);
    for(int i=1; i<n; ++i) {
      if(a[i-1] == a[i]) {
        ans = "NO"; break;
      }
    }
    
    // 出力
    System.out.println(ans);
  }
}

Measured memory_bytes: 64328
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (size_t i = 0; i < (size_t) (n); i++)

using namespace std;
using ll = long long;

int main(void) {
  string s, t;
  cin >> s >> t;
  cout << (s == t.substr(0, t.size()-1) && s.size() + 1 == t.size() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int h,w,k; cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h) {
        rep(j,w) cin >> c[i][j];
    }
    ll ans = 0;
    // rep(i,h) {
    //     rep(j,w) {
    //         ll cnt = 0;
    //         rep(k,h) {
    //             rep(l,w) {
    //                 if(k == i || l == j) continue;
    //                 if(c[k][l] == '#') cnt++;
    //             }
    //         }
    //         if(cnt == k) {
    //             cout << i <<" " << j << endl;
    //             ans++;
    //         }
    //     }
    // }
    for (int bit_h = 0;bit_h <(1<<h);++bit_h) {
        for (int bit_w = 0;bit_w <(1<<w);++bit_w) {
            ll cnt = 0;
            rep(i,h) {
                rep(j,w) {
                    if(bit_h &(1<<i) || bit_w & (1<<j)) continue;
                    if(c[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  set<char>s;
  rep(i,3){
    char c;cin>>c;
    s.insert(c);
  }
  if(s.size()==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 
  vector <string> a,b;
  string tmp;
  int n,i;
 
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    a.push_back(tmp);
  }

  b.assign(a.begin(),a.end());
  for(i=0;i<n-1;i++) for(int j=n-2;j!=i-1;j--) if(a[j][1]>a[j+1][1]) swap(a[j],a[j+1]);
  for(i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<"Stable"<<endl;
 
  for(i=0;i<n-1;i++){
    int now,minnum=101;
    for(int j=i;j<n;j++) if(minnum>b[j].at(1)-'0'){
        now=j;
        minnum=b[j].at(1)-'0';
      }
    if(i!=now)  swap(b[i],b[now]);
  }
 
  for(i=0;i<n-1;i++) cout<<b[i]<<" ";
  cout<<b[n-1]<<endl;
  if(a==b) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
 
  return 0;
 
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int n;
int c1(const void *v1,const void *v2){
    return strcmp((char *)v2,(char *)v1);
}
int c2(const void *v1,const void *v2){
    return strcmp((char *)v1,(char *)v2);
}
int central(int number){
    char line[8],line1[8];
    int large,small,i;
    int n1=sprintf(line,"%d",number);
    int n2=sprintf(line1,"%d",number);
    qsort(line,n1,sizeof(char),c1);
    qsort(line1,n2,sizeof(char),c2);
    for(i=n2;i<n;i++)
        line[i]=48;
    line[i]=0;
    large=atoi(line);
    small=atoi(line1);
    return large-small;
}
int main(void){
    int sign,number,max,line[21]={0},i;
    for(;max=1,sign=0,memset(line,0,sizeof(line)),scanf("%d %d",&number,&n),line[0]=number,n;){
        while(1){
            number=central(number);
            for(i=0;i<max;i++)
                if(line[i]== number){
                    printf("%d %d %d\n",i,number,max-i);
                    sign=1;
                    break;
                }
            if(sign==1)
                break;
            else{
                line[i]=number;
                max++;
            }
        }
    }
    return 0;
}

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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

int32_t main(){
	boost;



	int a , b;

	cin >> a >> b;

	cout << max( a+b , max( 2*a - 1 , 2*b - 1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
int main(){
  	int n;
  	cin>>n;
  	int h[n];
  	for(int i=0;i<n;i++){
      	cin>>h[i];
    }
  	int dp[n+1];
  	dp[0]=0;
  	dp[1]=0;
  	for(int i=2;i<=n;i++){
      	int val=INT_MAX;
      	for(int j=max(1,i-2);j<i;j++){
          	val=min(abs(h[i-1]-h[j-1])+dp[j],val);
        }
      	dp[i]=val;
    }
  	cout<<dp[n]<<endl;
  	
}

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

int main()
{
    int n,i,c=0,a[100005];
    scanf(" %d",&n);
    for(i=1;i<=n;i++){
        scanf(" %d",&a[i]);
    }
    for(i=1;i<=n;i++){
        if(i+1<=n){
            if(a[i]==i && a[i+1]==i+1){
                c++;
                i++;
            }
            else if(a[i]==i){
                c++;
            }
            else{

            }
        }
        else{
            if(a[i]==i){
                c++;
            }
        }
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 640
import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,w = map(int,readline().split()) #n:頂点数　w:辺の数
g = [[] for i in range(n)] #g[i]:点iに隣接している点のリスト
for i in range(w):
    x,y = map(int,readline().split())
    x,y = x-1,y-1
    g[x].append(y)
    g[y].append(x)

def dfs():
    ans = 0
    queue = deque([[0]]) #queueの中身をvisitedにするlen(queue)==nの時ans+=1
    while queue:
        lst = queue.popleft()
        if len(lst)==n:
            ans += 1
            continue
        for i in g[lst[-1]]:
            if not i in lst:
                queue.append(lst+[i])
    
    return ans

print(dfs())




Measured memory_bytes: 41584
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include<limits.h>
using namespace std;
using T = tuple<int,int,int>;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
//#define endl '\n'
#define int long long
#define INF 1e7
#define ss second
#define ff first
#define vi vector<int>
#define pri(arr,a,b) repn(i,1,a){repn(j,i+1,b){cout<<arr[i][j]<<" ";}cout<<endl;}
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<int,pair<int,int>> piii;
 
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=(1LL<<21)+10;
 
int a[23][23],dp[MAXN][23],n;
 
int rec(int mask,int id){
    if(mask==(1LL<<n)-1 && id==n){
        return 1;
    }
    if(dp[mask][id]!=-1){
        return dp[mask][id];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(mask & (1LL<<i)){
            continue;
        }
        if(a[id][i]){
            ans=(ans+rec(mask|(1LL<<i),id+1))%mod;
        }
    }
    return (dp[mask][id]=ans);
}
void solve()
{
    mem(dp,-1);
    cin>>n;
    rep(i,0,n){
        rep(j,0,n){
            cin>>a[i][j];
        }
    }
    int ans=rec(0,0);
    cout<<ans<<endl;
}
int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     freopen("outputf.in", "w", stdout);
    // #endif
    fast_cin();
    int T;
    //sieve();
    //cin>>T;
    T=1;
    int t1=1;
    while(true)
    {  
        solve();  
        t1++;
        if(t1>T)
            break;
    }
}

Measured memory_bytes: 380488
// PANASONIC2020 - B - Bishop

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

typedef long long ll;

int main(){
	ll H,W;
	cin>>H>>W;

	if(H==1||W==1){
		cout<<1<<endl;
	}else{
		cout<<(H*W+1)/2<<endl;
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

typedef pair<xy_t, bool> dat;

namespace std{
	bool operator < (const xy_t &a, const xy_t &b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a)*b);
}

int ccw(xy_t a, xy_t b, xy_t c){
	b -= a; c -= a;
	if(cross(b, c) > 0) return 1;
	if(cross(b, c) < 0) return -1;
	if(dot(b, c) < 0) return +2;
	if(norm(b) < norm(c) ) return -2;
	return 0;
}

bool intersectSS(const line &s, const line &t){
	return ccw(s.first, s.second, t.first) * ccw(s.first, s.second, t.second) <= 0 &&
		ccw(t.first, t.second, s.first) * ccw(t.first, t.second, s.second) <= 0;
}

xy_t crosspoint(const line &l, const line &m){
	double a = cross(l.second - l.first, m.second - m.first);
	double b = cross(l.second - l.first, l.second - m.first);
	if(abs(a) < EPS && abs(b) < EPS) return m.first;
	if(abs(a) < EPS) assert(false);
	return m.first + b / a * (m.second - m.first);
}

line lines[200];

int main(){
	int n;
	double x1, y1, x2, y2;
	while(cin >> n && n){
		int ans = 1;
		for(int i = 0; i < n; i++){
			vector<xy_t> ps;
			ans++;
			cin >> x1 >> y1 >> x2 >> y2;
			lines[i] = line(xy_t(x1, y1), xy_t(x2, y2));
			for(int j = 0; j < i; j++){
				if(intersectSS(lines[i], lines[j])){
					xy_t p = crosspoint(lines[i], lines[j]);
		//			cout << p << endl;
					if(abs(imag(p)) - 100.0 + EPS > 0 || abs(real(p)) - 100.0 + EPS > 0) continue;
					bool ok = true;
					for(int k = 0; k < (int)ps.size(); k++){
						if(abs(ps[k] - p) < EPS){
							ok = false;
							break;
						}
					}
					if(ok) ps.push_back(p);
				}
			}
			ans += ps.size();
		}
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long LL;

const int N=1000000,C=26;

int n,len[N+9];
char s[N+9],*str[N+9];
struct tree{
  int s[C],cnt;
}tr[N+9];
int cn;

void Build(){cn=1;}

void Insert(char *s,int n){
  int k=1;
  for (int i=1;i<=n;++i){
	int &t=tr[k].s[s[i]-'a'];
	k=t=t?t:++cn;
  }
  ++tr[k].cnt;
}

int cnt[C+9];

int Solve(int id){
  int res=0;
  for (int i=0;i<C;++i) cnt[i]=0;
  int m=len[id];
  for (int i=1;i<=m;++i) ++cnt[(s[i]=str[id][i])-'a'];
  int k=1;
  for (int i=0;i<=m;++i){
	if (i){
	  --cnt[s[i]-'a'];
	  k=tr[k].s[s[i]-'a'];
	}
	//res+=tr[k].cnt;
	for (int j=0;j<C;++j){
	  if (!cnt[j]) continue;
	  res+=tr[tr[k].s[j]].cnt;
	}
  }
  return res;
}

void work(){
  scanf("%d",&n);
  Build();
  for (int i=1;i<=n;++i){
	scanf("%s",s+1);
	len[i]=strlen(s+1);
	reverse(s+1,s+len[i]+1);
	Insert(s,len[i]);
	str[i]=new char[len[i]+9];
	for (int j=1;j<=len[i];++j) str[i][j]=s[j];
  }
  LL ans=0;
  for (int i=1;i<=n;++i) ans+=Solve(i);
  printf("%lld\n",ans-n);
}

int main(){
  int T=1;
  //scanf("%d",&T);
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 110044
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(){
  int n, i;
  for(i=0;i<50;i++) dp[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;


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

    if(K > (N-1) * (N-2) / 2) {
        cout << "-1" << endl;
        return 0;
    }

    vector<pii> v;
    for(int i = 1; i <= N; i++) {
        for(int j = i+1; j <= N; j++) {
            v.push_back({i, j});
        }
    }

    int M = (N-1) * (N-2) / 2 - K + N - 1;
    cout << M << endl;

    for(int i = 0; i < M; i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N = 2e5 + 10;
int dp[N];

void solve()
{
   int n,x,m;
    cin >> n >> x >> m;
    
   if(m == 1)
   {
       cout << 0 << '\n';
       return;
   }
    
   dp[1] = x;
   for(int i=2;i<N;i++) dp[i] = (dp[i-1]*dp[i-1])%m;
    
   int res = 0; 
    
   if(n < N)
   {
       for(int i=1;i<=n;i++) res+=dp[i];
   }
   else
   {
       map<int,int> save;
       
       for(int i=1;i<N;i++)
       {
          if(save.find(dp[i]) == save.end())
          {
              save[dp[i]] = i;
              res+=dp[i];
          }
          else
          {
              int st = save[dp[i]];
              int len = i - st;
              n-=i-1;
              
              int full = (n/len);
              int partial = (n % len);
              
              for(int j=st;j<i;j++)
              {
                  res+=full*dp[j];
                  
                  if(partial > 0) 
                  {
                      res+=dp[j];
                      partial--;
                  }
              }
              
              break;
          }
       }
   }
    
   cout << res; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n; cin >> n;
    vector<ll> dp(n+100000,INF);
    vector<int> c(1,1);
    for(int i=6;i<=100000;i*=6) c.push_back(i);
    for(int i=9;i<=100000;i*=9) c.push_back(i);
    sort(c.begin(),c.end());
    
    dp[0] = 0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<c.size();j++){
            chmin(dp[i+c[j]],dp[i]+1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	long long int n, m, u;

	scanf("%lld%lld", &n, &m);

	if(n == 1){
		if(m != 1){
			u = m - 2;
		}
		else{
			u = 1;
		}
	}
	else if(m == 1){
		u = n - 2;
	}
	else{
		u = (n-2) * (m-2);
	}

	printf("%lld", u);

	return 0;
}


Measured memory_bytes: 128
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n]);
    let mut ret = 0;
    for (i, v) in a.iter().enumerate() {
        if i % 2 == 0 && v % 2 == 1
        {
            ret = ret + 1;
        }
    }
    println!("{}", ret);
}


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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;
int main(){
  string s; cin >> s;
  if( s[0] == s[1] && s[1] == s[2]){ cout << "Yes" << endl; return 0;}
  else if( s[1] == s[2] && s[2] == s[3]){ cout << "Yes" << endl; return 0;}
  
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s; cin>>s;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D');
            else {cout<<"No"<<endl;return 0;}
        }else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D');
            else {cout<<"No"<<endl;return 0;}
        }
    }
    cout<<"Yes"<<endl;return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const long long mod=998244353;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>L(K),R(K);
  for(int i=0;i<K;i++){
    cin>>L[i]>>R[i];
  }
  vector<int>dp(N+1);
  vector<int>sum(N+1);
  dp[1]=1;
  sum[1]=1;
  for(int i=2;i<=N;i++){
    for(int k=0;k<K;k++){
      int li=i-R[k];
      int ri=i-L[k];
      li=max(li,1);
      if(ri<0){continue;}
      (dp[i]+=(sum[ri]-sum[li-1]+mod)%mod)%=mod;
    }
    sum[i]=(sum[i-1]+dp[i])%mod;
  }
  cout<<dp[N]<<endl;
  return 0;                       
}

Measured memory_bytes: 4812
N,M = map(int,input().split())
py = []

for i in range(M):
    p,y = map(int,input().split())
    py.append([p,y,i])

py.sort()

P = [0]*(N+1)
ID = []

for p,y,i in py:
    
    P[p] += 1 ##どの県に何個市があるかカウント

    p_tmp = str(p)
    y_tmp = str(P[p])

    upper = "0"*max(0,6-len(p_tmp))+p_tmp
    lower = "0"*max(0,6-len(y_tmp))+y_tmp

    ID.append([i,upper+lower])

ID.sort()

for _,i in ID:
    print(i)

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

int main() {
	int N;
	cin >> N;
	int ans=1;
	for (int i=2; i<=N; i++){
	    int power=i*i;
	    for (int j=2; ; j++){
	        if (power>N) break;
	        ans=max(ans, power);
	        power*=i;
	    }
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;

//#define _DBG

int main()
{
	int N;
	int ret;

#ifdef _DBG
	ret = scanf_s("%d", &N);
#else
	ret = scanf("%d", &N);
#endif

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
#ifdef _DBG
		ret = scanf_s("%d", &v[i]);
#else
		ret = scanf("%d", &v[i]);
#endif
	}
	//	sort(v.begin(), v.end(), std::greater<int>());
	sort(v.begin(), v.end());
	int result = INT_MAX,temp;
	for (int i = v[0]; i <= v[N-1]; i++) {
		temp = 0;
		for (int j = 0; j < N; j++) {
			temp += (v[j] - i)*(v[j] - i);
		}
		if (result > temp) {
			result = temp;
		}
	}
	printf("%d\n", result);
	return 0;
//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];

            long[] h = ILongs();

            long ima = 0;
            long ans = 0;
            for(long i=n-1;i>0;i--){
                if(h[i]<=h[i-1]){
                    ima++;
                    if(ima>ans)ans++;
                }else{
                    ima = 0;
                }
            }

            WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 23388
import java.util.Scanner;

public class Main {

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

	final static int MOD = 1000000007;
	public void run() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long ans = pow(2, n);
		ans = minus(ans, 1);
		ans = minus(ans, combi(n, a));
		ans = minus(ans, combi(n, b));
		System.out.println(ans);
		sc.close();
	}

	private long combi(long n, long k) {
		long x=1;
		long y=1;
		for(int i=0; i<k; i++) {
			x = mul(x, (n-i));
			y = mul(y, (i+1));
		}
		return div(x, y);
	}

	private long div(long a, long b) {
		return mul(a, inv(b));
	}

	private long inv(long n) {
		return pow(n, MOD-2);
	}

	private long pow(long n, long x) {
		long res = 1;
		if(x==0) return res;
		res = pow(n, x/2);
		if(x%2==0) {
			res = mul(res, res);
		}else {
			res = mul(mul(res, res), n);
		}
		return res;
	}

	private long minus(long a, long b) {
		if((a -= b) < 0) a += MOD;
		return a;
	}

	private long mul(long a, long b) {
		return (a * b) % MOD;
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n;
set<int> st;
signed main(){
  cin>>n;
  rep(i,n){
    int t;cin>>t;
    if(st.count(t)){
      cout << "NO" << endl;
      return 0;
    }else{
      st.insert(t);
    }
  }
  cout << "YES" << endl;
}




Measured memory_bytes: 9600
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#define UTIL_SWAP(x, y)                                                                                                                    \
  do {                                                                                                                                     \
    typeof(x) _a = x;                                                                                                                      \
    x = y;                                                                                                                                 \
    y = _a;                                                                                                                                \
  } while (0)


size_t partition(int32_t data[], size_t len)
{
  size_t index = 0;

  if (data == NULL) return index;

  int32_t pivot = data[len - 1];

  uint32_t i;
  for (i = 0; i < len - 1; i++) {
    if (data[i] <= pivot) {
      UTIL_SWAP(data[index], data[i]);
      index++;
    }
  }

  UTIL_SWAP(data[index], data[len - 1]);
  return index;
}

#if !defined(TEST)
#include <stdio.h>
static int32_t data[1000000];

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  int32_t i;
  for (i = 0; i < num; i++) {
    scanf("%d", &data[i]);
  }

  size_t index = partition(data, num);

  for (i = 0; i < num; i++) {
    if (i != 0) printf(" ");

    if (i == index) {
      printf("[%d]", data[i]);
    } else {
      printf("%d", data[i]);
    }
  }

  printf("\n");

  return 0;
}

#endif

Measured memory_bytes: 992
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n), l, r; re(i, n) std::cin >> a[i];
  if(n==2){
    std::cout << abs(a[0] - a[1]) << '\n';
    return 0;
  }
  sort(a.begin(), a.end());
  for(int i=0;i<(n%2==0?n/2-1:n/2);i++) l.push_back(a[i]),r.push_back(a[n-1-i]);

  vll A{l[0], r[r.size()-1], 0}, B{r[0], l[l.size()-1], 0};
  ll tmp = 0;
  re(i, l.size()){
    if(i!=0) tmp += abs(l[i] - r[i-1]);
    tmp += abs(l[i]-r[i]);
  }
  A[2] = tmp;
  tmp = 0;
  re(i, l.size()){
    if(i!=0) tmp += abs(r[i] - l[i-1]);
    tmp += abs(r[i]-l[i]);
  }
  B[2] = tmp;
  //std::cout << A[0] << " " << A[1] << " " << A[2]  << '\n';
  //std::cout << B[0] << " " << B[1] << " " << B[2]  << '\n';

  if(n%2==1){
    ll x = a[n/2];
    ll ans = max({A[2]+abs(A[0]-x), A[2]+abs(A[1]-x), B[2]+abs(B[0]-x),B[2]+abs(B[1]-x)});
    std::cout << ans << '\n';
  }else{
    ll x = a[n/2-1], y = a[n/2];
    ll ans = max({A[2]+abs(A[0]-x)+abs(A[1]-y), A[2]+abs(A[1]-x)+abs(A[0]-y)});
    ans = max({ans, B[2]+abs(B[0]-x)+abs(B[1]-y), B[2]+abs(B[1]-x)+abs(B[0]-y)});
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 2932
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli x = 0ll, k = 0ll, d = 0ll;
	cin >> x >> k >> d;
	if (x < 0ll)
		x = -x;
	lli t = x / d;
	if (t >= k)
		x -= (1ll * d * k);
	else
	{
		k -= t;
		if (k & 1ll)
			x -= (1ll * d * (t + 1ll));
		else
			x -= (1ll * d * t);
	}
	if (x < 0ll)
		x = -x;
	cout << x << endl;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	inl(x);
	inl(x1);
	if (x1 == 1 or x == 1) { out(1);return 0; }
	if(x1%2)out(((x1+1)/2)*x-(x/2));
	else{ out(((x1 + 1) / 2) * x); }
	return 0;
}

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


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    
    const double pi = 2 * acos(-1);
    
    double alpha = pi * (60 * H + M) / 720;
    double beta = pi * M / 60;
    
    double Ax = A * cos(alpha);
    double Ay = A * sin(alpha);
    
    double Bx = B * cos(beta);
    double By = B * sin(beta);
    
    double ans = sqrt(pow(Ax - Bx, 2) + pow(Ay - By, 2));
    
    cout << ans << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3592
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...)
#endif
using namespace std;

const int maxN = 1 << 11;

int main()
{
	int n, m;
	scanf ("%d%d", &n, &m);

	printf("%d\n", n^m);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
ll n,k;
  cin>>n>>k;
  ll count=1;
  while(1){
  if(n<k)
    break;
    n=n/k;
    count++;
  }
  cout<<count;
  return 0;
 
}
 


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



from queue import deque
n,x = map(int, input().split())
A = list(map(int, input().split()))

def sub(p):
    k = p
    res = []
    q = deque([])
    a = A + A[:k-1]
    # q: i0<i1<,..., a_i0>a_i1>,...であるようなi0, i1,... のキュー
    for i,num in enumerate(a):
        while q and a[q[-1]]>num:
            q.pop()
        q.append(i)
        if q[0]<=i-k:
            q.popleft()
        if i>=k-1:
            m = a[q[0]] # i-k+1,...iの中の最小値
            res.append(m)
    return sum(res)


ans = 10**15
for p in range(n):
    ans = min(ans, sub(p+1) + x*p)
print(ans)

Measured memory_bytes: 56920
#include <stdio.h>
#include <string.h>
#define N 500000

typedef struct{
  int key, left, right;
}Node;

Node tree[N+1];
int size;

void insert(int x){
  int p = 0;
  while(1){
    if(x < tree[p].key){
      if(tree[p].left == -1){
        tree[p].left = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].left;
    }else{
      if(tree[p].right == -1){
        tree[p].right = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].right;
    }
  }
}

void inorder(int p){
  if(tree[p].left != -1) inorder(tree[p].left);
  printf(" %d", tree[p].key);
  if(tree[p].right != -1) inorder(tree[p].right);
}

void preorder(int p){
  printf(" %d", tree[p].key);
  if(tree[p].left != -1) preorder(tree[p].left);
  if(tree[p].right != -1) preorder(tree[p].right);
}

main(){
  int n, i, first;
  first = 1;
  scanf("%d", &n);
  for(i=0;i<=n;i++) tree[i].key = tree[i].left = tree[i].right = -1;
  size = 0;
  while(n--){
    char str[100];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(first){
        tree[size++].key = in;
        first = 0;
      }
      else insert(in);
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 6280
# -*- coding: utf-8 -*-

def main():

	while True:
		H,W = map(int,raw_input().split())
		if H == W == 0:
			break
		a = ''
		for i in xrange(W):
			a += '#'
		for i in xrange(H):
			print(a)
		print('')

if __name__ == "__main__":

	main()


Measured memory_bytes: 6364
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

H = ri()
cnt = 1
while H > 1:
    H = H // 2
    cnt += 1
print(sum([2 ** i for i in range(cnt)]))

Measured memory_bytes: 9216
a=["#." * (300//2),".#" * (300//2)]*(300//2)
while True:
    [h,w] = map(int, input().split())
    if h==0 and w==0:
        break
    t = map(lambda x: x[0:w], (a[0:h]))
    for i in t:
        print(i)
    print()

Measured memory_bytes: 7696
n = gets.to_i
h = gets.split.map(&:to_i)

max = 0
cur = 0
(0...n-1).each do |i|
  if h[i] >= h[i+1]
    cur += 1
    max = [max, cur].max
  else
    cur = 0
  end
end

puts max


Measured memory_bytes: 11140