akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i, m, tail = 0, cnt = 0;
	cin >> m >> m;
	vector<pair<int, int>> r(m);
	for (i = 0; i < m; i++) cin >> r[i].second >> r[i].first;
	sort(full(r));
	for (i = 0; i < m; i++) {
		if (tail <= r[i].second) {
			cnt++;
			tail = r[i].first;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;



int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    int cnt = 0;
    int a, b, c, d;
    for(int i = 1; i <= N; ++i){
        a = i / 1000;
        b = (i % 1000) / 100;
        c = (i % 100) / 10;
        d = i % 10;
        
        if(i == 10000){
            if(A == 1){
                cnt += 10000;
            }
        } else {
            if(a + b + c + d >= A && a + b + c + d <= B){
                cnt += i;
            }
        }
        
    }
    

    cout << cnt << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
//#define first F
//#define second S
P r[105],an[105];
int main(void){
    int n,a;cin>>n;string s;
    for(int i=0;i<n;i++){
        cin>>s>>a;
        r[i]=P(s,a);
        an[i]=P(s,a);
    }
    sort(r,r+n);
    //for(int i=0;i<n;i++)cout<<r[i].first<<" "<<r[i].second<<endl;
    for(int i=0;i<n;i++){
        int c=0;
        while(r[i+c].first==r[i].first)c++;
        //cout<<"#"<<c<<endl;
        for(int j=i+c-1;j>=i;j--){
            int h=0,cV=0;
            while(1){
                if(r[j].first==an[h].first&&r[j].second==an[h].second){
                    if(cV==0){cout<<h+1<<endl;break;}
                    else cV++;
                }
                h++;
            }
        }
        i+=c-1;
    }
    
    return 0;
}


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

dp = [[0] * (N) for _ in range(N+1)]
ans = int(0)
for i in range(N):
    dp[i][i] = a[i]

#for l in range(1,N)
for l in range(1,N):
    for i in range(N-l):
        j = i + l
        dp[i][j] = max(dp[i][i]-dp[i+1][j], dp[j][j]-dp[i][j-1])


ans = dp[0][N-1]

print(ans)
#print(dp)

Measured memory_bytes: 112604
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 18)

struct edge {
	int v1, v2;
	ll w;

	edge(int tv1 = 0, int tv2 = 0, ll tw = 0) {
		v1 = tv1;
		v2 = tv2;
		w = tw;
	}

	bool operator<(const edge & e) const {
		return w < e.w;
	}
	
	void read() {
		cin >> v1 >> v2 >> w;
		v1--;
		v2--;
	}
};

edge e[MAXN];
ll x[MAXN];
int n, m;

int p[MAXN];
ll sumv[MAXN];
ll maxw[MAXN];
int id[MAXN];
bool ok[MAXN];

int idcnt;
vector<int> t[MAXN];
int v[MAXN];

int find(int v) {
	if (v == p[v]) {
		return v;	
	}
	int ret = find(p[v]);
	p[v] = ret;
	return ret;
}


void merge(int v1, int v2, ll w) {
	v1 = find(v1);
	v2 = find(v2);
	//cerr << v1 << " " << v2 << " " << id[v1] << " " << id[v2] << endl;
	if (v1 != v2) {
		p[v2] = v1;
		sumv[v1] += sumv[v2];
		maxw[v1] = max(maxw[v1], maxw[v2]);
		t[idcnt].push_back(id[v1]);
		t[idcnt].push_back(id[v2]);
	} else {
		t[idcnt].push_back(id[v1]);
	}
	maxw[v1] = max(maxw[v1], w);
	id[v1] = idcnt;	
	ok[idcnt] = (maxw[v1] <= sumv[v1]);
	idcnt++;
}

int ret = 0;

void dfs(int cur) {
	v[cur] = 1;
//	cerr << cur << endl;
	if (ok[cur]) {
		return;
	}
	ret++;
	for (auto& nnext : t[cur]) {
		if (!v[nnext]) {
			dfs(nnext);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		p[i] = i;
		sumv[i] = x[i];
		maxw[i] = 0;
		id[i] = i;
		ok[i] = true;
	}
	idcnt = n;
	for (int i = 0; i < m; i++) {
		e[i].read();
	}
	sort(e, e + m);
	for (int i = 0; i < m; i++) {
		merge(e[i].v1, e[i].v2, e[i].w);
	}
	dfs(idcnt - 1);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 23996
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
ll a,b,n,s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(a),sc(b),sc(n);
    n=min(n,b-1);
    s=a*n/b-a*(n/b);
    printf("%lld\n",s);
    return 0;
}

Measured memory_bytes: 3848
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	int X;
	cin >> X;
	int num = X % 100;
	int m = X /= 100;
	if (m * 5 >= num) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 1000002
#define ll long long
const ll INF = 1e18+7;

string s;
ll num[MAX], sum[MAX], dp[MAX][2];

int main()
{
	cin >> s;
	s = '0' + s;
	int len = s.length();
	for (int i=0; i<len; ++i) {
		num[i] = s[i] - '0';
		sum[i+1] = sum[i] + num[i];
	}

	for (int i=0; i<=len; ++i)
		for (int j=0; j<2; ++j)
			dp[i][j] = INF;

	dp[0][0] = 0;
	for (int i=0; i<len; ++i) {
		dp[i+1][0] = min(dp[i+1][0], dp[i][0] + num[i]);
		dp[i+1][1] = min(dp[i+1][1], dp[i][0] + num[i] + 1);
		dp[i+1][0] = min(dp[i+1][0], dp[i][1] - num[i] + 10);
		dp[i+1][1] = min(dp[i+1][1], dp[i][1] - num[i] + 9);
	}
	cout << dp[len][0] << '\n';

	return 0;
}

Measured memory_bytes: 32560
<?php

$ks = explode(' ',fgets(STDIN));
$k = $ks[0];
$s = $ks[1];

$count = 0;
for($i=0; $i<=$k; $i++){
  for($j=0;$j<=$k; $j++){
    $l = $s-$i-$j;
    if (0<=$l && $l<=$k) $count++;
  }
}

echo $count;

?>

Measured memory_bytes: 4728
class Array
  def cumsum; s = 0; map{|k| s += k } end
  def mod(m); map{|k|k%m} end
end

n,k = gets.split.map(&:to_i)
a   = [0] + gets.split.map{ |k| k.to_i - 1 }

c = a.cumsum.mod(k)

ans = 0
h = Hash.new(0)

(n+1).times do |i|
  h[c[i-k]] -= 1 if i >= k
  ans += h[c[i]]
  h[c[i]] += 1
end

puts ans

Measured memory_bytes: 31628
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int h,w,cnt=0,i,j,a[101][101];
	char b[101][101];
	memset( a ,-1 ,sizeof a ) ;
	
	cin >> h >> w ;
	fo(i,h){
		cin >> b[i] ;
		fo(j,w){
			if(b[i][j] == 'c'){
				a[i][j] = 0;
				cnt = 1;
			}
			else if(cnt >= 1){
				a[i][j] = cnt ;
				cnt++;
			}
		}
		cnt = 0;
	}
	fo(i,h){
		fo(j,w){
			cout << a[i][j] ;
			if(j == w - 1) break;
			cout << " " ;
		}
		cout << "\n" ;
	}
	
	return 0;
}

Measured memory_bytes: 3128
def main():
    N = int(input())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append((a, b))

    A = sorted(A, key=lambda x: x[1])
    time = 0
    for a, b in A:
        time += a
        if time > b:
            return 'No'

    return 'Yes'

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 33396
#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 1e5 + 5;

int n, u, v, dp[2][maxn];   // {white, total}
vector<int> adj[maxn];

void dfs(int x, int p)
{
    int ways[2] = {1, 1};
    for(auto v : adj[x])
        if(v != p)
        {
            dfs(v, x);
            for(int j = 0; j < 2; j++)
            {
                ways[j] *= (dp[j][v]);
                ways[j] %= MOD;
            }
        }
    dp[0][x] = ways[1] % MOD;
    dp[1][x] = ways[0] + ways[1];
    dp[1][x] %= MOD;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0, -1);
    cout << dp[1][0] << "\n";
    return 0;
}

