akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <climits>
#include <set>
#include <algorithm>
#define R register
#define IN inline
#define W while
#define MX 200500
#define gc getchar()
#define ls (now << 1)
#define rs (now << 1 | 1)
#define ll long long 
#define MOD 1000000007
#define lbt(i) ((i) & (-(i)))
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
template <class T> IN T max(T a, T b) {return a > b ? a : b;}
template <class T> IN T min(T a, T b) {return a < b ? a : b;}
int n, bd;
int tree[MX];
struct INFO {int pos, spd;} dat[MX];
struct Seg {int lb, rb;} seg[MX];
IN bool operator < (const INFO &x, const INFO &y) {return x.spd < y.spd;}
IN bool operator < (const Seg &x, const Seg &y) {return x.rb == y.rb ? x.lb < y.lb : x.rb < y.rb;}
namespace SGT1
{
	int mn[MX << 2], mx[MX << 2];
	IN void pushup(R int now)
	{
		mn[now] = min(mn[ls], mn[rs]);
		mx[now] = max(mx[ls], mx[rs]);
	}
	void build (R int now, R int lef, R int rig)
	{
		if (lef == rig) return mn[now] = mx[now] = dat[lef].pos, void();
		int mid = lef + rig >> 1;
		build(ls, lef, mid), build(rs, mid + 1, rig);
		pushup(now);
	}
	int qmin(R int now, R int lef, R int rig, R int lb, R int rb)
	{
		if (lef >= lb && rig <= rb) return mn[now];
		int mid = lef + rig >> 1, ret = INT_MAX;
		if (lb <= mid) ret = qmin(ls, lef, mid, lb, rb);
		if (rb >  mid) ret = min(ret, qmin(rs, mid + 1, rig, lb, rb));
		return ret;
	}
	int qmax(R int now, R int lef, R int rig, R int lb, R int rb)
	{
		if (lef >= lb && rig <= rb) return mx[now];
		int mid = lef + rig >> 1, ret = -INT_MAX;
		if (lb <= mid) ret = qmax(ls, lef, mid, lb, rb);
		if (rb >  mid) ret = max(ret, qmax(rs, mid + 1, rig, lb, rb));
		return ret;
	}
	int qpos(R int now, R int lef, R int rig, R int lb, R int rb, R int tar, R bool typ)
	{
		if (lef == rig) return lef;
		int mid = lef + rig >> 1;
		if (!typ)//to query the most left point with pos > tar
		{
			if (mx[ls] >= tar) return qpos(ls, lef, mid, lb, rb, tar, typ);
			else return qpos(rs, mid + 1, rig, lb, rb, tar, typ);
		}
		else
		{
			if (mn[rs] <= tar) return qpos(rs, mid + 1, rig, lb, rb, tar, typ);
			else return qpos(ls, lef, mid, lb, rb, tar, typ);
		}
	}
}
IN void add(R int pos, R int v)
{for (; pos <= bd; pos += lbt(pos)) (tree[pos] += v) %= MOD;}
IN int qpfix(R int pos)
{
	int ret = 0;
	for (; pos; pos -= lbt(pos)) (ret += tree[pos]) %= MOD;
	return ret;
}
IN int query(R int lb, R int rb) {return (qpfix(rb) - qpfix(lb - 1) + MOD) % MOD;}
int main(void)
{
	in(n); bd = n + 1;
	for (R int i = 1; i <= n; ++i) in(dat[i].pos), in(dat[i].spd);
	std::sort(dat + 1, dat + 1 + n);
	SGT1::build(1, 1, n);
	for (R int i = 1; i <= n; ++i)
	{
		seg[i].lb = SGT1::qpos(1, 1, n, 1, i, dat[i].pos, 0);
		seg[i].rb = SGT1::qpos(1, 1, n, i, n, dat[i].pos, 1);
	}
	std::sort(seg + 1, seg + 1 + n);
	add(1, 1);
	for (R int i = 1; i <= n; ++i) seg[i].lb++, seg[i].rb++, add(seg[i].rb, query(seg[i].lb - 1, seg[i].rb));
	printf("%d", query(n + 1, n + 1));
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int a[N];
void solve(){
    int n;
    cin >> n;
    map <int,int> mp; 
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        mp[-(a[i] + i)] ++;
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans += mp[a[i] - i]; 
    }
    cout << ans ;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 21296
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    int A, B;

    cin >> A >> B;        

    if ((A+B)%3 == 0) cout << "Possible" << endl;
    else if (A%3 == 0) cout << "Possible" << endl;
    else if (B%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl; 
    
    return 0;

}

Measured memory_bytes: 256
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
s=input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Measured memory_bytes: 62136
#include<iostream>
#include<vector>
using namespace std;
int main(){
   int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0)
    cout<<1;
  
  
  else if(x2==0)
    cout<<2;
  
  else if(x3==0)
    cout<<3;
  
  else if(x4==0)
    cout<<4;
  
  else if(x5==0)
    cout<<5;
  
  
  return 0;
  
  
  
  
  
}


