akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(all(a));
    if (a[0] + a[1] == a[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int main(void){
	string s;
	ll k;
	cin>>s>>k;
	for(ll i=0;i<s.size();++i){
		if(s[i]!='1'){
			cout<<s[i]<<endl;
			return 0;
		}
 		if(i==k-1){
			cout<<s[i]<<endl;
			return 0;
		}
      
	}
	cout<<"1\n";
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut now = a[0];
    for i in 1..n {
        if a[i] < now {
            println!("No");
            return;
        } else if a[i] == now {
        } else {
            now = a[i] - 1;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 3656
def main():
    n = input()
    if n == 1:
        print 1
        return
    xy = []
    for _ in xrange(n):
        x, y = map(int, raw_input().split())
        xy.append([x, y])
    count = {}
    for i in xrange(n):
        x0, y0 = xy[i]
        for j in xrange(n):
            if i == j:
                continue
            x1, y1 = xy[j]
            key = (x1 - x0, y1 - y0)
            try:
                count[key] += 1
            except KeyError:
                count[key] = 1
    print n - max(count.values())


if __name__ == '__main__':
    main()


Measured memory_bytes: 31084
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N; cin >> N;
    int cnt[100010] = {0};
    int maxi = 0;

    REP(i, N){
        int num;
        cin >> num;
        cnt[num]++;
        cnt[num + 1]++;
        cnt[num - 1]++;
    }

    int res = 0;
    REP(i, 100001){
        res = max(res, cnt[i]);
    }
    cout << res << endl;

}

Measured memory_bytes: 640
A, B, C = map(int, input().split())
res = 0
while (not (A == B == C)):
    A, B, C = sorted((A, B, C))
    if A < B <= C:
        A += 2
        res += 1
    A, B, C = sorted((A, B, C))
    if A <= B < C:
        A += 1
        B += 1
        res += 1

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string s, ans;
    cin >> s;
    int n = s.size();

    ans = "Yes";
    rep(i, n){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                ans = "No";
                break;
            }
        } else {
            if(s[i] == 'R'){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  
  s3 = s % 10;
  s = s / 10;
  s2 = s % 10;
  s = s / 10;
  s1 = s % 10;
    
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// 二項係数計算
long long COM(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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
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;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int a,b; cin >> a >> b;
    if((a*b)%2!=0) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

Int dp[2005][2005];

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> s(n), t(m);
    for (Int i = 0; i < n ;i++) cin >> s[i];
    for (Int i = 0; i < m; i++) cin >> t[i];
    dp[0][0] = 1;
    for (Int i = 0; i <= n; i++) {
        for (Int j = 0; j <= m; j++) {
           if (i > 0 && j > 0 && s[i - 1] == t[j - 1]) dp[i][j] += dp[i - 1][j - 1];
           if (i > 0 && j > 0) dp[i][j] -= dp[i - 1][j - 1];
           if (i > 0) dp[i][j] += dp[i - 1][j];
           if (j > 0) dp[i][j] += dp[i][j - 1];
           dp[i][j] = (dp[i][j] + mod) % mod;
        }
    }
    dump(dp[n][m]);
    return 0;
}

Measured memory_bytes: 31616
n,k = map(int, input().split())
h = list(map(int, input().split()))
INF = 999999999999999999999999999
dp = [INF] * n
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))
    
print(dp[n-1])


Measured memory_bytes: 85572
import java.util.Scanner;

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

		String S = scan.next();

		long count = 0;
		int n = S.length();
		String[] Srow = new String[n];

		for (int i = 0; i < n; i++) {
			Srow[i] = S.substring(i, i+1);
		}

		if (n == 1) {
			count = Integer.parseInt(S);
		} else {
			for (int bit = 0; bit < Math.pow(2, n-1); bit++) {

				String[] temp = new String[n];
				String number = Srow[0];
				int tempIndex = 0;

				for (int shift = 0; shift < n-1; shift++) {
					if ((1&bit>>shift) == 1) {
						temp[tempIndex] = number;
						number = Srow[shift+1];
						tempIndex++;
					} else {
						number += Srow[shift+1];
					}
				}

				temp[tempIndex] = number;

				for (int wa = 0; wa < n; wa++) {
					if (temp[wa] != null) {
						count += Long.parseLong(temp[wa]);
					}
				}

			}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 21972
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
    for sum_w in range(W+1):
        if sum_w - w[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[N][W])

Measured memory_bytes: 148976
def main():
  S=input()

  N=len(S)
  s=S
  for i in range(len(s)//2):
    if s[i]!=s[len(s)-i-1]:
      print('No')
      return
  s=S[:(N-1)//2]
  for i in range(len(s)//2):
    if s[i]!=s[len(s)-i-1]:
      print('No')
      return
  s=S[(N+3)//2-1:]
  for i in range(len(s)//2):
    if s[i]!=s[len(s)-i-1]:
      print('No')
      return
  print('Yes')
  
main()



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    vector<int> A(N); iota(begin(A), end(A), 0);
    double sum = 0;
    int cnt = 0;
    do {
        for (int i = 0; i < N - 1; i++) {
            sum += hypot(X[A[i + 1]] - X[A[i]], Y[A[i + 1]] - Y[A[i]]);
        }
        cnt++;
    } while (next_permutation(begin(A), end(A)));
    cout << fixed << setprecision(9) << sum / cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
// see the editorial well explained in that  a good problem involving combinatorics
//implemented in systematic manner as explained in the editorial
//dry run for the sample test case
//solve sample test case on paper again
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long int modpow(int b, int p){
    long long int num = 1, power = b;
    for(int i=0; i<=30; i++){
        if((p>>i) & 1) num *= power;
        num %= MOD;
        power *= power;
        power %= MOD;
    }
    return num;
}
int main(){
    int n;
    cin >> n;
 
    int count = 0;
    map<pair<long long int, long long int>, int> ab;
    for(int i=0; i<n; i++){
        long long int a, b;
        cin >> a >> b;
 
        if(a == 0 && b == 0) count += 1;
        else{
            if(a == 0) b = 1;
            else if(b == 0) a = 1;
            else{
                long long int d = gcd(a,b);
                a /= d;
                b /= d;
                if(b < 0){ b *= -1; a *= -1; }
            }
 
            if(ab.find(make_pair(a,b)) == ab.end()) ab[make_pair(a,b)] = 1;
            else ab[make_pair(a,b)] += 1;
        }
    }
 
    long long int ans = 1;
    set<pair<long long int, long long int>> visited;
    for(auto p : ab){
        if(visited.find(p.first) != visited.end()) continue;
        long long int a = p.first.first;
        long long int b = p.first.second;
        int num = p.second;
 
      //  cout << "(" << a << ", " << b << ") : " << num << endl;
 
        long long int c = b;
        long long int d = a;
        if(d < 0){ c *= -1; d *= -1; }
        if(d != 0) c *= -1;
        //c *= -1;
        int cnum = 0;
        pair<long long int, long long int> cp = make_pair(c,d);
        if(ab.find(cp) != ab.end()) cnum = ab[cp];
 
      //  cout << "(" << c << ", " << d << ") : " << cnum << endl;
        
        long long int times = modpow(2, num) + modpow(2, cnum) - 1;
        times = (times % MOD + MOD) % MOD;
 
        ans *= times;
        ans %= MOD;
       // cout<<ans<<"\n";
 
        visited.insert(p.first);
        visited.insert(cp);
    }
    ans = ((ans - 1 + count) % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, a[100005];
int dp[100005];

int frog1(int index)
{
	if (index == n - 1)
		return 0;

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

	int left = abs(a[index] - a[index + 1]) + frog1(index + 1);

	int right = INT_MAX;

	if (index + 2 < n)
	{
		right = abs(a[index] - a[index + 2]) + frog1(index + 2);
	}

	return dp[index] = min(left, right);
}

int32_t main()
{
	FIO();
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	memset(dp, -1, sizeof(dp));

	cout << frog1(0);
	return 0;
}

Measured memory_bytes: 8276
fun main(args: Array<String>) {
    val (N, L1) = readLine()!!.split(" ").map(String::toInt)
    val L2 = N + L1 - 1
    if (L1 * L2 < 0) {
        println((L1..L2).sum())
    } else if (L2 <= 0) {
        println((L1 until L2).sum())
    } else {
        println((L1 + 1..L2).sum())
    }
}

Measured memory_bytes: 37868
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	int h, m;
	cin >> h >> m;

	double x = h * 30 + m * 0.5;
	
	double y = m * 6;

	double pi = acos(-1);

	auto in_radians = [&](double degree) {
		return (degree * pi) / 180;
	};

	double ans = a*a + b*b - 2 * a * b * cos(in_radians(x-y));

	ans = sqrt(ans);

	cout << fixed << setprecision(10) << ans;

	return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
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 N;
int x[10], y[10];

double dist(int k, int m) {
	double dx = x[k] - x[m];
	double dy = y[k] - y[m];
	return pow(dx * dx + dy * dy, 0.5);
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> x[i] >> y[i];
	}
	double sum = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++)v[i] = i + 1;

	do
	{
		for (int i = 0; i < N-1; i++)
		{
			sum += dist(v[i], v[i + 1]);
		}
	} while (next_permutation(v.begin(),v.end()));

	int Factorial = 1;
	for (int i = 2; i <= N; i++)
	{
		Factorial *= i;
	}
	cout << fixed << setprecision(10) << sum / Factorial << endl;
	return 0;
	
}

Measured memory_bytes: 4148
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> i2;
typedef pair<ll,ll> ll2;

ll n;

ll arr[100000];

bool larger(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num>2);
}

bool smaller(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    
    return (num<2);
}

bool works(ll num)
{
    
    for (ll i = 0; i < n; i++)
    {
        num -= num%arr[i];
    }
    return (num==2);
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    
    cin >> n;
    
    for (ll i = 0; i < n; i++) cin >> arr[i];
    
    ll s, l;
    
    ll lo = 1;
    ll hi = 1e14;
    
    while (hi > lo)
    {
        ll mid = (lo+hi)/2;
        if (smaller(mid)) lo = mid+1; //needs more
        else hi = mid;
    }
    
    s = lo;
    
    lo = 1;
    hi = 1e14;
    
    while (hi > lo)
    {
        ll mid = (lo+hi+1)/2;
        if (larger(mid)) hi = mid-1;
        else lo = mid;
    }
    
    l = lo;
    
    if (works(s) && works(l)) cout << s << ' ' << l << '\n';
    else cout << -1 << '\n';

    
    
    return 0;
    
}




Measured memory_bytes: 1024
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))

ll dp[18][100010];
//dp[k][n]=nを含み、n以下のk個の数からなるやつ
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,1,n+1){
		dp[1][i]=1;
		repp(j,i+i,n+1,i){
			rep(m,1,17)dp[m+1][j]+=dp[m][i];
		}
	}
	ll ans=0;
	if(k<18)rep(i,1,n+1)ans+=dp[k][i];
	printf("%lld\n",ans);
}


Measured memory_bytes: 14952
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
//#define d_arr(arr, h, w) rep(i,( (arr).size() ) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}
#define d_arr(arr, type) rep(i, sizeof(arr)/sizeof(arr)[0] ){ cout << "["; rep(j,sizeof(arr[0])/sizeof(type)) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}

class Coordinates
{
    public:
        int x;
        int y;

        Coordinates(){ x = 0; y = 0;};
        Coordinates(int a, int b) { x = a; y = b;}

        Coordinates operator+(Coordinates p)
        {
            Coordinates tmp;
            tmp.x = x + p.x;
            tmp.y = y + p.y;
            return tmp;
        }

        friend bool operator==(const Coordinates a, const Coordinates b)
        {
            return (a.x == b.x && a.y == b.y);
        }
        friend bool operator<(const Coordinates a, const Coordinates b)
        {
            return (a.x < b.x && a.y < b.y);
        }
        friend bool operator<=(const Coordinates a, const Coordinates b)
        {
            return (a.x <= b.x && a.y <= b.y);
        }
        void show() { cout << "(" <<  y << ", " << x << ")" << endl; }
};
typedef Coordinates Coo;


Coo dir[4] = { Coo(0,-1), Coo(1,0), Coo(0,1), Coo(-1,0) };


char grid[30][30];
bool isVisit[30][30];
//start_pos
Coo start;
int h,w;

int four_max(int a, int b, int c, int d);
int max(int a, int b);
void dfs(Coo s);

int main()
{
    while (cin >> w >> h) 
    {
        if( w == 0 && h ==0) {return 0;}
        for (int i = 0; i < h; i++) 
        {
            for (int j = 0; j < w; j++) 
            {
                cin >> grid[i][j];
                if (grid[i][j] == '@') 
                {
                    //Coo(x, y)
                    start = Coo(j, i);
                }
                //ついでにisVisit初期化
                isVisit[i][j]=false;
            }
        }
        isVisit[start.y][start.x] = true;
        dfs(start);
        int cnt = 0;
        rep(i,h)
        {
            rep(j,w)
            {
                if( isVisit[i][j] == true ) { cnt++; }
            }
        }

        cout << cnt << endl;
    }
    return 0;
}

//x,yから始まって最大行けるredの数返す関数
void dfs(Coo s)
{
    //s.show();
    vector<int> maxnum;
    rep(i, 4) 
    {
        Coo next = s + dir[i];
        //外に出てたら
        if ( next.y < 0 || next.x < 0  ||  h <= next.y || w <= next.x ) { continue; }
        //壁じゃなかったら
        if ( grid[next.y][next.x] == '#') { continue; }
        //既に訪れてたら
        if (isVisit[next.y][next.x] == true ) { continue; }

        isVisit[next.y][next.x] = true;
        dfs(next);
    }
    return;
}



int four_max(int a, int b, int c, int d)
{
    return max( max(a, b), max(c, d) );
}

int max(int a, int b) 
{
    if ( a > b)  { return a; }
    else         { return b; }
}

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);


int main(){
    IOS;

    lln x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    lln no = x / d;
    lln dis1 = x - (no*d);
    lln dis2 = abs(x - (no+1)*d);
    if(no >= k){
        cout << (x - (k*d)) << endl;
        return 0;
    }
    if(no%2){
        if(k%2) cout << dis1 << endl;
        else cout << dis2 << endl;
    }
    else{
        if(k%2) cout << dis2 << endl;
        else cout << dis1 << endl;
    }    
    return 0;    
}

Measured memory_bytes: 3608
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 3;

int n, x, m, res, wyn, occ[N], a[N];

signed main() {
  init_ios();
  cin >> n >> a[1] >> m;
  occ[a[1]] = 1;
  res = a[1];
  for (int i = 2; i <= n; ++i) {
    int val = a[i-1]*a[i-1]%m;
    if (occ[val] != 0) {
      res = 0;
      for (int j = 1; j < occ[val]; ++j)
        res += a[j];
      int cyk = 0;
      for (int j = occ[val]; j < i; ++j)
        cyk += a[j];
      int len = n-occ[val]+1;
      int ile = len/(i-occ[val]);
      res += cyk*ile;
      i += (ile-1)*(i-occ[val]);
      int v = val;
      while (i <= n) {
        res += v;
        v = (v*v)%m;
        ++i;
      }
      // cout<<"hm\n";
      cout<<res<<"\n";
      return 0;
    }
    a[i] = val;
    occ[val] = i;
    res += a[i];
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 4700
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1180
#include <fstream>
#include <deque>
#include <iostream>

// Other includes

using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) ((((lli) a) + ((lli) b))%MOD))
#define mult(a,b) ((int) ((((lli) a) * ((lli) b))%MOD))

int K;
deque<lli> pcs; // starts out as single digit

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> K;
    F0R(i,9) pcs.emplace_back(i+1);
    int bsi = 0;
    while (pcs.size()+bsi < K) {
        int sz = pcs.size();
        F0R(i,sz) {
            lli cur = pcs.front(); pcs.pop_front();
            if (cur%10 - 1 >= 0) pcs.emplace_back(cur*10+cur%10-1);
            pcs.emplace_back(cur*10+cur%10);
            if (cur%10+1 <= 9) pcs.emplace_back(cur*10+cur%10+1);
        }
        bsi += sz;
    }
    cout << pcs[K-bsi-1] << '\n';
}

Measured memory_bytes: 1280
#include<stdio.h>

int main()
{
	int i, h;
	int A[250];
	scanf("%d", &h);

	for(i = 1; i <= h; i++){ scanf("%d", &A[i]); }

	for(i = 1; i <= h; i++){
		printf("node %d: key = %d, ", i, A[i]);
		if(i != 1) printf("parent key = %d, ", A[i/2]);
		if(2*i <= h) printf("left key = %d, ", A[2*i]);
		if(2*i+1 <= h) printf("right key = %d, ", A[2*i+1]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
n,k = map(int,input().split())
a = [int(i)-1 for i in input().split()]
counter = 0
cur = 0
mem = [0]
fiv = [False]*n
fiv[0] = True
while True:
   if counter == k:
      ans = cur +1
      break
   cur = a[cur]
   
   #print(cur)
   
   mem.append(cur)
   counter += 1
   if fiv[cur]:
      if fiv[0] == True:
         fiv[0] = 0
      roop = counter -fiv[cur]
      k -= fiv[cur]
      k %= roop
      #print(k)
      ans = mem[k+fiv[cur]] +1
      break
   fiv[cur] = counter
   #print(counter,fiv,mem)
print(ans)

Measured memory_bytes: 32328
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main
{
    private static class Range {
        int from;
        int to;

        Range(int from, int to)
        {
            this.from = from;
            this.to = to;
        }
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = scanner.nextInt();
        }

        int[] hs = new int[n];
        for (int i = 0; i < n; i++) {
            hs[i] = 0;
        }

        int count = 0;
        while (true) {
            List<Range> ranges = new ArrayList<>();
            Integer start = null;
            boolean goal = true;
            for (int i = 0; i < n; i++) {
                if (xs[i] != hs[i]) {
                    goal = false;

                    if (start == null) {
                        start = i;
                    }
                }
                else {
                    if (start != null) {
                        ranges.add(new Range(start, i));
                        start = null;
                    }
                }
            }
            if (goal) {
                System.out.println(count);
                return;
            }

            if (start != null) {
                ranges.add(new Range(start, n));
            }

            for (Range range : ranges) {
                for (int i = range.from; i < range.to; i++) {
                    hs[i] += 1;
                }
                count++;
            }
        }
    }
}



Measured memory_bytes: 25172
def main():
    n, *v = map(int, open(0).read().split())
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    if be.index(max(be)) == bo.index(max(bo)):
        ve = max(be)
        vo = max(bo)
        be[be.index(ve)] = 0
        bo[bo.index(vo)] = 0
        print(min(n - ve - max(bo), n - vo - max(be)))
    else:
        print(n - max(be) - max(bo))
    return


main()


Measured memory_bytes: 14324
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int input_int(void)
{
	int i;
	cin >> i;
	return i;
}
int main()
{
	
	string word;
	cin >> word;
	if (word.substr(0, 1) == "S")
	{
		cout << "Cloudy" << endl;
	}
	if (word.substr(0, 1) == "C")
	{
		cout << "Rainy" << endl;
	}
	if (word.substr(0, 1) == "R")
	{
		cout << "Sunny" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
# n=int(input())
n=int(input())
a=list(map(int,input().split(" ")))
mat=[[(0,0) for i in range(n)] for j in range(n)]
for l in range(1,n+1):
	for i in range(n-l+1):
		j=i+l-1
		# print(i,j)
		# if(i<=j):
		if(i==j):
			x=a[i]
			y=-a[i]
			mat[i][j]=(x,y)
		else:
			# print(i+1)
			x=max(a[i]+mat[i+1][j][1],a[j]+mat[i][j-1][1])
			y=min(-a[i]+mat[i+1][j][0],-a[j]+mat[i][j-1][0])
			mat[i][j]=(x,y)
print(mat[0][n-1][0])
# print(mat)

Measured memory_bytes: 208520
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
	// your code goes here
 int n, k;
 string s;
 cin >> n >> k;
 cin >> s;
 if (s[k - 1] <= 'Z') s[k - 1] += 32;
 cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
items = [None] * n
for i in range(n):
    a, b = map(int, input().split())
    items[i] = (a+b, a, b)
items.sort(reverse=True)
ans = 0
for i in range(n):
    if i % 2: ans -= items[i][2]
    else: ans += items[i][1]
print(ans)


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n;
	cin >> n;
	string s = to_string(n);
	map<string, bool> mymp;
	queue<string> Q;
	Q.push("3");
	Q.push("5");
	Q.push("7");
	int res = 0;
	while (!Q.empty()){
		string tmp = Q.front();
		Q.pop();
		if (mymp.find(tmp) != mymp.end()) continue;
		mymp[tmp] = 1;
		if (stoi(tmp) <= n && SZ(tmp) >= 3 && tmp.find("3") != string::npos && tmp.find("5") != string::npos && tmp.find("7") != string::npos) {
			res++;
		}
		if (SZ(tmp) == SZ(s)) continue;
		Q.push(tmp + "7");
		Q.push(tmp + "5");
		Q.push(tmp + "3");
	}
	cout << res << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 3840
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< pii > C(M);
	rep(i, M) cin >> C[i].second >> C[i].first;
	sort(C.rbegin(), C.rend());
	sort(A.begin(), A.end());
	int j = 0;
	rep(i, N) {
		if (C[j].second <= 0) {
			j++;
		}
		if (j >= M)
			break;
		if (C[j].first < A[i])
			break;
		A[i] = C[j].first;
		C[j].second--;
	}
	int ans = 0;
	rep(i, N) ans += A[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (300)

double dpsss[MAX_N + 1][MAX_N + 1][MAX_N + 1];

int main() {
  // read inputs
  int N, as[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // solve dp
  // dpsss[i][j][k] : The expected number of times to roll the dice before
  //                  all the dishes are empty starting at a state where
  //                      i dishes have 1 sushi
  //                      j dishes have 2 sushis
  //                      k dishes have 3 sushis
  for (int k = 0; k <= N; k++) {
    for (int j = 0; j <= N - k; j++) {
      for (int i = 0; i <= N - k - j; i++) {
        const int total = i + j + k;
        dpsss[i][j][k] =
            (i > 0 ? 1.0 * i / total * dpsss[i - 1][j][k] : 0.0) +
            (j > 0 ? 1.0 * j / total * dpsss[i + 1][j - 1][k] : 0.0) +
            (k > 0 ? 1.0 * k / total * dpsss[i][j + 1][k - 1] : 0.0) +
            (total > 0 ? 1.0 * N / total : 0.0);
        // printf("i = %d, j = %d, k = %d, dpsss[i][j][k] = %lf\n", i, j, k,
        //        dpsss[i][j][k]);
      }
    }
  }

  // count number of dishes with each number of sushis on them
  int cnts[4] = {};
  for (int i = 0; i < N; i++) {
    cnts[as[i]]++;
  }
  printf("%.12lf\n", dpsss[cnts[1]][cnts[2]][cnts[3]]);
}

Measured memory_bytes: 213120
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

double solve(lint dist, double p){
    return dist / p;
}

int main(){
    lint x;
    int p_100;
    cin >> x >> p_100;
    double p = p_100 / 100.0;
    if(x % 2){
        fcout << 1 + p * solve(x / 2, p) + (1 - p) * solve(x / 2 + 1, p) << endl;
    }else{
        fcout << solve(x / 2, p) << endl;
    }
}



Measured memory_bytes: 256
import math

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

m=math.ceil( max(a*100/8,b*100/10) )
M=min( (a+1)*100/8 , (b+1)*100/10 ) - 0.0000001
M=math.floor(M)

if m>M:
    print(-1)
else:
    print(int(m))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

ll x;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>x;
    int k=1;
    while(x*k%360!=0)k++;
    cout<<k<<endl;
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  
  if(n==0) cout<<'0'<<endl;
  
  else{
  
  int count =1;
  for(int i=1;i<n;i++)
  {
		if(s[i]!=s[i-1]) count++;
    	
  }
  cout<<count<<endl;
  }
}  


Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std; 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
#define mode 1000000007
//=================================================================================
int mod(int x)
{
	if(x>=0)
		return x;
	else
		return -1*x;
}


//=================================================================================
int main() 
{
	fastio
	

	//int t=1; 
	//cin>>t; 
	ull ans=0;
	 
		int n;
		cin>>n;
		int arr[n+1],dp[n+5];
		memset(dp,0,sizeof(dp));
		memset(arr,0,sizeof(arr));
		dp[1]=0;

		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
			//cout<<arr[i]<<" ";
			
		}
		dp[2]=mod(arr[2]-arr[1]);
		for(int i=3;i<=n;i++)
		{
			dp[i]=min( (dp[i-1]+mod( arr[i] - arr[i-1] )), (dp[i-2]+mod(arr[i]-arr[i-2])));
		}
		// for(int i=1;i<=n;i++)
		// {
		// 	cout<<dp[i]<<" ";
		// }
		
		ans=dp[n];
		cout<<ans<<endl;
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0; 
} 



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

int main(){
    int a,b;
    cin >> a >> b;
   if(a == 1 && b == 2){
       cout << 3;
   }else if(a == 1 && b == 3){
       cout << 2;
   }else if(a == 2 && b == 1){
       cout << 3;
   }else if(a == 2 && b == 3){
       cout << 1;
   }else if(a == 3 && b == 1){
       cout << 2;
   }else if(a == 3 && b == 2){
       cout << 1;
   }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL n, x, count, mi = 100000;
	cin >> n >> x;
	vector<LL> m(n);
	count = n;

	for (LL i = 0; i < n; i++) {
		cin >> m[i];
		x -= m[i];
		mi = min(mi, m[i]);
	}
	cout << count + (x / mi) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define MAX 110

int main() {
	int n, T[MAX][3]; scanf("%d", &n);
	int x, y, h; bool isSet = false;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &T[i][0], &T[i][1], &T[i][2]);
		if (!isSet) if (T[i][2] != 0) { x = T[i][0]; y = T[i][1]; h = T[i][2]; isSet = true; }
	}
	
	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			int H = h + abs(x - Cx) + abs(y - Cy);
			bool check = true;

			for (int i = 0; i < n; i++) {
				int t = max(0, H - abs(T[i][0] - Cx) - abs(T[i][1] - Cy));
				if (t != T[i][2]) { check = false; break; }
			}
			if (check) { printf("%d %d %d\n", Cx, Cy, H); return 0; }
		}
	}
	
	return 0;
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int64_t a, ans;
  mp::cpp_dec_float_50 b;
  cin >> a >> b;

  b *= a;
  ans = (int64_t)b;

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3740
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    string s;cin>>s;
    int n=s.length();
    int win=0,lose=0;
    int pa=0,gu=0;//pa<=gu
    for(int i=0;i<n;i++){
        if(s[i]=='g'){
            if(pa<gu){
                pa++;
                win++;
            }
            else{
                gu++;
            }
        }
        else{
            if(pa<gu){
                pa++;
            }
            else{
                gu++;
                lose++;
            }
        }
    }
    cout<<win-lose<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 512
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
typedef long long ll;
const int MAXN = 2*1e5 + 10 ;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 1e9 + 7;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}
int main () {
    
    ll a,b,c ;
    cin >> a >> b >> c ;
    if(a+b >= c) cout<<b+c<<endl;
    else cout<<2*b + min(c-b,a) + (a >= c-b ? 0 : 1)<<endl;
    
    return 0 ;
}


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

int n,m;
vector<int> g[15];
int p[15];
bool on[15];
int ans;

void dfs(int cur){
    if(cur>n){
        for(int i=1;i<=m;i++){
            int cnt=0;
            for(int j=0;j<g[i].size();j++){
                int y=g[i][j];
                cnt+=on[y];
            }
            if(cnt%2!=p[i])return;
        }
        ans++;
        return;
    }
    for(int i=0;i<2;i++){
        on[cur]=i;
        dfs(cur+1);
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int k;
        cin>>k;
        while(k--){
            int t;
            cin>>t;
            g[i].push_back(t);
        }
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    dfs(1);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  auto c = b - a;
  int sum = 0;
  for (int i=1; i<=c; i++) {
    sum += i;
  }
  cout << sum - b << endl;
}

Measured memory_bytes: 256