Measured memory_bytes: 17648
N = int(input())
h = [int(x) for x in input().split()]

dp = [0] * (N + 1)

dp[0] = 0
dp[1] = abs(h[0] - h[1])

for n in range(2, N):
    dp[n] = min(dp[n - 2] + abs(h[n - 2] - h[n]), dp[n - 1] + abs(h[n - 1] - h[n]))

print(dp[N - 1])


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

class Program
{
    static int N, C;

    public static void Main(string[] args)
    {
        const int MaxT = 100000;
        N = Input.NextInt();
        C = Input.NextInt();
        var channels = new bool[C][];
        for (int i = 0; i < C; i++)
            channels[i] = new bool[MaxT];
        for (int i = 0; i < N; i++)
        { 
            var vals = Input.LineInt();
            var s = vals[0] - 1;
            var t = vals[1] - 1;
            var c = vals[2] - 1;
            for (int x = s; x <= t; x++)
            {
                channels[c][x] = true;
            }
        }

        int maxCount = 0;
        for (int t = 1; t < MaxT; t++)
        {
            int count = channels.Count(n => n[t]);
            maxCount = Math.Max(maxCount, count);
        }

        Console.WriteLine(maxCount);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 20432
s=input()
a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
if a+b+c+d==7:
    print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a+b+c-d==7:
    print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a+b-c+d==7:
    print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a-b+c+d==7:
    print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a+b-c-d==7:
    print("{}+{}-{}-{}=7".format(a,b,c,d))
elif a-b+c-d==7:
    print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a-b-c+d==7:
    print("{}-{}-{}+{}=7".format(a,b,c,d))
else:
    print("{}-{}-{}-{}=7".format(a,b,c,d))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
vector <vector<int>> mul(vector <vector<int>> &A, vector <vector<int>> &B){
    vector <vector<int>> C(A.size(),vector <int>(B[0].size()));
    rep(i,A.size()){
        rep(k,B.size()){
            rep(j,B[0].size()){
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    return C;
}
vector <vector<int>> identity(int e){
    vector <vector<int>> C(e,vector <int>(e));
    rep(i, e) C[i][i] = 1;
    return C;
}

vector <vector<int>> mpow(vector <vector<int>> A, int n){
    vector <vector<int>> B(A.size(),vector <int>(A.size(),1));
    while(n > 0){
        if(n & 1) B = mul(B,A);
        A = mul(A,A);
        n >>= 1;
        return B;
    }
}

void show_matrix(vector <vector<int>> &A){
    for(int i=0;i<A.size();i++){
        for(int j=0;j<A[i].size();j++){
            
            if(j != A[i].size()-1) cout<<A[i][j]<<' ';
            else cout<<A[i][j];
        }
        cout<<endl;
    }
}

signed main(void){
    int n,m,l; cin>>n>>m>>l;
    vector <vector<int>> A(n,vector <int>(m));
    vector <vector<int>> B(m,vector <int>(l));
    rep(i,n) rep(j,m) cin>>A[i][j];
    rep(j,m) rep(k,l) cin>>B[j][k];
    vector <vector<int>> ans = mul(A,B);
    show_matrix(ans);
}



Measured memory_bytes: 3180
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    cout << a / b << " "<< a%b << " " << fixed << setprecision(5) << (double)a /(double)b << endl;
    
    

    return 0;
}



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

#define rep(inc, bgn, end) for(int inc=bgn; inc<(end); ++inc)

int main(){
    int n, m;
    int a[50] = {0};

    cin >> n >> m;

    rep(i, 0, m){
        int inp, oup;
        cin >> inp >> oup;

        a[inp-1] ++;
        a[oup-1] ++;
    }

    rep(i, 0, n){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
func readThreeInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2])
}

func mainA() {
    let (N, X, T) = readThreeInts()

    let full = N / X
    let remain = N % X

    print(full * T + (remain == 0 ? 0 : T))
}
mainA()

Measured memory_bytes: 8260
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
#include <cstring>

using namespace std;

typedef long long ll;

int a[200000];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", a + i);
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        auto c = s[i];
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
            ++cnt;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << max(ans, cnt) << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
char s[N];
int dp[N];
int sum[N];
int best[1 << 26];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; ++i) {
    int k = s[i] - 'a';
    sum[i + 1] = sum[i] ^ (1 << k);
  }
  dp[n] = 0;
  for (int k = 0; k < (1 << 26); ++k) best[k] = INF;
  best[sum[n]] = 0;
  for (int i = n - 1; i >= 0; --i) {
    dp[i] = INF;
    dp[i] = min(dp[i], best[sum[i]] + 1);
    for (int k = 0; k < 26; ++k) {
      int cur = (1 << k) ^ sum[i];
      dp[i] = min(dp[i], best[cur] + 1);
    }
    best[sum[i]] = min(best[sum[i]], dp[i]);
  }
  int ret = dp[0] == INF ? -1 : dp[0];
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 264192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P > T;

int h,w;
bool finish(){
    return (h==0)&&(w==0);
}

int main(void){
    while(true){
        cin>>h>>w;
        if(finish())break;
        int ans1 = 0,ans2 = 0;
        int min_=0;
        int base = h*h+w*w;
        vector<P>p;
        for(int i=1;i<=150;i++){
            for(int j=i+1;j<=150;j++){
                if(i*i+j*j==base){
                    if(h<i)p.push_back(P(i,j));
                }
            }
        }
        if(p.size()>0){
            for(int i=0;i<(int)p.size();i++){
                if(ans1 == 0 && ans2 == 0){
                    ans1 = p[i].first;
                    ans2 = p[i].second;
                }
                else{
                    if(p[i].first<ans1){
                        ans1 = p[i].first;
                        ans2 = p[i].second;
                    }
                }
            }
            cout<<ans1<<" "<<ans2<<endl;
        }
        else{
            for(int i=1;i<=150;i++){
                for(int j=i+1;j<=150;j++){
                    if(i*i+j*j>base){
                        if(min_==0)min_=i*i+j*j;
                        else min_ = min(min_,i*i+j*j);
                    }
                }
            }
            for(int i=1;i<=150;i++){
                for(int j=i+1;j<=150;j++){
                    if(i*i+j*j==min_){
                        if(ans1 == 0 && ans2 == 0){
                            ans1 = i;
                            ans2 = j;
                        }
                        else{
                            if(i<ans1){
                                ans1 = i;
                                ans2 = j;
                            }
                        }
                    }
                }
            }
            cout<<ans1<<" "<<ans2<<endl;
        }
    }
    return 0;
}


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

#include<cstring>

int a[100000];
int cnt[100000];

int main() {
	memset(cnt, 0, sizeof(cnt));
	int n;
	cin >> n;

	int max_1 = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
		if (max_1 < a[i]) { max_1 = a[i]; }
	}

	int max_2 = 0, ans = 0;
	for (int j = 0; j <= max_1; ++j) {
		if (j == 0) {
			max_2 = cnt[j] + cnt[j + 1];
			ans = j;
		}
		else if (j == max_1) {
			int sum;
			sum = cnt[j - 1] + cnt[j];
			if (max_2 < sum) {
				ans = j;
				max_2 = sum;
			}
		}
		else {
			int sum = cnt[j - 1] + cnt[j] + cnt[j + 1];
			if (max_2 < sum) {
				ans = j;
				max_2 = sum;
			}
		}
	}

	cout << max_2 << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  char s[3];
  int sum = 0;
    scanf("%s",&s);
    for(int i = 0;i<3;i++){
      if(s[i]=='A'){
        sum = sum + 1;
      }
    }
      if(sum == 0 || sum == 3){
        printf("No");
      }
      else {
        printf("Yes");
      }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  double C;
  cin >> A;
  vector<string>W(A);
  vector<double>H(A);
  for(int i=0;i<A;i++)cin >> H[i] >> W[i];
  for(int i=0;i<A;i++){
    if(W[i]=="BTC")C+=H[i]*380000;
    else C+=H[i]*1.0;
  }
  cout << C << endl;
}


Measured memory_bytes: 256
import math
A,B,H,M=map(int,input().split())
hour = (H/6+M/360)*math.pi
minute = M/30*math.pi
radi = abs(hour-minute)
# print(radi, math.degrees(radi))
if radi > math.pi:
  ans = math.sqrt(A**2+B**2-2*A*B*math.cos(2*math.pi-radi))
else:
  ans = math.sqrt(A**2+B**2-2*A*B*math.cos(radi))
print(ans)

Measured memory_bytes: 9396
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
vector<T> bellman_ford(int s, int N,vector<edge<T> > &G){
    vector<T> dist(N, INF<T>);
    vector<bool> negative(N);
    dist[s] = 0;
    for (int i = 0; i < N - 1; ++ i) {
        for (auto &&e : G) {
            if(dist[e.from] == INF<T>) continue;
            if(dist[e.to] > dist[e.from]+ e.cost){
                dist[e.to] = dist[e.from]+ e.cost;
            }
        }
    }

    ll ans = dist[N - 1];

    for (int i = 0; i < N ; ++i) {
        for (auto &&e : G) {
            if(dist[e.from] == INF<T>) continue;
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                negative[e.to] = true;
            }
            if(negative[e.from]) negative[e.to] = true;
        }
    }
    for (int i = 0; i < N; ++i) {
        if(negative[i]) dist[i] = -INF<T>;
    }
    return dist;
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge<ll>> G;
    for (int i = 0; i < m; ++i) {
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--; c = p-c;
        G.emplace_back(a, b, c);
    }
    auto ans = bellman_ford(0, n, G);
    if(ans.back() == -INF<ll>) puts("-1");
    else {
        cout << max(0LL, -ans.back()) << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def run():
    H, W, A, B = map(int, sysread().split())
    MAP = [[0] * W for _ in range(H)]


    for i in range(H):
        for j in range(W):
            if (0 <= i <= B-1 and 0 <= j <= A-1) or (B <= i and A <= j):
                MAP[i][j] = 1


    for m in MAP:
        print(''.join([str(s) for s in m]))

if __name__ == "__main__":
    run()


Measured memory_bytes: 17020
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int n,k,x,y;
	cin >> n >> k >> x >> y;
	if (n > k) cout << k*x + (n - k)*y << endl;
	else cout << n*x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;
ll f[2200000];
ll invf[2200000];
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll nCm(ll n,ll m){
    return ((f[n]*invf[m])%mod)*invf[n-m]%mod;  
}

int main()
{
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    rep(i,2100000){
        f[i] = invf[i] = 1;
    }
    for(ll i = 1;i <= 2100000;i++){
        f[i] = (f[i-1]*i)%mod;
    }
    invf[2010000] = modpow(f[2010000],mod-2,mod);
    for(ll i = 2010000;i >= 2;i--){
        invf[i-1] = (invf[i] *i)%mod;
    }


    
    ll ans = nCm(r2+c2+2,r2+1)%mod;
    ans  = (ans - nCm(r1+c2+1,r1)+mod)%mod;
    ans  = (ans - nCm(r2+c1+1,r2+1)+mod)%mod;
    ans = (ans+nCm(r1+c1,r1))%mod;
    cout << (ans+mod)%mod << endl;
    


    return 0;
}

Measured memory_bytes: 33792
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const ll INF = numeric_limits<ll>::max();
int main() {
	int N;
	//cin >> N;
	scanf("%d", &N);
	vector<ll>v(3 * N);
	priority_queue<ll, vector<ll>,greater<ll>>p_que_big;//前半部分　大きいものを入れていく
	priority_queue <ll, vector<ll>>p_que_small;//後半部分　小さいものを入れていく
	ll l=0;
	ll r=0;
	for (int i = 0; i < 3 * N; i++) {
		scanf("%lld", &v[i]);
		if (0 <= i && i < N) {
			p_que_big.push(v[i]);
			l += v[i];
		}
		else if (2 * N <= i && i < 3 * N) {
			p_que_small.push(v[i]);
			r += v[i];
		}
	}
	vector<ll>ls(N+1, 0);
	ls[0] = l;
	int count0 = 1;
	for (int i = N; i <2 * N; i++) {
		p_que_big.push(v[i]);
		l += v[i];
		auto e = p_que_big.top();
		l -= e;
		p_que_big.pop();
		ls[count0] = l;
		count0++;
	}
	vector<ll>rs(N+1, 0);
	rs[0] = r;
	int count = 1;
	for (int i = 2 * N - 1; i >= N; i--) {
		p_que_small.push(v[i]);
		r += v[i];
		auto e = p_que_small.top();
		r -= e;
		p_que_small.pop();
		rs[count] = r;
		count++;
	}
	ll ans = -INF;
	for (int i = 0; i < N+1; i++) {
		ll res = ls[i] - rs[N - i];
		//ans = max(ans, res);
		if (ans < res) {
			ans = res;
		}
	}
	printf("%lld", ans);
}


Measured memory_bytes: 5876
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int[] a = new int[3];

        for(int i = 0;i < 3;i++){
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);


        System.out.println(a[2] -  a[0]);


    }
}