Measured memory_bytes: 3544
import sys
input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))
D, G = inpl()
P = [0]*D
C = [0]*D
for i in range(D):
    P[i], C[i] = inpl()

ans = sum(P)
for k in range(2**D):
    score = 0
    cnt = 0
    for i in range(D):
        if (k >> i) & 1:
            cnt += P[i]
            score += 100*(i+1)*P[i] + C[i]
    
    for i in range(D-1, -1, -1):
        if (k >> i) & 1 == 0:
            tmp = -(-(G - score)//(100*(i+1)))
            x = max(0, min(P[i]-1, tmp))
            cnt += x
            score += 100*(i+1)*x
    if score >= G:
        ans = min(ans, cnt)
            
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x;
    cin >> x;
    int sum = 0;
    if ((x / 100) > 0){
	sum++;
    }
    if ((x % 100) / 10){
	sum++;
    }
    if ((x % 10)){
	sum++;
    }
    
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,x=1;
double dp[2][6001];
main()
{
	cin>>n;
	dp[0][n]=1;
	for(int i=0;i<n;i++)
	{
		double p;cin>>p;
		for(int j=0;j<=2*n;j++)dp[x][j]=0;
		for(int j=0;j<2*n;j++)dp[x][j+1]+=dp[!x][j]*p;
		for(int j=0;j++<2*n;)dp[x][j-1]+=dp[!x][j]*(1-p);
		x=!x;
	}
	double ans=0;
	for(int i=0;i++<n;)ans+=dp[!x][i+n];
	cout<<fixed<<setprecision(15)<<ans<<endl;
}

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

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

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);
const ld E=2.71828182845904523536;

int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    int n,ans=0,b=0,a=0,ba=0;
    cin>>n;
    string s[n];
    rep(i,n) cin>>s[i];

    rep(i,n){
         forv(j,s[i]){
            if(j==SZ(s[i])-1) ;
            else if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
         }
         if(s[i][0]=='B') b++;
         if(s[i][SZ(s[i])-1]=='A') a++;
         if(s[i][0]=='B' && s[i][SZ(s[i])-1]=='A') ba++;
    }

    //cout<<a _ b _ ba _ ans<<endl;
    if(a==b){
        if(a==ba && a>0) ans+=a-1;
        else ans+=a;
    }
    else ans+=min(a,b);
    cout<<ans<<endl;

return 0;
}






Measured memory_bytes: 768
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    bool ok = true;
    if (V <= W) {
        ok = false;
    } else if (abs(A - B) > T * (V - W)) {
    // } else if (abs(A - B) % (V - W) != 0 || abs(A - B) / (V - W) > T) {
        ok = false;
    }

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

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

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; }

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}


int main(){
    int N;
    cin >> N;
    bool f = false;
    if(N%10 == 7){
        f=true;
    }
    if((N/10)%10 == 7){
        f=true;
    }
    if((N/100)%10 == 7){
        f=true;
    }
    if(f){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3672
n=int(input())
a=[int(input()) for i in range(n)]
count=0
for i in range(n):
    if a[i]>1:count+=a[i]//2
    if i==n-1:continue
    if a[i]%2==1 and a[i+1]>0:
        count+=1
        a[i+1]-=1
print(count)

Measured memory_bytes: 7072
function Main(input) {
	var tmp = input.split("\n");
	var N = parseInt(tmp[0].split(" ")[0], 10);
	var L = parseInt(tmp[0].split(" ")[1], 10);
	var stringAry = [];
	for (var i = 1; i <= N; i++) {
		stringAry.push(tmp[i]);
	}
	var sortedAry = stringAry.sort();
	var ans = sortedAry.join("");
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));process.stdin.resume();

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

vector<vector<int>> v;
int pnum[100100];
int ans[100100];

void dfs(int i) {
	for(int j: v[i]) if (--pnum[j] == 0) ans[j] = i + 1;
	for(int j: v[i]) if (pnum[j] == 0) dfs(j);
}

int main() {
	int n, m;
	cin >> n >> m;
	v.resize(n);
        rep(i, n - 1 + m) {
                int s, t;
                cin >> s >> t;
                s--; t--;
                v[s].push_back(t);
		pnum[t]++;
        }
	int root;
	rep(i, n) if (pnum[i] == 0) root = i;
	dfs(root);
	rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 10240
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll int n;
	cin>>n;
	ll int a[n];
	rep(i,n)cin>>a[i];
	ll int c=0;
	sort(a,a+n);
	if(n%2){cout<<0;return;}
	ll int x=a[n/2-1];
	ll int y=a[n/2];
	cout<<y-x;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<int> a(3), b(3);
	rep(i,3) cin >> a[i];
	rep(i,3) cin >> b[i];
	rep(_,2){
		vector<ll> dp(n+1);
		rep(i,3){
			rep(j,n-a[i]+1) chmax(dp[j+a[i]], dp[j]+b[i]);
		}
		ll mx = 0;
		rep(i,n+1) chmax(mx, n-i+dp[i]);
		n = mx;
		swap(a, b);
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 195584
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

class Main{
    private String[] S;
    private String[] T;

    int count = 0;
    public void run(){
        int seqCount = 0;
        List<String> existStringList = new ArrayList<>();
        parseInput().stream()
            .forEach(n -> resultPrint(n, count));
        for(int i = 0; i < S.length;i++){
            for(int j = 0;j < T.length; j++){
                if(Objects.equals(S[i],T[j]) && !existStringList.contains(T[j])){
                    seqCount++;
                    existStringList.add(T[j]);
                }
            }
        }
        System.out.println(seqCount);
    }
    public void resultPrint(String str, int count){
        if(count == 1)
            S = str.split(" ");
        else if(count == 3)
            T = str.split(" ");
        this.count++;
    }

    public List<String> parseInput(){
        return new BufferedReader(new InputStreamReader(System.in)).lines()
            .filter(n -> !Objects.equals(n, ""))
            .collect(Collectors.toList());
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 32120
class Bit # Binary Indexed Tree
  def initialize n
    @n = n
    @bit = Array.new n+1, 0
  end
  attr_reader :bit

  def sum i
    s = 0
    while i > 0
      s += @bit[i]
      i -= i & (-i)
    end
    return s
  end

  def add i, x
    i += 1
    while i <= @n
      @bit[i] += x
      i += i & (-i)
    end
  end
end

lambda {
  n,k = *readline.split(/\s+/).map(&:to_i)
  a = [0] + readlines.map{|v| v.to_i - k}

  acc = a.inject([]){|r,v| r << (v + (r.last || 0))}
  acc_sort = acc.sort
  acc_reg = acc.map{|v| acc_sort.bsearch_index{|x| x >= v}}
  # p acc
  # p acc_sort
  # p acc_reg

  bit = Bit.new n+1
  count = 0
  acc_reg.each do |i|
    count += bit.sum(i+1)
    bit.add i, 1
  end
  puts count
}.call


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int g[][] = new int[n][n];
		int inf = Integer.MAX_VALUE/2;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++) {
			if(i==j)g[i][j]=0;
			else g[i][j] = inf;
		}
		
		
		for(int i=0;i<m;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1, c = fs.nextInt();
			g[a][b] = g[b][a] = c;
		}
		int memo[][] = new int[n][n];
		for(int i=0;i<n;i++)for(int j=0;j<n;j++) {
			memo[i][j] = g[i][j];
		}
			
		for(int k=0;k<n;k++) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					g[i][j] = Math.min(g[i][j], g[i][k]+g[k][j]);
				}
			}
		}
		int cnt = 0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				if(memo[i][j]==inf)continue;
				if(memo[i][j]!=g[i][j])cnt++;
			}
		}
		System.out.println(cnt/2);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

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

    int N;
    cin >> N;

    int minn = N + 1, ans = 0;

    while(N--)
    {
        int x;
        cin >> x;

        if(x < minn)
            ans++;
        
        minn = min(minn, x);
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		scanner.nextLine();
		String string = scanner.nextLine();
		LinkedList<Character> list = new LinkedList<>();
		LinkedList<Character> stack = new LinkedList<>();
		for(int i = 0; i < n; i ++) {
			char c = string.charAt(i);
			list.addLast(c);
			if(c == '(') {
				stack.addLast('(');				
			} else {
				if(stack.isEmpty()) {
					list.addFirst('(');
				} else {
					stack.removeLast();
				}
			}
		}
		while(!stack.isEmpty()) {
			stack.removeLast();
			list.addLast(')');
		}
		StringBuilder stringBuilder = new StringBuilder();
		for(char c: list) {
			stringBuilder.append(c);
		}
		
		System.out.println(stringBuilder);
		scanner.close();
	}
}

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