Measured memory_bytes: 21716
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
int n,m,d[100],x,y;
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d",&x,&y);
		d[x]++;
		d[y]++;
	}
	fo(i,1,n) printf("%d\n",d[i]);
	return 0;
}

Measured memory_bytes: 128
package main

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

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 100000)

	s, _, _ := reader.ReadLine()
	out(s)

	g := 0
	p := 0
	cnt := 0
	for i := 0; i < len(s); i++ {
		out(string(s[i]))
		if s[i] == 'g' {
			if g > p {
				p++
				cnt++
				out("P")
			} else {
				g++
				out("G")
			}
		} else {
			if g > p {
				p++
				out("P")
			} else {
				g++
				cnt--
				out("G")
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int,int> c;
  for(int i=0;i<n;i++){
    cin >> a[i];
    c[a[i]]++;
  }
  int ans=0;
  for(auto p:c){
    if(p.second<p.first){
      ans+=p.second;
    }
    else{
      ans+=p.second-p.first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    ll n , m ;
    cin >> n >> m ;
    vector<ll> div ; 
    for(ll i = 1; i * i <= m; i++){
        if ( m % i == 0 ){
            div.push_back(i) ; 
            if ( m / i != i ) div.push_back(m / i) ; 
        }
    }
    sort(div.begin(), div.end()) ; 
    ll t = (ll) div.size() ;
    for(ll i = t - 1; i >= 0; i--){
        ll sum = 0 ;
        for(ll j = 0; j < n; j++){
            sum += div[i] ; 
        }
        if ( sum > m ) continue ;
        else {
            if ( (m - sum) % div[i] == 0 ){
                return cout << div[i] << endl, 0 ; 
            }
        }
    }
    return 0 ;
}

Measured memory_bytes: 256
<?php
        // Input < n,m,l
        $input = preg_split('/ /', trim(fgets(STDIN)));
        $n = $input[0];
        $m = $input[1];
        $l = $input[2];

        // Input < A(n*m)
        $arrayA = array();
        for($loop_n = 0; $loop_n < $n;  $loop_n++)
        {
                $input = preg_split('/ /', trim(fgets(STDIN)));
                if($m == count($input))
                {
                        $arrayA[] = $input;
                }
                else
                {
                        $loop_n--;
                }
        }

        // Input < B(m*l)
        $arrayB = array();
        for($loop_m = 0; $loop_m < $m;  $loop_m++)
        {
                $input = preg_split('/ /', trim(fgets(STDIN)));
                if($l == count($input))
                {
                        $arrayB[] = $input;
                }
                else
                {
                        $loop_m--;
                }
        }

        // Output < C(n*l)
        for($i = 0; $i < $n; $i++)
        {
                $ans = array();
                for($j = 0; $j < $l; $j++)
                {
                        $c = 0;
                        for($k = 0; $k < $m; $k++)
                        {
                                $c = $c + $arrayA[$i][$k] * $arrayB[$k][$j];
                        }
                        $ans[] = $c;
                }
                echo implode(' ' , $ans) . "\n";
        }
?>


Measured memory_bytes: 12812
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();

        int[][] a = new int[h][w];
        for(int i = 0; i < h; i++){
            String s = sc.next();
            for(int j = 0; j < w; j++){
                if(s.charAt(j) == '.') a[i][j] = 0;
                else a[i][j] = 1;
            }
        }
        for(int i = 0;  i < h; i++){
            int tmp = 0;
            for(int j = 0; j < w; j++){
                tmp += a[i][j];
            }
            if(tmp == 0){
                for(int k = i; k < h-1; k++){
                    for(int j = 0; j < w; j++){
                        a[k][j] = a[k+1][j];
                    }
                }
                h--;
                i--;
            }
        }
        for(int j = 0; j < w; j++){
            int tmp = 0;
            for(int i = 0; i < h; i++){
                tmp += a[i][j];
            }
            if(tmp == 0){
                for(int k = j; k < w-1; k++){
                    for(int i = 0; i < h; i++){
                        a[i][k] = a[i][k+1];
                    }
                }
                w--;
                j--;
            }
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(a[i][j] == 0)
                    System.out.print(".");
                else
                    System.out.print("#");
            }
            System.out.print("\n");
        }
    }
 }


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

using namespace std;

int main(){
    int n, b, f, r, v;
    int apart[4][3][10]={
    {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
    {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
    {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}
    };
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> b >> f >> r >> v;
      apart[b-1][f-1][r-1] += v;
    }
    for(int i=0;i<4;i++){
      for(int y=0;y<3;y++){
        for(int j=0;j<10;j++){
          cout << " " << apart[i][y][j];
        }
        cout << endl;
      }
      if(i!=3) cout<<"####################"<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){
        string str;
        cin>>str;
        string res;
        for(int i=0;i<19;i++){
                if(str[i]==','){
                        res+=' ';
                }
                else{
                        res+=str[i];
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
int a[224514];
int cnt[224514];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	rep(i, n)cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		int memo = 0;
		for (int j = i; j < n; j += (i + 1))memo += cnt[j];
		cnt[i] = (a[i] - memo + 2) % 2;
	}
	int m = 0;
	rep(i, n) {
		if (cnt[i])m++;
	}
	cout << m << endl;
	rep(i, n) {
		if (cnt[i])cout << i + 1 << " ";
	}
	ggr
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();

    for (ll i = n-m; i >= 0; i--) {
        string u = s.substr(i, m);
        bool ok = true;
        for (ll j = 0; j < m; j++) {
            if (u[j] != '?' && u[j] != t[j]) ok = false;
        }
        if (ok) {
            for (ll k = 0; k < n; k++) {
                if (i <= k && k <= i+m-1) cout << t[k-i];
                else if (s[k] == '?') cout << 'a';
                else cout << s[k];
            }
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
int cnt=0;
for(int i=1;i<=n;i++)
{
	int x;
	cin>>x;
	if(i&1)
	{
		if(x&1)
		cnt++;
	}
}
cout<<cnt;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}



Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10000)
k = [-1,0,1]
def search(x,y,m):
    if x<0 or x>=len(m[0]) or y<0 or y>=len(m): return
    if m[y][x]==0: return
    m[y][x] = 0
    for i in k:
        for j in k:
            search(x+i,y+j,m)

while True:
    c = 0
    w,h = map(int,input().split())
    if w==0: break
    m = [list(map(int,input().split())) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if m[i][j]==1:
                search(j, i, m)
                c += 1
    print(c)

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == s.at(i+1)) {
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good"; 
}

Measured memory_bytes: 256
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
for i in range(N):
    if i == 0:
        cnt = x[i][0]
        sum = x[i][1] + x[i][2]
    else:
        cnt = x[i][0] - x[i-1][0]
        sum = abs(x[i][1]-x[i-1][1]) + abs(x[i][2]-x[i-1][2])
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27300
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k%2==0){
        cout << a - b << endl;
    }
    else
        cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s,cnt[20];

ll check(ll x){
  ll y=x,c=0,z=9;
  while(y)y/=10,c++;
  for(int i=0;i<c-2;i++)z=z*10+9;
  ll sum=x-(x/3+x/5-x/15);
  if(x>=10)sum=(sum-(z-(z/3+z/5-z/15)))*c+cnt[c-1];
  sum+=(x/3-x/15)*4+(x/5-x/15)*4+x/15*8;
  return sum;
}

string lltos(ll x){
  string res;
  while(x)res+=x%10+'0',x/=10;
  reverse(res.begin(),res.end());
  return res;
}

string cal(ll x){
  string res;
  ll cp=x;
  for(ll i=0;i<20;i++){
    if(!(x%15))res+="FizzBuzz";
    else if(!(x%3))res+="Fizz";
    else if(!(x%5))res+="Buzz";
    else res+=lltos(x);
    x++;
  }
  x=cp;
  if(x==1)return res.substr(0,20);
  ll r=check(x-1);
  return res.substr(s-r-1,20);
}

string bynary_search(){
  ll l=1,r=(1e18);
  r+=25;
  while(l<r){
    ll m=(l+r)/2;
    if(check(m)>=s)r=m;
    else l=m+1;
  }
  return cal(l);
}

void init(){
  ll x=9,idx=1;
  while(1){
    cnt[idx]=x-(x/3+x/5-x/15);
    if(idx>1)
      cnt[idx]=(cnt[idx]-(x/10-((x/10)/3+(x/10)/5-(x/10)/15)))*idx+cnt[idx-1];
    idx++;
    if(idx==19)break;
    x=x*10+9;
  }
}

int main(){
  cin>>s;
  init();
  cout<<bynary_search()<<endl;
  return 0;
}

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

using namespace std ;

int a[ 100001 ] , n , k , dp[ 100001 ] ;

void solve( int i )
{
    if( i <= 1 )
        return ;

    if( dp[ i ] != -1 )
        return ;

    int ans = 1e9 ;
     for( int j = 1 ; j <= k ; j++ )
        if( i - j >= 1 )
        {
            solve( i - j ) ;
            ans = min( dp[ i - j ] + abs( a[ i ] - a[ i - j ] ) , ans ) ;
        }
    dp[ i ] = ans ;

}
int main()
{
    cin >> n >> k ;

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

    dp[ 1 ] = 0 ;
    dp[ 2 ] = abs( a[ 1 ] - a[ 2 ] ) ;

    solve( n ) ;
    cout << dp[ n ] << endl ;
}



Measured memory_bytes: 12212
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	int h,n;
	cin>>h>>n;
	int k;
	for (int i = 0; i<n; i++){
		cin>>k;
		h-=k;
	}
	if (h > 0){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 3596
N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10**9
dp = [INF] * N
dp[0] = 0
for i in range(N):
    for k in range(1, K+1):
        if i + k < N:
            dp[i+k] = min(dp[i+k], dp[i]+abs(h[i] - h[i+k]))
        else:
            break
print(dp[N-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vecInt = vector<int>;
using vecLong = vector<long long>;
#define rep(i,l,n) for(int i=l;i<n;i++)

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;
const ll lINF = 1l<<40;

int main(){
    int n;
    cin >> n;
    vecLong f(n+1);
    rep(i,1,n+1){
        for(int j=i;j<=n;j+=i) f[j]++;
    }
    ll ans = 0l;
    rep(i,1,n+1) ans += i * f[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81224
import bisect

N = int(input())
ans = 0
X = [int(input())for _ in range(N)]
A = []
for a in X[::-1]:
    if len(A) == 0:
        A.append(a)
    elif A[-1] <= a:
        A.append(a)
    else:
        i = bisect.bisect_right(A, a)
        A[i] = a

print(len(A))



Measured memory_bytes: 56792
import std.stdio,std.conv,std.string,std.algorithm,std.array;
void main(){
  auto a=readln();
  auto b=readln();
  auto c=readln();
  char A,B,C;
  A=a[0];
  B=b[1];
  C=c[2];
  write(A);
  write(B);
  write(C);
  writeln();
}

Measured memory_bytes: 256
N,M = map(int,input().split())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return sorted(lower_divisors + upper_divisors[::-1],reverse=True)

divisors = make_divisors(M)
for d in divisors:
    tmp = M // d
    if tmp >= N:
        print(d)
        break

Measured memory_bytes: 9124
/*
   AOJ 0131
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int n;
int ph[10][10];     //photon mult.
int ph_org[10][10];
int r[10][10];

void inv(int i,int j)
{

	    ph[i][j] ^=1;
	    if(i>0)
	      ph[i-1][j] ^=1;
	    if(i<9)
	      ph[i+1][j] ^=1;
	    if(j>0)
	      ph[i][j-1] ^=1;
	    if(j<9)
	      ph[i][j+1] ^=1;
}


void find1(int *y,int *x)
{
  int i,j;

  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      if(ph[i][j])
	{
	  *y=i;*x=j;
	  return;
	    }
  *y=*x=-1;
}
void output()
{
  int i,j;

  for(i=0;i<10;i++)
    {
      for(j=0;j<9;j++)
	printf("%d ",r[i][j]);
      printf("%d",r[i][9]);
      printf("\n");
    }
  //printf("---------\n");
}
void display()
{
  int i,j;

  for(i=0;i<10;i++)
    {
      for(j=0;j<10;j++)
	printf("%d ",ph[i][j]);
      printf("\n");
    }
  //printf("---------\n");
}

int is_all_off()
{
  int i,j;

  for(i=0;i<10;i++)
    for(j=0;j<10;j++)
      if(ph[i][j])
	return(0);
  return(-1);
}
void solve()
{
  int y,x,i,pos,bit;

  for(i=0;i<1024;i++)
    {
      memset(r,0,sizeof(int)*10*10);
      memcpy(ph,ph_org,sizeof(int)*10*10);

      for(pos=0;pos<10;pos++)
	{
	  bit = 1<<pos;
	  if(bit & i)
	    {
	      r[0][pos] ^= 1;
	      inv(0,pos);
	    }
	}
      //display();
      while(find1(&y,&x),y!=-1 && y < 9)
	{
	  r[y+1][x] = 1;
	  inv(y+1,x);
	
	  if(is_all_off())
	    return;
	}
    }
}

 


main()
{
  int i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<10;j++)
	for(k=0;k<10;k++)
	  scanf("%d",&ph_org[j][k]);
      solve();
      output();
    }
  return(0);
}

Measured memory_bytes: 604
a, b, c = map(int, input().split())

if a > b:
    x = b
    if a > c:
        y = c
        z = a
    else:
        y = a
        z = c
else:
    x = a
    if b > c:
        y = c
        z = b
    else:
        y = b
        z = c

if x < y:
    print('{} {} {}'.format(x, y, z))
else:
    print('{} {} {}'.format(y, x, z))


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



int main(){

  ll n;
  cin >> n;
  ll x[n];
  rep(i,n) cin >> x[i];
  ll L;
  cin >> L;
  ll Q;
  cin >> Q;
  ll a[Q],b[Q];
  rep(i,Q){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    if(a[i]>b[i]) swap(a[i],b[i]);
  }
  //  cout << a[n-1] << endl;
	    
  ll logn=ceil(log2((double) n));
  ll dou_hotel[n][logn]; 
  rep(k,logn){
    rep(i,n){
      dou_hotel[i][k]=INT_MAX;
    }
  }
  rep(i,n){
    if(i==0) dou_hotel[i][0] = 0;
    else dou_hotel[i][0]=dou_hotel[i-1][0];
    ll t= dou_hotel[i][0];
    while(t+1<=n-1){
      if(x[t+1]-x[i]>L) break;
      t++;
      //      if(t==n-1) t=n*2LL;
    }
    dou_hotel[i][0]=t;
  }
  rep(k,logn-1){
    rep(i,n){
      if(dou_hotel[i][k]==INT_MAX){
	dou_hotel[i][k+1]==INT_MAX;
      }
      else{
	dou_hotel[i][k+1] = dou_hotel[dou_hotel[i][k]][k];
      }
    }
  }
  rep(j,Q){
    ll ind;
    ll ch=a[j];
    ll ans=0;
    for(ll i=logn-1; i>=0; i--){
      /*      if(dou_hotel[ch][i]==b[j]){
	ans+=pow(2,i);
	break;
	}*/
      /* if(i==0) ans++;
      else if(dou_hotel[ch][i]>=b[j] && dou_hotel[ch][i-1]<b[j]){	
	ans+=pow(2,i-1);
	ch=dou_hotel[ch][i-1];
	i++;
	}*/
      if(dou_hotel[ch][i]<b[j]){
	ans+=pow(2,i);
	ch=dou_hotel[ch][i];       
      }
    }
    cout << ans+1 << endl;   
  }
    

  
  return 0;

}


Measured memory_bytes: 16512