int main() {
    int a,b,k;
    cin >> k >> a >> b;
    int flag = 0;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            flag = 1;
        }
    }
    if(flag == 1){
        cout << "OK";
    } else {
        cout << "NG";
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int[] a= new int[26];
        int sum=0;
        for(int i=0; i<s.length(); i++) {
        	a[s.charAt(i)-'a']++;
        }
        for(int i=0; i<26; i++) {
        	sum+=a[i]%2;
        }//各文字2ずつ入ってれば良いから1つしかない文字をカウント
        System.out.println(sum/2);//cpcみたいなの以外は各文字2つになるようにする。
	}
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define display(v) for (auto x : v) cout << x << ", "
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define ceel(x, y) ((x) / (y) + !((x) % (y) == 0))
#define ss second
#define ff first
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
 
// DEBUG TEMPLATE by livw
void __print(int x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifdef INCLUDEWHENOFFLINE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    fastio;
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
        ans += !(s[i] == t[i]);
    cout << ans;

    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes"<<endl;}
  else if(a==c&&b!=c){
    cout<<"Yes"<<endl;}
  else if(b==c&&a!=c){
    cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
int n;
double v[60],ans;
int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    sort(v+1,v+1+n);

    ans = (v[1] + v[2])/2;
    for(int i=3;i<=n;i++){
        ans = (ans + v[i])/2;
    }
    cout<<fixed<<setprecision(10)<<ans<<newl;



}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

struct Move{
    int x1,y1,x2,y2;
};

void Main()
{
    int h,w;cin>>h>>w;
    VVI a(h);
    REP(i,h){
        a[i].resize(w);
        REP(j,w){
            cin>>a[i][j];
        }
    }
    VVI b = a;
    int result = 0;
    vector<Move> result_move;

    REP(i,h-1){
        REP(j,w){
            if(a[i][j]%2 == 1){
                result++;
                a[i][j]--;
                a[i+1][j]++;
                result_move.PB((Move){i+1,j+1,i+2,j+1});
            }
        }
    }
    REP(j,w-1){
        if(a[h-1][j]%2 == 1){
            result++;
            a[h-1][j]--;
            a[h-1][j+1]++;
            result_move.PB((Move){h,j+1,h,j+2});
        }
    }

    cout<<result<<endl;
    REP(i,result){
        cout<<result_move[i].x1<<" "<<result_move[i].y1<<" "<<result_move[i].x2<<" "<<result_move[i].y2<<endl;
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static HashMap<String,Boolean> map;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String in = sc.nextLine();
			String[] a = in.split(" ");
			int n = Integer.parseInt(a[0]);
			int m = Integer.parseInt(a[1]);
			int[] C = new int[n];
			int[] V = new int[n];
			int[] D = new int[n];
			int[] L = new int[n];
			for(int i = 0; i < n; i++) {
				in = sc.nextLine();
				in = sc.nextLine();
				a = in.split(" ");
				C[i] = Integer.parseInt(a[0]);
				V[i] = Integer.parseInt(a[1]);
				D[i] = Integer.parseInt(a[2]);
				L[i] = Integer.parseInt(a[3]);
			}
			int MAX = 0;
			int[][] dp = new int[m+1][3];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j <= m; j++) {
					for(int k = 0; ; k++) {
						if(j + C[i] * k > m) break;
						dp[j + C[i] * k][0] = Math.max(dp[j + C[i] * k][0], dp[j][0] + V[i] * k);
						dp[j + C[i] * k][1] = Math.max(dp[j + C[i] * k][1], dp[j][1] + D[i] * k);
						dp[j + C[i] * k][2] = Math.max(dp[j + C[i] * k][2], dp[j][2] + L[i] * k);
					}
				}
			}
			for(int i = 0; i <= m; i++) {
				MAX = Math.max(dp[i][0], MAX);
				MAX = Math.max(dp[i][1], MAX);
				MAX = Math.max(dp[i][2], MAX);
			}
			System.out.println(MAX);
			
			
			
			
		}
		
	}
 }

Measured memory_bytes: 168576
#include<stdio.h>
#include<math.h>
int main()
{
  long long int  i,n,d,c=0;

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

  for(i=0;i<n;i++)
  {
      double j;
   long long int p,q;
     scanf("%lld%lld",&p,&q);
     j=sqrt((p*p)+(q*q));
     if(j<=d)
     {
         c++;
     }
  }
printf("%lld\n",c);
return 0;
}



Measured memory_bytes: 2152
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> x(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        x[i]=a[i];
    }
    sort(x.begin(),x.end());
    ll l=x[n/2-1];
    ll r=x[n/2];
    vector<ll> ans(n);
    for(ll i=0;i<n;i++){
        if(a[i]<=l){
            ans[i]=r;
        }else{
            ans[i]=l;
        }
    }
    for(ll i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ms=998244353;
ll ans=0,inv[1000005],fac[1000005];
ll C(ll n,ll k){
	return fac[n]*inv[k]%ms*inv[n-k]%ms;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if (n<m) swap(n,m);
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for (int i=2;i<=n+m;i++){
		inv[i]=(ll)(ms-ms/i)*inv[ms%i]%ms; fac[i]=fac[i-1]*i%ms;
	}
	for (int i=2;i<=n+m;i++)
	inv[i]=inv[i]*inv[i-1]%ms;
	for (int i=1;i<=m;i++){
		ll p=inv[2]*C(2*i,i)%ms*C(n+m-2*i,n-i)%ms;
	    ans=(ans+p)%ms;
	}
	ans=ans*fac[n]%ms*fac[m]%ms*inv[n+m]%ms;
	ans=(ans+n)%ms;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,t,sum=0,en=-1,last;
    cin>>n>>t;
    while(n--)
    {
        ll a;
        cin>>a;
        if(a>en)
        {
            sum+=t;
            en=a+t;
            last=a;
        }
        else{
            sum+=(a-last);
            en=a+t;
            last=a;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a^b^c) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;

#define LL long long
inline LL read() {
	LL x=0,f=1; char ch=getchar();
	while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
#define MAXN 100010

int a[MAXN],num[MAXN];
int main() {
	int N=read(),sum=0,mx=0;
	for (int i=1; i<=N; i++) a[i]=read(),sum+=a[i],num[a[i]]++,mx=max(mx,a[i]);
	sort(a+1,a+N+1);
	int ans=N;
	for (int i=1; i<=mx; i++) {
		if (num[i]>1 && num[i]%2==1)
			ans-=num[i],ans++,num[i]=1;
		else {
			if (num[i]>2 && num[i]%2==0) {
				ans-=num[i],ans+=2,num[i]=2;
			}
		}
	}
	int p=0;
	for (int i=1; i<=mx; i++) {
		if (num[i]==2) p++;
	}
	
	if (p==0) printf("%d\n",ans);
	else {
		if (p%2==1) ans=ans-p-1;
		else ans=ans-p;	
		ans=max(ans,1);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int K;
  cin>>K;
  int N;
  cin>>N;
  int mama = 0;
  int susum = 0;
  int a[N];
  cin>>a[0];
  for(int i = 1;i<N;i++){
    cin>>a[i];
    susum += a[i];
    mama = max(mama,a[i]-a[i-1]);
  }
  mama = max(mama,K+a[0]-a[N-1]);
  cout << K-mama << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from collections import deque
#======================================================#
def main():
    h, w = MII()
    ch, cw = MII()
    dh, dw = MII()
    maze = [IS() for _ in range(h)]
    dq = deque([(ch-1, cw-1)])
    check = [[-1]*w for i in range(h)]
    check[ch-1][cw-1] = 0
    count = 0

    # 判定式
    inMaze = lambda x,y: 0 <= y < h and 0 <= x < w
    isWall = lambda x,y: maze[y][x] == '#'
    isChecked = lambda x,y: check[y][x] != -1
    allCheck = lambda x,y: (not inMaze(x,y)) or isWall(x,y) or isChecked(x,y)

    # 移動先
    walk = [(0,1), (0,-1), (1,0), (-1,0)]
    warp = [(dy, dx) for dy in range(-2,3) for dx in range(-2,3)]

    while True:
        tmp = []
        while dq:
            y, x = dq.popleft()
            tmp.append((y, x))
            for dy, dx in walk:
                ny = y+dy
                nx = x+dx
                if allCheck(nx, ny):
                    continue
                check[ny][nx] = count
                dq.appendleft((ny, nx))

        count += 1
        for y, x in tmp:
            for dy, dx in warp:
                ny = y+dy
                nx = x+dx
                if allCheck(nx, ny):
                    continue
                check[ny][nx] = count
                dq.append((ny, nx))
        if not dq:
            break

    print(check[dh-1][dw-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 89144
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=200000+10;
int h[maxn],go[maxn*4],nxt[maxn*4],co[maxn*4],e[maxn][2];
int dfn[maxn],low[maxn],dep[maxn],d[maxn],dl[maxn],fa[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,x,y,tot,top,ans,head,tail;
void add(int x,int y,int z){
    go[++tot]=y;
    co[tot]=z;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x,int y){
    fa[x]=y;
    dfn[x]=++top;
    int t=h[x];
    while (t){
        if (co[t]&&go[t]!=y){
            dep[go[t]]=dep[x]+1;
            dfs(go[t],x);
        }
        t=nxt[t];
    }
    low[x]=++top;
}
bool check(int x,int y){
    if (dfn[x]>dfn[y]) swap(x,y);
    if (dfn[x]<=dfn[y]&&low[x]>=low[y]) return dep[y]-dep[x]>2;
    if (fa[x]==fa[y]) return 0;else return 1;
}
void bfs(){
    int now,t;
    pd[x]=1;
    dl[tail=1]=x;
    while (head<tail){
        now=dl[++head];
        t=h[now];
        while (t){
            if (!co[t]&&!pd[go[t]]){
                d[go[t]]=d[now]+1;
                if (d[go[t]]<dep[go[t]]){
                    pd[go[t]]=1;
                    dl[++tail]=go[t];
                }
            }
            t=nxt[t];
        }
    }
}
int main(){
    scanf("%d%d%d",&n,&x,&y);
    fo(i,1,n-1){
        scanf("%d%d",&j,&k);
        //add(j,k,0);add(k,j,0);
        e[i][0]=j;e[i][1]=k;
    }
    fo(i,1,n-1){
        scanf("%d%d",&j,&k);
        add(j,k,1);add(k,j,1);
    }
    dfs(y,0);
    fo(i,1,n-1){
        j=e[i][0];k=e[i][1];
        if (check(j,k)) bz[j]=bz[k]=1;
        else{
            
        }add(j,k,0);
            add(k,j,0);
    }
    bfs();
    fo(i,1,n){
        if (pd[i]&&bz[i]){
            printf("-1\n");
            return 0;
        }
        else if (pd[i]) ans=max(ans,dep[i]*2);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 24960
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		StringBuffer str=new StringBuffer(sc.nextLine()),
					 ansstr=new StringBuffer();
		for(int i=0;i<str.length();i++)
		{
			if(i%2==0)
			{
				ansstr.append(str.charAt(i));
			}	
		}
		System.out.println(ansstr);
	}
}

Measured memory_bytes: 23744
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll A,B,N;
        cin>>A>>B>>N;
        cout<<A*(min(B-1,N))/B;





    }



    return 0;
}

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

int main(){
  double A,B,H,M;
  double dH,dM,dx,dy,pi;
  cin >> A >> B >> H >> M;
  pi = acos(-1);
  dM = 2 * pi * M / 60;
  dH = 2 * pi * (H+M/60) / 12;
  dx = A*cos(dH)-B*cos(dM);
  dy = A*sin(dH)-B*sin(dM);
  
  cout << fixed << setprecision(20) << sqrt(dx*dx+dy*dy) << endl;

  return 0;
}

Measured memory_bytes: 4132
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int res[100000];
 
int main(){
 
    int n,m,temp;
    cin >> n >> m;
    int num[m];
    for(int i=0;i<m;i++){
    cin >> temp;
    num[i] = temp;
    res[temp] = 1;
    }
    bool flag=true;
    while(flag){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        if(res[i] > 0 ){
            if(res[i+num[j]] == 0) res[i+num[j]] = res[i]+1;
            else{res[i+num[j]] = min(res[i+num[j]],res[i]+1);
            if(i+num[j] == n) flag = false;
            }
        }
        }
    }
    }
     
    cout << res[n]<< endl;
 
    return 0;
}

Measured memory_bytes: 1396
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
import math
from functools import reduce

def li():
    return [int(x) for x in input().split()]

N = int(input())
a = li()
cnt = 0
for k in range(N):
    i = k + 1
    if i % 2 == 1 and a[k] % 2 == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 67520
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
    int n, a[105];
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    ll ans = LLINF;
    for (int i = -100; i <= 100; i++) {
        ll t = 0;
        for (int j = 0; j < n; j++) {
            t += (i - a[j])*(i - a[j]);
        }
        if (ans > t)ans = t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define MAX_A 1'000'001
int N;
vector<int> A, C(MAX_A, 0);

string solve(){
	for(int a:A) C[a]++;
	bool pairwise = true;
	int c = 0;
	for(int j=2; j<MAX_A; j+=2) c += C[j];
	if(c > 1) pairwise = false;
	for(int i=3; i<MAX_A; i+=2){
		int c = 0;
		for(int j=i; j<MAX_A; j+=i) c += C[j];
		if(c > 1) pairwise = false;
	}
	if(pairwise) return "pairwise";
	int g = 0;
	for(int a:A) g = gcd(g, a);
	if(g == 1) return "setwise";
	return "not";
}

int main(){
	cin>>N;
	A.resize(N); for(int i=0; i<N; ++i) cin>>A[i];
	cout<< solve() <<" coprime\n";
}


Measured memory_bytes: 11164
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    switch(a){
        case 5 : 
                if( (b == 7 && c ==5) || (b == 5 && c == 7) ){
                    printf("YES\n");
                }else{
                    printf("NO\n");
                }
                break;
        case 7 : 
                if(b == 5 && c == 5){
                    printf("YES\n");
                }else{
                    printf("NO\n");
                }
                break;
        default:  
                printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
/**
 * Source: https://codeforces.com/blog/entry/79438
 */

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int main() {
    int n;
    scanf("%d", &n);
    ll a[n], sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        sum ^= a[i];
    }
    sum ^= a[0] ^ a[1];
    ll total = a[0] + a[1];
    ll dp[2];
    dp[0] = -1e15, dp[1] = 0;
    for (int bit = 44; bit >= 0; bit--) {
        if (sum & (1ll << bit)) {
            dp[0] += (1ll << bit);
            if (a[0] & (1ll << bit)) {
                ckmax(dp[0], dp[1]);
                dp[1] += (1ll << bit);
            }
            total -= (1ll << bit);
        } else if (total >= (1ll << (bit + 1))) {
            if (!(a[0] & (1ll << bit))) {
                dp[1] = -1e15;
            }
            dp[0] += (1ll << bit);
            dp[1] += (1ll << bit);
            total -= 1ll << (bit + 1);
        } else if (a[0] & (1ll << bit)) {
            ckmax(dp[0], dp[1]);
        }
    }
    if (total == 0 && (dp[0] > 0 || dp[1] > 0))
        printf("%lld\n", a[0] - max(dp[0], dp[1]));
    else
        printf("-1\n");
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 1000000000001
using namespace std;

int main() {
  ull n, p;
  cin >> n >> p;
  ull max=1,i=2, x;
  if(n == 1) {
    cout << p << endl;
    return 0;
  }
  while((x=pow(i,n)) && (x<=p) ) {
    if(p % x == 0 ){
      max=i;
    }
    i++;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll x[n + 1], y[n + 1], h[n + 1];
	for(int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> h[i];
	}
	for(int i = 0; i <= 100; i++)
	{
		for(int j = 0; j <= 100; j++)
		{
			for(int k = 0; k < n; k++)
			{
				bool flag = true;
				ll H = h[k] + abs(x[k] - i) + abs(y[k] - j);
				for(int l = 0; l < n; l++)
				{
					ll tmp = H - abs(x[l] - i) - abs(y[l] - j);
					if(tmp < 0)
						tmp = 0;
					if(tmp != h[l])
						flag = false;
				}
				if(flag)
				{
					cout << i << " " << j << " " << H << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,m;
    cin>>n>>m;
	ll a[n];
	vector<pll> vec(m);
	rep(i,0,n)cin>>a[i];
	rep(i,0,m){
		cin>>vec[i].se>>vec[i].fi;
	}
	sort(a,a+n);
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	int k=0;
	rep(i,0,m){
		int j=0;
		for(;j<vec[i].se;j++){
			if(k==n||a[k]>=vec[i].fi)break;
			a[k]=vec[i].fi;
			k++;
		}
		if(j==0)break;
	}
	ll sum=0;
	rep(i,0,n)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 5560
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

long long dis(long long a, long long b) {
    if ((a > 0 && b > 0) || (a < 0 && b < 0))return max(abs(a), abs(b));
    else return abs(a - b) + min(abs(a), abs(b));
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long>x(N);
    for (int i = 0; i < N; i++)cin >> x[i];

    long long ans = 1e20;
    for (int i = 0; i <= N-K; i++) {
        ans = min(ans, dis(x[i], x[i + K - 1]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "cstdio"
int abs(int x,int y){
	int s=x-y;
	if(s<0)return -s;
	else return s;
}
struct stu{
	int ai,bi;
};stu a[100],b[100];
int minn=1000000000,n,m,i,j,k;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	scanf("%d%d",&a[i].ai,&a[i].bi);
	for(i=1;i<=m;i++)
	scanf("%d%d",&b[i].ai,&b[i].bi);
	for(i=1;i<=n;i++){
	    for(j=1;j<=m;j++){
		    if(minn>(abs(a[i].ai,b[j].ai)+abs(a[i].bi,b[j].bi)))minn=(abs(a[i].ai,b[j].ai)+abs(a[i].bi,b[j].bi)),k=j;
	    }
	    printf("%d\n",k),minn=1000000000;
	}
}

Measured memory_bytes: 128